1 /*=========================================================================
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
33 * \brief Class bbtk::vtkGBlackBoxView
37 #include "vtkGBlackBoxView.h"
43 //=========================================================================
44 vtkGBlackBoxView::vtkGBlackBoxView()
48 //=========================================================================
49 vtkGBlackBoxView::~vtkGBlackBoxView()
53 //=========================================================================
54 void vtkGBlackBoxView::update(int idController,int command)
58 double xInic, yInic,zInic,xFin, yFin,zFin;
59 _model->getInicPoint(xInic,yInic,zInic);
60 _model->getFinalPoint(xFin, yFin,zFin);
62 // RaC In the actual version, zInic=zFin=900
64 _pts->SetPoint(0, xInic, yInic, zInic );
65 _pts->SetPoint(1, xInic, yFin, zInic );
66 _pts->SetPoint(2, xFin, yFin, zFin );
67 _pts->SetPoint(3, xFin, yInic, zFin );
70 _ptsFill->SetPoint(0, xInic, yInic, zInic-0.01 );
71 _ptsFill->SetPoint(1, xInic, yFin, zInic-0.01 );
72 _ptsFill->SetPoint(2, xFin, yFin, zFin-0.01 );
73 _ptsFill->SetPoint(3, xFin, yInic, zFin-0.01 );
78 updatePositionTextActors(xInic, yInic,zInic);
84 //=========================================================================
86 void vtkGBlackBoxView::createVtkObjects() //virtual
90 _pts = vtkPoints::New();
91 vtkCellArray *lines = vtkCellArray::New();
92 vtkPolyData *_pd = vtkPolyData::New();
93 vtkPolyDataMapper* _bboxMapper=vtkPolyDataMapper::New();
94 _objectBorderActor=vtkActor::New();
96 _pts->SetNumberOfPoints(4);
98 double xInic, yInic,zInic,xFin, yFin,zFin;
99 _model->getInicPoint(xInic,yInic,zInic);
100 _model->getFinalPoint(xFin, yFin,zFin);
102 // RaC In the actual version, zInic=zFin=900
104 _pts->SetPoint(0, xInic, yInic, zInic );
105 _pts->SetPoint(1, xInic, yFin, zInic );
106 _pts->SetPoint(2, xFin, yFin, zFin );
107 _pts->SetPoint(3, xFin, yInic, zFin );
109 lines->InsertNextCell(5);
110 lines->InsertCellPoint(0);
111 lines->InsertCellPoint(1);
112 lines->InsertCellPoint(2);
113 lines->InsertCellPoint(3);
114 lines->InsertCellPoint(0);
116 _pd->SetPoints( _pts );
117 _pd->SetLines( lines );
119 _bboxMapper->SetInput(_pd);
120 _objectBorderActor->SetMapper(_bboxMapper);
122 _objectBorderActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
125 ///************************* FILL *************************
127 _ptsFill = vtkPoints::New();
128 vtkCellArray *strip = vtkCellArray::New();
129 vtkPolyData *pdFill = vtkPolyData::New();
130 vtkPolyDataMapper* bboxMapperFill=vtkPolyDataMapper::New();
131 _fillBorderActor=vtkActor::New();
133 _ptsFill->SetNumberOfPoints(4);
135 // RaC In the actual version, zInic=zFin=900
137 _ptsFill->SetPoint(0, xInic, yInic, zInic-0.01 );
138 _ptsFill->SetPoint(1, xInic, yFin, zInic-0.01 );
139 _ptsFill->SetPoint(2, xFin, yFin, zFin-0.01 );
140 _ptsFill->SetPoint(3, xFin, yInic, zFin-0.01 );
142 strip->InsertNextCell(5);
143 strip->InsertCellPoint(0);
144 strip->InsertCellPoint(1);
145 strip->InsertCellPoint(2);
146 strip->InsertCellPoint(0);
147 strip->InsertCellPoint(3);
149 pdFill->SetPoints( _pts );
150 pdFill->SetStrips( strip );
152 bboxMapperFill->SetInput(pdFill);
153 _fillBorderActor->SetMapper(bboxMapperFill);
154 _fillBorderActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
156 ///************************* FILL *************************
160 _nameActor = vtkTextActor3D::New();
161 std::string temp = _model->getBBTKName();
162 _nameActor->GetTextProperty()->SetFontSize(80);
163 _nameActor->GetTextProperty()->BoldOn();
164 _nameActor->SetInput(temp.c_str());
168 _typeActor = vtkTextActor3D::New();
169 temp = _model->getBBTKType();
170 _typeActor->GetTextProperty()->SetFontSize(80);
171 _typeActor->GetTextProperty()->BoldOn();
172 _typeActor->SetInput(temp.c_str());
176 updatePositionTextActors( xInic, yInic, zInic);
179 //=========================================================================
181 void vtkGBlackBoxView::addVtkActors()//virtual
183 _baseView->GetRenderer()->AddActor(_nameActor);
185 _baseView->GetRenderer()->AddActor(_typeActor);
187 vtkGObjectView::addVtkActors();
190 //=========================================================================
192 void vtkGBlackBoxView::updatePositionTextActors(double xInic, double yInic, double zInic)
194 _nameActor->SetPosition(xInic+4,yInic-5,zInic);
195 _nameActor->SetScale(0.04,0.04,1);
197 _typeActor->SetPosition(xInic+4,yInic-10,zInic);
198 _typeActor->SetScale(0.04,0.04,1);
201 //=========================================================================
203 void vtkGBlackBoxView::updateColors()
205 _objectBorderActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
206 _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
207 _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
208 _fillBorderActor->GetProperty()->SetColor(1,.5,.3);
210 if(_state==NOTHING_HAPPENS)
212 _objectBorderActor->GetProperty()->SetLineWidth(1);
213 _objectBorderActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
214 _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
215 _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
217 else if(_state==HIGHLIGHTED)
219 _objectBorderActor->GetProperty()->SetLineWidth(2);
220 _objectBorderActor->GetProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
221 _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
222 _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
224 else if(_state==DRAG)
226 _objectBorderActor->GetProperty()->SetLineWidth(1.2);
227 _objectBorderActor->GetProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
228 _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
229 _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
231 else if(_state==SELECTED)
233 _objectBorderActor->GetProperty()->SetLineWidth(2);
234 _objectBorderActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
235 _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
236 _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
240 //=========================================================================
242 } // EO namespace bbtk