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 command)
56 _objectActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
58 if(_model->getState()==NOTHING_HAPPENS)
60 _objectActor->GetProperty()->SetLineWidth(1);
61 _objectActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
62 //_nameActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
63 _typeActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
65 else if(_model->getState()==HIGHLIGHTED)
67 _objectActor->GetProperty()->SetLineWidth(2);
68 _objectActor->GetProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
69 //_nameActor->GetProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
70 _typeActor->GetProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
72 else if(_model->getState()==DRAG)
74 _objectActor->GetProperty()->SetLineWidth(1.2);
75 _objectActor->GetProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
76 //_nameActor->GetProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
77 _typeActor->GetProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
79 else if(_model->getState()==SELECTED)
81 _objectActor->GetProperty()->SetLineWidth(2);
82 _objectActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
83 //_nameActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
84 _typeActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
87 double xInic, yInic,zInic,xFin, yFin,zFin;
88 _model->getInicPoint(xInic,yInic,zInic);
89 _model->getFinalPoint(xFin, yFin,zFin);
91 // RaC In the actual version, zInic=zFin=900
93 _pts->SetPoint(0, xInic, yInic, zInic );
94 _pts->SetPoint(1, xInic, yFin, zInic );
95 _pts->SetPoint(2, xFin, yFin, zFin );
96 _pts->SetPoint(3, xFin, yInic, zFin );
100 updatePositionTextActors(xInic, yInic,zInic);
104 _baseView->RefreshView();
105 _baseView->Refresh();
108 //=========================================================================
110 void vtkGBlackBoxView::createVtkObjects() //virtual
114 _pts = vtkPoints::New();
115 vtkCellArray *lines = vtkCellArray::New();
116 vtkPolyData *_pd = vtkPolyData::New();
117 vtkPolyDataMapper* _bboxMapper=vtkPolyDataMapper::New();
118 _objectActor=vtkActor::New();
120 _pts->SetNumberOfPoints(4);
122 double xInic, yInic,zInic,xFin, yFin,zFin;
123 _model->getInicPoint(xInic,yInic,zInic);
124 _model->getFinalPoint(xFin, yFin,zFin);
126 // RaC In the actual version, zInic=zFin=900
128 _pts->SetPoint(0, xInic, yInic, zInic );
129 _pts->SetPoint(1, xInic, yFin, zInic );
130 _pts->SetPoint(2, xFin, yFin, zFin );
131 _pts->SetPoint(3, xFin, yInic, zFin );
133 lines->InsertNextCell(5);
134 lines->InsertCellPoint(0);
135 lines->InsertCellPoint(1);
136 lines->InsertCellPoint(2);
137 lines->InsertCellPoint(3);
138 lines->InsertCellPoint(0);
140 _pd->SetPoints( _pts );
141 _pd->SetLines( lines );
143 _bboxMapper->SetInput(_pd);
144 _objectActor->SetMapper(_bboxMapper);
146 _objectActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
151 _vectorNameText = vtkVectorText::New();
152 std::string temp = _model->getBBTKName();
153 _vectorNameText->SetText(temp.c_str());
155 vtkPolyDataMapper* txtMapper = vtkPolyDataMapper::New();
156 txtMapper->SetInputConnection( _vectorNameText->GetOutputPort());
157 _nameActor = vtkActor::New();
158 _nameActor->SetMapper(txtMapper);
161 _vectorNameText = vtkTextActor3D::New();
162 std::string temp = _model->getBBTKName();
163 _vectorNameText->SetInput( temp.c_str() );
168 _vectorTypeText = vtkVectorText::New();
169 temp = _model->getBBTKType();
170 _vectorTypeText->SetText(temp.c_str());
172 vtkPolyDataMapper* txtMapper = vtkPolyDataMapper::New();
173 txtMapper->SetInputConnection( _vectorTypeText->GetOutputPort());
174 _typeActor = vtkActor::New();
175 _typeActor->SetMapper(txtMapper);
179 updatePositionTextActors( xInic, yInic, zInic);
181 //_nameActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
182 _vectorNameText->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
183 _vectorNameText->GetTextProperty()->SetFontSize(75);//SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
184 _vectorNameText->GetTextProperty()->BoldOn();
185 _vectorNameText->SetScale(0.05,0.05,1);
186 _typeActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
190 //=========================================================================
192 void vtkGBlackBoxView::addVtkActors()//virtual
194 //_baseView->GetRenderer()->AddActor(_nameActor);
196 _baseView->GetRenderer()->AddActor(_vectorNameText);
198 _baseView->GetRenderer()->AddActor(_typeActor);
200 vtkGObjectView::addVtkActors();
203 //=========================================================================
205 void vtkGBlackBoxView::updatePositionTextActors(double xInic, double yInic, double zInic)
207 //_nameActor->SetPosition(xInic+4,yInic-5,zInic);
208 //_nameActor->SetScale(2,2,1);
209 _vectorNameText->SetPosition(xInic+4,yInic-5,zInic);
211 _typeActor->SetPosition(xInic+4,yInic-10,zInic);
212 _typeActor->SetScale(2,2,1);
215 //=========================================================================
217 } // EO namespace bbtk