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 _borderPolyMapper->Modified();
71 _fillPolyMapper->Modified();
74 updatePositionTextActor(xInic, yInic,zInic);
80 //=========================================================================
82 void vtkGBlackBoxView::createVtkObjects() //virtual
86 _pts = vtkPoints::New();
87 vtkCellArray *lines = vtkCellArray::New();
88 vtkPolyData *_pd = vtkPolyData::New();
89 _borderPolyMapper=vtkPolyDataMapper::New();
90 _borderObjectActor=vtkActor::New();
92 _pts->SetNumberOfPoints(4);
94 double xInic, yInic,zInic,xFin, yFin,zFin;
95 _model->getInicPoint(xInic,yInic,zInic);
96 _model->getFinalPoint(xFin, yFin,zFin);
98 // RaC In the actual version, zInic=zFin=900
100 _pts->SetPoint(0, xInic, yInic, zInic );
101 _pts->SetPoint(1, xInic, yFin, zInic );
102 _pts->SetPoint(2, xFin, yFin, zFin );
103 _pts->SetPoint(3, xFin, yInic, zFin );
105 lines->InsertNextCell(5);
106 lines->InsertCellPoint(0);
107 lines->InsertCellPoint(1);
108 lines->InsertCellPoint(2);
109 lines->InsertCellPoint(3);
110 lines->InsertCellPoint(0);
112 _pd->SetPoints( _pts );
113 _pd->SetLines( lines );
115 _borderPolyMapper->SetInput(_pd);
116 _borderObjectActor->SetMapper(_borderPolyMapper);
117 _borderPolyMapper->Modified();
120 ///************************* FILL *************************
122 vtkCellArray *strip = vtkCellArray::New();
123 vtkPolyData *pdFill = vtkPolyData::New();
124 _fillPolyMapper=vtkPolyDataMapper::New();
125 _fillObjectActor=vtkActor::New();
127 // RaC In the actual version, zInic=zFin=900
129 strip->InsertNextCell(5);
130 strip->InsertCellPoint(0);
131 strip->InsertCellPoint(1);
132 strip->InsertCellPoint(2);
133 strip->InsertCellPoint(0);
134 strip->InsertCellPoint(3);
136 pdFill->SetPoints( _pts );
137 pdFill->SetStrips( strip );
139 _fillPolyMapper->SetInput(pdFill);
140 _fillObjectActor->SetMapper(_fillPolyMapper);
141 _fillPolyMapper->Modified();
143 ///************************* FILL *************************
147 _boxTextActor = vtkTextActor3D::New();
148 std::string temp = _model->getBBTKType();
150 temp+=_model->getBBTKName();
151 _boxTextActor->GetTextProperty()->SetFontSize(80);
152 _boxTextActor->GetTextProperty()->BoldOn();
153 _boxTextActor->SetInput(temp.c_str());
157 updatePositionTextActor( xInic, yInic, zInic);
160 //=========================================================================
162 void vtkGBlackBoxView::addVtkActors()//virtual
164 _baseView->GetRenderer()->AddActor(_borderObjectActor);
165 _baseView->GetRenderer()->AddActor(_boxTextActor);
166 vtkGObjectView::addVtkActors();
169 //=========================================================================
171 void vtkGBlackBoxView::removeVtkActors()//virtual
173 _baseView->GetRenderer()->RemoveActor(_borderObjectActor);
174 _baseView->GetRenderer()->RemoveActor(_boxTextActor);
175 vtkGObjectView::removeVtkActors();
178 //=========================================================================
180 void vtkGBlackBoxView::updatePositionTextActor(double xInic, double yInic, double zInic)
182 _boxTextActor->SetPosition(xInic+4,yInic-7,zInic);
183 _boxTextActor->SetScale(0.05,0.05,1);
186 //=========================================================================
188 void vtkGBlackBoxView::updateColors()
190 _fillObjectActor->GetProperty()->SetAmbient(0.6);
192 if(_state==NOTHING_HAPPENS)
194 _borderObjectActor->GetProperty()->SetLineWidth(1);
195 _borderObjectActor->GetProperty()->SetColor(BOXBORDER_NH_R,BOXBORDER_NH_G,BOXBORDER_NH_B);
196 _fillObjectActor->GetProperty()->SetColor(BOXFILL_NH_R,BOXFILL_NH_G,BOXFILL_NH_B);
197 _boxTextActor->GetTextProperty()->SetColor(BOXTEXT_NH_R,BOXTEXT_NH_G,BOXTEXT_NH_B);
199 GBlackBoxModel *bbmodel = (GBlackBoxModel*)_model;
200 if(bbmodel->isExecutable())
202 _borderObjectActor->GetProperty()->SetColor(BOXBORDER_NH_R,0.9,BOXBORDER_HIGHLIGHTED_B);
203 _fillObjectActor->GetProperty()->SetColor(BOXFILL_NH_R,0.9,BOXFILL_HIGHLIGHTED_B);
207 else if(_state==HIGHLIGHTED)
209 _borderObjectActor->GetProperty()->SetLineWidth(2);
211 _borderObjectActor->GetProperty()->SetColor(BOXBORDER_HIGHLIGHTED_R,BOXBORDER_HIGHLIGHTED_G,BOXBORDER_HIGHLIGHTED_B);
212 _fillObjectActor->GetProperty()->SetColor(BOXFILL_HIGHLIGHTED_R,BOXFILL_HIGHLIGHTED_G,BOXFILL_HIGHLIGHTED_B);
213 _boxTextActor->GetTextProperty()->SetColor(BOXTEXT_HIGHLIGHTED_R,BOXTEXT_HIGHLIGHTED_G,BOXTEXT_HIGHLIGHTED_B);
215 else if(_state==DRAG)
217 _borderObjectActor->GetProperty()->SetLineWidth(1.2);
218 _borderObjectActor->GetProperty()->SetColor(BOXBORDER_DRAG_R,BOXBORDER_DRAG_G,BOXBORDER_DRAG_B);
219 _fillObjectActor->GetProperty()->SetColor(BOXFILL_DRAG_R,BOXFILL_DRAG_G,BOXFILL_DRAG_B);
220 _boxTextActor->GetTextProperty()->SetColor(BOXTEXT_DRAG_R,BOXTEXT_DRAG_G,BOXTEXT_DRAG_B);
222 else if(_state==SELECTED)
224 _borderObjectActor->GetProperty()->SetLineWidth(2);
225 _borderObjectActor->GetProperty()->SetColor(BOXBORDER_SELECTED_R,BOXBORDER_SELECTED_G,BOXBORDER_SELECTED_B);
226 _fillObjectActor->GetProperty()->SetColor(BOXFILL_SELECTED_R,BOXFILL_SELECTED_G,BOXFILL_SELECTED_B);
227 _boxTextActor->GetTextProperty()->SetColor(BOXTEXT_SELECTED_R,BOXTEXT_SELECTED_G,BOXTEXT_SELECTED_B);
231 //=========================================================================
233 } // EO namespace bbtk