2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
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.
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
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 # ------------------------------------------------------------------------
27 /*=========================================================================
33 =========================================================================*/
35 /* ---------------------------------------------------------------------
37 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
38 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
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.
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
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 * ------------------------------------------------------------------------ */
59 * \brief Class bbtk::vtkGPortView
63 #include "vtkGPortView.h"
68 //=========================================================================
70 vtkGPortView::vtkGPortView( ) {
73 //=========================================================================
75 vtkGPortView::~vtkGPortView( ) {
78 //=========================================================================
80 void vtkGPortView::update( int idController , int command )
84 double xInic , yInic , zInic , xFin , yFin , zFin ;
85 _model->getInicPoint( xInic , yInic , zInic ) ;
86 _model->getFinalPoint( xFin , yFin , zFin ) ;
87 // RaC In the actual version, zInic=zFin=GPOSITION_Z
88 double mid = ( xInic + xFin ) / 2 ;
89 _pts->SetPoint( 0 , xInic , yInic , zInic ) ;
90 _pts->SetPoint( 1 , mid , yFin , zInic ) ;
91 _pts->SetPoint( 2 , xFin , yInic , zFin ) ;
92 _fillPolyMapper->Modified( ) ;
94 setRefreshWaiting( ) ;
97 //=========================================================================
99 void vtkGPortView::createVtkObjects( ) //virtual
102 double xInic , yInic , zInic , xFin , yFin , zFin ;
104 _model->getInicPoint( xInic , yInic , zInic ) ;
105 _model->getFinalPoint( xFin , yFin , zFin ) ;
107 // RaC In the actual version, zInic=zFin=GPOSITION_Z
109 double mid = ( xInic + xFin ) / 2 ;
111 //EED _pts->SetPoint(0, xInic, yInic, zInic );
112 //EED _pts->SetPoint(1, mid, yFin, zInic );
113 //EED _pts->SetPoint(2, xFin, yInic, zFin );
115 _pts = vtkPoints::New( ) ;
116 _pts->SetNumberOfPoints( 3 ) ;
119 // _pts->SetPoint( 0 , -1000 , -1000 , -1000 ) ;
120 // _pts->SetPoint( 1 , mid , yFin , zInic ) ;
121 // _pts->SetPoint( 2 , 1000 , 1000 , 1000 ) ;
124 ///************************* FILL *************************
126 vtkCellArray *strip = vtkCellArray::New( ) ;
127 vtkPolyData *pdFill = vtkPolyData::New( ) ;
128 _fillPolyMapper = vtkPolyDataMapper::New( ) ;
129 _fillObjectActor = vtkActor::New( ) ;
131 // RaC In the actual version, zInic=zFin=GPOSITION_Z
133 strip->InsertNextCell( 3 ) ;
134 strip->InsertCellPoint( 0 ) ;
135 strip->InsertCellPoint( 1 ) ;
136 strip->InsertCellPoint( 2 ) ;
138 pdFill->SetPoints( _pts ) ;
139 pdFill->SetStrips( strip ) ;
141 //EED 2017-01-01 Migration VTK7
142 #if VTK_MAJOR_VERSION <= 5
143 _fillPolyMapper->SetInput( pdFill ) ;
145 _fillPolyMapper->SetInputData( pdFill ) ;
148 _fillObjectActor->SetMapper( _fillPolyMapper ) ;
149 _fillPolyMapper->Modified( ) ;
151 ///************************* FILL *************************
158 //=========================================================================
160 void vtkGPortView::updateColors( )
165 _fillObjectActor->GetProperty( )->SetColor( rgb[0] , rgb[1] , rgb[2] ) ;
168 //=========================================================================
170 void vtkGPortView::getColors(float* rgb)
172 rgb[0]=0.45; rgb[1]=0.45; rgb[2]=0.45;
174 if ( _state == POSSIBLE_CONNECTION ) {
175 rgb[0]=1; rgb[1]=1; rgb[2]=0;
176 } else if ( _state == SELECTED_POSSIBLE_CONNECTION ) {
177 rgb[0]=0; rgb[1]=1; rgb[2]=0;
178 } else if ( _state == HIGHLIGHTED ) {
179 rgb[0]=0; rgb[1]=0; rgb[2]=1;
181 GPortModel* portm = ( GPortModel* ) _model ;
182 if ( portm->isConnected( ) ) {
183 rgb[0]=0.15; rgb[1]=0.15; rgb[2]=0.15;
184 } else if ( portm->isValueSet( ) ) {
185 rgb[0]=0.55; rgb[1]=0.25; rgb[2]=0.25;
187 rgb[0]=0.45; rgb[1]=0.45; rgb[2]=0.45;
192 } // EO namespace bbtk