]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGComplexBoxPortView.cxx
#3066 bbGEditor Bug New Normal - Refresh vtk objects
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsVtkGUIEditorGraphic / vtkGComplexBoxPortView.cxx
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5 #                        pour la Santé)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 #
8 #  This software is governed by the CeCILL-B license under French law and 
9 #  abiding by the rules of distribution of free software. You can  use, 
10 #  modify and/ or redistribute the software under the terms of the CeCILL-B 
11 #  license as circulated by CEA, CNRS and INRIA at the following URL 
12 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
13 #  or in the file LICENSE.txt.
14 #
15 #  As a counterpart to the access to the source code and  rights to copy,
16 #  modify and redistribute granted by the license, users are provided only
17 #  with a limited warranty  and the software's author,  the holder of the
18 #  economic rights,  and the successive licensors  have only  limited
19 #  liability. 
20 #
21 #  The fact that you are presently reading this means that you have had
22 #  knowledge of the CeCILL-B license and that you accept its terms.
23 # ------------------------------------------------------------------------  
24 */
25
26
27 /*=========================================================================                                                                               
28 Program:   bbtk
29 Module:    $RCSfile$
30 Language:  C++
31 Date:      $Date$
32 Version:   $Revision$
33 =========================================================================*/
34
35 /* ---------------------------------------------------------------------
36
37  * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
38  * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
39  *
40  *  This software is governed by the CeCILL-B license under French law and 
41  *  abiding by the rules of distribution of free software. You can  use, 
42  *  modify and/ or redistribute the software under the terms of the CeCILL-B 
43  *  license as circulated by CEA, CNRS and INRIA at the following URL 
44  *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
45  *  or in the file LICENSE.txt.
46  *
47  *  As a counterpart to the access to the source code and  rights to copy,
48  *  modify and redistribute granted by the license, users are provided only
49  *  with a limited warranty  and the software's author,  the holder of the
50  *  economic rights,  and the successive licensors  have only  limited
51  *  liability. 
52  *
53  *  The fact that you are presently reading this means that you have had
54  *  knowledge of the CeCILL-B license and that you accept its terms.
55  * ------------------------------------------------------------------------ */
56
57 /**
58  *  \file 
59  *  \brief Class bbtk::vtkGComplexBoxPortView 
60  */
61
62
63 #include "vtkGComplexBoxPortView.h"
64
65 namespace bbtk {
66
67
68     //=========================================================================
69
70     vtkGComplexBoxPortView::vtkGComplexBoxPortView( ) 
71         {
72     }
73
74     //=========================================================================
75
76     vtkGComplexBoxPortView::~vtkGComplexBoxPortView( ) 
77         {
78     }
79
80
81 /*EED Borrame
82     //=========================================================================
83     void vtkGComplexBoxPortView::update( int idController , int command ) 
84         {
85         updateColors( ) ;
86         double xInic , yInic , zInic , xFin , yFin , zFin ;
87         _model->getInicPoint( xInic , yInic , zInic ) ;
88         _model->getFinalPoint( xFin , yFin , zFin ) ;
89         // RaC In the actual version, zInic=zFin=GPOSITION_Z
90         _pts->SetPoint( 0 , xInic , yInic , zInic ) ;
91         _pts->SetPoint( 1 , xInic , yFin , zInic ) ;
92         _pts->SetPoint( 2 , xFin , yFin , zFin ) ;
93         _pts->SetPoint( 3 , xFin , yInic , zFin ) ;
94         updatePorts( ) ;
95 //        _borderPolyMapper->Modified( ) ;
96         _fillPolyMapper->Modified( ) ;
97         //-----------
98
99         setRefreshWaiting( ) ;
100     }
101 */
102
103     //=========================================================================
104
105     void vtkGComplexBoxPortView::createVtkObjects( ) //virtual
106     {
107
108         //------------
109         _pts = vtkPoints::New( ) ;
110 //        vtkCellArray *lines = vtkCellArray::New( ) ;
111 //        vtkPolyData *_pd = vtkPolyData::New( ) ;
112 //        _borderPolyMapper = vtkPolyDataMapper::New( ) ;
113 //        _borderObjectActor = vtkActor::New( ) ;
114
115         _pts->SetNumberOfPoints( 4 ) ;
116
117         double xInic , yInic , zInic , xFin , yFin , zFin ;
118         _model->getInicPoint( xInic , yInic , zInic ) ;
119         _model->getFinalPoint( xFin , yFin , zFin ) ;
120
121         // RaC In the actual version, zInic=zFin=GPOSITION_Z
122
123         //EED           _pts->SetPoint(0, xInic, yInic, zInic );
124         //EED           _pts->SetPoint(1, xInic, yFin, zInic );
125         //EED           _pts->SetPoint(2, xFin, yFin, zFin );
126         //EED           _pts->SetPoint(3, xFin, yInic, zFin );
127
128 //EED 2017-03-02
129 //        _pts->SetPoint( 0 , -1000 , -1000 , -1000 ) ;
130 //        _pts->SetPoint( 1 , xInic , yFin , zInic ) ;
131 //        _pts->SetPoint( 2 , 1000 , 1000 , 1000 ) ;
132 //        _pts->SetPoint( 3 , xFin , yInic , zFin ) ;
133
134
135 //        lines->InsertNextCell( 5 ) ;
136 //        lines->InsertCellPoint( 0 ) ;
137 //        lines->InsertCellPoint( 1 ) ;
138 //        lines->InsertCellPoint( 2 ) ;
139 //        lines->InsertCellPoint( 3 ) ;
140 //        lines->InsertCellPoint( 0 ) ;
141 //      _pd->SetPoints( _pts ) ;
142 //        _pd->SetLines( lines ) ;
143 //        _borderPolyMapper->SetInput( _pd ) ;
144 //        _borderObjectActor->SetMapper( _borderPolyMapper ) ;
145 //        _borderPolyMapper->Modified( ) ;
146
147
148         ///************************* FILL *************************
149         vtkCellArray *strip = vtkCellArray::New( ) ;
150         vtkPolyData *pdFill = vtkPolyData::New( ) ;
151         _fillPolyMapper = vtkPolyDataMapper::New( ) ;
152         _fillObjectActor = vtkActor::New( ) ;
153         // RaC In the actual version, zInic=zFin=GPOSITION_Z
154         strip->InsertNextCell( 5 ) ;
155         strip->InsertCellPoint( 0 ) ;
156         strip->InsertCellPoint( 1 ) ;
157         strip->InsertCellPoint( 2 ) ;
158         strip->InsertCellPoint( 0 ) ;
159         strip->InsertCellPoint( 3 ) ;
160         pdFill->SetPoints( _pts ) ;
161         pdFill->SetStrips( strip ) ;
162         _fillPolyMapper->SetInput( pdFill ) ;
163         _fillObjectActor->SetMapper( _fillPolyMapper ) ;
164         _fillPolyMapper->Modified( ) ;
165         ///************************* FILL *************************
166
167                 createVtkInputOutputPorts();
168
169     }
170
171     //=========================================================================
172
173     void vtkGComplexBoxPortView::addVtkActors( )//virtual
174     {
175 //        _baseView->GetRenderer( )->AddActor( _borderObjectActor ) ;
176         vtkGBoxView::addVtkActors( ) ;
177     }
178
179     //=========================================================================
180
181     void vtkGComplexBoxPortView::removeVtkActors( )//virtual
182     {
183 //        _baseView->GetRenderer( )->RemoveActor( _borderObjectActor ) ;
184         vtkGBoxView::removeVtkActors( ) ;
185     }
186
187     //=========================================================================
188
189     void vtkGComplexBoxPortView::updateColors( ) {
190         _fillObjectActor->GetProperty( )->SetAmbient( 0.6 ) ;
191
192         if ( _state == NOTHING_HAPPENS ) 
193         {
194 //            _borderObjectActor->GetProperty( )->SetLineWidth( 1 ) ;
195             GComplexBoxPortModel *portModel = ( GComplexBoxPortModel* ) _model ;
196             if ( portModel->getComplexPortType( ) == GCOMPLEXINPUTPORT ) {
197                 _fillObjectActor->GetProperty( )->SetColor( COMPLEXINPUTPORTFILL_NH_R , COMPLEXINPUTPORTFILL_NH_G , COMPLEXINPUTPORTFILL_NH_B ) ;
198 //                _borderObjectActor->GetProperty( )->SetColor( COMPLEXINPUTPORTBORDER_NH_R , COMPLEXINPUTPORTBORDER_NH_G , COMPLEXINPUTPORTBORDER_NH_B ) ;
199             } else if ( portModel->getComplexPortType( ) == GCOMPLEXOUTPUTPORT ) {
200                 _fillObjectActor->GetProperty( )->SetColor( COMPLEXOUTPUTPORTFILL_NH_R , COMPLEXOUTPUTPORTFILL_NH_G , COMPLEXOUTPUTPORTFILL_NH_B ) ;
201 //                _borderObjectActor->GetProperty( )->SetColor( COMPLEXOUTPUTPORTBORDER_NH_R , COMPLEXOUTPUTPORTBORDER_NH_G , COMPLEXOUTPUTPORTBORDER_NH_B ) ;
202             }
203
204         } else if ( _state == HIGHLIGHTED ) {
205 //            _borderObjectActor->GetProperty( )->SetLineWidth( 2 ) ;
206 //            _borderObjectActor->GetProperty( )->SetColor( BOXBORDER_HIGHLIGHTED_R , BOXBORDER_HIGHLIGHTED_G , BOXBORDER_HIGHLIGHTED_B ) ;
207             _fillObjectActor->GetProperty( )->SetColor( BOXFILL_HIGHLIGHTED_R , BOXFILL_HIGHLIGHTED_G , BOXFILL_HIGHLIGHTED_B ) ;
208         } else if ( _state == DRAG ) {
209 //            _borderObjectActor->GetProperty( )->SetLineWidth( 1.2 ) ;
210 //            _borderObjectActor->GetProperty( )->SetColor( BOXBORDER_DRAG_R , BOXBORDER_DRAG_G , BOXBORDER_DRAG_B ) ;
211             _fillObjectActor->GetProperty( )->SetColor( BOXFILL_DRAG_R , BOXFILL_DRAG_G , BOXFILL_DRAG_B ) ;
212         } else if ( _state == SELECTED ) {
213 //            _borderObjectActor->GetProperty( )->SetLineWidth( 2 ) ;
214 //            _borderObjectActor->GetProperty( )->SetColor( BOXBORDER_SELECTED_R , BOXBORDER_SELECTED_G , BOXBORDER_SELECTED_B ) ;
215             _fillObjectActor->GetProperty( )->SetColor( BOXFILL_SELECTED_R , BOXFILL_SELECTED_G , BOXFILL_SELECTED_B ) ;
216         }
217     }
218
219     //=========================================================================
220
221
222 } // EO namespace bbtk
223
224 // EOF
225