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::vtkGBoxView
37 #include "vtkGBoxView.h"
43 //=========================================================================
44 vtkGBoxView::vtkGBoxView()
48 //=========================================================================
49 vtkGBoxView::~vtkGBoxView()
53 //=========================================================================
54 void vtkGBoxView::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=GPOSITION_Z
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();
79 //=========================================================================
81 void vtkGBoxView::createVtkObjects() //virtual
85 _pts = vtkPoints::New();
86 vtkCellArray *lines = vtkCellArray::New();
87 vtkPolyData *_pd = vtkPolyData::New();
88 _borderPolyMapper = vtkPolyDataMapper::New();
89 _borderObjectActor = vtkActor::New();
91 _pts->SetNumberOfPoints(4);
93 double xInic, yInic,zInic,xFin, yFin,zFin;
94 _model->getInicPoint(xInic,yInic,zInic);
95 _model->getFinalPoint(xFin, yFin,zFin);
97 // RaC In the actual version, zInic=zFin=GPOSITION_Z
99 //EED _pts->SetPoint(0, xInic, yInic, zInic );
100 //EED _pts->SetPoint(1, xInic, yFin, zInic );
101 //EED _pts->SetPoint(2, xFin, yFin, zFin );
102 //EED _pts->SetPoint(3, xFin, yInic, zFin );
104 _pts->SetPoint(0, -1000, -1000, -1000 );
105 _pts->SetPoint(1, xInic, yFin, zInic );
106 _pts->SetPoint(2, 1000, 1000, 1000 );
107 _pts->SetPoint(3, xFin, yInic, zFin );
111 lines->InsertNextCell(5);
112 lines->InsertCellPoint(0);
113 lines->InsertCellPoint(1);
114 lines->InsertCellPoint(2);
115 lines->InsertCellPoint(3);
116 lines->InsertCellPoint(0);
118 _pd->SetPoints( _pts );
119 _pd->SetLines( lines );
121 _borderPolyMapper->SetInput(_pd);
122 _borderObjectActor->SetMapper(_borderPolyMapper);
123 _borderPolyMapper->Modified();
126 ///************************* FILL *************************
128 vtkCellArray *strip = vtkCellArray::New();
129 vtkPolyData *pdFill = vtkPolyData::New();
130 _fillPolyMapper = vtkPolyDataMapper::New();
131 _fillObjectActor = vtkActor::New();
133 // RaC In the actual version, zInic=zFin=GPOSITION_Z
135 strip->InsertNextCell(5);
136 strip->InsertCellPoint(0);
137 strip->InsertCellPoint(1);
138 strip->InsertCellPoint(2);
139 strip->InsertCellPoint(0);
140 strip->InsertCellPoint(3);
142 pdFill->SetPoints( _pts );
143 pdFill->SetStrips( strip );
145 _fillPolyMapper->SetInput(pdFill);
146 _fillObjectActor->SetMapper(_fillPolyMapper);
147 _fillPolyMapper->Modified();
149 ///************************* FILL *************************
153 //=========================================================================
155 void vtkGBoxView::addVtkActors()//virtual
157 _baseView->GetRenderer()->AddActor(_borderObjectActor);
158 vtkGObjectView::addVtkActors();
161 //=========================================================================
163 void vtkGBoxView::removeVtkActors()//virtual
165 _baseView->GetRenderer()->RemoveActor(_borderObjectActor);
166 vtkGObjectView::removeVtkActors();
169 //=========================================================================
171 void vtkGBoxView::updateColors()
173 _fillObjectActor->GetProperty()->SetAmbient(0.6);
175 if(_state==NOTHING_HAPPENS)
177 _borderObjectActor->GetProperty()->SetLineWidth(1);
178 _borderObjectActor->GetProperty()->SetColor(BOXBORDER_NH_R,BOXBORDER_NH_G,BOXBORDER_NH_B);
179 _fillObjectActor->GetProperty()->SetColor(BOXFILL_NH_R,BOXFILL_NH_G,BOXFILL_NH_B);
182 else if(_state==HIGHLIGHTED)
184 _borderObjectActor->GetProperty()->SetLineWidth(2);
186 _borderObjectActor->GetProperty()->SetColor(BOXBORDER_HIGHLIGHTED_R,BOXBORDER_HIGHLIGHTED_G,BOXBORDER_HIGHLIGHTED_B);
187 _fillObjectActor->GetProperty()->SetColor(BOXFILL_HIGHLIGHTED_R,BOXFILL_HIGHLIGHTED_G,BOXFILL_HIGHLIGHTED_B);
189 else if(_state==DRAG)
191 _borderObjectActor->GetProperty()->SetLineWidth(1.2);
192 _borderObjectActor->GetProperty()->SetColor(BOXBORDER_DRAG_R,BOXBORDER_DRAG_G,BOXBORDER_DRAG_B);
193 _fillObjectActor->GetProperty()->SetColor(BOXFILL_DRAG_R,BOXFILL_DRAG_G,BOXFILL_DRAG_B);
195 else if(_state==SELECTED)
197 _borderObjectActor->GetProperty()->SetLineWidth(2);
198 _borderObjectActor->GetProperty()->SetColor(BOXBORDER_SELECTED_R,BOXBORDER_SELECTED_G,BOXBORDER_SELECTED_B);
199 _fillObjectActor->GetProperty()->SetColor(BOXFILL_SELECTED_R,BOXFILL_SELECTED_G,BOXFILL_SELECTED_B);
203 //=========================================================================
205 void vtkGBoxView::updatePorts()
207 GBoxModel* bmod =(GBoxModel*)_model;
211 //=========================================================================
213 } // EO namespace bbtk