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)
59 double xInic, yInic,zInic,xFin, yFin,zFin;
60 _model->getInicPoint(xInic,yInic,zInic);
61 _model->getFinalPoint(xFin, yFin,zFin);
63 // RaC In the actual version, zInic=zFin=900
65 _pts->SetPoint(0, xInic, yInic, zInic );
66 _pts->SetPoint(1, xInic, yFin, zInic );
67 _pts->SetPoint(2, xFin, yFin, zFin );
68 _pts->SetPoint(3, xFin, yInic, zFin );
72 updatePositionTextActors(xInic, yInic,zInic);
78 //=========================================================================
80 void vtkGBlackBoxView::createVtkObjects() //virtual
84 _pts = vtkPoints::New();
85 vtkCellArray *lines = vtkCellArray::New();
86 vtkPolyData *_pd = vtkPolyData::New();
87 vtkPolyDataMapper* _bboxMapper=vtkPolyDataMapper::New();
88 _objectActor=vtkActor::New();
90 _pts->SetNumberOfPoints(4);
92 double xInic, yInic,zInic,xFin, yFin,zFin;
93 _model->getInicPoint(xInic,yInic,zInic);
94 _model->getFinalPoint(xFin, yFin,zFin);
96 // RaC In the actual version, zInic=zFin=900
98 _pts->SetPoint(0, xInic, yInic, zInic );
99 _pts->SetPoint(1, xInic, yFin, zInic );
100 _pts->SetPoint(2, xFin, yFin, zFin );
101 _pts->SetPoint(3, xFin, yInic, zFin );
103 lines->InsertNextCell(5);
104 lines->InsertCellPoint(0);
105 lines->InsertCellPoint(1);
106 lines->InsertCellPoint(2);
107 lines->InsertCellPoint(3);
108 lines->InsertCellPoint(0);
110 _pd->SetPoints( _pts );
111 _pd->SetLines( lines );
113 _bboxMapper->SetInput(_pd);
114 _objectActor->SetMapper(_bboxMapper);
116 _objectActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
120 _nameActor = vtkTextActor3D::New();
121 std::string temp = _model->getBBTKName();
122 _nameActor->GetTextProperty()->SetFontSize(80);
123 _nameActor->GetTextProperty()->BoldOn();
124 _nameActor->SetInput(temp.c_str());
128 _typeActor = vtkTextActor3D::New();
129 temp = _model->getBBTKType();
130 _typeActor->GetTextProperty()->SetFontSize(80);
131 _typeActor->GetTextProperty()->BoldOn();
132 _typeActor->SetInput(temp.c_str());
136 updatePositionTextActors( xInic, yInic, zInic);
139 //=========================================================================
141 void vtkGBlackBoxView::addVtkActors()//virtual
143 _baseView->GetRenderer()->AddActor(_nameActor);
145 _baseView->GetRenderer()->AddActor(_typeActor);
147 vtkGObjectView::addVtkActors();
150 //=========================================================================
152 void vtkGBlackBoxView::updatePositionTextActors(double xInic, double yInic, double zInic)
154 _nameActor->SetPosition(xInic+4,yInic-5,zInic);
155 _nameActor->SetScale(0.04,0.04,1);
157 _typeActor->SetPosition(xInic+4,yInic-10,zInic);
158 _typeActor->SetScale(0.04,0.04,1);
161 //=========================================================================
163 void vtkGBlackBoxView::updateColors()
165 _objectActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
166 _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
167 _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
169 if(_state==NOTHING_HAPPENS)
171 _objectActor->GetProperty()->SetLineWidth(1);
172 _objectActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
173 _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
174 _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
176 else if(_state==HIGHLIGHTED)
178 _objectActor->GetProperty()->SetLineWidth(2);
179 _objectActor->GetProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
180 _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
181 _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
183 else if(_state==DRAG)
185 _objectActor->GetProperty()->SetLineWidth(1.2);
186 _objectActor->GetProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
187 _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
188 _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
190 else if(_state==SELECTED)
192 _objectActor->GetProperty()->SetLineWidth(2);
193 _objectActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
194 _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
195 _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
199 //=========================================================================
201 } // EO namespace bbtk