KiCad PCB EDA Suite
DS_DATA_MODEL Class Reference

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

#include <ds_data_model.h>

Public Member Functions

 DS_DATA_MODEL ()
 
 ~DS_DATA_MODEL ()
 
int GetFileFormatVersionAtLoad ()
 
void SetFileFormatVersionAtLoad (int aVersion)
 
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 drawing sheet is needed So if the list is empty, a default drawing sheet is loaded, the first time it 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< DS_DATA_ITEM * > &aItemsList, wxString *aOutputString)
 Fill the given string with an S-expr serialization of the WS_DATA_ITEMs. More...
 
void Append (DS_DATA_ITEM *aItem)
 
void Remove (DS_DATA_ITEM *aItem)
 
int GetItemIndex (DS_DATA_ITEM *aItem) const
 
DS_DATA_ITEMGetItem (unsigned aIdx) const
 
std::vector< DS_DATA_ITEM * > & GetItems ()
 
unsigned GetCount () const
 
void SetDefaultLayout ()
 
void SetEmptyLayout ()
 
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. More...
 
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. More...
 

Static Public Member Functions

static DS_DATA_MODELGetTheInstance ()
 static function: returns the instance of DS_DATA_MODEL used in the application More...
 
static void SetAltInstance (DS_DATA_MODEL *aLayout=nullptr)
 Set an alternate instance of DS_DATA_MODEL. More...
 
static wxString EmptyLayout ()
 Return a string containing the empty layout shape. More...
 
static wxString DefaultLayout ()
 Return 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)
 

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< DS_DATA_ITEM * > m_list
 
bool m_allowVoidList
 
int m_fileFormatVersionAtLoad
 
double m_leftMargin
 
double m_rightMargin
 
double m_topMargin
 
double m_bottomMargin
 

Detailed Description

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

Definition at line 38 of file ds_data_model.h.

Constructor & Destructor Documentation

◆ DS_DATA_MODEL()

DS_DATA_MODEL::DS_DATA_MODEL ( )

Definition at line 61 of file ds_data_model.cpp.

61  :
62  m_WSunits2Iu( 1000.0 ),
63  m_DefaultLineWidth( 0.0 ),
66  m_EditMode( false )
67 {
68  m_allowVoidList = false;
70  m_leftMargin = 10.0; // the left page margin in mm
71  m_rightMargin = 10.0; // the right page margin in mm
72  m_topMargin = 10.0; // the top page margin in mm
73  m_bottomMargin = 10.0; // the bottom page margin in mm
74 }
double m_DefaultLineWidth
#define TB_DEFAULT_TEXTSIZE
Definition: ds_data_item.h:35
int m_fileFormatVersionAtLoad
double m_topMargin
double m_DefaultTextThickness
double m_bottomMargin
DSIZE m_DefaultTextSize
double m_leftMargin
double m_WSunits2Iu
double m_rightMargin

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

◆ ~DS_DATA_MODEL()

DS_DATA_MODEL::~DS_DATA_MODEL ( )
inline

Definition at line 43 of file ds_data_model.h.

44  {
45  ClearList();
46  }
void ClearList()
Erase the list of items.

References ClearList().

Member Function Documentation

◆ AllowVoidList()

void DS_DATA_MODEL::AllowVoidList ( bool  Allow)
inline

In KiCad applications, a drawing sheet is needed So if the list is empty, a default drawing sheet is loaded, the first time it is drawn.

However, in drawing sheet editor an empty list is acceptable. AllowVoidList allows or not the empty list

Definition at line 83 of file ds_data_model.h.

83 { m_allowVoidList = Allow; }

References m_allowVoidList.

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

◆ Append()

void DS_DATA_MODEL::Append ( DS_DATA_ITEM aItem)

Definition at line 128 of file ds_data_model.cpp.

129 {
130  m_list.push_back( aItem );
131 }
std::vector< DS_DATA_ITEM * > m_list

References m_list.

Referenced by PL_EDITOR_FRAME::AddDrawingSheetItem(), LoadDrawingSheet(), DRAWING_SHEET_READER_PARSER::Parse(), and SetPageLayout().

◆ ClearList()

void DS_DATA_MODEL::ClearList ( )

Erase the list of items.

Definition at line 119 of file ds_data_model.cpp.

120 {
121  for( DS_DATA_ITEM* item : m_list )
122  delete item;
123 
124  m_list.clear();
125 }
std::vector< DS_DATA_ITEM * > m_list
Drawing sheet structure type definitions.
Definition: ds_data_item.h:95

References m_list.

Referenced by PL_EDITOR_FRAME::doCloseWindow(), PL_EDITOR_FRAME::Files_io(), LoadDrawingSheet(), PL_EDITOR_FRAME::PL_EDITOR_FRAME(), SetPageLayout(), and ~DS_DATA_MODEL().

◆ DefaultLayout()

wxString DS_DATA_MODEL::DefaultLayout ( )
static

Return a string containing the empty layout shape.

Definition at line 834 of file drawing_sheet_reader.cpp.

835 {
836  return wxString( defaultDrawingSheet );
837 }
const char defaultDrawingSheet[]

References defaultDrawingSheet.

◆ EmptyLayout()

wxString DS_DATA_MODEL::EmptyLayout ( )
static

Return a string containing the empty layout shape.

Definition at line 849 of file drawing_sheet_reader.cpp.

850 {
851  return wxString( emptyDrawingSheet );
852 }
const char emptyDrawingSheet[]

References emptyDrawingSheet.

Referenced by SCH_EDIT_FRAME::importFile().

◆ GetBottomMargin()

double DS_DATA_MODEL::GetBottomMargin ( )
inline

◆ GetCount()

unsigned DS_DATA_MODEL::GetCount ( ) const
inline
Returns
the item count.

Definition at line 135 of file ds_data_model.h.

135 { return m_list.size(); }
std::vector< DS_DATA_ITEM * > m_list

References m_list.

Referenced by DS_DRAW_ITEM_LIST::BuildDrawItemsList(), and DS_DATA_MODEL_IO::Format().

◆ GetFileFormatVersionAtLoad()

int DS_DATA_MODEL::GetFileFormatVersionAtLoad ( )
inline

Definition at line 60 of file ds_data_model.h.

60 { return m_fileFormatVersionAtLoad; }
int m_fileFormatVersionAtLoad

References m_fileFormatVersionAtLoad.

◆ GetItem()

DS_DATA_ITEM * DS_DATA_MODEL::GetItem ( unsigned  aIdx) const
Returns
is the item from its index aIdx, or NULL if does not exist.

Definition at line 157 of file ds_data_model.cpp.

158 {
159  if( aIdx < m_list.size() )
160  return m_list[aIdx];
161  else
162  return nullptr;
163 }
std::vector< DS_DATA_ITEM * > m_list

References m_list.

Referenced by DS_PROXY_UNDO_ITEM::DS_PROXY_UNDO_ITEM(), DS_DATA_MODEL_IO::Format(), and DS_PROXY_UNDO_ITEM::Restore().

◆ GetItemIndex()

int DS_DATA_MODEL::GetItemIndex ( DS_DATA_ITEM aItem) const
Returns
the index of aItem, or -1 if does not exist.

Definition at line 141 of file ds_data_model.cpp.

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

References m_list.

◆ GetItems()

std::vector<DS_DATA_ITEM*>& DS_DATA_MODEL::GetItems ( )
inline

◆ GetLeftMargin()

double DS_DATA_MODEL::GetLeftMargin ( )
inline

◆ GetRightMargin()

double DS_DATA_MODEL::GetRightMargin ( )
inline

◆ GetTheInstance()

DS_DATA_MODEL & DS_DATA_MODEL::GetTheInstance ( )
static

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

Definition at line 79 of file ds_data_model.cpp.

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

References wksAltInstance, and wksTheInstance.

Referenced by PL_EDITOR_FRAME::AddDrawingSheetItem(), DS_DRAW_ITEM_LIST::BuildDrawItemsList(), PL_EDIT_TOOL::Copy(), PROPERTIES_FRAME::CopyPrmsFromGeneralToPanel(), PROPERTIES_FRAME::CopyPrmsFromPanelToGeneral(), PL_EDIT_TOOL::DeleteItemCursor(), DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS(), PL_DRAW_PANEL_GAL::DisplayDrawingSheet(), PL_EDITOR_FRAME::doCloseWindow(), PL_EDIT_TOOL::DoDelete(), DS_PROXY_UNDO_ITEM::DS_PROXY_UNDO_ITEM(), PL_EDITOR_FRAME::Files_io(), DS_DATA_ITEM_POLYGONS::GetCornerPositionUi(), DS_DATA_ITEM::GetEndPos(), DS_DATA_ITEM::GetEndPosUi(), DS_DATA_ITEM::GetPenSizeUi(), DS_DATA_ITEM_POLYGONS::GetPenSizeUi(), DS_DATA_ITEM_TEXT::GetPenSizeUi(), DS_DATA_ITEM::GetStartPos(), DS_DATA_ITEM::GetStartPosUi(), SCH_EDIT_FRAME::importFile(), PL_EDITOR_FRAME::InsertDrawingSheetFile(), DS_DATA_ITEM::IsInsidePage(), DS_DATA_ITEM_POLYGONS::IsInsidePage(), PL_EDITOR_FRAME::LoadDrawingSheetFile(), SCH_EDIT_FRAME::LoadProjectSettings(), PCB_EDIT_FRAME::LoadProjectSettings(), DS_DATA_ITEM::MoveEndPointTo(), DS_DATA_ITEM::MoveEndPointToUi(), DS_DATA_ITEM::MoveStartPointTo(), DS_DATA_ITEM::MoveStartPointToUi(), DS_DATA_ITEM::MoveToUi(), PROPERTIES_FRAME::OnSetDefaultValues(), PL_EDIT_TOOL::Paste(), PL_EDITOR_FRAME::PL_EDITOR_FRAME(), PLEDITOR_PRINTOUT::PrintPage(), PL_EDITOR_FRAME::PrintPage(), PL_SELECTION_TOOL::RebuildSelection(), DIALOG_INSPECTOR::ReCreateDesignList(), DS_PROXY_UNDO_ITEM::Restore(), PL_EDITOR_FRAME::SaveDrawingSheetFile(), DIALOG_PAGES_SETTINGS::SavePageSettings(), PL_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), DS_DATA_ITEM_TEXT::SetConstrainedTextSize(), PL_EDITOR_FRAME::setupUIConditions(), DS_DATA_ITEM_TEXT::SyncDrawItems(), and PL_EDITOR_CONTROL::TitleBlockDisplayMode().

◆ GetTopMargin()

double DS_DATA_MODEL::GetTopMargin ( )
inline

◆ LoadDrawingSheet()

bool DS_DATA_MODEL::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.

Parameters
aFullFileNameis the custom drawing sheet file. If empty, load the file defined by KICAD_WKSFILE and if its not defined, the default internal drawing sheet.
Appendif true: do not delete old layout, and load only aFullFileName.

Definition at line 873 of file drawing_sheet_reader.cpp.

874 {
875  wxString fullFileName = aFullFileName;
876 
877  if( !Append )
878  {
879  if( fullFileName.IsEmpty() )
880  wxGetEnv( wxT( "KICAD_WKSFILE" ), &fullFileName );
881 
882  if( fullFileName.IsEmpty() )
883  {
885  return true; // we assume its fine / default init
886  }
887 
888  if( !wxFileExists( fullFileName ) )
889  {
890  wxLogMessage( _( "Drawing sheet '%s' not found." ), fullFileName );
892  return false;
893  }
894  }
895 
896  wxFFile wksFile( fullFileName, "rb" );
897 
898  if( ! wksFile.IsOpened() )
899  {
900  wxLogMessage( _( "Drawing sheet '%s' could not be opened." ), fullFileName );
901 
902  if( !Append )
904 
905  return false;
906  }
907 
908  size_t filelen = wksFile.Length();
909  std::unique_ptr<char[]> buffer = std::make_unique<char[]>(filelen+10);
910 
911  if( wksFile.Read( buffer.get(), filelen ) != filelen )
912  {
913  wxLogMessage( _( "Drawing sheet '%s' was not fully read." ), fullFileName.GetData() );
914  return false;
915  }
916  else
917  {
918  buffer[filelen]=0;
919 
920  if( ! Append )
921  ClearList();
922 
923  DRAWING_SHEET_READER_PARSER pl_parser( buffer.get(), fullFileName );
924 
925  try
926  {
927  pl_parser.Parse( this );
928  }
929  catch( const IO_ERROR& ioe )
930  {
931  wxLogMessage( ioe.What() );
932  return false;
933  }
934  catch( const std::bad_alloc& )
935  {
936  wxLogMessage( "Memory exhaustion reading drawing sheet" );
937  return false;
938  }
939  }
940 
941  return true;
942 }
void ClearList()
Erase the list of items.
DRAWING_SHEET_READER_PARSER holds data and functions pertinent to parsing a S-expression file for a D...
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
#define _(s)
void Parse(DS_DATA_MODEL *aLayout)
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
void Append(DS_DATA_ITEM *aItem)

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

Referenced by DS_DRAW_ITEM_LIST::BuildDrawItemsList(), PL_EDITOR_FRAME::InsertDrawingSheetFile(), PL_EDITOR_FRAME::LoadDrawingSheetFile(), PL_EDITOR_FRAME::PL_EDITOR_FRAME(), and DIALOG_PAGES_SETTINGS::SavePageSettings().

◆ MakeFullFileName()

const wxString DS_DATA_MODEL::MakeFullFileName ( const wxString &  aShortFileName,
const wxString &  aProjectPath 
)
static
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
Returns
a full filename from a short filename.

Definition at line 195 of file ds_data_model.cpp.

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

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

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

◆ MakeShortFileName()

const wxString DS_DATA_MODEL::MakeShortFileName ( const wxString &  aFullFileName,
const wxString &  aProjectPath 
)
static
Parameters
aFullFileNameis the full filename, which can be a relative.
aProjectPathis the current project absolute path (can be empty).
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

Definition at line 166 of file ds_data_model.cpp.

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

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

Referenced by DIALOG_PAGES_SETTINGS::OnWksFileSelection().

◆ Remove()

void DS_DATA_MODEL::Remove ( DS_DATA_ITEM aItem)

Definition at line 134 of file ds_data_model.cpp.

135 {
136  auto newEnd = std::remove( m_list.begin(), m_list.end(), aItem );
137  m_list.erase( newEnd, m_list.end() );
138 }
std::vector< DS_DATA_ITEM * > m_list

References m_list.

Referenced by PL_EDIT_TOOL::DoDelete().

◆ Save()

void DS_DATA_MODEL::Save ( const wxString &  aFullFileName)

Save the description in a file.

Parameters
aFullFileNamethe filename of the file to created.

Definition at line 137 of file ds_data_model_io.cpp.

138 {
139  DS_DATA_MODEL_FILEIO writer( aFullFileName );
140  writer.Format( this );
141 }

References DS_DATA_MODEL_IO::Format().

Referenced by PL_EDITOR_FRAME::SaveDrawingSheetFile().

◆ SaveInString() [1/2]

void DS_DATA_MODEL::SaveInString ( wxString *  aOutputString)

Save the description in a buffer.

Parameters
aOutputStringis a wxString to store the S expr string

Definition at line 144 of file ds_data_model_io.cpp.

145 {
146  DS_DATA_MODEL_STRINGIO writer( aOutputString );
147  writer.Format( this );
148 }

References DS_DATA_MODEL_IO::Format().

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

◆ SaveInString() [2/2]

void DS_DATA_MODEL::SaveInString ( std::vector< DS_DATA_ITEM * > &  aItemsList,
wxString *  aOutputString 
)

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

Definition at line 151 of file ds_data_model_io.cpp.

152 {
153  DS_DATA_MODEL_STRINGIO writer( aOutputString );
154 
155  LOCALE_IO toggle; // switch on/off the locale "C" notation
156 
157  for( DS_DATA_ITEM* item : aItemsList )
158  writer.Format( this, item, 0 );
159 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
Drawing sheet structure type definitions.
Definition: ds_data_item.h:95

References DS_DATA_MODEL_IO::Format().

◆ SetAltInstance()

void DS_DATA_MODEL::SetAltInstance ( DS_DATA_MODEL aLayout = nullptr)
static

Set an alternate instance of DS_DATA_MODEL.

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

Parameters
aLayoutthe alternate drawing sheet; if null restore the default drawing sheet
aLayout= the alternate drawing sheet. if null, restore the basic drawing sheet

Definition at line 93 of file ds_data_model.cpp.

94 {
95  wksAltInstance = aLayout;
96 }
static DS_DATA_MODEL * wksAltInstance

References wksAltInstance.

Referenced by DIALOG_PAGES_SETTINGS::UpdateDrawingSheetExample().

◆ SetBottomMargin()

void DS_DATA_MODEL::SetBottomMargin ( double  aMargin)
inline

◆ SetDefaultLayout()

void DS_DATA_MODEL::SetDefaultLayout ( )

Definition at line 828 of file drawing_sheet_reader.cpp.

829 {
830  SetPageLayout( defaultDrawingSheet, false, wxT( "default page" ) );
831 }
const char defaultDrawingSheet[]
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.

References defaultDrawingSheet, and SetPageLayout().

Referenced by LoadDrawingSheet().

◆ SetEmptyLayout()

void DS_DATA_MODEL::SetEmptyLayout ( )

Definition at line 843 of file drawing_sheet_reader.cpp.

844 {
845  SetPageLayout( emptyDrawingSheet, false, wxT( "empty page" ) );
846 }
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.
const char emptyDrawingSheet[]

References emptyDrawingSheet, and SetPageLayout().

Referenced by SCH_EDIT_FRAME::importFile().

◆ SetFileFormatVersionAtLoad()

void DS_DATA_MODEL::SetFileFormatVersionAtLoad ( int  aVersion)
inline

Definition at line 61 of file ds_data_model.h.

61 { m_fileFormatVersionAtLoad = aVersion; }
int m_fileFormatVersionAtLoad

References m_fileFormatVersionAtLoad.

Referenced by DRAWING_SHEET_READER_PARSER::Parse().

◆ SetLeftMargin()

void DS_DATA_MODEL::SetLeftMargin ( double  aMargin)
inline

Definition at line 64 of file ds_data_model.h.

64 { m_leftMargin = aMargin; }
double m_leftMargin

References m_leftMargin.

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

◆ SetPageLayout()

void DS_DATA_MODEL::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.

Parameters
aPageLayoutis 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 855 of file drawing_sheet_reader.cpp.

856 {
857  if( ! Append )
858  ClearList();
859 
860  DRAWING_SHEET_READER_PARSER lp_parser( aPageLayout, wxT( "Sexpr_string" ) );
861 
862  try
863  {
864  lp_parser.Parse( this );
865  }
866  catch( const IO_ERROR& ioe )
867  {
868  wxLogMessage( ioe.What() );
869  }
870 }
void ClearList()
Erase the list of items.
DRAWING_SHEET_READER_PARSER holds data and functions pertinent to parsing a S-expression file for a D...
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
void Append(DS_DATA_ITEM *aItem)

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

Referenced by DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS(), PL_EDIT_TOOL::Paste(), DS_PROXY_UNDO_ITEM::Restore(), SetDefaultLayout(), and SetEmptyLayout().

◆ SetRightMargin()

void DS_DATA_MODEL::SetRightMargin ( double  aMargin)
inline

Definition at line 67 of file ds_data_model.h.

67 { m_rightMargin = aMargin; }
double m_rightMargin

References m_rightMargin.

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

◆ SetTopMargin()

void DS_DATA_MODEL::SetTopMargin ( double  aMargin)
inline

Definition at line 70 of file ds_data_model.h.

70 { m_topMargin = aMargin; }
double m_topMargin

References m_topMargin.

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

◆ SetupDrawEnvironment()

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

Definition at line 99 of file ds_data_model.cpp.

100 {
101 #define MILS_TO_MM (25.4/1000)
102 
103  m_WSunits2Iu = aMilsToIU / MILS_TO_MM;
104 
105  // Left top corner position
106  DPOINT lt_corner;
107  lt_corner.x = GetLeftMargin();
108  lt_corner.y = GetTopMargin();
109  m_LT_Corner = lt_corner;
110 
111  // Right bottom corner position
112  DPOINT rb_corner;
113  rb_corner.x = ( aPageInfo.GetSizeMils().x * MILS_TO_MM ) - GetRightMargin();
114  rb_corner.y = ( aPageInfo.GetSizeMils().y * MILS_TO_MM ) - GetBottomMargin();
115  m_RB_Corner = rb_corner;
116 }
double GetRightMargin()
Definition: ds_data_model.h:66
double GetTopMargin()
Definition: ds_data_model.h:69
double GetLeftMargin()
Definition: ds_data_model.h:63
DPOINT m_RB_Corner
DPOINT m_LT_Corner
double GetBottomMargin()
Definition: ds_data_model.h:72
#define MILS_TO_MM
double m_WSunits2Iu
const wxSize & GetSizeMils() const
Definition: page_info.h:135

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 DS_DRAW_ITEM_LIST::BuildDrawItemsList().

◆ VoidListAllowed()

bool DS_DATA_MODEL::VoidListAllowed ( )
inline
Returns
true if an empty list is allowed

Definition at line 88 of file ds_data_model.h.

88 { return m_allowVoidList; }

References m_allowVoidList.

Referenced by DS_DRAW_ITEM_LIST::BuildDrawItemsList().

Member Data Documentation

◆ m_allowVoidList

bool DS_DATA_MODEL::m_allowVoidList
private

Definition at line 211 of file ds_data_model.h.

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

◆ m_bottomMargin

double DS_DATA_MODEL::m_bottomMargin
private

Definition at line 218 of file ds_data_model.h.

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

◆ m_DefaultLineWidth

◆ m_DefaultTextSize

◆ m_DefaultTextThickness

◆ m_EditMode

◆ m_fileFormatVersionAtLoad

int DS_DATA_MODEL::m_fileFormatVersionAtLoad
private

◆ m_leftMargin

double DS_DATA_MODEL::m_leftMargin
private

Definition at line 215 of file ds_data_model.h.

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

◆ m_list

std::vector<DS_DATA_ITEM*> DS_DATA_MODEL::m_list
private

Definition at line 210 of file ds_data_model.h.

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

◆ m_LT_Corner

◆ m_RB_Corner

◆ m_rightMargin

double DS_DATA_MODEL::m_rightMargin
private

Definition at line 216 of file ds_data_model.h.

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

◆ m_topMargin

double DS_DATA_MODEL::m_topMargin
private

Definition at line 217 of file ds_data_model.h.

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

◆ m_WSunits2Iu


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