From 6c3c0e6d699ac7a835a6480e17b196077acdb184 Mon Sep 17 00:00:00 2001 From: Eduardo Davila Date: Tue, 10 Jul 2012 19:23:20 +0000 Subject: [PATCH] 1495 BUG Refresh PlotterViewer --- bbtk/src/bbmaracasvisuPlotterView.cxx | 119 ++++++++++++------ bbtk/src/bbmaracasvisuPlotterView.h | 2 + .../wxWindows/widgets/pPlotter/mathplot.cxx | 12 +- 3 files changed, 91 insertions(+), 42 deletions(-) diff --git a/bbtk/src/bbmaracasvisuPlotterView.cxx b/bbtk/src/bbmaracasvisuPlotterView.cxx index 283c173..078bfb2 100644 --- a/bbtk/src/bbmaracasvisuPlotterView.cxx +++ b/bbtk/src/bbmaracasvisuPlotterView.cxx @@ -18,48 +18,97 @@ void PlotterView::Process() if (firsttime==true) { firsttime=false; - std::vector 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;igetFunctionForVectors( &(bbGetInputInX()), &(bbGetInputInY()) ); // taking address of temporary ! JPRx + std::vector inX; + if (bbGetInputInX().size()==0) { - inX.push_back((double)i); - } - } else { - - inX = bbGetInputInX(); - } - std::vector inY = bbGetInputInY(); - pGraphicalFunction *pGF = mwxwidget->getFunctionForVectors( &inX, &inY ); - mwxwidget->addFunction(pGF); - } - - + int i,size=bbGetInputInY().size(); + for(i=0;i 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 inX2; + if (bbGetInputInX().size()==0) + { + int i,size=bbGetInputInY2().size(); + for(i=0;i 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; ideletePointAt(i); - } - - double px; - sizePoints=bbGetInputInY().size(); - for (i=0; igetSizePoints(); + for (i=1; ideletePointAt(1); + } // for i + double px; + sizePoints=bbGetInputInY().size(); + for (i=0; iAddNewPoint( px, bbGetInputInY()[i] ); + } + }// if pGF + + + // Erasing points + pGraphicalFunction *pGF2 = mwxwidget->getFunction(1); + if (pGF2!=NULL) { - if (igetSizePoints(); + for (i=0; iAddNewPoint( 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; iAddNewPoint( 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 ); } diff --git a/bbtk/src/bbmaracasvisuPlotterView.h b/bbtk/src/bbmaracasvisuPlotterView.h index 65e800a..66cc5f7 100644 --- a/bbtk/src/bbmaracasvisuPlotterView.h +++ b/bbtk/src/bbmaracasvisuPlotterView.h @@ -15,6 +15,7 @@ class /*BBTK_EXPORT*/ PlotterView BBTK_BLACK_BOX_INTERFACE(PlotterView,bbtk::WxBlackBox); BBTK_DECLARE_INPUT(InX, std::vector ); BBTK_DECLARE_INPUT(InY, std::vector ); + BBTK_DECLARE_INPUT(InY2, std::vector ); 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,""); BBTK_INPUT(PlotterView,InY,"y vector",std::vector,""); + BBTK_INPUT(PlotterView,InY2,"y2 vector",std::vector,""); BBTK_END_DESCRIBE_BLACK_BOX(PlotterView); } // EO namespace bbcreaMaracasVisu diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.cxx index b6b1e48..6875161 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.cxx @@ -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(); -- 2.47.1