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 );
71 _borderPolyMapper->Modified();
72 _fillPolyMapper->Modified();
75 updatePositionTextActor(xInic, yInic,zInic);
81 //=========================================================================
83 void vtkGBlackBoxView::createVtkObjects() //virtual
87 _pts = vtkPoints::New();
88 vtkCellArray *lines = vtkCellArray::New();
89 vtkPolyData *_pd = vtkPolyData::New();
90 _borderPolyMapper = vtkPolyDataMapper::New();
91 _borderObjectActor = vtkActor::New();
93 _pts->SetNumberOfPoints(4);
95 double xInic, yInic,zInic,xFin, yFin,zFin;
96 _model->getInicPoint(xInic,yInic,zInic);
97 _model->getFinalPoint(xFin, yFin,zFin);
99 // RaC In the actual version, zInic=zFin=900
101 //EED _pts->SetPoint(0, xInic, yInic, zInic );
102 //EED _pts->SetPoint(1, xInic, yFin, zInic );
103 //EED _pts->SetPoint(2, xFin, yFin, zFin );
104 //EED _pts->SetPoint(3, xFin, yInic, zFin );
106 _pts->SetPoint(0, -1000, -1000, -1000 );
107 _pts->SetPoint(1, xInic, yFin, zInic );
108 _pts->SetPoint(2, 1000, 1000, 1000 );
109 _pts->SetPoint(3, xFin, yInic, zFin );
113 lines->InsertNextCell(5);
114 lines->InsertCellPoint(0);
115 lines->InsertCellPoint(1);
116 lines->InsertCellPoint(2);
117 lines->InsertCellPoint(3);
118 lines->InsertCellPoint(0);
120 _pd->SetPoints( _pts );
121 _pd->SetLines( lines );
123 _borderPolyMapper->SetInput(_pd);
124 _borderObjectActor->SetMapper(_borderPolyMapper);
125 _borderPolyMapper->Modified();
128 ///************************* FILL *************************
130 vtkCellArray *strip = vtkCellArray::New();
131 vtkPolyData *pdFill = vtkPolyData::New();
132 _fillPolyMapper = vtkPolyDataMapper::New();
133 _fillObjectActor = vtkActor::New();
135 // RaC In the actual version, zInic=zFin=900
137 strip->InsertNextCell(5);
138 strip->InsertCellPoint(0);
139 strip->InsertCellPoint(1);
140 strip->InsertCellPoint(2);
141 strip->InsertCellPoint(0);
142 strip->InsertCellPoint(3);
144 pdFill->SetPoints( _pts );
145 pdFill->SetStrips( strip );
147 _fillPolyMapper->SetInput(pdFill);
148 _fillObjectActor->SetMapper(_fillPolyMapper);
149 _fillPolyMapper->Modified();
151 ///************************* FILL *************************
155 _boxTextActor = vtkTextActor3D::New();
156 _boxTextActor->GetTextProperty()->SetFontSize(80);
157 _boxTextActor->GetTextProperty()->BoldOn();
161 updatePositionTextActor( xInic, yInic, zInic);
164 //=========================================================================
166 void vtkGBlackBoxView::addVtkActors()//virtual
168 _baseView->GetRenderer()->AddActor(_borderObjectActor);
169 _baseView->GetRenderer()->AddActor(_boxTextActor);
170 vtkGObjectView::addVtkActors();
173 //=========================================================================
175 void vtkGBlackBoxView::removeVtkActors()//virtual
177 _baseView->GetRenderer()->RemoveActor(_borderObjectActor);
178 _baseView->GetRenderer()->RemoveActor(_boxTextActor);
179 vtkGObjectView::removeVtkActors();
182 //=========================================================================
184 void vtkGBlackBoxView::updatePositionTextActor(double xInic, double yInic, double zInic)
186 std::string temp = _model->getBBTKType();
188 temp+=_model->getBBTKName();
189 _boxTextActor->SetInput(temp.c_str());
190 _boxTextActor->SetPosition(xInic+4,yInic-7,zInic);
191 _boxTextActor->SetScale(0.05,0.05,1);
194 //=========================================================================
196 void vtkGBlackBoxView::updateColors()
198 _fillObjectActor->GetProperty()->SetAmbient(0.6);
200 if(_state==NOTHING_HAPPENS)
202 _borderObjectActor->GetProperty()->SetLineWidth(1);
203 _borderObjectActor->GetProperty()->SetColor(BOXBORDER_NH_R,BOXBORDER_NH_G,BOXBORDER_NH_B);
204 _fillObjectActor->GetProperty()->SetColor(BOXFILL_NH_R,BOXFILL_NH_G,BOXFILL_NH_B);
205 _boxTextActor->GetTextProperty()->SetColor(BOXTEXT_NH_R,BOXTEXT_NH_G,BOXTEXT_NH_B);
207 GBlackBoxModel *bbmodel = (GBlackBoxModel*)_model;
208 if(bbmodel->isExecutable())
210 _borderObjectActor->GetProperty()->SetColor(BOXBORDER_NH_R,0.9,BOXBORDER_HIGHLIGHTED_B);
211 _fillObjectActor->GetProperty()->SetColor(BOXFILL_NH_R,0.9,BOXFILL_HIGHLIGHTED_B);
215 else if(_state==HIGHLIGHTED)
217 _borderObjectActor->GetProperty()->SetLineWidth(2);
219 _borderObjectActor->GetProperty()->SetColor(BOXBORDER_HIGHLIGHTED_R,BOXBORDER_HIGHLIGHTED_G,BOXBORDER_HIGHLIGHTED_B);
220 _fillObjectActor->GetProperty()->SetColor(BOXFILL_HIGHLIGHTED_R,BOXFILL_HIGHLIGHTED_G,BOXFILL_HIGHLIGHTED_B);
221 _boxTextActor->GetTextProperty()->SetColor(BOXTEXT_HIGHLIGHTED_R,BOXTEXT_HIGHLIGHTED_G,BOXTEXT_HIGHLIGHTED_B);
223 else if(_state==DRAG)
225 _borderObjectActor->GetProperty()->SetLineWidth(1.2);
226 _borderObjectActor->GetProperty()->SetColor(BOXBORDER_DRAG_R,BOXBORDER_DRAG_G,BOXBORDER_DRAG_B);
227 _fillObjectActor->GetProperty()->SetColor(BOXFILL_DRAG_R,BOXFILL_DRAG_G,BOXFILL_DRAG_B);
228 _boxTextActor->GetTextProperty()->SetColor(BOXTEXT_DRAG_R,BOXTEXT_DRAG_G,BOXTEXT_DRAG_B);
230 else if(_state==SELECTED)
232 _borderObjectActor->GetProperty()->SetLineWidth(2);
233 _borderObjectActor->GetProperty()->SetColor(BOXBORDER_SELECTED_R,BOXBORDER_SELECTED_G,BOXBORDER_SELECTED_B);
234 _fillObjectActor->GetProperty()->SetColor(BOXFILL_SELECTED_R,BOXFILL_SELECTED_G,BOXFILL_SELECTED_B);
235 _boxTextActor->GetTextProperty()->SetColor(BOXTEXT_SELECTED_R,BOXTEXT_SELECTED_G,BOXTEXT_SELECTED_B);
239 //=========================================================================
242 } // EO namespace bbtk