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