]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx
#3057 bbGEditor Feature New Normal - optimizing of vtk actors management (input...
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsVtkGUIEditorGraphic / vtkGObjectView.cxx
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5 #                        pour la Santé)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 #
8 #  This software is governed by the CeCILL-B license under French law and 
9 #  abiding by the rules of distribution of free software. You can  use, 
10 #  modify and/ or redistribute the software under the terms of the CeCILL-B 
11 #  license as circulated by CEA, CNRS and INRIA at the following URL 
12 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
13 #  or in the file LICENSE.txt.
14 #
15 #  As a counterpart to the access to the source code and  rights to copy,
16 #  modify and redistribute granted by the license, users are provided only
17 #  with a limited warranty  and the software's author,  the holder of the
18 #  economic rights,  and the successive licensors  have only  limited
19 #  liability. 
20 #
21 #  The fact that you are presently reading this means that you have had
22 #  knowledge of the CeCILL-B license and that you accept its terms.
23 # ------------------------------------------------------------------------  
24 */
25
26
27 /*=========================================================================                                                                               
28 Program:   bbtk
29 Module:    $RCSfile$
30 Language:  C++
31 Date:      $Date$
32 Version:   $Revision$
33 =========================================================================*/
34
35 /* ---------------------------------------------------------------------
36
37 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
38 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
39 *
40 *  This software is governed by the CeCILL-B license under French law and 
41 *  abiding by the rules of distribution of free software. You can  use, 
42 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
43 *  license as circulated by CEA, CNRS and INRIA at the following URL 
44 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
45 *  or in the file LICENSE.txt.
46 *
47 *  As a counterpart to the access to the source code and  rights to copy,
48 *  modify and redistribute granted by the license, users are provided only
49 *  with a limited warranty  and the software's author,  the holder of the
50 *  economic rights,  and the successive licensors  have only  limited
51 *  liability. 
52 *
53 *  The fact that you are presently reading this means that you have had
54 *  knowledge of the CeCILL-B license and that you accept its terms.
55 * ------------------------------------------------------------------------ */                                                                         
56
57 /**
58 *  \file 
59 *  \brief Class bbtk::vtkGObjectView 
60 */
61
62
63 #include "vtkGObjectView.h"
64
65 namespace bbtk
66 {
67
68
69         //=========================================================================
70         vtkGObjectView::vtkGObjectView()
71         {
72                 _baseView                       = NULL;
73 //              _borderObjectActor      = NULL;
74                 _fillObjectActor        = NULL;
75                 _isStartDragging        = false;
76                 
77                 _state                          = NOTHING_HAPPENS;
78         }
79
80         //=========================================================================
81         vtkGObjectView::~vtkGObjectView()
82         {
83         }
84         //=========================================================================
85
86         void vtkGObjectView::update(int idController,int command)//virtual
87         {
88                 //virtual
89         }
90
91         //=========================================================================
92         
93         void vtkGObjectView::setModel(GObjectModel *model)
94         {
95                 _model = model;
96         }
97
98         //=========================================================================
99         
100         void vtkGObjectView::setBaseView(wxVtkBaseView* baseView)
101         {
102                 _baseView = baseView;
103         }
104
105         //=========================================================================
106
107         void vtkGObjectView::initVtkObjects()
108         {
109                 createVtkObjects();
110                 addVtkActors();
111         }
112
113         //=========================================================================
114
115         void vtkGObjectView::createVtkObjects() //virtual
116         {
117                 //virtual
118         }
119
120         //=========================================================================
121
122         void vtkGObjectView::updateColors() //virtual
123         {
124                 //virtual
125         }
126
127         //=========================================================================
128
129         void vtkGObjectView::addVtkActors()//virtual
130         {               
131                 _baseView->GetRenderer()->AddActor(_fillObjectActor);
132 //EED2017               _baseView->GetRenderer()->Render();
133         }
134
135         //=========================================================================
136
137         void vtkGObjectView::removeVtkActors()//virtual
138         {
139                 _baseView->GetRenderer()->RemoveActor(_fillObjectActor);
140 //EED2017               _baseView->GetRenderer()->Render();
141         }
142
143         //=========================================================================
144
145         bool vtkGObjectView::isPointInside(int X,int Y) //virtual
146         {
147                 // RaC In the actual version, always z=GPOSITION_Z
148                 double xx=X,yy=Y,zz=GPOSITION_Z;
149                 _baseView->TransCoordScreenToWorld(xx,yy,zz);
150                 return _model->isPointInside(xx,yy,zz);
151         }
152
153         //=========================================================================
154
155         void vtkGObjectView::moveObject(int X,int Y) //virtual
156         {               
157                 // RaC In the actual version, always z=GPOSITION_Z
158                 double xx=X,yy=Y,zz=GPOSITION_Z;
159                 _baseView->TransCoordScreenToWorld(xx,yy,zz);
160
161                 if(_isStartDragging)
162                 {
163                         _isStartDragging=false;
164                         
165                         double xInic,yInic,zInic;
166                         _model->getInicPoint(xInic,yInic,zInic);                        
167                         dragDifX=xx-xInic;
168                         dragDifY=yy-yInic;      
169                 }
170                 _model->move(xx-dragDifX,yy-dragDifY,zz);
171
172         }
173
174         //=========================================================================
175
176         void vtkGObjectView::setStartDragging(bool param)
177         {
178                 _isStartDragging=param;
179                 dragDifX=0;
180                 dragDifX=0;
181         }
182
183         //=========================================================================
184
185         void vtkGObjectView::setState(int state)
186         {
187                 _state = state;
188         }
189
190         //=========================================================================
191
192         int vtkGObjectView::getState()
193         {
194                 return _state;
195         }
196
197         //=========================================================================
198
199         void vtkGObjectView::setRefreshWaiting()
200         {
201                 ((vtkInteractorStyleBaseView*)_baseView->GetInteractorStyleBaseView())->SetRefresh_waiting();
202         }
203
204         //=========================================================================
205         
206         void vtkGObjectView::removeFromScene()
207         {
208                 removeVtkActors();
209                 setRefreshWaiting();
210         }
211
212         //=========================================================================
213
214
215 }  // EO namespace bbtk
216
217 // EOF
218