X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsVtkGUIEditorGraphic%2FvtkGPortView.cxx;h=321a858241e81bd2cc8c05822bf6802661c6b083;hb=66d85963bdb3dea88f7d8e8931855d092629b37c;hp=d6bef81568860aae7bc07f4d537605b32eec53f7;hpb=8fa663b7b47e797e6e23722d1fef41c40419a6d6;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx index d6bef81..321a858 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx @@ -42,7 +42,7 @@ namespace bbtk //========================================================================= vtkGPortView::vtkGPortView() - { + { } //========================================================================= @@ -51,17 +51,10 @@ namespace bbtk } //========================================================================= - void vtkGPortView::update(int command) + void vtkGPortView::update(int idController,int command) { - if(_model->getState()==HIGHLIGHTED) - { - _objectActor->GetProperty()->SetColor(0.8,0.2,0.5); - } - else - { - _objectActor->GetProperty()->SetColor(0.3,0.2,0.2); - } - + updateColors(); + double xInic, yInic,zInic,xFin, yFin,zFin; _model->getInicPoint(xInic,yInic,zInic); @@ -69,14 +62,16 @@ namespace bbtk // RaC In the actual version, zInic=zFin=900 - _pts->SetPoint(0, xInic, yInic, zInic ); - _pts->SetPoint(1, xInic, yFin, zInic ); - _pts->SetPoint(2, xFin, yFin, zFin ); - _pts->SetPoint(3, xFin, yInic, zFin ); + double mid = (xInic+xFin)/2; - _baseView->GetRenderer()->Render(); - _baseView->GetRenWin()->Render(); + _pts->SetPoint(0, xInic, yInic, zInic ); + _pts->SetPoint(1, mid, yFin, zInic ); + _pts->SetPoint(2, xFin, yInic, zFin ); + _fillPolyMapper->Modified(); + + //----------- + setRefreshWaiting(); } //========================================================================= @@ -84,12 +79,7 @@ namespace bbtk void vtkGPortView::createVtkObjects() //virtual { _pts = vtkPoints::New(); - vtkCellArray *lines = vtkCellArray::New(); - vtkPolyData *_pd = vtkPolyData::New(); - vtkPolyDataMapper* _bboxMapper=vtkPolyDataMapper::New(); - _objectActor=vtkActor::New(); - - _pts->SetNumberOfPoints(4); + _pts->SetNumberOfPoints(3); double xInic, yInic,zInic,xFin, yFin,zFin; @@ -97,26 +87,67 @@ namespace bbtk _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, xInic, yFin, zInic ); - _pts->SetPoint(2, xFin, yFin, zFin ); - _pts->SetPoint(3, xFin, yInic, zFin ); - - lines->InsertNextCell(5); - lines->InsertCellPoint(0); - lines->InsertCellPoint(1); - lines->InsertCellPoint(2); - lines->InsertCellPoint(3); - lines->InsertCellPoint(0); + _pts->SetPoint(1, mid, yFin, zInic ); + _pts->SetPoint(2, xFin, yInic, zFin ); - _pd->SetPoints( _pts ); - _pd->SetLines( lines ); + ///************************* FILL ************************* + + vtkCellArray *strip = vtkCellArray::New(); + vtkPolyData *pdFill = vtkPolyData::New(); + _fillPolyMapper=vtkPolyDataMapper::New(); + _fillObjectActor=vtkActor::New(); - _bboxMapper->SetInput(_pd); - _objectActor->SetMapper(_bboxMapper); + // RaC In the actual version, zInic=zFin=900 - _objectActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B); + 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() + { + _fillObjectActor->GetProperty()->SetColor(0.5,0.45,0.45); + + if(_state==HIGHLIGHTED) + { + _fillObjectActor->GetProperty()->SetColor(0.8,0.8,0.8); + } + else + { + GPortModel* portm = (GPortModel*)_model; + if(portm->isConnected()) + { + _fillObjectActor->GetProperty()->SetColor(0.15,0.15,0.15); + } + else if(portm->isValueSet()) + { + _fillObjectActor->GetProperty()->SetColor(0.55,0.25,0.25); + } + else + { + _fillObjectActor->GetProperty()->SetColor(0.5,0.45,0.45); + } + } } //=========================================================================