vtkGBoxView.cxx

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

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