]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/PointView.cxx
creaMaracasVisu Library
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / PointView.cxx
1 #include "PointView.h"
2
3
4 // ----------------------------------------------------------------------------
5 // ----------------------------------------------------------------------------
6 // ----------------------------------------------------------------------------
7
8 PointView::PointView()
9 {
10         _wxvtkbaseview = NULL;
11 }
12
13 // ----------------------------------------------------------------------------
14 PointView::~PointView()
15 {
16         DeletePoints();
17 }
18
19 // ----------------------------------------------------------------------------
20 void PointView::DeletePoints()
21 {
22         DeleteVtkObjects();
23         point_mapped.clear();
24         point_actor.clear();
25 }
26
27 // ----------------------------------------------------------------------------
28 void PointView::SetWxVtkBaseView(wxVtkBaseView *wxvtkbaseview)
29 {
30         _wxvtkbaseview = wxvtkbaseview;
31 }
32
33 // ----------------------------------------------------------------------------
34 void PointView::Refresh()
35 {
36         _wxvtkbaseview->GetRenWin()->Render();
37 }
38
39 // ----------------------------------------------------------------------------
40 void PointView::CreateNewPoint(double x, double y, int type)
41 {
42         vtkSphereSource* aSphere =vtkSphereSource::New();
43         aSphere->SetRadius(1);
44         aSphere->SetCenter(x,y,0);
45         
46         point_mapped.push_back(vtkPolyDataMapper::New());
47 //      point_mapped.back()->ImmediateModeRenderingOn();
48         //point_mapped.back()->ScalarVisibilityOff( );
49         point_mapped.back()->SetInput(aSphere->GetOutput());
50
51         point_actor.push_back(vtkActor::New());
52         point_actor.back()->SetMapper(point_mapped.back());
53 //      point_actor.back()->GetProperty()->BackfaceCullingOff();
54
55         switch (type)
56         {
57         case PointView::BLUE :          point_actor.back()->GetProperty()->SetColor(0, 0, 1);
58                                                                 break;
59         case PointView::MAGENTA :       point_actor.back()->GetProperty()->SetColor(1, 0, 1);
60                                                                 break;
61         case PointView::GREEN :         point_actor.back()->GetProperty()->SetColor(0, 1, 0);
62                                                                 break;
63         case PointView::YELLOW :        point_actor.back()->GetProperty()->SetColor(0, 1, 1);
64                                                                 break;
65         default:                                        point_actor.back()->GetProperty()->SetColor(0, 0, 1);
66
67         }
68
69         //point_actor.back()->GetProperty()->SetColor(0, 1, 0);
70         
71         point_actor.back()->ApplyProperties();
72
73         _wxvtkbaseview->GetRenderer()->AddActor(point_actor.back());
74         _wxvtkbaseview->GetRenWin()->Render();
75 }
76
77 // ----------------------------------------------------------------------------
78 void PointView::DeleteVtkObjects()
79 {
80         int i,size=point_mapped.size();
81         for (i=0;i<size; i++){
82                 if ( point_mapped[i]    != NULL )       { 
83                         point_mapped[i]  -> Delete(); 
84                 }
85                 if ( point_actor[i]     != NULL )       { 
86                         _wxvtkbaseview->GetRenderer()->RemoveActor(point_actor[i]);
87                         point_actor[i]  -> Delete(); 
88                 }
89                 point_actor[i] = NULL;
90                 point_mapped[i] = NULL;
91         }
92 }