pPlotterScaleX.cxx

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 // Class definition include
00003 //----------------------------------------------------------------------------
00004 #include "pPlotterScaleX.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 #define mpLN10 2.3025850929940456840179914546844
00019 
00020 IMPLEMENT_CLASS(pPlotterScaleX, pPlotterLayer)
00021 //----------------------------------------------------------------------------
00022 // Methods
00023 //----------------------------------------------------------------------------
00024 pPlotterScaleX::pPlotterScaleX(wxString aName,int flags) {
00025 
00026         SetName(aName);/*
00027         SetFont(*wxSMALL_FONT);
00028         SetPen(*wxGREY_PEN);*/
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         //data
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         //setting origins
00055         
00056         //EED 14Mai2009
00057         //const int orgy   = w.GetScrY()-40;
00058 //      dc.SetDeviceOrigin(70,orgy);    
00059 //      dc.SetAxisOrientation(true,true);  //EED  MacOx  ???
00060         
00061         const int orgy   = 40;
00062         //dc.SetDeviceOrigin(70,orgy);  
00063         dc.SetDeviceOrigin(70,0);       
00064         //dc.SetAxisOrientation(true,false);  
00065         double sizedc = dc.GetSize().GetY()-orgy;
00066                 
00067         //const int extend = w.GetScrX()-100; //JPRx
00068 
00069         
00070         //draw the axe
00071         dc.DrawLine(0,GetYTranslated(sizedc, 0),(max-min)*scaleX,GetYTranslated(sizedc, 0));
00072 
00073         //maximum value in x
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         //drawing the axe with the numbers
00087         wxString s;
00088         
00089         
00090         //drawing the first line
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         //drawing the last line
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 

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1