]> Creatis software - creaMaracasVisu.git/blobdiff - bbtk/src/bbmaracasvisuShowNPoints.cxx
.
[creaMaracasVisu.git] / bbtk / src / bbmaracasvisuShowNPoints.cxx
index ef31b02838e5ad5a7c87e311998641c798337a7b..cf0a4de47774b00d88e415a94f4b0847ca056a78 100644 (file)
@@ -79,7 +79,13 @@ std::vector<int> WidgetShowNPoints::GetLstPointsZ()
        return lstPointsZ;
 }
 
-
+//------------------------------------------------------------------------
+       std::vector<std::string> WidgetShowNPoints::GetLstLabels()
+{
+       return lstLabels;
+}
+       
+       
 
 
 //------------------------------------------------------------------------
@@ -122,6 +128,7 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
                        lstPointsX.push_back( mpoint[0] );
                        lstPointsY.push_back( mpoint[1] );
                        lstPointsZ.push_back( mpoint[2] );
+                       lstLabels.push_back( (const char*) ( textCtrl->GetValue().mb_str() )  );
 
                        // Sphere
                        vtkSphereSource *vtksphere              = vtkSphereSource::New();
@@ -143,18 +150,15 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
                        renderer->AddActor( sphereActor );
                        
                        // Actor
-                       vtkTextActor3D *text = vtkTextActor3D::New();
-                       text->SetPosition(  mradio+spc[0]*mpoint[0] , spc[1]*mpoint[1] , spc[2]*mpoint[2] );
-                       text->SetInput( (const char*) ( textCtrl->GetValue().mb_str() )  );
-                       renderer->AddActor( text );
-                       lstActorsText.push_back(text);
+                       vtkTextActor3D *textActor = vtkTextActor3D::New();
+                       textActor->SetPosition(  mradio+spc[0]*mpoint[0] , spc[1]*mpoint[1] , spc[2]*mpoint[2] );
+                       textActor->SetInput( (const char*) ( textCtrl->GetValue().mb_str() )  );
+                       renderer->AddActor( textActor );
+                       lstActorsText.push_back(textActor);
                        
                        renderer->GetRenderWindow()->Render();
 
-                       //--BBTK
-                       mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsX"));    
-                       mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsY"));    
-                       mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsZ"));    
+                       SetOutputBox(); 
                        
                } else {//mpoint.size
                        printf("creaMaracasVisu::ShowNPoints (not match point) \n");
@@ -162,6 +166,18 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
        } // renderer
 }
 
+       void WidgetShowNPoints::SetOutputBox()
+       {
+               //--BBTK
+               mbbShowNPoints->bbSetOutputlstPointsX( GetLstPointsX() );
+               mbbShowNPoints->bbSetOutputlstPointsY( GetLstPointsY() );
+               mbbShowNPoints->bbSetOutputlstPointsZ( GetLstPointsZ() );
+               mbbShowNPoints->bbSetOutputlstLabels( GetLstLabels() );
+               mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsX"));    
+               mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsY"));    
+               mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsZ"));    
+               mbbShowNPoints->bbSignalOutputModification(std::string("lstLabels"));    
+       }
        
        //------------------------------------------------------------------------
        void WidgetShowNPoints::ErasePoint(int id)
@@ -174,14 +190,15 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
                                 lstActorsText[id]->Delete();
                                lstActorsSphere.erase( lstActorsSphere.begin()+id );
                                lstActorsText.erase( lstActorsText.begin()+id );
+                               
                                lstPointsX.erase( lstPointsX.begin()+id );
                                lstPointsY.erase( lstPointsY.begin()+id );
                                lstPointsZ.erase( lstPointsZ.begin()+id );
+                               lstLabels.erase( lstLabels.begin()+id );
+
                                renderer->GetRenderWindow()->Render();
-                               //--BBTK
-                               mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsX"));    
-                               mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsY"));    
-                               mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsZ"));    
+                               SetOutputBox(); 
+
                        } // if id
                } // if renderer
        }
@@ -217,30 +234,16 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
 //------------------------------------------------------------------------
 void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
 {
-       int i,size=lstActorsSphere.size();
-       if (this->renderer!=NULL){ 
-               for (i=0;i<size;i++)
-               {
-                       renderer->RemoveActor( lstActorsSphere[i] );
-                       renderer->RemoveActor( lstActorsText[i] );
-               }
-               lstActorsSphere.clear();
-               lstActorsText.clear();
-               lstPointsX.clear();
-               lstPointsY.clear();
-               lstPointsZ.clear();
-               renderer->GetRenderWindow()->Render();
-               //--BBTK
-               mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsX"));    
-               mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsY"));    
-               mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsZ"));    
-       } // renderer
+       int id,size=lstActorsSphere.size();
+       for (id=size-1;id>=0;id--)
+       {
+               ErasePoint(id);
+       }
+               
 }
 
 
 
-
-
 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ShowNPoints)
 BBTK_BLACK_BOX_IMPLEMENTATION(ShowNPoints,bbtk::WxBlackBox);
 
@@ -257,6 +260,7 @@ void ShowNPoints::Process()
                bbSetOutputlstPointsX( mwxwidget->GetLstPointsX() );
                bbSetOutputlstPointsY( mwxwidget->GetLstPointsY() );
                bbSetOutputlstPointsZ( mwxwidget->GetLstPointsZ() );
+               bbSetOutputlstLabels( mwxwidget->GetLstLabels() );
        } // mwxwidget
 }