]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterLayer.cxx
#3418 creaMaracasVisu Feature New Normal - ManualPaint_model with openmp
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / pPlotterLayer.cxx
index c8c64d66267484952324d736535856044a361b7b..6951ccef5c2d9c081a3a392f0aac41ab34f0a510 100644 (file)
@@ -1,3 +1,28 @@
+/*# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+#                        pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+#  This software is governed by the CeCILL-B license under French law and
+#  abiding by the rules of distribution of free software. You can  use,
+#  modify and/ or redistribute the software under the terms of the CeCILL-B
+#  license as circulated by CEA, CNRS and INRIA at the following URL
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability.
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------ */
+
 //----------------------------------------------------------------------------
 // Class definition include
 //----------------------------------------------------------------------------
@@ -32,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;
 }
 
 /*
@@ -289,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();
        /***********/
@@ -320,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;
        /*
@@ -333,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();
@@ -354,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;
@@ -373,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)
        {
@@ -401,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
 }
 
 /**
@@ -469,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
        
        
        /*
@@ -645,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
 }