#include <mathplot.h>
Public Member Functions | |
mpFX (wxString name=wxEmptyString, int flags=0x00) | |
virtual double | GetY (double x)=0 |
virtual void | Plot (wxDC &dc, mpWindow &w) |
virtual bool | HasBBox () |
virtual double | GetMinX () |
virtual double | GetMaxX () |
virtual double | GetMinY () |
virtual double | GetMaxY () |
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 | |
int | m_flags |
Holds label alignment. | |
wxFont | m_font |
Layer's font. | |
wxPen | m_pen |
Layer's pen. | |
wxString | m_name |
Layer's name. |
Abstract base class providing plot and labeling functionality for functions F:X->Y. Override mpFX::GetY to implement a function. Optionally implement a constructor and pass a name (label) and a label alignment to the constructor mpFX::mpFX. If the layer name is empty, no label will be plotted.
Definition at line 251 of file mathplot.h.
mpFX::mpFX | ( | wxString | name = wxEmptyString , |
|
int | flags = 0x00 | |||
) |
name | Label | |
flags | Label alignment, pass one of mpALIGN_RIGHT, mpALIGN_CENTER, mpALIGN_LEFT. |
Definition at line 72 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; }
virtual double mpFX::GetY | ( | double | x | ) | [pure virtual] |
Get function value for argument. Override this function in your implementation.
x | Argument |
Referenced by Plot().
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 mpScaleY::Plot().
virtual bool mpLayer::HasBBox | ( | ) | [inline, virtual, inherited] |
Check whether this layer has a bounding box. The default implementation returns TRUE. Overide and return FALSE if your mpLayer implementation should be ignored by the calculation of the global bounding box for all layers in a mpWindow.
TRUE | Has bounding box | |
FALSE | Has not bounding box |
Reimplemented in mpScaleX, mpScaleY, pPlotterScaleX, and pPlotterScaleY.
Definition at line 110 of file mathplot.h.
Referenced by mpWindow::UpdateBBox().
void mpFX::Plot | ( | wxDC & | dc, | |
mpWindow & | w | |||
) | [virtual] |
Layer plot handler. This implementation will plot the function in the visible area and put a label according to the aligment specified.
Implements mpLayer.
Definition at line 78 of file mathplot.cxx.
References mpWindow::GetPosX(), mpWindow::GetPosY(), mpWindow::GetScaleX(), mpWindow::GetScaleY(), mpWindow::GetScrX(), GetY(), m_flags, mpLayer::m_font, mpLayer::m_name, mpLayer::m_pen, mpALIGN_CENTER, mpALIGN_RIGHT, and mpALIGNMASK.
00079 { 00080 dc.SetPen( m_pen); 00081 00082 if (m_pen.GetWidth() <= 1) 00083 { 00084 for (wxCoord i = -(w.GetScrX()>>1); i < (w.GetScrX()>>1); ++i) 00085 { 00086 dc.DrawPoint(i, (wxCoord) ((w.GetPosY() - GetY( (double)i / w.GetScaleX() + w.GetPosX()) ) * w.GetScaleY())); 00087 } 00088 } 00089 else 00090 { 00091 for (wxCoord i = -(w.GetScrX()>>1); i < (w.GetScrX()>>1); ++i) 00092 { 00093 wxCoord c = (wxCoord) ((w.GetPosY() - GetY( (double)i / w.GetScaleX() + w.GetPosX()) ) * w.GetScaleY()); 00094 dc.DrawLine( i, c, i, c); 00095 } 00096 } 00097 00098 if (!m_name.IsEmpty()) 00099 { 00100 dc.SetFont(m_font); 00101 00102 wxCoord tx, ty; 00103 dc.GetTextExtent(m_name, &tx, &ty); 00104 00105 if ((m_flags & mpALIGNMASK) == mpALIGN_RIGHT) 00106 tx = (w.GetScrX()>>1) - tx - 8; 00107 else if ((m_flags & mpALIGNMASK) == mpALIGN_CENTER) 00108 tx = -tx/2; 00109 else 00110 tx = -(w.GetScrX()>>1) + 8; 00111 00112 dc.DrawText( m_name, tx, (wxCoord) ((w.GetPosY() - GetY( (double)tx / w.GetScaleX() + w.GetPosX())) * w.GetScaleY()) ); 00113 } 00114 }
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; }
int mpFX::m_flags [protected] |
wxFont mpLayer::m_font [protected, inherited] |
Layer's font.
Definition at line 206 of file mathplot.h.
Referenced by pPlotterScaleY::Plot(), pPlotterScaleX::Plot(), mpScaleY::Plot(), mpScaleX::Plot(), mpFXY::Plot(), mpFY::Plot(), and Plot().
wxString mpLayer::m_name [protected, inherited] |
Layer's name.
Definition at line 208 of file mathplot.h.
Referenced by mpScaleY::Plot(), mpScaleX::Plot(), mpFXY::Plot(), mpFY::Plot(), and 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(), mpScaleY::Plot(), mpScaleX::Plot(), mpFXY::Plot(), mpFY::Plot(), and Plot().