-void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
-{
- if (this->renderer!=NULL){
- if (mpoint.size()==3){
- 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();
- vtksphere->SetThetaResolution (20);
- vtksphere->SetPhiResolution (20);
- vtksphere->SetRadius( mradio );
- vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
- sphereMapper->SetInput( vtksphere->GetOutput() );
- vtkActor *sphereActor = vtkActor::New();
- sphereActor->SetMapper(sphereMapper);
- sphereActor->SetOrigin(0, 0, 0);
- double spc[3];
- mimage->GetSpacing(spc);
- sphereActor->SetPosition( spc[0]*mpoint[0] , spc[1]*mpoint[1] , spc[2]*mpoint[2] );
- 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]*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();
-
- SetOutputBox();
-
- } else {//mpoint.size
- printf("creaMaracasVisu::ShowNPoints (not match point) \n");
- }
- } // 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)
- {
- if (this->renderer!=NULL){
- if (id>=0){
- renderer->RemoveActor( lstActorsSphere[id] );
- renderer->RemoveActor( lstActorsText[id] );
- lstActorsSphere[id]->Delete();
- 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();
- SetOutputBox();
-
- } // if id
- } // if renderer
- }
-
- //------------------------------------------------------------------------
- void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
- {
- 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]);
- double ry = spc[1]*(mpoint[1] - lstPointsY [i]);
- double rz = spc[2]*(mpoint[2] - lstPointsZ [i]);
- if ( rx*rx + ry*ry + rz*rz <= mradio*mradio)
- {
- id=i;
- } // if
- } // for
- ErasePoint(id);
- }
-
- //------------------------------------------------------------------------
- void WidgetShowNPoints::OnEraseLastPoint(wxCommandEvent& event)
- {
- ErasePoint(lstActorsSphere.size()-1);
- }
-
-