]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/PointView.cxx
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / PointView.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 #include "PointView.h"
27
28
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
31 // ----------------------------------------------------------------------------
32
33 PointView::PointView()
34 {
35         _wxvtkbaseview = NULL;
36 }
37
38 // ----------------------------------------------------------------------------
39 PointView::~PointView()
40 {
41         DeletePoints();
42 }
43
44 // ----------------------------------------------------------------------------
45 void PointView::DeletePoints()
46 {
47         DeleteVtkObjects();
48         point_mapped.clear();
49         point_actor.clear();
50 }
51
52 // ----------------------------------------------------------------------------
53 void PointView::SetWxVtkBaseView(wxVtkBaseView *wxvtkbaseview)
54 {
55         _wxvtkbaseview = wxvtkbaseview;
56 }
57
58 // ----------------------------------------------------------------------------
59 void PointView::Refresh()
60 {
61         _wxvtkbaseview->GetRenWin()->Render();
62 }
63
64 // ----------------------------------------------------------------------------
65 void PointView::CreateNewPoint(double x, double y, int type)
66 {
67         vtkSphereSource* aSphere =vtkSphereSource::New();
68         aSphere->SetRadius(1);
69         aSphere->SetCenter(x,y,0);
70         
71         point_mapped.push_back(vtkPolyDataMapper::New());
72 //      point_mapped.back()->ImmediateModeRenderingOn();
73         //point_mapped.back()->ScalarVisibilityOff( );
74         point_mapped.back()->SetInput(aSphere->GetOutput());
75
76         point_actor.push_back(vtkActor::New());
77         point_actor.back()->SetMapper(point_mapped.back());
78 //      point_actor.back()->GetProperty()->BackfaceCullingOff();
79
80         switch (type)
81         {
82         case PointView::BLUE :          point_actor.back()->GetProperty()->SetColor(0, 0, 1);
83                                                                 break;
84         case PointView::MAGENTA :       point_actor.back()->GetProperty()->SetColor(1, 0, 1);
85                                                                 break;
86         case PointView::GREEN :         point_actor.back()->GetProperty()->SetColor(0, 1, 0);
87                                                                 break;
88         case PointView::YELLOW :        point_actor.back()->GetProperty()->SetColor(0, 1, 1);
89                                                                 break;
90         default:                                        point_actor.back()->GetProperty()->SetColor(0, 0, 1);
91
92         }
93
94         //point_actor.back()->GetProperty()->SetColor(0, 1, 0);
95         
96         point_actor.back()->ApplyProperties();
97
98         _wxvtkbaseview->GetRenderer()->AddActor(point_actor.back());
99         _wxvtkbaseview->GetRenWin()->Render();
100 }
101
102 // ----------------------------------------------------------------------------
103 void PointView::DeleteVtkObjects()
104 {
105         int i,size=point_mapped.size();
106         for (i=0;i<size; i++){
107                 if ( point_mapped[i]    != NULL )       { 
108                         point_mapped[i]  -> Delete(); 
109                 }
110                 if ( point_actor[i]     != NULL )       { 
111                         _wxvtkbaseview->GetRenderer()->RemoveActor(point_actor[i]);
112                         point_actor[i]  -> Delete(); 
113                 }
114                 point_actor[i] = NULL;
115                 point_mapped[i] = NULL;
116         }
117 }