]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotterScaleX.cxx
- Comment out uselesss #define MAX (vtk-4.5 doesn't compile)
[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         const int orgy   = w.GetScrY()-40;
54         //const int extend = w.GetScrX()-100; //JPRx
55
56         dc.SetDeviceOrigin(70,orgy);
57         dc.SetAxisOrientation(true,true);
58         
59         //draw the axe
60         dc.DrawLine(0,0,(max-min)*scaleX,0);
61
62         //maximum value in x
63         int d=max-min;
64         if(d<20)
65                 {
66                         int k=d/divisions;
67                         while(k==0)
68                                 {
69                                         divisions--;
70                                         k=d/divisions;
71                                 }
72                 }
73         float step=(max-min)/divisions;
74
75         //drawing the axe with the numbers
76         wxString s;
77         
78         
79         //drawing the first line
80         dc.DrawLine(0,0,0,-10);
81         s.Printf(_T("%d"),(int)(min));
82         dc.DrawText(s,(wxCoord)0,(wxCoord)-20);
83         
84         for(float i=0;i<=(max);i+=step)
85         {
86                 
87                 int p=(i-min-offsetX)*scaleX+offsetpx;
88                 if(p>=0)
89                 {       
90                         dc.DrawLine(p,0,p,-10);
91                         s.Printf(_T("%d"),(int)(i));
92                         dc.DrawText(s,(wxCoord)p,(wxCoord)-20);         
93                 }
94         }
95         //drawing the last line
96         int p=(max-min-offsetX)*scaleX+offsetpx;
97         dc.DrawLine(p,0,p,-10);
98         s.Printf(_T("%d"),(int)(max));
99         dc.DrawText(s,(wxCoord)p,(wxCoord)-20);
100
101 }
102
103