X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsVtkGUIEditorGraphic%2FvtkGPortView.cxx;h=6633e1fe3bcff3c876dd21532838958ca049de83;hb=a62e394e0f56bb5adff696adf06be425680bddca;hp=51881b2315d5d025279456ed162bc73f7481b77c;hpb=098558ac7780900858114a8ae01fe93847d67043;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx index 51881b2..6633e1f 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx @@ -42,7 +42,7 @@ namespace bbtk //========================================================================= vtkGPortView::vtkGPortView() - { + { } //========================================================================= @@ -51,59 +51,125 @@ namespace bbtk } //========================================================================= - void vtkGPortView::update() + void vtkGPortView::update(int idController,int command) { - //paint(); - if(_model->getState()==HIGHLIGHTED) - { - _objectActor->GetProperty()->SetColor(0.0,0.2,0.5); - } - else - { - _objectActor->GetProperty()->SetColor(0.3,0.2,0.2); - } - _baseView->GetRenderer()->Render(); + updateColors(); + + double xInic, yInic,zInic,xFin, yFin,zFin; + + _model->getInicPoint(xInic,yInic,zInic); + _model->getFinalPoint(xFin, yFin,zFin); + + // RaC In the actual version, zInic=zFin=900 + + double mid = (xInic+xFin)/2; + + _pts->SetPoint(0, xInic, yInic, zInic ); + _pts->SetPoint(1, mid, yFin, zInic ); + _pts->SetPoint(2, xFin, yInic, zFin ); + + _borderObjectActor->Modified(); + _fillPolyMapper->Modified(); + + setRefreshWaiting(); } //========================================================================= void vtkGPortView::createVtkObjects() //virtual { - vtkPoints *_pts = vtkPoints::New(); + _pts = vtkPoints::New(); vtkCellArray *lines = vtkCellArray::New(); vtkPolyData *_pd = vtkPolyData::New(); - vtkPolyDataMapper* _bboxMapper=vtkPolyDataMapper::New(); - _objectActor=vtkActor::New(); + _borderPolyMapper=vtkPolyDataMapper::New(); + _borderObjectActor=vtkActor::New(); - _pts->SetNumberOfPoints(4); + _pts->SetNumberOfPoints(3); double xInic, yInic,zInic,xFin, yFin,zFin; + _model->getInicPoint(xInic,yInic,zInic); _model->getFinalPoint(xFin, yFin,zFin); - cout<<"RaC ----------"<SetPoint(0, xInic, yInic, 0 ); - _pts->SetPoint(1, xInic, yFin, 0 ); - _pts->SetPoint(2, xFin, yFin, 0 ); - _pts->SetPoint(3, xFin, yInic, 0 ); + + // RaC In the actual version, zInic=zFin=900 + + double mid = (xInic+xFin)/2; + + _pts->SetPoint(0, xInic, yInic, zInic ); + _pts->SetPoint(1, mid, yFin, zInic ); + _pts->SetPoint(2, xFin, yInic, zFin ); - lines->InsertNextCell(5); + lines->InsertNextCell(4); lines->InsertCellPoint(0); lines->InsertCellPoint(1); lines->InsertCellPoint(2); - lines->InsertCellPoint(3); lines->InsertCellPoint(0); _pd->SetPoints( _pts ); _pd->SetLines( lines ); - _bboxMapper->SetInput(_pd); - _objectActor->SetMapper(_bboxMapper); + _borderPolyMapper->SetInput(_pd); + _borderObjectActor->SetMapper(_borderPolyMapper); + _borderPolyMapper->Modified(); - _objectActor->GetProperty()->SetColor(0.8,0.0,0.0); + + ///************************* FILL ************************* + vtkCellArray *strip = vtkCellArray::New(); + vtkPolyData *pdFill = vtkPolyData::New(); + _fillPolyMapper=vtkPolyDataMapper::New(); + _fillObjectActor=vtkActor::New(); + + // RaC In the actual version, zInic=zFin=900 + + strip->InsertNextCell(3); + strip->InsertCellPoint(0); + strip->InsertCellPoint(1); + strip->InsertCellPoint(2); + + pdFill->SetPoints( _pts ); + pdFill->SetStrips( strip ); + + _fillPolyMapper->SetInput(pdFill); + _fillObjectActor->SetMapper(_fillPolyMapper); + _fillPolyMapper->Modified(); + + ///************************* FILL ************************* + + updateColors(); + + + } + + //========================================================================= + + void vtkGPortView::updateColors() + { + _borderObjectActor->GetProperty()->SetColor(BOXBORDER_NH_R,BOXBORDER_NH_G,BOXBORDER_NH_B); + _fillObjectActor->GetProperty()->SetColor(0.6,0.6,0.6); + + if(_state==HIGHLIGHTED) + { + _borderObjectActor->GetProperty()->SetColor(0.35,0.15,0.1); + _fillObjectActor->GetProperty()->SetColor(0.8,0.8,0.8); + } + else + { + GPortModel* portm = (GPortModel*)_model; + _borderObjectActor->GetProperty()->SetColor(0.15,0.15,0.15); + if(portm->isConnected()) + { + _fillObjectActor->GetProperty()->SetColor(0.2,0.2,0.2); + } + else if(portm->isValueSet()) + { + _fillObjectActor->GetProperty()->SetColor(0.5,0.2,0.2); + } + else + { + _fillObjectActor->GetProperty()->SetColor(0.6,0.6,0.6); + } + } } //=========================================================================