vtkGComplexBoxPortView.cxx

Go to the documentation of this file.
00001 /*=========================================================================                                                                               
00002 Program:   bbtk
00003 Module:    $RCSfile: vtkGComplexBoxPortView.cxx,v $
00004 Language:  C++
00005 Date:      $Date: 2012/05/23 15:57:13 $
00006 Version:   $Revision: 1.3 $
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 "vtkGComplexBoxPortView.h"
00038 
00039 namespace bbtk {
00040 
00041 
00042     //=========================================================================
00043 
00044     vtkGComplexBoxPortView::vtkGComplexBoxPortView( ) {
00045     }
00046 
00047     //=========================================================================
00048 
00049     vtkGComplexBoxPortView::~vtkGComplexBoxPortView( ) {
00050     }
00051 
00052     //=========================================================================
00053 
00054     void vtkGComplexBoxPortView::update( int idController , int command ) {
00055         updateColors( ) ;
00056 
00057         double xInic , yInic , zInic , xFin , yFin , zFin ;
00058         _model->getInicPoint( xInic , yInic , zInic ) ;
00059         _model->getFinalPoint( xFin , yFin , zFin ) ;
00060 
00061         // RaC In the actual version, zInic=zFin=900
00062 
00063         _pts->SetPoint( 0 , xInic , yInic , zInic ) ;
00064         _pts->SetPoint( 1 , xInic , yFin , zInic ) ;
00065         _pts->SetPoint( 2 , xFin , yFin , zFin ) ;
00066         _pts->SetPoint( 3 , xFin , yInic , zFin ) ;
00067 
00068         updatePorts( ) ;
00069 
00070         _borderPolyMapper->Modified( ) ;
00071         _fillPolyMapper->Modified( ) ;
00072         //-----------
00073 
00074         //-----------
00075         setRefreshWaiting( ) ;
00076     }
00077 
00078     //=========================================================================
00079 
00080     void vtkGComplexBoxPortView::createVtkObjects( ) //virtual
00081     {
00082 
00083         //------------
00084         _pts = vtkPoints::New( ) ;
00085         vtkCellArray *lines = vtkCellArray::New( ) ;
00086         vtkPolyData *_pd = vtkPolyData::New( ) ;
00087         _borderPolyMapper = vtkPolyDataMapper::New( ) ;
00088         _borderObjectActor = vtkActor::New( ) ;
00089 
00090         _pts->SetNumberOfPoints( 4 ) ;
00091 
00092         double xInic , yInic , zInic , xFin , yFin , zFin ;
00093         _model->getInicPoint( xInic , yInic , zInic ) ;
00094         _model->getFinalPoint( xFin , yFin , zFin ) ;
00095 
00096         // RaC In the actual version, zInic=zFin=900
00097 
00098         //EED           _pts->SetPoint(0, xInic, yInic, zInic );
00099         //EED           _pts->SetPoint(1, xInic, yFin, zInic );
00100         //EED           _pts->SetPoint(2, xFin, yFin, zFin );
00101         //EED           _pts->SetPoint(3, xFin, yInic, zFin );
00102 
00103 
00104         _pts->SetPoint( 0 , -1000 , -1000 , -1000 ) ;
00105         _pts->SetPoint( 1 , xInic , yFin , zInic ) ;
00106         _pts->SetPoint( 2 , 1000 , 1000 , 1000 ) ;
00107         _pts->SetPoint( 3 , xFin , yInic , zFin ) ;
00108 
00109 
00110         lines->InsertNextCell( 5 ) ;
00111         lines->InsertCellPoint( 0 ) ;
00112         lines->InsertCellPoint( 1 ) ;
00113         lines->InsertCellPoint( 2 ) ;
00114         lines->InsertCellPoint( 3 ) ;
00115         lines->InsertCellPoint( 0 ) ;
00116 
00117         _pd->SetPoints( _pts ) ;
00118         _pd->SetLines( lines ) ;
00119 
00120         _borderPolyMapper->SetInput( _pd ) ;
00121         _borderObjectActor->SetMapper( _borderPolyMapper ) ;
00122         _borderPolyMapper->Modified( ) ;
00123 
00124 
00126 
00127         vtkCellArray *strip = vtkCellArray::New( ) ;
00128         vtkPolyData *pdFill = vtkPolyData::New( ) ;
00129         _fillPolyMapper = vtkPolyDataMapper::New( ) ;
00130         _fillObjectActor = vtkActor::New( ) ;
00131 
00132         // RaC In the actual version, zInic=zFin=900
00133 
00134         strip->InsertNextCell( 5 ) ;
00135         strip->InsertCellPoint( 0 ) ;
00136         strip->InsertCellPoint( 1 ) ;
00137         strip->InsertCellPoint( 2 ) ;
00138         strip->InsertCellPoint( 0 ) ;
00139         strip->InsertCellPoint( 3 ) ;
00140 
00141         pdFill->SetPoints( _pts ) ;
00142         pdFill->SetStrips( strip ) ;
00143 
00144         _fillPolyMapper->SetInput( pdFill ) ;
00145         _fillObjectActor->SetMapper( _fillPolyMapper ) ;
00146         _fillPolyMapper->Modified( ) ;
00147 
00149 
00150     }
00151 
00152     //=========================================================================
00153 
00154     void vtkGComplexBoxPortView::addVtkActors( )//virtual
00155     {
00156         _baseView->GetRenderer( )->AddActor( _borderObjectActor ) ;
00157         vtkGObjectView::addVtkActors( ) ;
00158     }
00159 
00160     //=========================================================================
00161 
00162     void vtkGComplexBoxPortView::removeVtkActors( )//virtual
00163     {
00164         _baseView->GetRenderer( )->RemoveActor( _borderObjectActor ) ;
00165         vtkGObjectView::removeVtkActors( ) ;
00166     }
00167 
00168     //=========================================================================
00169 
00170     void vtkGComplexBoxPortView::updateColors( ) {
00171         _fillObjectActor->GetProperty( )->SetAmbient( 0.6 ) ;
00172 
00173         if ( _state == NOTHING_HAPPENS ) {
00174             _borderObjectActor->GetProperty( )->SetLineWidth( 1 ) ;
00175 
00176 
00177             GComplexBoxPortModel *portModel = ( GComplexBoxPortModel* ) _model ;
00178             if ( portModel->getComplexPortType( ) == GCOMPLEXINPUTPORT ) {
00179                 _fillObjectActor->GetProperty( )->SetColor( COMPLEXINPUTPORTFILL_NH_R , COMPLEXINPUTPORTFILL_NH_G , COMPLEXINPUTPORTFILL_NH_B ) ;
00180                 _borderObjectActor->GetProperty( )->SetColor( COMPLEXINPUTPORTBORDER_NH_R , COMPLEXINPUTPORTBORDER_NH_G , COMPLEXINPUTPORTBORDER_NH_B ) ;
00181             } else if ( portModel->getComplexPortType( ) == GCOMPLEXOUTPUTPORT ) {
00182                 _fillObjectActor->GetProperty( )->SetColor( COMPLEXOUTPUTPORTFILL_NH_R , COMPLEXOUTPUTPORTFILL_NH_G , COMPLEXOUTPUTPORTFILL_NH_B ) ;
00183                 _borderObjectActor->GetProperty( )->SetColor( COMPLEXOUTPUTPORTBORDER_NH_R , COMPLEXOUTPUTPORTBORDER_NH_G , COMPLEXOUTPUTPORTBORDER_NH_B ) ;
00184             }
00185 
00186         } else if ( _state == HIGHLIGHTED ) {
00187             _borderObjectActor->GetProperty( )->SetLineWidth( 2 ) ;
00188 
00189             _borderObjectActor->GetProperty( )->SetColor( BOXBORDER_HIGHLIGHTED_R , BOXBORDER_HIGHLIGHTED_G , BOXBORDER_HIGHLIGHTED_B ) ;
00190             _fillObjectActor->GetProperty( )->SetColor( BOXFILL_HIGHLIGHTED_R , BOXFILL_HIGHLIGHTED_G , BOXFILL_HIGHLIGHTED_B ) ;
00191         } else if ( _state == DRAG ) {
00192             _borderObjectActor->GetProperty( )->SetLineWidth( 1.2 ) ;
00193             _borderObjectActor->GetProperty( )->SetColor( BOXBORDER_DRAG_R , BOXBORDER_DRAG_G , BOXBORDER_DRAG_B ) ;
00194             _fillObjectActor->GetProperty( )->SetColor( BOXFILL_DRAG_R , BOXFILL_DRAG_G , BOXFILL_DRAG_B ) ;
00195         } else if ( _state == SELECTED ) {
00196             _borderObjectActor->GetProperty( )->SetLineWidth( 2 ) ;
00197             _borderObjectActor->GetProperty( )->SetColor( BOXBORDER_SELECTED_R , BOXBORDER_SELECTED_G , BOXBORDER_SELECTED_B ) ;
00198             _fillObjectActor->GetProperty( )->SetColor( BOXFILL_SELECTED_R , BOXFILL_SELECTED_G , BOXFILL_SELECTED_B ) ;
00199         }
00200     }
00201 
00202     //=========================================================================
00203 
00204 
00205 } // EO namespace bbtk
00206 
00207 // EOF
00208 

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