]> Creatis software - creaMaracasVisu.git/commitdiff
#3485 ShowNPionts for Multiple Groups
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Thu, 19 May 2022 12:57:59 +0000 (14:57 +0200)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Thu, 19 May 2022 12:57:59 +0000 (14:57 +0200)
bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx
bbtk/src/bbmaracasvisuShowNPoints.cxx
bbtk/src/bbmaracasvisuViewerNV.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ViewShowNPoints.cxx [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/ViewShowNPoints.h [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h

index bae9e276b0ae2e7c62b32cad69896d698d83da76..02d0f4ad490f415f8720ec536c60e384d478ced8 100644 (file)
@@ -73,14 +73,14 @@ void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis)
        int lstpointsXsize =bbGetInputlstPointX().size();
        if( lstpointsXsize>0 )
        {
-               vtkPoints       *allPoints              = vtkPoints::New( );
-               vtkPolyLine *polyline           = vtkPolyLine::New();
-               vtkCellArrayallTopology       = vtkCellArray::New( );
+               vtkPoints        *allPoints             = vtkPoints::New( );
+               vtkPolyLine  *polyline          = vtkPolyLine::New();
+               vtkCellArray *allTopology       = vtkCellArray::New( );
 //             allTopology->InsertNextCell( numPoints );
                size=iGeneral+numPoints;
-        std::vector<double> lstX =bbGetInputlstPointX();
-        std::vector<double> lstY =bbGetInputlstPointY();
-        std::vector<double> lstZ =bbGetInputlstPointZ();
+        std::vector<double> lstX    = bbGetInputlstPointX();
+        std::vector<double> lstY    = bbGetInputlstPointY();
+        std::vector<double> lstZ    = bbGetInputlstPointZ();
                for (i=iGeneral;i<size;i++)
                {
                        //multiplicar ver parametros spacing, en maracas cuando se toca la imagen y se ve dycom
index e57135756ccf3dd2da59a388773d3f8ff9d004e1..661b6778b5d3400ea478b4b26ee98d051ada4059 100644 (file)
@@ -105,13 +105,11 @@ void ShowNPoints::Process()
                mwxwidget->SetColour( bbGetInputColour() );
                mwxwidget->SetOpacity( bbGetInputOpacity() );
                mwxwidget->SetRadio( bbGetInputRadio() );
-
                if ( mwxwidget->GetModelShowNPoints()->GetFirstTime()==true )
                {
                        mwxwidget->GetModelShowNPoints()->SetFirstTime(false);
                        mwxwidget->SetInitLstPoints( bbGetInputInitLstPointsX() , bbGetInputInitLstPointsY() , bbGetInputInitLstPointsZ() , bbGetInputInitLstLabels() );
                }
-
                bbSetOutputlstPointsX( mwxwidget->GetModelShowNPoints()->GetLstPointsX() );
                bbSetOutputlstPointsY( mwxwidget->GetModelShowNPoints()->GetLstPointsY() );
                bbSetOutputlstPointsZ( mwxwidget->GetModelShowNPoints()->GetLstPointsZ() );
index e46763547f9cc669a575e9c6783bb6b80de32774..2dcd98950f71a29c6c30e89fafb8d606d29086ce 100644 (file)
@@ -76,11 +76,8 @@ void bbwxMaracas_N_ViewersWidget::OnRefreshView(wxCommandEvent & event)
 //-------------------------------------------------------------
 void bbwxMaracas_N_ViewersWidget::OnDClickLeft(wxCommandEvent & event)
 {
-    printf("EED bbwxMaracas_N_ViewersWidget::OnDClickLeft 1\n");
        wxMaracas_N_ViewersWidget::OnDClickLeft(event);
-    printf("EED bbwxMaracas_N_ViewersWidget::OnDClickLeft 2\n");
        mbbViewerNV->bbSignalOutputModification(std::string("Point"));
-    printf("EED bbwxMaracas_N_ViewersWidget::OnDClickLeft 3\n");
 }
 
 //-------------------------------------------------------------
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ViewShowNPoints.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ViewShowNPoints.cxx
new file mode 100644 (file)
index 0000000..ac81dd7
--- /dev/null
@@ -0,0 +1,138 @@
+
+
+#include "ViewShowNPoints.h"
+
+
+//----------------------------------------------------------------------
+ViewShowNPoints::ViewShowNPoints(ModelShowNPoints* modelShowNPoints)
+{
+    renderer                    = NULL;
+    mmodelShowNPoints=modelShowNPoints;
+}
+//----------------------------------------------------------------------
+
+ViewShowNPoints::~ViewShowNPoints()
+{
+}
+
+
+//------------------------------------------------------------------------
+    
+void ViewShowNPoints::RefreshPoint(int id)
+{
+    double spc[3];
+    int x,y,z;
+    GetModelShowNPoints()->GetIdPoint(id,&x,&y,&z);
+    GetModelShowNPoints()->GetImage()->GetSpacing(spc);
+    std::string label     = GetModelShowNPoints()->GetIdLabel(id);
+    double radio         = GetModelShowNPoints()->GetRadio();
+    lstActorsSphere[id]->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
+    lstActorsSphere[id]->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
+    lstActorsSphere[id]->GetProperty()->SetOpacity( mopacity );
+    lstSourceSphere[id]->SetRadius( radio );
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+    // ..
+#else
+    lstSourceSphere[id]->Update();
+#endif
+    lstActorsText[id]->SetInput( label.c_str()  );
+    lstActorsText[id]->SetPosition(  radio+spc[0]*x , spc[1]*y , spc[2]*z );
+}
+
+//------------------------------------------------------------------------
+void ViewShowNPoints::RefreshPoints()
+{
+    int id,size=lstActorsSphere.size();
+    for (id=0;id<size;id++)
+    {
+        RefreshPoint(id);
+    } // for
+    renderer->GetRenderWindow()->Render();
+}
+
+//------------------------------------------------------------------------
+void ViewShowNPoints::AddVtkPoint()
+{
+    // Sphere
+    vtkSphereSource *vtksphere = vtkSphereSource::New();
+    vtksphere->SetThetaResolution (20);
+    vtksphere->SetPhiResolution (20);
+    vtksphere->SetRadius( 1 );
+    //NTU: For updating points
+    lstSourceSphere.push_back(vtksphere);
+    vtkPolyDataMapper *sphereMapper    = vtkPolyDataMapper::New();
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+    sphereMapper->SetInput( vtksphere->GetOutput() );
+#else
+    vtksphere->Update();
+    sphereMapper->SetInputData( vtksphere->GetOutput() );
+#endif
+
+    vtkActor *sphereActor    = vtkActor::New();
+    sphereActor->SetMapper(sphereMapper);
+    sphereActor->SetOrigin(0, 0, 0);
+
+    lstActorsSphere.push_back(sphereActor);
+    
+    if(renderer==NULL){
+    // EED 2022-05-19
+    //    wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
+    //    dialog.ShowModal();
+        printf("EED ShowNPoints Warning: Renderer Not Set\n");
+        return;
+    }
+    
+    renderer->AddActor( sphereActor );
+    // Actor
+    vtkTextActor3D *textActor = vtkTextActor3D::New();
+//    textActor->SetInput( strLabel.c_str()  );
+    renderer->AddActor( textActor );
+    lstActorsText.push_back(textActor);
+}
+
+//------------------------------------------------------------------------
+void ViewShowNPoints::AddPoint()
+{
+    AddVtkPoint();
+    RefreshPoint(lstActorsSphere.size()-1);
+}
+
+//------------------------------------------------------------------------
+void ViewShowNPoints::Render()
+{
+    renderer->GetRenderWindow()->Render();
+}
+
+//------------------------------------------------------------------------
+void ViewShowNPoints::ErasePoint(int id)
+{
+    if (this->renderer!=NULL)
+    {
+        if (id>=0)
+        {
+            renderer->RemoveActor( lstActorsSphere[id] );
+            renderer->RemoveActor( lstActorsText[id] );
+            lstActorsSphere[id]->Delete();
+            lstActorsText[id]->Delete();
+            lstSourceSphere[id]->Delete();
+            lstActorsSphere.erase( lstActorsSphere.begin()+id );
+            lstActorsText.erase( lstActorsText.begin()+id );
+            lstSourceSphere.erase( lstSourceSphere.begin()+id );
+        } // if id
+    } // if renderer
+}
+
+//------------------------------------------------------------------------
+ModelShowNPoints* ViewShowNPoints::GetModelShowNPoints()
+{
+    return mmodelShowNPoints;
+}
+
+//------------------------------------------------------------------------
+void ViewShowNPoints::SetModelShowNPoints( ModelShowNPoints*  modelShowNPoints)
+{
+    mmodelShowNPoints=modelShowNPoints;
+}
diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ViewShowNPoints.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ViewShowNPoints.h
new file mode 100644 (file)
index 0000000..168d86a
--- /dev/null
@@ -0,0 +1,43 @@
+
+#ifndef __ViewShowNPoints_h_INCLUDED__
+#define __ViewShowNPoints_h_INCLUDED__
+
+
+#include "vtkActor.h"
+#include <vtkTextActor3D.h>
+#include <vtkRenderer.h>
+#include <vtkSphereSource.h>
+#include "vtkProperty.h"
+#include "vtkPolyDataMapper.h"
+#include "vtkRenderWindow.h"
+#include <vtkTextProperty.h>
+
+#include "ModelShowNPoints.h"
+
+class ViewShowNPoints
+  {
+       public:
+         ViewShowNPoints(ModelShowNPoints* modelShowNPoints);
+         ~ViewShowNPoints();
+      ModelShowNPoints* GetModelShowNPoints();
+      void SetModelShowNPoints(ModelShowNPoints* modelShowNPoints);
+      void RefreshPoint(int id);
+      void RefreshPoints();
+      void AddVtkPoint();
+      void AddPoint();
+      void Render();
+      void ErasePoint(int id);
+      
+      std::vector<vtkActor*>            lstActorsSphere;//NTU changed from prop3D to Actor
+      std::vector<vtkTextActor3D*>      lstActorsText;
+      std::vector<vtkSphereSource*>     lstSourceSphere;
+      std::vector<double>               mcolour;
+      double                            mopacity;
+      vtkRenderer*                      renderer;
+       private:
+      ModelShowNPoints*                 mmodelShowNPoints;
+  };
+
+#endif // __ViewShowNPoints_h_INCLUDED__
+
+
index 1a5a8dca32c971dab43839430aef052b5ff69c88..f7fa68f29570aefedf98041f7cb6a7350fc772f6 100644 (file)
@@ -1,15 +1,10 @@
 
 
-#include "vtkActor.h"
 #include "vtkSphereSource.h"
 #include "vtkRenderer.h"
 #include "vtkTextActor3D.h"
 
 
-#include "vtkProperty.h"
-#include "vtkPolyDataMapper.h"
-#include "vtkRenderWindow.h"
-#include <vtkTextProperty.h>
 
 #include <wx/button.h>
 #include <wx/sizer.h>
   WidgetShowNPoints::WidgetShowNPoints(wxWindow *parent, int type)
     : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
   {
-       mmodelShowNPoints                               = new ModelShowNPoints();
+       // EED 2022-05-19
+    //  mmodelShowNPoints                               = new ModelShowNPoints();
+      mActualLstPoints=0;
+      ModelShowNPoints* modelShowNPoints = new ModelShowNPoints();
+      lstModelShowNPoints.push_back( modelShowNPoints );
+      lstViewShowNPoints.push_back( new  ViewShowNPoints( modelShowNPoints ) );
+      
+      
     mtype                                                      = type;
     SetType(mtype);
-    this->renderer                                     = NULL;
     wxPanel    *panel                                  = this;
     wxSizer *sizer                                     = NULL;
 
         sizer1->Add(btnDeleteAllPoints);
         sizer1->Add(spacer);
         sizer1->Add(textCtrl);
-        sdrOpacity = new wxSlider();
-        sdrRadio = new wxSlider();
+        sdrOpacity  = new wxSlider();
+        sdrRadio    = new wxSlider();
         txtNrPoints = new wxStaticText(panel, -1, _T("\n\n\n"));
         sizer = sizer1;
        } // bbGetInputType 2
@@ -164,14 +165,29 @@ WidgetShowNPoints::~WidgetShowNPoints()
 //------------------------------------------------------------------------
 ModelShowNPoints* WidgetShowNPoints::GetModelShowNPoints()
 {
-       return mmodelShowNPoints;
+    // EED 2022-05-19
+    // return mmodelShowNPoints;
+    return lstModelShowNPoints[ mActualLstPoints ];
+}
+
+// EED 2022-05-19
+//------------------------------------------------------------------------
+ViewShowNPoints* WidgetShowNPoints::GetViewShowNPoints()
+{
+    return lstViewShowNPoints[ mActualLstPoints ];
 }
 
 
 //------------------------------------------------------------------------
 void WidgetShowNPoints::SetRadio(double radio)
 {
-       GetModelShowNPoints()->SetRadio(radio);
+    // EED 2022-05-19
+    // GetModelShowNPoints()->SetRadio(radio);
+    int i,size = lstModelShowNPoints.size();
+    for (i=0;i<size;i++)
+    {
+        lstModelShowNPoints[i]->SetRadio( radio );
+    } // for i
        //NTU: For Slider
        sdrRadio->SetValue(radio);
 }
@@ -179,61 +195,77 @@ void WidgetShowNPoints::SetRadio(double radio)
 //------------------------------------------------------------------------
 void WidgetShowNPoints::SetColour(std::vector<double> colour)
 {
-       this->mcolour = colour;
+    // EED 2022-05-19
+    //this->mcolour = colour;
+    int i,size = lstViewShowNPoints.size();
+    for (i=0 ; i<size ; i++)
+    {
+        lstViewShowNPoints[i]->mcolour = colour;
+    } // for i
 }
 
 //------------------------------------------------------------------------
 void WidgetShowNPoints::SetImage(vtkImageData* image)
 {
-       GetModelShowNPoints()->SetImage(image);
+    // EED 2022-05-19
+       //GetModelShowNPoints()->SetImage(image);
+    int i,size = lstModelShowNPoints.size();
+    for (i=0 ; i<size ; i++)
+    {
+        lstModelShowNPoints[i]->SetImage(image);
+    } // for i
 }
 
 //------------------------------------------------------------------------
 void WidgetShowNPoints::SetOpacity(double opacity)
 {
-       this->mopacity=opacity;
+    // EED 2022-05-19
+       //this->mopacity=opacity;
+    int i,size = lstViewShowNPoints.size();
+    for (i=0 ; i<size ; i++)
+    {
+        lstViewShowNPoints[i]->mopacity = opacity;
+    } // for i
        //NTU: For Slider
-       sdrOpacity->SetValue(this->mopacity*100.0);
+       sdrOpacity->SetValue( opacity*100.0 );
 }
 
 
 //------------------------------------------------------------------------
 void  WidgetShowNPoints::SetRenderer(vtkRenderer *renderer)
 {
-       this->renderer  = renderer;
+    // EED 2022-05-19
+       //this->renderer        = renderer;
+    int i,size = lstViewShowNPoints.size();
+    for (i=0 ; i<size ; i++)
+    {
+        lstViewShowNPoints[i]->renderer = renderer;
+    } // for i
 }
-       
+
+/* EED 2022-05-19
 //------------------------------------------------------------------------
        
 void WidgetShowNPoints::RefreshPoint(int id)
 {
        double spc[3];
-
-//EED 2016/06/17
-//     mimage->GetSpacing(spc);
-//     int x = lstPointsX[id];
-//     int y = lstPointsY[id];
-//     int z = lstPointsZ[id];
        int x,y,z;
        GetModelShowNPoints()->GetIdPoint(id,&x,&y,&z);
        GetModelShowNPoints()->GetImage()->GetSpacing(spc);
        std::string label       = GetModelShowNPoints()->GetIdLabel(id);
        double radio            = GetModelShowNPoints()->GetRadio();
-
-       lstActorsSphere[id]->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
-       lstActorsSphere[id]->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
-       lstActorsSphere[id]->GetProperty()->SetOpacity( mopacity );
-       lstSourceSphere[id]->SetRadius( radio );
-
+    lstActorsSphere[id]->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
+    lstActorsSphere[id]->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
+    lstActorsSphere[id]->GetProperty()->SetOpacity( mopacity );
+    lstSourceSphere[id]->SetRadius( radio );
 //EED 2017-01-01 Migration VTK7
 #if VTK_MAJOR_VERSION <= 5
        // ..
 #else
-       lstSourceSphere[id]->Update();
+    lstSourceSphere[id]->Update();
 #endif
-
-       lstActorsText[id]->SetInput( label.c_str()  );
-       lstActorsText[id]->SetPosition(  radio+spc[0]*x , spc[1]*y , spc[2]*z );
+    lstActorsText[id]->SetInput( label.c_str()  );
+    lstActorsText[id]->SetPosition(  radio+spc[0]*x , spc[1]*y , spc[2]*z );
 }
 
 //------------------------------------------------------------------------
@@ -284,39 +316,47 @@ void WidgetShowNPoints::AddVtkPoint()
        renderer->AddActor( textActor );
        lstActorsText.push_back(textActor);
 }
+ */
 
 
 //------------------------------------------------------------------------
 void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
 {
        GetModelShowNPoints()->AddPoint(x,y,z, label );
-       AddVtkPoint();
-       RefreshPoint(lstActorsSphere.size()-1);
+    // EED 2022-05-19
+    //AddVtkPoint();
+    //RefreshPoint(lstActorsSphere.size()-1);
+    GetViewShowNPoints()->AddPoint();
 }
 
-
-
 //------------------------------------------------------------------------
 void WidgetShowNPoints::InsertPoint(int x, int y, int z, std::string label)//CFT
 {
+    // EED 2022-05-19
+       //if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
+       //{
+    //    AddVtkPoint();
+       //} else {
+       //      AddPoint(x,y,z,label);
+       //}
+       //RefreshPoints();
+    if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
+    {
+        GetViewShowNPoints()->AddVtkPoint();
+    } else {
+        AddPoint(x,y,z,label);
+    }
+    GetViewShowNPoints()->RefreshPoints();
 
-//--
-       if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
-       {
-               AddVtkPoint();
-       } else {
-               AddPoint(x,y,z,label);
-       }
-       RefreshPoints();
-       //end if
 }
 
-
 //------------------------------------------------------------------------
 void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
 {      
-       if (this->renderer==NULL)
-       { 
+    // EED 2022-05-19
+       //if (this->renderer==NULL)
+    if (GetViewShowNPoints()->renderer==NULL)
+       {
                return;
        }
 
@@ -325,7 +365,9 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
        {
                AddPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
                SetOutputBox();
-               renderer->GetRenderWindow()->Render();
+        // EED 2022-05-19
+        //renderer->GetRenderWindow()->Render();
+        GetViewShowNPoints()->Render();
        } else {//mpoint.size
                printf("creaMaracasVisu::ShowNPoints (not match point) \n");
        }
@@ -334,8 +376,10 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
 //------------------------------------------------------------------------
 void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
 {      
-       if (this->renderer==NULL)
-       { 
+    // EED 2022-05-19
+    //if (this->renderer==NULL)
+    if (GetViewShowNPoints()->renderer==NULL)
+       {
                return;
        }
 
@@ -356,7 +400,7 @@ void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
 //EED          renderer->GetRenderWindow()->Render();
                wxString strTmp;
                strTmp.Printf(_T("Nbr of points: %d"), GetModelShowNPoints()->GetLstPointsSize() );
-               txtNrPoints->SetLabel(  strTmp );
+               txtNrPoints->SetLabel( strTmp );
                //--BBTK
 
 //EED 2017-06-03
@@ -391,13 +435,9 @@ void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
                                             wxDefaultPosition);
 #endif
 
-
-
                int result_FD = FD->ShowModal();
-               
                // This line is need it by windows //EED
                FD->SetReturnCode( result_FD );
-
                if (FD->GetReturnCode()==wxID_OK)
                {
                        std::string filename= (const char*) ( FD->GetPath().mb_str() ); 
@@ -440,12 +480,15 @@ void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
                        int numberPointsRead = GetModelShowNPoints()->ReadPoints( filename );
                        for (i=0;i<numberPointsRead;i++)
                        {
-                               AddVtkPoint();
+                // EED 2022-05-19
+                //AddVtkPoint();
+                GetViewShowNPoints()->AddVtkPoint();
                        }// for
                        SetOutputBox();
-                       RefreshPoints();
+            // EED 2022-05-19
+                       //RefreshPoints();
+            GetViewShowNPoints()->RefreshPoints();
                }       // dialog box
-
        }
 
        //------------------------------------------------------------------------
@@ -462,8 +505,11 @@ void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
                if (id>=0)
                {
                        GetModelShowNPoints()->SetPointId_mReferencePoint(id);
-                       RefreshPoint(id);
-                       renderer->GetRenderWindow()->Render();
+            // EED 2022-05-19
+                       //RefreshPoint(id);
+                       //renderer->GetRenderWindow()->Render();
+            GetViewShowNPoints()->RefreshPoint(id);
+            GetViewShowNPoints()->Render();
                } // if id
                SetOutputBox();
        }
@@ -474,27 +520,34 @@ void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
                int id = GetModelShowNPoints()->RenamePoint( (const char*) ( textCtrl->GetValue().mb_str() ) );
                if (id>=0)
                {
-                       lstActorsText[id]->SetInput(  (const char*) ( textCtrl->GetValue().mb_str() ) );
-                       SetOutputBox();
-                       renderer->GetRenderWindow()->Render();
+            // EED 2022-05-19
+                       //lstActorsText[id]->SetInput(  (const char*) ( textCtrl->GetValue().mb_str() ) );
+                       //renderer->GetRenderWindow()->Render();
+            GetViewShowNPoints()->lstActorsText[id]->SetInput(  (const char*) ( textCtrl->GetValue().mb_str() ) );
+            GetViewShowNPoints()->Render();
+            SetOutputBox();
                }
        }
 
 //------------------------------------------------------------------------
        void WidgetShowNPoints::ErasePoint(int id)
        {
-               if (this->renderer!=NULL)
+        // EED 2022-05-19
+               //if (this->renderer!=NULL)
+        if (GetViewShowNPoints()->renderer!=NULL)
                {
                        if (id>=0)
                        {
-                               renderer->RemoveActor( lstActorsSphere[id] );
-                               renderer->RemoveActor( lstActorsText[id] );
-                               lstActorsSphere[id]->Delete();
-                               lstActorsText[id]->Delete();
-                               lstSourceSphere[id]->Delete();
-                               lstActorsSphere.erase( lstActorsSphere.begin()+id );
-                               lstActorsText.erase( lstActorsText.begin()+id );
-                               lstSourceSphere.erase( lstSourceSphere.begin()+id );
+                // EED 2022-05-19
+                               //renderer->RemoveActor( lstActorsSphere[id] );
+                               //renderer->RemoveActor( lstActorsText[id] );
+                               //lstActorsSphere[id]->Delete();
+                               //lstActorsText[id]->Delete();
+                               //lstSourceSphere[id]->Delete();
+                               //lstActorsSphere.erase( lstActorsSphere.begin()+id );
+                               //lstActorsText.erase( lstActorsText.begin()+id );
+                               //lstSourceSphere.erase( lstSourceSphere.begin()+id );
+                GetViewShowNPoints()->ErasePoint(id);
                                GetModelShowNPoints()->ErasePoint(id);
                        } // if id
                } // if renderer
@@ -505,27 +558,37 @@ void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
        {
                ErasePoint( GetModelShowNPoints()->IdInsidePoint() );
                SetOutputBox();
-               renderer->GetRenderWindow()->Render();
+        // EED 2022-05-19
+               //renderer->GetRenderWindow()->Render();
+        GetViewShowNPoints()->Render();
        }
 
 //------------------------------------------------------------------------
        void WidgetShowNPoints::OnEraseLastPoint(wxCommandEvent& event)
        {
-               ErasePoint(lstActorsSphere.size()-1);
-               SetOutputBox();
-               renderer->GetRenderWindow()->Render();
+        // EED 2022-05-19
+        //ErasePoint( lstActorsSphere.size()-1 );
+        //renderer->GetRenderWindow()->Render();
+        int id = GetViewShowNPoints()->lstActorsSphere.size()-1;
+        ErasePoint( id );
+        GetViewShowNPoints()->Render();
+        SetOutputBox();
        }
 
 //------------------------------------------------------------------------
 void WidgetShowNPoints::DeleteAllPoints()
 {
-       int id,size=lstActorsSphere.size();
+    // EED 2022-05-19
+       //int id,size=lstActorsSphere.size();
+    int id,size=GetViewShowNPoints()->lstActorsSphere.size();
        for (id=size-1;id>=0;id--)
        {
                ErasePoint(id);
        }
        SetOutputBox();
-       renderer->GetRenderWindow()->Render();
+    // EED 2022-05-19
+       //renderer->GetRenderWindow()->Render();
+    GetViewShowNPoints()->Render();
 }
 
 //------------------------------------------------------------------------
@@ -539,18 +602,20 @@ void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
 //------------------------------------------------------------------------
 void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event)
 {
-       //Difference in Radio for text placement
-//     double radio=GetModelShowNPoints()->GetRadio();
-       this->mopacity = sdrOpacity->GetValue()/100.0;
-       GetModelShowNPoints()->SetRadio( sdrRadio->GetValue() ) ;
-//     radio = sdrRadio->GetValue();
-       //NTU refresh the inputs
-
-//EED 2017-06-03
-//     mbbShowNPoints->bbSetInputOpacity(this->mopacity);
-//     mbbShowNPoints->bbSetInputRadio( radio );
-       // EED 
-       RefreshPoints();
+    // EED 2022-05-19
+       //this->mopacity = sdrOpacity->GetValue()/100.0;
+    //GetModelShowNPoints()->SetRadio( sdrRadio->GetValue() ) ;
+    //RefreshPoints();
+
+    double opacity  = sdrOpacity->GetValue()/100.0;
+    double radio    = sdrRadio->GetValue();
+    int i,size      = lstViewShowNPoints.size();
+    for (i=0 ; i<size ; i++)
+    {
+        lstViewShowNPoints[i]->mopacity = opacity;
+        lstModelShowNPoints[i]->SetRadio( radio ) ;
+    } // for i
+    GetViewShowNPoints()->RefreshPoints();
 }
 
 //------------------------------------------------------------------------
@@ -562,23 +627,21 @@ void  WidgetShowNPoints::SetReferencePoint(std::vector<int> point)
 //------------------------------------------------------------------------
 void  WidgetShowNPoints::SetInitLstPoints( std::vector<int> initLstPointsX,  std::vector<int> initLstPointsY, std::vector<int> initLstPointsZ, std::vector<std::string> initLstLabels )
 {
-       if (this->renderer==NULL)
-       { 
+    // EED 2022-05-19
+       //if (this->renderer==NULL)
+    if (GetViewShowNPoints()->renderer==NULL)
+       {
                return;
        }
-
        int i,sizeX,sizeY,sizeZ,sizeLabels;
        sizeX=(int)initLstPointsX.size();
        sizeY=(int)initLstPointsY.size();
        sizeZ=(int)initLstPointsZ.size();
        sizeLabels=(int)initLstLabels.size();
-
        int x,y,z;
        std::string label;
-
        if ( (sizeX==sizeY) && (sizeX==sizeZ) )
        {
-
                for (i=0;i<sizeX;i++)
                {
                        x               = initLstPointsX[i];
@@ -594,9 +657,9 @@ void  WidgetShowNPoints::SetInitLstPoints( std::vector<int> initLstPointsX,  std
                } // for i
                //      SetOutputBox(); 
                //      renderer->GetRenderWindow()->Render();
-
        } // if size
 }
+
 //------------------------------------------------------------------------
 void WidgetShowNPoints::SetType(int type)
 {
@@ -615,11 +678,8 @@ double WidgetShowNPoints::GetRadio()
 {
        return sdrRadio->GetValue();
 }
-
 //------------------------------------------------------------------------
 double WidgetShowNPoints::GetOpacity()
 {
-       return mopacity;
+       return sdrOpacity->GetValue()/100;
 }
-
-
index 05fa5f15092a7850d958645c728770230947c7b7..e1308c3f6ad135f38f4434c877ea46733f7f7aa7 100644 (file)
@@ -7,14 +7,12 @@
 
 
 #include "ModelShowNPoints.h"
+#include "ViewShowNPoints.h"
 
 #include <wx/panel.h>
 #include <wx/textctrl.h>
 #include <wx/slider.h>
 #include <wx/stattext.h>
-#include <vtkRenderer.h>
-#include <vtkTextActor3D.h>
-#include <vtkSphereSource.h>
 
 
 class WidgetShowNPoints : public wxPanel
@@ -34,8 +32,11 @@ class WidgetShowNPoints : public wxPanel
 
          virtual void UpdatePoints(wxCommandEvent &event);
          
-         void RefreshPoint(int id);
-         
+    // EED 2022-05-19
+         //void RefreshPoint(int id);
+      //void RefreshPoints();
+      //void AddVtkPoint();
+
          void SetColour(std::vector<double> colour);
          void SetOpacity(double opacity);
          void SetRadio(double radio);
@@ -48,8 +49,7 @@ class WidgetShowNPoints : public wxPanel
          void DeleteAllPoints();
 
          ModelShowNPoints* GetModelShowNPoints();
-         void RefreshPoints();
-         void AddVtkPoint();
+      ViewShowNPoints* GetViewShowNPoints();
          void SetInitLstPoints( std::vector<int> initLstPointsX,  std::vector<int> initLstPointsY, std::vector<int> initLstPointsZ, std::vector<std::string> initLstLabels );
 
                void SetType(int type);
@@ -62,21 +62,29 @@ class WidgetShowNPoints : public wxPanel
          virtual void                                  SetOutputBox();
 
   private:
-         void                                  ErasePoint(int id);
-         vtkRenderer                   *renderer;
-         std::vector<vtkActor*>        lstActorsSphere;//NTU changed from prop3D to Actor
-         std::vector<vtkTextActor3D*>  lstActorsText;
+         void                                      ErasePoint(int id);
+    
+      // EED 2022-05-19
+      //vtkRenderer                       *renderer;
+         //std::vector<vtkActor*>            lstActorsSphere;//NTU changed from prop3D to Actor
+         //std::vector<vtkTextActor3D*>      lstActorsText;
+      //std::vector<vtkSphereSource*>     lstSourceSphere;
+      //std::vector<double>               mcolour;
+      //ModelShowNPoints                *mmodelShowNPoints;
+      //double                            mopacity;
+      std::vector<ViewShowNPoints*>     lstViewShowNPoints;
+
          //NTU: For updating points
-         std::vector<vtkSphereSource*> lstSourceSphere;
-         std::vector<double>                   mcolour;
-         wxStaticText                          *askPointLabel;
-         wxTextCtrl                            *textCtrl;
-         wxStaticText                          *txtNrPoints;
-         wxSlider                              *sdrOpacity;
-         wxSlider                              *sdrRadio;
-         ModelShowNPoints                              *mmodelShowNPoints;
-         int                                                   mtype;
-         double                                mopacity;
+         wxStaticText                              *askPointLabel;
+         wxTextCtrl                                *textCtrl;
+         wxStaticText                              *txtNrPoints;
+         wxSlider                                  *sdrOpacity;
+         wxSlider                                  *sdrRadio;
+    
+    std::vector<ModelShowNPoints*>    lstModelShowNPoints;
+      int                               mActualLstPoints;
+  
+         int                                                       mtype;
 };