pPlotterScaleX.cxx
Go to the documentation of this file.00001
00002
00003
00004 #include "pPlotterScaleX.h"
00005
00006
00007
00008
00009
00010
00011 #ifndef WX_PRECOMP
00012 #include <wx/wx.h>
00013 #endif
00014
00015
00016
00017
00018 #define mpLN10 2.3025850929940456840179914546844
00019
00020 IMPLEMENT_CLASS(pPlotterScaleX, pPlotterLayer)
00021
00022
00023
00024 pPlotterScaleX::pPlotterScaleX(wxString aName,int flags) {
00025
00026 SetName(aName);
00027
00028
00029 wxFont ff( *wxSMALL_FONT);
00030 wxPen pp( *wxGREY_PEN);
00031 SetPen( pp );
00032 SetFont( ff );
00033 }
00034
00035 void pPlotterScaleX::Plot(wxDC& dc, mpWindow& w)
00036 {
00037
00038 int divisions=20;
00039
00040
00041 dc.SetPen( m_pen);
00042 dc.SetFont( m_font);
00043
00044
00045
00046
00047 float min=(float)w.getMinScrX();
00048 float max=(float)w.getMaxScrX();
00049 float scrX=(float)w.GetScrX()-100;
00050 double scaleX=(scrX/(max-min))*w.getZoomFactor();
00051 int offsetpx=w.getOffsetPixelsX();
00052 int offsetX=w.getOffsetX();
00053
00054
00055
00056
00057
00058
00059
00060
00061 const int orgy = 40;
00062
00063 dc.SetDeviceOrigin(70,0);
00064
00065 double sizedc = dc.GetSize().GetY()-orgy;
00066
00067
00068
00069
00070
00071 dc.DrawLine(0,GetYTranslated(sizedc, 0),(max-min)*scaleX,GetYTranslated(sizedc, 0));
00072
00073
00074 int d=max-min;
00075 if(d<20)
00076 {
00077 int k=d/divisions;
00078 while(k==0)
00079 {
00080 divisions--;
00081 k=d/divisions;
00082 }
00083 }
00084 float step=(max-min)/divisions;
00085
00086
00087 wxString s;
00088
00089
00090
00091 dc.DrawLine(0,GetYTranslated(sizedc, 0),0,GetYTranslated(sizedc, -10));
00092 s.Printf(_T("%d"),(int)(min));
00093 dc.DrawText(s,(wxCoord)0,GetYTranslated(sizedc, (wxCoord)-20));
00094
00095 for(float i=0;i<=(max);i+=step)
00096 {
00097
00098 int p=(i-min-offsetX)*scaleX+offsetpx;
00099 if(p>=0)
00100 {
00101 dc.DrawLine(p,0,p,-10);
00102 s.Printf(_T("%d"),(int)(i));
00103 dc.DrawText(s,(wxCoord)p,GetYTranslated(sizedc, (wxCoord)-20));
00104 }
00105 }
00106
00107 int p=(max-min-offsetX)*scaleX+offsetpx;
00108 dc.DrawLine(p,GetYTranslated(sizedc, 0),p,GetYTranslated(sizedc, -10));
00109 s.Printf(_T("%d"),(int)(max));
00110 dc.DrawText(s,(wxCoord)p,GetYTranslated(sizedc, (wxCoord)-20));
00111
00112 }
00113
00114