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 "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
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()
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
00098
00099
00100
00101
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
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
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()
00156 {
00157 _baseView->GetRenderer()->AddActor(_borderObjectActor);
00158 vtkGObjectView::addVtkActors();
00159 }
00160
00161
00162
00163 void vtkGBoxView::removeVtkActors()
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 }
00214
00215
00216