KiCad PCB EDA Suite
ws_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-2016 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 WS_DATA_MODEL_H
26 #define WS_DATA_MODEL_H
27 
28 #include <math/vector2d.h>
29 #include <eda_text.h>
30 #include <eda_text.h>
31 #include <bitmap_base.h>
32 #include <ws_data_item.h>
33 
34 
35 
40 {
41  std::vector <WS_DATA_ITEM*> m_list;
42  bool m_allowVoidList; // If false, the default page layout will be loaded the
43  // first time WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList
44  // is run (useful mainly for page layout editor)
45  double m_leftMargin; // the left page margin in mm
46  double m_rightMargin; // the right page margin in mm
47  double m_topMargin; // the top page margin in mm
48  double m_bottomMargin; // the bottom page margin in mm
49 
50 public:
51  double m_WSunits2Iu; // conversion factor between
52  // ws units (mils) and draw/plot units
53  DPOINT m_RB_Corner; // cordinates of the right bottom corner (in mm)
54  DPOINT m_LT_Corner; // cordinates of the left top corner (in mm)
55  double m_DefaultLineWidth; // Used when object line width is 0
56  DSIZE m_DefaultTextSize; // Used when object text size is 0
57  double m_DefaultTextThickness; // Used when object text stroke width is 0
58  bool m_EditMode; // Used in page layout editor to toggle variable substution
59  // In normal mode (m_EditMode = false) the %format is
60  // replaced by the corresponding text.
61  // In edit mode (m_EditMode = true) the %format is
62  // displayed "as this"
63 
64 public:
65  WS_DATA_MODEL();
67  {
68  ClearList();
69  }
70 
74  static WS_DATA_MODEL& GetTheInstance();
75 
81  static void SetAltInstance( WS_DATA_MODEL* aLayout = NULL );
82 
83  // Accessors:
84  double GetLeftMargin() { return m_leftMargin; }
85  void SetLeftMargin( double aMargin ) { m_leftMargin = aMargin; }
86 
87  double GetRightMargin() { return m_rightMargin; }
88  void SetRightMargin( double aMargin ) { m_rightMargin = aMargin; }
89 
90  double GetTopMargin() { return m_topMargin; }
91  void SetTopMargin( double aMargin ) { m_topMargin = aMargin; }
92 
93  double GetBottomMargin() { return m_bottomMargin; }
94  void SetBottomMargin( double aMargin ) { m_bottomMargin = aMargin; }
95 
96  void SetupDrawEnvironment( const PAGE_INFO& aPageInfo, double aMilsToIU );
97 
105  void AllowVoidList( bool Allow ) { m_allowVoidList = Allow; }
106 
111  bool VoidListAllowed() { return m_allowVoidList; }
112 
116  void ClearList();
117 
122  void Save( const wxString& aFullFileName );
123 
128  void SaveInString( wxString& aOutputString );
129 
133  void SaveInString( std::vector<WS_DATA_ITEM*> aItemsList, wxString& aOutputString );
134 
135  void Append( WS_DATA_ITEM* aItem );
136  void Remove( WS_DATA_ITEM* aItem );
137 
141  int GetItemIndex( WS_DATA_ITEM* aItem ) const;
142 
146  WS_DATA_ITEM* GetItem( unsigned aIdx ) const;
147 
151  std::vector<WS_DATA_ITEM*>& GetItems() { return m_list; }
152 
156  unsigned GetCount() const { return m_list.size(); }
157 
158  void SetDefaultLayout();
159  void SetEmptyLayout();
160 
164  static wxString EmptyLayout();
165 
169  static wxString DefaultLayout();
170 
180  void SetPageLayout( const wxString& aFullFileName = wxEmptyString, bool Append = false );
181 
189  void SetPageLayout( const char* aPageLayout, bool aAppend = false,
190  const wxString& aSource = wxT( "Sexpr_string" ) );
191 
200  static const wxString MakeShortFileName( const wxString& aFullFileName,
201  const wxString& aProjectPath );
202 
214  static const wxString MakeFullFileName( const wxString& aShortFileName,
215  const wxString& aProjectPath );
216 };
217 
218 #endif // WS_DATA_MODEL_H
int GetItemIndex(WS_DATA_ITEM *aItem) const
WS_DATA_MODEL handles the graphic items list to draw/plot the frame and title block.
Definition: ws_data_model.h:39
DPOINT m_RB_Corner
Definition: ws_data_model.h:53
double GetTopMargin()
Definition: ws_data_model.h:90
Work sheet structure type definitions.
Definition: ws_data_item.h:93
std::vector< WS_DATA_ITEM * > m_list
Definition: ws_data_model.h:41
Class VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
double m_bottomMargin
Definition: ws_data_model.h:48
WS_DATA_ITEM * GetItem(unsigned aIdx) const
bool m_allowVoidList
Definition: ws_data_model.h:42
void SetPageLayout(const wxString &aFullFileName=wxEmptyString, bool Append=false)
Populates the list with a custom layout, or the default layout, if no custom layout available.
std::vector< WS_DATA_ITEM * > & GetItems()
static wxString EmptyLayout()
Returns a string containing the empty layout shape.
DSIZE m_DefaultTextSize
Definition: ws_data_model.h:56
DPOINT m_LT_Corner
Definition: ws_data_model.h:54
double GetBottomMargin()
Definition: ws_data_model.h:93
double m_leftMargin
Definition: ws_data_model.h:45
void ClearList()
erase the list of items
static WS_DATA_MODEL & GetTheInstance()
static function: returns the instance of WS_DATA_MODEL used in the application
static void SetAltInstance(WS_DATA_MODEL *aLayout=NULL)
static function: Set an alternate instance of WS_DATA_MODEL mainly used in page setting dialog
void AllowVoidList(bool Allow)
In Kicad applications, a page layout description is needed So if the list is empty,...
static const wxString MakeShortFileName(const wxString &aFullFileName, const wxString &aProjectPath)
double GetRightMargin()
Definition: ws_data_model.h:87
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: page_info.h:54
void SetLeftMargin(double aMargin)
Definition: ws_data_model.h:85
void SetTopMargin(double aMargin)
Definition: ws_data_model.h:91
double m_topMargin
Definition: ws_data_model.h:47
static wxString DefaultLayout()
Returns a string containing the empty layout shape.
void Remove(WS_DATA_ITEM *aItem)
void SetupDrawEnvironment(const PAGE_INFO &aPageInfo, double aMilsToIU)
void Save(const wxString &aFullFileName)
Save the description in a file.
void SetBottomMargin(double aMargin)
Definition: ws_data_model.h:94
static const wxString MakeFullFileName(const wxString &aShortFileName, const wxString &aProjectPath)
Static function.
double m_DefaultLineWidth
Definition: ws_data_model.h:55
double GetLeftMargin()
Definition: ws_data_model.h:84
double m_WSunits2Iu
Definition: ws_data_model.h:51
bool VoidListAllowed()
double m_DefaultTextThickness
Definition: ws_data_model.h:57
void Append(WS_DATA_ITEM *aItem)
double m_rightMargin
Definition: ws_data_model.h:46
void SetRightMargin(double aMargin)
Definition: ws_data_model.h:88
void SaveInString(wxString &aOutputString)
Save the description in a buffer.
unsigned GetCount() const