KiCad PCB EDA Suite
mpInfoCoords Class Reference

Implements an overlay box which shows the mouse coordinates in plot units. More...

#include <mathplot.h>

Inheritance diagram for mpInfoCoords:
mpInfoLayer mpLayer

Public Member Functions

 mpInfoCoords ()
 Default constructor. More...
 
 mpInfoCoords (wxRect rect, const wxBrush *brush=wxTRANSPARENT_BRUSH)
 Complete constructor, setting initial rectangle and background brush. More...
 
 ~mpInfoCoords ()
 Default destructor. More...
 
virtual void UpdateInfo (mpWindow &w, wxEvent &event) override
 Updates the content of the info box. More...
 
virtual void Plot (wxDC &dc, mpWindow &w) override
 Plot method. More...
 
virtual bool HasBBox () const override
 mpInfoLayer has not bounding box. More...
 
virtual bool IsInfo () const override
 Specifies that this is an Info box layer. More...
 
virtual bool Inside (wxPoint &point)
 Checks whether a point is inside the info box rectangle. More...
 
virtual void Move (wxPoint delta)
 Moves the layer rectangle of given pixel deltas. More...
 
virtual void UpdateReference ()
 Updates the rectangle reference point. More...
 
wxPoint GetPosition () const
 Returns the position of the upper left corner of the box (in pixels) More...
 
wxSize GetSize () const
 Returns the size of the box (in pixels) More...
 
const wxRect & GetRectangle () const
 Returns the current rectangle coordinates. More...
 
virtual double GetMinX () const
 Get inclusive left border of bounding box. More...
 
virtual double GetMaxX () const
 Get inclusive right border of bounding box. More...
 
virtual double GetMinY () const
 Get inclusive bottom border of bounding box. More...
 
virtual double GetMaxY () const
 Get inclusive top border of bounding 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) const
 Get a small square bitmap filled with the colour of the pen used in the layer. More...
 
mpLayerType GetLayerType () const
 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 () const
 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 Attributes

wxString m_content
 
wxRect m_dim
 
wxPoint m_reference
 
wxBrush m_brush
 
int m_winX
 
int m_winY
 
wxFont m_font
 
wxPen m_pen
 
wxString m_name
 
bool m_continuous
 
bool m_showName
 
bool m_drawOutsideMargins
 
mpLayerType m_type
 
bool m_visible
 

Detailed Description

Implements an overlay box which shows the mouse coordinates in plot units.

When an mpInfoCoords layer is activated, when mouse is moved over the mpWindow, its coordinates (in mpWindow units, not pixels) are continuously reported inside the layer box.

Definition at line 406 of file mathplot.h.

Constructor & Destructor Documentation

◆ mpInfoCoords() [1/2]

mpInfoCoords::mpInfoCoords ( )

Default constructor.

Definition at line 199 of file mathplot.cpp.

199 : mpInfoLayer()
200{
201}
mpInfoLayer()
Default constructor.
Definition: mathplot.cpp:94

◆ mpInfoCoords() [2/2]

mpInfoCoords::mpInfoCoords ( wxRect  rect,
const wxBrush *  brush = wxTRANSPARENT_BRUSH 
)

Complete constructor, setting initial rectangle and background brush.

Parameters
rectThe initial bounding rectangle.
brushThe wxBrush to be used for box background: default is transparent

Definition at line 204 of file mathplot.cpp.

204 : mpInfoLayer( rect, brush )
205{
206}

◆ ~mpInfoCoords()

mpInfoCoords::~mpInfoCoords ( )

Default destructor.

Definition at line 209 of file mathplot.cpp.

210{
211}

Member Function Documentation

◆ GetBrush()

const wxBrush & mpLayer::GetBrush ( ) const
inlineinherited

Get brush set for this layer.

Returns
brush.

Definition at line 306 of file mathplot.h.

306{ return m_brush; };
wxBrush m_brush
Definition: mathplot.h:316

◆ GetColourSquare()

wxBitmap mpLayer::GetColourSquare ( int  side = 16) const
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 74 of file mathplot.cpp.

75{
76 wxBitmap square( side, side, -1 );
77 wxColour filler = m_pen.GetColour();
78 wxBrush brush( filler, wxBRUSHSTYLE_SOLID );
79 wxMemoryDC dc;
80
81 dc.SelectObject( square );
82 dc.SetBackground( brush );
83 dc.Clear();
84 dc.SelectObject( wxNullBitmap );
85 return square;
86}
double square(double x)
wxPen m_pen
Definition: mathplot.h:315

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

258{ return m_continuous; }
bool m_continuous
Definition: mathplot.h:318

◆ GetDrawOutsideMargins()

bool mpLayer::GetDrawOutsideMargins ( )
inlineinherited

Get Draw mode: inside or outside margins.

Returns
The draw mode

Definition at line 285 of file mathplot.h.

285{ return m_drawOutsideMargins; };
bool m_drawOutsideMargins
Definition: mathplot.h:320

◆ GetFont()

const wxFont & mpLayer::GetFont ( ) const
inlineinherited

Get font set for this layer.

Returns
Font

Definition at line 243 of file mathplot.h.

243{ return m_font; }
wxFont m_font
Definition: mathplot.h:314

◆ GetLayerType()

mpLayerType mpLayer::GetLayerType ( ) const
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 294 of file mathplot.h.

294{ return m_type; };
mpLayerType m_type
Definition: mathplot.h:321

Referenced by mpInfoLegend::Plot().

◆ GetMaxX()

virtual double mpLayer::GetMaxX ( ) const
inlinevirtualinherited

Get inclusive right border of bounding box.

Returns
Value

Reimplemented in mpFXYVector, mpMovableObject, and mpBitmapLayer.

Definition at line 180 of file mathplot.h.

180{ return 1.0; }

Referenced by mpFXY::UpdateScales().

◆ GetMaxY()

virtual double mpLayer::GetMaxY ( ) const
inlinevirtualinherited

Get inclusive top border of bounding box.

Returns
Value

Reimplemented in mpFXYVector, mpMovableObject, and mpBitmapLayer.

Definition at line 190 of file mathplot.h.

190{ return 1.0; }

Referenced by mpFXY::UpdateScales().

◆ GetMinX()

virtual double mpLayer::GetMinX ( ) const
inlinevirtualinherited

Get inclusive left border of bounding box.

Returns
Value

Reimplemented in mpFXYVector, mpMovableObject, and mpBitmapLayer.

Definition at line 175 of file mathplot.h.

175{ return -1.0; }

Referenced by mpFXY::UpdateScales().

◆ GetMinY()

virtual double mpLayer::GetMinY ( ) const
inlinevirtualinherited

Get inclusive bottom border of bounding box.

Returns
Value

Reimplemented in mpFXYVector, mpMovableObject, and mpBitmapLayer.

Definition at line 185 of file mathplot.h.

185{ return -1.0; }

Referenced by mpFXY::UpdateScales().

◆ GetName()

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

Get layer name.

Returns
Name

Definition at line 238 of file mathplot.h.

238{ return m_name; }
wxString m_name
Definition: mathplot.h:317

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

248{ return m_pen; }

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

◆ GetPosition()

wxPoint mpInfoLayer::GetPosition ( ) const
inherited

Returns the position of the upper left corner of the box (in pixels)

Returns
The rectangle position

Definition at line 187 of file mathplot.cpp.

188{
189 return m_dim.GetPosition();
190}
wxRect m_dim
Definition: mathplot.h:395

References mpInfoLayer::m_dim.

◆ GetRectangle()

const wxRect & mpInfoLayer::GetRectangle ( ) const
inlineinherited

Returns the current rectangle coordinates.

Returns
The info layer rectangle

Definition at line 392 of file mathplot.h.

392{ return m_dim; };

Referenced by mpWindow::OnMouseMove().

◆ GetSize()

wxSize mpInfoLayer::GetSize ( ) const
inherited

Returns the size of the box (in pixels)

Returns
The rectangle size

Definition at line 193 of file mathplot.cpp.

194{
195 return m_dim.GetSize();
196}

References mpInfoLayer::m_dim.

◆ HasBBox()

virtual bool mpInfoLayer::HasBBox ( ) const
inlineoverridevirtualinherited

mpInfoLayer has not bounding box.

See also
mpLayer::HasBBox
Returns
always false

Reimplemented from mpLayer.

Definition at line 357 of file mathplot.h.

357{ return false; }

◆ Inside()

bool mpInfoLayer::Inside ( wxPoint &  point)
virtualinherited

Checks whether a point is inside the info box rectangle.

Parameters
pointThe point to be checked
Returns
true if the point is inside the bounding box

Reimplemented in CURSOR.

Definition at line 126 of file mathplot.cpp.

127{
128 return m_dim.Contains( point );
129}

References mpInfoLayer::m_dim.

Referenced by mpWindow::IsInsideInfoLayer().

◆ IsInfo()

virtual bool mpInfoLayer::IsInfo ( ) const
inlineoverridevirtualinherited

Specifies that this is an Info box layer.

Returns
always true
See also
mpLayer::IsInfo

Reimplemented from mpLayer.

Definition at line 368 of file mathplot.h.

368{ return true; }

◆ IsVisible()

bool mpLayer::IsVisible ( ) const
inlineinherited

Checks whether the layer is visible or not.

Returns
true if visible

Definition at line 298 of file mathplot.h.

298{ return m_visible; };
bool m_visible
Definition: mathplot.h:322

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

◆ Move()

void mpInfoLayer::Move ( wxPoint  delta)
virtualinherited

Moves the layer rectangle of given pixel deltas.

Parameters
deltaThe wxPoint container for delta coordinates along x and y. Units are in pixels.

Reimplemented in CURSOR.

Definition at line 132 of file mathplot.cpp.

133{
134 m_dim.SetX( m_reference.x + delta.x );
135 m_dim.SetY( m_reference.y + delta.y );
136}
wxPoint m_reference
Definition: mathplot.h:396
constexpr int delta

References delta, mpInfoLayer::m_dim, and mpInfoLayer::m_reference.

Referenced by CURSOR::Move(), and mpWindow::OnMouseMove().

◆ Plot()

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

Plot method.

Parameters
dcthe device content where to plot
wthe window to plot
See also
mpLayer::Plot

Reimplemented from mpInfoLayer.

Definition at line 230 of file mathplot.cpp.

231{
232 if( m_visible )
233 {
234 // Adjust relative position inside the window
235 int scrx = w.GetScrX();
236 int scry = w.GetScrY();
237
238 if( (m_winX != scrx) || (m_winY != scry) )
239 {
240 if( m_winX > 1 )
241 m_dim.x = (int) floor( (double) (m_dim.x * scrx / m_winX) );
242
243 if( m_winY > 1 )
244 {
245 m_dim.y = (int) floor( (double) (m_dim.y * scry / m_winY) );
247 }
248
249 // Finally update window size
250 m_winX = scrx;
251 m_winY = scry;
252 }
253
254 dc.SetPen( m_pen );
255 // wxImage image0(wxT("pixel.png"), wxBITMAP_TYPE_PNG);
256 // wxBitmap image1(image0);
257 // wxBrush semiWhite(image1);
258 dc.SetBrush( m_brush );
259 dc.SetFont( m_font );
260 int textX, textY;
261 dc.GetTextExtent( m_content, &textX, &textY );
262
263 if( m_dim.width < textX + 10 )
264 m_dim.width = textX + 10;
265
266 if( m_dim.height < textY + 10 )
267 m_dim.height = textY + 10;
268
269 dc.DrawRectangle( m_dim.x, m_dim.y, m_dim.width, m_dim.height );
270 dc.DrawText( m_content, m_dim.x + 5, m_dim.y + 5 );
271 }
272}
wxString m_content
Definition: mathplot.h:431
int m_winY
Definition: mathplot.h:398
virtual void UpdateReference()
Updates the rectangle reference point.
Definition: mathplot.cpp:139
wxBrush m_brush
Definition: mathplot.h:397
int m_winX
Definition: mathplot.h:398
int GetScrX(void) const
Get current view's X dimension in device context units.
Definition: mathplot.h:1138
int GetScrY(void) const
Get current view's Y dimension in device context units.
Definition: mathplot.h:1147

References mpWindow::GetScrX(), mpWindow::GetScrY(), mpInfoLayer::m_brush, m_content, mpInfoLayer::m_dim, mpLayer::m_font, mpLayer::m_pen, mpLayer::m_visible, mpInfoLayer::m_winX, mpInfoLayer::m_winY, and mpInfoLayer::UpdateReference().

◆ SetBrush()

void mpLayer::SetBrush ( wxBrush  brush)
inlineinherited

Set layer brush.

Parameters
brushbrush, will be copied to internal class member

Definition at line 310 of file mathplot.h.

310{ m_brush = brush; };

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

253{ m_continuous = continuity; }

Referenced by TRACE::TRACE().

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

281{ m_drawOutsideMargins = drawModeOutside; };

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

272{ m_font = font; }

◆ SetName()

void mpLayer::SetName ( wxString  name)
inlineinherited

Set layer name.

Parameters
nameName, will be copied to internal class member

Definition at line 267 of file mathplot.h.

267{ m_name = name; }
const char * name
Definition: DXF_plotter.cpp:56

References name.

◆ SetPen()

void mpLayer::SetPen ( wxPen  pen)
inlineinherited

Set layer pen.

Parameters
penPen, will be copied to internal class member

Definition at line 277 of file mathplot.h.

277{ m_pen = pen; }

Referenced by SIM_PLOT_PANEL::EnableCursor(), and SIM_PLOT_PANEL::UpdateTraceStyle().

◆ SetVisible()

void mpLayer::SetVisible ( bool  show)
inlineinherited

Sets layer visibility.

Parameters
showvisibility bool.

Definition at line 302 of file mathplot.h.

302{ m_visible = show; };

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

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

262{ m_showName = show; };
bool m_showName
Definition: mathplot.h:319

Referenced by TRACE::TRACE().

◆ UpdateInfo()

void mpInfoCoords::UpdateInfo ( mpWindow w,
wxEvent &  event 
)
overridevirtual

Updates the content of the info box.

It is used to update coordinates.

Parameters
wparent mpWindow from which to obtain information
eventThe event which called the update.

Reimplemented from mpInfoLayer.

Definition at line 214 of file mathplot.cpp.

215{
216 if( event.GetEventType() == wxEVT_MOTION )
217 {
218 /* It seems that Windows port of wxWidgets don't support multi-line test to be drawn in a wxDC.
219 * wxGTK instead works perfectly with it.
220 * Info on wxForum: http://wxforum.shadonet.com/viewtopic.php?t=3451&highlight=drawtext+eol */
221#ifdef _WINDOWS
222 // FIXME m_content.Printf(wxT("x = %f y = %f"), XScale().P2x(w, mouseX), YScale().P2x(w, mouseY));
223#else
224 // FIXME m_content.Printf(wxT("x = %f\ny = %f"), XScale().P2x(w, mouseX), YScale().P2x(w, mouseY));
225#endif
226 }
227}

◆ UpdateReference()

void mpInfoLayer::UpdateReference ( )
virtualinherited

Updates the rectangle reference point.

Used by internal methods of mpWindow to correctly move mpInfoLayers.

Reimplemented in CURSOR.

Definition at line 139 of file mathplot.cpp.

140{
141 m_reference.x = m_dim.x;
142 m_reference.y = m_dim.y;
143}

References mpInfoLayer::m_dim, and mpInfoLayer::m_reference.

Referenced by mpWindow::OnMouseLeftRelease(), mpInfoLayer::Plot(), Plot(), and mpInfoLegend::Plot().

Member Data Documentation

◆ m_brush

wxBrush mpInfoLayer::m_brush
protectedinherited

Definition at line 397 of file mathplot.h.

Referenced by mpInfoLayer::mpInfoLayer(), mpInfoLayer::Plot(), Plot(), and mpInfoLegend::Plot().

◆ m_content

wxString mpInfoCoords::m_content
protected

Definition at line 431 of file mathplot.h.

Referenced by Plot().

◆ m_continuous

bool mpLayer::m_continuous
protectedinherited

Definition at line 318 of file mathplot.h.

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

◆ m_dim

◆ m_drawOutsideMargins

◆ m_font

◆ m_name

wxString mpLayer::m_name
protectedinherited

◆ m_pen

◆ m_reference

wxPoint mpInfoLayer::m_reference
protectedinherited

◆ m_showName

bool mpLayer::m_showName
protectedinherited

◆ m_type

mpLayerType mpLayer::m_type
protectedinherited

Definition at line 321 of file mathplot.h.

Referenced by mpInfoLayer::mpInfoLayer().

◆ m_visible

◆ m_winX

int mpInfoLayer::m_winX
protectedinherited

Definition at line 398 of file mathplot.h.

Referenced by mpInfoLayer::mpInfoLayer(), mpInfoLayer::Plot(), Plot(), and mpInfoLegend::Plot().

◆ m_winY

int mpInfoLayer::m_winY
protectedinherited

Definition at line 398 of file mathplot.h.

Referenced by mpInfoLayer::mpInfoLayer(), mpInfoLayer::Plot(), Plot(), and mpInfoLegend::Plot().


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