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::vtkGComplexBoxPortView
37 #include "vtkGComplexBoxPortView.h"
42 //=========================================================================
44 vtkGComplexBoxPortView::vtkGComplexBoxPortView( ) {
47 //=========================================================================
49 vtkGComplexBoxPortView::~vtkGComplexBoxPortView( ) {
52 //=========================================================================
54 void vtkGComplexBoxPortView::update( int idController , int command ) {
57 double xInic , yInic , zInic , xFin , yFin , zFin ;
58 _model->getInicPoint( xInic , yInic , zInic ) ;
59 _model->getFinalPoint( xFin , yFin , zFin ) ;
61 // RaC In the actual version, zInic=zFin=900
63 _pts->SetPoint( 0 , xInic , yInic , zInic ) ;
64 _pts->SetPoint( 1 , xInic , yFin , zInic ) ;
65 _pts->SetPoint( 2 , xFin , yFin , zFin ) ;
66 _pts->SetPoint( 3 , xFin , yInic , zFin ) ;
70 _borderPolyMapper->Modified( ) ;
71 _fillPolyMapper->Modified( ) ;
75 setRefreshWaiting( ) ;
78 //=========================================================================
80 void vtkGComplexBoxPortView::createVtkObjects( ) //virtual
84 _pts = vtkPoints::New( ) ;
85 vtkCellArray *lines = vtkCellArray::New( ) ;
86 vtkPolyData *_pd = vtkPolyData::New( ) ;
87 _borderPolyMapper = vtkPolyDataMapper::New( ) ;
88 _borderObjectActor = 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 //EED _pts->SetPoint(0, xInic, yInic, zInic );
99 //EED _pts->SetPoint(1, xInic, yFin, zInic );
100 //EED _pts->SetPoint(2, xFin, yFin, zFin );
101 //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 ) ;
110 lines->InsertNextCell( 5 ) ;
111 lines->InsertCellPoint( 0 ) ;
112 lines->InsertCellPoint( 1 ) ;
113 lines->InsertCellPoint( 2 ) ;
114 lines->InsertCellPoint( 3 ) ;
115 lines->InsertCellPoint( 0 ) ;
117 _pd->SetPoints( _pts ) ;
118 _pd->SetLines( lines ) ;
120 _borderPolyMapper->SetInput( _pd ) ;
121 _borderObjectActor->SetMapper( _borderPolyMapper ) ;
122 _borderPolyMapper->Modified( ) ;
125 ///************************* FILL *************************
127 vtkCellArray *strip = vtkCellArray::New( ) ;
128 vtkPolyData *pdFill = vtkPolyData::New( ) ;
129 _fillPolyMapper = vtkPolyDataMapper::New( ) ;
130 _fillObjectActor = vtkActor::New( ) ;
132 // RaC In the actual version, zInic=zFin=900
134 strip->InsertNextCell( 5 ) ;
135 strip->InsertCellPoint( 0 ) ;
136 strip->InsertCellPoint( 1 ) ;
137 strip->InsertCellPoint( 2 ) ;
138 strip->InsertCellPoint( 0 ) ;
139 strip->InsertCellPoint( 3 ) ;
141 pdFill->SetPoints( _pts ) ;
142 pdFill->SetStrips( strip ) ;
144 _fillPolyMapper->SetInput( pdFill ) ;
145 _fillObjectActor->SetMapper( _fillPolyMapper ) ;
146 _fillPolyMapper->Modified( ) ;
148 ///************************* FILL *************************
152 //=========================================================================
154 void vtkGComplexBoxPortView::addVtkActors( )//virtual
156 _baseView->GetRenderer( )->AddActor( _borderObjectActor ) ;
157 vtkGObjectView::addVtkActors( ) ;
160 //=========================================================================
162 void vtkGComplexBoxPortView::removeVtkActors( )//virtual
164 _baseView->GetRenderer( )->RemoveActor( _borderObjectActor ) ;
165 vtkGObjectView::removeVtkActors( ) ;
168 //=========================================================================
170 void vtkGComplexBoxPortView::updateColors( ) {
171 _fillObjectActor->GetProperty( )->SetAmbient( 0.6 ) ;
173 if ( _state == NOTHING_HAPPENS ) {
174 _borderObjectActor->GetProperty( )->SetLineWidth( 1 ) ;
177 GComplexBoxPortModel *portModel = ( GComplexBoxPortModel* ) _model ;
178 if ( portModel->getComplexPortType( ) == GCOMPLEXINPUTPORT ) {
179 _fillObjectActor->GetProperty( )->SetColor( COMPLEXINPUTPORTFILL_NH_R , COMPLEXINPUTPORTFILL_NH_G , COMPLEXINPUTPORTFILL_NH_B ) ;
180 _borderObjectActor->GetProperty( )->SetColor( COMPLEXINPUTPORTBORDER_NH_R , COMPLEXINPUTPORTBORDER_NH_G , COMPLEXINPUTPORTBORDER_NH_B ) ;
181 } else if ( portModel->getComplexPortType( ) == GCOMPLEXOUTPUTPORT ) {
182 _fillObjectActor->GetProperty( )->SetColor( COMPLEXOUTPUTPORTFILL_NH_R , COMPLEXOUTPUTPORTFILL_NH_G , COMPLEXOUTPUTPORTFILL_NH_B ) ;
183 _borderObjectActor->GetProperty( )->SetColor( COMPLEXOUTPUTPORTBORDER_NH_R , COMPLEXOUTPUTPORTBORDER_NH_G , COMPLEXOUTPUTPORTBORDER_NH_B ) ;
186 } else if ( _state == HIGHLIGHTED ) {
187 _borderObjectActor->GetProperty( )->SetLineWidth( 2 ) ;
189 _borderObjectActor->GetProperty( )->SetColor( BOXBORDER_HIGHLIGHTED_R , BOXBORDER_HIGHLIGHTED_G , BOXBORDER_HIGHLIGHTED_B ) ;
190 _fillObjectActor->GetProperty( )->SetColor( BOXFILL_HIGHLIGHTED_R , BOXFILL_HIGHLIGHTED_G , BOXFILL_HIGHLIGHTED_B ) ;
191 } else if ( _state == DRAG ) {
192 _borderObjectActor->GetProperty( )->SetLineWidth( 1.2 ) ;
193 _borderObjectActor->GetProperty( )->SetColor( BOXBORDER_DRAG_R , BOXBORDER_DRAG_G , BOXBORDER_DRAG_B ) ;
194 _fillObjectActor->GetProperty( )->SetColor( BOXFILL_DRAG_R , BOXFILL_DRAG_G , BOXFILL_DRAG_B ) ;
195 } else if ( _state == SELECTED ) {
196 _borderObjectActor->GetProperty( )->SetLineWidth( 2 ) ;
197 _borderObjectActor->GetProperty( )->SetColor( BOXBORDER_SELECTED_R , BOXBORDER_SELECTED_G , BOXBORDER_SELECTED_B ) ;
198 _fillObjectActor->GetProperty( )->SetColor( BOXFILL_SELECTED_R , BOXFILL_SELECTED_G , BOXFILL_SELECTED_B ) ;
202 //=========================================================================
205 } // EO namespace bbtk