00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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
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( )
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
00090
00091 double mid = ( xInic + xFin ) / 2 ;
00092
00093
00094
00095
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
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 }
00157
00158
00159