]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterScaleY.cxx
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / pPlotterScaleY.cxx
1 //----------------------------------------------------------------------------
2 // Class definition include
3 //----------------------------------------------------------------------------
4 #include "pPlotterScaleY.h"
5
6 // ----------------------------------------------------------------------------
7 // WX headers inclusion.
8 // For compilers that support precompilation, includes <wx/wx.h>.
9 // ----------------------------------------------------------------------------
10
11 #ifndef WX_PRECOMP
12 #include <wx/wx.h>
13 #endif
14
15 //----------------------------------------------------------------------------
16 // Class implementation
17 //----------------------------------------------------------------------------
18
19 #define mpLN10 2.3025850929940456840179914546844
20
21 IMPLEMENT_CLASS(pPlotterScaleY, pPlotterLayer)
22 //----------------------------------------------------------------------------
23 // Methods
24 //----------------------------------------------------------------------------
25 pPlotterScaleY::pPlotterScaleY(wxString aName,int flags) {
26
27         SetName(aName);/*
28         SetFont(*wxSMALL_FONT);
29         SetPen(*wxGREY_PEN);*/
30         wxFont ff( *wxSMALL_FONT);
31         wxPen pp( *wxGREY_PEN);
32         SetPen( pp );
33         SetFont( ff );
34 }
35
36 void pPlotterScaleY::Plot(wxDC& dc, mpWindow& w) 
37 {
38
39         int divisions=20;
40         
41         dc.SetPen( m_pen);
42         dc.SetFont( m_font);
43         
44         //data
45         float min= (float)w.getMinScrY();
46         float max=(float)w.getMaxScrY();
47         float scrY=(float)w.GetScrY()-50;
48         double scaleY=(scrY/(max-min))*w.getZoomFactor();
49         int offsetpy=w.getOffsetPixelsY();
50         int offsetY=w.getOffsetY();
51
52
53         //setting origins
54         
55 //EED 14Mai2009
56 //      const int orgy   = w.GetScrY()-40;
57 //      dc.SetDeviceOrigin(70,orgy);
58 //      dc.SetAxisOrientation(true,true);  //EED  MacOx ??? 
59         
60         const int orgy   = 40;
61         //dc.SetDeviceOrigin(70,orgy);
62         dc.SetDeviceOrigin(70,0);
63         double sizedc = dc.GetSize().GetY()-orgy;
64         //dc.SetAxisOrientation(true,false);  
65
66         //      const int extend = w.GetScrY()-50;   //EED
67         
68         //draw the axe
69         dc.DrawLine( 0,GetYTranslated(sizedc, 0), 0, GetYTranslated(sizedc, (max-min)*scaleY));
70
71         //maximum value in Y
72         int d=max-min;
73         if(d<20)
74                 {
75                         int k=d/divisions;
76                         while(k==0)
77                                 {
78                                         divisions--;
79                                         k=d/divisions;
80                                 }
81                 }
82         float step=(max-min)/divisions;
83         
84
85         //drawing the axe with the numbers
86         wxString s;
87         //drawing the first line
88         dc.DrawLine(0,GetYTranslated(sizedc, 0),-10,GetYTranslated(sizedc, 0));
89         s.Printf(_T("%d"),(int)(min));
90         dc.DrawText(s,(wxCoord)-20,GetYTranslated(sizedc, (wxCoord)0));
91         
92         
93         for(float i=0;i<=(max);i+=step)
94         {
95                 
96                 int p=(i-min-offsetY)*scaleY+offsetpy;
97                 if(p>=0)
98                 {       
99                         dc.DrawLine(0,GetYTranslated(sizedc, p),-10,GetYTranslated(sizedc, p));
100                         s.Printf(_T("%d"),(int)(i));
101                         dc.DrawText(s,(wxCoord)-20,GetYTranslated(sizedc, (wxCoord)p));
102                 }
103         }       
104         //drawing the last line
105         int p=(max-min-offsetY)*scaleY+offsetpy;
106         dc.DrawLine(0,GetYTranslated(sizedc, p),-10,GetYTranslated(sizedc, p));
107         s.Printf(_T("%d"),(int)(max));
108         dc.DrawText(s,(wxCoord)-20,GetYTranslated(sizedc, (wxCoord)p));
109 }
110
111
112