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 (C) 1992-2023 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_MODEL_H
26#define DS_DATA_MODEL_H
27
28#include <math/vector2d.h>
29#include <eda_text.h>
30#include <bitmap_base.h>
31
32class DS_DATA_ITEM;
33class PAGE_INFO;
34
39{
40public:
42
44 {
45 ClearList();
46 }
47
52
58 static void SetAltInstance( DS_DATA_MODEL* aLayout = nullptr );
59
61 void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
62
63 double GetLeftMargin() { return m_leftMargin; }
64 void SetLeftMargin( double aMargin ) { m_leftMargin = aMargin; }
65
66 double GetRightMargin() { return m_rightMargin; }
67 void SetRightMargin( double aMargin ) { m_rightMargin = aMargin; }
68
69 double GetTopMargin() { return m_topMargin; }
70 void SetTopMargin( double aMargin ) { m_topMargin = aMargin; }
71
72 double GetBottomMargin() { return m_bottomMargin; }
73 void SetBottomMargin( double aMargin ) { m_bottomMargin = aMargin; }
74
75 void SetupDrawEnvironment( const PAGE_INFO& aPageInfo, double aMilsToIU );
76
83 void AllowVoidList( bool Allow ) { m_allowVoidList = Allow; }
84
89
93 void ClearList();
94
100 void Save( const wxString& aFullFileName );
101
107 void SaveInString( wxString* aOutputString );
108
112 void SaveInString( std::vector<DS_DATA_ITEM*>& aItemsList, wxString* aOutputString );
113
114 void Append( DS_DATA_ITEM* aItem );
115 void Remove( DS_DATA_ITEM* aItem );
116
120 DS_DATA_ITEM* GetItem( unsigned aIdx ) const;
121
125 std::vector<DS_DATA_ITEM*>& GetItems() { return m_list; }
126
130 unsigned GetCount() const { return m_list.size(); }
131
132 void SetDefaultLayout();
133 void SetEmptyLayout();
134
138 static wxString EmptyLayout();
139
143 static wxString DefaultLayout();
144
154 bool LoadDrawingSheet( const wxString& aFullFileName = wxEmptyString, bool Append = 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 double m_leftMargin; // the left page margin in mm
192 double m_rightMargin; // the right page margin in mm
193 double m_topMargin; // the top page margin in mm
194 double m_bottomMargin; // the bottom page margin in mm
195};
196
197#endif // DS_DATA_MODEL_H
Drawing sheet structure type definitions.
Definition: ds_data_item.h:96
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:39
void SetBottomMargin(double aMargin)
Definition: ds_data_model.h:73
std::vector< DS_DATA_ITEM * > m_list
double GetRightMargin()
Definition: ds_data_model.h:66
void SetupDrawEnvironment(const PAGE_INFO &aPageInfo, double aMilsToIU)
VECTOR2D m_DefaultTextSize
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
double GetTopMargin()
Definition: ds_data_model.h:69
void SetRightMargin(double aMargin)
Definition: ds_data_model.h:67
unsigned GetCount() const
double m_rightMargin
double m_DefaultLineWidth
DS_DATA_ITEM * GetItem(unsigned aIdx) const
static wxString DefaultLayout()
Return a string containing the empty layout shape.
double GetBottomMargin()
Definition: ds_data_model.h:72
double m_bottomMargin
double GetLeftMargin()
Definition: ds_data_model.h:63
static wxString EmptyLayout()
Return a string containing the empty layout shape.
void SetLeftMargin(double aMargin)
Definition: ds_data_model.h:64
double m_DefaultTextThickness
VECTOR2D m_RB_Corner
double m_WSunits2Iu
void Append(DS_DATA_ITEM *aItem)
bool VoidListAllowed()
Definition: ds_data_model.h:88
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 ...
Definition: ds_data_model.h:83
void ClearList()
Erase the list of items.
void Remove(DS_DATA_ITEM *aItem)
VECTOR2D m_LT_Corner
int GetFileFormatVersionAtLoad()
Definition: ds_data_model.h:60
double m_leftMargin
void SetTopMargin(double aMargin)
Definition: ds_data_model.h:70
std::vector< DS_DATA_ITEM * > & GetItems()
void SetFileFormatVersionAtLoad(int aVersion)
Definition: ds_data_model.h:61
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.
double m_topMargin
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.
bool LoadDrawingSheet(const wxString &aFullFileName=wxEmptyString, bool Append=false)
Populates the list with a custom layout or the default layout if no custom layout is available.
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:59