2014-10-22 15:51:34 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2019-05-25 11:05:39 +00:00
|
|
|
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-10-22 15:51:34 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
#ifndef WS_DRAW_ITEM_H
|
|
|
|
#define WS_DRAW_ITEM_H
|
2013-05-22 08:45:25 +00:00
|
|
|
|
2013-07-08 13:05:12 +00:00
|
|
|
#include <math/vector2d.h>
|
2013-06-05 12:03:16 +00:00
|
|
|
#include <eda_text.h>
|
2018-01-29 08:39:13 +00:00
|
|
|
#include <bitmap_base.h>
|
2019-05-20 10:23:32 +00:00
|
|
|
#include "msgpanel.h"
|
2019-06-13 11:23:39 +00:00
|
|
|
#include <geometry/shape_poly_set.h>
|
2013-06-05 12:03:16 +00:00
|
|
|
|
2020-07-06 13:17:37 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <vector>
|
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
class WS_DATA_ITEM;
|
2013-07-19 18:27:22 +00:00
|
|
|
class TITLE_BLOCK;
|
2014-12-23 13:01:59 +00:00
|
|
|
class PAGE_INFO;
|
2013-06-05 12:03:16 +00:00
|
|
|
|
2013-05-22 08:45:25 +00:00
|
|
|
/*
|
2019-05-20 10:23:32 +00:00
|
|
|
* Helper classes to handle basic graphic items used to draw/plot
|
2019-05-25 11:05:39 +00:00
|
|
|
* title blocks and frame references
|
|
|
|
* segments
|
|
|
|
* rect
|
|
|
|
* polygons (for logos)
|
|
|
|
* graphic texts
|
|
|
|
* bitmaps (also for logos, but they cannot be plot by SVG, GERBER or HPGL plotters
|
|
|
|
* where we just plot the bounding box)
|
2013-05-22 08:45:25 +00:00
|
|
|
*/
|
2019-05-20 10:23:32 +00:00
|
|
|
class WS_DRAW_ITEM_BASE : public EDA_ITEM // This basic class, not directly usable.
|
2013-05-22 08:45:25 +00:00
|
|
|
{
|
|
|
|
protected:
|
2019-05-25 11:05:39 +00:00
|
|
|
WS_DATA_ITEM* m_peer; // the parent WS_DATA_ITEM item in the WS_DATA_MODEL
|
2019-05-26 18:35:20 +00:00
|
|
|
int m_index; // the index in the parent's repeat count
|
2020-04-14 12:25:00 +00:00
|
|
|
int m_penWidth;
|
2013-06-05 12:03:16 +00:00
|
|
|
|
2019-05-26 18:35:20 +00:00
|
|
|
WS_DRAW_ITEM_BASE( WS_DATA_ITEM* aPeer, int aIndex, KICAD_T aType ) :
|
2019-05-20 10:23:32 +00:00
|
|
|
EDA_ITEM( aType )
|
2013-05-22 08:45:25 +00:00
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
m_peer = aPeer;
|
2019-05-26 18:35:20 +00:00
|
|
|
m_index = aIndex;
|
2020-04-14 12:25:00 +00:00
|
|
|
m_penWidth = 0;
|
2013-07-19 18:27:22 +00:00
|
|
|
m_Flags = 0;
|
2013-05-22 08:45:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~WS_DRAW_ITEM_BASE() {}
|
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
WS_DATA_ITEM* GetPeer() const { return m_peer; }
|
2019-05-26 18:35:20 +00:00
|
|
|
int GetIndexInPeer() const { return m_index; }
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2019-05-24 13:37:55 +00:00
|
|
|
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
virtual void SetPosition( wxPoint aPos ) = 0;
|
|
|
|
virtual void SetEnd( wxPoint aPos ) { /* not all types will need this */ }
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
virtual int GetPenWidth() const
|
|
|
|
{
|
|
|
|
if( m_penWidth > 0 )
|
|
|
|
return m_penWidth;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-05-31 12:15:25 +00:00
|
|
|
// The function to print a WS_DRAW_ITEM
|
2020-04-14 12:25:00 +00:00
|
|
|
virtual void PrintWsItem( RENDER_SETTINGS* aSettings )
|
2016-06-11 13:51:05 +00:00
|
|
|
{
|
2020-04-14 12:25:00 +00:00
|
|
|
PrintWsItem( aSettings, wxPoint( 0, 0 ) );
|
2016-06-11 13:51:05 +00:00
|
|
|
}
|
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
// More advanced version of DrawWsItem. This is what must be defined in the derived type.
|
2020-04-14 12:25:00 +00:00
|
|
|
virtual void PrintWsItem( RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) = 0;
|
2013-07-25 18:58:46 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
// Derived types must define GetBoundingBox() as a minimum, and can then override the
|
|
|
|
// two HitTest() functions if they need something more specific.
|
|
|
|
const EDA_RECT GetBoundingBox() const override = 0;
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override
|
|
|
|
{
|
|
|
|
// This is just here to prevent annoying compiler warnings about hidden overloaded
|
|
|
|
// virtual functions
|
|
|
|
return EDA_ITEM::HitTest( aPosition, aAccuracy );
|
|
|
|
}
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList ) override;
|
2013-05-22 08:45:25 +00:00
|
|
|
};
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2013-05-22 08:45:25 +00:00
|
|
|
// This class draws a thick segment
|
|
|
|
class WS_DRAW_ITEM_LINE : public WS_DRAW_ITEM_BASE
|
|
|
|
{
|
|
|
|
wxPoint m_start; // start point of line/rect
|
|
|
|
wxPoint m_end; // end point
|
2013-05-24 08:59:40 +00:00
|
|
|
|
2013-05-22 08:45:25 +00:00
|
|
|
public:
|
2019-05-26 18:35:20 +00:00
|
|
|
WS_DRAW_ITEM_LINE( WS_DATA_ITEM* aPeer, int aIndex, wxPoint aStart, wxPoint aEnd,
|
|
|
|
int aPenWidth ) :
|
|
|
|
WS_DRAW_ITEM_BASE( aPeer, aIndex, WSG_LINE_T )
|
2013-05-22 08:45:25 +00:00
|
|
|
{
|
|
|
|
m_start = aStart;
|
|
|
|
m_end = aEnd;
|
|
|
|
m_penWidth = aPenWidth;
|
|
|
|
}
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
virtual wxString GetClass() const override { return wxT( "WS_DRAW_ITEM_LINE" ); }
|
|
|
|
|
2013-05-22 08:45:25 +00:00
|
|
|
// Accessors:
|
2013-09-10 12:31:52 +00:00
|
|
|
const wxPoint& GetStart() const { return m_start; }
|
2019-05-20 10:23:32 +00:00
|
|
|
void SetStart( wxPoint aPos ) { m_start = aPos; }
|
2013-09-10 12:31:52 +00:00
|
|
|
const wxPoint& GetEnd() const { return m_end; }
|
2019-05-20 10:23:32 +00:00
|
|
|
void SetEnd( wxPoint aPos ) override { m_end = aPos; }
|
|
|
|
|
2020-05-27 14:01:07 +00:00
|
|
|
wxPoint GetPosition() const override { return GetStart(); }
|
2019-05-20 10:23:32 +00:00
|
|
|
void SetPosition( wxPoint aPos ) override { SetStart( aPos ); }
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2019-05-24 20:10:44 +00:00
|
|
|
const EDA_RECT GetBoundingBox() const override;
|
2019-05-20 10:23:32 +00:00
|
|
|
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
void PrintWsItem( RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override;
|
2019-05-24 20:10:44 +00:00
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
2016-06-11 13:51:05 +00:00
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
|
|
|
#endif
|
2013-05-22 08:45:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// This class draws a polygon
|
2019-06-13 11:23:39 +00:00
|
|
|
class WS_DRAW_ITEM_POLYPOLYGONS : public WS_DRAW_ITEM_BASE
|
2013-05-22 08:45:25 +00:00
|
|
|
{
|
2013-07-19 18:27:22 +00:00
|
|
|
wxPoint m_pos; // position of reference point, from the
|
2019-05-25 11:05:39 +00:00
|
|
|
// WS_DATA_ITEM_POLYGONS parent
|
2013-07-19 18:27:22 +00:00
|
|
|
// (used only in page layout editor to draw anchors)
|
2013-05-23 16:38:17 +00:00
|
|
|
|
2013-05-22 08:45:25 +00:00
|
|
|
public:
|
2019-06-13 11:23:39 +00:00
|
|
|
/** The list of polygons. Because these polygons are only for drawing purposes,
|
|
|
|
* each polygon is expected having no holes, jusst a main outline
|
|
|
|
*/
|
|
|
|
SHAPE_POLY_SET m_Polygons;
|
2013-06-08 18:19:09 +00:00
|
|
|
|
2013-05-22 08:45:25 +00:00
|
|
|
public:
|
2019-06-13 11:23:39 +00:00
|
|
|
WS_DRAW_ITEM_POLYPOLYGONS( WS_DATA_ITEM* aPeer, int aIndex, wxPoint aPos, int aPenWidth ) :
|
2019-05-26 18:35:20 +00:00
|
|
|
WS_DRAW_ITEM_BASE( aPeer, aIndex, WSG_POLY_T )
|
2013-05-22 08:45:25 +00:00
|
|
|
{
|
|
|
|
m_penWidth = aPenWidth;
|
2013-07-19 18:27:22 +00:00
|
|
|
m_pos = aPos;
|
2013-05-22 08:45:25 +00:00
|
|
|
}
|
|
|
|
|
2019-06-13 11:23:39 +00:00
|
|
|
virtual wxString GetClass() const override { return wxT( "WS_DRAW_ITEM_POLYPOLYGONS" ); }
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2013-05-22 08:45:25 +00:00
|
|
|
// Accessors:
|
2019-06-13 11:23:39 +00:00
|
|
|
SHAPE_POLY_SET& GetPolygons() { return m_Polygons; }
|
2020-05-27 14:01:07 +00:00
|
|
|
wxPoint GetPosition() const override { return m_pos; }
|
2019-06-13 12:01:57 +00:00
|
|
|
void SetPosition( wxPoint aPos ) override;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2019-05-24 20:10:44 +00:00
|
|
|
const EDA_RECT GetBoundingBox() const override;
|
2019-05-20 10:23:32 +00:00
|
|
|
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
|
|
|
|
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
2016-06-11 13:51:05 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
void PrintWsItem( RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override;
|
2019-05-24 20:10:44 +00:00
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
2019-05-20 10:23:32 +00:00
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
|
|
|
#endif
|
2013-05-22 08:45:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// This class draws a not filled rectangle with thick segment
|
2019-05-20 10:23:32 +00:00
|
|
|
class WS_DRAW_ITEM_RECT : public WS_DRAW_ITEM_BASE
|
2013-05-22 08:45:25 +00:00
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
wxPoint m_start; // start point of line/rect
|
|
|
|
wxPoint m_end; // end point
|
|
|
|
|
2013-05-22 08:45:25 +00:00
|
|
|
public:
|
2019-05-26 18:35:20 +00:00
|
|
|
WS_DRAW_ITEM_RECT( WS_DATA_ITEM* aPeer, int aIndex, wxPoint aStart, wxPoint aEnd,
|
|
|
|
int aPenWidth ) :
|
|
|
|
WS_DRAW_ITEM_BASE( aPeer, aIndex, WSG_RECT_T )
|
2013-05-22 08:45:25 +00:00
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
m_start = aStart;
|
|
|
|
m_end = aEnd;
|
|
|
|
m_penWidth = aPenWidth;
|
2013-05-22 08:45:25 +00:00
|
|
|
}
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
virtual wxString GetClass() const override { return wxT( "WS_DRAW_ITEM_RECT" ); }
|
|
|
|
|
|
|
|
// Accessors:
|
|
|
|
const wxPoint& GetStart() const { return m_start; }
|
|
|
|
void SetStart( wxPoint aPos ) { m_start = aPos; }
|
|
|
|
const wxPoint& GetEnd() const { return m_end; }
|
|
|
|
void SetEnd( wxPoint aPos ) override { m_end = aPos; }
|
|
|
|
|
2020-05-27 14:01:07 +00:00
|
|
|
wxPoint GetPosition() const override { return GetStart(); }
|
2019-05-20 10:23:32 +00:00
|
|
|
void SetPosition( wxPoint aPos ) override { SetStart( aPos ); }
|
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
void PrintWsItem( RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override;
|
2013-07-25 18:58:46 +00:00
|
|
|
|
2019-05-24 20:10:44 +00:00
|
|
|
const EDA_RECT GetBoundingBox() const override;
|
2019-05-20 10:23:32 +00:00
|
|
|
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
2016-06-11 13:51:05 +00:00
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
|
|
|
#endif
|
2013-05-22 08:45:25 +00:00
|
|
|
};
|
|
|
|
|
2019-06-07 10:42:28 +00:00
|
|
|
|
|
|
|
// This class draws a rectangle with thick segment showing the page limits
|
2019-06-13 11:23:39 +00:00
|
|
|
// and a marker showing the coord origin. This only a draw item only.
|
|
|
|
// Therefore m_peer ( the parent WS_DATA_ITEM item in the WS_DATA_MODEL) is always a nullptr.
|
2019-06-07 10:42:28 +00:00
|
|
|
class WS_DRAW_ITEM_PAGE : public WS_DRAW_ITEM_BASE
|
|
|
|
{
|
|
|
|
wxPoint m_markerPos; // position of the marker
|
|
|
|
wxSize m_pageSize; // full size of the page
|
|
|
|
double m_markerSize;
|
|
|
|
|
|
|
|
public:
|
|
|
|
WS_DRAW_ITEM_PAGE( int aPenWidth, double aMarkerSize ) :
|
|
|
|
WS_DRAW_ITEM_BASE( nullptr, 0, WSG_PAGE_T )
|
|
|
|
{
|
|
|
|
m_penWidth = aPenWidth;
|
|
|
|
m_markerSize = aMarkerSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual wxString GetClass() const override { return wxT( "WS_DRAW_ITEM_PAGE" ); }
|
|
|
|
|
|
|
|
// Accessors:
|
|
|
|
void SetPageSize( wxSize aSize ) { m_pageSize = aSize; }
|
|
|
|
wxSize GetPageSize() const { return m_pageSize; }
|
|
|
|
const wxPoint& GetMarkerPos() const { return m_markerPos; }
|
|
|
|
void SetMarkerPos( wxPoint aPos ) { m_markerPos = aPos; }
|
|
|
|
double GetMarkerSize() const { return m_markerSize; }
|
|
|
|
|
2020-05-27 14:01:07 +00:00
|
|
|
wxPoint GetPosition() const override { return wxPoint( 0, 0 ); }
|
2019-06-07 10:42:28 +00:00
|
|
|
void SetPosition( wxPoint aPos ) override { /* do nothing */ }
|
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
void PrintWsItem( RENDER_SETTINGS* , const wxPoint& ) override { /* do nothing */ }
|
2019-06-07 10:42:28 +00:00
|
|
|
|
|
|
|
const EDA_RECT GetBoundingBox() const override;
|
|
|
|
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override { return false; }
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
2019-06-07 10:42:28 +00:00
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2013-05-22 08:45:25 +00:00
|
|
|
// This class draws a graphic text.
|
|
|
|
// it is derived from an EDA_TEXT, so it handle all caracteristics
|
|
|
|
// of this graphic text (justification, rotation ... )
|
|
|
|
class WS_DRAW_ITEM_TEXT : public WS_DRAW_ITEM_BASE, public EDA_TEXT
|
|
|
|
{
|
|
|
|
public:
|
2019-05-26 18:35:20 +00:00
|
|
|
WS_DRAW_ITEM_TEXT( WS_DATA_ITEM* aPeer, int aIndex, wxString& aText, wxPoint aPos,
|
2020-04-18 20:04:41 +00:00
|
|
|
wxSize aSize, int aPenWidth, bool aItalic = false,
|
2020-04-14 12:25:00 +00:00
|
|
|
bool aBold = false ) :
|
2019-05-26 18:35:20 +00:00
|
|
|
WS_DRAW_ITEM_BASE( aPeer, aIndex, WSG_TEXT_T),
|
2020-04-18 20:04:41 +00:00
|
|
|
EDA_TEXT( aText )
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
|
|
|
SetTextPos( aPos );
|
|
|
|
SetTextSize( aSize );
|
2020-04-14 12:25:00 +00:00
|
|
|
SetTextThickness( aPenWidth );
|
2019-05-20 10:23:32 +00:00
|
|
|
SetItalic( aItalic );
|
|
|
|
SetBold( aBold );
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual wxString GetClass() const override { return wxT( "WS_DRAW_ITEM_TEXT" ); }
|
2013-07-25 18:58:46 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
void PrintWsItem( RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override;
|
2013-05-22 08:45:25 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
void SetTextAngle( double aAngle ) override
|
2017-01-23 20:30:11 +00:00
|
|
|
{
|
2017-10-23 13:35:03 +00:00
|
|
|
EDA_TEXT::SetTextAngle( NormalizeAngle360Min( aAngle ) );
|
2017-01-23 20:30:11 +00:00
|
|
|
}
|
|
|
|
|
2020-05-27 14:01:07 +00:00
|
|
|
wxPoint GetPosition() const override { return GetTextPos(); }
|
2019-05-20 10:23:32 +00:00
|
|
|
void SetPosition( wxPoint aPos ) override { SetTextPos( aPos ); }
|
|
|
|
|
2019-05-24 20:10:44 +00:00
|
|
|
const EDA_RECT GetBoundingBox() const override;
|
2019-05-20 10:23:32 +00:00
|
|
|
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
|
|
|
|
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
2016-06-11 13:51:05 +00:00
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
2019-05-20 10:23:32 +00:00
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
|
|
|
#endif
|
2013-05-22 08:45:25 +00:00
|
|
|
};
|
|
|
|
|
2013-10-18 17:38:03 +00:00
|
|
|
// This class draws a bitmap.
|
|
|
|
class WS_DRAW_ITEM_BITMAP : public WS_DRAW_ITEM_BASE
|
|
|
|
{
|
|
|
|
wxPoint m_pos; // position of reference point
|
|
|
|
|
|
|
|
public:
|
2019-05-26 18:35:20 +00:00
|
|
|
WS_DRAW_ITEM_BITMAP( WS_DATA_ITEM* aPeer, int aIndex, wxPoint aPos ) :
|
|
|
|
WS_DRAW_ITEM_BASE( aPeer, aIndex, WSG_BITMAP_T )
|
2013-10-18 17:38:03 +00:00
|
|
|
{
|
|
|
|
m_pos = aPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
~WS_DRAW_ITEM_BITMAP() {}
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
virtual wxString GetClass() const override { return wxT( "WS_DRAW_ITEM_BITMAP" ); }
|
2013-10-18 17:38:03 +00:00
|
|
|
|
2020-05-27 14:01:07 +00:00
|
|
|
wxPoint GetPosition() const override { return m_pos; }
|
2019-05-20 10:23:32 +00:00
|
|
|
void SetPosition( wxPoint aPos ) override { m_pos = aPos; }
|
2013-10-18 17:38:03 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
void PrintWsItem( RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override;
|
2016-06-11 13:51:05 +00:00
|
|
|
|
2019-06-06 09:13:10 +00:00
|
|
|
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
|
|
|
|
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
2019-05-20 10:23:32 +00:00
|
|
|
const EDA_RECT GetBoundingBox() const override;
|
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
2013-10-18 17:38:03 +00:00
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
|
|
|
#endif
|
2013-10-18 17:38:03 +00:00
|
|
|
};
|
|
|
|
|
2013-05-22 08:45:25 +00:00
|
|
|
/*
|
2013-05-24 08:59:40 +00:00
|
|
|
* this class stores the list of graphic items:
|
|
|
|
* rect, lines, polygons and texts to draw/plot
|
|
|
|
* the title block and frame references, and parameters to
|
|
|
|
* draw/plot them
|
2013-05-22 08:45:25 +00:00
|
|
|
*/
|
|
|
|
class WS_DRAW_ITEM_LIST
|
|
|
|
{
|
2013-07-22 16:45:22 +00:00
|
|
|
protected:
|
2013-05-22 08:45:25 +00:00
|
|
|
std::vector <WS_DRAW_ITEM_BASE*> m_graphicList; // Items to draw/plot
|
2020-03-26 11:02:59 +00:00
|
|
|
unsigned m_idx; // for GetFirst, GetNext functions
|
|
|
|
double m_milsToIu; // the scalar to convert pages units ( mils)
|
|
|
|
// to draw/plot units.
|
|
|
|
int m_penSize; // The default line width for drawings.
|
|
|
|
// used when an item has a pen size = 0
|
|
|
|
int m_sheetNumber; // the value of the sheet number, for basic inscriptions
|
|
|
|
int m_sheetCount; // the value of the number of sheets, in schematic
|
|
|
|
// for basic inscriptions, in schematic
|
|
|
|
const TITLE_BLOCK* m_titleBlock; // for basic inscriptions
|
|
|
|
const wxString* m_paperFormat; // for basic inscriptions
|
|
|
|
wxString m_fileName; // for basic inscriptions
|
|
|
|
wxString m_sheetFullName; // for basic inscriptions
|
|
|
|
const wxString* m_sheetLayer; // for basic inscriptions
|
|
|
|
const PROJECT* m_project; // for project-based variable substitutions
|
2013-05-22 08:45:25 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
WS_DRAW_ITEM_LIST()
|
|
|
|
{
|
|
|
|
m_idx = 0;
|
2013-05-22 15:08:57 +00:00
|
|
|
m_milsToIu = 1.0;
|
|
|
|
m_penSize = 1;
|
2013-05-24 08:59:40 +00:00
|
|
|
m_sheetNumber = 1;
|
|
|
|
m_sheetCount = 1;
|
2018-03-10 09:25:07 +00:00
|
|
|
m_sheetLayer = nullptr;
|
|
|
|
m_titleBlock = nullptr;
|
|
|
|
m_paperFormat = nullptr;
|
2020-03-26 11:02:59 +00:00
|
|
|
m_project = nullptr;
|
2013-05-22 08:45:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~WS_DRAW_ITEM_LIST()
|
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
// Items in the m_graphicList are owned by their respective WORKSHEET_DATAITEMs.
|
|
|
|
// for( WS_DRAW_ITEM_BASE* item : m_graphicList )
|
|
|
|
// delete item;
|
2013-05-22 08:45:25 +00:00
|
|
|
}
|
|
|
|
|
2020-03-26 11:02:59 +00:00
|
|
|
void SetProject( const PROJECT* aProject ) { m_project = aProject; }
|
|
|
|
|
2019-06-15 16:15:29 +00:00
|
|
|
/**
|
|
|
|
* Set the title block (mainly for page layout editor)
|
|
|
|
*/
|
|
|
|
void SetTitleBlock( const TITLE_BLOCK* aTblock ) { m_titleBlock = aTblock; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the paper format name (mainly for page layout editor)
|
|
|
|
*/
|
|
|
|
void SetPaperFormat( const wxString* aFormatName ) { m_paperFormat = aFormatName; }
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
/**
|
|
|
|
* Set the filename to draw/plot
|
|
|
|
*/
|
2018-03-10 09:25:07 +00:00
|
|
|
void SetFileName( const wxString& aFileName )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2013-08-07 13:22:59 +00:00
|
|
|
m_fileName = aFileName;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the sheet name to draw/plot
|
|
|
|
*/
|
2018-03-10 09:25:07 +00:00
|
|
|
void SetSheetName( const wxString& aSheetName )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2018-03-10 09:25:07 +00:00
|
|
|
m_sheetFullName = aSheetName;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2016-09-10 18:06:31 +00:00
|
|
|
/**
|
|
|
|
* Set the sheet layer to draw/plot
|
|
|
|
*/
|
2018-03-10 09:25:07 +00:00
|
|
|
void SetSheetLayer( const wxString& aSheetLayer )
|
2016-09-10 18:06:31 +00:00
|
|
|
{
|
|
|
|
m_sheetLayer = &aSheetLayer;
|
|
|
|
}
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
void SetDefaultPenSize( int aPenSize ) { m_penSize = aPenSize; }
|
|
|
|
int GetDefaultPenSize() const { return m_penSize; }
|
2013-05-22 08:45:25 +00:00
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
/**
|
|
|
|
* Function SetMilsToIUfactor
|
|
|
|
* Set the scalar to convert pages units (mils) to draw/plot units
|
2013-05-22 08:45:25 +00:00
|
|
|
*/
|
|
|
|
void SetMilsToIUfactor( double aScale )
|
|
|
|
{
|
|
|
|
m_milsToIu = aScale;
|
|
|
|
}
|
|
|
|
|
2013-05-24 08:59:40 +00:00
|
|
|
/**
|
|
|
|
* Function SetSheetNumber
|
|
|
|
* Set the value of the sheet number, for basic inscriptions
|
|
|
|
*/
|
|
|
|
void SetSheetNumber( int aSheetNumber )
|
|
|
|
{
|
|
|
|
m_sheetNumber = aSheetNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetSheetCount
|
|
|
|
* Set the value of the count of sheets, for basic inscriptions
|
|
|
|
*/
|
|
|
|
void SetSheetCount( int aSheetCount )
|
|
|
|
{
|
|
|
|
m_sheetCount = aSheetCount;
|
|
|
|
}
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
void Append( WS_DRAW_ITEM_BASE* aItem )
|
2013-05-22 08:45:25 +00:00
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
m_graphicList.push_back( aItem );
|
2013-05-22 08:45:25 +00:00
|
|
|
}
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
void Remove( WS_DRAW_ITEM_BASE* aItem )
|
2013-05-22 08:45:25 +00:00
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
auto newEnd = std::remove( m_graphicList.begin(), m_graphicList.end(), aItem );
|
|
|
|
m_graphicList.erase( newEnd, m_graphicList.end() );
|
2013-05-22 08:45:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WS_DRAW_ITEM_BASE* GetFirst()
|
|
|
|
{
|
|
|
|
m_idx = 0;
|
|
|
|
|
|
|
|
if( m_graphicList.size() )
|
|
|
|
return m_graphicList[0];
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
WS_DRAW_ITEM_BASE* GetNext()
|
|
|
|
{
|
|
|
|
m_idx++;
|
|
|
|
|
|
|
|
if( m_graphicList.size() > m_idx )
|
|
|
|
return m_graphicList[m_idx];
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-06-11 13:51:05 +00:00
|
|
|
void GetAllItems( std::vector<WS_DRAW_ITEM_BASE*>* aList )
|
|
|
|
{
|
|
|
|
*aList = m_graphicList;
|
|
|
|
}
|
|
|
|
|
2013-06-29 09:52:22 +00:00
|
|
|
/**
|
2013-07-19 18:27:22 +00:00
|
|
|
* Draws the item list created by BuildWorkSheetGraphicList
|
2013-06-29 09:52:22 +00:00
|
|
|
*/
|
2020-04-14 12:25:00 +00:00
|
|
|
void Print( RENDER_SETTINGS* aSettings );
|
2013-06-29 09:52:22 +00:00
|
|
|
|
2013-05-22 08:45:25 +00:00
|
|
|
/**
|
2019-05-20 10:23:32 +00:00
|
|
|
* Function BuildWorkSheetGraphicList is a core function for drawing or plotting the
|
|
|
|
* page layout with the frame and the basic inscriptions.
|
|
|
|
*
|
|
|
|
* Before calling this function, some parameters should be initialized by calling:
|
2013-07-19 18:27:22 +00:00
|
|
|
* SetPenSize( aPenWidth );
|
|
|
|
* SetMilsToIUfactor( aScalar );
|
|
|
|
* SetSheetNumber( aSheetNumber );
|
|
|
|
* SetSheetCount( aSheetCount );
|
|
|
|
* SetFileName( aFileName );
|
|
|
|
* SetSheetName( aFullSheetName );
|
2013-05-22 08:45:25 +00:00
|
|
|
*
|
2013-07-19 18:27:22 +00:00
|
|
|
* @param aPageInfo The PAGE_INFO, for page size, margins...
|
2013-05-22 08:45:25 +00:00
|
|
|
* @param aTitleBlock The sheet title block, for basic inscriptions.
|
2013-06-29 09:52:22 +00:00
|
|
|
* @param aColor The color for drawing.
|
2019-05-20 10:23:32 +00:00
|
|
|
* @param aAltColor The color for items which need to be "highlighted".
|
2013-05-22 08:45:25 +00:00
|
|
|
*/
|
2019-05-20 10:23:32 +00:00
|
|
|
void BuildWorkSheetGraphicList( const PAGE_INFO& aPageInfo, const TITLE_BLOCK& aTitleBlock );
|
|
|
|
|
2020-05-30 09:22:19 +00:00
|
|
|
static void GetTextVars( wxArrayString* aVars );
|
|
|
|
|
2013-05-25 09:01:44 +00:00
|
|
|
/**
|
|
|
|
* Function BuildFullText
|
|
|
|
* returns the full text corresponding to the aTextbase,
|
|
|
|
* after replacing format symbols by the corresponding value
|
|
|
|
*
|
|
|
|
* Basic texts in Ki_WorkSheetData struct use format notation
|
|
|
|
* like "Title %T" to identify at run time the full text
|
|
|
|
* to display.
|
|
|
|
* Currently format identifier is % followed by a letter or 2 letters
|
|
|
|
*
|
|
|
|
* %% = replaced by %
|
|
|
|
* %K = Kicad version
|
|
|
|
* %Z = paper format name (A4, USLetter)
|
|
|
|
* %Y = company name
|
|
|
|
* %D = date
|
|
|
|
* %R = revision
|
|
|
|
* %S = sheet number
|
|
|
|
* %N = number of sheets
|
|
|
|
* %Cx = comment (x = 0 to 9 to identify the comment)
|
|
|
|
* %F = filename
|
|
|
|
* %P = sheet path or sheet full name
|
|
|
|
* %T = title
|
|
|
|
* Other fields like Developer, Verifier, Approver could use %Cx
|
|
|
|
* and are seen as comments for format
|
|
|
|
*
|
|
|
|
* @param aTextbase = the text with format symbols
|
|
|
|
* @return the text, after replacing the format symbols by the actual value
|
|
|
|
*/
|
|
|
|
wxString BuildFullText( const wxString& aTextbase );
|
2013-05-22 08:45:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
#endif // WS_DRAW_ITEM_H
|