From ca967e00cd510d1fbd49b18e6f0004afdb322e98 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Thu, 5 Oct 2017 16:10:51 +0200 Subject: [PATCH] #3144 creaMaracasVisu Bug New Normal - changeWx28to30 --- bbtk/src/bbmaracasvisuHistogramView.cxx | 3 - bbtk/src/bbmaracasvisuPlotterView.cxx | 33 ++++---- .../wxWindows/widgets/pPlotter/mBarRange.cxx | 36 ++------ .../widgets/pPlotter/pGraphicalFunction.cxx | 42 +++++----- .../widgets/pPlotter/pGraphicalFunction.h | 22 ++++- .../wxWindows/widgets/pPlotter/pHistogram.cxx | 1 - .../widgets/pPlotter/pLogicalFunction.h | 16 ++++ .../widgets/pPlotter/pPlotterLayer.cxx | 83 ++++++++++--------- .../widgets/pPlotter/pPlotterLayer.h | 17 ++++ .../widgets/pPlotter/pPlotterScaleX.cxx | 4 +- .../widgets/pPlotter/pPlotterWindow.cxx | 16 ++-- .../widgets/pPlotter/pPlotterWindow.h | 2 +- 12 files changed, 156 insertions(+), 119 deletions(-) diff --git a/bbtk/src/bbmaracasvisuHistogramView.cxx b/bbtk/src/bbmaracasvisuHistogramView.cxx index a310168..f9c3994 100644 --- a/bbtk/src/bbmaracasvisuHistogramView.cxx +++ b/bbtk/src/bbmaracasvisuHistogramView.cxx @@ -36,14 +36,12 @@ BBTK_BLACK_BOX_IMPLEMENTATION(HistogramView,bbtk::WxBlackBox); //------------------------------------------------ void HistogramView::Process() { -printf("EED HistogramView::Process Start \n"); if (firsttime==true) { firsttime=false; // histogram_wxwidget = new Histogram( wxpanel , -1, wxPoint(0,0), wxSize(400,400),wxNO_BORDER ); _histogramMinMaxLevel->Configure( bbGetInputIn() ); } -printf("EED HistogramView::Process End \n"); } //------------------------------------------------ @@ -88,4 +86,3 @@ void HistogramView::CreateWidget(wxWindow* parent) } // EO namespace bbcreaMaracasVisu - diff --git a/bbtk/src/bbmaracasvisuPlotterView.cxx b/bbtk/src/bbmaracasvisuPlotterView.cxx index 5023801..af7cecc 100644 --- a/bbtk/src/bbmaracasvisuPlotterView.cxx +++ b/bbtk/src/bbmaracasvisuPlotterView.cxx @@ -42,10 +42,7 @@ void PlotterView::Process() // if (firsttime==true) // { // firsttime=false; - - - printf("EED PlotterView::Process %d %d \n ", bbGetInputInY().size(),bbGetInputInY2().size()); - + pGraphicalFunction *pGF = mwxwidget->getFunction(0); pGraphicalFunction *pGF2 = mwxwidget->getFunction(1); @@ -110,6 +107,7 @@ void PlotterView::Process() } // if bbGetInputInY // } // if firsttime + if (pGF!=NULL) { @@ -134,14 +132,18 @@ void PlotterView::Process() } }// if pGF - if (pGF2!=NULL) { // -Erasing points- int i,sizePoints = pGF2->getSizePoints(); for (i=0; ideletePointAt(1); // EED here NOT 0 is 1 +#else + pGF2->deletePointAt(0); // EED here NOT 0 is 1 +#endif } // for i // -Add Points- double px; @@ -155,30 +157,23 @@ void PlotterView::Process() px = i; } pGF2->AddNewPoint( px, bbGetInputInY2()[i] ); - } + } // for }// if pGF - mwxwidget->UpdateAll(); - - } //--------------------------------------------------- void PlotterView::CreateWidget(wxWindow* parent) { - bbtkDebugMessageInc("Core",9,"PlotterView::CreateWxWindow()"<AddLayer(new pPlotterScaleX()); - mwxwidget->AddLayer(new pPlotterScaleY()); - + bbtkDebugMessageInc("Core",9,"PlotterView::CreateWxWindow()"<AddLayer(new pPlotterScaleX()); + mwxwidget->AddLayer(new pPlotterScaleY()); mwxwidget->setMinScrY(0); mwxwidget->setMaxScrY(5000); - - - bbtkDebugDecTab("Core",9); - bbSetOutputWidget( mwxwidget ); + bbtkDebugDecTab("Core",9); + bbSetOutputWidget( mwxwidget ); } //--------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange.cxx index b92232f..fc10c87 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange.cxx @@ -24,6 +24,9 @@ # ------------------------------------------------------------------------ */ //---------------------------------------------------------------------------- +#include +#include + #include "mBarRange.h" @@ -77,10 +80,9 @@ mBarRange::mBarRange(wxWindow *parent, int w, int h) _initialPoint = 0; trianglesHalfWidth = 5; - wxColour start_Colour; // Setting the default parts colors - start_Colour = wxColour(0,0,255); + start_Colour = wxColour(1,0,255,254); actual_Colour = wxColour(255,255,202); end_Colour = wxColour(0,0,255); bar_Colour = wxColour(255,0,255); @@ -444,11 +446,9 @@ void mBarRange::RefreshHorizontalView() int pxEnd = GetPixelEnd(); int pxActual = GetPixelActual(); - int letterHeight= 9; int barHeight = 2*letterHeight; - int tempHeight = _h-(6*letterHeight); - + int tempHeight = _h-(6*letterHeight); if (_visibleLables) { @@ -460,36 +460,26 @@ void mBarRange::RefreshHorizontalView() wxMemoryDC temp_dc; temp_dc.SelectObject( *_bitmap_bar ); - // Background of this widget - - temp_dc.SetPen(wxPen( backgroundColor )); temp_dc.SetBrush(wxBrush( backgroundColor ,wxSOLID )); - temp_dc.DrawRectangle(0,0,_w+2*trianglesHalfWidth,_h); - - temp_dc.SetPen(wxPen( wxColour(167,165,191) ,1,wxSOLID )); temp_dc.DrawLine(trianglesHalfWidth+2, 0, _w-deviceEndMargin, 0); temp_dc.DrawLine(trianglesHalfWidth+2, barHeight, (_w-deviceEndMargin-trianglesHalfWidth-2), barHeight); temp_dc.SetDeviceOrigin(trianglesHalfWidth+2,0); - // Filling the bar temp_dc.SetBrush(wxBrush( wxColour(104,104,104),wxSOLID )); temp_dc.SetPen(wxPen( wxColour(104,104,104),1,wxSOLID )); temp_dc.DrawRectangle( pxStart , 0, pxEnd-pxStart, barHeight); - // The Bar if( _selectionMoveId==4 ) { temp_dc.SetBrush(wxBrush( wxColour(128,255,0),wxSOLID )); temp_dc.SetPen(wxPen( wxColour(0,128,0),1,wxSOLID )); - } - else - { + } else { temp_dc.SetBrush(wxBrush( bar_Colour,wxSOLID )); temp_dc.SetPen(wxPen( wxColour(164,0,164),1,wxSOLID )); } @@ -516,9 +506,7 @@ void mBarRange::RefreshHorizontalView() { temp_dc.SetBrush(wxBrush( wxColour(128,255,0),wxSOLID )); temp_dc.SetPen(wxPen( wxColour(0,128,0),1,wxSOLID )); - } - else - { + } else { temp_dc.SetBrush(wxBrush( start_Colour,wxSOLID )); temp_dc.SetPen(wxPen( wxColour(0,51,204),1,wxSOLID )); } @@ -528,9 +516,7 @@ void mBarRange::RefreshHorizontalView() { temp_dc.SetBrush(wxBrush( wxColour(128,255,0),wxSOLID )); temp_dc.SetPen(wxPen( wxColour(0,128,0),1,wxSOLID )); - } - else - { + } else { temp_dc.SetBrush(wxBrush( end_Colour,wxSOLID )); temp_dc.SetPen(wxPen( wxColour(0,0,255),1,wxSOLID )); } @@ -551,9 +537,7 @@ void mBarRange::RefreshHorizontalView() { temp_dc.SetBrush(wxBrush( wxColour(128,255,0),wxSOLID )); temp_dc.SetPen(wxPen( wxColour(0,128,0),1,wxSOLID )); - } - else - { + } else { temp_dc.SetBrush(wxBrush( actual_Colour,wxSOLID )); temp_dc.SetPen(wxPen( wxColour(205,160,5),1,wxSOLID )); } @@ -583,7 +567,6 @@ void mBarRange::RefreshHorizontalView() temp_dc.SetFont(font); temp_dc.SetTextForeground(*wxBLACK); - //the **MIN** value, always at the same y level that corresponds to barHeight+1 wxString text_min; // text_min<< GetMin(); @@ -634,7 +617,6 @@ void mBarRange::RefreshHorizontalView() temp_dc.DrawText(text_actual, pxActual-(stringSize.GetWidth()/2),barHeight+letterHeight); } } - } //---------------------------------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.cxx index 7de96c4..1a8cd58 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.cxx @@ -52,27 +52,27 @@ IMPLEMENT_CLASS(pGraphicalFunction, pPlotterLayer) pGraphicalFunction:: pGraphicalFunction(wxString name, int flags) { SetName(name); - showPointsF = false; - validPointRange = 5; - logicFunction = new pLogicalFunction (); - fromWindow=false; - factorZoom=1; - drawing=false; - editable=true; - ifActual=false; - zoomIn=false; - setOffsetX(0); + showPointsF = false; + validPointRange = 5; + logicFunction = new pLogicalFunction (); + fromWindow = false; + factorZoom = 1; + drawing = false; + editable = true; + ifActual = false; + zoomIn = false; + setOffsetX(0) ; setOffsetY(0); - initialDrawingPoint=NULL; - finalDrawingPoint=NULL; + initialDrawingPoint = NULL; + finalDrawingPoint = NULL; //type=1 means that is going to be a piecewise function - _type=1; - xKSpline=NULL; - yKSpline=NULL; - offsetPixelX=0; - offsetPixelY=0; - xTraslation=0; - mType=DEFAULT; + _type = 1; + xKSpline = NULL; + yKSpline = NULL; + offsetPixelX = 0; + offsetPixelY = 0; + xTraslation = 0; + mType = DEFAULT; } @@ -224,9 +224,9 @@ bool pGraphicalFunction::deletePointAt(int index) { bool added=logicFunction -> deletePointAt( index ); if(!fromWindow) - setUp(); - else { + setUp(); + } else { logicFunction->setEndPoints(); logicFunction->setStartPoints(); } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.h index 4e8564c..227df55 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.h @@ -270,6 +270,11 @@ public: } return false; } + + + +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 /** Get Point list of the funcion @param return points @@ -279,16 +284,27 @@ public: logicFunction->GetPoints(points); //points = realPoints; } +#else + /** + Get Point list of the funcion + @param return pointsPtr + */ + virtual wxList* GetPointsPtr() + { + return logicFunction->GetPointsPtr(); + } +#endif + + /** Get the point where the user made a click */ - virtual void getMousePoint(int &x,int &y) { - x=mousePoint.x; - y=mousePoint.y; + x = mousePoint.x; + y = mousePoint.y; } /** diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pHistogram.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pHistogram.cxx index 95dc7a6..4bac5fb 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pHistogram.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pHistogram.cxx @@ -153,7 +153,6 @@ void pHistogram::initializePoints(int xDimension) void pHistogram::setPoints(vtkImageData* imageData) { -printf("EED pHistogram::setPoints Trinng new histogram ..\n"); /* printf("EED pHistogram::setPoints Test: vtkPComputeHistogram2DOutliers\n"); vtkComputeHistogram2DOutliers *vtkhist = vtkComputeHistogram2DOutliers::New(); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pLogicalFunction.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pLogicalFunction.h index 4958a39..6c5bac4 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pLogicalFunction.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pLogicalFunction.h @@ -101,6 +101,9 @@ public: } */ + +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 /** Get Point list of the funcion @param return points @@ -110,6 +113,19 @@ public: { points = realPoints; } +#else + /** + Get Point list of the funcion + @param return pointsPtr + */ + /*virtual*/ + wxList* GetPointsPtr() + { + return &realPoints; + } +#endif + + /* * validate if the function has that point in a sensible area returning the index where the point was found or -1 if is in not part of the function: define the sensible area is * x1-validPointRangeGetFirst(); +#endif // int i=1;//points.GetCount()+1; //JPRx int j=2; /* @@ -358,16 +365,19 @@ void pPlotterLayer::drawFunction(wxDC & dc,mpWindow & w, int orgy) /* Fill the function if it represented an histogram */ - ppoints=(wxPoint*)malloc(sizeof(int)*2*(points.GetCount()+2)); +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 + ppoints = (wxPoint*)malloc(sizeof(int)*2*(points.GetCount()+2)); +#else + ppoints = (wxPoint*)malloc(sizeof(int)*2*(GetPointsPtr()->GetCount()+2)); +#endif //initialize points - point.x=-5000; - point.y=GetYTranslated(sizedc,-5000); - ppoints[0]=point; - ppoints[1]=point; - + point.x = -5000; + point.y = GetYTranslated(sizedc,-5000); + ppoints[0] = point; + ppoints[1] = point; } - while (node!=NULL && node->GetNext()!=NULL) { pFunctionPoint* pointi=(pFunctionPoint*)node->GetData(); @@ -379,18 +389,16 @@ void pPlotterLayer::drawFunction(wxDC & dc,mpWindow & w, int orgy) int pyi=(pointi->getRealY()-minY)-offsetY; int pxj=(pointj->getRealX()-minX)-offsetX; int pyj=(pointj->getRealY()-minY)-offsetY; - - int cxi=pxi* scaleX + offsetpx; //+ xTraslation; int cxj=pxj* scaleX + offsetpx; //+ xTraslation; int cyi=pyi* scaleY+ offsetpy ; int cyj=pyj* scaleY+ offsetpy ; //dc.DrawLine(pxi* scaleX + offsetpx,pyi* scaleY+ offsetpy, pxj* scaleX + offsetpx,pyj* scaleY+ offsetpy ); if(type!=2) + { draw(dc,w,pxi* scaleX + offsetpx,pyi* scaleY+ offsetpy, pxj* scaleX + offsetpx,pyj* scaleY+ offsetpy,orgy ); //dc.DrawLine(pxi* scaleX + offsetpx,pyi* scaleY+ offsetpy, pxj* scaleX + offsetpx,pyj* scaleY+ offsetpy ); - else if(type==2) - { + } else if(type==2) { if(!initializePolygon(ppoints,cxi,cyi,cxj,cyj) && ((cxi<=0 && cxj>=0)||(cxi>=0 && cxj>=0))) { point.x=cxj; @@ -398,11 +406,9 @@ void pPlotterLayer::drawFunction(wxDC & dc,mpWindow & w, int orgy) ppoints[j]=point; j++; - } - } - + } // if + } // if type node=node->GetNext(); - } if(type==2) { @@ -426,9 +432,7 @@ void pPlotterLayer::drawFunction(wxDC & dc,mpWindow & w, int orgy) dc.SetPen(wxPen( wxColour(0,0,0) ,1,wxSOLID )); //dc.DrawPolygon(vx.size()+2,ppoints,0,0); dc.DrawPolygon(j+2,ppoints,0,0); - - } - + } // if type } /** @@ -494,10 +498,16 @@ void pPlotterLayer::drawLineToMousePoint(wxDC & dc,mpWindow & w, int orgy) getDirection(direction); getSize(sizeP); //Lines betwen the points - GetPoints(points); - wxNode *node=points.GetLast(); - wxNode *node1=points.GetFirst(); +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 + GetPoints(points); + wxNode *node = points.GetLast(); + wxNode *node1 = points.GetFirst(); +#else + wxNode *node = GetPointsPtr()->GetLast(); + wxNode *node1 = GetPointsPtr()->GetFirst(); +#endif /* @@ -670,8 +680,7 @@ void pPlotterLayer::Plot(wxDC & dc, mpWindow & w) GetYTranslated(sizedc,(realY_guide/*-w.getMinScrY()*/-offsetX)*scaleX + offsetpx), scrwX, GetYTranslated(sizedc,(realY_guide/*-w.getMinScrY()*/-offsetX)*scaleX + offsetpx)); - } - } - + } // if realY_guide + } // if actual } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.h index 1c9022e..1e6ef4d 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.h @@ -213,11 +213,21 @@ void draw(wxDC & dc,mpWindow & w,double x1,double y1,double x2,double y2, int or */ virtual bool GetNextXY(double & x, double & y){return false;} +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 /** Get Point list of the funcion @param return points */ virtual void GetPoints(wxList &points){} +#else + /** + Get Point list of the funcion + @param return points + */ + virtual wxList* GetPointsPtr(){ } +#endif + /** Layer plot handler. This implementation will plot the locus in the visible area and @@ -250,10 +260,17 @@ void draw(wxDC & dc,mpWindow & w,double x1,double y1,double x2,double y2, int or protected: int m_flags; //!< Holds label alignment + +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 /* * Points of the function thats is drawing */ wxList points; +#else + // use GetPointsPtr() +#endif + /* * the scale in x, with wich it must draw */ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterScaleX.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterScaleX.cxx index e9dc15c..6db34e6 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterScaleX.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterScaleX.cxx @@ -46,8 +46,8 @@ IMPLEMENT_CLASS(pPlotterScaleX, pPlotterLayer) //---------------------------------------------------------------------------- // Methods //---------------------------------------------------------------------------- -pPlotterScaleX::pPlotterScaleX(wxString aName,int flags) { - +pPlotterScaleX::pPlotterScaleX(wxString aName,int flags) +{ SetName(aName);/* SetFont(*wxSMALL_FONT); SetPen(*wxGREY_PEN);*/ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterWindow.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterWindow.cxx index 5115e2d..ea0be8f 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterWindow.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterWindow.cxx @@ -1740,12 +1740,20 @@ void pPlotterWindow :: OnGuideLines (wxCommandEvent &event) */ pGraphicalFunction* pPlotterWindow::getFunction(int index) { - wxNode* node=functions.Item(index); - if(node==NULL){ + wxNode* node=NULL; + if (functions.size()>index) + { + node=functions.Item(index); + } // if + + if(node==NULL) + { return NULL; - } + } // if node return (pGraphicalFunction*)node->GetData(); } + + /* move the functions that the user wants to move and that were set in functionsToMove @@ -1755,9 +1763,7 @@ pGraphicalFunction* pPlotterWindow::getFunction(int index) @param porcentageMaxX:the percentage that the maxShowed of the functions have to be move 0<=porcentageMaxX<=1 - */ - void pPlotterWindow::moveFunctions( float porcentageMinX,float porcentageMaxX) { //Adding the actual function diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterWindow.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterWindow.h index 64c29bf..264cc73 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterWindow.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterWindow.h @@ -395,7 +395,7 @@ private: */ wxTextCtrl *m_log; - wxString text; + wxString text; /* Functions to be move at the same time -- 2.45.1