]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx
#3084 bbGEditor Bug New Normal - Color refresh for inputs and outputs
[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         vtkGObjectView::vtkGObjectView()
70         {
71                 _baseView                       = NULL;
72 //              _borderObjectActor      = NULL;
73                 _fillObjectActor        = NULL;
74                 _isStartDragging        = false;
75                 
76                 _state                          = NOTHING_HAPPENS;
77         }
78
79         //=========================================================================
80         vtkGObjectView::~vtkGObjectView()
81         {
82         }
83         //=========================================================================
84         void vtkGObjectView::update(int idController,int command)//virtual
85         {
86                 //virtual
87         }
88
89         //=========================================================================
90         void vtkGObjectView::setModel(GObjectModel *model)
91         {
92                 _model = model;
93         }
94
95         //=========================================================================
96         void vtkGObjectView::setBaseView(wxVtkBaseView* baseView)
97         {
98                 _baseView = baseView;
99         }
100
101         //=========================================================================
102         void vtkGObjectView::initVtkObjects()
103         {
104                 createVtkObjects();
105                 addVtkActors();
106         }
107
108         //=========================================================================
109         void vtkGObjectView::createVtkObjects() //virtual
110         {
111                 //virtual
112         }
113
114         //=========================================================================
115         void vtkGObjectView::updateColors() //virtual
116         {
117                 //virtual
118         }
119
120         //=========================================================================
121         void vtkGObjectView::addVtkActors()//virtual
122         {               
123                 _baseView->GetRenderer()->AddActor(_fillObjectActor);
124 //EED2017               _baseView->GetRenderer()->Render();
125         }
126
127         //=========================================================================
128         void vtkGObjectView::removeVtkActors()//virtual
129         {
130                 _baseView->GetRenderer()->RemoveActor(_fillObjectActor);
131 //EED2017               _baseView->GetRenderer()->Render();
132         }
133
134         //=========================================================================
135         bool vtkGObjectView::isPointInside(int X,int Y) //virtual
136         {
137                 // RaC In the actual version, always z=GPOSITION_Z
138                 double xx=X,yy=Y,zz=GPOSITION_Z;
139                 _baseView->TransCoordScreenToWorld(xx,yy,zz);
140                 return _model->isPointInside(xx,yy,zz);
141         }
142
143         //=========================================================================
144         void vtkGObjectView::moveObject(int X,int Y) //virtual
145         {               
146                 // RaC In the actual version, always z=GPOSITION_Z
147                 double xx=X,yy=Y,zz=GPOSITION_Z;
148                 _baseView->TransCoordScreenToWorld(xx,yy,zz);
149                 if(_isStartDragging)
150                 {
151                         _isStartDragging=false;
152                         
153                         double xInic,yInic,zInic;
154                         _model->getInicPoint(xInic,yInic,zInic);                        
155                         dragDifX=xx-xInic;
156                         dragDifY=yy-yInic;      
157                 }
158                 _model->move(xx-dragDifX,yy-dragDifY,zz);
159         }
160
161         //=========================================================================
162         void vtkGObjectView::setStartDragging(bool param)
163         {
164                 _isStartDragging=param;
165                 dragDifX=0;
166                 dragDifX=0;
167         }
168
169         //=========================================================================
170         void vtkGObjectView::setState(int state)
171         {
172                 _state = state;
173         }
174
175         //=========================================================================
176         int vtkGObjectView::getState()
177         {
178                 return _state;
179         }
180
181         //=========================================================================
182         void vtkGObjectView::setRefreshWaiting()
183         {
184                 ((vtkInteractorStyleBaseView*)_baseView->GetInteractorStyleBaseView())->SetRefresh_waiting();
185         }
186
187         //=========================================================================
188         void vtkGObjectView::removeFromScene()
189         {
190                 removeVtkActors();
191                 setRefreshWaiting();
192         }
193
194         //=========================================================================
195
196
197 }  // EO namespace bbtk
198
199 // EOF
200