]> Creatis software - creaMaracasVisu.git/commitdiff
1495 BUG
authorEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Tue, 10 Jul 2012 19:23:20 +0000 (19:23 +0000)
committerEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Tue, 10 Jul 2012 19:23:20 +0000 (19:23 +0000)
  Refresh PlotterViewer

bbtk/src/bbmaracasvisuPlotterView.cxx
bbtk/src/bbmaracasvisuPlotterView.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.cxx

index 283c17365ea39f8678a3c3f1d0776e1f2edb0d82..078bfb2f2a24a7fa93ea37739d9f8af8f2d3cb59 100644 (file)
@@ -18,48 +18,97 @@ 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)
+               if (bbGetInputInY().size()!=0)          
                {
-                       int i,size=bbGetInputInY().size();
-                       for(i=0;i<size;i++)
+                       // avoid 'taking address of temporary '
+                       //pGraphicalFunction *pGF = mwxwidget->getFunctionForVectors( &(bbGetInputInX()), &(bbGetInputInY()) ); // taking address of temporary ! JPRx
+                       std::vector<double> inX;
+                       if (bbGetInputInX().size()==0)
                        {
-                               inX.push_back((double)i);
-                       }
-               } else {
-                       
-                       inX = bbGetInputInX();
-               }
-               std::vector<double> inY = bbGetInputInY();
-               pGraphicalFunction *pGF = mwxwidget->getFunctionForVectors( &inX, &inY ); 
-               mwxwidget->addFunction(pGF);            
-       }
-       
-       
+                               int i,size=bbGetInputInY().size();
+                               for(i=0;i<size;i++)
+                               {
+                                       inX.push_back((double)i);
+                               } // for
+                       } else {
+                               inX = bbGetInputInX();
+                       } // if bbGetInputInX
+                       std::vector<double> inY = bbGetInputInY();
+                       pGraphicalFunction *pGF = mwxwidget->getFunctionForVectors( &inX, &inY ); 
+                       mwxwidget->addFunction(pGF);            
+               } // if bbGetInputInY
+
+               if (bbGetInputInY2().size()!=0)         
+               {
+                       // avoid 'taking address of temporary '
+                       //pGraphicalFunction *pGF = mwxwidget->getFunctionForVectors( &(bbGetInputInX()), &(bbGetInputInY()) ); // taking address of temporary ! JPRx
+                       std::vector<double> inX2;
+                       if (bbGetInputInX().size()==0)
+                       {
+                               int i,size=bbGetInputInY2().size();
+                               for(i=0;i<size;i++)
+                               {
+                                       inX2.push_back((double)i);
+                               } // for
+                       } else {
+                               inX2 = bbGetInputInX();
+                       } // if bbGetInputInX
+                       std::vector<double> inY2 = bbGetInputInY();
+                       pGraphicalFunction *pGF2 = mwxwidget->getFunctionForVectors( &inX2, &inY2 ); 
+                       mwxwidget->addFunction(pGF2);           
+               } // if bbGetInputInY
+               
+       } // if firsttime
        
+       // Erasing  points
        pGraphicalFunction *pGF = mwxwidget->getFunction(0);
-       int i,sizePoints = pGF->getSizePoints();
-       for (i=0; i<sizePoints;i++)
+       if (pGF!=NULL)  
        {
-               pGF->deletePointAt(i);
-       }
-       
-       double px;
-       sizePoints=bbGetInputInY().size();
-       for (i=0; i<sizePoints;i++)
+               int i,sizePoints                = pGF->getSizePoints();
+               for (i=1; i<sizePoints;i++)
+               {
+                       pGF->deletePointAt(1);
+               } // for 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] );
+               }               
+       }// if pGF
+
+
+       // Erasing  points
+       pGraphicalFunction *pGF2 = mwxwidget->getFunction(1);
+       if (pGF2!=NULL) 
        {
-               if (i<bbGetInputInX().size())
+               int i,sizePoints                = pGF2->getSizePoints();
+               for (i=0; i<sizePoints;i++)
                {
-                       px=bbGetInputInX()[i]; 
-               } else {
-                       px=i;
-               }       
-               pGF->AddNewPoint( px, bbGetInputInY()[i] );
-               printf ("EED PlotterView::Process %f %f\n", px, bbGetInputInY()[i]);
-       }
+                       pGF2->deletePointAt(1);
+               } // for i
+               double px;
+               sizePoints=bbGetInputInY2().size();
+               for (i=0; i<sizePoints;i++)
+               {
+                       if (i<bbGetInputInX().size())
+                       {
+                               px = bbGetInputInX()[i]; 
+                       } else {
+                               px = i;
+                       }       
+                       pGF2->AddNewPoint( px, bbGetInputInY2()[i] );
+               }               
+       }// if pGF
+               
+       mwxwidget->setMinScrY(0);
        mwxwidget->UpdateAll();
 }
 
@@ -72,7 +121,7 @@ void PlotterView::CreateWidget(wxWindow* parent)
    mwxwidget = new pPlotterWindow( parent , -1,wxDefaultPosition,  wxDefaultSize,  0 );
    mwxwidget->AddLayer(new pPlotterScaleX());
    mwxwidget->AddLayer(new pPlotterScaleY());
-   
+       
           bbtkDebugDecTab("Core",9);
    bbSetOutputWidget( mwxwidget );
 }
index 65e800ab6c02d83a264c2e226d49b4d9a8e697bc..66cc5f779531bf9c8bb39190cadfec8ca4275293 100644 (file)
@@ -15,6 +15,7 @@ class /*BBTK_EXPORT*/ PlotterView
   BBTK_BLACK_BOX_INTERFACE(PlotterView,bbtk::WxBlackBox);
        BBTK_DECLARE_INPUT(InX, std::vector<double> );
        BBTK_DECLARE_INPUT(InY, std::vector<double> );
+       BBTK_DECLARE_INPUT(InY2, std::vector<double> );
   BBTK_PROCESS(Process);
   void Process();
   BBTK_CREATE_WIDGET(CreateWidget);
@@ -33,6 +34,7 @@ BBTK_DESCRIPTION("Plotter Window");
 BBTK_CATEGORY("viewer");
   BBTK_INPUT(PlotterView,InX,"x vector",std::vector<double>,"");
   BBTK_INPUT(PlotterView,InY,"y vector",std::vector<double>,"");
+       BBTK_INPUT(PlotterView,InY2,"y2 vector",std::vector<double>,"");
 BBTK_END_DESCRIBE_BLACK_BOX(PlotterView);
 }
 // EO namespace bbcreaMaracasVisu
index b6b1e48c9784eb5a3a2a59ec9c4b5cce58e9f279..68751613a72003c50b78aad89b0ac5dc30a74689 100644 (file)
@@ -565,7 +565,6 @@ void mpWindow::OnPaint( wxPaintEvent &event )
 {
        wxPaintDC dc(this);
        dc.GetSize(&m_scrX, &m_scrY);
-printf("EED mpWindow::OnPaint %d %d\n",m_scrX,m_scrY);
 
        //m_scrX=200;
        //m_scrY=200;
@@ -705,13 +704,12 @@ void mpWindow::UpdateAll()
        {
                int cx, cy;
                GetClientSize( &cx, &cy);
-printf("EED mpWindow::UpdateAll %d %d\n",cx,cy);
 
-               //const int sx = (int)((m_maxX - m_minX) * GetScaleX()); // JPRx
-               //const int sy = (int)((m_maxY - m_minY) * GetScaleY()); // JPRx
-               //const int px = (int)((GetPosX() - m_minX) * GetScaleX() - (cx>>1)); // JPRx
-               //const int py = (int)((GetPosY() - m_minY) * GetScaleY() - (cy>>1)); // JPRx
-               //SetScrollbars( 1, 1, sx, sy, px, py);
+               const int sx = (int)((m_maxX - m_minX) * GetScaleX()); // JPRx
+               const int sy = (int)((m_maxY - m_minY) * GetScaleY()); // JPRx
+               const int px = (int)((GetPosX() - m_minX) * GetScaleX() - (cx>>1)); // JPRx
+               const int py = (int)((GetPosY() - m_minY) * GetScaleY() - (cy>>1)); // JPRx
+               SetScrollbars( 1, 1, sx, sy, px, py);
        }
 
        FitInside();