KiCad PCB EDA Suite
mpPolygon Class Reference

An arbitrary polygon, descendant of mpMovableObject. More...

#include <mathplot.h>

Inheritance diagram for mpPolygon:
mpMovableObject mpLayer

Public Member Functions

 mpPolygon (const wxString &layerName=wxT(""))
 Default constructor. More...
 
virtual ~mpPolygon ()
 
void setPoints (const std::vector< double > &points_xs, const std::vector< double > &points_ys, bool closedShape=true)
 Set the points in the polygon. More...
 
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

An arbitrary polygon, descendant of mpMovableObject.

Use "setPoints" to set the list of N points. This class also can draw non-closed polygons by passing the appropriate parameters to "setPoints". To draw a point-cloud, call "SetContinuity(false)".

Definition at line 1887 of file mathplot.h.

Constructor & Destructor Documentation

◆ mpPolygon()

mpPolygon::mpPolygon ( const wxString &  layerName = wxT(""))
inline

Default constructor.

Definition at line 1892 of file mathplot.h.

1893  {
1894  m_continuous = true;
1895  m_name = layerName;
1896  }
bool m_continuous
Definition: mathplot.h:317
wxString m_name
Definition: mathplot.h:316

◆ ~mpPolygon()

virtual mpPolygon::~mpPolygon ( )
inlinevirtual

Definition at line 1898 of file mathplot.h.

1898 {}

Member Function Documentation

◆ GetBrush()

const wxBrush& mpLayer::GetBrush ( ) const
inlineinherited

Get brush set for this layer.

Returns
brush.

Definition at line 305 of file mathplot.h.

305 { return m_brush; };
wxBrush m_brush
Definition: mathplot.h:315

◆ 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 }
wxPen m_pen
Definition: mathplot.h:314

References mpLayer::m_pen.

◆ GetContinuity()

bool mpLayer::GetContinuity ( ) const
inlineinherited

Gets the 'continuity' property of the layer.

See also
SetContinuity

Definition at line 257 of file mathplot.h.

257 { return m_continuous; }
bool m_continuous
Definition: mathplot.h:317

◆ GetCoordinateBase()

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

Get the current coordinate transformation.

Definition at line 1716 of file mathplot.h.

1717  {
1718  x = m_reference_x;
1719  y = m_reference_y;
1720  phi = m_reference_phi;
1721  }
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:1764
double m_reference_y
Definition: mathplot.h:1764
double m_reference_phi
Definition: mathplot.h:1764

◆ GetDrawOutsideMargins()

bool mpLayer::GetDrawOutsideMargins ( )
inlineinherited

Get Draw mode: inside or outside margins.

Returns
The draw mode

Definition at line 284 of file mathplot.h.

284 { return m_drawOutsideMargins; };
bool m_drawOutsideMargins
Definition: mathplot.h:319

◆ GetFont()

const wxFont& mpLayer::GetFont ( ) const
inlineinherited

Get font set for this layer.

Returns
Font

Definition at line 242 of file mathplot.h.

242 { return m_font; }
wxFont m_font
Definition: mathplot.h:309

◆ 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 293 of file mathplot.h.

293 { return m_type; };
mpLayerType m_type
Definition: mathplot.h:320

Referenced by mpInfoLegend::Plot().

◆ GetMaxX()

virtual double mpMovableObject::GetMaxX ( )
inlineoverridevirtualinherited

Get inclusive right border of bounding box.

Reimplemented from mpLayer.

Definition at line 1742 of file mathplot.h.

1742 { return m_bbox_max_x; }
double m_bbox_max_x
Definition: mathplot.h:1784

◆ GetMaxY()

virtual double mpMovableObject::GetMaxY ( )
inlineoverridevirtualinherited

Get inclusive top border of bounding box.

Reimplemented from mpLayer.

Definition at line 1750 of file mathplot.h.

1750 { return m_bbox_max_y; }
double m_bbox_max_y
Definition: mathplot.h:1784

◆ GetMinX()

virtual double mpMovableObject::GetMinX ( )
inlineoverridevirtualinherited

Get inclusive left border of bounding box.

Reimplemented from mpLayer.

Definition at line 1738 of file mathplot.h.

1738 { return m_bbox_min_x; }
double m_bbox_min_x
The precomputed bounding box:
Definition: mathplot.h:1784

◆ GetMinY()

virtual double mpMovableObject::GetMinY ( )
inlineoverridevirtualinherited

Get inclusive bottom border of bounding box.

Reimplemented from mpLayer.

Definition at line 1746 of file mathplot.h.

1746 { return m_bbox_min_y; }
double m_bbox_min_y
Definition: mathplot.h:1784

◆ GetName()

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

Get layer name.

Returns
Name

Definition at line 237 of file mathplot.h.

237 { return m_name; }
wxString m_name
Definition: mathplot.h:316

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 247 of file mathplot.h.

247 { return m_pen; }
wxPen m_pen
Definition: mathplot.h:314

Referenced by mpInfoLegend::Plot().

◆ HasBBox()

virtual bool mpMovableObject::HasBBox ( )
inlineoverridevirtualinherited

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 1734 of file mathplot.h.

1734 { 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:1779

Referenced by mpMovableObject::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 169 of file mathplot.h.

169 { return false; };

◆ IsVisible()

bool mpLayer::IsVisible ( )
inlineinherited

Checks whether the layer is visible or not.

Returns
true if visible

Definition at line 297 of file mathplot.h.

297 { return m_visible; };
bool m_visible
Definition: mathplot.h:321

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

◆ Plot()

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

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 3613 of file mathplot.cpp.

3614 {
3615  if( m_visible )
3616  {
3617  dc.SetPen( m_pen );
3618 
3619 
3620  std::vector<double>::iterator itX = m_trans_shape_xs.begin();
3621  std::vector<double>::iterator itY = m_trans_shape_ys.begin();
3622 
3623  if( !m_continuous )
3624  {
3625  // for some reason DrawPoint does not use the current pen,
3626  // so we use DrawLine for fat pens
3627  if( m_pen.GetWidth() <= 1 )
3628  {
3629  while( itX!=m_trans_shape_xs.end() )
3630  {
3631  dc.DrawPoint( w.x2p( *(itX++) ), w.y2p( *(itY++) ) );
3632  }
3633  }
3634  else
3635  {
3636  while( itX!=m_trans_shape_xs.end() )
3637  {
3638  wxCoord cx = w.x2p( *(itX++) );
3639  wxCoord cy = w.y2p( *(itY++) );
3640  dc.DrawLine( cx, cy, cx, cy );
3641  }
3642  }
3643  }
3644  else
3645  {
3646  wxCoord cx0 = 0, cy0 = 0;
3647  bool first = true;
3648 
3649  while( itX!=m_trans_shape_xs.end() )
3650  {
3651  wxCoord cx = w.x2p( *(itX++) );
3652  wxCoord cy = w.y2p( *(itY++) );
3653 
3654  if( first )
3655  {
3656  first = false;
3657  cx0 = cx; cy0 = cy;
3658  }
3659 
3660  dc.DrawLine( cx0, cy0, cx, cy );
3661  cx0 = cx; cy0 = cy;
3662  }
3663  }
3664 
3665  if( !m_name.IsEmpty() && m_showName )
3666  {
3667  dc.SetFont( m_font );
3668 
3669  wxCoord tx, ty;
3670  dc.GetTextExtent( m_name, &tx, &ty );
3671 
3672  if( HasBBox() )
3673  {
3674  wxCoord sx = (wxCoord) ( ( m_bbox_max_x - w.GetPosX() ) * w.GetScaleX() );
3675  wxCoord sy = (wxCoord) ( (w.GetPosY() - m_bbox_max_y ) * w.GetScaleY() );
3676 
3677  tx = sx - tx - 8;
3678  ty = sy - 8 - ty;
3679  }
3680  else
3681  {
3682  const int sx = w.GetScrX() >> 1;
3683  const int sy = w.GetScrY() >> 1;
3684 
3685  if( (m_flags & mpALIGNMASK) == mpALIGN_NE )
3686  {
3687  tx = sx - tx - 8;
3688  ty = -sy + 8;
3689  }
3690  else if( (m_flags & mpALIGNMASK) == mpALIGN_NW )
3691  {
3692  tx = -sx + 8;
3693  ty = -sy + 8;
3694  }
3695  else if( (m_flags & mpALIGNMASK) == mpALIGN_SW )
3696  {
3697  tx = -sx + 8;
3698  ty = sy - 8 - ty;
3699  }
3700  else
3701  {
3702  tx = sx - tx - 8;
3703  ty = sy - 8 - ty;
3704  }
3705  }
3706 
3707  dc.DrawText( m_name, tx, ty );
3708  }
3709  }
3710 }
bool m_continuous
Definition: mathplot.h:317
#define mpALIGN_NW
Aligns label to north-west.
Definition: mathplot.h:506
double GetPosY(void) const
Definition: mathplot.h:1123
double GetScaleX(void) const
Definition: mathplot.h:1102
std::vector< double > m_trans_shape_ys
Definition: mathplot.h:1779
double GetScaleY(void) const
Definition: mathplot.h:1109
double GetPosX(void) const
Definition: mathplot.h:1116
bool m_visible
Definition: mathplot.h:321
double m_bbox_max_y
Definition: mathplot.h:1784
wxCoord y2p(double y)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
Definition: mathplot.h:1200
virtual bool HasBBox() override
Check whether this layer has a bounding box.
Definition: mathplot.h:1734
int GetScrX(void) const
Get current view's X dimension in device context units.
Definition: mathplot.h:1131
wxFont m_font
Definition: mathplot.h:309
#define mpALIGN_NE
Aligns label to north-east.
Definition: mathplot.h:504
#define mpALIGNMASK
Definition: mathplot.h:474
bool m_showName
Definition: mathplot.h:318
wxCoord x2p(double x)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
Definition: mathplot.h:1195
wxPen m_pen
Definition: mathplot.h:314
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:1779
wxString m_name
Definition: mathplot.h:316
double m_bbox_max_x
Definition: mathplot.h:1784
int GetScrY(void) const
Get current view's Y dimension in device context units.
Definition: mathplot.h:1140
#define mpALIGN_SW
Aligns label to south-west.
Definition: mathplot.h:508

References mpWindow::GetPosX(), mpWindow::GetPosY(), mpWindow::GetScaleX(), mpWindow::GetScaleY(), mpWindow::GetScrX(), mpWindow::GetScrY(), mpMovableObject::HasBBox(), mpMovableObject::m_bbox_max_x, mpMovableObject::m_bbox_max_y, mpLayer::m_continuous, mpMovableObject::m_flags, mpLayer::m_font, mpLayer::m_name, mpLayer::m_pen, mpLayer::m_showName, mpMovableObject::m_trans_shape_xs, mpMovableObject::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)
inlineinherited

Set label axis alignment.

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

Definition at line 1757 of file mathplot.h.

1757 { 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 309 of file mathplot.h.

309 { m_brush = brush; };
wxBrush m_brush
Definition: mathplot.h:315

◆ 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 252 of file mathplot.h.

252 { m_continuous = continuity; }
bool m_continuous
Definition: mathplot.h:317

Referenced by TRACE::TRACE().

◆ SetCoordinateBase()

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

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

Definition at line 1725 of file mathplot.h.

1726  {
1727  m_reference_x = x;
1728  m_reference_y = y;
1729  m_reference_phi = phi;
1730  m_flags = mpALIGN_NE;
1731  ShapeUpdated();
1732  }
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:1764
void ShapeUpdated()
Must be called by the descendent class after updating the shape (m_shape_xs/ys), or when the transfor...
Definition: mathplot.cpp:3565
double m_reference_y
Definition: mathplot.h:1764
#define mpALIGN_NE
Aligns label to north-east.
Definition: mathplot.h:504
double m_reference_phi
Definition: mathplot.h:1764

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 280 of file mathplot.h.

280 { m_drawOutsideMargins = drawModeOutside; };
bool m_drawOutsideMargins
Definition: mathplot.h:319

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 271 of file mathplot.h.

271 { m_font = font; }
wxFont m_font
Definition: mathplot.h:309

◆ SetName()

void mpLayer::SetName ( wxString  name)
inlineinherited

Set layer name.

Parameters
nameName, will be copied to internal class member

Definition at line 266 of file mathplot.h.

266 { m_name = name; }
const char * name
Definition: DXF_plotter.cpp:61
wxString m_name
Definition: mathplot.h:316

References name.

◆ SetPen()

void mpLayer::SetPen ( wxPen  pen)
inlineinherited

Set layer pen.

Parameters
penPen, will be copied to internal class member

Definition at line 276 of file mathplot.h.

276 { m_pen = pen; }
wxPen m_pen
Definition: mathplot.h:314

◆ setPoints()

void mpPolygon::setPoints ( const std::vector< double > &  points_xs,
const std::vector< double > &  points_ys,
bool  closedShape = true 
)

Set the points in the polygon.

Parameters
points_xsThe X coordinates of the points.
points_ysThe Y coordinates of the points.
closedShapeIf set to true, an additional segment will be added from the last to the first point.

Definition at line 3830 of file mathplot.cpp.

3833 {
3834  if( points_xs.size()!=points_ys.size() )
3835  {
3836  wxLogError( wxT(
3837  "[mpPolygon] Error: points_xs and points_ys must have the same number of elements" ) );
3838  }
3839  else
3840  {
3841  m_shape_xs = points_xs;
3842  m_shape_ys = points_ys;
3843 
3844  if( closedShape && points_xs.size() )
3845  {
3846  m_shape_xs.push_back( points_xs[0] );
3847  m_shape_ys.push_back( points_ys[0] );
3848  }
3849 
3850  ShapeUpdated();
3851  }
3852 }
void ShapeUpdated()
Must be called by the descendent class after updating the shape (m_shape_xs/ys), or when the transfor...
Definition: mathplot.cpp:3565
std::vector< double > m_shape_ys
Definition: mathplot.h:1774
std::vector< double > m_shape_xs
This contains the object points, in local coordinates (to be transformed by the current transformatio...
Definition: mathplot.h:1774

References mpMovableObject::m_shape_xs, mpMovableObject::m_shape_ys, and mpMovableObject::ShapeUpdated().

◆ SetVisible()

void mpLayer::SetVisible ( bool  show)
inlineinherited

Sets layer visibility.

Parameters
showvisibility bool.

Definition at line 301 of file mathplot.h.

301 { m_visible = show; };
bool m_visible
Definition: mathplot.h:321

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

◆ ShapeUpdated()

void mpMovableObject::ShapeUpdated ( )
protectedinherited

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 3565 of file mathplot.cpp.

3566 {
3567  // Just in case...
3568  if( m_shape_xs.size()!=m_shape_ys.size() )
3569  {
3570  wxLogError( wxT(
3571  "[mpMovableObject::ShapeUpdated] Error, m_shape_xs and m_shape_ys have different lengths!" ) );
3572  }
3573  else
3574  {
3575  double ccos = cos( m_reference_phi ); // Avoid computing cos/sin twice.
3576  double csin = sin( m_reference_phi );
3577 
3578  m_trans_shape_xs.resize( m_shape_xs.size() );
3579  m_trans_shape_ys.resize( m_shape_xs.size() );
3580 
3581  std::vector<double>::iterator itXi, itXo;
3582  std::vector<double>::iterator itYi, itYo;
3583 
3584  m_bbox_min_x = 1e300;
3585  m_bbox_max_x = -1e300;
3586  m_bbox_min_y = 1e300;
3587  m_bbox_max_y = -1e300;
3588 
3589  for( itXo = m_trans_shape_xs.begin(),
3590  itYo = m_trans_shape_ys.begin(), itXi = m_shape_xs.begin(), itYi = m_shape_ys.begin();
3591  itXo!=m_trans_shape_xs.end(); itXo++, itYo++, itXi++, itYi++ )
3592  {
3593  *itXo = m_reference_x + ccos * (*itXi) - csin * (*itYi);
3594  *itYo = m_reference_y + csin * (*itXi) + ccos * (*itYi);
3595 
3596  // Keep BBox:
3597  if( *itXo < m_bbox_min_x )
3598  m_bbox_min_x = *itXo;
3599 
3600  if( *itXo > m_bbox_max_x )
3601  m_bbox_max_x = *itXo;
3602 
3603  if( *itYo < m_bbox_min_y )
3604  m_bbox_min_y = *itYo;
3605 
3606  if( *itYo > m_bbox_max_y )
3607  m_bbox_max_y = *itYo;
3608  }
3609  }
3610 }
std::vector< double > m_trans_shape_ys
Definition: mathplot.h:1779
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:1764
double m_bbox_max_y
Definition: mathplot.h:1784
double m_bbox_min_x
The precomputed bounding box:
Definition: mathplot.h:1784
double m_reference_y
Definition: mathplot.h:1764
std::vector< double > m_shape_ys
Definition: mathplot.h:1774
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:1779
double m_reference_phi
Definition: mathplot.h:1764
double m_bbox_max_x
Definition: mathplot.h:1784
std::vector< double > m_shape_xs
This contains the object points, in local coordinates (to be transformed by the current transformatio...
Definition: mathplot.h:1774
double m_bbox_min_y
Definition: mathplot.h:1784

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

Referenced by mpCovarianceEllipse::RecalculateShape(), and 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 261 of file mathplot.h.

261 { m_showName = show; };
bool m_showName
Definition: mathplot.h:318

Referenced by TRACE::TRACE().

◆ TranslatePoint()

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

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 3554 of file mathplot.cpp.

3555 {
3556  double ccos = cos( m_reference_phi ); // Avoid computing cos/sin twice.
3557  double csin = sin( m_reference_phi );
3558 
3559  out_x = m_reference_x + ccos * x - csin * y;
3560  out_y = m_reference_y + csin * x + ccos * y;
3561 }
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition: mathplot.h:1764
double m_reference_y
Definition: mathplot.h:1764
double m_reference_phi
Definition: mathplot.h:1764

References mpMovableObject::m_reference_phi, mpMovableObject::m_reference_x, and mpMovableObject::m_reference_y.

Member Data Documentation

◆ m_bbox_max_x

double mpMovableObject::m_bbox_max_x
protectedinherited

Definition at line 1784 of file mathplot.h.

Referenced by mpMovableObject::Plot(), and mpMovableObject::ShapeUpdated().

◆ m_bbox_max_y

double mpMovableObject::m_bbox_max_y
protectedinherited

Definition at line 1784 of file mathplot.h.

Referenced by mpMovableObject::Plot(), and mpMovableObject::ShapeUpdated().

◆ m_bbox_min_x

double mpMovableObject::m_bbox_min_x
protectedinherited

The precomputed bounding box:

See also
ShapeUpdated

Definition at line 1784 of file mathplot.h.

Referenced by mpMovableObject::ShapeUpdated().

◆ m_bbox_min_y

double mpMovableObject::m_bbox_min_y
protectedinherited

Definition at line 1784 of file mathplot.h.

Referenced by mpMovableObject::ShapeUpdated().

◆ m_brush

wxBrush mpLayer::m_brush
protectedinherited

Definition at line 315 of file mathplot.h.

◆ m_continuous

bool mpLayer::m_continuous
protectedinherited

Definition at line 317 of file mathplot.h.

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

◆ m_drawOutsideMargins

◆ m_flags

int mpMovableObject::m_flags
protectedinherited

Definition at line 1757 of file mathplot.h.

Referenced by mpMovableObject::Plot().

◆ m_font

◆ m_name

wxString mpLayer::m_name
protectedinherited

◆ m_pen

◆ m_reference_phi

double mpMovableObject::m_reference_phi
protectedinherited

Definition at line 1764 of file mathplot.h.

Referenced by mpMovableObject::ShapeUpdated(), and mpMovableObject::TranslatePoint().

◆ m_reference_x

double mpMovableObject::m_reference_x
protectedinherited

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

Definition at line 1764 of file mathplot.h.

Referenced by mpMovableObject::ShapeUpdated(), and mpMovableObject::TranslatePoint().

◆ m_reference_y

double mpMovableObject::m_reference_y
protectedinherited

Definition at line 1764 of file mathplot.h.

Referenced by mpMovableObject::ShapeUpdated(), and mpMovableObject::TranslatePoint().

◆ m_shape_xs

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

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

Definition at line 1774 of file mathplot.h.

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

◆ m_shape_ys

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

◆ m_showName

bool mpLayer::m_showName
protectedinherited

◆ m_trans_shape_xs

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

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

Definition at line 1779 of file mathplot.h.

Referenced by mpMovableObject::Plot(), and mpMovableObject::ShapeUpdated().

◆ m_trans_shape_ys

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

Definition at line 1779 of file mathplot.h.

Referenced by mpMovableObject::Plot(), and mpMovableObject::ShapeUpdated().

◆ m_type

mpLayerType mpLayer::m_type
protectedinherited

Definition at line 320 of file mathplot.h.

Referenced by mpInfoLayer::mpInfoLayer().

◆ m_visible


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