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.SetAxisOrientation(true,false);  
00063 
00064         //      const int extend = w.GetScrY()-50;   //EED
00065         
00066         //draw the axe
00067         dc.DrawLine( 0,0, 0, (max-min)*scaleY);
00068 
00069         //maximum value in Y
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         //drawing the axe with the numbers
00084         wxString s;
00085         //drawing the first line
00086         dc.DrawLine(0,0,-10,0);
00087         s.Printf(_T("%d"),(int)(min));
00088         dc.DrawText(s,(wxCoord)-20,(wxCoord)0);
00089         
00090         
00091         for(float i=0;i<=(max);i+=step)
00092         {
00093                 
00094                 int p=(i-min-offsetY)*scaleY+offsetpy;
00095                 if(p>=0)
00096                 {       
00097                         dc.DrawLine(0,p,-10,p);
00098                         s.Printf(_T("%d"),(int)(i));
00099                         dc.DrawText(s,(wxCoord)-20,(wxCoord)p);
00100                 }
00101         }       
00102         //drawing the last line
00103         int p=(max-min-offsetY)*scaleY+offsetpy;
00104         dc.DrawLine(0,p,-10,p);
00105         s.Printf(_T("%d"),(int)(max));
00106         dc.DrawText(s,(wxCoord)-20,(wxCoord)p);
00107 }
00108 
00109 
00110 

Generated on Fri Jun 12 00:08:33 2009 for creaMaracasVisu by  doxygen 1.5.7.1