]> Creatis software - creaMaracasVisu.git/blobdiff - bbtk/src/bbmaracasvisuShowNPoints.cxx
*** empty log message ***
[creaMaracasVisu.git] / bbtk / src / bbmaracasvisuShowNPoints.cxx
index 21cb59119c24f6b21d73e3bc97fe954ffb12c98a..83d7fe2a6c03597899453dfa2c0edf9104549248 100644 (file)
@@ -19,7 +19,7 @@ namespace bbcreaMaracasVisu
     this->renderer                             = NULL;
        wxPanel *panel                          = this;
     wxSizer *sizer                             = NULL;
-       
+
 
        // Widget interface
        textCtrl                                                = new wxTextCtrl(panel, -1);
@@ -32,7 +32,7 @@ namespace bbcreaMaracasVisu
        wxButton *btnLoadPoints                 = new wxButton( panel, -1, _T("Load points"));
        txtNrPoints                                             = new wxStaticText(panel,-1, _T(" "));
 
-       wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1); 
+       wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
 //    sizer1->Add(new wxStaticText(panel,-1,_T("  ")));
 
          Connect(btnAddPoint->GetId()                  , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint);
@@ -56,8 +56,8 @@ namespace bbcreaMaracasVisu
          sizer = sizer1;
          panel ->      SetSizer(sizer);
          panel ->      SetAutoLayout(true);
-         panel ->      Layout();  
-       
+         panel ->      Layout();
+
 }
 
 
@@ -94,8 +94,8 @@ std::vector<int> WidgetShowNPoints::GetLstPointsZ()
 {
        return lstLabels;
 }
-       
-       
+
+
 
 
 //------------------------------------------------------------------------
@@ -138,7 +138,7 @@ std::string WidgetShowNPoints::CleanSpaces(std::string ss)
        }
        return ss;
 }
-       
+
 //------------------------------------------------------------------------
 void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
 {
@@ -147,14 +147,14 @@ void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
        lstPointsZ.push_back( z );
 
        std::string strLabel = CleanSpaces(  label );
-       
+
        lstLabels.push_back( strLabel );
-       
+
        // Sphere
        vtkSphereSource *vtksphere              = vtkSphereSource::New();
        vtksphere->SetThetaResolution (20);
        vtksphere->SetPhiResolution (20);
-       vtksphere->SetRadius( mradio  ); 
+       vtksphere->SetRadius( mradio  );
        vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
        sphereMapper->SetInput( vtksphere->GetOutput() );
        vtkActor *sphereActor   = vtkActor::New();
@@ -165,58 +165,58 @@ void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
        sphereActor->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
        sphereActor->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
        sphereActor->GetProperty()->SetOpacity( mopacity );
-       
+
        lstActorsSphere.push_back(sphereActor);
        renderer->AddActor( sphereActor );
-       
+
        // Actor
        vtkTextActor3D *textActor = vtkTextActor3D::New();
        textActor->SetPosition(  mradio+spc[0]*x , spc[1]*y , spc[2]*z );
        textActor->SetInput( strLabel.c_str()  );
        renderer->AddActor( textActor );
        lstActorsText.push_back(textActor);
-       
-       SetOutputBox(); 
-       
+
+       SetOutputBox();
+
 }
-       
+
 //------------------------------------------------------------------------
 void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
 {
-       if (this->renderer!=NULL){ 
+       if (this->renderer!=NULL){
                if (mpoint.size()==3){
-                       AddPoint(mpoint[0],mpoint[1],mpoint[2], (const char*) ( textCtrl->GetValue().mb_str() ) );                      
+                       AddPoint(mpoint[0],mpoint[1],mpoint[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
                } else {//mpoint.size
                        printf("creaMaracasVisu::ShowNPoints (not match point) \n");
                }
        } // renderer
 }
 
-       
+
        //------------------------------------------------------------------------
        void WidgetShowNPoints::SetOutputBox()
        {
                renderer->GetRenderWindow()->Render();
                wxString strTmp;
-               strTmp.Printf("Nbr of points: %d", (int)(lstPointsX.size()) );
+               strTmp.Printf(_T("Nbr of points: %d"), (int)(lstPointsX.size()) );
                txtNrPoints->SetLabel(  strTmp );
-               
+
                //--BBTK
                mbbShowNPoints->bbSetOutputlstPointsX( lstPointsX );
                mbbShowNPoints->bbSetOutputlstPointsY( lstPointsY );
                mbbShowNPoints->bbSetOutputlstPointsZ( lstPointsZ );
                mbbShowNPoints->bbSetOutputlstLabels( lstLabels );
-               mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsX"));    
-               mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsY"));    
-               mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsZ"));    
-               mbbShowNPoints->bbSignalOutputModification(std::string("lstLabels"));    
+               mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsX"));
+               mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsY"));
+               mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsZ"));
+               mbbShowNPoints->bbSignalOutputModification(std::string("lstLabels"));
        }
-       
+
        //------------------------------------------------------------------------
        void WidgetShowNPoints::OnSavePoints(wxCommandEvent& event)
        {
-               
-               wxFileDialog* FD = new wxFileDialog( 0, 
+
+               wxFileDialog* FD = new wxFileDialog( 0,
                                                                                        _T("Save points .."),
                                                                                        _T(""),
                                                                                        _T(""),
@@ -224,12 +224,12 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
                                                                                         wxSAVE | wxOVERWRITE_PROMPT,
                                                                                        wxDefaultPosition);
                //EED
-               
+
                int result_FD = FD->ShowModal();
-               
+
                // This line is need it by windows //EED
                FD->SetReturnCode( result_FD );
-               
+
                if (FD->GetReturnCode()==wxID_OK)
                {
                        FILE *ff;
@@ -255,13 +255,13 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
                                printf("WidgetShowNPoints::OnSavePoints  ...Error... creating file");
                        } //ff
                }       // dialog box
-               
-       }               
+
+       }
 
        //------------------------------------------------------------------------
        void WidgetShowNPoints::OnLoadPoints(wxCommandEvent& event)
        {
-               wxFileDialog* FD = new wxFileDialog( 0, 
+               wxFileDialog* FD = new wxFileDialog( 0,
                                                                                        _T("Load points .."),
                                                                                        _T(""),
                                                                                        _T(""),
@@ -269,12 +269,12 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
                                                                                        wxOPEN | wxFILE_MUST_EXIST,
                                                                                        wxDefaultPosition);
                //EED
-               
+
                int result_FD = FD->ShowModal();
-               
+
                // This line is need it by windows //EED
                FD->SetReturnCode( result_FD );
-               
+
                if (FD->GetReturnCode()==wxID_OK)
                {
                        FILE *ff;
@@ -292,24 +292,24 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
                                for (i=0; i<size; i++)
                                {
                                        fscanf(ff," %d %d %d %f %s",&x,&y,&z,&value,chartmp );  // x,y,z,value,label
-                                       AddPoint(x,y,z, chartmp );                      
+                                       AddPoint(x,y,z, chartmp );
                                }
                                fclose(ff);
                        } else {   // else ff
                                printf("WidgetShowNPoints::OnLoadPoints  ...Error... reading file");
                        } //ff
                }       // dialog box
-               
-               
-       }               
-       
+
+
+       }
+
        int WidgetShowNPoints::GetNearestPoint()
        {
                int id=-1;
                int i, size=(int)(lstActorsSphere.size());
                double spc[3];
                mimage->GetSpacing(spc);
-               
+
                for ( i=0  ; i<size; i++ )
                {
                        double rx =  spc[0]*(mpoint[0] - lstPointsX [i]);
@@ -318,12 +318,12 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
                        if ( rx*rx + ry*ry + rz*rz <= mradio*mradio)
                        {
                                id=i;
-                       }       // if           
+                       }       // if
                } // for
-               
+
                return id;
        }
-       
+
        //------------------------------------------------------------------------
        void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event)
        {
@@ -333,14 +333,14 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
                        std::string strLabel = CleanSpaces(  (const char*) ( textCtrl->GetValue().mb_str() ) );
                        lstLabels[id] = CleanSpaces( (const char*) (textCtrl->GetValue().mb_str()) ) ;
                        lstActorsText[id]->SetInput(  lstLabels[id].c_str() );
-                       SetOutputBox(); 
+                       SetOutputBox();
                }
-       }               
-       
+       }
+
        //------------------------------------------------------------------------
        void WidgetShowNPoints::ErasePoint(int id)
        {
-               if (this->renderer!=NULL){ 
+               if (this->renderer!=NULL){
                        if (id>=0){
                                renderer->RemoveActor( lstActorsSphere[id] );
                                renderer->RemoveActor( lstActorsText[id] );
@@ -348,31 +348,31 @@ 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 );
 
-                               SetOutputBox(); 
+                               SetOutputBox();
 
                        } // if id
                } // if renderer
        }
-       
+
        //------------------------------------------------------------------------
        void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
        {
                ErasePoint( GetNearestPoint() );
        }
-       
+
        //------------------------------------------------------------------------
        void WidgetShowNPoints::OnEraseLastPoint(wxCommandEvent& event)
        {
                ErasePoint(lstActorsSphere.size()-1);
        }
-       
-       
+
+
 //------------------------------------------------------------------------
 void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
 {
@@ -381,7 +381,7 @@ void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
        {
                ErasePoint(id);
        }
-               
+
 }
 
 
@@ -392,12 +392,12 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ShowNPoints,bbtk::WxBlackBox);
 void ShowNPoints::Process()
 {
        if (mwxwidget!=NULL){
-               mwxwidget->SetRenderer( bbGetInputRenderer() );   
-               mwxwidget->SetPoint( bbGetInputIn() );   
-               mwxwidget->SetImage( bbGetInputImage() );   
-               mwxwidget->SetColour( bbGetInputColour() );   
-               mwxwidget->SetOpacity( bbGetInputOpacity() );   
-               mwxwidget->SetRadio( bbGetInputRadio() );   
+               mwxwidget->SetRenderer( bbGetInputRenderer() );
+               mwxwidget->SetPoint( bbGetInputIn() );
+               mwxwidget->SetImage( bbGetInputImage() );
+               mwxwidget->SetColour( bbGetInputColour() );
+               mwxwidget->SetOpacity( bbGetInputOpacity() );
+               mwxwidget->SetRadio( bbGetInputRadio() );
 
                bbSetOutputlstPointsX( mwxwidget->GetLstPointsX() );
                bbSetOutputlstPointsY( mwxwidget->GetLstPointsY() );
@@ -417,7 +417,7 @@ void ShowNPoints::CreateWidget(wxWindow* parent)
                printf("Missing Image  (ShowNPoints) \n");
        }
 
-   bbSetOutputWidget( mwxwidget ); 
+   bbSetOutputWidget( mwxwidget );
 }
 
 void ShowNPoints::bbUserSetDefaultValues()
@@ -426,7 +426,7 @@ void ShowNPoints::bbUserSetDefaultValues()
 
        bbSetInputRadio(0.5);
        bbSetInputOpacity(1);
-       
+
        std::vector<double> colour;
        colour.push_back(1.0);
        colour.push_back(0.0);
@@ -436,18 +436,18 @@ void ShowNPoints::bbUserSetDefaultValues()
        bbSetInputImage(NULL);
        bbSetInputRenderer(NULL);
 }
-       
-       //-----------------------------------------------------------------     
+
+       //-----------------------------------------------------------------
        void ShowNPoints::bbUserInitializeProcessing()
        {
        }
-       
-       //-----------------------------------------------------------------     
+
+       //-----------------------------------------------------------------
        void ShowNPoints::bbUserFinalizeProcessing()
        {
        }
-       
-       //-----------------------------------------------------------------     
+
+       //-----------------------------------------------------------------
 
 }
 // EO namespace bbcreaMaracasVisu