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)
83 double xInic, yInic,zInic,xFin, yFin,zFin;
84 _model->getInicPoint(xInic,yInic,zInic);
85 _model->getFinalPoint(xFin, yFin,zFin);
87 // RaC In the actual version, zInic=zFin=GPOSITION_Z
89 _pts->SetPoint(0, xInic, yInic, zInic );
90 _pts->SetPoint(1, xInic, yFin, zInic );
91 _pts->SetPoint(2, xFin, yFin, zFin );
92 _pts->SetPoint(3, xFin, yInic, zFin );
96 // _borderPolyMapper->Modified();
97 _fillPolyMapper->Modified();
106 //=========================================================================
108 void vtkGBoxView::createVtkInputOutputPorts()
110 ///************************* Inputs Fill (triangles) *************************
111 GBoxModel* boxModel =(GBoxModel*)_model;
112 int numberOfTriangles = boxModel->getNumInputPorts();
113 _TrianglesInputsPts = vtkPoints::New();
114 _TrianglesInputsPts->SetNumberOfPoints( 3*numberOfTriangles );
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 );
138 vtkCellArray *stripTrianglesOutputs = vtkCellArray::New();
139 vtkPolyData *pdTrianglesOutputs = vtkPolyData::New();
140 _TrianglesOutputsPolyMapper = vtkPolyDataMapper::New();
141 _TrianglesOutputsActor = vtkActor::New();
142 // RaC In the actual version, zInic=zFin=GPOSITION_Z
143 for (int i=0 ; i<numberOfTriangles; i++)
145 stripTrianglesOutputs->InsertNextCell( 3 );
146 stripTrianglesOutputs->InsertCellPoint(i*3+0);
147 stripTrianglesOutputs->InsertCellPoint(i*3+1);
148 stripTrianglesOutputs->InsertCellPoint(i*3+2);
150 pdTrianglesOutputs->SetPoints( _TrianglesOutputsPts );
151 pdTrianglesOutputs->SetStrips( stripTrianglesOutputs );
152 _TrianglesOutputsPolyMapper->SetInput( pdTrianglesOutputs );
153 _TrianglesOutputsActor->SetMapper(_TrianglesOutputsPolyMapper);
154 _TrianglesOutputsPolyMapper->Modified();
155 ///************************* Inputs Fill (triangles) *************************
159 //=========================================================================
161 void vtkGBoxView::createVtkObjects() //virtual
164 _pts = vtkPoints::New();
165 // vtkCellArray *lines = vtkCellArray::New();
166 // vtkPolyData *_pd = vtkPolyData::New();
167 // _borderPolyMapper = vtkPolyDataMapper::New();
168 // _borderObjectActor = vtkActor::New();
170 _pts->SetNumberOfPoints(4);
172 double xInic, yInic,zInic,xFin, yFin,zFin;
173 _model->getInicPoint(xInic,yInic,zInic);
174 _model->getFinalPoint(xFin, yFin,zFin);
176 // RaC In the actual version, zInic=zFin=GPOSITION_Z
178 //EED _pts->SetPoint(0, xInic, yInic, zInic );
179 //EED _pts->SetPoint(1, xInic, yFin, zInic );
180 //EED _pts->SetPoint(2, xFin, yFin, zFin );
181 //EED _pts->SetPoint(3, xFin, yInic, zFin );
182 _pts->SetPoint(0, -1000, -1000, -1000 );
183 _pts->SetPoint(1, xInic, yFin, zInic );
184 _pts->SetPoint(2, 1000, 1000, 1000 );
185 _pts->SetPoint(3, xFin, yInic, zFin );
187 // lines->InsertNextCell(5);
188 // lines->InsertCellPoint(0);
189 // lines->InsertCellPoint(1);
190 // lines->InsertCellPoint(2);
191 // lines->InsertCellPoint(3);
192 // lines->InsertCellPoint(0);
193 // _pd->SetPoints( _pts );
194 // _pd->SetLines( lines );
195 // _borderPolyMapper->SetInput(_pd);
196 // _borderObjectActor->SetMapper(_borderPolyMapper);
197 // _borderPolyMapper->Modified();
200 ///************************* FILL *************************
202 vtkCellArray *strip = vtkCellArray::New();
203 vtkPolyData *pdFill = vtkPolyData::New();
204 _fillPolyMapper = vtkPolyDataMapper::New();
205 _fillObjectActor = vtkActor::New();
207 // RaC In the actual version, zInic=zFin=GPOSITION_Z
209 strip->InsertNextCell(5);
210 strip->InsertCellPoint(0);
211 strip->InsertCellPoint(1);
212 strip->InsertCellPoint(2);
213 strip->InsertCellPoint(0);
214 strip->InsertCellPoint(3);
216 pdFill->SetPoints( _pts );
217 pdFill->SetStrips( strip );
219 _fillPolyMapper->SetInput(pdFill);
220 _fillObjectActor->SetMapper(_fillPolyMapper);
221 _fillPolyMapper->Modified();
223 ///************************* FILL *************************
226 //=========================================================================
228 void vtkGBoxView::addVtkActors()//virtual
230 // _baseView->GetRenderer()->AddActor(_borderObjectActor);
231 vtkGObjectView::addVtkActors();
232 _baseView->GetRenderer()->AddActor(_TrianglesInputsActor);
233 _baseView->GetRenderer()->AddActor(_TrianglesOutputsActor);
236 //=========================================================================
238 void vtkGBoxView::removeVtkActors()//virtual
240 // _baseView->GetRenderer()->RemoveActor(_borderObjectActor);
241 _baseView->GetRenderer()->RemoveActor(_TrianglesInputsActor);
242 _baseView->GetRenderer()->RemoveActor(_TrianglesOutputsActor);
243 vtkGObjectView::removeVtkActors();
246 //=========================================================================
248 void vtkGBoxView::updateColors()
250 _fillObjectActor->GetProperty()->SetAmbient(0.6);
252 if(_state==NOTHING_HAPPENS)
254 // _borderObjectActor->GetProperty()->SetLineWidth(1);
255 // _borderObjectActor->GetProperty()->SetColor(BOXBORDER_NH_R,BOXBORDER_NH_G,BOXBORDER_NH_B);
256 _fillObjectActor->GetProperty()->SetColor(BOXFILL_NH_R,BOXFILL_NH_G,BOXFILL_NH_B);
259 else if(_state==HIGHLIGHTED)
261 // _borderObjectActor->GetProperty()->SetLineWidth(2);
262 // _borderObjectActor->GetProperty()->SetColor(BOXBORDER_HIGHLIGHTED_R,BOXBORDER_HIGHLIGHTED_G,BOXBORDER_HIGHLIGHTED_B);
263 _fillObjectActor->GetProperty()->SetColor(BOXFILL_HIGHLIGHTED_R,BOXFILL_HIGHLIGHTED_G,BOXFILL_HIGHLIGHTED_B);
265 else if(_state==DRAG)
267 // _borderObjectActor->GetProperty()->SetLineWidth(1.2);
268 // _borderObjectActor->GetProperty()->SetColor(BOXBORDER_DRAG_R,BOXBORDER_DRAG_G,BOXBORDER_DRAG_B);
269 _fillObjectActor->GetProperty()->SetColor(BOXFILL_DRAG_R,BOXFILL_DRAG_G,BOXFILL_DRAG_B);
271 else if(_state==SELECTED)
273 // _borderObjectActor->GetProperty()->SetLineWidth(2);
274 // _borderObjectActor->GetProperty()->SetColor(BOXBORDER_SELECTED_R,BOXBORDER_SELECTED_G,BOXBORDER_SELECTED_B);
275 _fillObjectActor->GetProperty()->SetColor(BOXFILL_SELECTED_R,BOXFILL_SELECTED_G,BOXFILL_SELECTED_B);
279 //=========================================================================
281 void vtkGBoxView::updatePorts()
283 double xInic, yInic,zInic,xFin, yFin,zFin;
285 GBoxModel* boxModel =(GBoxModel*)_model;
286 boxModel->updatePorts();
288 // update position for one Actor that represents all InputPorts
289 GPortModel *portModel;
290 int numberOfTriangles = boxModel->getNumInputPorts();
291 for (int i=0;i<numberOfTriangles;i++)
293 portModel= boxModel->getInputPort(i);
294 portModel->getInicPoint( xInic , yInic , zInic ) ;
295 portModel->getFinalPoint( xFin , yFin , zFin ) ;
296 // RaC In the actual version, zInic=zFin=GPOSITION_Z
297 _TrianglesInputsPts->SetPoint(i*3+0, xInic , yInic , zInic );
298 _TrianglesInputsPts->SetPoint(i*3+1, ( xInic + xFin ) / 2 , yFin , zInic );
299 _TrianglesInputsPts->SetPoint(i*3+2, xFin , yInic , zFin );
301 _TrianglesInputsPolyMapper->Modified( ) ;
303 // update position for one Actor that represents all OutputPorts
304 numberOfTriangles = boxModel->getNumOutputPorts();
305 for (int i=0;i<numberOfTriangles;i++)
307 portModel= boxModel->getOutputPort(i);
308 portModel->getInicPoint( xInic , yInic , zInic ) ;
309 portModel->getFinalPoint( xFin , yFin , zFin ) ;
310 // RaC In the actual version, zInic=zFin=GPOSITION_Z
311 _TrianglesOutputsPts->SetPoint(i*3+0, xInic , yInic , zInic );
312 _TrianglesOutputsPts->SetPoint(i*3+1, ( xInic + xFin ) / 2 , yFin , zInic );
313 _TrianglesOutputsPts->SetPoint(i*3+2, xFin , yInic , zFin );
315 _TrianglesOutputsPolyMapper->Modified( ) ;
321 //=========================================================================
323 } // EO namespace bbtk