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 );
76 bboxMapperFill->Modified();
79 updatePositionTextActors(xInic, yInic,zInic);
85 //=========================================================================
87 void vtkGBlackBoxView::createVtkObjects() //virtual
91 _pts = vtkPoints::New();
92 vtkCellArray *lines = vtkCellArray::New();
93 vtkPolyData *_pd = vtkPolyData::New();
94 vtkPolyDataMapper* _bboxMapper=vtkPolyDataMapper::New();
95 _objectBorderActor=vtkActor::New();
97 _pts->SetNumberOfPoints(4);
99 double xInic, yInic,zInic,xFin, yFin,zFin;
100 _model->getInicPoint(xInic,yInic,zInic);
101 _model->getFinalPoint(xFin, yFin,zFin);
103 // RaC In the actual version, zInic=zFin=900
105 _pts->SetPoint(0, xInic, yInic, zInic );
106 _pts->SetPoint(1, xInic, yFin, zInic );
107 _pts->SetPoint(2, xFin, yFin, zFin );
108 _pts->SetPoint(3, xFin, yInic, zFin );
110 lines->InsertNextCell(5);
111 lines->InsertCellPoint(0);
112 lines->InsertCellPoint(1);
113 lines->InsertCellPoint(2);
114 lines->InsertCellPoint(3);
115 lines->InsertCellPoint(0);
117 _pd->SetPoints( _pts );
118 _pd->SetLines( lines );
120 _bboxMapper->SetInput(_pd);
121 _objectBorderActor->SetMapper(_bboxMapper);
123 _objectBorderActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
126 ///************************* FILL *************************
128 _ptsFill = vtkPoints::New();
129 vtkCellArray *strip = vtkCellArray::New();
130 vtkPolyData *pdFill = vtkPolyData::New();
131 bboxMapperFill=vtkPolyDataMapper::New();
132 _fillBorderActor=vtkActor::New();
134 _ptsFill->SetNumberOfPoints(4);
136 // RaC In the actual version, zInic=zFin=900
138 _ptsFill->SetPoint(0, xInic, yInic, zInic-0.01 );
139 _ptsFill->SetPoint(1, xInic, yFin, zInic-0.01 );
140 _ptsFill->SetPoint(2, xFin, yFin, zFin-0.01 );
141 _ptsFill->SetPoint(3, xFin, yInic, zFin-0.01 );
143 strip->InsertNextCell(5);
144 strip->InsertCellPoint(0);
145 strip->InsertCellPoint(1);
146 strip->InsertCellPoint(2);
147 strip->InsertCellPoint(0);
148 strip->InsertCellPoint(3);
150 pdFill->SetPoints( _ptsFill );
151 pdFill->SetStrips( strip );
153 bboxMapperFill->SetInput(pdFill);
154 _fillBorderActor->SetMapper(bboxMapperFill);
155 bboxMapperFill->Modified();
158 ///************************* FILL *************************
162 _nameActor = vtkTextActor3D::New();
163 std::string temp = _model->getBBTKName();
164 _nameActor->GetTextProperty()->SetFontSize(80);
165 _nameActor->GetTextProperty()->BoldOn();
166 _nameActor->SetInput(temp.c_str());
170 _typeActor = vtkTextActor3D::New();
171 temp = _model->getBBTKType();
172 _typeActor->GetTextProperty()->SetFontSize(80);
173 _typeActor->GetTextProperty()->BoldOn();
174 _typeActor->SetInput(temp.c_str());
178 updatePositionTextActors( xInic, yInic, zInic);
181 //=========================================================================
183 void vtkGBlackBoxView::addVtkActors()//virtual
185 _baseView->GetRenderer()->AddActor(_nameActor);
187 _baseView->GetRenderer()->AddActor(_typeActor);
189 vtkGObjectView::addVtkActors();
192 //=========================================================================
194 void vtkGBlackBoxView::updatePositionTextActors(double xInic, double yInic, double zInic)
196 _nameActor->SetPosition(xInic+4,yInic-5,zInic);
197 _nameActor->SetScale(0.04,0.04,1);
199 _typeActor->SetPosition(xInic+4,yInic-10,zInic);
200 _typeActor->SetScale(0.04,0.04,1);
203 //=========================================================================
205 void vtkGBlackBoxView::updateColors()
207 _objectBorderActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
208 _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
209 _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
210 _fillBorderActor->GetProperty()->SetColor(0.2,0.8,0.2);
212 if(_state==NOTHING_HAPPENS)
214 _objectBorderActor->GetProperty()->SetLineWidth(1);
215 _objectBorderActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
216 _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
217 _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
218 _fillBorderActor->GetProperty()->SetColor(0.2,0.8,0.2);
220 else if(_state==HIGHLIGHTED)
222 _objectBorderActor->GetProperty()->SetLineWidth(2);
223 _objectBorderActor->GetProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
224 _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
225 _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
226 _fillBorderActor->GetProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R+.1,BOXCONTOUR_HIGHLIGHTED_G+.1,BOXCONTOUR_HIGHLIGHTED_B+.1);
228 else if(_state==DRAG)
230 _objectBorderActor->GetProperty()->SetLineWidth(1.2);
231 _objectBorderActor->GetProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
232 _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
233 _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
234 _fillBorderActor->GetProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
236 else if(_state==SELECTED)
238 _objectBorderActor->GetProperty()->SetLineWidth(2);
239 _objectBorderActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
240 _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
241 _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
242 _fillBorderActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
246 //=========================================================================
248 } // EO namespace bbtk