KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ds_data_model.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-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef DS_DATA_MODEL_H
22#define DS_DATA_MODEL_H
23
24#include <math/vector2d.h>
25#include <eda_text.h>
26#include <bitmap_base.h>
27
28class DS_DATA_ITEM;
29class PAGE_INFO;
30
35{
36public:
38
40 {
41 ClearList();
42 }
43
48
54 static void SetAltInstance( DS_DATA_MODEL* aLayout = nullptr );
55
57 void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
58
59 const wxString& GetGenerator() const { return m_generator; }
60 void SetGenerator( const wxString& aGenerator ) { m_generator = aGenerator; }
61
62 double GetLeftMargin() { return m_leftMargin; }
63 void SetLeftMargin( double aMargin ) { m_leftMargin = aMargin; }
64
65 double GetRightMargin() { return m_rightMargin; }
66 void SetRightMargin( double aMargin ) { m_rightMargin = aMargin; }
67
68 double GetTopMargin() { return m_topMargin; }
69 void SetTopMargin( double aMargin ) { m_topMargin = aMargin; }
70
71 double GetBottomMargin() { return m_bottomMargin; }
72 void SetBottomMargin( double aMargin ) { m_bottomMargin = aMargin; }
73
74 void SetupDrawEnvironment( const PAGE_INFO& aPageInfo, double aMilsToIU );
75
82 void AllowVoidList( bool Allow ) { m_allowVoidList = Allow; }
83
88
92 void ClearList();
93
99 void Save( const wxString& aFullFileName );
100
106 void SaveInString( wxString* aOutputString );
107
111 void SaveInString( std::vector<DS_DATA_ITEM*>& aItemsList, wxString* aOutputString );
112
113 void Append( DS_DATA_ITEM* aItem );
114 void Remove( DS_DATA_ITEM* aItem );
115
119 DS_DATA_ITEM* GetItem( unsigned aIdx ) const;
120
124 std::vector<DS_DATA_ITEM*>& GetItems() { return m_list; }
125
129 unsigned GetCount() const { return m_list.size(); }
130
131 void SetDefaultLayout();
132 void SetEmptyLayout();
133
137 static wxString EmptyLayout();
138
142 static wxString DefaultLayout();
143
154 bool LoadDrawingSheet( const wxString& aFullFileName, wxString* aMsg, bool aAppend = false );
155
164 void SetPageLayout( const char* aPageLayout, bool aAppend = false,
165 const wxString& aSource = wxT( "Sexpr_string" ) );
166
170 static const wxString ResolvePath( const wxString& aPath, const wxString& aProjectPath );
171
172 double m_WSunits2Iu; // conversion factor between
173 // ws units (mils) and draw/plot units
174 VECTOR2D m_RB_Corner; // coordinates of the right bottom corner (in mm)
175 VECTOR2D m_LT_Corner; // coordinates of the left top corner (in mm)
176 double m_DefaultLineWidth; // Used when object line width is 0
177 VECTOR2D m_DefaultTextSize; // Used when object text size is 0
178 double m_DefaultTextThickness; // Used when object text stroke width is 0
179 bool m_EditMode; // Used in drawing sheet editor to toggle variable substitution
180 // In normal mode (m_EditMode = false) the %format is
181 // replaced by the corresponding text.
182 // In edit mode (m_EditMode = true) the %format is
183 // displayed "as this"
184
185private:
186 std::vector <DS_DATA_ITEM*> m_list;
187 bool m_allowVoidList; // If false, the default drawing sheet will be loaded the
188 // first time DS_DRAW_ITEM_LIST::BuildDrawItemsList is run
189 // (useful mainly for drawing sheet editor)
191 wxString m_generator; // Tool name written in the generator field
192 double m_leftMargin; // the left page margin in mm
193 double m_rightMargin; // the right page margin in mm
194 double m_topMargin; // the top page margin in mm
195 double m_bottomMargin; // the bottom page margin in mm
196};
197
198#endif // DS_DATA_MODEL_H
Drawing sheet structure type definitions.
Handle the graphic items list to draw/plot the frame and title block.
bool LoadDrawingSheet(const wxString &aFullFileName, wxString *aMsg, bool aAppend=false)
Populate the list with a custom layout or the default layout if no custom layout is available.
void SetBottomMargin(double aMargin)
std::vector< DS_DATA_ITEM * > m_list
double GetRightMargin()
void SetupDrawEnvironment(const PAGE_INFO &aPageInfo, double aMilsToIU)
VECTOR2D m_DefaultTextSize
static DS_DATA_MODEL & GetTheInstance()
Return the instance of DS_DATA_MODEL used in the application.
double GetTopMargin()
void SetRightMargin(double aMargin)
unsigned GetCount() const
void SetGenerator(const wxString &aGenerator)
double m_DefaultLineWidth
DS_DATA_ITEM * GetItem(unsigned aIdx) const
static wxString DefaultLayout()
Return a string containing the empty layout shape.
double GetBottomMargin()
double m_bottomMargin
double GetLeftMargin()
static wxString EmptyLayout()
Return a string containing the empty layout shape.
void SetLeftMargin(double aMargin)
double m_DefaultTextThickness
VECTOR2D m_RB_Corner
void Append(DS_DATA_ITEM *aItem)
bool VoidListAllowed()
void SaveInString(wxString *aOutputString)
Save the description in a buffer.
void AllowVoidList(bool Allow)
In KiCad applications, a drawing sheet is needed So if the list is empty, a default drawing sheet is ...
wxString m_generator
const wxString & GetGenerator() const
void ClearList()
Erase the list of items.
void Remove(DS_DATA_ITEM *aItem)
VECTOR2D m_LT_Corner
int GetFileFormatVersionAtLoad()
void SetTopMargin(double aMargin)
std::vector< DS_DATA_ITEM * > & GetItems()
void SetFileFormatVersionAtLoad(int aVersion)
void SetPageLayout(const char *aPageLayout, bool aAppend=false, const wxString &aSource=wxT("Sexpr_string"))
Populate the list from a S expr description stored in a string.
static void SetAltInstance(DS_DATA_MODEL *aLayout=nullptr)
Set an alternate instance of DS_DATA_MODEL.
void Save(const wxString &aFullFileName)
Save the description in a file.
static const wxString ResolvePath(const wxString &aPath, const wxString &aProjectPath)
Resolve a path which might be project-relative or contain env variable references.
int m_fileFormatVersionAtLoad
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition page_info.h:75
VECTOR2< double > VECTOR2D
Definition vector2d.h:682