pPlotterScaleY.cxx

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 // Class definition include
00003 //----------------------------------------------------------------------------
00004 #include "pPlotterScaleY.h"
00005 
00006 // ----------------------------------------------------------------------------
00007 // WX headers inclusion.
00008 // For compilers that support precompilation, includes <wx/wx.h>.
00009 // ----------------------------------------------------------------------------
00010 
00011 #ifndef WX_PRECOMP
00012 #include <wx/wx.h>
00013 #endif
00014 
00015 //----------------------------------------------------------------------------
00016 // Class implementation
00017 //----------------------------------------------------------------------------
00018 
00019 #define mpLN10 2.3025850929940456840179914546844
00020 
00021 IMPLEMENT_CLASS(pPlotterScaleY, pPlotterLayer)
00022 //----------------------------------------------------------------------------
00023 // Methods
00024 //----------------------------------------------------------------------------
00025 pPlotterScaleY::pPlotterScaleY(wxString aName,int flags) {
00026 
00027         SetName(aName);/*
00028         SetFont(*wxSMALL_FONT);
00029         SetPen(*wxGREY_PEN);*/
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         //data
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         //setting origins
00054         
00055 //EED 14Mai2009
00056 //      const int orgy   = w.GetScrY()-40;
00057 //      dc.SetDeviceOrigin(70,orgy);
00058 //      dc.SetAxisOrientation(true,true);  //EED  MacOx ??? 
00059         
00060         const int orgy   = 40;
00061         //dc.SetDeviceOrigin(70,orgy);
00062         dc.SetDeviceOrigin(70,0);
00063         double sizedc = dc.GetSize().GetY()-orgy;
00064         //dc.SetAxisOrientation(true,false);  
00065 
00066         //      const int extend = w.GetScrY()-50;   //EED
00067         
00068         //draw the axe
00069         dc.DrawLine( 0,GetYTranslated(sizedc, 0), 0, GetYTranslated(sizedc, (max-min)*scaleY));
00070 
00071         //maximum value in Y
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         //drawing the axe with the numbers
00086         wxString s;
00087         //drawing the first line
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         //drawing the last line
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 

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1