vtkGPortView.cxx

Go to the documentation of this file.
00001 /*=========================================================================                                                                               
00002 Program:   bbtk
00003 Module:    $RCSfile: vtkGPortView.cxx,v $
00004 Language:  C++
00005 Date:      $Date: 2012/05/23 15:57:13 $
00006 Version:   $Revision: 1.17 $
00007 =========================================================================*/
00008 
00009 /* ---------------------------------------------------------------------
00010 
00011  * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
00012  * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
00013  *
00014  *  This software is governed by the CeCILL-B license under French law and 
00015  *  abiding by the rules of distribution of free software. You can  use, 
00016  *  modify and/ or redistribute the software under the terms of the CeCILL-B 
00017  *  license as circulated by CEA, CNRS and INRIA at the following URL 
00018  *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
00019  *  or in the file LICENSE.txt.
00020  *
00021  *  As a counterpart to the access to the source code and  rights to copy,
00022  *  modify and redistribute granted by the license, users are provided only
00023  *  with a limited warranty  and the software's author,  the holder of the
00024  *  economic rights,  and the successive licensors  have only  limited
00025  *  liability. 
00026  *
00027  *  The fact that you are presently reading this means that you have had
00028  *  knowledge of the CeCILL-B license and that you accept its terms.
00029  * ------------------------------------------------------------------------ */
00030 
00037 #include "vtkGPortView.h"
00038 
00039 namespace bbtk {
00040 
00041 
00042     //=========================================================================
00043 
00044     vtkGPortView::vtkGPortView( ) {
00045     }
00046 
00047     //=========================================================================
00048 
00049     vtkGPortView::~vtkGPortView( ) {
00050     }
00051 
00052     //=========================================================================
00053 
00054     void vtkGPortView::update( int idController , int command ) {
00055 
00056         updateColors( ) ;
00057 
00058         double xInic , yInic , zInic , xFin , yFin , zFin ;
00059 
00060         _model->getInicPoint( xInic , yInic , zInic ) ;
00061         _model->getFinalPoint( xFin , yFin , zFin ) ;
00062 
00063         // RaC In the actual version, zInic=zFin=900
00064 
00065         double mid = ( xInic + xFin ) / 2 ;
00066 
00067         _pts->SetPoint( 0 , xInic , yInic , zInic ) ;
00068         _pts->SetPoint( 1 , mid , yFin , zInic ) ;
00069         _pts->SetPoint( 2 , xFin , yInic , zFin ) ;
00070 
00071         _fillPolyMapper->Modified( ) ;
00072 
00073         //-----------
00074         setRefreshWaiting( ) ;
00075     }
00076 
00077     //=========================================================================
00078 
00079     void vtkGPortView::createVtkObjects( ) //virtual
00080     {
00081         _pts = vtkPoints::New( ) ;
00082         _pts->SetNumberOfPoints( 3 ) ;
00083 
00084         double xInic , yInic , zInic , xFin , yFin , zFin ;
00085 
00086         _model->getInicPoint( xInic , yInic , zInic ) ;
00087         _model->getFinalPoint( xFin , yFin , zFin ) ;
00088 
00089         // RaC In the actual version, zInic=zFin=900
00090 
00091         double mid = ( xInic + xFin ) / 2 ;
00092 
00093         //EED           _pts->SetPoint(0, xInic, yInic, zInic );
00094         //EED           _pts->SetPoint(1, mid, yFin, zInic );
00095         //EED           _pts->SetPoint(2, xFin, yInic, zFin );                          
00096 
00097         _pts->SetPoint( 0 , -1000 , -1000 , -1000 ) ;
00098         _pts->SetPoint( 1 , mid , yFin , zInic ) ;
00099         _pts->SetPoint( 2 , 1000 , 1000 , 1000 ) ;
00100 
00101 
00103 
00104         vtkCellArray *strip = vtkCellArray::New( ) ;
00105         vtkPolyData *pdFill = vtkPolyData::New( ) ;
00106         _fillPolyMapper = vtkPolyDataMapper::New( ) ;
00107         _fillObjectActor = vtkActor::New( ) ;
00108 
00109         // RaC In the actual version, zInic=zFin=900
00110 
00111         strip->InsertNextCell( 3 ) ;
00112         strip->InsertCellPoint( 0 ) ;
00113         strip->InsertCellPoint( 1 ) ;
00114         strip->InsertCellPoint( 2 ) ;
00115 
00116         pdFill->SetPoints( _pts ) ;
00117         pdFill->SetStrips( strip ) ;
00118 
00119         _fillPolyMapper->SetInput( pdFill ) ;
00120         _fillObjectActor->SetMapper( _fillPolyMapper ) ;
00121         _fillPolyMapper->Modified( ) ;
00122 
00124 
00125         updateColors( ) ;
00126 
00127 
00128     }
00129 
00130     //=========================================================================
00131 
00132     void vtkGPortView::updateColors( ) {
00133         _fillObjectActor->GetProperty( )->SetColor( 0.45 , 0.45 , 0.45 ) ;
00134 
00135         if ( _state == POSSIBLE_CONNECTION ) {
00136             _fillObjectActor->GetProperty( )->SetColor( 1 , 1 , 0 ) ;
00137         } else if ( _state == SELECTED_POSSIBLE_CONNECTION ) {
00138             _fillObjectActor->GetProperty( )->SetColor( 0 , 1 , 0 ) ;
00139         } else if ( _state == HIGHLIGHTED ) {
00140             _fillObjectActor->GetProperty( )->SetColor( 0 , 0 , 1 ) ;
00141         } else {
00142             GPortModel* portm = ( GPortModel* ) _model ;
00143             if ( portm->isConnected( ) ) {
00144                 _fillObjectActor->GetProperty( )->SetColor( 0.15 , 0.15 , 0.15 ) ;
00145             } else if ( portm->isValueSet( ) ) {
00146                 _fillObjectActor->GetProperty( )->SetColor( 0.55 , 0.25 , 0.25 ) ;
00147             } else {
00148                 _fillObjectActor->GetProperty( )->SetColor( 0.45 , 0.45 , 0.45 ) ;
00149             }
00150         }
00151     }
00152 
00153     //=========================================================================
00154 
00155 
00156 } // EO namespace bbtk
00157 
00158 // EOF
00159 

Generated on Thu May 31 15:12:19 2012 for bbtkGEditor by  doxygen 1.5.7.1