KiCad PCB EDA Suite
mpMovableObject Class Reference

This virtual class represents objects that can be moved to an arbitrary 2D location+rotation. More...

#include <mathplot.h>

Inheritance diagram for mpMovableObject:
mpLayer mpCovarianceEllipse mpPolygon

Public Member Functions

 mpMovableObject ()
 Default constructor (sets location and rotation to (0,0,0)) More...
 
virtual ~mpMovableObject ()
 
void GetCoordinateBase (double &x, double &y, double &phi) const
 Get the current coordinate transformation. More...
 
void SetCoordinateBase (double x, double y, double phi=0)
 Set the coordinate transformation (phi in radians, 0 means no rotation). More...
 
virtual bool HasBBox () override
 Check whether this layer has a bounding box. More...
 
virtual double GetMinX () override
 Get inclusive left border of bounding box. More...
 
virtual double GetMaxX () override
 Get inclusive right border of bounding box. More...
 
virtual double GetMinY () override
 Get inclusive bottom border of bounding box. More...
 
virtual double GetMaxY () override
 Get inclusive top border of bounding box. More...
 
virtual void Plot (wxDC &dc, mpWindow &w) override
 Plot given view of layer to the given device context. More...
 
void SetAlign (int align)
 Set label axis alignment. More...
 
virtual bool IsInfo ()
 Check whether the layer is an info box. More...
 
const wxString & GetName () const
 Get layer name. More...
 
const wxFont & GetFont () const
 Get font set for this layer. More...
 
const wxPen & GetPen () const
 Get pen set for this layer. More...
 
void SetContinuity (bool continuity)
 Set the 'continuity' property of the layer (true:draws a continuous line, false:draws separate points). More...
 
bool GetContinuity () const
 Gets the 'continuity' property of the layer. More...
 
void ShowName (bool show)
 Shows or hides the text label with the name of the layer (default is visible). More...
 
void SetName (wxString name)
 Set layer name. More...
 
void SetFont (wxFont &font)
 Set layer font. More...
 
void SetPen (wxPen pen)
 Set layer pen. More...
 
void SetDrawOutsideMargins (bool drawModeOutside)
 Set Draw mode: inside or outside margins. More...
 
bool GetDrawOutsideMargins ()
 Get Draw mode: inside or outside margins. More...
 
wxBitmap GetColourSquare (int side=16)
 Get a small square bitmap filled with the colour of the pen used in the layer. More...
 
mpLayerType GetLayerType ()
 Get layer type: a Layer can be of different types: plot lines, axis, info boxes, etc, this method returns the right value. More...
 
bool IsVisible ()
 Checks whether the layer is visible or not. More...
 
void SetVisible (bool show)
 Sets layer visibility. More...
 
const wxBrush & GetBrush () const
 Get brush set for this layer. More...
 
void SetBrush (wxBrush brush)
 Set layer brush. More...
 

Protected Member Functions

void TranslatePoint (double x, double y, double &out_x, double &out_y)
 A method for 2D translation and rotation, using the current transformation stored in m_reference_x,m_reference_y,m_reference_phi. More...
 
void ShapeUpdated ()
 Must be called by the descendent class after updating the shape (m_shape_xs/ys), or when the transformation changes. More...
 

Protected Attributes

int m_flags
 
double m_reference_x
 The coordinates of the object (orientation "phi" is in radians). More...
 
double m_reference_y
 
double m_reference_phi
 
std::vector< double > m_shape_xs
 This contains the object points, in local coordinates (to be transformed by the current transformation). More...
 
std::vector< double > m_shape_ys
 
std::vector< double > m_trans_shape_xs
 The buffer for the translated & rotated points (to avoid recomputing them with each mpWindow refresh). More...
 
std::vector< double > m_trans_shape_ys
 
double m_bbox_min_x
 The precomputed bounding box: More...
 
double m_bbox_max_x
 
double m_bbox_min_y
 
double m_bbox_max_y
 
wxFont m_font
 
wxPen m_pen
 
wxBrush m_brush
 
wxString m_name
 
bool m_continuous
 
bool m_showName
 
bool m_drawOutsideMargins
 
mpLayerType m_type
 
bool m_visible
 

Detailed Description

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 rendering, assuming that the object updates its shape in m_shape_xs & m_shape_ys.

Definition at line 1724 of file mathplot.h.

Constructor & Destructor Documentation

◆ mpMovableObject()

mpMovableObject::mpMovableObject ( )
inline

Default constructor (sets location and rotation to (0,0,0))

Definition at line 1729 of file mathplot.h.

1729  :
1730  m_reference_x( 0 ),
1731  m_reference_y( 0 ),
1732  m_reference_phi( 0 ),
1733  m_shape_xs( 0 ),
1734  m_shape_ys( 0 )
1735  {
1736  m_type = mpLAYER_PLOT;
1737  }
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:1791
double m_reference_y
Definition: mathplot.h:1791
std::vector< double > m_shape_ys
Definition: mathplot.h:1801
mpLayerType m_type
Definition: mathplot.h:322
double m_reference_phi
Definition: mathplot.h:1791
std::vector< double > m_shape_xs
This contains the object points, in local coordinates (to be transformed by the current transformatio...
Definition: mathplot.h:1801

References mpLAYER_PLOT.

◆ ~mpMovableObject()

virtual mpMovableObject::~mpMovableObject ( )
inlinevirtual

Definition at line 1739 of file mathplot.h.

1739 {};

Member Function Documentation

◆ GetBrush()

const wxBrush& mpLayer::GetBrush ( ) const
inlineinherited

Get brush set for this layer.

Returns
brush.

Definition at line 307 of file mathplot.h.

307 { return m_brush; };
wxBrush m_brush
Definition: mathplot.h:317

◆ GetColourSquare()

wxBitmap mpLayer::GetColourSquare ( int  side = 16)
inherited

Get a small square bitmap filled with the colour of the pen used in the layer.

Useful to create legends or similar reference to the layers.

Parameters
sideside length in pixels
Returns
a wxBitmap filled with layer's colour

Definition at line 83 of file mathplot.cpp.

84 {
85  wxBitmap square( side, side, -1 );
86  wxColour filler = m_pen.GetColour();
87  wxBrush brush( filler, wxBRUSHSTYLE_SOLID );
88  wxMemoryDC dc;
89 
90  dc.SelectObject( square );
91  dc.SetBackground( brush );
92  dc.Clear();
93  dc.SelectObject( wxNullBitmap );
94  return square;
95 }
double square(double x)
wxPen m_pen
Definition: mathplot.h:316

References mpLayer::m_pen, and square().

◆ GetContinuity()

bool mpLayer::GetContinuity ( ) const
inlineinherited

Gets the 'continuity' property of the layer.

See also
SetContinuity

Definition at line 259 of file mathplot.h.

259 { return m_continuous; }
bool m_continuous
Definition: mathplot.h:319

◆ GetCoordinateBase()

void mpMovableObject::GetCoordinateBase ( double &  x,
double &  y,
double &  phi 
) const
inline

Get the current coordinate transformation.

Definition at line 1743 of file mathplot.h.

1744  {
1745  x = m_reference_x;
1746  y = m_reference_y;
1747  phi = m_reference_phi;
1748  }
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:1791
double m_reference_y
Definition: mathplot.h:1791
double m_reference_phi
Definition: mathplot.h:1791

◆ GetDrawOutsideMargins()

bool mpLayer::GetDrawOutsideMargins ( )
inlineinherited

Get Draw mode: inside or outside margins.

Returns
The draw mode

Definition at line 286 of file mathplot.h.

286 { return m_drawOutsideMargins; };
bool m_drawOutsideMargins
Definition: mathplot.h:321

◆ GetFont()

const wxFont& mpLayer::GetFont ( ) const
inlineinherited

Get font set for this layer.

Returns
Font

Definition at line 244 of file mathplot.h.

244 { return m_font; }
wxFont m_font
Definition: mathplot.h:311

◆ GetLayerType()

mpLayerType mpLayer::GetLayerType ( )
inlineinherited

Get layer type: a Layer can be of different types: plot lines, axis, info boxes, etc, this method returns the right value.

Returns
An integer indicating layer type

Definition at line 295 of file mathplot.h.

295 { return m_type; };
mpLayerType m_type
Definition: mathplot.h:322

Referenced by mpInfoLegend::Plot().

◆ GetMaxX()

virtual double mpMovableObject::GetMaxX ( )
inlineoverridevirtual

Get inclusive right border of bounding box.

Reimplemented from mpLayer.

Definition at line 1769 of file mathplot.h.

1769 { return m_bbox_max_x; }
double m_bbox_max_x
Definition: mathplot.h:1811

◆ GetMaxY()

virtual double mpMovableObject::GetMaxY ( )
inlineoverridevirtual

Get inclusive top border of bounding box.

Reimplemented from mpLayer.

Definition at line 1777 of file mathplot.h.

1777 { return m_bbox_max_y; }
double m_bbox_max_y
Definition: mathplot.h:1811

◆ GetMinX()

virtual double mpMovableObject::GetMinX ( )
inlineoverridevirtual

Get inclusive left border of bounding box.

Reimplemented from mpLayer.

Definition at line 1765 of file mathplot.h.

1765 { return m_bbox_min_x; }
double m_bbox_min_x
The precomputed bounding box:
Definition: mathplot.h:1811

◆ GetMinY()

virtual double mpMovableObject::GetMinY ( )
inlineoverridevirtual

Get inclusive bottom border of bounding box.

Reimplemented from mpLayer.

Definition at line 1773 of file mathplot.h.

1773 { return m_bbox_min_y; }
double m_bbox_min_y
Definition: mathplot.h:1811

◆ GetName()

const wxString& mpLayer::GetName ( void  ) const
inlineinherited

Get layer name.

Returns
Name

Definition at line 239 of file mathplot.h.

239 { return m_name; }
wxString m_name
Definition: mathplot.h:318

Referenced by SIM_PLOT_PANEL::GetLabelX(), SIM_PLOT_PANEL::GetLabelY1(), SIM_PLOT_PANEL::GetLabelY2(), mpInfoLegend::Plot(), and mpText::Plot().

◆ GetPen()

const wxPen& mpLayer::GetPen ( ) const
inlineinherited

Get pen set for this layer.

Returns
Pen

Definition at line 249 of file mathplot.h.

249 { return m_pen; }
wxPen m_pen
Definition: mathplot.h:316

Referenced by mpInfoLegend::Plot().

◆ HasBBox()

virtual bool mpMovableObject::HasBBox ( )
inlineoverridevirtual

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.

Return values
TRUEHas bounding box
FALSEHas not bounding box

Reimplemented from mpLayer.

Definition at line 1761 of file mathplot.h.

1761 { return m_trans_shape_xs.size()!=0; }
std::vector< double > m_trans_shape_xs
The buffer for the translated & rotated points (to avoid recomputing them with each mpWindow refresh)...
Definition: mathplot.h:1806

Referenced by Plot().

◆ IsInfo()

virtual bool mpLayer::IsInfo ( )
inlinevirtualinherited

Check whether the layer is an info box.

The default implementation returns FALSE. It is overrided to TRUE for mpInfoLayer class and its derivative. It is necessary to define mouse actions behaviour over info boxes.

Returns
whether the layer is an info boxes
See also
mpInfoLayer::IsInfo

Reimplemented in mpInfoLayer.

Definition at line 171 of file mathplot.h.

171 { return false; };

◆ IsVisible()

bool mpLayer::IsVisible ( )
inlineinherited

Checks whether the layer is visible or not.

Returns
true if visible

Definition at line 299 of file mathplot.h.

299 { return m_visible; };
bool m_visible
Definition: mathplot.h:323

Referenced by mpWindow::IsLayerVisible(), SIM_PLOT_PANEL::IsLegendShown(), and mpInfoLegend::Plot().

◆ Plot()

void mpMovableObject::Plot ( wxDC &  dc,
mpWindow w 
)
overridevirtual

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
Parameters
dcDevice context to plot to.
wView to plot. The visible area can be retrieved from this object.
See also
mpWindow::p2x,mpWindow::p2y,mpWindow::x2p,mpWindow::y2p

Implements mpLayer.

Definition at line 3534 of file mathplot.cpp.

3535 {
3536  if( m_visible )
3537  {
3538  dc.SetPen( m_pen );
3539 
3540 
3541  std::vector<double>::iterator itX = m_trans_shape_xs.begin();
3542  std::vector<double>::iterator itY = m_trans_shape_ys.begin();
3543 
3544  if( !m_continuous )
3545  {
3546  // for some reason DrawPoint does not use the current pen,
3547  // so we use DrawLine for fat pens
3548  if( m_pen.GetWidth() <= 1 )
3549  {
3550  while( itX!=m_trans_shape_xs.end() )
3551  {
3552  dc.DrawPoint( w.x2p( *(itX++) ), w.y2p( *(itY++) ) );
3553  }
3554  }
3555  else
3556  {
3557  while( itX!=m_trans_shape_xs.end() )
3558  {
3559  wxCoord cx = w.x2p( *(itX++) );
3560  wxCoord cy = w.y2p( *(itY++) );
3561  dc.DrawLine( cx, cy, cx, cy );
3562  }
3563  }
3564  }
3565  else
3566  {
3567  wxCoord cx0 = 0, cy0 = 0;
3568  bool first = true;
3569 
3570  while( itX!=m_trans_shape_xs.end() )
3571  {
3572  wxCoord cx = w.x2p( *(itX++) );
3573  wxCoord cy = w.y2p( *(itY++) );
3574 
3575  if( first )
3576  {
3577  first = false;
3578  cx0 = cx; cy0 = cy;
3579  }
3580 
3581  dc.DrawLine( cx0, cy0, cx, cy );
3582  cx0 = cx; cy0 = cy;
3583  }
3584  }
3585 
3586  if( !m_name.IsEmpty() && m_showName )
3587  {
3588  dc.SetFont( m_font );
3589 
3590  wxCoord tx, ty;
3591  dc.GetTextExtent( m_name, &tx, &ty );
3592 
3593  if( HasBBox() )
3594  {
3595  wxCoord sx = (wxCoord) ( ( m_bbox_max_x - w.GetPosX() ) * w.GetScaleX() );
3596  wxCoord sy = (wxCoord) ( (w.GetPosY() - m_bbox_max_y ) * w.GetScaleY() );
3597 
3598  tx = sx - tx - 8;
3599  ty = sy - 8 - ty;
3600  }
3601  else
3602  {
3603  const int sx = w.GetScrX() >> 1;
3604  const int sy = w.GetScrY() >> 1;
3605 
3606  if( (m_flags & mpALIGNMASK) == mpALIGN_NE )
3607  {
3608  tx = sx - tx - 8;
3609  ty = -sy + 8;
3610  }
3611  else if( (m_flags & mpALIGNMASK) == mpALIGN_NW )
3612  {
3613  tx = -sx + 8;
3614  ty = -sy + 8;
3615  }
3616  else if( (m_flags & mpALIGNMASK) == mpALIGN_SW )
3617  {
3618  tx = -sx + 8;
3619  ty = sy - 8 - ty;
3620  }
3621  else
3622  {
3623  tx = sx - tx - 8;
3624  ty = sy - 8 - ty;
3625  }
3626  }
3627 
3628  dc.DrawText( m_name, tx, ty );
3629  }
3630  }
3631 }
bool m_continuous
Definition: mathplot.h:319
#define mpALIGN_NW
Aligns label to north-west.
Definition: mathplot.h:508
double GetPosY(void) const
Definition: mathplot.h:1127
double GetScaleX(void) const
Definition: mathplot.h:1106
std::vector< double > m_trans_shape_ys
Definition: mathplot.h:1806
double GetScaleY(void) const
Definition: mathplot.h:1113
double GetPosX(void) const
Definition: mathplot.h:1120
bool m_visible
Definition: mathplot.h:323
double m_bbox_max_y
Definition: mathplot.h:1811
wxCoord y2p(double y)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
Definition: mathplot.h:1204
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1761
int GetScrX(void) const
Get current view's X dimension in device context units.
Definition: mathplot.h:1135
wxFont m_font
Definition: mathplot.h:311
#define mpALIGN_NE
Aligns label to north-east.
Definition: mathplot.h:506
#define mpALIGNMASK
Definition: mathplot.h:476
bool m_showName
Definition: mathplot.h:320
wxCoord x2p(double x)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
Definition: mathplot.h:1199
wxPen m_pen
Definition: mathplot.h:316
std::vector< double > m_trans_shape_xs
The buffer for the translated & rotated points (to avoid recomputing them with each mpWindow refresh)...
Definition: mathplot.h:1806
wxString m_name
Definition: mathplot.h:318
double m_bbox_max_x
Definition: mathplot.h:1811
int GetScrY(void) const
Get current view's Y dimension in device context units.
Definition: mathplot.h:1144
#define mpALIGN_SW
Aligns label to south-west.
Definition: mathplot.h:510

References mpWindow::GetPosX(), mpWindow::GetPosY(), mpWindow::GetScaleX(), mpWindow::GetScaleY(), mpWindow::GetScrX(), mpWindow::GetScrY(), HasBBox(), m_bbox_max_x, m_bbox_max_y, mpLayer::m_continuous, m_flags, mpLayer::m_font, mpLayer::m_name, mpLayer::m_pen, mpLayer::m_showName, m_trans_shape_xs, m_trans_shape_ys, mpLayer::m_visible, mpALIGN_NE, mpALIGN_NW, mpALIGN_SW, mpALIGNMASK, mpWindow::x2p(), and mpWindow::y2p().

◆ SetAlign()

void mpMovableObject::SetAlign ( int  align)
inline

Set label axis alignment.

Parameters
alignalignment (choose between mpALIGN_NE, mpALIGN_NW, mpALIGN_SW, mpALIGN_SE

Definition at line 1784 of file mathplot.h.

1784 { m_flags = align; };

◆ SetBrush()

void mpLayer::SetBrush ( wxBrush  brush)
inlineinherited

Set layer brush.

Parameters
brushbrush, will be copied to internal class member

Definition at line 311 of file mathplot.h.

311 { m_brush = brush; };
wxBrush m_brush
Definition: mathplot.h:317

◆ SetContinuity()

void mpLayer::SetContinuity ( bool  continuity)
inlineinherited

Set the 'continuity' property of the layer (true:draws a continuous line, false:draws separate points).

See also
GetContinuity

Definition at line 254 of file mathplot.h.

254 { m_continuous = continuity; }
bool m_continuous
Definition: mathplot.h:319

Referenced by TRACE::TRACE().

◆ SetCoordinateBase()

void mpMovableObject::SetCoordinateBase ( double  x,
double  y,
double  phi = 0 
)
inline

Set the coordinate transformation (phi in radians, 0 means no rotation).

Definition at line 1752 of file mathplot.h.

1753  {
1754  m_reference_x = x;
1755  m_reference_y = y;
1756  m_reference_phi = phi;
1757  m_flags = mpALIGN_NE;
1758  ShapeUpdated();
1759  }
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:1791
void ShapeUpdated()
Must be called by the descendent class after updating the shape (m_shape_xs/ys), or when the transfor...
Definition: mathplot.cpp:3488
double m_reference_y
Definition: mathplot.h:1791
#define mpALIGN_NE
Aligns label to north-east.
Definition: mathplot.h:506
double m_reference_phi
Definition: mathplot.h:1791

References mpALIGN_NE.

◆ SetDrawOutsideMargins()

void mpLayer::SetDrawOutsideMargins ( bool  drawModeOutside)
inlineinherited

Set Draw mode: inside or outside margins.

Default is outside, which allows the layer to draw up to the mpWindow border.

Parameters
drawModeOutsideThe draw mode to be set

Definition at line 282 of file mathplot.h.

282 { m_drawOutsideMargins = drawModeOutside; };
bool m_drawOutsideMargins
Definition: mathplot.h:321

Referenced by CURSOR::CURSOR(), and TRACE::TRACE().

◆ SetFont()

void mpLayer::SetFont ( wxFont &  font)
inlineinherited

Set layer font.

Parameters
fontFont, will be copied to internal class member

Definition at line 273 of file mathplot.h.

273 { m_font = font; }
wxFont m_font
Definition: mathplot.h:311

◆ SetName()

void mpLayer::SetName ( wxString  name)
inlineinherited

Set layer name.

Parameters
nameName, will be copied to internal class member

Definition at line 268 of file mathplot.h.

268 { m_name = name; }
const char * name
Definition: DXF_plotter.cpp:59
wxString m_name
Definition: mathplot.h:318

References name.

◆ SetPen()

void mpLayer::SetPen ( wxPen  pen)
inlineinherited

Set layer pen.

Parameters
penPen, will be copied to internal class member

Definition at line 278 of file mathplot.h.

278 { m_pen = pen; }
wxPen m_pen
Definition: mathplot.h:316

Referenced by SIM_PLOT_PANEL::UpdateTraceStyle().

◆ SetVisible()

void mpLayer::SetVisible ( bool  show)
inlineinherited

Sets layer visibility.

Parameters
showvisibility bool.

Definition at line 303 of file mathplot.h.

303 { m_visible = show; };
bool m_visible
Definition: mathplot.h:323

Referenced by mpWindow::SetLayerVisible(), SIM_PLOT_PANEL::ShowLegend(), and SIM_PLOT_PANEL::SIM_PLOT_PANEL().

◆ ShapeUpdated()

void mpMovableObject::ShapeUpdated ( )
protected

Must be called by the descendent class after updating the shape (m_shape_xs/ys), or when the transformation changes.

This method updates the buffers m_trans_shape_xs/ys, and the precomputed bounding box.

Definition at line 3488 of file mathplot.cpp.

3489 {
3490  // Just in case...
3491  if( m_shape_xs.size()!=m_shape_ys.size() )
3492  {
3493  }
3494  else
3495  {
3496  double ccos = cos( m_reference_phi ); // Avoid computing cos/sin twice.
3497  double csin = sin( m_reference_phi );
3498 
3499  m_trans_shape_xs.resize( m_shape_xs.size() );
3500  m_trans_shape_ys.resize( m_shape_xs.size() );
3501 
3502  std::vector<double>::iterator itXi, itXo;
3503  std::vector<double>::iterator itYi, itYo;
3504 
3505  m_bbox_min_x = 1e300;
3506  m_bbox_max_x = -1e300;
3507  m_bbox_min_y = 1e300;
3508  m_bbox_max_y = -1e300;
3509 
3510  for( itXo = m_trans_shape_xs.begin(),
3511  itYo = m_trans_shape_ys.begin(), itXi = m_shape_xs.begin(), itYi = m_shape_ys.begin();
3512  itXo!=m_trans_shape_xs.end(); itXo++, itYo++, itXi++, itYi++ )
3513  {
3514  *itXo = m_reference_x + ccos * (*itXi) - csin * (*itYi);
3515  *itYo = m_reference_y + csin * (*itXi) + ccos * (*itYi);
3516 
3517  // Keep BBox:
3518  if( *itXo < m_bbox_min_x )
3519  m_bbox_min_x = *itXo;
3520 
3521  if( *itXo > m_bbox_max_x )
3522  m_bbox_max_x = *itXo;
3523 
3524  if( *itYo < m_bbox_min_y )
3525  m_bbox_min_y = *itYo;
3526 
3527  if( *itYo > m_bbox_max_y )
3528  m_bbox_max_y = *itYo;
3529  }
3530  }
3531 }
std::vector< double > m_trans_shape_ys
Definition: mathplot.h:1806
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:1791
double m_bbox_max_y
Definition: mathplot.h:1811
double m_bbox_min_x
The precomputed bounding box:
Definition: mathplot.h:1811
double m_reference_y
Definition: mathplot.h:1791
std::vector< double > m_shape_ys
Definition: mathplot.h:1801
std::vector< double > m_trans_shape_xs
The buffer for the translated & rotated points (to avoid recomputing them with each mpWindow refresh)...
Definition: mathplot.h:1806
double m_reference_phi
Definition: mathplot.h:1791
double m_bbox_max_x
Definition: mathplot.h:1811
std::vector< double > m_shape_xs
This contains the object points, in local coordinates (to be transformed by the current transformatio...
Definition: mathplot.h:1801
double m_bbox_min_y
Definition: mathplot.h:1811

References m_bbox_max_x, m_bbox_max_y, m_bbox_min_x, m_bbox_min_y, m_reference_phi, m_reference_x, m_reference_y, m_shape_xs, m_shape_ys, m_trans_shape_xs, and m_trans_shape_ys.

Referenced by mpCovarianceEllipse::RecalculateShape(), and mpPolygon::setPoints().

◆ ShowName()

void mpLayer::ShowName ( bool  show)
inlineinherited

Shows or hides the text label with the name of the layer (default is visible).

Definition at line 263 of file mathplot.h.

263 { m_showName = show; };
bool m_showName
Definition: mathplot.h:320

Referenced by TRACE::TRACE().

◆ TranslatePoint()

void mpMovableObject::TranslatePoint ( double  x,
double  y,
double &  out_x,
double &  out_y 
)
protected

A method for 2D translation and rotation, using the current transformation stored in m_reference_x,m_reference_y,m_reference_phi.

Definition at line 3477 of file mathplot.cpp.

3478 {
3479  double ccos = cos( m_reference_phi ); // Avoid computing cos/sin twice.
3480  double csin = sin( m_reference_phi );
3481 
3482  out_x = m_reference_x + ccos * x - csin * y;
3483  out_y = m_reference_y + csin * x + ccos * y;
3484 }
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:1791
double m_reference_y
Definition: mathplot.h:1791
double m_reference_phi
Definition: mathplot.h:1791

References m_reference_phi, m_reference_x, and m_reference_y.

Member Data Documentation

◆ m_bbox_max_x

double mpMovableObject::m_bbox_max_x
protected

Definition at line 1811 of file mathplot.h.

Referenced by Plot(), and ShapeUpdated().

◆ m_bbox_max_y

double mpMovableObject::m_bbox_max_y
protected

Definition at line 1811 of file mathplot.h.

Referenced by Plot(), and ShapeUpdated().

◆ m_bbox_min_x

double mpMovableObject::m_bbox_min_x
protected

The precomputed bounding box:

See also
ShapeUpdated

Definition at line 1811 of file mathplot.h.

Referenced by ShapeUpdated().

◆ m_bbox_min_y

double mpMovableObject::m_bbox_min_y
protected

Definition at line 1811 of file mathplot.h.

Referenced by ShapeUpdated().

◆ m_brush

wxBrush mpLayer::m_brush
protectedinherited

Definition at line 317 of file mathplot.h.

◆ m_continuous

bool mpLayer::m_continuous
protectedinherited

Definition at line 319 of file mathplot.h.

Referenced by CURSOR::Plot(), mpFXY::Plot(), and Plot().

◆ m_drawOutsideMargins

◆ m_flags

int mpMovableObject::m_flags
protected

Definition at line 1784 of file mathplot.h.

Referenced by Plot().

◆ m_font

◆ m_name

wxString mpLayer::m_name
protectedinherited

◆ m_pen

◆ m_reference_phi

double mpMovableObject::m_reference_phi
protected

Definition at line 1791 of file mathplot.h.

Referenced by ShapeUpdated(), and TranslatePoint().

◆ m_reference_x

double mpMovableObject::m_reference_x
protected

The coordinates of the object (orientation "phi" is in radians).

Definition at line 1791 of file mathplot.h.

Referenced by ShapeUpdated(), and TranslatePoint().

◆ m_reference_y

double mpMovableObject::m_reference_y
protected

Definition at line 1791 of file mathplot.h.

Referenced by ShapeUpdated(), and TranslatePoint().

◆ m_shape_xs

std::vector<double> mpMovableObject::m_shape_xs
protected

This contains the object points, in local coordinates (to be transformed by the current transformation).

Definition at line 1801 of file mathplot.h.

Referenced by mpCovarianceEllipse::RecalculateShape(), mpPolygon::setPoints(), and ShapeUpdated().

◆ m_shape_ys

std::vector<double> mpMovableObject::m_shape_ys
protected

◆ m_showName

bool mpLayer::m_showName
protectedinherited

Definition at line 320 of file mathplot.h.

Referenced by mpFX::Plot(), mpFY::Plot(), mpFXY::Plot(), Plot(), and mpBitmapLayer::Plot().

◆ m_trans_shape_xs

std::vector<double> mpMovableObject::m_trans_shape_xs
protected

The buffer for the translated & rotated points (to avoid recomputing them with each mpWindow refresh).

Definition at line 1806 of file mathplot.h.

Referenced by Plot(), and ShapeUpdated().

◆ m_trans_shape_ys

std::vector<double> mpMovableObject::m_trans_shape_ys
protected

Definition at line 1806 of file mathplot.h.

Referenced by Plot(), and ShapeUpdated().

◆ m_type

mpLayerType mpLayer::m_type
protectedinherited

Definition at line 322 of file mathplot.h.

Referenced by mpInfoLayer::mpInfoLayer().

◆ m_visible


The documentation for this class was generated from the following files: