]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBoxView.cxx
#3084 bbGEditor Bug New Normal - Color refresh for inputs and outputs
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsVtkGUIEditorGraphic / vtkGBoxView.cxx
index 24db98a14240ae4e82838753eaeee126b2b84d16..a8789d779f407038f2ff23a1107a7667307b8a75 100644 (file)
@@ -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,17 +122,17 @@ 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 );
@@ -148,7 +141,6 @@ namespace bbtk
                _TrianglesInputsPolyMapper->Modified();
 
 
-
                ///************************* Inputs Fill (triangles) *************************
 
                ///************************* Outputs Fill (triangles) *************************
@@ -156,13 +148,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,17 +161,17 @@ 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 );
                _TrianglesOutputsPolyMapper->SetInput( pdTrianglesOutputs );
@@ -289,6 +274,7 @@ namespace bbtk
 
        void vtkGBoxView::updateColors()
        {
+               printf("EED vtkGBoxView::updateColors\n");
                _fillObjectActor->GetProperty()->SetAmbient(0.6);
 
                if(_state==NOTHING_HAPPENS)
@@ -315,24 +301,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 ; i<numberOfTriangles; i++)
+               {
+                       portView = _inputsG[i];
+                       portView->getColors(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 ; i<numberOfTriangles; i++)
+               {
+                       portView = _outputsG[i];
+                       portView->getColors(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;i<numberOfTriangles;i++)
                {
-                       portModel= boxModel->getInputPort(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 +382,17 @@ namespace bbtk
        }
 
        //=========================================================================
+       void vtkGBoxView::addInputPort(vtkGPortView *inputport)
+       {
+               _inputsG.push_back(inputport);
+       }
+
+       //=========================================================================
+       void vtkGBoxView::addOutputPort(vtkGPortView *outputport)
+       {
+               _outputsG.push_back(outputport);
+       }
+
 
 }  // EO namespace bbtk