#include <mathplot.h>
Public Member Functions | |
mpBitmapLayer () | |
virtual | ~mpBitmapLayer () |
void | GetBitmapCopy (wxImage &outBmp) const |
void | SetBitmap (const wxImage &inBmp, double x, double y, double lx, double ly) |
virtual bool | HasBBox () |
virtual double | GetMinX () |
virtual double | GetMaxX () |
virtual double | GetMinY () |
virtual double | GetMaxY () |
virtual void | Plot (wxDC &dc, mpWindow &w) |
void | SetAlign (int align) |
Protected Attributes | |
int | m_flags |
Holds label alignment. | |
wxImage | m_bitmap |
wxBitmap | m_scaledBitmap |
wxCoord | m_scaledBitmap_offset_x |
wxCoord | m_scaledBitmap_offset_y |
bool | m_validImg |
double | m_min_x |
double | m_max_x |
double | m_min_y |
double | m_max_y |
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation. The current transformation is set through SetCoordinateBase. To ease the implementation of descendent classes, mpMovableObject will be in charge of Bounding Box computation and layer render, assuming that the object updates its shape in m_shape_xs & m_shape_ys.
mpBitmapLayer::mpBitmapLayer | ( | ) | [inline] |
Default constructor.
References mpLAYER_BITMAP.
virtual mpBitmapLayer::~mpBitmapLayer | ( | ) | [inline, virtual] |
void mpBitmapLayer::GetBitmapCopy | ( | wxImage & | outBmp | ) | const |
Returns a copy of the current bitmap assigned to the layer.
References m_bitmap, and m_validImg.
virtual double mpBitmapLayer::GetMaxX | ( | ) | [inline, virtual] |
Get inclusive right border of bounding box.
Reimplemented from mpLayer.
virtual double mpBitmapLayer::GetMaxY | ( | ) | [inline, virtual] |
Get inclusive top border of bounding box.
Reimplemented from mpLayer.
virtual double mpBitmapLayer::GetMinX | ( | ) | [inline, virtual] |
Get inclusive left border of bounding box.
Reimplemented from mpLayer.
virtual double mpBitmapLayer::GetMinY | ( | ) | [inline, virtual] |
Get inclusive bottom border of bounding box.
Reimplemented from mpLayer.
virtual bool mpBitmapLayer::HasBBox | ( | ) | [inline, virtual] |
Check whether this layer has a bounding box. The default implementation returns TRUE. Override 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 from mpLayer.
Referenced by Plot().
void mpBitmapLayer::Plot | ( | wxDC & | dc, | |
mpWindow & | w | |||
) | [virtual] |
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. Note that the public methods of mpWindow: x2p,y2p and p2x,p2y are already provided which transform layer coordinates to DC pixel coordinates, and user code should rely on them for portability and future changes to be applied transparently, instead of implementing the following formulas manually.
The passed device context dc has its coordinate origin set to the top-left corner of the visible area (the default). The coordinate orientation is as shown in the following picture:
(wxDC origin 0,0) x-------------> ascending X ----------------+ | | | | V ascending Y | | | | | | | +-------------------------------------------+ <-- right-bottom corner of the mpWindow visible area.
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. This change of coordinates is taken into account in the methods p2x,p2y,x2p,y2p.
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 guaranteed 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. |
Implements mpLayer.
References mpWindow::GetPosX(), mpWindow::GetPosY(), mpWindow::GetScaleX(), mpWindow::GetScaleY(), mpWindow::GetScrX(), mpWindow::GetScrY(), HasBBox(), m_bitmap, m_flags, mpLayer::m_font, m_max_x, m_max_y, m_min_x, m_min_y, mpLayer::m_name, m_scaledBitmap, m_scaledBitmap_offset_x, m_scaledBitmap_offset_y, mpLayer::m_showName, m_validImg, mpLayer::m_visible, mpALIGN_NE, mpALIGN_NW, mpALIGN_SW, mpALIGNMASK, mpWindow::x2p(), and mpWindow::y2p().
void mpBitmapLayer::SetAlign | ( | int | align | ) | [inline] |
Set label axis alignment.
align | alignment (choose between mpALIGN_NE, mpALIGN_NW, mpALIGN_SW, mpALIGN_SE |
void mpBitmapLayer::SetBitmap | ( | const wxImage & | inBmp, | |
double | x, | |||
double | y, | |||
double | lx, | |||
double | ly | |||
) |
Change the bitmap associated with the layer (to update the screen, refresh the mpWindow).
inBmp | The bitmap to associate. A copy is made, thus it can be released after calling this. | |
x | The left corner X coordinate (in plot units). | |
y | The top corner Y coordinate (in plot units). | |
lx | The width in plot units. | |
ly | The height in plot units. |
References m_bitmap, m_max_x, m_max_y, m_min_x, m_min_y, and m_validImg.
wxImage mpBitmapLayer::m_bitmap [protected] |
The internal copy of the Bitmap:
Referenced by GetBitmapCopy(), Plot(), and SetBitmap().
int mpBitmapLayer::m_flags [protected] |
Holds label alignment.
Referenced by Plot().
double mpBitmapLayer::m_max_x [protected] |
Referenced by Plot(), and SetBitmap().
double mpBitmapLayer::m_max_y [protected] |
Referenced by Plot(), and SetBitmap().
double mpBitmapLayer::m_min_x [protected] |
The shape of the bitmap:
Referenced by Plot(), and SetBitmap().
double mpBitmapLayer::m_min_y [protected] |
Referenced by Plot(), and SetBitmap().
wxBitmap mpBitmapLayer::m_scaledBitmap [protected] |
Referenced by Plot().
wxCoord mpBitmapLayer::m_scaledBitmap_offset_x [protected] |
Referenced by Plot().
wxCoord mpBitmapLayer::m_scaledBitmap_offset_y [protected] |
Referenced by Plot().
bool mpBitmapLayer::m_validImg [protected] |
Referenced by GetBitmapCopy(), Plot(), and SetBitmap().