]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx
Feature #1771 Add licence terms for all files.
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsVtkGUIEditorGraphic / vtkGPortView.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::vtkGPortView 
60  */
61
62
63 #include "vtkGPortView.h"
64
65 namespace bbtk {
66
67
68     //=========================================================================
69
70     vtkGPortView::vtkGPortView( ) {
71     }
72
73     //=========================================================================
74
75     vtkGPortView::~vtkGPortView( ) {
76     }
77
78     //=========================================================================
79
80     void vtkGPortView::update( int idController , int command ) {
81
82         updateColors( ) ;
83
84         double xInic , yInic , zInic , xFin , yFin , zFin ;
85
86         _model->getInicPoint( xInic , yInic , zInic ) ;
87         _model->getFinalPoint( xFin , yFin , zFin ) ;
88
89         // RaC In the actual version, zInic=zFin=GPOSITION_Z
90
91         double mid = ( xInic + xFin ) / 2 ;
92
93         _pts->SetPoint( 0 , xInic , yInic , zInic ) ;
94         _pts->SetPoint( 1 , mid , yFin , zInic ) ;
95         _pts->SetPoint( 2 , xFin , yInic , zFin ) ;
96
97         _fillPolyMapper->Modified( ) ;
98
99         //-----------
100         setRefreshWaiting( ) ;
101     }
102
103     //=========================================================================
104
105     void vtkGPortView::createVtkObjects( ) //virtual
106     {
107         _pts = vtkPoints::New( ) ;
108         _pts->SetNumberOfPoints( 3 ) ;
109
110         double xInic , yInic , zInic , xFin , yFin , zFin ;
111
112         _model->getInicPoint( xInic , yInic , zInic ) ;
113         _model->getFinalPoint( xFin , yFin , zFin ) ;
114
115         // RaC In the actual version, zInic=zFin=GPOSITION_Z
116
117         double mid = ( xInic + xFin ) / 2 ;
118
119         //EED           _pts->SetPoint(0, xInic, yInic, zInic );
120         //EED           _pts->SetPoint(1, mid, yFin, zInic );
121         //EED           _pts->SetPoint(2, xFin, yInic, zFin );                          
122
123         _pts->SetPoint( 0 , -1000 , -1000 , -1000 ) ;
124         _pts->SetPoint( 1 , mid , yFin , zInic ) ;
125         _pts->SetPoint( 2 , 1000 , 1000 , 1000 ) ;
126
127
128         ///************************* FILL *************************
129
130         vtkCellArray *strip = vtkCellArray::New( ) ;
131         vtkPolyData *pdFill = vtkPolyData::New( ) ;
132         _fillPolyMapper = vtkPolyDataMapper::New( ) ;
133         _fillObjectActor = vtkActor::New( ) ;
134
135         // RaC In the actual version, zInic=zFin=GPOSITION_Z
136
137         strip->InsertNextCell( 3 ) ;
138         strip->InsertCellPoint( 0 ) ;
139         strip->InsertCellPoint( 1 ) ;
140         strip->InsertCellPoint( 2 ) ;
141
142         pdFill->SetPoints( _pts ) ;
143         pdFill->SetStrips( strip ) ;
144
145         _fillPolyMapper->SetInput( pdFill ) ;
146         _fillObjectActor->SetMapper( _fillPolyMapper ) ;
147         _fillPolyMapper->Modified( ) ;
148
149         ///************************* FILL *************************
150
151         updateColors( ) ;
152
153
154     }
155
156     //=========================================================================
157
158     void vtkGPortView::updateColors( ) {
159         _fillObjectActor->GetProperty( )->SetColor( 0.45 , 0.45 , 0.45 ) ;
160
161         if ( _state == POSSIBLE_CONNECTION ) {
162             _fillObjectActor->GetProperty( )->SetColor( 1 , 1 , 0 ) ;
163         } else if ( _state == SELECTED_POSSIBLE_CONNECTION ) {
164             _fillObjectActor->GetProperty( )->SetColor( 0 , 1 , 0 ) ;
165         } else if ( _state == HIGHLIGHTED ) {
166             _fillObjectActor->GetProperty( )->SetColor( 0 , 0 , 1 ) ;
167         } else {
168             GPortModel* portm = ( GPortModel* ) _model ;
169             if ( portm->isConnected( ) ) {
170                 _fillObjectActor->GetProperty( )->SetColor( 0.15 , 0.15 , 0.15 ) ;
171             } else if ( portm->isValueSet( ) ) {
172                 _fillObjectActor->GetProperty( )->SetColor( 0.55 , 0.25 , 0.25 ) ;
173             } else {
174                 _fillObjectActor->GetProperty( )->SetColor( 0.45 , 0.45 , 0.45 ) ;
175             }
176         }
177     }
178
179     //=========================================================================
180
181
182 } // EO namespace bbtk
183
184 // EOF
185