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 float min=(float)w.getMinScrX();
00046 float max=(float)w.getMaxScrX();
00047 float scrX=(float)w.GetScrX()-100;
00048 double scaleX=(scrX/(max-min))*w.getZoomFactor();
00049 int offsetpx=w.getOffsetPixelsX();
00050 int offsetX=w.getOffsetX();
00051
00052
00053
00054
00055
00056
00057
00058
00059 const int orgy = 40;
00060 dc.SetDeviceOrigin(70,orgy);
00061 dc.SetAxisOrientation(true,false);
00062
00063
00064
00065
00066
00067 dc.DrawLine(0,0,(max-min)*scaleX,0);
00068
00069
00070 int d=max-min;
00071 if(d<20)
00072 {
00073 int k=d/divisions;
00074 while(k==0)
00075 {
00076 divisions--;
00077 k=d/divisions;
00078 }
00079 }
00080 float step=(max-min)/divisions;
00081
00082
00083 wxString s;
00084
00085
00086
00087 dc.DrawLine(0,0,0,-10);
00088 s.Printf(_T("%d"),(int)(min));
00089 dc.DrawText(s,(wxCoord)0,(wxCoord)-20);
00090
00091 for(float i=0;i<=(max);i+=step)
00092 {
00093
00094 int p=(i-min-offsetX)*scaleX+offsetpx;
00095 if(p>=0)
00096 {
00097 dc.DrawLine(p,0,p,-10);
00098 s.Printf(_T("%d"),(int)(i));
00099 dc.DrawText(s,(wxCoord)p,(wxCoord)-20);
00100 }
00101 }
00102
00103 int p=(max-min-offsetX)*scaleX+offsetpx;
00104 dc.DrawLine(p,0,p,-10);
00105 s.Printf(_T("%d"),(int)(max));
00106 dc.DrawText(s,(wxCoord)p,(wxCoord)-20);
00107
00108 }
00109
00110