2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
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.
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
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 # ------------------------------------------------------------------------
26 /*=========================================================================
32 =========================================================================*/
34 /* ---------------------------------------------------------------------
36 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
37 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
39 * This software is governed by the CeCILL-B license under French law and
40 * abiding by the rules of distribution of free software. You can use,
41 * modify and/ or redistribute the software under the terms of the CeCILL-B
42 * license as circulated by CEA, CNRS and INRIA at the following URL
43 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
44 * or in the file LICENSE.txt.
46 * As a counterpart to the access to the source code and rights to copy,
47 * modify and redistribute granted by the license, users are provided only
48 * with a limited warranty and the software's author, the holder of the
49 * economic rights, and the successive licensors have only limited
52 * The fact that you are presently reading this means that you have had
53 * knowledge of the CeCILL-B license and that you accept its terms.
54 * ------------------------------------------------------------------------ */
58 * \brief Class bbtk::vtkGBoxView
62 #include "vtkGBoxView.h"
68 //=========================================================================
69 vtkGBoxView::vtkGBoxView()
73 //=========================================================================
74 vtkGBoxView::~vtkGBoxView()
78 //=========================================================================
79 void vtkGBoxView::update(int idController,int command)
82 double xInic, yInic,zInic,xFin, yFin,zFin;
83 _model->getInicPoint(xInic,yInic,zInic);
84 _model->getFinalPoint(xFin, yFin,zFin);
85 // RaC In the actual version, zInic=zFin=GPOSITION_Z
86 _pts->SetPoint(0, xInic, yInic, zInic );
87 _pts->SetPoint(1, xInic, yFin, zInic );
88 _pts->SetPoint(2, xFin, yFin, zFin );
89 _pts->SetPoint(3, xFin, yInic, zFin );
92 // _borderPolyMapper->Modified();
93 _fillPolyMapper->Modified();
98 //=========================================================================
100 void vtkGBoxView::createVtkInputOutputPorts()
102 ///************************* Inputs Fill (triangles) *************************
103 GBoxModel* boxModel =(GBoxModel*)_model;
104 int numberOfTriangles = boxModel->getNumInputPorts();
105 _TrianglesInputsPts = vtkPoints::New();
106 _TrianglesInputsPts->SetNumberOfPoints( 3*numberOfTriangles );
109 // if (numberOfTriangles>0)
111 // _TrianglesInputsPts->SetPoint(0, -1000, -1000, -1000 );
112 // _TrianglesInputsPts->SetPoint(1, 1000, 1000, 1000 );
115 vtkCellArray *stripTrianglesInputs = vtkCellArray::New();
116 vtkPolyData *pdTrianglesInputs = vtkPolyData::New();
117 _TrianglesInputsPolyMapper = vtkPolyDataMapper::New();
118 _TrianglesInputsActor = vtkActor::New();
119 // RaC In the actual version, zInic=zFin=GPOSITION_Z
120 for (int i=0 ; i<numberOfTriangles; i++)
122 stripTrianglesInputs->InsertNextCell( 3 );
123 stripTrianglesInputs->InsertCellPoint(i*3+0);
124 stripTrianglesInputs->InsertCellPoint(i*3+1);
125 stripTrianglesInputs->InsertCellPoint(i*3+2);
127 pdTrianglesInputs->SetPoints( _TrianglesInputsPts );
128 pdTrianglesInputs->SetStrips( stripTrianglesInputs );
129 _TrianglesInputsPolyMapper->SetInput( pdTrianglesInputs );
130 _TrianglesInputsActor->SetMapper(_TrianglesInputsPolyMapper);
131 _TrianglesInputsPolyMapper->Modified();
132 ///************************* Inputs Fill (triangles) *************************
134 ///************************* Outputs Fill (triangles) *************************
135 numberOfTriangles = boxModel->getNumOutputPorts();
136 _TrianglesOutputsPts = vtkPoints::New();
137 _TrianglesOutputsPts->SetNumberOfPoints( 3*numberOfTriangles );
140 // if (numberOfTriangles>0)
142 // _TrianglesOutputsPts->SetPoint(0, -1000, -1000, -1000 );
143 // _TrianglesOutputsPts->SetPoint(1, 1000, 1000, 1000 );
146 vtkCellArray *stripTrianglesOutputs = vtkCellArray::New();
147 vtkPolyData *pdTrianglesOutputs = vtkPolyData::New();
148 _TrianglesOutputsPolyMapper = vtkPolyDataMapper::New();
149 _TrianglesOutputsActor = vtkActor::New();
150 // RaC In the actual version, zInic=zFin=GPOSITION_Z
151 for (int i=0 ; i<numberOfTriangles; i++)
153 stripTrianglesOutputs->InsertNextCell( 3 );
154 stripTrianglesOutputs->InsertCellPoint(i*3+0);
155 stripTrianglesOutputs->InsertCellPoint(i*3+1);
156 stripTrianglesOutputs->InsertCellPoint(i*3+2);
158 pdTrianglesOutputs->SetPoints( _TrianglesOutputsPts );
159 pdTrianglesOutputs->SetStrips( stripTrianglesOutputs );
160 _TrianglesOutputsPolyMapper->SetInput( pdTrianglesOutputs );
161 _TrianglesOutputsActor->SetMapper(_TrianglesOutputsPolyMapper);
162 _TrianglesOutputsPolyMapper->Modified();
163 ///************************* Inputs Fill (triangles) *************************
167 //=========================================================================
169 void vtkGBoxView::createVtkObjects() //virtual
172 _pts = vtkPoints::New();
173 // vtkCellArray *lines = vtkCellArray::New();
174 // vtkPolyData *_pd = vtkPolyData::New();
175 // _borderPolyMapper = vtkPolyDataMapper::New();
176 // _borderObjectActor = vtkActor::New();
178 _pts->SetNumberOfPoints(4);
180 double xInic, yInic,zInic,xFin, yFin,zFin;
181 _model->getInicPoint(xInic,yInic,zInic);
182 _model->getFinalPoint(xFin, yFin,zFin);
184 // RaC In the actual version, zInic=zFin=GPOSITION_Z
186 //EED _pts->SetPoint(0, xInic, yInic, zInic );
187 //EED _pts->SetPoint(1, xInic, yFin, zInic );
188 //EED _pts->SetPoint(2, xFin, yFin, zFin );
189 //EED _pts->SetPoint(3, xFin, yInic, zFin );
192 // _pts->SetPoint(0, -1000, -1000, -1000 );
193 // _pts->SetPoint(1, xInic, yFin, zInic );
194 // _pts->SetPoint(2, 1000, 1000, 1000 );
195 // _pts->SetPoint(3, xFin, yInic, zFin );
197 // lines->InsertNextCell(5);
198 // lines->InsertCellPoint(0);
199 // lines->InsertCellPoint(1);
200 // lines->InsertCellPoint(2);
201 // lines->InsertCellPoint(3);
202 // lines->InsertCellPoint(0);
203 // _pd->SetPoints( _pts );
204 // _pd->SetLines( lines );
205 // _borderPolyMapper->SetInput(_pd);
206 // _borderObjectActor->SetMapper(_borderPolyMapper);
207 // _borderPolyMapper->Modified();
210 ///************************* FILL *************************
212 vtkCellArray *strip = vtkCellArray::New();
213 vtkPolyData *pdFill = vtkPolyData::New();
214 _fillPolyMapper = vtkPolyDataMapper::New();
215 _fillObjectActor = vtkActor::New();
217 // RaC In the actual version, zInic=zFin=GPOSITION_Z
219 strip->InsertNextCell(5);
220 strip->InsertCellPoint(0);
221 strip->InsertCellPoint(1);
222 strip->InsertCellPoint(2);
223 strip->InsertCellPoint(0);
224 strip->InsertCellPoint(3);
226 pdFill->SetPoints( _pts );
227 pdFill->SetStrips( strip );
229 _fillPolyMapper->SetInput(pdFill);
230 _fillObjectActor->SetMapper(_fillPolyMapper);
231 _fillPolyMapper->Modified();
233 ///************************* FILL *************************
236 //=========================================================================
238 void vtkGBoxView::addVtkActors()//virtual
240 // _baseView->GetRenderer()->AddActor(_borderObjectActor);
241 vtkGObjectView::addVtkActors();
242 _baseView->GetRenderer()->AddActor(_TrianglesInputsActor);
243 _baseView->GetRenderer()->AddActor(_TrianglesOutputsActor);
246 //=========================================================================
248 void vtkGBoxView::removeVtkActors()//virtual
250 // _baseView->GetRenderer()->RemoveActor(_borderObjectActor);
251 _baseView->GetRenderer()->RemoveActor(_TrianglesInputsActor);
252 _baseView->GetRenderer()->RemoveActor(_TrianglesOutputsActor);
253 vtkGObjectView::removeVtkActors();
256 //=========================================================================
258 void vtkGBoxView::updateColors()
260 _fillObjectActor->GetProperty()->SetAmbient(0.6);
262 if(_state==NOTHING_HAPPENS)
264 // _borderObjectActor->GetProperty()->SetLineWidth(1);
265 // _borderObjectActor->GetProperty()->SetColor(BOXBORDER_NH_R,BOXBORDER_NH_G,BOXBORDER_NH_B);
266 _fillObjectActor->GetProperty()->SetColor(BOXFILL_NH_R,BOXFILL_NH_G,BOXFILL_NH_B);
269 else if(_state==HIGHLIGHTED)
271 // _borderObjectActor->GetProperty()->SetLineWidth(2);
272 // _borderObjectActor->GetProperty()->SetColor(BOXBORDER_HIGHLIGHTED_R,BOXBORDER_HIGHLIGHTED_G,BOXBORDER_HIGHLIGHTED_B);
273 _fillObjectActor->GetProperty()->SetColor(BOXFILL_HIGHLIGHTED_R,BOXFILL_HIGHLIGHTED_G,BOXFILL_HIGHLIGHTED_B);
275 else if(_state==DRAG)
277 // _borderObjectActor->GetProperty()->SetLineWidth(1.2);
278 // _borderObjectActor->GetProperty()->SetColor(BOXBORDER_DRAG_R,BOXBORDER_DRAG_G,BOXBORDER_DRAG_B);
279 _fillObjectActor->GetProperty()->SetColor(BOXFILL_DRAG_R,BOXFILL_DRAG_G,BOXFILL_DRAG_B);
281 else if(_state==SELECTED)
283 // _borderObjectActor->GetProperty()->SetLineWidth(2);
284 // _borderObjectActor->GetProperty()->SetColor(BOXBORDER_SELECTED_R,BOXBORDER_SELECTED_G,BOXBORDER_SELECTED_B);
285 _fillObjectActor->GetProperty()->SetColor(BOXFILL_SELECTED_R,BOXFILL_SELECTED_G,BOXFILL_SELECTED_B);
289 //=========================================================================
291 void vtkGBoxView::updatePorts()
293 double xInic, yInic,zInic,xFin, yFin,zFin;
295 GBoxModel* boxModel =(GBoxModel*)_model;
296 boxModel->updatePorts();
298 // update position for one Actor that represents all InputPorts
299 GPortModel *portModel;
300 int numberOfTriangles = boxModel->getNumInputPorts();
301 for (int i=0;i<numberOfTriangles;i++)
303 portModel= boxModel->getInputPort(i);
304 portModel->getInicPoint( xInic , yInic , zInic ) ;
305 portModel->getFinalPoint( xFin , yFin , zFin ) ;
306 // RaC In the actual version, zInic=zFin=GPOSITION_Z
307 _TrianglesInputsPts->SetPoint(i*3+0, xInic , yInic , zInic );
308 _TrianglesInputsPts->SetPoint(i*3+1, ( xInic + xFin ) / 2 , yFin , zInic );
309 _TrianglesInputsPts->SetPoint(i*3+2, xFin , yInic , zFin );
311 _TrianglesInputsPts->Modified();
312 _TrianglesInputsPolyMapper->Modified( ) ;
314 // update position for one Actor that represents all OutputPorts
315 numberOfTriangles = boxModel->getNumOutputPorts();
316 for (int i=0;i<numberOfTriangles;i++)
318 portModel= boxModel->getOutputPort(i);
319 portModel->getInicPoint( xInic , yInic , zInic ) ;
320 portModel->getFinalPoint( xFin , yFin , zFin ) ;
321 // RaC In the actual version, zInic=zFin=GPOSITION_Z
322 _TrianglesOutputsPts->SetPoint(i*3+0, xInic , yInic , zInic );
323 _TrianglesOutputsPts->SetPoint(i*3+1, ( xInic + xFin ) / 2 , yFin , zInic );
324 _TrianglesOutputsPts->SetPoint(i*3+2, xFin , yInic , zFin );
326 _TrianglesOutputsPts->Modified();
327 _TrianglesOutputsPolyMapper->Modified( ) ;
333 //=========================================================================
335 } // EO namespace bbtk