]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterScaleX.cxx
BUG MacOs
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / pPlotterScaleX.cxx
1 //----------------------------------------------------------------------------
2 // Class definition include
3 //----------------------------------------------------------------------------
4 #include "pPlotterScaleX.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 #define mpLN10 2.3025850929940456840179914546844
19
20 IMPLEMENT_CLASS(pPlotterScaleX, pPlotterLayer)
21 //----------------------------------------------------------------------------
22 // Methods
23 //----------------------------------------------------------------------------
24 pPlotterScaleX::pPlotterScaleX(wxString aName,int flags) {
25
26         SetName(aName);/*
27         SetFont(*wxSMALL_FONT);
28         SetPen(*wxGREY_PEN);*/
29         wxFont ff( *wxSMALL_FONT);
30         wxPen pp( *wxGREY_PEN);
31         SetPen( pp );
32         SetFont( ff );
33 }
34
35 void pPlotterScaleX::Plot(wxDC& dc, mpWindow& w) 
36 {
37
38         int divisions=20;
39         
40
41         dc.SetPen( m_pen);
42         dc.SetFont( m_font);
43         
44         //data
45         float min=(float)w.getMinScrX();
46         float max=(float)w.getMaxScrX();
47         float scrX=(float)w.GetScrX()-100;
48         double scaleX=(scrX/(max-min))*w.getZoomFactor();
49         int offsetpx=w.getOffsetPixelsX();
50         int offsetX=w.getOffsetX();
51
52         //setting origins
53         
54         //EED 14Mai2009
55         //const int orgy   = w.GetScrY()-40;
56 //      dc.SetDeviceOrigin(70,orgy);    
57 //      dc.SetAxisOrientation(true,true);  //EED  MacOx  ???
58         
59         const int orgy   = 40;
60         dc.SetDeviceOrigin(70,orgy);    
61         dc.SetAxisOrientation(true,false);  
62         
63         //const int extend = w.GetScrX()-100; //JPRx
64
65         
66         //draw the axe
67         dc.DrawLine(0,0,(max-min)*scaleX,0);
68
69         //maximum value in x
70         int d=max-min;
71         if(d<20)
72                 {
73                         int k=d/divisions;
74                         while(k==0)
75                                 {
76                                         divisions--;
77                                         k=d/divisions;
78                                 }
79                 }
80         float step=(max-min)/divisions;
81
82         //drawing the axe with the numbers
83         wxString s;
84         
85         
86         //drawing the first line
87         dc.DrawLine(0,0,0,-10);
88         s.Printf(_T("%d"),(int)(min));
89         dc.DrawText(s,(wxCoord)0,(wxCoord)-20);
90         
91         for(float i=0;i<=(max);i+=step)
92         {
93                 
94                 int p=(i-min-offsetX)*scaleX+offsetpx;
95                 if(p>=0)
96                 {       
97                         dc.DrawLine(p,0,p,-10);
98                         s.Printf(_T("%d"),(int)(i));
99                         dc.DrawText(s,(wxCoord)p,(wxCoord)-20);         
100                 }
101         }
102         //drawing the last line
103         int p=(max-min-offsetX)*scaleX+offsetpx;
104         dc.DrawLine(p,0,p,-10);
105         s.Printf(_T("%d"),(int)(max));
106         dc.DrawText(s,(wxCoord)p,(wxCoord)-20);
107
108 }
109
110