3 #include "ViewShowNPoints.h"
6 //----------------------------------------------------------------------
7 ViewShowNPoints::ViewShowNPoints(ModelShowNPoints* modelShowNPoints)
10 mmodelShowNPoints = modelShowNPoints;
13 //----------------------------------------------------------------------
15 ViewShowNPoints::~ViewShowNPoints()
20 //------------------------------------------------------------------------
22 void ViewShowNPoints::RefreshPoint(int id)
26 GetModelShowNPoints()->GetIdPoint(id,&x,&y,&z);
27 GetModelShowNPoints()->GetImage()->GetSpacing(spc);
28 std::string label = GetModelShowNPoints()->GetIdLabel(id);
29 double radio = GetModelShowNPoints()->GetRadio() * ratioRadio;
30 lstActorsSphere[id]->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
31 lstActorsSphere[id]->GetProperty()->SetOpacity( mopacity );
32 lstSourceSphere[id]->SetRadius( radio );
33 lstActorsSphere[id]->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
34 //EED 2017-01-01 Migration VTK7
35 #if VTK_MAJOR_VERSION <= 5
38 lstSourceSphere[id]->Update();
40 lstActorsText[id]->SetInput( label.c_str() );
41 lstActorsText[id]->SetPosition( radio+spc[0]*x , spc[1]*y , spc[2]*z );
44 //------------------------------------------------------------------------
45 void ViewShowNPoints::RefreshEachPoint()
47 int id,size=lstActorsSphere.size();
48 for (id=0;id<size;id++)
54 //------------------------------------------------------------------------
55 void ViewShowNPoints::RefreshPoints()
58 renderer->GetRenderWindow()->Render();
61 //------------------------------------------------------------------------
62 void ViewShowNPoints::AddVtkPoint()
65 vtkSphereSource *vtksphere = vtkSphereSource::New();
66 vtksphere->SetThetaResolution (8);
67 vtksphere->SetPhiResolution (8);
68 vtksphere->SetRadius( 1 );
69 //NTU: For updating points
70 lstSourceSphere.push_back(vtksphere);
71 vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
73 //EED 2017-01-01 Migration VTK7
74 #if VTK_MAJOR_VERSION <= 5
75 sphereMapper->SetInput( vtksphere->GetOutput() );
78 sphereMapper->SetInputData( vtksphere->GetOutput() );
81 vtkActor *sphereActor = vtkActor::New();
82 sphereActor->SetMapper(sphereMapper);
83 sphereActor->SetOrigin(0, 0, 0);
85 lstActorsSphere.push_back(sphereActor);
89 // wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
90 // dialog.ShowModal();
91 printf("EED ShowNPoints Warning: Renderer Not Set\n");
95 renderer->AddActor( sphereActor );
97 vtkTextActor3D *textActor = vtkTextActor3D::New();
98 // textActor->SetInput( strLabel.c_str() );
99 renderer->AddActor( textActor );
100 lstActorsText.push_back(textActor);
103 //------------------------------------------------------------------------
104 void ViewShowNPoints::AddPoint()
107 RefreshPoint(lstActorsSphere.size()-1);
110 //------------------------------------------------------------------------
111 void ViewShowNPoints::Render()
113 renderer->GetRenderWindow()->Render();
116 //------------------------------------------------------------------------
117 void ViewShowNPoints::ErasePoint(int id)
119 if (this->renderer!=NULL)
123 renderer->RemoveActor( lstActorsSphere[id] );
124 renderer->RemoveActor( lstActorsText[id] );
125 lstActorsSphere[id]->Delete();
126 lstActorsText[id]->Delete();
127 lstSourceSphere[id]->Delete();
128 lstActorsSphere.erase( lstActorsSphere.begin()+id );
129 lstActorsText.erase( lstActorsText.begin()+id );
130 lstSourceSphere.erase( lstSourceSphere.begin()+id );
135 //------------------------------------------------------------------------
136 ModelShowNPoints* ViewShowNPoints::GetModelShowNPoints()
138 return mmodelShowNPoints;
141 //------------------------------------------------------------------------
142 void ViewShowNPoints::SetModelShowNPoints( ModelShowNPoints* modelShowNPoints)
144 mmodelShowNPoints = modelShowNPoints;