]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mathplot.h
#3128 creaMaracasVisu Feature New Normal - branch changeWx28to30 compilation with...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / mathplot.h
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 /////////////////////////////////////////////////////////////////////////////
27 // Name:        mathplot.h
28 // Purpose:     Framework for mathematical graph plotting in wxWindows
29 // Author:      David Schalig
30 // Modified by:
31 // Created:     21/07/2003
32 // Copyright:   (c) David Schalig
33 // Licence:     wxWindows licence
34 /////////////////////////////////////////////////////////////////////////////
35
36 #ifndef _MP_MATHPLOT_H_
37 #define _MP_MATHPLOT_H_
38 #define ZOOM_FACTOR 1.5
39
40 /* @file mathplot.h */
41 /* @mainpage wxMathPlot
42 wxMathPlot is a framework for mathematical graph plotting in wxWindows.
43
44 The framework is designed for convenience and ease of use.
45
46 @section screenshots Screenshots
47 <a href="screenshots.html">Go to the screenshots page.</a>
48
49 @section overview Overview
50 The heart of wxMathPlot is mpWindow, which is a 2D canvas for plot layers.
51 mpWindow can be embedded as subwindow in a wxPane, a wxFrame, or any other wxWindow.
52 mpWindow provides a zoomable and moveable view of the layers. The current view can
53 be controlled with the mouse, the scrollbars, and a context menu.
54
55 Plot layers are implementations of the abstract base class mpLayer. Those can
56 be function plots, scale rulers, or any other vector data visualisation. wxMathPlot provides
57 two mpLayer implementations for plotting horizontal and vertical rulers: mpScaleX and mpScaleY.
58 For convenient function plotting three more abstract base classes derived from mpLayer
59 are provided: mpFX, mpFY and mpFXY. These base classes already come with plot code, own
60 functions can be implemented by overiding just one member for retrieving a function value.
61
62 @section coding Coding conventions
63 wxMathPlot sticks to wxWindow's coding conventions. All entities defined by wxMathPlot
64 have the prefix <i>mp</i>.
65
66 @section author Author and license
67 wxMathPlot is published under the terms of the wxWindow license.
68 The author David Schalig can be contacted via the wxMathPlot's homepage at
69 http://sourceforge.net/projects/wxmathplot
70 */
71
72 /*
73 #if defined(__GNUG__) && !defined(__APPLE__)
74 #pragma interface "mathplot.h"
75 #endif
76 */
77
78 #include "marTypes.h"
79 #include "wx/defs.h"
80 #include <wx/wx.h>
81
82 /*
83 #include "wx/menu.h"
84 #include "wx/scrolwin.h"
85 #include "wx/event.h"
86 #include "wx/dynarray.h"
87 */
88
89 //-----------------------------------------------------------------------------
90 // classes
91 //-----------------------------------------------------------------------------
92
93 class  mpLayer;
94 class  mpFX;
95 class  mpFY;
96 class  mpFXY;
97 class  mpScaleX;
98 class  mpScaleY;
99 class  mpWindow;
100
101 /** Command IDs used by mpWindow */
102 enum
103 {
104         mpID_FIT = 2000,    //!< Fit view to match bounding box of all layers
105         mpID_ZOOM_IN,       //!< Zoom into view at clickposition / window center
106         mpID_ZOOM_OUT,      //!< Zoom out
107         mpID_CENTER,        //!< Center view on click position
108         mpID_LOCKASPECT,    //!< Lock x/y scaling aspect
109         mpID_LINE_GUIDES,       //!< Enables or disables the line guides drawing condition
110 };
111
112 //-----------------------------------------------------------------------------
113 // mpLayer
114 //-----------------------------------------------------------------------------
115
116 /** Plot layer, abstract base class.
117 Any number of mpLayer implementations can be attached to mpWindow.
118 Examples for mpLayer implementations are function graphs, or scale rulers.
119
120 For convenience mpLayer defines a name, a font (wxFont), and a pen (wxPen)
121 as class members. These may or may not be used by implementations.
122 */
123 class creaMaracasVisu_EXPORT mpLayer : public wxObject
124 {
125 public:
126         mpLayer();
127
128         /** Check whether this layer has a bounding box.
129         The default implementation returns \a TRUE. Overide and return
130         FALSE if your mpLayer implementation should be ignored by the calculation
131         of the global bounding box for all layers in a mpWindow.
132         @retval TRUE Has bounding box
133         @retval FALSE Has not bounding box
134         */
135         virtual bool   HasBBox() { return TRUE; }
136
137         /** Get inclusive left border of bounding box.
138         @return Value
139         */
140         virtual double GetMinX() { return -1.0; }
141
142         /** Get inclusive right border of bounding box.
143         @return Value
144         */
145         virtual double GetMaxX() { return  1.0; }
146
147         /** Get inclusive bottom border of bounding box.
148         @return Value
149         */
150         virtual double GetMinY() { return -1.0; }
151
152         /** Get inclusive top border of bounding box.
153         @return Value
154         */
155         virtual double GetMaxY() { return  1.0; }
156
157         /** Plot given view of layer to the given device context.
158         An implementation of this function has to transform layer coordinates to
159         wxDC coordinates based on the view parameters retrievable from the mpWindow
160         passed in \a w. The passed device context \a dc has its coordinate origin set
161         to the center of the visible area. The coordinate orientation is as show in the
162         following picture:
163         <pre>
164         +--------------------------------------------------+
165         |                                                  |
166         |                                                  |
167         |                (wxDC origin 0,0)                 |
168         |                       x-------------> acending X |
169         |                       |                          |
170         |                       |                          |
171         |                       V ascending Y              |
172         +--------------------------------------------------+
173         </pre>
174         Note that Y ascends in downward direction, whereas the usual vertical orientation
175         for mathematical plots is vice versa. Thus Y-orientation will be swapped usually,
176         when transforming between wxDC and mpLayer coordinates.
177
178         <b> Rules for transformation between mpLayer and wxDC coordinates </b>
179         @code
180         dc_X = (layer_X - mpWindow::GetPosX()) * mpWindow::GetScaleX()
181         dc_Y = (mpWindow::GetPosY() - layer_Y) * mpWindow::GetScaleY() // swapping Y-orientation
182
183         layer_X = (dc_X / mpWindow::GetScaleX()) + mpWindow::GetPosX() // scale guaranted to be not 0
184         layer_Y = mpWindow::GetPosY() - (dc_Y / mpWindow::GetScaleY()) // swapping Y-orientation
185         @endcode
186
187         @param dc Device context to plot to.
188         @param w  View to plot. The visible area can be retrieved from this object.
189         */
190         virtual void   Plot(wxDC & dc, mpWindow & w) = 0;
191
192         /** Get layer name.
193         @return Name
194         */
195         wxString       GetName() const { return m_name; }
196
197         /** Get font set for this layer.
198         @return Font
199         */
200         const wxFont&  GetFont() const { return m_font; }
201
202         /** Get pen set for this layer.
203         @return Pen
204         */
205         const wxPen&   GetPen()  const { return m_pen;  }
206
207         /** Set layer name
208         @param name Name, will be copied to internal class member
209         */
210         void SetName(wxString name) { m_name = name; }
211
212         /** Set layer font
213         @param font Font, will be copied to internal class member
214         */
215         void SetFont(wxFont& font)  { m_font = font; }
216
217         /** Set layer pen
218         @param pen Pen, will be copied to internal class member
219         */
220         void SetPen(wxPen& pen)     { m_pen  = pen;  }
221
222         /**
223         ** Get the translation of the Y coordinate acoording to the new orientation of the axis du to the problem
224         ** identified in MACOS with the funtion 'SetAxisOrientation'
225         **/
226         int GetYTranslated(double sizey, double y){
227                 return -y+sizey;
228         }
229
230 protected:
231         wxFont   m_font;    //!< Layer's font
232         wxPen    m_pen;     //!< Layer's pen
233         wxString m_name;    //!< Layer's name
234
235         DECLARE_CLASS(mpLayer)
236 };
237
238 //-----------------------------------------------------------------------------
239 // mpLayer implementations - functions
240 //-----------------------------------------------------------------------------
241
242 /** @name Label alignment constants
243 @{*/
244
245 /** @internal */
246 #define mpALIGNMASK    0x03
247 /** Aligns label to the right. For use with mpFX. */
248 #define mpALIGN_RIGHT  0x00
249 /** Aligns label to the center. For use with mpFX and mpFY. */
250 #define mpALIGN_CENTER 0x01
251 /** Aligns label to the left. For use with mpFX. */
252 #define mpALIGN_LEFT   0x02
253 /** Aligns label to the top. For use with mpFY. */
254 #define mpALIGN_TOP    mpALIGN_RIGHT
255 /** Aligns label to the bottom. For use with mpFY. */
256 #define mpALIGN_BOTTOM mpALIGN_LEFT
257 /** Aligns label to north-east. For use with mpFXY. */
258 #define mpALIGN_NE     0x00
259 /** Aligns label to north-west. For use with mpFXY. */
260 #define mpALIGN_NW     0x01
261 /** Aligns label to south-west. For use with mpFXY. */
262 #define mpALIGN_SW     0x02
263 /** Aligns label to south-east. For use with mpFXY. */
264 #define mpALIGN_SE     0x03
265
266 /*@}*/
267
268 /** @name mpLayer implementations - functions
269 @{*/
270
271 /** Abstract base class providing plot and labeling functionality for functions F:X->Y.
272 Override mpFX::GetY to implement a function.
273 Optionally implement a constructor and pass a name (label) and a label alignment
274 to the constructor mpFX::mpFX. If the layer name is empty, no label will be plotted.
275 */
276 class  mpFX : public mpLayer
277 {
278 public:
279         /** @param name  Label
280         @param flags Label alignment, pass one of #mpALIGN_RIGHT, #mpALIGN_CENTER, #mpALIGN_LEFT.
281         */
282         mpFX(wxString name = wxEmptyString, int flags = mpALIGN_RIGHT);
283
284         /** Get function value for argument.
285         Override this function in your implementation.
286         @param x Argument
287         @return Function value
288         */
289         virtual double GetY( double x ) = 0;
290
291         /** Layer plot handler.
292         This implementation will plot the function in the visible area and
293         put a label according to the aligment specified.
294         */
295         virtual void Plot(wxDC & dc, mpWindow & w);
296
297 protected:
298         int m_flags; //!< Holds label alignment
299
300         DECLARE_CLASS(mpFX)
301 };
302
303 /** Abstract base class providing plot and labeling functionality for functions F:Y->X.
304 Override mpFY::GetX to implement a function.
305 Optionally implement a constructor and pass a name (label) and a label alignment
306 to the constructor mpFY::mpFY. If the layer name is empty, no label will be plotted.
307 */
308 class  mpFY : public mpLayer
309 {
310 public:
311         /** @param name  Label
312         @param flags Label alignment, pass one of #mpALIGN_BOTTOM, #mpALIGN_CENTER, #mpALIGN_TOP.
313         */
314         mpFY(wxString name = wxEmptyString, int flags = mpALIGN_TOP);
315
316         /** Get function value for argument.
317         Override this function in your implementation.
318         @param y Argument
319         @return Function value
320         */
321         virtual double GetX( double y ) = 0;
322
323         /** Layer plot handler.
324         This implementation will plot the function in the visible area and
325         put a label according to the aligment specified.
326         */
327         virtual void Plot(wxDC & dc, mpWindow & w);
328
329 protected:
330         int m_flags; //!< Holds label alignment
331
332         DECLARE_CLASS(mpFY)
333 };
334
335 /** Abstract base class providing plot and labeling functionality for a locus plot F:N->X,Y.
336 Locus argument N is assumed to be in range 0 .. MAX_N, and implicitely derived by enumrating
337 all locus values. Override mpFXY::Rewind and mpFXY::GetNextXY to implement a locus.
338 Optionally implement a constructor and pass a name (label) and a label alignment
339 to the constructor mpFXY::mpFXY. If the layer name is empty, no label will be plotted.
340 */
341 class  mpFXY : public mpLayer
342 {
343 public:
344         /** @param name  Label
345         @param flags Label alignment, pass one of #mpALIGN_NE, #mpALIGN_NW, #mpALIGN_SW, #mpALIGN_SE.
346         */
347         mpFXY(wxString name = wxEmptyString, int flags = mpALIGN_NE);
348
349         /** Rewind value enumeration with mpFXY::GetNextXY.
350         Override this function in your implementation.
351         */
352         virtual void Rewind() = 0;
353
354         /** Get locus value for next N.
355         Override this function in your implementation.
356         @param x Returns X value
357         @param y Returns Y value
358         */
359         virtual bool GetNextXY(double & x, double & y) = 0;
360
361         /** Layer plot handler.
362         This implementation will plot the locus in the visible area and
363         put a label according to the aligment specified.
364         */
365         virtual void Plot(wxDC & dc, mpWindow & w);
366
367 protected:
368         int m_flags; //!< Holds label alignment
369
370         DECLARE_CLASS(mpFXY)
371 };
372
373 /*@}*/
374
375 //-----------------------------------------------------------------------------
376 // mpLayer implementations - furniture (scales, ...)
377 //-----------------------------------------------------------------------------
378
379 /** @name mpLayer implementations - furniture (scales, ...)
380 @{*/
381
382 /** Plot layer implementing a x-scale ruler.
383 The ruler is fixed at Y=0 in the coordinate system. A label is plottet at
384 the bottom-right hand of the ruler. The scale numbering automatically
385 adjusts to view and zoom factor.
386 */
387 class  mpScaleX : public mpLayer
388 {
389 public:
390         /** @param name Label to plot by the ruler */
391         mpScaleX(wxString name = wxT("X"));
392
393         /** Layer plot handler.
394         This implementation will plot the ruler adjusted to the visible area.
395         */
396         virtual void Plot(wxDC & dc, mpWindow & w);
397
398         /** Check whether this layer has a bounding box.
399         This implementation returns \a FALSE thus making the ruler invisible
400         to the plot layer bounding box calculation by mpWindow.
401         */
402         virtual bool HasBBox() { return FALSE; }
403
404         DECLARE_CLASS(mpScaleX)
405 };
406
407 /** Plot layer implementing a y-scale ruler.
408 The ruler is fixed at X=0 in the coordinate system. A label is plottet at
409 the top-right hand of the ruler. The scale numbering automatically
410 adjusts to view and zoom factor.
411 */
412 class  mpScaleY : public mpLayer
413 {
414 public:
415         /** @param name Label to plot by the ruler */
416         mpScaleY(wxString name = wxT("Y"));
417
418         /** Layer plot handler.
419         This implementation will plot the ruler adjusted to the visible area.
420         */
421         virtual void Plot(wxDC & dc, mpWindow & w, int orgy);
422
423         /** Check whether this layer has a bounding box.
424         This implementation returns \a FALSE thus making the ruler invisible
425         to the plot layer bounding box calculation by mpWindow.
426         */
427         virtual bool HasBBox() { return FALSE; }
428
429 protected:
430
431         DECLARE_CLASS(mpScaleY)
432 };
433
434 //-----------------------------------------------------------------------------
435 // mpWindow
436 //-----------------------------------------------------------------------------
437
438 /** @name Constants defining mouse modes for mpWindow
439 @{*/
440
441 /** Mouse panning drags the view. Mouse mode for mpWindow. */
442 #define mpMOUSEMODE_DRAG    0
443 /** Mouse panning creates a zoom box. Mouse mode for mpWindow. */
444 #define mpMOUSEMODE_ZOOMBOX 1
445
446 /*@}*/
447
448 /** Canvas for plotting mpLayer implementations.
449
450 This class defines a zoomable and moveable 2D plot canvas. Any number
451 of mpLayer implementations (scale rulers, function plots, ...) can be
452 attached using mpWindow::AddLayer.
453
454 The canvas window provides a context menu with actions for navigating the view.
455 The context menu can be retrieved with mpWindow::GetPopupMenu, e.g. for extending it
456 externally.
457 */
458 class creaMaracasVisu_EXPORT mpWindow : public wxScrolledWindow
459 {
460 public:
461         mpWindow() {}
462         mpWindow( wxWindow *parent, wxWindowID id,
463                 const wxPoint &pos = wxDefaultPosition, 
464                 const wxSize &size = wxDefaultSize,
465                 int flags = 0);
466         ~mpWindow();
467
468
469         /** Get reference to context menu of the plot canvas.
470         @return Pointer to menu. The menu can be modified.
471         */
472         wxMenu* GetPopupMenu() { return &m_popmenu; }
473
474         //-----------------------
475         // new methods for plotter
476         //-----------------------
477         /*
478          Set Type
479         */
480         void setType(int t)
481         {
482                 type=t;
483         }
484         /*
485          Get Type
486         */
487         int getType()
488         {
489                 return type;
490         }
491                 
492         
493         /**
494          set the max value in the x axis
495          @param maxX 
496         */
497         void setMaxScrX(int maxX)
498         {
499                 maxScrX=maxX;
500         }
501         /**
502          set the max value in the y axis
503          @param maxY
504         */
505         void setMaxScrY(int maxY)
506         {
507                 maxScrY=maxY;
508         }
509         
510         
511         /**Get maximum value in x
512          @return maxScrX
513         */
514         double getMaxScrX()
515         {
516                 return maxScrX;
517         }
518         /**Get maximum value in y
519          @return maxScrY
520         */
521         double getMaxScrY()
522         {
523                 return maxScrY;
524         }
525         /*
526          returns the zoomFactor
527         */
528         float getZoomFactor()
529         {
530                 return zoomFactor;
531         }
532         /**
533          set the min value in the x axis
534          @param minX 
535         */
536         void setMinScrX(int minX)
537         {
538                 minScrX=minX;
539         }
540         /**
541          set the min value in the y axis
542          @param minY
543         */
544         void setMinScrY(int minY)
545         {
546                 minScrY=minY;
547         }
548         
549         
550         /**Get miniimum value in x
551          @return minScrX
552         */
553         double getMinScrX()
554         {
555                 return minScrX;
556         }
557         /**Get minimum value in y
558          @return minScrY
559         */
560         double getMinScrY()
561         {
562                 return minScrY;
563         }
564
565         /**
566         Get the x-clicked by the user
567         @return m_clickedX
568         */
569         int getClickedX()
570         {
571                 return m_clickedX;
572         }
573
574         /**
575         Get the y-clicked by the user
576         @return m_clickedY
577         */
578         int getClickedY()
579         {
580                 return m_clickedY;
581         }
582         
583         /**
584         Gets the x-offset of the zoom
585         in pixels
586         */
587         int getOffsetPixelsX()
588         {
589                 return offsetPixelX;
590         }       
591         
592         /**
593         Gets the offset of the zoom
594         in pixels
595         */
596         int getOffsetPixelsY()
597         {
598                 return offsetPixelY;
599         }
600         /**
601          Set the x-offset of the zoom
602         */
603         void setOffsetPixelX(int offX)
604         {
605                 offsetPixelX=offX;
606         }
607         /**
608          Set the y-offset of the zoom
609         */
610         void setOffsetPixelY(int offY)
611         {
612                 offsetPixelY=offY;
613         }       
614         
615         /**
616         Gets the x-offset of the zoom
617         */
618         int getOffsetX()
619         {
620                 return offsetX;
621         }       
622         
623         /**
624         Gets the offset of the zoom
625         */
626         int getOffsetY()
627         {
628                 return offsetY;
629         }
630         /**
631          Set the x-offset of the zoom
632         */
633         void setOffsetX(int offX)
634         {
635                 offsetX=offX;
636         }
637         /**
638          Set the y-offset of the zoom
639         */
640         void setOffsetY(int offY)
641         {
642                 offsetY=offY;
643         }       
644         
645         /*
646         * Sets real value of the y-coord for the vertical guide line
647         * @param newX_realGuide The new value to assing for the vertical guide
648         */
649         void setRealGuideX(int newX_realGuide)
650         {               
651                 real_guideLine_X = newX_realGuide;      
652                 if(real_guideLine_X!=-1)
653                         UpdateAll();
654         }
655
656         /*
657         * Gets the real value of the y-coord for the vertical guide line
658         * @retval real_guideLine_X The assigned value for the vertical guide
659         */
660         int getRealGuideX()
661         {
662                 return real_guideLine_X;
663         }       
664
665         /*
666         * Sets real value of the y-coord for the vertical guide line
667         * @param newY_realGuide The new value to assing for the vertical guide
668         */
669         void setRealGuideY(int newY_realGuide)
670         {               
671                 real_guideLine_Y = newY_realGuide;      
672                 if(real_guideLine_Y!=-1)
673                         UpdateAll();
674         }
675
676         /*
677         * Gets the real value of the y-coord for the vertical guide line
678         * @retval real_guideLine_Y The assigned value for the vertical guide
679         */
680         int getRealGuideY()
681         {
682                 return real_guideLine_Y;
683         }               
684
685         /*
686         * Sets the condition for drawing or not the guide lines
687         * @param ifDrawing The new condition to assing 
688         */
689         /*void setLineGuidesCondition(bool ifDrawing)
690         {               
691                 drawGuides = ifDrawing;         
692         }
693         */
694         
695         /*
696         * Gets the condition for drawing or not the guide lines
697         * @retval drawGuides The assigned condition
698         */
699         bool drawGuideLines();
700
701         /*
702         * Guide lines menu handler method that reacts to the mpID_LINE_GUIDES cimmand event
703         * event The corresponding event to handle
704         */
705         
706         //void OnGuideLines (wxCommandEvent   &event); 
707
708         //----------------------------------------------------------------------------------
709         // Previous methods
710         //----------------------------------------------------------------------------------
711         
712         
713         /** Add a plot layer to the canvas.
714         @param layer Pointer to layer. The mpLayer object will get under control of mpWindow,
715         i.e. it will be delete'd on mpWindow destruction
716         @retval TRUE Success
717         @retval FALSE Failure due to out of memory.
718         */
719         bool AddLayer( mpLayer* layer);
720
721         /** Remove a plot layer from the canvas.
722         @param layer Pointer to layer. The mpLayer object will be destructed using delete.
723         */
724         void DelLayer( mpLayer* layer);
725
726         /** Get current view's X scale.
727         See @ref mpLayer::Plot "rules for coordinate transformation"
728         @return Scale
729         */
730         double GetScaleX(void) const { return m_scaleX; }
731
732         /** Get current view's Y scale.
733         See @ref mpLayer::Plot "rules for coordinate transformation"
734         @return Scale
735         */
736         double GetScaleY(void) const { return m_scaleY; }
737
738         /** Get current view's X position.
739         See @ref mpLayer::Plot "rules for coordinate transformation"
740         @return X Position in layer coordinate system, that corresponds to the center point of the view.
741         */
742         double GetPosX(void) const { return m_posX; }
743
744         /** Get current view's Y position.
745         See @ref mpLayer::Plot "rules for coordinate transformation"
746         @return Y Position in layer coordinate system, that corresponds to the center point of the view.
747         */
748         double GetPosY(void) const { return m_posY; }
749
750         /** Get current view's X dimension in device context units.
751         Usually this is equal to wxDC::GetSize, but it might differ thus mpLayer
752         implementations should rely on the value returned by the function.
753         See @ref mpLayer::Plot "rules for coordinate transformation"
754         @return X dimension. 
755         */
756         int GetScrX(void) const { return m_scrX; }
757
758         /** Get current view's Y dimension in device context units.
759         Usually this is equal to wxDC::GetSize, but it might differ thus mpLayer
760         implementations should rely on the value returned by the function.
761         See @ref mpLayer::Plot "rules for coordinate transformation"
762         @return Y dimension. 
763         */
764         int GetScrY(void) const { return m_scrY; }
765         //void SetScrY(int x) const { return m_scrY; }
766
767         /** Set current view's X scale and refresh display. 
768         @param scaleX New scale, must not be 0.
769         */
770         void SetScaleX(double scaleX) { if (scaleX!=0) m_scaleX=scaleX; /*UpdateAll();*/ }
771
772         /** Set current view's Y scale and refresh display. 
773         @param scaleY New scale, must not be 0.
774         */
775         void SetScaleY(double scaleY) { if (scaleY!=0) m_scaleY=scaleY; /*UpdateAll();*/ }
776
777         /** Set current view's X position and refresh display. 
778         @param posX New position that corresponds to the center point of the view.
779         */
780         void SetPosX(double posX) { m_posX=posX; UpdateAll(); }
781
782         /** Set current view's Y position and refresh display. 
783         @param posY New position that corresponds to the center point of the view.
784         */
785         void SetPosY(double posY) { m_posY=posY; UpdateAll(); }
786
787         /** Set current view's X and Y position and refresh display. 
788         @param posX New position that corresponds to the center point of the view.
789         @param posY New position that corresponds to the center point of the view.
790         */
791         void SetPos( double posX, double posY) { m_posX=posX; m_posY=posY; UpdateAll(); }
792
793         /** Enable or disable X/Y scale aspect locking for the view.
794         @note Explicit calls to mpWindow::SetScaleX and mpWindow::SetScaleY will set
795         an unlocked apect, but any other action changing the view scale will
796         lock the aspect again.
797         */
798         void LockAspect(bool enable = TRUE);
799
800         /** Checks whether the X/Y scale aspect is locked.
801         @retval TRUE Locked
802         @retval FALSE Unlocked
803         */
804         inline bool IsAspectLocked() { return m_lockaspect; }
805
806         /** Set view to fit global bounding box of all plot layers and refresh display.
807         Scale and position will be set to a show all attached mpLayers.
808         The X/Y scale aspect lock is taken into account.
809         */
810         void Fit();
811
812         /** Zoom into current view and refresh display */
813         void ZoomIn();
814
815         /** Zoom out current view and refresh display */
816         void ZoomOut();
817
818         /** Refresh display */
819         void UpdateAll();
820
821         /**
822         ** Get the translation of the Y coordinate
823         **/
824         int GetYTranslated(wxSize size, double y){
825                 return size.GetHeight()-y;
826         }
827
828 protected:
829
830         void Refresh(bool eraseBackground = true, const wxRect* rect = NULL);
831         void OnPaint         (wxPaintEvent     &event); //!< Paint handler, will plot all attached layers
832         void OnSize          (wxSizeEvent      &event); //!< Size handler, will update scroll bar sizes
833         void OnScroll2       (wxScrollWinEvent &event); //!< Scroll handler, will move canvas
834         void OnShowPopupMenu (wxMouseEvent     &event); //!< Mouse handler, will show context menu
835         void OnCenter        (wxCommandEvent   &event); //!< Context menu handler
836         void OnFit           (wxCommandEvent   &event); //!< Context menu handler
837         void OnZoomIn        (wxCommandEvent   &event); //!< Context menu handler
838         void OnZoomOut       (wxCommandEvent   &event); //!< Context menu handler
839         void OnLockAspect    (wxCommandEvent   &event); //!< Context menu handler
840         
841
842         bool UpdateBBox(); //!< Recalculate global layer bounding box
843
844         wxList m_layers;    //!< List of attached plot layers
845         wxMenu m_popmenu;   //!< Canvas' context menu
846         bool   m_lockaspect;//!< Scale aspect is locked or not
847
848         double m_minX;      //!< Global layer bounding box, left border incl.
849         double m_maxX;      //!< Global layer bounding box, right border incl.
850         double m_minY;      //!< Global layer bounding box, bottom border incl.
851         double m_maxY;      //!< Global layer bounding box, top border incl.
852         double m_scaleX;    //!< Current view's X scale
853         double m_scaleY;    //!< Current view's Y scale
854         double m_posX;      //!< Current view's X position
855         double m_posY;      //!< Current view's Y position
856         int    m_scrX;      //!< Current view's X dimension
857         int    m_scrY;      //!< Current view's Y dimension
858         int    m_clickedX;  //!< Last mouse click X position, for centering and zooming the view
859         int    m_clickedY;  //!< Last mouse click Y position, for centering and zooming the view
860         
861         //----------------------------------------------
862         //NEW ATTRIBUTES FOR COMPATIBILITY WITH PPlotter
863         //----------------------------------------------
864         /**
865          the max value in the x axis
866         */
867         int    maxScrX;
868         
869         /**
870          the max value in the y axis
871         */
872         int    maxScrY;
873         /**
874          the min value in the x axis
875         */
876         int  minScrX;
877         
878         /**
879          the min value in the y axis
880         */
881         int  minScrY;
882         /*
883          the zoom factor
884          of the zoom
885         */
886         float      zoomFactor;
887
888         
889         /**
890          offset in pixels where the user has clicked
891          before changing the scale (in the actual function)
892         */
893         int offsetPixelX;
894         int offsetPixelY;
895         /*
896          Offsets in real value according to the actual function
897         */
898         int offsetX;
899         int offsetY;
900
901         /*
902         * The real value of the y-coord for the horizontal guide line
903         */
904         int real_guideLine_X;
905         /*
906         * The real value of the y-coord for the vertical guide line
907         */
908         int real_guideLine_Y;
909
910         /*
911         * Represents the condition for drawing or not the line guides, default color is red and assigned to draw them
912         */
913         bool drawGuides;
914         /*
915          Use to know which type of plotter is
916          1= default Plotter
917          2= histogram plotter
918         */
919          int type;
920
921
922  private:
923         //bitmap of functions
924         wxBitmap        *_bitmap_functions;
925
926
927 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
928 #if wxMAJOR_VERSION <= 2
929         DECLARE_CLASS(mpWindow)
930 #else
931         wxDECLARE_DYNAMIC_CLASS(mpWindow);
932 #endif
933
934         DECLARE_EVENT_TABLE()
935
936
937 };
938
939 #endif // _MP_MATHPLOT_H_