#include <mathplot.h>
Public Member Functions | |
mpScaleY (wxString name=wxT("Y")) | |
virtual void | Plot (wxDC &dc, mpWindow &w, int orgy) |
virtual bool | HasBBox () |
virtual double | GetMinX () |
virtual double | GetMaxX () |
virtual double | GetMinY () |
virtual double | GetMaxY () |
virtual void | Plot (wxDC &dc, mpWindow &w)=0 |
wxString | GetName () const |
const wxFont & | GetFont () const |
const wxPen & | GetPen () const |
void | SetName (wxString name) |
void | SetFont (wxFont &font) |
void | SetPen (wxPen &pen) |
int | GetYTranslated (double sizey, double y) |
Protected Attributes | |
wxFont | m_font |
Layer's font. | |
wxPen | m_pen |
Layer's pen. | |
wxString | m_name |
Layer's name. |
Plot layer implementing a y-scale ruler. The ruler is fixed at X=0 in the coordinate system. A label is plottet at the top-right hand of the ruler. The scale numbering automatically adjusts to view and zoom factor.
Definition at line 387 of file mathplot.h.
mpScaleY::mpScaleY | ( | wxString | name = wxT("Y") |
) |
name | Label to plot by the ruler |
Definition at line 312 of file mathplot.cxx.
const wxFont& mpLayer::GetFont | ( | ) | const [inline, inherited] |
Get font set for this layer.
Definition at line 175 of file mathplot.h.
00175 { return m_font; }
virtual double mpLayer::GetMaxX | ( | ) | [inline, virtual, inherited] |
Get inclusive right border of bounding box.
Definition at line 120 of file mathplot.h.
Referenced by mpWindow::UpdateBBox().
virtual double mpLayer::GetMaxY | ( | ) | [inline, virtual, inherited] |
Get inclusive top border of bounding box.
Definition at line 130 of file mathplot.h.
Referenced by mpWindow::UpdateBBox().
virtual double mpLayer::GetMinX | ( | ) | [inline, virtual, inherited] |
Get inclusive left border of bounding box.
Definition at line 115 of file mathplot.h.
Referenced by mpWindow::UpdateBBox().
virtual double mpLayer::GetMinY | ( | ) | [inline, virtual, inherited] |
Get inclusive bottom border of bounding box.
Definition at line 125 of file mathplot.h.
Referenced by mpWindow::UpdateBBox().
wxString mpLayer::GetName | ( | ) | const [inline, inherited] |
const wxPen& mpLayer::GetPen | ( | ) | const [inline, inherited] |
Get pen set for this layer.
Definition at line 180 of file mathplot.h.
00180 { return m_pen; }
int mpLayer::GetYTranslated | ( | double | sizey, | |
double | y | |||
) | [inline, inherited] |
Get the translation of the Y coordinate acoording to the new orientation of the axis du to the problem identified in MACOS with the funtion 'SetAxisOrientation'
Definition at line 201 of file mathplot.h.
Referenced by pPlotterLayer::draw(), pPlotterLayer::drawFunction(), pPlotterLayer::drawPoints(), pPlotterLayer::drawSplineCurve(), pPlotterScaleY::Plot(), pPlotterScaleX::Plot(), pPlotterLayer::Plot(), and Plot().
virtual bool mpScaleY::HasBBox | ( | ) | [inline, virtual] |
Check whether this layer has a bounding box. This implementation returns FALSE thus making the ruler invisible to the plot layer bounding box calculation by mpWindow.
Reimplemented from mpLayer.
Definition at line 402 of file mathplot.h.
virtual void mpLayer::Plot | ( | wxDC & | dc, | |
mpWindow & | w | |||
) | [pure virtual, inherited] |
Plot given view of layer to the given device context. An implementation of this function has to transform layer coordinates to wxDC coordinates based on the view parameters retrievable from the mpWindow passed in w. The passed device context dc has its coordinate origin set to the center of the visible area. The coordinate orientation is as show in the following picture:
+--------------------------------------------------+ | | | | | (wxDC origin 0,0) | | x-------------> acending X | | | | | | | | V ascending Y | +--------------------------------------------------+
Note that Y ascends in downward direction, whereas the usual vertical orientation for mathematical plots is vice versa. Thus Y-orientation will be swapped usually, when transforming between wxDC and mpLayer coordinates.
Rules for transformation between mpLayer and wxDC coordinates
dc_X = (layer_X - mpWindow::GetPosX()) * mpWindow::GetScaleX() dc_Y = (mpWindow::GetPosY() - layer_Y) * mpWindow::GetScaleY() // swapping Y-orientation layer_X = (dc_X / mpWindow::GetScaleX()) + mpWindow::GetPosX() // scale guaranted to be not 0 layer_Y = mpWindow::GetPosY() - (dc_Y / mpWindow::GetScaleY()) // swapping Y-orientation
dc | Device context to plot to. | |
w | View to plot. The visible area can be retrieved from this object. |
Implemented in mpFX, mpFY, mpFXY, mpScaleX, pPlotterLayer, pPlotterScaleX, and pPlotterScaleY.
void mpScaleY::Plot | ( | wxDC & | dc, | |
mpWindow & | w, | |||
int | orgy | |||
) | [virtual] |
Layer plot handler. This implementation will plot the ruler adjusted to the visible area.
Definition at line 323 of file mathplot.cxx.
References mpWindow::GetPosX(), mpWindow::GetPosY(), mpWindow::GetScaleX(), mpWindow::GetScaleY(), mpWindow::GetScrY(), mpLayer::GetYTranslated(), mpLayer::m_font, mpLayer::m_name, mpLayer::m_pen, and mpLN10.
00324 { 00325 dc.SetPen( m_pen); 00326 dc.SetFont( m_font); 00327 00328 const int orgx = -(int)(w.GetPosX() * w.GetScaleX()); 00329 const int extend = w.GetScrY()/2; 00330 00331 double sizedc = dc.GetSize().GetHeight()-orgy; 00332 00333 dc.DrawLine( orgx, GetYTranslated(sizedc, -extend), orgx, GetYTranslated(sizedc, extend)); 00334 00335 const double dig = floor( log( 128.0 / w.GetScaleY() ) / mpLN10 ); 00336 const double step = exp( mpLN10 * dig); 00337 const double end = w.GetPosY() + (double)extend / w.GetScaleY(); 00338 00339 wxCoord tx, ty; 00340 wxString s; 00341 wxString fmt; 00342 int tmp = (int)dig; 00343 if (tmp>=1) 00344 { 00345 fmt = wxT("%.f"); 00346 } 00347 else 00348 { 00349 tmp=8-tmp; 00350 fmt.Printf(wxT("%%.%df"), tmp >= -1 ? 2 : -tmp); 00351 } 00352 00353 double n = floor( (w.GetPosY() - (double)extend / w.GetScaleY()) / step ) * step ; 00354 00355 tmp=65536; 00356 for (;n < end; n += step) 00357 { 00358 const int p = (int)((w.GetPosY() - n) * w.GetScaleY()); 00359 dc.DrawLine( orgx, GetYTranslated(sizedc, p), orgx+4, GetYTranslated(sizedc,p)); 00360 00361 s.Printf(fmt, n); 00362 dc.GetTextExtent(s, &tx, &ty); 00363 if ((tmp-p+ty/2) > 32) 00364 { 00365 dc.DrawText( s, orgx+4, GetYTranslated(sizedc,p-ty/2)); 00366 tmp=p-ty/2; 00367 } 00368 } 00369 00370 dc.GetTextExtent(m_name, &tx, &ty); 00371 dc.DrawText( m_name, orgx-tx-4, GetYTranslated(sizedc,-extend + ty + 4)); 00372 }
void mpLayer::SetFont | ( | wxFont & | font | ) | [inline, inherited] |
Set layer font
font | Font, will be copied to internal class member |
Definition at line 190 of file mathplot.h.
00190 { m_font = font; }
void mpLayer::SetName | ( | wxString | name | ) | [inline, inherited] |
Set layer name
name | Name, will be copied to internal class member |
Definition at line 185 of file mathplot.h.
00185 { m_name = name; }
void mpLayer::SetPen | ( | wxPen & | pen | ) | [inline, inherited] |
Set layer pen
pen | Pen, will be copied to internal class member |
Definition at line 195 of file mathplot.h.
Referenced by HistogramWidget::drawHistogram(), Histogram::drawHistogram(), HistogramWidget::drawTransferenceFunction(), pPlotterWindow::onChangeColor(), pPlotterWindow::onLoad(), and pPlotterWindow::onStartDrawing().
00195 { m_pen = pen; }
wxFont mpLayer::m_font [protected, inherited] |
Layer's font.
Definition at line 206 of file mathplot.h.
Referenced by pPlotterScaleY::Plot(), pPlotterScaleX::Plot(), Plot(), mpScaleX::Plot(), mpFXY::Plot(), mpFY::Plot(), and mpFX::Plot().
wxString mpLayer::m_name [protected, inherited] |
Layer's name.
Definition at line 208 of file mathplot.h.
Referenced by Plot(), mpScaleX::Plot(), mpFXY::Plot(), mpFY::Plot(), and mpFX::Plot().
wxPen mpLayer::m_pen [protected, inherited] |
Layer's pen.
Definition at line 207 of file mathplot.h.
Referenced by pPlotterScaleY::Plot(), pPlotterScaleX::Plot(), pPlotterLayer::Plot(), Plot(), mpScaleX::Plot(), mpFXY::Plot(), mpFY::Plot(), and mpFX::Plot().