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::vtkGBlackBoxView
62 #include "vtkGBlackBoxView.h"
68 //=========================================================================
69 vtkGBlackBoxView::vtkGBlackBoxView()
73 //=========================================================================
74 vtkGBlackBoxView::~vtkGBlackBoxView()
78 //=========================================================================
79 void vtkGBlackBoxView::update_X_Fin()
81 double xInic, yInic,zInic,xFin, yFin,zFin;
82 _model->getInicPoint(xInic,yInic,zInic);
83 double *bounds = _boxTextActor->GetBounds();
84 _model->getFinalPoint(xFin, yFin,zFin);
86 double xFin1,xFin2,xFin3;
87 // position referens from box name
88 xFin1 = xInic+(bounds[1]-bounds[0])/2 + 20;
91 // position referens from input ports
92 GBoxModel* gbm=(GBoxModel*)_model;
93 if ( gbm->getNumInputPorts()>0 )
95 GPortModel* gpm = gbm->getInputPort( gbm->getNumInputPorts()-1 );
96 double xpFin, ypFin, zpFin;
97 gpm->getFinalPoint(xpFin, ypFin, zpFin);
100 // position referens from output ports
101 if ( gbm->getNumOutputPorts()>0 )
103 GPortModel* gpm = gbm->getOutputPort( gbm->getNumOutputPorts()-1 );
104 double xpFin, ypFin, zpFin;
105 gpm->getFinalPoint(xpFin, ypFin, zpFin);
109 if (xFin2>xFin) xFin=xFin2;
110 if (xFin3>xFin) xFin=xFin3;
111 _model->setFinalPoint( xFin , yFin , zFin );
114 //=========================================================================
115 void vtkGBlackBoxView::update(int idController,int command)
119 vtkGBoxView::update(idController,command);
120 double xInic, yInic,zInic,xFin, yFin,zFin;
121 _model->getInicPoint(xInic,yInic,zInic);
122 updatePositionTextActor(xInic, yInic,zInic);
126 //=========================================================================
128 void vtkGBlackBoxView::createVtkObjects() //virtual
132 _pts = vtkPoints::New();
133 // vtkCellArray *lines = vtkCellArray::New();
134 // vtkPolyData *_pd = vtkPolyData::New();
135 // _borderPolyMapper = vtkPolyDataMapper::New();
136 // _borderObjectActor = vtkActor::New();
138 _pts->SetNumberOfPoints(4);
140 double xInic, yInic,zInic,xFin, yFin,zFin;
141 _model->getInicPoint(xInic,yInic,zInic);
142 _model->getFinalPoint(xFin, yFin,zFin);
144 // RaC In the actual version, zInic=zFin=GPOSITION_Z
146 //EED _pts->SetPoint(0, xInic, yInic, zInic );
147 //EED _pts->SetPoint(1, xInic, yFin, zInic );
148 //EED _pts->SetPoint(2, xFin, yFin, zFin );
149 //EED _pts->SetPoint(3, xFin, yInic, zFin );
152 // _pts->SetPoint(0, -1000, -1000, -1000 );
153 // _pts->SetPoint(1, xInic, yFin, zInic );
154 // _pts->SetPoint(2, 1000, 1000, 1000 );
155 // _pts->SetPoint(3, xFin, yInic, zFin );
158 // lines->InsertNextCell(5);
159 // lines->InsertCellPoint(0);
160 // lines->InsertCellPoint(1);
161 // lines->InsertCellPoint(2);
162 // lines->InsertCellPoint(3);
163 // lines->InsertCellPoint(0);
165 // _pd->SetPoints( _pts );
166 // _pd->SetLines( lines );
167 // _borderPolyMapper->SetInput(_pd);
168 // _borderObjectActor->SetMapper(_borderPolyMapper);
169 // _borderPolyMapper->Modified();
172 ///************************* FILL *************************
173 vtkCellArray *strip = vtkCellArray::New();
174 vtkPolyData *pdFill = vtkPolyData::New();
175 _fillPolyMapper = vtkPolyDataMapper::New();
176 _fillObjectActor = vtkActor::New();
177 // RaC In the actual version, zInic=zFin=GPOSITION_Z
178 strip->InsertNextCell(5);
179 strip->InsertCellPoint(0);
180 strip->InsertCellPoint(1);
181 strip->InsertCellPoint(2);
182 strip->InsertCellPoint(0);
183 strip->InsertCellPoint(3);
184 pdFill->SetPoints( _pts );
185 pdFill->SetStrips( strip );
188 //EED 2017-01-01 Migration VTK7
189 #if VTK_MAJOR_VERSION <= 5
190 _fillPolyMapper->SetInput(pdFill);
192 _fillPolyMapper->SetInputData(pdFill);
196 _fillObjectActor->SetMapper(_fillPolyMapper);
197 _fillPolyMapper->Modified();
198 ///************************* FILL *************************
202 createVtkInputOutputPorts();
208 _boxTextActor = vtkTextActor3D::New();
209 vtkTextProperty *prop = vtkTextProperty::New();
211 prop->SetFontFamilyToArial();
212 _boxTextActor->GetTextProperty()->BoldOn();
213 prop->SetFontSize(80);
214 _boxTextActor->SetTextProperty(prop);
216 // _boxTextActor->GetTextProperty()->SetFontSize(80);
221 updatePositionTextActor( xInic, yInic, zInic);
224 //===============BoundaryEdgesOn==========================================================
226 void vtkGBlackBoxView::addVtkActors()//virtual
229 // _baseView->GetRenderer()->AddActor(_borderObjectActor);
230 vtkGBoxView::addVtkActors();
231 _baseView->GetRenderer()->AddActor(_boxTextActor);
235 //=========================================================================
237 void vtkGBlackBoxView::removeVtkActors()//virtual
239 _baseView->GetRenderer()->RemoveActor(_boxTextActor);
240 // _baseView->GetRenderer()->RemoveActor(_borderObjectActor);
241 vtkGBoxView::removeVtkActors();
244 //=========================================================================
246 void vtkGBlackBoxView::updatePositionTextActor(double xInic, double yInic, double zInic)
248 std::string temp = _model->getBBTKType();
250 temp+=_model->getBBTKName();
251 _boxTextActor->SetInput(temp.c_str());
252 _boxTextActor->SetPosition(xInic+4,yInic-7,zInic+1);
253 _boxTextActor->SetScale(0.05,0.05,1);
256 //=========================================================================
258 void vtkGBlackBoxView::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);
267 _boxTextActor->GetTextProperty()->SetColor(BOXTEXT_NH_R,BOXTEXT_NH_G,BOXTEXT_NH_B);
269 GBlackBoxModel *bbmodel = (GBlackBoxModel*)_model;
270 if(bbmodel->isExecutable())
272 // _borderObjectActor->GetProperty()->SetColor(BOXBORDER_NH_R,0.9,BOXBORDER_HIGHLIGHTED_B);
273 _fillObjectActor->GetProperty()->SetColor(BOXFILL_NH_R,0.9,BOXFILL_HIGHLIGHTED_B);
277 else if(_state==HIGHLIGHTED)
279 // _borderObjectActor->GetProperty()->SetLineWidth(2);
280 // _borderObjectActor->GetProperty()->SetColor(BOXBORDER_HIGHLIGHTED_R,BOXBORDER_HIGHLIGHTED_G,BOXBORDER_HIGHLIGHTED_B);
281 _fillObjectActor->GetProperty()->SetColor(BOXFILL_HIGHLIGHTED_R,BOXFILL_HIGHLIGHTED_G,BOXFILL_HIGHLIGHTED_B);
282 _boxTextActor->GetTextProperty()->SetColor(BOXTEXT_HIGHLIGHTED_R,BOXTEXT_HIGHLIGHTED_G,BOXTEXT_HIGHLIGHTED_B);
284 else if(_state==DRAG)
286 // _borderObjectActor->GetProperty()->SetLineWidth(1.2);
287 // _borderObjectActor->GetProperty()->SetColor(BOXBORDER_DRAG_R,BOXBORDER_DRAG_G,BOXBORDER_DRAG_B);
288 _fillObjectActor->GetProperty()->SetColor(BOXFILL_DRAG_R,BOXFILL_DRAG_G,BOXFILL_DRAG_B);
289 _boxTextActor->GetTextProperty()->SetColor(BOXTEXT_DRAG_R,BOXTEXT_DRAG_G,BOXTEXT_DRAG_B);
291 else if(_state==SELECTED)
293 // _borderObjectActor->GetProperty()->SetLineWidth(2);
294 // _borderObjectActor->GetProperty()->SetColor(BOXBORDER_SELECTED_R,BOXBORDER_SELECTED_G,BOXBORDER_SELECTED_B);
295 _fillObjectActor->GetProperty()->SetColor(BOXFILL_SELECTED_R,BOXFILL_SELECTED_G,BOXFILL_SELECTED_B);
296 _boxTextActor->GetTextProperty()->SetColor(BOXTEXT_SELECTED_R,BOXTEXT_SELECTED_G,BOXTEXT_SELECTED_B);
303 //=========================================================================
306 } // EO namespace bbtk