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
|
2023-03-13 11:25:30 +00:00
|
|
|
* Copyright (C) 1992-2023 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
|
|
|
|
*/
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
#ifndef DS_DRAW_ITEM_H
|
|
|
|
#define DS_DRAW_ITEM_H
|
2013-05-22 08:45:25 +00:00
|
|
|
|
2020-10-14 02:46:39 +00:00
|
|
|
#include <core/typeinfo.h>
|
2013-07-08 13:05:12 +00:00
|
|
|
#include <math/vector2d.h>
|
2013-06-05 12:03:16 +00:00
|
|
|
#include <eda_text.h>
|
2020-10-25 04:49:02 +00:00
|
|
|
#include "widgets/msgpanel.h"
|
2019-06-13 11:23:39 +00:00
|
|
|
#include <geometry/shape_poly_set.h>
|
2021-04-15 03:20:36 +00:00
|
|
|
#include <eda_item.h>
|
2020-10-24 14:45:37 +00:00
|
|
|
#include <eda_units.h>
|
2013-06-05 12:03:16 +00:00
|
|
|
|
2020-07-06 13:17:37 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <vector>
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
class DS_DATA_ITEM;
|
2013-07-19 18:27:22 +00:00
|
|
|
class TITLE_BLOCK;
|
2014-12-23 13:01:59 +00:00
|
|
|
class PAGE_INFO;
|
2020-10-14 02:46:39 +00:00
|
|
|
class EDA_ITEM;
|
|
|
|
class EDA_DRAW_FRAME;
|
2020-10-24 14:45:37 +00:00
|
|
|
class PROJECT;
|
2013-06-05 12:03:16 +00:00
|
|
|
|
2020-10-18 20:30:37 +00:00
|
|
|
/**
|
2020-12-21 23:42:21 +00:00
|
|
|
* Base class to handle basic graphic items.
|
|
|
|
*
|
|
|
|
* Used to draw and/or plot:
|
|
|
|
* - 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
|
|
|
*/
|
2021-02-22 23:47:17 +00:00
|
|
|
class DS_DRAW_ITEM_BASE : public EDA_ITEM
|
2013-05-22 08:45:25 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-02-22 23:47:17 +00:00
|
|
|
virtual ~DS_DRAW_ITEM_BASE() {}
|
2013-05-22 08:45:25 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_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;
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
virtual void SetEnd( const VECTOR2I& 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;
|
|
|
|
}
|
|
|
|
|
2023-08-06 19:20:53 +00:00
|
|
|
const KIFONT::METRICS& GetFontMetrics() const;
|
|
|
|
|
2019-05-31 12:15:25 +00:00
|
|
|
// The function to print a WS_DRAW_ITEM
|
2020-12-20 18:18:54 +00:00
|
|
|
virtual void PrintWsItem( const RENDER_SETTINGS* aSettings )
|
2016-06-11 13:51:05 +00:00
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
PrintWsItem( aSettings, VECTOR2I( 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.
|
2022-01-01 06:04:08 +00:00
|
|
|
virtual void PrintWsItem( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) = 0;
|
2013-07-25 18:58:46 +00:00
|
|
|
|
2023-05-27 15:30:12 +00:00
|
|
|
// We can't cache bounding boxes because we're recreated for each draw event. This method
|
|
|
|
// can be overridden by items whose real bounding boxes are expensive to calculate. It is
|
|
|
|
// used to determine if we're in the current view, so it can be sloppy.
|
|
|
|
virtual const BOX2I GetApproxBBox()
|
|
|
|
{
|
|
|
|
return GetBoundingBox();
|
|
|
|
}
|
|
|
|
|
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.
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I GetBoundingBox() const override = 0;
|
2019-05-25 11:05:39 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
|
|
|
// 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
|
|
|
|
2022-08-31 09:33:46 +00:00
|
|
|
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2021-09-26 23:22:32 +00:00
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
2020-12-21 23:42:21 +00:00
|
|
|
|
|
|
|
protected:
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DRAW_ITEM_BASE( DS_DATA_ITEM* aPeer, int aIndex, KICAD_T aType ) :
|
2020-12-21 23:42:21 +00:00
|
|
|
EDA_ITEM( aType )
|
|
|
|
{
|
|
|
|
m_peer = aPeer;
|
|
|
|
m_index = aIndex;
|
|
|
|
m_penWidth = 0;
|
|
|
|
m_flags = 0;
|
|
|
|
}
|
|
|
|
|
2023-03-13 11:25:30 +00:00
|
|
|
protected:
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DATA_ITEM* m_peer; // the parent DS_DATA_ITEM item in the DS_DATA_MODEL
|
2020-12-21 23:42:21 +00:00
|
|
|
int m_index; // the index in the parent's repeat count
|
|
|
|
int m_penWidth;
|
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
|
2021-02-22 23:47:17 +00:00
|
|
|
class DS_DRAW_ITEM_LINE : public DS_DRAW_ITEM_BASE
|
2013-05-22 08:45:25 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-01-01 06:04:08 +00:00
|
|
|
DS_DRAW_ITEM_LINE( DS_DATA_ITEM* aPeer, int aIndex, VECTOR2I aStart, VECTOR2I aEnd,
|
2019-05-26 18:35:20 +00:00
|
|
|
int aPenWidth ) :
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_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;
|
|
|
|
}
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
virtual wxString GetClass() const override { return wxT( "DS_DRAW_ITEM_LINE" ); }
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
const VECTOR2I& GetStart() const { return m_start; }
|
2022-10-22 12:59:32 +00:00
|
|
|
void SetStart( const VECTOR2I& aPos ) { m_start = aPos; }
|
2022-01-01 06:04:08 +00:00
|
|
|
const VECTOR2I& GetEnd() const { return m_end; }
|
|
|
|
void SetEnd( const VECTOR2I& aPos ) override { m_end = aPos; }
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I GetPosition() const override { return GetStart(); }
|
|
|
|
void SetPosition( const VECTOR2I& aPos ) override { SetStart( aPos ); }
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I GetBoundingBox() const override;
|
2022-10-22 12:59:32 +00:00
|
|
|
|
|
|
|
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void PrintWsItem( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
|
2019-05-24 20:10:44 +00:00
|
|
|
|
2023-01-12 03:27:44 +00:00
|
|
|
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) 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
|
2020-12-21 23:42:21 +00:00
|
|
|
|
|
|
|
private:
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I m_start; // start point of line/rect
|
|
|
|
VECTOR2I m_end; // end point
|
2013-05-22 08:45:25 +00:00
|
|
|
};
|
|
|
|
|
2020-10-18 20:30:37 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
class DS_DRAW_ITEM_POLYPOLYGONS : public DS_DRAW_ITEM_BASE
|
2013-05-22 08:45:25 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-01-01 06:04:08 +00:00
|
|
|
DS_DRAW_ITEM_POLYPOLYGONS( DS_DATA_ITEM* aPeer, int aIndex, VECTOR2I aPos, int aPenWidth ) :
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_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
|
|
|
}
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
virtual wxString GetClass() const override { return wxT( "DS_DRAW_ITEM_POLYPOLYGONS" ); }
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2019-06-13 11:23:39 +00:00
|
|
|
SHAPE_POLY_SET& GetPolygons() { return m_Polygons; }
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I GetPosition() const override { return m_pos; }
|
|
|
|
void SetPosition( const VECTOR2I& aPos ) override;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I GetBoundingBox() const override;
|
2022-01-01 06:04:08 +00:00
|
|
|
|
|
|
|
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
|
2022-08-31 09:33:46 +00:00
|
|
|
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
2016-06-11 13:51:05 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void PrintWsItem( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
|
2019-05-24 20:10:44 +00:00
|
|
|
|
2023-01-12 03:27:44 +00:00
|
|
|
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) 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
|
2020-12-21 23:42:21 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* The list of polygons.
|
|
|
|
*
|
|
|
|
* Because these polygons are only for drawing purposes, each polygon is expected to
|
|
|
|
* have no holes just a main outline.
|
|
|
|
*/
|
|
|
|
SHAPE_POLY_SET m_Polygons;
|
|
|
|
|
|
|
|
private:
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I m_pos; // position of reference point, from the DS_DATA_ITEM_POLYGONS parent
|
|
|
|
// (used only in drawing sheet editor to draw anchors)
|
2013-05-22 08:45:25 +00:00
|
|
|
};
|
|
|
|
|
2020-10-18 20:30:37 +00:00
|
|
|
|
2020-12-21 23:42:21 +00:00
|
|
|
/**
|
|
|
|
* Non filled rectangle with thick segment.
|
|
|
|
*/
|
2021-02-22 23:47:17 +00:00
|
|
|
class DS_DRAW_ITEM_RECT : public DS_DRAW_ITEM_BASE
|
2013-05-22 08:45:25 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-01-01 06:04:08 +00:00
|
|
|
DS_DRAW_ITEM_RECT( DS_DATA_ITEM* aPeer, int aIndex, VECTOR2I aStart, VECTOR2I aEnd,
|
2019-05-26 18:35:20 +00:00
|
|
|
int aPenWidth ) :
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_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
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
virtual wxString GetClass() const override { return wxT( "DS_DRAW_ITEM_RECT" ); }
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
const VECTOR2I& GetStart() const { return m_start; }
|
2022-10-22 12:59:32 +00:00
|
|
|
void SetStart( const VECTOR2I& aPos ) { m_start = aPos; }
|
2022-01-01 06:04:08 +00:00
|
|
|
const VECTOR2I& GetEnd() const { return m_end; }
|
|
|
|
void SetEnd( const VECTOR2I& aPos ) override { m_end = aPos; }
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I GetPosition() const override { return GetStart(); }
|
|
|
|
void SetPosition( const VECTOR2I& aPos ) override { SetStart( aPos ); }
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void PrintWsItem( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
|
2013-07-25 18:58:46 +00:00
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I GetBoundingBox() const override;
|
2022-01-01 06:04:08 +00:00
|
|
|
|
|
|
|
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
|
2022-08-31 09:33:46 +00:00
|
|
|
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2023-01-12 03:27:44 +00:00
|
|
|
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) 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
|
2020-12-21 23:42:21 +00:00
|
|
|
|
|
|
|
private:
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I m_start; // start point of line/rect
|
|
|
|
VECTOR2I m_end; // end point
|
2013-05-22 08:45:25 +00:00
|
|
|
};
|
|
|
|
|
2019-06-07 10:42:28 +00:00
|
|
|
|
2020-12-21 23:42:21 +00:00
|
|
|
/**
|
|
|
|
* A rectangle with thick segment showing the page limits and a marker showing the coordinate
|
|
|
|
* origin.
|
|
|
|
*
|
2021-02-22 23:47:17 +00:00
|
|
|
* This only a draw item only. Therefore m_peer ( the parent DS_DATA_ITEM item in the
|
|
|
|
* DS_DATA_MODEL) is always a nullptr.
|
2020-12-21 23:42:21 +00:00
|
|
|
*/
|
2021-02-22 23:47:17 +00:00
|
|
|
class DS_DRAW_ITEM_PAGE : public DS_DRAW_ITEM_BASE
|
2019-06-07 10:42:28 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DRAW_ITEM_PAGE( int aPenWidth, double aMarkerSize ) :
|
|
|
|
DS_DRAW_ITEM_BASE( nullptr, 0, WSG_PAGE_T )
|
2019-06-07 10:42:28 +00:00
|
|
|
{
|
|
|
|
m_penWidth = aPenWidth;
|
|
|
|
m_markerSize = aMarkerSize;
|
|
|
|
}
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
virtual wxString GetClass() const override { return wxT( "DS_DRAW_ITEM_PAGE" ); }
|
2019-06-07 10:42:28 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void SetPageSize( const VECTOR2I& aSize ) { m_pageSize = aSize; }
|
|
|
|
VECTOR2I GetPageSize() const { return m_pageSize; }
|
|
|
|
|
|
|
|
const VECTOR2I& GetMarkerPos() const { return m_markerPos; }
|
|
|
|
void SetMarkerPos( const VECTOR2I& aPos ) { m_markerPos = aPos; }
|
|
|
|
|
2019-06-07 10:42:28 +00:00
|
|
|
double GetMarkerSize() const { return m_markerSize; }
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I GetPosition() const override { return VECTOR2I( 0, 0 ); }
|
|
|
|
void SetPosition( const VECTOR2I& aPos ) override { /* do nothing */ }
|
2019-06-07 10:42:28 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void PrintWsItem( const RENDER_SETTINGS* , const VECTOR2I& ) override { /* do nothing */ }
|
2019-06-07 10:42:28 +00:00
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I GetBoundingBox() const override;
|
2022-01-01 06:04:08 +00:00
|
|
|
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override { return false; }
|
2019-06-07 10:42:28 +00:00
|
|
|
|
2023-01-12 03:27:44 +00:00
|
|
|
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) 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
|
2020-12-21 23:42:21 +00:00
|
|
|
|
|
|
|
private:
|
2023-03-13 11:25:30 +00:00
|
|
|
VECTOR2I m_markerPos; // position of the marker
|
|
|
|
VECTOR2I m_pageSize; // full size of the page
|
|
|
|
double m_markerSize;
|
2019-06-07 10:42:28 +00:00
|
|
|
};
|
|
|
|
|
2020-10-18 20:30:37 +00:00
|
|
|
|
2020-12-21 23:42:21 +00:00
|
|
|
/**
|
|
|
|
* A graphic text.
|
|
|
|
*
|
|
|
|
* It is derived from an #EDA_TEXT, so it handle all characteristics of this graphic text
|
|
|
|
* (justification, rotation ... ).
|
|
|
|
*/
|
2021-02-22 23:47:17 +00:00
|
|
|
class DS_DRAW_ITEM_TEXT : public DS_DRAW_ITEM_BASE, public EDA_TEXT
|
2013-05-22 08:45:25 +00:00
|
|
|
{
|
|
|
|
public:
|
2023-06-12 21:33:55 +00:00
|
|
|
DS_DRAW_ITEM_TEXT( const EDA_IU_SCALE& aIuScale, DS_DATA_ITEM* aPeer, int aIndex,
|
|
|
|
const wxString& aText, const VECTOR2I& aPos, const VECTOR2I& aSize,
|
|
|
|
int aPenWidth, KIFONT::FONT* aFont,
|
2022-03-31 18:43:08 +00:00
|
|
|
bool aItalic = false, bool aBold = false,
|
|
|
|
const KIGFX::COLOR4D& aColor = KIGFX::COLOR4D::UNSPECIFIED ) :
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DRAW_ITEM_BASE( aPeer, aIndex, WSG_TEXT_T),
|
2023-06-12 21:33:55 +00:00
|
|
|
EDA_TEXT( aIuScale, aText )
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
|
|
|
SetTextPos( aPos );
|
2022-08-28 13:44:31 +00:00
|
|
|
SetTextSize( aSize );
|
2020-04-14 12:25:00 +00:00
|
|
|
SetTextThickness( aPenWidth );
|
2022-02-28 18:02:00 +00:00
|
|
|
SetFont( aFont );
|
2019-05-20 10:23:32 +00:00
|
|
|
SetItalic( aItalic );
|
|
|
|
SetBold( aBold );
|
2022-03-31 18:43:08 +00:00
|
|
|
SetTextColor( aColor );
|
2019-05-20 10:23:32 +00:00
|
|
|
}
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
virtual wxString GetClass() const override { return wxT( "DS_DRAW_ITEM_TEXT" ); }
|
2013-07-25 18:58:46 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void PrintWsItem( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
|
2013-05-22 08:45:25 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I GetPosition() const override { return GetTextPos(); }
|
|
|
|
void SetPosition( const VECTOR2I& aPos ) override { SetTextPos( aPos ); }
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2023-05-27 15:30:12 +00:00
|
|
|
virtual const BOX2I GetApproxBBox() override;
|
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I GetBoundingBox() const override;
|
2022-01-01 06:04:08 +00:00
|
|
|
|
|
|
|
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
|
2022-08-31 09:33:46 +00:00
|
|
|
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
2016-06-11 13:51:05 +00:00
|
|
|
|
2023-01-12 03:27:44 +00:00
|
|
|
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) 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
|
2023-08-06 19:20:53 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
|
2013-05-22 08:45:25 +00:00
|
|
|
};
|
|
|
|
|
2020-10-18 20:30:37 +00:00
|
|
|
|
2020-12-21 23:42:21 +00:00
|
|
|
/**
|
|
|
|
* A bitmap.
|
|
|
|
*/
|
2021-02-22 23:47:17 +00:00
|
|
|
class DS_DRAW_ITEM_BITMAP : public DS_DRAW_ITEM_BASE
|
2013-10-18 17:38:03 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-01-01 06:04:08 +00:00
|
|
|
DS_DRAW_ITEM_BITMAP( DS_DATA_ITEM* aPeer, int aIndex, VECTOR2I aPos ) :
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DRAW_ITEM_BASE( aPeer, aIndex, WSG_BITMAP_T )
|
2013-10-18 17:38:03 +00:00
|
|
|
{
|
|
|
|
m_pos = aPos;
|
|
|
|
}
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
~DS_DRAW_ITEM_BITMAP() {}
|
2013-10-18 17:38:03 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
virtual wxString GetClass() const override { return wxT( "DS_DRAW_ITEM_BITMAP" ); }
|
2013-10-18 17:38:03 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I GetPosition() const override { return m_pos; }
|
2022-10-22 12:59:32 +00:00
|
|
|
void SetPosition( const VECTOR2I& aPos ) override { m_pos = aPos; }
|
2013-10-18 17:38:03 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void PrintWsItem( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
|
2016-06-11 13:51:05 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
|
2022-08-31 09:33:46 +00:00
|
|
|
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
2022-10-22 12:59:32 +00:00
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I GetBoundingBox() const override;
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2023-01-12 03:27:44 +00:00
|
|
|
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) 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
|
2020-12-21 23:42:21 +00:00
|
|
|
|
|
|
|
private:
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I m_pos; // position of reference point
|
2013-10-18 17:38:03 +00:00
|
|
|
};
|
|
|
|
|
2020-10-18 20:30:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Store the list of graphic items:
|
2013-05-24 08:59:40 +00:00
|
|
|
* 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
|
|
|
*/
|
2021-02-22 23:47:17 +00:00
|
|
|
class DS_DRAW_ITEM_LIST
|
2013-05-22 08:45:25 +00:00
|
|
|
{
|
|
|
|
public:
|
2023-06-12 21:33:55 +00:00
|
|
|
DS_DRAW_ITEM_LIST( const EDA_IU_SCALE& aIuScale ) :
|
|
|
|
m_iuScale( aIuScale )
|
2013-05-22 08:45:25 +00:00
|
|
|
{
|
|
|
|
m_idx = 0;
|
2023-06-12 21:33:55 +00:00
|
|
|
m_plotterMilsToIu = 0.0;
|
2013-05-22 15:08:57 +00:00
|
|
|
m_penSize = 1;
|
2020-10-18 20:30:37 +00:00
|
|
|
m_pageNumber = "1";
|
2013-05-24 08:59:40 +00:00
|
|
|
m_sheetCount = 1;
|
2018-03-10 09:25:07 +00:00
|
|
|
m_titleBlock = nullptr;
|
2020-03-26 11:02:59 +00:00
|
|
|
m_project = nullptr;
|
2020-10-18 20:30:37 +00:00
|
|
|
m_isFirstPage = true;
|
2022-09-20 14:25:03 +00:00
|
|
|
m_properties = nullptr;
|
2013-05-22 08:45:25 +00:00
|
|
|
}
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
~DS_DRAW_ITEM_LIST()
|
2013-05-22 08:45:25 +00:00
|
|
|
{
|
2021-05-30 22:56:24 +00:00
|
|
|
// Items in the m_graphicList are owned by their respective DS_DATA_ITEMs.
|
2021-02-22 23:47:17 +00:00
|
|
|
// for( DS_DRAW_ITEM_BASE* item : m_graphicList )
|
2019-05-20 10:23:32 +00:00
|
|
|
// 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
|
|
|
/**
|
2021-02-22 16:37:43 +00:00
|
|
|
* Set the title block (mainly for drawing sheet editor)
|
2019-06-15 16:15:29 +00:00
|
|
|
*/
|
|
|
|
void SetTitleBlock( const TITLE_BLOCK* aTblock ) { m_titleBlock = aTblock; }
|
|
|
|
|
2022-09-20 14:25:03 +00:00
|
|
|
/**
|
|
|
|
* Set properties used for text variable resolution.
|
|
|
|
*/
|
|
|
|
void SetProperties( const std::map<wxString, wxString>* aProps ) { m_properties = aProps; }
|
|
|
|
|
2019-06-15 16:15:29 +00:00
|
|
|
/**
|
2021-02-22 16:37:43 +00:00
|
|
|
* Set the paper format name (mainly for drawing sheet editor)
|
2019-06-15 16:15:29 +00:00
|
|
|
*/
|
2023-01-18 01:16:57 +00:00
|
|
|
void SetPaperFormat( const wxString& aFormatName ) { m_paperFormat = aFormatName; }
|
2019-06-15 16:15:29 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
/**
|
|
|
|
* Set the filename to draw/plot
|
|
|
|
*/
|
2022-10-22 12:59:32 +00:00
|
|
|
void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the sheet name to draw/plot
|
|
|
|
*/
|
2022-10-22 12:59:32 +00:00
|
|
|
void SetSheetName( const wxString& aSheetName ) { m_sheetName = aSheetName; }
|
2022-04-09 14:38:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the sheet path to draw/plot
|
|
|
|
*/
|
2022-10-22 12:59:32 +00:00
|
|
|
void SetSheetPath( const wxString& aSheetPath ) { m_sheetPath = aSheetPath; }
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2016-09-10 18:06:31 +00:00
|
|
|
/**
|
|
|
|
* Set the sheet layer to draw/plot
|
|
|
|
*/
|
2023-01-18 01:16:57 +00:00
|
|
|
void SetSheetLayer( const wxString& aSheetLayer ) { m_sheetLayer = aSheetLayer; }
|
2016-09-10 18:06:31 +00:00
|
|
|
|
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
|
|
|
/**
|
2023-06-12 21:33:55 +00:00
|
|
|
* Set the scalar to convert pages units (mils) to plot units.
|
2013-05-22 08:45:25 +00:00
|
|
|
*/
|
2023-06-12 21:33:55 +00:00
|
|
|
void SetPlotterMilsToIUfactor( double aMils2Iu ) { m_plotterMilsToIu = aMils2Iu; }
|
2013-05-22 08:45:25 +00:00
|
|
|
|
2020-11-28 09:53:26 +00:00
|
|
|
/**
|
2023-06-12 21:33:55 +00:00
|
|
|
* Get the scalar to convert pages units (mils) to draw/plot units.
|
|
|
|
*
|
|
|
|
* This will be controlled by EITHER the parent frame's EDA_IU_SCALE or the plotter's
|
|
|
|
* mils-to-iu factor.
|
2020-11-28 09:53:26 +00:00
|
|
|
*/
|
2023-06-12 21:33:55 +00:00
|
|
|
double GetMilsToIUfactor()
|
|
|
|
{
|
|
|
|
if( m_plotterMilsToIu > 0.0 )
|
|
|
|
return m_plotterMilsToIu;
|
|
|
|
else
|
|
|
|
return m_iuScale.IU_PER_MILS;
|
|
|
|
}
|
|
|
|
|
|
|
|
const EDA_IU_SCALE& GetIuScale() const { return m_iuScale; }
|
2020-11-28 09:53:26 +00:00
|
|
|
|
2013-05-24 08:59:40 +00:00
|
|
|
/**
|
2020-10-18 20:30:37 +00:00
|
|
|
* Set the value of the sheet number.
|
2013-05-24 08:59:40 +00:00
|
|
|
*/
|
2022-10-22 12:59:32 +00:00
|
|
|
void SetPageNumber( const wxString& aPageNumber ) { m_pageNumber = aPageNumber; }
|
2013-05-24 08:59:40 +00:00
|
|
|
|
|
|
|
/**
|
2020-10-18 20:30:37 +00:00
|
|
|
* Set if the page is the first page.
|
|
|
|
*/
|
|
|
|
void SetIsFirstPage( bool aIsFirstPage ) { m_isFirstPage = aIsFirstPage; }
|
|
|
|
|
|
|
|
/**
|
2013-05-24 08:59:40 +00:00
|
|
|
* Set the value of the count of sheets, for basic inscriptions
|
|
|
|
*/
|
2022-10-22 12:59:32 +00:00
|
|
|
void SetSheetCount( int aSheetCount ) { m_sheetCount = aSheetCount; }
|
2013-05-24 08:59:40 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
void Append( DS_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
|
|
|
}
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
void Remove( DS_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
|
|
|
}
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DRAW_ITEM_BASE* GetFirst()
|
2013-05-22 08:45:25 +00:00
|
|
|
{
|
|
|
|
m_idx = 0;
|
|
|
|
|
|
|
|
if( m_graphicList.size() )
|
|
|
|
return m_graphicList[0];
|
|
|
|
else
|
2021-07-15 19:26:35 +00:00
|
|
|
return nullptr;
|
2013-05-22 08:45:25 +00:00
|
|
|
}
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DRAW_ITEM_BASE* GetNext()
|
2013-05-22 08:45:25 +00:00
|
|
|
{
|
|
|
|
m_idx++;
|
|
|
|
|
|
|
|
if( m_graphicList.size() > m_idx )
|
|
|
|
return m_graphicList[m_idx];
|
|
|
|
else
|
2021-07-15 19:26:35 +00:00
|
|
|
return nullptr;
|
2013-05-22 08:45:25 +00:00
|
|
|
}
|
|
|
|
|
2013-06-29 09:52:22 +00:00
|
|
|
/**
|
2021-02-22 16:37:43 +00:00
|
|
|
* Draws the item list created by BuildDrawItemsList
|
2013-06-29 09:52:22 +00:00
|
|
|
*/
|
2020-12-20 18:18:54 +00:00
|
|
|
void Print( const RENDER_SETTINGS* aSettings );
|
2013-06-29 09:52:22 +00:00
|
|
|
|
2013-05-22 08:45:25 +00:00
|
|
|
/**
|
2021-05-30 22:56:24 +00:00
|
|
|
* Drawing or plot the drawing sheet.
|
2019-05-20 10:23:32 +00:00
|
|
|
*
|
|
|
|
* Before calling this function, some parameters should be initialized by calling:
|
2013-07-19 18:27:22 +00:00
|
|
|
* SetPenSize( aPenWidth );
|
|
|
|
* SetSheetNumber( aSheetNumber );
|
|
|
|
* SetSheetCount( aSheetCount );
|
|
|
|
* SetFileName( aFileName );
|
2022-04-09 14:38:47 +00:00
|
|
|
* SetSheetName( aSheetName );
|
|
|
|
* SetSheetPath( aSheetPath );
|
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
|
|
|
*/
|
2021-02-22 16:37:43 +00:00
|
|
|
void BuildDrawItemsList( const PAGE_INFO& aPageInfo, const TITLE_BLOCK& aTitleBlock );
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2020-05-30 09:22:19 +00:00
|
|
|
static void GetTextVars( wxArrayString* aVars );
|
|
|
|
|
2013-05-25 09:01:44 +00:00
|
|
|
/**
|
2022-09-20 14:25:03 +00:00
|
|
|
* @return the full text corresponding to the aTextbase, after replacing any text variable
|
|
|
|
* references.
|
2013-05-25 09:01:44 +00:00
|
|
|
*/
|
|
|
|
wxString BuildFullText( const wxString& aTextbase );
|
2020-12-21 23:42:21 +00:00
|
|
|
|
|
|
|
protected:
|
2021-02-22 23:47:17 +00:00
|
|
|
std::vector <DS_DRAW_ITEM_BASE*> m_graphicList; // Items to draw/plot
|
2023-06-12 21:33:55 +00:00
|
|
|
const EDA_IU_SCALE& m_iuScale; // IU scale for drawing
|
|
|
|
double m_plotterMilsToIu; // IU scale for plotting
|
|
|
|
|
2020-12-21 23:42:21 +00:00
|
|
|
unsigned m_idx; // for GetFirst, GetNext functions
|
|
|
|
int m_penSize; // The default line width for drawings.
|
|
|
|
// used when an item has a pen size = 0
|
|
|
|
bool m_isFirstPage; ///< Is this the first page or not.
|
|
|
|
int m_sheetCount; ///< The number of sheets
|
2022-09-20 14:25:03 +00:00
|
|
|
// for text variable references, in schematic
|
|
|
|
const TITLE_BLOCK* m_titleBlock; // for text variable references
|
2023-01-18 01:16:57 +00:00
|
|
|
wxString m_paperFormat; // for text variable references
|
2022-09-20 14:25:03 +00:00
|
|
|
wxString m_fileName; // for text variable references
|
|
|
|
wxString m_sheetName; // for text variable references
|
|
|
|
wxString m_sheetPath; // for text variable references
|
2020-12-21 23:42:21 +00:00
|
|
|
wxString m_pageNumber; ///< The actual page number displayed in the title block.
|
2023-01-18 01:16:57 +00:00
|
|
|
wxString m_sheetLayer; // for text variable references
|
2022-09-20 14:25:03 +00:00
|
|
|
const PROJECT* m_project; // for project-based text variable references
|
|
|
|
|
|
|
|
const std::map<wxString, wxString>* m_properties; // for text variable references
|
2013-05-22 08:45:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
#endif // DS_DRAW_ITEM_H
|