KiCad PCB EDA Suite
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-2020 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 
32 class DS_DATA_ITEM;
33 class PAGE_INFO;
34 
39 {
40 public:
41  DS_DATA_MODEL();
42 
44  {
45  ClearList();
46  }
47 
51  static DS_DATA_MODEL& GetTheInstance();
52 
58  static void SetAltInstance( DS_DATA_MODEL* aLayout = NULL );
59 
60  double GetLeftMargin() { return m_leftMargin; }
61  void SetLeftMargin( double aMargin ) { m_leftMargin = aMargin; }
62 
63  double GetRightMargin() { return m_rightMargin; }
64  void SetRightMargin( double aMargin ) { m_rightMargin = aMargin; }
65 
66  double GetTopMargin() { return m_topMargin; }
67  void SetTopMargin( double aMargin ) { m_topMargin = aMargin; }
68 
69  double GetBottomMargin() { return m_bottomMargin; }
70  void SetBottomMargin( double aMargin ) { m_bottomMargin = aMargin; }
71 
72  void SetupDrawEnvironment( const PAGE_INFO& aPageInfo, double aMilsToIU );
73 
81  void AllowVoidList( bool Allow ) { m_allowVoidList = Allow; }
82 
86  bool VoidListAllowed() { return m_allowVoidList; }
87 
91  void ClearList();
92 
98  void Save( const wxString& aFullFileName );
99 
105  void SaveInString( wxString& aOutputString );
106 
110  void SaveInString( std::vector<DS_DATA_ITEM*> aItemsList, wxString& aOutputString );
111 
112  void Append( DS_DATA_ITEM* aItem );
113  void Remove( DS_DATA_ITEM* aItem );
114 
118  int GetItemIndex( DS_DATA_ITEM* aItem ) const;
119 
123  DS_DATA_ITEM* GetItem( unsigned aIdx ) const;
124 
128  std::vector<DS_DATA_ITEM*>& GetItems() { return m_list; }
129 
133  unsigned GetCount() const { return m_list.size(); }
134 
135  void SetDefaultLayout();
136  void SetEmptyLayout();
137 
141  static wxString EmptyLayout();
142 
146  static wxString DefaultLayout();
147 
157  void LoadDrawingSheet( const wxString& aFullFileName = wxEmptyString, bool Append = false );
158 
167  void SetPageLayout( const char* aPageLayout, bool aAppend = false,
168  const wxString& aSource = wxT( "Sexpr_string" ) );
169 
178  static const wxString MakeShortFileName( const wxString& aFullFileName,
179  const wxString& aProjectPath );
180 
191  static const wxString MakeFullFileName( const wxString& aShortFileName,
192  const wxString& aProjectPath );
193 
194  double m_WSunits2Iu; // conversion factor between
195  // ws units (mils) and draw/plot units
196  DPOINT m_RB_Corner; // coordinates of the right bottom corner (in mm)
197  DPOINT m_LT_Corner; // coordinates of the left top corner (in mm)
198  double m_DefaultLineWidth; // Used when object line width is 0
199  DSIZE m_DefaultTextSize; // Used when object text size is 0
200  double m_DefaultTextThickness; // Used when object text stroke width is 0
201  bool m_EditMode; // Used in drawing sheet editor to toggle variable substitution
202  // In normal mode (m_EditMode = false) the %format is
203  // replaced by the corresponding text.
204  // In edit mode (m_EditMode = true) the %format is
205  // displayed "as this"
206 
207 private:
208  std::vector <DS_DATA_ITEM*> m_list;
209  bool m_allowVoidList; // If false, the default page layout will be loaded the
210  // first time DS_DRAW_ITEM_LIST::BuildDrawItemsList
211  // is run (useful mainly for drawing sheet editor)
212  double m_leftMargin; // the left page margin in mm
213  double m_rightMargin; // the right page margin in mm
214  double m_topMargin; // the top page margin in mm
215  double m_bottomMargin; // the bottom page margin in mm
216 
217 
218 };
219 
220 #endif // DS_DATA_MODEL_H
void ClearList()
Erase the list of items.
std::vector< DS_DATA_ITEM * > m_list
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:38
void 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 void SetAltInstance(DS_DATA_MODEL *aLayout=NULL)
Set an alternate instance of DS_DATA_MODEL.
double GetRightMargin()
Definition: ds_data_model.h:63
static wxString DefaultLayout()
Return a string containing the empty layout shape.
void SetBottomMargin(double aMargin)
Definition: ds_data_model.h:70
double m_DefaultLineWidth
double GetTopMargin()
Definition: ds_data_model.h:66
void SetLeftMargin(double aMargin)
Definition: ds_data_model.h:61
std::vector< DS_DATA_ITEM * > & GetItems()
double GetLeftMargin()
Definition: ds_data_model.h:60
DPOINT m_RB_Corner
void SetRightMargin(double aMargin)
Definition: ds_data_model.h:64
double m_topMargin
void Save(const wxString &aFullFileName)
Save the description in a file.
DPOINT m_LT_Corner
double m_DefaultTextThickness
int GetItemIndex(DS_DATA_ITEM *aItem) const
double m_bottomMargin
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
#define NULL
DSIZE m_DefaultTextSize
void AllowVoidList(bool Allow)
In KiCad applications, a page layout description is needed So if the list is empty,...
Definition: ds_data_model.h:81
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:53
double GetBottomMargin()
Definition: ds_data_model.h:69
static const wxString MakeShortFileName(const wxString &aFullFileName, const wxString &aProjectPath)
void SetTopMargin(double aMargin)
Definition: ds_data_model.h:67
double m_leftMargin
static wxString EmptyLayout()
Return a string containing the empty layout shape.
double m_WSunits2Iu
double m_rightMargin
void SaveInString(wxString &aOutputString)
Save the description in a buffer.
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.
DS_DATA_ITEM * GetItem(unsigned aIdx) const
Drawing sheet structure type definitions.
Definition: ds_data_item.h:95
static const wxString MakeFullFileName(const wxString &aShortFileName, const wxString &aProjectPath)
void SetupDrawEnvironment(const PAGE_INFO &aPageInfo, double aMilsToIU)
unsigned GetCount() const
bool VoidListAllowed()
Definition: ds_data_model.h:86
void Remove(DS_DATA_ITEM *aItem)
void Append(DS_DATA_ITEM *aItem)