KiCad PCB EDA Suite
WS_DATA_MODEL Class Reference

WS_DATA_MODEL handles the graphic items list to draw/plot the frame and title block. More...

#include <ws_data_model.h>

Public Member Functions

 WS_DATA_MODEL ()
 
 ~WS_DATA_MODEL ()
 
double GetLeftMargin ()
 
void SetLeftMargin (double aMargin)
 
double GetRightMargin ()
 
void SetRightMargin (double aMargin)
 
double GetTopMargin ()
 
void SetTopMargin (double aMargin)
 
double GetBottomMargin ()
 
void SetBottomMargin (double aMargin)
 
void SetupDrawEnvironment (const PAGE_INFO &aPageInfo, double aMilsToIU)
 
void AllowVoidList (bool Allow)
 In Kicad applications, a page layout description is needed So if the list is empty, a default description is loaded, the first time a page layout is drawn. More...
 
bool VoidListAllowed ()
 
void ClearList ()
 erase the list of items More...
 
void Save (const wxString &aFullFileName)
 Save the description in a file. More...
 
void SaveInString (wxString &aOutputString)
 Save the description in a buffer. More...
 
void SaveInString (std::vector< WS_DATA_ITEM * > aItemsList, wxString &aOutputString)
 Fill the given string with an S-expr serialization of the WS_DATA_ITEMs. More...
 
void Append (WS_DATA_ITEM *aItem)
 
void Remove (WS_DATA_ITEM *aItem)
 
int GetItemIndex (WS_DATA_ITEM *aItem) const
 
WS_DATA_ITEMGetItem (unsigned aIdx) const
 
std::vector< WS_DATA_ITEM * > & GetItems ()
 
unsigned GetCount () const
 
void SetDefaultLayout ()
 
void SetEmptyLayout ()
 
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. More...
 
void SetPageLayout (const char *aPageLayout, bool aAppend=false, const wxString &aSource=wxT("Sexpr_string"))
 Populates the list from a S expr description stored in a string. More...
 

Static Public Member Functions

static WS_DATA_MODELGetTheInstance ()
 static function: returns the instance of WS_DATA_MODEL used in the application More...
 
static void SetAltInstance (WS_DATA_MODEL *aLayout=NULL)
 static function: Set an alternate instance of WS_DATA_MODEL mainly used in page setting dialog More...
 
static wxString EmptyLayout ()
 Returns a string containing the empty layout shape. More...
 
static wxString DefaultLayout ()
 Returns a string containing the empty layout shape. More...
 
static const wxString MakeShortFileName (const wxString &aFullFileName, const wxString &aProjectPath)
 
static const wxString MakeFullFileName (const wxString &aShortFileName, const wxString &aProjectPath)
 Static function. More...
 

Public Attributes

double m_WSunits2Iu
 
DPOINT m_RB_Corner
 
DPOINT m_LT_Corner
 
double m_DefaultLineWidth
 
DSIZE m_DefaultTextSize
 
double m_DefaultTextThickness
 
bool m_EditMode
 

Private Attributes

std::vector< WS_DATA_ITEM * > m_list
 
bool m_allowVoidList
 
double m_leftMargin
 
double m_rightMargin
 
double m_topMargin
 
double m_bottomMargin
 

Detailed Description

WS_DATA_MODEL handles the graphic items list to draw/plot the frame and title block.

Definition at line 39 of file ws_data_model.h.

Constructor & Destructor Documentation

◆ WS_DATA_MODEL()

WS_DATA_MODEL::WS_DATA_MODEL ( )

Definition at line 61 of file ws_data_model.cpp.

61  :
62  m_WSunits2Iu( 1000.0 ),
63  m_DefaultLineWidth( 0.0 ),
66  m_EditMode( false )
67 {
68  m_allowVoidList = false;
69  m_leftMargin = 10.0; // the left page margin in mm
70  m_rightMargin = 10.0; // the right page margin in mm
71  m_topMargin = 10.0; // the top page margin in mm
72  m_bottomMargin = 10.0; // the bottom page margin in mm
73 }
double m_bottomMargin
Definition: ws_data_model.h:48
bool m_allowVoidList
Definition: ws_data_model.h:42
#define TB_DEFAULT_TEXTSIZE
Definition: ws_data_item.h:41
DSIZE m_DefaultTextSize
Definition: ws_data_model.h:56
double m_leftMargin
Definition: ws_data_model.h:45
double m_topMargin
Definition: ws_data_model.h:47
double m_DefaultLineWidth
Definition: ws_data_model.h:55
double m_WSunits2Iu
Definition: ws_data_model.h:51
double m_DefaultTextThickness
Definition: ws_data_model.h:57
double m_rightMargin
Definition: ws_data_model.h:46

References m_allowVoidList, m_bottomMargin, m_leftMargin, m_rightMargin, and m_topMargin.

◆ ~WS_DATA_MODEL()

WS_DATA_MODEL::~WS_DATA_MODEL ( )
inline

Definition at line 66 of file ws_data_model.h.

67  {
68  ClearList();
69  }
void ClearList()
erase the list of items

References ClearList().

Member Function Documentation

◆ AllowVoidList()

void WS_DATA_MODEL::AllowVoidList ( bool  Allow)
inline

In Kicad applications, a page layout description is needed So if the list is empty, a default description is loaded, the first time a page layout is drawn.

However, in page layout editor, an empty list is acceptable. AllowVoidList allows or not the empty list

Definition at line 105 of file ws_data_model.h.

105 { m_allowVoidList = Allow; }
bool m_allowVoidList
Definition: ws_data_model.h:42

References m_allowVoidList.

Referenced by PL_EDITOR_FRAME::Files_io(), PAGE_LAYOUT_READER_PARSER::parseSetup(), and PL_EDITOR_FRAME::PL_EDITOR_FRAME().

◆ Append()

void WS_DATA_MODEL::Append ( WS_DATA_ITEM aItem)

Definition at line 127 of file ws_data_model.cpp.

128 {
129  m_list.push_back( aItem );
130 }
std::vector< WS_DATA_ITEM * > m_list
Definition: ws_data_model.h:41

References m_list.

Referenced by PL_EDITOR_FRAME::AddPageLayoutItem(), PAGE_LAYOUT_READER_PARSER::Parse(), and SetPageLayout().

◆ ClearList()

void WS_DATA_MODEL::ClearList ( )

erase the list of items

Definition at line 118 of file ws_data_model.cpp.

119 {
120  for( WS_DATA_ITEM* item : m_list )
121  delete item;
122 
123  m_list.clear();
124 }
Work sheet structure type definitions.
Definition: ws_data_item.h:93
std::vector< WS_DATA_ITEM * > m_list
Definition: ws_data_model.h:41

References m_list.

Referenced by PL_EDITOR_FRAME::Files_io(), PL_EDITOR_FRAME::PL_EDITOR_FRAME(), SetPageLayout(), and ~WS_DATA_MODEL().

◆ DefaultLayout()

wxString WS_DATA_MODEL::DefaultLayout ( )
static

Returns a string containing the empty layout shape.

Definition at line 702 of file page_layout_reader.cpp.

703 {
704  return wxString( defaultPageLayout );
705 }
const char defaultPageLayout[]

References defaultPageLayout.

◆ EmptyLayout()

wxString WS_DATA_MODEL::EmptyLayout ( )
static

Returns a string containing the empty layout shape.

Definition at line 719 of file page_layout_reader.cpp.

720 {
721  return wxString( emptyPageLayout );
722 }
const char emptyPageLayout[]

References emptyPageLayout.

Referenced by SCH_EDIT_FRAME::importFile().

◆ GetBottomMargin()

double WS_DATA_MODEL::GetBottomMargin ( )
inline

◆ GetCount()

unsigned WS_DATA_MODEL::GetCount ( ) const
inline
Returns
the item count

Definition at line 156 of file ws_data_model.h.

156 { return m_list.size(); }
std::vector< WS_DATA_ITEM * > m_list
Definition: ws_data_model.h:41

References m_list.

Referenced by WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(), and WS_DATA_MODEL_IO::Format().

◆ GetItem()

WS_DATA_ITEM * WS_DATA_MODEL::GetItem ( unsigned  aIdx) const
Returns
the item from its index aIdx, or NULL if does not exist

Definition at line 156 of file ws_data_model.cpp.

157 {
158  if( aIdx < m_list.size() )
159  return m_list[aIdx];
160  else
161  return nullptr;
162 }
std::vector< WS_DATA_ITEM * > m_list
Definition: ws_data_model.h:41

References m_list.

Referenced by WS_DATA_MODEL_IO::Format(), WS_PROXY_UNDO_ITEM::Restore(), and WS_PROXY_UNDO_ITEM::WS_PROXY_UNDO_ITEM().

◆ GetItemIndex()

int WS_DATA_MODEL::GetItemIndex ( WS_DATA_ITEM aItem) const
Returns
the index of aItem, or -1 if does not exist

Definition at line 140 of file ws_data_model.cpp.

141 {
142  unsigned idx = 0;
143  while( idx < m_list.size() )
144  {
145  if( m_list[idx] == aItem )
146  return (int) idx;
147 
148  idx++;
149  }
150 
151  return -1;
152 }
std::vector< WS_DATA_ITEM * > m_list
Definition: ws_data_model.h:41

References m_list.

◆ GetItems()

std::vector<WS_DATA_ITEM*>& WS_DATA_MODEL::GetItems ( )
inline
Returns
a reference to the items.

Definition at line 151 of file ws_data_model.h.

151 { return m_list; }
std::vector< WS_DATA_ITEM * > m_list
Definition: ws_data_model.h:41

References m_list.

Referenced by WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(), PL_EDIT_TOOL::Paste(), DIALOG_INSPECTOR::ReCreateDesignList(), WS_PROXY_UNDO_ITEM::Restore(), and WS_PROXY_UNDO_ITEM::WS_PROXY_UNDO_ITEM().

◆ GetLeftMargin()

double WS_DATA_MODEL::GetLeftMargin ( )
inline

◆ GetRightMargin()

double WS_DATA_MODEL::GetRightMargin ( )
inline

◆ GetTheInstance()

WS_DATA_MODEL & WS_DATA_MODEL::GetTheInstance ( )
static

static function: returns the instance of WS_DATA_MODEL used in the application

Definition at line 78 of file ws_data_model.cpp.

79 {
80  if( wksAltInstance )
81  return *wksAltInstance;
82  else
83  return wksTheInstance;
84 }
static WS_DATA_MODEL * wksAltInstance
static WS_DATA_MODEL wksTheInstance

References wksAltInstance, and wksTheInstance.

Referenced by PL_EDITOR_FRAME::AddPageLayoutItem(), WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(), PL_EDIT_TOOL::Copy(), PROPERTIES_FRAME::CopyPrmsFromGeneralToPanel(), PROPERTIES_FRAME::CopyPrmsFromPanelToGeneral(), PL_EDIT_TOOL::DeleteItemCursor(), DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS(), PL_DRAW_PANEL_GAL::DisplayWorksheet(), PL_EDIT_TOOL::DoDelete(), PL_EDITOR_FRAME::Files_io(), WS_DATA_ITEM_POLYGONS::GetCornerPositionUi(), WS_DATA_ITEM::GetEndPos(), WS_DATA_ITEM::GetEndPosUi(), WS_DATA_ITEM::GetPenSizeUi(), WS_DATA_ITEM_POLYGONS::GetPenSizeUi(), WS_DATA_ITEM_TEXT::GetPenSizeUi(), WS_DATA_ITEM::GetStartPos(), WS_DATA_ITEM::GetStartPosUi(), SCH_EDIT_FRAME::importFile(), PL_EDITOR_FRAME::InsertPageLayoutDescrFile(), WS_DATA_ITEM::IsInsidePage(), WS_DATA_ITEM_POLYGONS::IsInsidePage(), PL_EDITOR_FRAME::LoadPageLayoutDescrFile(), SCH_EDIT_FRAME::LoadProjectFile(), PCB_EDIT_FRAME::LoadProjectSettings(), WS_DATA_ITEM::MoveEndPointTo(), WS_DATA_ITEM::MoveEndPointToUi(), WS_DATA_ITEM::MoveStartPointTo(), WS_DATA_ITEM::MoveStartPointToUi(), WS_DATA_ITEM::MoveToUi(), PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode(), PROPERTIES_FRAME::OnSetDefaultValues(), PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayEditMode(), PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayNormalMode(), PL_EDIT_TOOL::Paste(), PL_EDITOR_FRAME::PL_EDITOR_FRAME(), PL_SELECTION_TOOL::RebuildSelection(), DIALOG_INSPECTOR::ReCreateDesignList(), WS_PROXY_UNDO_ITEM::Restore(), PL_EDITOR_FRAME::SavePageLayoutDescrFile(), DIALOG_PAGES_SETTINGS::SavePageSettings(), PL_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), WS_DATA_ITEM_TEXT::SetConstrainedTextSize(), WS_DATA_ITEM_TEXT::SyncDrawItems(), and WS_PROXY_UNDO_ITEM::WS_PROXY_UNDO_ITEM().

◆ GetTopMargin()

double WS_DATA_MODEL::GetTopMargin ( )
inline

◆ MakeFullFileName()

const wxString WS_DATA_MODEL::MakeFullFileName ( const wxString &  aShortFileName,
const wxString &  aProjectPath 
)
static

Static function.

Returns
a full filename from a short filename.
Parameters
aShortFileName= the short filename, which can be a relative
aProjectPath= the curr project absolute path (can be empty) or absolute path, and can include env variable reference ( ${envvar} expression ) if the short filename path is relative, it is expected relative to the project path or (if aProjectPath is empty or if the file does not exist) relative to kicad.pro (in template) If aShortFileName is absolute return aShortFileName

Definition at line 194 of file ws_data_model.cpp.

196 {
197  wxString fullFileName = ExpandEnvVarSubstitutions( aShortFileName );
198 
199  if( fullFileName.IsEmpty() )
200  return fullFileName;
201 
202  wxFileName fn = fullFileName;
203 
204  if( fn.IsAbsolute() )
205  return fullFileName;
206 
207  // the path is not absolute: search it in project path, and then in
208  // kicad valid paths
209  if( !aProjectPath.IsEmpty() )
210  {
211  fn.MakeAbsolute( aProjectPath );
212 
213  if( wxFileExists( fn.GetFullPath() ) )
214  return fn.GetFullPath();
215  }
216 
217  fn = fullFileName;
218  wxString name = Kiface().KifaceSearch().FindValidPath( fn.GetFullName() );
219 
220  if( !name.IsEmpty() )
221  fullFileName = name;
222 
223  return fullFileName;
224 }
wxString FindValidPath(const wxString &aFileName) const
Definition: search_stack.h:73
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:51
SEARCH_STACK & KifaceSearch()
Only for DSO specific 'non-library' files.
Definition: kiface_i.h:127
const wxString ExpandEnvVarSubstitutions(const wxString &aString)
Replace any environment variable references with their values.
Definition: common.cpp:458
const char * name
Definition: DXF_plotter.cpp:61

References ExpandEnvVarSubstitutions(), SEARCH_STACK::FindValidPath(), Kiface(), KIFACE_I::KifaceSearch(), and name.

Referenced by SCH_EDIT_FRAME::LoadProjectFile(), PCB_EDIT_FRAME::LoadProjectSettings(), and DIALOG_PAGES_SETTINGS::SavePageSettings().

◆ MakeShortFileName()

const wxString WS_DATA_MODEL::MakeShortFileName ( const wxString &  aFullFileName,
const wxString &  aProjectPath 
)
static
Returns
a short filename from a full filename: if the path is the current project path, or if the path is the same as kicad.pro (in template), returns the shortname else do nothing and returns a full filename
Parameters
aFullFileName= the full filename, which can be a relative
aProjectPath= the curr project absolute path (can be empty)

Definition at line 165 of file ws_data_model.cpp.

167 {
168  wxString shortFileName = aFullFileName;
169  wxFileName fn = aFullFileName;
170 
171  if( fn.IsRelative() )
172  return shortFileName;
173 
174  if( ! aProjectPath.IsEmpty() && aFullFileName.StartsWith( aProjectPath ) )
175  {
176  fn.MakeRelativeTo( aProjectPath );
177  shortFileName = fn.GetFullPath();
178  return shortFileName;
179  }
180 
181  wxString fileName = Kiface().KifaceSearch().FindValidPath( fn.GetFullName() );
182 
183  if( !fileName.IsEmpty() )
184  {
185  fn = fileName;
186  shortFileName = fn.GetFullName();
187  return shortFileName;
188  }
189 
190  return shortFileName;
191 }
wxString FindValidPath(const wxString &aFileName) const
Definition: search_stack.h:73
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:51
SEARCH_STACK & KifaceSearch()
Only for DSO specific 'non-library' files.
Definition: kiface_i.h:127

References SEARCH_STACK::FindValidPath(), Kiface(), and KIFACE_I::KifaceSearch().

Referenced by DIALOG_PAGES_SETTINGS::OnWksFileSelection().

◆ Remove()

void WS_DATA_MODEL::Remove ( WS_DATA_ITEM aItem)

Definition at line 133 of file ws_data_model.cpp.

134 {
135  auto newEnd = std::remove( m_list.begin(), m_list.end(), aItem );
136  m_list.erase( newEnd, m_list.end() );
137 }
std::vector< WS_DATA_ITEM * > m_list
Definition: ws_data_model.h:41

References m_list.

Referenced by PL_EDIT_TOOL::DoDelete().

◆ Save()

void WS_DATA_MODEL::Save ( const wxString &  aFullFileName)

Save the description in a file.

Parameters
aFullFileNamethe filename of the file to created

Definition at line 142 of file ws_data_model_io.cpp.

143 {
144  WS_DATA_MODEL_FILEIO writer( aFullFileName );
145  writer.Format( this );
146 }

References WS_DATA_MODEL_IO::Format().

Referenced by PL_EDITOR_FRAME::SavePageLayoutDescrFile().

◆ SaveInString() [1/2]

void WS_DATA_MODEL::SaveInString ( wxString &  aOutputString)

Save the description in a buffer.

Parameters
aOutputString= a wxString to store the S expr string

Definition at line 151 of file ws_data_model_io.cpp.

152 {
153  WS_DATA_MODEL_STRINGIO writer( aOutputString );
154  writer.Format( this );
155 }

References WS_DATA_MODEL_IO::Format().

Referenced by PL_EDIT_TOOL::Copy(), DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS(), and WS_PROXY_UNDO_ITEM::WS_PROXY_UNDO_ITEM().

◆ SaveInString() [2/2]

void WS_DATA_MODEL::SaveInString ( std::vector< WS_DATA_ITEM * >  aItemsList,
wxString &  aOutputString 
)

Fill the given string with an S-expr serialization of the WS_DATA_ITEMs.

Definition at line 158 of file ws_data_model_io.cpp.

159 {
160  WS_DATA_MODEL_STRINGIO writer( aOutputString );
161 
162  LOCALE_IO toggle; // switch on/off the locale "C" notation
163 
164  for( WS_DATA_ITEM* item : aItemsList )
165  writer.Format( this, item, 0 );
166 }
Work sheet structure type definitions.
Definition: ws_data_item.h:93
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:154

References WS_DATA_MODEL_IO::Format().

◆ SetAltInstance()

void WS_DATA_MODEL::SetAltInstance ( WS_DATA_MODEL aLayout = NULL)
static

static function: Set an alternate instance of WS_DATA_MODEL mainly used in page setting dialog

Parameters
aLayout= the alternate page layout; if null restore the basic page layout
aLayout= the alternate page layout. if null, restore the basic page layout

Definition at line 92 of file ws_data_model.cpp.

93 {
94  wksAltInstance = aLayout;
95 }
static WS_DATA_MODEL * wksAltInstance

References wksAltInstance.

Referenced by DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample().

◆ SetBottomMargin()

void WS_DATA_MODEL::SetBottomMargin ( double  aMargin)
inline

Definition at line 94 of file ws_data_model.h.

94 { m_bottomMargin = aMargin; }
double m_bottomMargin
Definition: ws_data_model.h:48

References m_bottomMargin.

Referenced by PROPERTIES_FRAME::CopyPrmsFromPanelToGeneral(), and PAGE_LAYOUT_READER_PARSER::parseSetup().

◆ SetDefaultLayout()

void WS_DATA_MODEL::SetDefaultLayout ( )

Definition at line 696 of file page_layout_reader.cpp.

697 {
698  SetPageLayout( defaultPageLayout, false, wxT( "default page" ) );
699 }
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.
const char defaultPageLayout[]

References defaultPageLayout, and SetPageLayout().

Referenced by SetPageLayout().

◆ SetEmptyLayout()

void WS_DATA_MODEL::SetEmptyLayout ( )

Definition at line 713 of file page_layout_reader.cpp.

714 {
715  SetPageLayout( emptyPageLayout, false, wxT( "empty page" ) );
716 }
const char emptyPageLayout[]
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.

References emptyPageLayout, and SetPageLayout().

Referenced by SCH_EDIT_FRAME::importFile().

◆ SetLeftMargin()

void WS_DATA_MODEL::SetLeftMargin ( double  aMargin)
inline

Definition at line 85 of file ws_data_model.h.

85 { m_leftMargin = aMargin; }
double m_leftMargin
Definition: ws_data_model.h:45

References m_leftMargin.

Referenced by PROPERTIES_FRAME::CopyPrmsFromPanelToGeneral(), and PAGE_LAYOUT_READER_PARSER::parseSetup().

◆ SetPageLayout() [1/2]

void WS_DATA_MODEL::SetPageLayout ( const wxString &  aFullFileName = wxEmptyString,
bool  Append = false 
)

Populates the list with a custom layout, or the default layout, if no custom layout available.

Parameters
aFullFileName= the custom page layout description file. if empty, loads the file defined by KICAD_WKSFILE and if its is not defined, uses the default internal description
Append= if true: do not delete old layout, and load only aFullFileName.

Definition at line 743 of file page_layout_reader.cpp.

744 {
745  wxString fullFileName = aFullFileName;
746 
747  if( !Append )
748  {
749  if( fullFileName.IsEmpty() )
750  wxGetEnv( wxT( "KICAD_WKSFILE" ), &fullFileName );
751 
752  if( fullFileName.IsEmpty() || !wxFileExists( fullFileName ) )
753  {
754  #if 0
755  if( !fullFileName.IsEmpty() )
756  wxLogMessage( wxT( "Page layout file <%s> not found" ), fullFileName.GetData() );
757  #endif
759  return;
760  }
761  }
762 
763  wxFile wksFile( fullFileName );
764 
765  if( ! wksFile.IsOpened() )
766  {
767  if( !Append )
769  return;
770  }
771 
772  int filelen = wksFile.Length();
773  char * buffer = new char[filelen+10];
774 
775  if( wksFile.Read( buffer, filelen ) != filelen )
776  wxLogMessage( _("The file \"%s\" was not fully read"), fullFileName.GetData() );
777  else
778  {
779  buffer[filelen]=0;
780 
781  if( ! Append )
782  ClearList();
783 
784  PAGE_LAYOUT_READER_PARSER pl_parser( buffer, fullFileName );
785 
786  try
787  {
788  pl_parser.Parse( this );
789  }
790  catch( const IO_ERROR& ioe )
791  {
792  wxLogMessage( ioe.What() );
793  }
794  }
795 
796  delete[] buffer;
797 }
void ClearList()
erase the list of items
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
Class PAGE_LAYOUT_READER_PARSER holds data and functions pertinent to parsing a S-expression file for...
#define _(s)
void Append(WS_DATA_ITEM *aItem)
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76

References _, Append(), ClearList(), PAGE_LAYOUT_READER_PARSER::Parse(), SetDefaultLayout(), and IO_ERROR::What().

Referenced by WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(), DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS(), PL_EDITOR_FRAME::InsertPageLayoutDescrFile(), PL_EDITOR_FRAME::LoadPageLayoutDescrFile(), SCH_EDIT_FRAME::LoadProjectFile(), PCB_EDIT_FRAME::LoadProjectSettings(), DIALOG_PAGES_SETTINGS::OnWksFileSelection(), PL_EDIT_TOOL::Paste(), PL_EDITOR_FRAME::PL_EDITOR_FRAME(), WS_PROXY_UNDO_ITEM::Restore(), DIALOG_PAGES_SETTINGS::SavePageSettings(), SetDefaultLayout(), and SetEmptyLayout().

◆ SetPageLayout() [2/2]

void WS_DATA_MODEL::SetPageLayout ( const char *  aPageLayout,
bool  aAppend = false,
const wxString &  aSource = wxT( "Sexpr_string" ) 
)

Populates the list from a S expr description stored in a string.

Parameters
aPageLayout= the S expr string
aAppendDo not delete old layout if true and append aPageLayout the existing one.
aSourceis the layout source description.

Definition at line 725 of file page_layout_reader.cpp.

726 {
727  if( ! Append )
728  ClearList();
729 
730  PAGE_LAYOUT_READER_PARSER lp_parser( aPageLayout, wxT( "Sexpr_string" ) );
731 
732  try
733  {
734  lp_parser.Parse( this );
735  }
736  catch( const IO_ERROR& ioe )
737  {
738  wxLogMessage( ioe.What() );
739  }
740 }
void ClearList()
erase the list of items
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
Class PAGE_LAYOUT_READER_PARSER holds data and functions pertinent to parsing a S-expression file for...
void Append(WS_DATA_ITEM *aItem)
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76

References Append(), ClearList(), PAGE_LAYOUT_READER_PARSER::Parse(), and IO_ERROR::What().

◆ SetRightMargin()

void WS_DATA_MODEL::SetRightMargin ( double  aMargin)
inline

Definition at line 88 of file ws_data_model.h.

88 { m_rightMargin = aMargin; }
double m_rightMargin
Definition: ws_data_model.h:46

References m_rightMargin.

Referenced by PROPERTIES_FRAME::CopyPrmsFromPanelToGeneral(), and PAGE_LAYOUT_READER_PARSER::parseSetup().

◆ SetTopMargin()

void WS_DATA_MODEL::SetTopMargin ( double  aMargin)
inline

Definition at line 91 of file ws_data_model.h.

91 { m_topMargin = aMargin; }
double m_topMargin
Definition: ws_data_model.h:47

References m_topMargin.

Referenced by PROPERTIES_FRAME::CopyPrmsFromPanelToGeneral(), and PAGE_LAYOUT_READER_PARSER::parseSetup().

◆ SetupDrawEnvironment()

void WS_DATA_MODEL::SetupDrawEnvironment ( const PAGE_INFO aPageInfo,
double  aMilsToIU 
)

Definition at line 98 of file ws_data_model.cpp.

99 {
100 #define MILS_TO_MM (25.4/1000)
101 
102  m_WSunits2Iu = aMilsToIU / MILS_TO_MM;
103 
104  // Left top corner position
105  DPOINT lt_corner;
106  lt_corner.x = GetLeftMargin();
107  lt_corner.y = GetTopMargin();
108  m_LT_Corner = lt_corner;
109 
110  // Right bottom corner position
111  DPOINT rb_corner;
112  rb_corner.x = ( aPageInfo.GetSizeMils().x * MILS_TO_MM ) - GetRightMargin();
113  rb_corner.y = ( aPageInfo.GetSizeMils().y * MILS_TO_MM ) - GetBottomMargin();
114  m_RB_Corner = rb_corner;
115 }
DPOINT m_RB_Corner
Definition: ws_data_model.h:53
double GetTopMargin()
Definition: ws_data_model.h:90
DPOINT m_LT_Corner
Definition: ws_data_model.h:54
double GetBottomMargin()
Definition: ws_data_model.h:93
double GetRightMargin()
Definition: ws_data_model.h:87
const wxSize & GetSizeMils() const
Definition: page_info.h:142
#define MILS_TO_MM
double GetLeftMargin()
Definition: ws_data_model.h:84
double m_WSunits2Iu
Definition: ws_data_model.h:51

References GetBottomMargin(), GetLeftMargin(), GetRightMargin(), PAGE_INFO::GetSizeMils(), GetTopMargin(), m_LT_Corner, m_RB_Corner, m_WSunits2Iu, MILS_TO_MM, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList().

◆ VoidListAllowed()

bool WS_DATA_MODEL::VoidListAllowed ( )
inline
Returns
true if an empty list is allowed (mainly allowed for page layout editor).

Definition at line 111 of file ws_data_model.h.

111 { return m_allowVoidList; }
bool m_allowVoidList
Definition: ws_data_model.h:42

References m_allowVoidList.

Referenced by WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList().

Member Data Documentation

◆ m_allowVoidList

bool WS_DATA_MODEL::m_allowVoidList
private

Definition at line 42 of file ws_data_model.h.

Referenced by AllowVoidList(), VoidListAllowed(), and WS_DATA_MODEL().

◆ m_bottomMargin

double WS_DATA_MODEL::m_bottomMargin
private

Definition at line 48 of file ws_data_model.h.

Referenced by GetBottomMargin(), SetBottomMargin(), and WS_DATA_MODEL().

◆ m_DefaultLineWidth

◆ m_DefaultTextSize

◆ m_DefaultTextThickness

◆ m_EditMode

bool WS_DATA_MODEL::m_EditMode

◆ m_leftMargin

double WS_DATA_MODEL::m_leftMargin
private

Definition at line 45 of file ws_data_model.h.

Referenced by GetLeftMargin(), SetLeftMargin(), and WS_DATA_MODEL().

◆ m_list

std::vector<WS_DATA_ITEM*> WS_DATA_MODEL::m_list
private

Definition at line 41 of file ws_data_model.h.

Referenced by Append(), ClearList(), GetCount(), GetItem(), GetItemIndex(), GetItems(), and Remove().

◆ m_LT_Corner

◆ m_RB_Corner

◆ m_rightMargin

double WS_DATA_MODEL::m_rightMargin
private

Definition at line 46 of file ws_data_model.h.

Referenced by GetRightMargin(), SetRightMargin(), and WS_DATA_MODEL().

◆ m_topMargin

double WS_DATA_MODEL::m_topMargin
private

Definition at line 47 of file ws_data_model.h.

Referenced by GetTopMargin(), SetTopMargin(), and WS_DATA_MODEL().

◆ m_WSunits2Iu


The documentation for this class was generated from the following files: