]> Creatis software - creaMaracasVisu.git/commitdiff
1495 PlotterViewer , Refresh data
authorEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Mon, 9 Jul 2012 13:08:50 +0000 (13:08 +0000)
committerEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Mon, 9 Jul 2012 13:08:50 +0000 (13:08 +0000)
bbtk/src/bbmaracasvisuPlotterView.cxx
bbtk/src/bbmaracasvisuPlotterView.h

index 9a0ee6c22a7c3235675fde1950367814e0fa1f5a..c6fcb8288a047ccc7a414e134c46a63a38ff8e99 100644 (file)
@@ -14,8 +14,55 @@ BBTK_BLACK_BOX_IMPLEMENTATION(PlotterView,bbtk::WxBlackBox);
 //---------------------------------------------------
 void PlotterView::Process()
 {
+       
+       if (firsttime==true)
+       {
+               firsttime=false;
+               std::vector<double> inX;
+               
+               // avoid 'taking address of temporary '
+               //pGraphicalFunction *pGF = mwxwidget->getFunctionForVectors( &(bbGetInputInX()), &(bbGetInputInY()) ); // taking address of temporary ! JPRx
+               if (bbGetInputInX().size()==0)
+               {
+                       int i,size=bbGetInputInY().size();
+                       for(i=0;i<size;i++)
+                       {
+                               inX.push_back((double)i);
+                       }
+               } else {
+                       
+                       inX = bbGetInputInX();
+               }
+               std::vector<double> inY = bbGetInputInY();
+               pGraphicalFunction *pGF = mwxwidget->getFunctionForVectors( &inX, &inY ); 
+               mwxwidget->addFunction(pGF);            
+       }
+       
+       
+       
+       pGraphicalFunction *pGF = mwxwidget->getFunction(0);
+       int i,sizePoints = pGF->getSizePoints();
+       for (i=0; i<sizePoints;i++)
+       {
+               pGF->deletePointAt(i);
+       }
+       
+       double px;
+       sizePoints=bbGetInputInY().size();
+       for (i=0; i<sizePoints;i++)
+       {
+               if (i<bbGetInputInX().size())
+               {
+                       px=bbGetInputInX()[i]; 
+               } else {
+                       px=i;
+               }       
+               pGF->AddNewPoint( px, bbGetInputInY()[i] );
+               printf ("EED PlotterView::Process %f %f\n", px, bbGetInputInY()[i]);
+       }
 }
 
+       
 //---------------------------------------------------
 void PlotterView::CreateWidget(wxWindow* parent)
 {
@@ -25,27 +72,7 @@ void PlotterView::CreateWidget(wxWindow* parent)
    mwxwidget->AddLayer(new pPlotterScaleX());
    mwxwidget->AddLayer(new pPlotterScaleY());
    
-       std::vector<double> inX;
-       
-   // avoid 'taking address of temporary '
-   //pGraphicalFunction *pGF = mwxwidget->getFunctionForVectors( &(bbGetInputInX()), &(bbGetInputInY()) ); // taking address of temporary ! JPRx
-       if (bbGetInputInX().size()==0)
-       {
-               int i,size=bbGetInputInY().size();
-               for(i=0;i<size;i++)
-               {
-                       inX.push_back((double)i);
-               }
-       } else {
-               
-                inX = bbGetInputInX();
-       }
-       
-   std::vector<double> inY = bbGetInputInY();
-      
-   pGraphicalFunction *pGF = mwxwidget->getFunctionForVectors( &inX, &inY ); 
-   mwxwidget->addFunction(pGF);
-   bbtkDebugDecTab("Core",9);
+          bbtkDebugDecTab("Core",9);
    bbSetOutputWidget( mwxwidget );
 }
 
@@ -53,6 +80,7 @@ void PlotterView::CreateWidget(wxWindow* parent)
 void PlotterView::bbUserSetDefaultValues()
 {
        mwxwidget = NULL;
+       firsttime=true;
 }
        
        //-----------------------------------------------------------------     
index d3d0dfe6e918137a790f0c9fade759141502e671..65e800ab6c02d83a264c2e226d49b4d9a8e697bc 100644 (file)
@@ -22,6 +22,7 @@ class /*BBTK_EXPORT*/ PlotterView
 
 private:
        pPlotterWindow *mwxwidget;
+       bool firsttime;
 
 };