X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsVtkGUIEditorGraphic%2FvtkGBoxView.cxx;h=4c6c7ee6d00d2f5ffc7b9096cc47112f017179d2;hb=188d35adf90fa5479a00708eb3ae54eb25c66f5e;hp=24db98a14240ae4e82838753eaeee126b2b84d16;hpb=d108e756e1f5444e19b63ec457033b7518ba060e;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBoxView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBoxView.cxx index 24db98a..4c6c7ee 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBoxView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBoxView.cxx @@ -108,13 +108,6 @@ namespace bbtk _TrianglesInputsPts = vtkPoints::New(); _TrianglesInputsPts->SetNumberOfPoints( 3*numberOfTriangles ); -//EED 2017-03-02 -// if (numberOfTriangles>0) -// { -// _TrianglesInputsPts->SetPoint(0, -1000, -1000, -1000 ); -// _TrianglesInputsPts->SetPoint(1, 1000, 1000, 1000 ); -// } - vtkCellArray *stripTrianglesInputs = vtkCellArray::New(); vtkPolyData *pdTrianglesInputs = vtkPolyData::New(); _TrianglesInputsPolyMapper = vtkPolyDataMapper::New(); @@ -129,26 +122,32 @@ namespace bbtk } // Create cell data - vtkUnsignedCharArray *cellDataInputTriangles = vtkUnsignedCharArray::New(); - cellDataInputTriangles->SetNumberOfComponents(3); - cellDataInputTriangles->SetNumberOfTuples(numberOfTriangles); + _cellDataInputTriangles = vtkUnsignedCharArray::New(); + _cellDataInputTriangles->SetNumberOfComponents(3); + _cellDataInputTriangles->SetNumberOfTuples(numberOfTriangles); for (int i = 0; i < numberOfTriangles; i++) { rgb[0] = 100; rgb[1] = 100; rgb[2] = 100; - cellDataInputTriangles->SetTuple(i, rgb); + _cellDataInputTriangles->SetTuple(i, rgb); } // for colors - pdTrianglesInputs->GetCellData()->SetScalars(cellDataInputTriangles); + pdTrianglesInputs->GetCellData()->SetScalars( _cellDataInputTriangles ); pdTrianglesInputs->SetPoints( _TrianglesInputsPts ); pdTrianglesInputs->SetStrips( stripTrianglesInputs ); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _TrianglesInputsPolyMapper->SetInput( pdTrianglesInputs ); +#else + _TrianglesInputsPolyMapper->SetInputData( pdTrianglesInputs ); +#endif + _TrianglesInputsActor->SetMapper(_TrianglesInputsPolyMapper); _TrianglesInputsPolyMapper->Modified(); - ///************************* Inputs Fill (triangles) ************************* ///************************* Outputs Fill (triangles) ************************* @@ -156,13 +155,6 @@ namespace bbtk _TrianglesOutputsPts = vtkPoints::New(); _TrianglesOutputsPts->SetNumberOfPoints( 3*numberOfTriangles ); -//EED 2017-03-02 -// if (numberOfTriangles>0) -// { -// _TrianglesOutputsPts->SetPoint(0, -1000, -1000, -1000 ); -// _TrianglesOutputsPts->SetPoint(1, 1000, 1000, 1000 ); -// } - vtkCellArray *stripTrianglesOutputs = vtkCellArray::New(); vtkPolyData *pdTrianglesOutputs = vtkPolyData::New(); _TrianglesOutputsPolyMapper = vtkPolyDataMapper::New(); @@ -176,20 +168,27 @@ namespace bbtk stripTrianglesOutputs->InsertCellPoint(i*3+2); } // for // Create cell data - vtkUnsignedCharArray *cellDataOutputTriangle = vtkUnsignedCharArray::New(); - cellDataOutputTriangle->SetNumberOfComponents(3); - cellDataOutputTriangle->SetNumberOfTuples(numberOfTriangles); + _cellDataOutputTriangles = vtkUnsignedCharArray::New(); + _cellDataOutputTriangles->SetNumberOfComponents(3); + _cellDataOutputTriangles->SetNumberOfTuples(numberOfTriangles); for (int i = 0; i < numberOfTriangles; i++) { rgb[0] = 000; rgb[1] = 255; rgb[2] = 255; - cellDataOutputTriangle->SetTuple(i, rgb); + _cellDataOutputTriangles->SetTuple(i, rgb); } // for colors - pdTrianglesOutputs->GetCellData()->SetScalars(cellDataOutputTriangle); + pdTrianglesOutputs->GetCellData()->SetScalars( _cellDataOutputTriangles ); pdTrianglesOutputs->SetPoints( _TrianglesOutputsPts ); pdTrianglesOutputs->SetStrips( stripTrianglesOutputs ); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _TrianglesOutputsPolyMapper->SetInput( pdTrianglesOutputs ); +#else + _TrianglesOutputsPolyMapper->SetInputData( pdTrianglesOutputs ); +#endif + _TrianglesOutputsActor->SetMapper(_TrianglesOutputsPolyMapper); _TrianglesOutputsPolyMapper->Modified(); ///************************* Inputs Fill (triangles) ************************* @@ -258,7 +257,12 @@ namespace bbtk pdFill->SetPoints( _pts ); pdFill->SetStrips( strip ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _fillPolyMapper->SetInput(pdFill); +#else + _fillPolyMapper->SetInputData(pdFill); +#endif _fillObjectActor->SetMapper(_fillPolyMapper); _fillPolyMapper->Modified(); @@ -289,6 +293,7 @@ namespace bbtk void vtkGBoxView::updateColors() { + printf("EED vtkGBoxView::updateColors\n"); _fillObjectActor->GetProperty()->SetAmbient(0.6); if(_state==NOTHING_HAPPENS) @@ -315,24 +320,57 @@ namespace bbtk // _borderObjectActor->GetProperty()->SetLineWidth(2); // _borderObjectActor->GetProperty()->SetColor(BOXBORDER_SELECTED_R,BOXBORDER_SELECTED_G,BOXBORDER_SELECTED_B); _fillObjectActor->GetProperty()->SetColor(BOXFILL_SELECTED_R,BOXFILL_SELECTED_G,BOXFILL_SELECTED_B); - } + } // if state box + + updateColorsPorts(); } + //========================================================================= + void vtkGBoxView::updateColorsPorts() + { + // Input ports + float rgb[3]; + vtkGPortView *portView; + GBoxModel *boxModel = (GBoxModel*)_model; + int numberOfTriangles = boxModel->getNumInputPorts(); + for (int i=0 ; igetColors(rgb); + rgb[0]=rgb[0]*255; + rgb[1]=rgb[1]*255; + rgb[2]=rgb[2]*255; + _cellDataInputTriangles->SetTuple(i, rgb); + } // for + + numberOfTriangles = boxModel->getNumOutputPorts(); + for (int i=0 ; igetColors(rgb); + rgb[0]=rgb[0]*255; + rgb[1]=rgb[1]*255; + rgb[2]=rgb[2]*255; + _cellDataOutputTriangles->SetTuple(i, rgb); + } // for + } + + //========================================================================= void vtkGBoxView::updatePorts() { double xInic, yInic,zInic,xFin, yFin,zFin; - GBoxModel* boxModel =(GBoxModel*)_model; + GBoxModel* boxModel = (GBoxModel*)_model; boxModel->updatePorts(); // update position for one Actor that represents all InputPorts - GPortModel *portModel; + GPortModel *portModel; int numberOfTriangles = boxModel->getNumInputPorts(); for (int i=0;igetInputPort(i); + portModel = boxModel->getInputPort(i); portModel->getInicPoint( xInic , yInic , zInic ) ; portModel->getFinalPoint( xFin , yFin , zFin ) ; // RaC In the actual version, zInic=zFin=GPOSITION_Z @@ -363,6 +401,17 @@ namespace bbtk } //========================================================================= + void vtkGBoxView::addInputPort(vtkGPortView *inputport) + { + _inputsG.push_back(inputport); + } + + //========================================================================= + void vtkGBoxView::addOutputPort(vtkGPortView *outputport) + { + _outputsG.push_back(outputport); + } + } // EO namespace bbtk