KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ds_data_item.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2013-2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef DS_DATA_ITEM_H
26#define DS_DATA_ITEM_H
27
28#include <math/vector2d.h>
29#include <eda_text.h>
30#include <bitmap_base.h>
32
33class DS_DRAW_ITEM_TEXT; // Forward declaration
34
35#define TB_DEFAULT_TEXTSIZE 1.5 // default drawing sheet text size in mm
36
37namespace KIGFX
38{
39class VIEW;
40}
41
48{
49 RB_CORNER, // right bottom corner
50 RT_CORNER, // right top corner
51 LB_CORNER, // left bottom corner
52 LT_CORNER, // left top corner
53};
54
56{
60};
61
70{
71public:
73
74 POINT_COORD( const VECTOR2D& aPos, enum CORNER_ANCHOR aAnchor = RB_CORNER )
75 {
76 m_Pos = aPos;
77 m_Anchor = aAnchor;
78 }
79
82};
83
84
96{
97public:
104 };
105
106 DS_DATA_ITEM( DS_ITEM_TYPE aType );
107
108 virtual ~DS_DATA_ITEM();
109
110 const std::vector<DS_DRAW_ITEM_BASE*>& GetDrawItems() const { return m_drawItems; }
111
112 virtual void SyncDrawItems( DS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView );
113
114 void SetStart( double aPosx, double aPosy, enum CORNER_ANCHOR aAnchor = RB_CORNER )
115 {
116 m_Pos.m_Pos.x = aPosx;
117 m_Pos.m_Pos.y = aPosy;
118 m_Pos.m_Anchor = aAnchor;
119 }
120
121 void SetEnd( double aPosx, double aPosy, enum CORNER_ANCHOR aAnchor = RB_CORNER )
122 {
123 m_End.m_Pos.x = aPosx;
124 m_End.m_Pos.y = aPosy;
125 m_End.m_Anchor = aAnchor;
126 }
127
128 DS_ITEM_TYPE GetType() const { return m_type; }
129
134 void SetPage1Option( PAGE_OPTION aChoice ) { m_pageOption = aChoice; }
135
136 // Coordinate handling
137 const VECTOR2I GetStartPosIU( int ii = 0 ) const;
138 const VECTOR2I GetEndPosIU( int ii = 0 ) const;
139 const VECTOR2D GetStartPos( int ii = 0 ) const;
140 const VECTOR2D GetEndPos( int ii = 0 ) const;
141
142 virtual int GetPenSizeIU();
143
149 void MoveTo( const VECTOR2D& aPosition );
150
156 void MoveToIU( const VECTOR2I& aPosition );
157
163 void MoveStartPointTo( const VECTOR2D& aPosition );
164
170 void MoveStartPointToIU( const VECTOR2I& aPosition );
171
172
180 void MoveEndPointTo( const VECTOR2D& aPosition );
181
189 void MoveEndPointToIU( const VECTOR2I& aPosition );
190
194 virtual bool IsInsidePage( int ii ) const;
195
196 const wxString GetClassName() const;
197
198 wxString m_Name; // a name used in drawing sheet editor to identify items
199 wxString m_Info; // a comment, only useful in drawing sheet editor
203 int m_RepeatCount; // repeat count for duplicate items
204 VECTOR2D m_IncrementVector; // for duplicate items: move vector for position increment
206
207protected:
210
211 std::vector<DS_DRAW_ITEM_BASE*> m_drawItems;
212};
213
214
216{
217public:
219
220 void SyncDrawItems( DS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView ) override;
221
222 virtual int GetPenSizeIU() override;
223
229 void AppendCorner( const VECTOR2D& aCorner )
230 {
231 m_Corners.push_back( aCorner );
232 }
233
239 {
240 m_polyIndexEnd.push_back( m_Corners.size() -1 );
241 }
242
246 int GetPolyCount() const { return (int) m_polyIndexEnd.size(); }
247
252 unsigned GetPolyIndexStart( unsigned aContour ) const
253 {
254 if( aContour == 0 )
255 return 0;
256 else
257 return m_polyIndexEnd[aContour-1] + 1;
258 }
259
264 unsigned GetPolyIndexEnd( unsigned aContour ) const
265 {
266 return m_polyIndexEnd[aContour];
267 }
268
272 const VECTOR2D GetCornerPosition( unsigned aIdx, int aRepeat = 0 ) const;
273
278 const VECTOR2I GetCornerPositionIU( unsigned aIdx, int aRepeat = 0 ) const;
279
283 void SetBoundingBox();
284
285 bool IsInsidePage( int ii ) const override;
286
287 EDA_ANGLE m_Orient; // Orientation
288 std::vector<VECTOR2D> m_Corners; // corner list
289
290private:
291 std::vector<unsigned> m_polyIndexEnd; // index of the last point of each polygon
292 VECTOR2D m_minCoord; // min coord of corners, relative to m_Pos
293 VECTOR2D m_maxCoord; // max coord of corners, relative to m_Pos
294};
295
296
298{
299public:
300 DS_DATA_ITEM_TEXT( const wxString& aTextBase );
301
302 void SyncDrawItems( DS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView ) override;
303
304 virtual int GetPenSizeIU() override;
305
315 void IncrementLabel( int aIncr );
316
326
333
334public:
335 wxString m_TextBase; // The basic text, with format symbols
336 wxString m_FullText; // The expanded text, shown on screen
337 double m_Orient; // Orientation in degrees
341 bool m_Bold;
345 VECTOR2D m_BoundingBoxSize; // When not null, this is the max size of the
346 // full text. The text size will be modified
347 // to keep the full text inside this bound.
348 VECTOR2D m_ConstrainedTextSize; // Actual text size, if constrained by
349 // the m_BoundingBoxSize constraint
350};
351
352
353class BITMAP_BASE;
354
356{
357public:
360 {
361 m_ImageBitmap = aImage;
362 }
363
364 void SyncDrawItems( DS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView ) override;
365
366 int GetPPI() const;
367 void SetPPI( int aBitmapPPI );
368
369public:
371};
372
373
374#endif // DS_DATA_ITEM_H
This class handle bitmap images in KiCad.
Definition: bitmap_base.h:48
BITMAP_BASE * m_ImageBitmap
Definition: ds_data_item.h:370
void SyncDrawItems(DS_DRAW_ITEM_LIST *aCollector, KIGFX::VIEW *aView) override
DS_DATA_ITEM_BITMAP(BITMAP_BASE *aImage)
Definition: ds_data_item.h:358
void SetPPI(int aBitmapPPI)
unsigned GetPolyIndexStart(unsigned aContour) const
Definition: ds_data_item.h:252
unsigned GetPolyIndexEnd(unsigned aContour) const
Definition: ds_data_item.h:264
int GetPolyCount() const
Definition: ds_data_item.h:246
const VECTOR2I GetCornerPositionIU(unsigned aIdx, int aRepeat=0) const
void SetBoundingBox()
Calculate the bounding box of the set polygons.
virtual int GetPenSizeIU() override
void SyncDrawItems(DS_DRAW_ITEM_LIST *aCollector, KIGFX::VIEW *aView) override
void CloseContour()
Close the current contour, by storing the index of the last corner of the current polygon in m_polyIn...
Definition: ds_data_item.h:238
bool IsInsidePage(int ii) const override
std::vector< unsigned > m_polyIndexEnd
Definition: ds_data_item.h:291
const VECTOR2D GetCornerPosition(unsigned aIdx, int aRepeat=0) const
void AppendCorner(const VECTOR2D &aCorner)
Add a corner in corner list.
Definition: ds_data_item.h:229
std::vector< VECTOR2D > m_Corners
Definition: ds_data_item.h:288
bool ReplaceAntiSlashSequence()
Replace the '\''n' sequence by EOL and the sequence '\''\' by only one '\' inside m_FullText.
void SyncDrawItems(DS_DRAW_ITEM_LIST *aCollector, KIGFX::VIEW *aView) override
void IncrementLabel(int aIncr)
Try to build text which is an increment of m_TextBase has meaning only if m_TextBase is a basic text ...
void SetConstrainedTextSize()
Calculate m_ConstrainedTextSize from m_TextSize to keep the X size and the full Y size of the text sm...
KIFONT::FONT * m_Font
Definition: ds_data_item.h:342
GR_TEXT_H_ALIGN_T m_Hjustify
Definition: ds_data_item.h:338
KIGFX::COLOR4D m_TextColor
Definition: ds_data_item.h:344
virtual int GetPenSizeIU() override
VECTOR2D m_BoundingBoxSize
Definition: ds_data_item.h:345
VECTOR2D m_ConstrainedTextSize
Definition: ds_data_item.h:348
GR_TEXT_V_ALIGN_T m_Vjustify
Definition: ds_data_item.h:339
Drawing sheet structure type definitions.
Definition: ds_data_item.h:96
PAGE_OPTION GetPage1Option() const
Definition: ds_data_item.h:133
virtual ~DS_DATA_ITEM()
void SetPage1Option(PAGE_OPTION aChoice)
Definition: ds_data_item.h:134
const VECTOR2D GetEndPos(int ii=0) const
void MoveStartPointToIU(const VECTOR2I &aPosition)
Move the starting point of the item to a new position.
const VECTOR2D GetStartPos(int ii=0) const
void MoveStartPointTo(const VECTOR2D &aPosition)
Move the starting point of the item to a new position.
void MoveEndPointTo(const VECTOR2D &aPosition)
Move the ending point of the item to a new position.
virtual int GetPenSizeIU()
void MoveEndPointToIU(const VECTOR2I &aPosition)
Move the ending point of the item to a new position.
DS_ITEM_TYPE GetType() const
Definition: ds_data_item.h:128
void MoveTo(const VECTOR2D &aPosition)
Move item to a new position.
void MoveToIU(const VECTOR2I &aPosition)
Move item to a new position.
std::vector< DS_DRAW_ITEM_BASE * > m_drawItems
Definition: ds_data_item.h:211
const wxString GetClassName() const
wxString m_Name
Definition: ds_data_item.h:198
const VECTOR2I GetStartPosIU(int ii=0) const
const VECTOR2I GetEndPosIU(int ii=0) const
void SetEnd(double aPosx, double aPosy, enum CORNER_ANCHOR aAnchor=RB_CORNER)
Definition: ds_data_item.h:121
VECTOR2D m_IncrementVector
Definition: ds_data_item.h:204
POINT_COORD m_Pos
Definition: ds_data_item.h:200
void SetStart(double aPosx, double aPosy, enum CORNER_ANCHOR aAnchor=RB_CORNER)
Definition: ds_data_item.h:114
wxString m_Info
Definition: ds_data_item.h:199
virtual void SyncDrawItems(DS_DRAW_ITEM_LIST *aCollector, KIGFX::VIEW *aView)
PAGE_OPTION m_pageOption
Definition: ds_data_item.h:209
DS_ITEM_TYPE m_type
Definition: ds_data_item.h:208
const std::vector< DS_DRAW_ITEM_BASE * > & GetDrawItems() const
Definition: ds_data_item.h:110
virtual bool IsInsidePage(int ii) const
double m_LineWidth
Definition: ds_data_item.h:202
POINT_COORD m_End
Definition: ds_data_item.h:201
int m_IncrementLabel
Definition: ds_data_item.h:205
Store the list of graphic items: rect, lines, polygons and texts to draw/plot the title block and fra...
Definition: ds_draw_item.h:401
A graphic text.
Definition: ds_draw_item.h:313
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:131
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
A coordinate point.
Definition: ds_data_item.h:70
VECTOR2D m_Pos
Definition: ds_data_item.h:80
POINT_COORD(const VECTOR2D &aPos, enum CORNER_ANCHOR aAnchor=RB_CORNER)
Definition: ds_data_item.h:74
PAGE_OPTION
Definition: ds_data_item.h:56
@ FIRST_PAGE_ONLY
Definition: ds_data_item.h:58
@ SUBSEQUENT_PAGES
Definition: ds_data_item.h:59
@ ALL_PAGES
Definition: ds_data_item.h:57
CORNER_ANCHOR
A coordinate is relative to a page corner.
Definition: ds_data_item.h:48
@ RB_CORNER
Definition: ds_data_item.h:49
@ RT_CORNER
Definition: ds_data_item.h:50
@ LT_CORNER
Definition: ds_data_item.h:52
@ LB_CORNER
Definition: ds_data_item.h:51
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
GR_TEXT_H_ALIGN_T
GR_TEXT_V_ALIGN_T