]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.cxx
#3144 creaMaracasVisu Bug New Normal - changeWx28to30
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / pPlotterLayer.cxx
index b1053424d1c4197d241c423fc4e5421ee8750bfe..6951ccef5c2d9c081a3a392f0aac41ab34f0a510 100644 (file)
@@ -57,9 +57,14 @@ pPlotterLayer:: pPlotterLayer(wxString name , int flags )
 {
        SetName(name);
        m_flags = flags;
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
        points.DeleteContents(TRUE);
-       offsetX=0;
-       offsetY=0;
+#else
+       // ...
+#endif
+       offsetX = 0;
+       offsetY = 0;
 }
 
 /*
@@ -314,28 +319,25 @@ bool pPlotterLayer::initializePolygon(wxPoint* points,double x1, double y1,doubl
 */
 void pPlotterLayer::drawFunction(wxDC & dc,mpWindow & w, int orgy)
 {
-
-       
        int scrwX,scrwY,offsetpx,offsetpy,maxX,minX,maxY,minY;
-       wxPoint* ppoints=NULL;
+       wxPoint* ppoints = NULL;
 
        /*
        This is the offset of every point scale to the window
        pixel
        */
-       offsetpx=getOffsetPixelsXv();
-       offsetpy=getOffsetPixelsYv();   
-
+       offsetpx = getOffsetPixelsXv();
+       offsetpy = getOffsetPixelsYv(); 
        Rewind();
-       
        dc.GetSize(&scrwX, &scrwY);
-       
        //Lines between the points
-
        int sizedc = dc.GetSize().GetHeight()-orgy;
-       
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
        GetPoints(points);
-
+#else
+  //...
+#endif
        // type of plotter
        int type=getmType();
        /***********/
@@ -345,7 +347,12 @@ void pPlotterLayer::drawFunction(wxDC & dc,mpWindow & w, int orgy)
 
        //traslation
        //int xTraslation=getXTraslation(); //JPRx
+//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+#if wxMAJOR_VERSION <= 2
        wxNode* node= points.GetFirst();
+#else
+       wxNode* node= GetPointsPtr()->GetFirst();
+#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
 }