3 #include "ViewShowNPoints.h"
6 //----------------------------------------------------------------------
7 ViewShowNPoints::ViewShowNPoints(ModelShowNPoints* modelShowNPoints)
10 mmodelShowNPoints=modelShowNPoints;
12 //----------------------------------------------------------------------
14 ViewShowNPoints::~ViewShowNPoints()
19 //------------------------------------------------------------------------
21 void ViewShowNPoints::RefreshPoint(int id)
25 GetModelShowNPoints()->GetIdPoint(id,&x,&y,&z);
26 GetModelShowNPoints()->GetImage()->GetSpacing(spc);
27 std::string label = GetModelShowNPoints()->GetIdLabel(id);
28 double radio = GetModelShowNPoints()->GetRadio();
29 lstActorsSphere[id]->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
30 lstActorsSphere[id]->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
31 lstActorsSphere[id]->GetProperty()->SetOpacity( mopacity );
32 lstSourceSphere[id]->SetRadius( radio );
33 //EED 2017-01-01 Migration VTK7
34 #if VTK_MAJOR_VERSION <= 5
37 lstSourceSphere[id]->Update();
39 lstActorsText[id]->SetInput( label.c_str() );
40 lstActorsText[id]->SetPosition( radio+spc[0]*x , spc[1]*y , spc[2]*z );
43 //------------------------------------------------------------------------
44 void ViewShowNPoints::RefreshPoints()
46 int id,size=lstActorsSphere.size();
47 for (id=0;id<size;id++)
51 renderer->GetRenderWindow()->Render();
54 //------------------------------------------------------------------------
55 void ViewShowNPoints::AddVtkPoint()
58 vtkSphereSource *vtksphere = vtkSphereSource::New();
59 vtksphere->SetThetaResolution (20);
60 vtksphere->SetPhiResolution (20);
61 vtksphere->SetRadius( 1 );
62 //NTU: For updating points
63 lstSourceSphere.push_back(vtksphere);
64 vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
66 //EED 2017-01-01 Migration VTK7
67 #if VTK_MAJOR_VERSION <= 5
68 sphereMapper->SetInput( vtksphere->GetOutput() );
71 sphereMapper->SetInputData( vtksphere->GetOutput() );
74 vtkActor *sphereActor = vtkActor::New();
75 sphereActor->SetMapper(sphereMapper);
76 sphereActor->SetOrigin(0, 0, 0);
78 lstActorsSphere.push_back(sphereActor);
82 // wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
83 // dialog.ShowModal();
84 printf("EED ShowNPoints Warning: Renderer Not Set\n");
88 renderer->AddActor( sphereActor );
90 vtkTextActor3D *textActor = vtkTextActor3D::New();
91 // textActor->SetInput( strLabel.c_str() );
92 renderer->AddActor( textActor );
93 lstActorsText.push_back(textActor);
96 //------------------------------------------------------------------------
97 void ViewShowNPoints::AddPoint()
100 RefreshPoint(lstActorsSphere.size()-1);
103 //------------------------------------------------------------------------
104 void ViewShowNPoints::Render()
106 renderer->GetRenderWindow()->Render();
109 //------------------------------------------------------------------------
110 void ViewShowNPoints::ErasePoint(int id)
112 if (this->renderer!=NULL)
116 renderer->RemoveActor( lstActorsSphere[id] );
117 renderer->RemoveActor( lstActorsText[id] );
118 lstActorsSphere[id]->Delete();
119 lstActorsText[id]->Delete();
120 lstSourceSphere[id]->Delete();
121 lstActorsSphere.erase( lstActorsSphere.begin()+id );
122 lstActorsText.erase( lstActorsText.begin()+id );
123 lstSourceSphere.erase( lstSourceSphere.begin()+id );
128 //------------------------------------------------------------------------
129 ModelShowNPoints* ViewShowNPoints::GetModelShowNPoints()
131 return mmodelShowNPoints;
134 //------------------------------------------------------------------------
135 void ViewShowNPoints::SetModelShowNPoints( ModelShowNPoints* modelShowNPoints)
137 mmodelShowNPoints=modelShowNPoints;