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::RefreshEachPoint()
46 int id,size=lstActorsSphere.size();
47 for (id=0;id<size;id++)
53 //------------------------------------------------------------------------
54 void ViewShowNPoints::RefreshPoints()
57 renderer->GetRenderWindow()->Render();
60 //------------------------------------------------------------------------
61 void ViewShowNPoints::AddVtkPoint()
64 vtkSphereSource *vtksphere = vtkSphereSource::New();
65 vtksphere->SetThetaResolution (10);
66 vtksphere->SetPhiResolution (10);
67 vtksphere->SetRadius( 1 );
68 //NTU: For updating points
69 lstSourceSphere.push_back(vtksphere);
70 vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
72 //EED 2017-01-01 Migration VTK7
73 #if VTK_MAJOR_VERSION <= 5
74 sphereMapper->SetInput( vtksphere->GetOutput() );
77 sphereMapper->SetInputData( vtksphere->GetOutput() );
80 vtkActor *sphereActor = vtkActor::New();
81 sphereActor->SetMapper(sphereMapper);
82 sphereActor->SetOrigin(0, 0, 0);
84 lstActorsSphere.push_back(sphereActor);
88 // wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
89 // dialog.ShowModal();
90 printf("EED ShowNPoints Warning: Renderer Not Set\n");
94 renderer->AddActor( sphereActor );
96 vtkTextActor3D *textActor = vtkTextActor3D::New();
97 // textActor->SetInput( strLabel.c_str() );
98 renderer->AddActor( textActor );
99 lstActorsText.push_back(textActor);
102 //------------------------------------------------------------------------
103 void ViewShowNPoints::AddPoint()
106 RefreshPoint(lstActorsSphere.size()-1);
109 //------------------------------------------------------------------------
110 void ViewShowNPoints::Render()
112 renderer->GetRenderWindow()->Render();
115 //------------------------------------------------------------------------
116 void ViewShowNPoints::ErasePoint(int id)
118 if (this->renderer!=NULL)
122 renderer->RemoveActor( lstActorsSphere[id] );
123 renderer->RemoveActor( lstActorsText[id] );
124 lstActorsSphere[id]->Delete();
125 lstActorsText[id]->Delete();
126 lstSourceSphere[id]->Delete();
127 lstActorsSphere.erase( lstActorsSphere.begin()+id );
128 lstActorsText.erase( lstActorsText.begin()+id );
129 lstSourceSphere.erase( lstSourceSphere.begin()+id );
134 //------------------------------------------------------------------------
135 ModelShowNPoints* ViewShowNPoints::GetModelShowNPoints()
137 return mmodelShowNPoints;
140 //------------------------------------------------------------------------
141 void ViewShowNPoints::SetModelShowNPoints( ModelShowNPoints* modelShowNPoints)
143 mmodelShowNPoints = modelShowNPoints;