From 76aa3f6e1c18bf2e54f27881f9c51fa029cf79bb Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Wed, 10 Nov 2010 10:30:12 -0500 Subject: [PATCH] EESchema schematic object refactoring and header rationalization. --- CHANGELOG.txt | 7 + common/dialog_page_settings.cpp | 3 +- common/sch_item_struct.cpp | 8 +- eeschema/CMakeLists.txt | 1 - eeschema/annotate.cpp | 4 +- eeschema/annotate_dialog.cpp | 2 +- eeschema/annotate_dialog.h | 5 + eeschema/backanno.cpp | 7 +- eeschema/block.cpp | 9 +- eeschema/block_libedit.cpp | 1 - eeschema/build_BOM.cpp | 5 +- eeschema/bus-wire-junction.cpp | 7 +- eeschema/busentry.cpp | 8 +- eeschema/class_drawsheet.cpp | 157 +++- eeschema/class_drawsheet.h | 32 +- eeschema/class_drawsheetpath.cpp | 8 +- eeschema/class_drawsheetpath.h | 4 + eeschema/class_hierarchical_PIN_sheet.cpp | 73 +- eeschema/class_libentry.cpp | 5 +- eeschema/class_libentry.h | 1 + eeschema/class_library.cpp | 3 +- eeschema/class_library.h | 3 + eeschema/class_marker_sch.cpp | 9 +- eeschema/class_netlist_object.cpp | 6 +- eeschema/class_netlist_object.h | 2 + eeschema/class_sch_cmp_field.cpp | 6 +- eeschema/class_sch_cmp_field.h | 6 + eeschema/class_sch_component.cpp | 325 ++++++- eeschema/class_sch_component.h | 12 +- eeschema/class_sch_screen.cpp | 8 +- eeschema/class_schematic_items.cpp | 167 +++- eeschema/class_schematic_items.h | 66 +- eeschema/class_text-label.cpp | 269 +++++- eeschema/class_text-label.h | 50 +- eeschema/cleanup.cpp | 3 +- eeschema/controle.cpp | 7 +- eeschema/cross-probing.cpp | 4 +- eeschema/dangling_ends.cpp | 4 +- eeschema/database.cpp | 6 +- eeschema/delete.cpp | 12 +- eeschema/delsheet.cpp | 4 +- eeschema/dialog_SVG_print.cpp | 5 +- eeschema/dialog_build_BOM.cpp | 2 +- eeschema/dialog_build_BOM.h | 5 + eeschema/dialog_create_component.cpp | 1 - eeschema/dialog_edit_component_in_lib.cpp | 2 - .../dialog_edit_component_in_schematic.cpp | 4 +- eeschema/dialog_edit_component_in_schematic.h | 3 + eeschema/dialog_edit_label.cpp | 4 +- eeschema/dialog_edit_label.h | 5 + .../dialog_edit_libentry_fields_in_lib.cpp | 4 +- eeschema/dialog_eeschema_config.cpp | 2 +- eeschema/dialog_erc.cpp | 3 +- eeschema/dialog_erc_listbox.h | 2 +- eeschema/dialog_libedit_dimensions.cpp | 5 +- eeschema/dialog_print_using_printer.cpp | 5 +- .../dialogs/dialog_plot_schematic_DXF.cpp | 5 +- .../dialogs/dialog_plot_schematic_HPGL.cpp | 5 +- eeschema/dialogs/dialog_plot_schematic_PS.cpp | 5 +- eeschema/edit_component_in_lib.cpp | 3 +- eeschema/edit_component_in_schematic.cpp | 4 +- eeschema/edit_graphic_bodyitem_text.cpp | 1 - eeschema/edit_label.cpp | 5 +- eeschema/eelayer.cpp | 2 +- eeschema/eelayer.h | 3 + eeschema/eelibs_read_libraryfiles.cpp | 3 +- eeschema/eeredraw.cpp | 8 +- eeschema/eeschema.cpp | 3 +- eeschema/eeschema_config.cpp | 7 +- eeschema/eeschema_config.h | 2 - eeschema/erc.cpp | 5 +- eeschema/events_called_functions_for_edit.cpp | 7 +- eeschema/files-io.cpp | 3 +- eeschema/find.cpp | 6 +- eeschema/general.h | 33 +- eeschema/getpart.cpp | 4 +- eeschema/hierarch.cpp | 5 +- eeschema/hotkeys.cpp | 5 +- eeschema/lib_arc.cpp | 2 + eeschema/lib_bezier.cpp | 2 + eeschema/lib_circle.cpp | 1 + eeschema/lib_export.cpp | 1 - eeschema/lib_field.cpp | 3 +- eeschema/lib_field.h | 2 +- eeschema/lib_pin.cpp | 3 +- eeschema/lib_polyline.cpp | 4 + eeschema/lib_rectangle.cpp | 1 + eeschema/lib_text.cpp | 3 +- eeschema/libarch.cpp | 5 +- eeschema/libedit.cpp | 6 +- eeschema/libedit_onleftclick.cpp | 1 - eeschema/libedit_onrightclick.cpp | 3 +- eeschema/libedit_plot_component.cpp | 5 +- eeschema/libedit_undo_redo.cpp | 1 - eeschema/libeditframe.cpp | 4 +- eeschema/libeditframe.h | 4 +- eeschema/libfield.cpp | 3 +- eeschema/load_one_schematic_file.cpp | 368 ++++---- eeschema/locate.cpp | 7 +- eeschema/menubar.cpp | 2 +- eeschema/menubar_libedit.cpp | 2 - eeschema/netform.cpp | 9 +- eeschema/netlist.cpp | 9 +- eeschema/netlist.h | 5 + eeschema/netlist_control.cpp | 5 +- eeschema/onleftclick.cpp | 7 +- eeschema/onrightclick.cpp | 9 +- eeschema/operations_on_items_lists.cpp | 7 +- eeschema/pinedit.cpp | 2 +- eeschema/plot.cpp | 6 +- eeschema/program.h | 54 -- ...from_file_schematic_items_descriptions.cpp | 843 ------------------ eeschema/schedit.cpp | 8 +- eeschema/schematic_undo_redo.cpp | 6 +- eeschema/schframe.cpp | 4 +- eeschema/selpart.cpp | 2 +- eeschema/sheet.cpp | 7 +- eeschema/sheetlab.cpp | 5 +- eeschema/symbdraw.cpp | 2 +- eeschema/symbedit.cpp | 3 +- eeschema/tool_lib.cpp | 1 - eeschema/tool_sch.cpp | 2 +- eeschema/tool_viewlib.cpp | 3 +- eeschema/viewlib_frame.cpp | 3 +- eeschema/viewlib_frame.h | 8 + eeschema/viewlibs.cpp | 3 +- include/sch_item_struct.h | 10 + 127 files changed, 1710 insertions(+), 1241 deletions(-) delete mode 100644 eeschema/program.h delete mode 100644 eeschema/read_from_file_schematic_items_descriptions.cpp diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 952aa093a6..300321947e 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,6 +4,13 @@ KiCad ChangeLog 2010 Please add newer entries at the top, list the date and your name with email address. +2010-nov-10 UPDATE Wayne Stambaugh +================================================================================ +++EESchema + * Header file rationalization. + * Move schematic object load code into the appropriate schematic object. + + 2010-nov-3 UPDATE Wayne Stambaugh ================================================================================ ++common diff --git a/common/dialog_page_settings.cpp b/common/dialog_page_settings.cpp index ad7d38c744..909de97fa8 100644 --- a/common/dialog_page_settings.cpp +++ b/common/dialog_page_settings.cpp @@ -12,13 +12,12 @@ #include "common.h" #include "base_struct.h" #include "class_drawpanel.h" -#include "class_base_screen.h" +#include "class_sch_screen.h" #include "wxstruct.h" #include "wx/valgen.h" #ifdef EESCHEMA -#include "program.h" #include "general.h" #endif diff --git a/common/sch_item_struct.cpp b/common/sch_item_struct.cpp index 6fabfa43c2..3163c657ee 100644 --- a/common/sch_item_struct.cpp +++ b/common/sch_item_struct.cpp @@ -11,7 +11,6 @@ #include "class_drawpanel.h" #include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" @@ -29,10 +28,17 @@ SCH_ITEM::SCH_ITEM( EDA_BaseStruct* aParent, KICAD_T aType ) : m_Layer = 0; } + SCH_ITEM::~SCH_ITEM() { + // Do not let the connections container go out of scope with any ojbects or they + // will be deleted by the container will cause the EESchema to crash. These objects + // are owned by the sheet object container. + if( !m_connections.empty() ) + m_connections.release(); } + /** * place the struct in EEDrawList. * if it is a new item, it it also put in undo list diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index e94d771730..8902c98862 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -122,7 +122,6 @@ set(EESCHEMA_SRCS operations_on_items_lists.cpp pinedit.cpp plot.cpp - read_from_file_schematic_items_descriptions.cpp schedit.cpp schematic_undo_redo.cpp schframe.cpp diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp index 9666ff2bcd..5530a8253c 100644 --- a/eeschema/annotate.cpp +++ b/eeschema/annotate.cpp @@ -10,10 +10,12 @@ #include "class_drawpanel.h" #include "confirm.h" #include "wxstruct.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "class_library.h" #include "protos.h" +#include "class_sch_screen.h" +#include "class_sch_component.h" #include "netlist.h" #include "lib_pin.h" diff --git a/eeschema/annotate_dialog.cpp b/eeschema/annotate_dialog.cpp index 9cf43da6b1..1a5a6e2aad 100644 --- a/eeschema/annotate_dialog.cpp +++ b/eeschema/annotate_dialog.cpp @@ -8,7 +8,7 @@ #include "appl_wxstruct.h" #include "bitmaps.h" #include "common.h" -#include "program.h" +#include "wxEeschemaStruct.h" #include "annotate_dialog.h" diff --git a/eeschema/annotate_dialog.h b/eeschema/annotate_dialog.h index e25c24b8d8..4b4c6af63c 100644 --- a/eeschema/annotate_dialog.h +++ b/eeschema/annotate_dialog.h @@ -26,6 +26,11 @@ #include "dialog_annotate_base.h" + +class WinEDA_SchematicFrame; +class wxConfig; + + /*! * DIALOG_ANNOTATE class declaration */ diff --git a/eeschema/backanno.cpp b/eeschema/backanno.cpp index 85adffd464..cace3b17b3 100644 --- a/eeschema/backanno.cpp +++ b/eeschema/backanno.cpp @@ -5,15 +5,16 @@ #include "fctsys.h" #include "common.h" -#include "program.h" #include "confirm.h" #include "kicad_string.h" #include "gestfich.h" #include "appl_wxstruct.h" +#include "wxEeschemaStruct.h" +#include "build_version.h" #include "general.h" - -#include "build_version.h" +#include "class_drawsheetpath.h" +#include "class_sch_component.h" /** function FillFootprintFieldForAllInstancesofComponent diff --git a/eeschema/block.cpp b/eeschema/block.cpp index 395c6f9e90..167590958f 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -9,13 +9,20 @@ #include "class_drawpanel.h" #include "confirm.h" #include "block_commande.h" +#include "wxEeschemaStruct.h" +#include "class_sch_screen.h" -#include "program.h" #include "general.h" #include "class_marker_sch.h" #include "class_library.h" #include "lib_pin.h" #include "protos.h" +#include "class_schematic_items.h" +#include "class_text-label.h" +#include "class_sch_component.h" +#include "class_drawsheet.h" + +#include // Imported functions: diff --git a/eeschema/block_libedit.cpp b/eeschema/block_libedit.cpp index aafb51cb0b..dab78a1c5c 100644 --- a/eeschema/block_libedit.cpp +++ b/eeschema/block_libedit.cpp @@ -9,7 +9,6 @@ #include "confirm.h" #include "block_commande.h" -#include "program.h" #include "general.h" #include "class_library.h" #include "protos.h" diff --git a/eeschema/build_BOM.cpp b/eeschema/build_BOM.cpp index 0323bef5a0..f067bee29a 100644 --- a/eeschema/build_BOM.cpp +++ b/eeschema/build_BOM.cpp @@ -15,12 +15,15 @@ #include "kicad_string.h" #include "gestfich.h" #include "appl_wxstruct.h" +#include "class_sch_screen.h" -#include "program.h" #include "general.h" #include "class_library.h" #include "netlist.h" #include "protos.h" +#include "class_drawsheet.h" +#include "template_fieldnames.h" +#include "class_sch_component.h" #include "build_version.h" diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index c91aa5f3f8..6f720405b3 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -7,12 +7,17 @@ #include "common.h" #include "class_drawpanel.h" #include "confirm.h" +#include "wxEeschemaStruct.h" +#include "class_sch_screen.h" -#include "program.h" #include "lib_draw_item.h" #include "lib_pin.h" #include "general.h" #include "protos.h" +#include "class_schematic_items.h" +#include "class_text-label.h" +#include "class_sch_component.h" +#include "class_drawsheet.h" /* Routines Locales */ diff --git a/eeschema/busentry.cpp b/eeschema/busentry.cpp index 27b87539e9..c9d6511a4e 100644 --- a/eeschema/busentry.cpp +++ b/eeschema/busentry.cpp @@ -8,10 +8,13 @@ #include "class_drawpanel.h" #include "eeschema_id.h" #include "confirm.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" +#include "class_schematic_items.h" + static int s_LastShape = '\\'; static wxPoint ItemInitialPosition; @@ -20,8 +23,7 @@ static wxPoint ItemInitialPosition; static void ExitBusEntry( WinEDA_DrawPanel* Panel, wxDC* DC ) { /* Exit bus entry mode. */ - SCH_BUS_ENTRY* BusEntry = - (SCH_BUS_ENTRY*) Panel->GetScreen()->GetCurItem(); + SCH_BUS_ENTRY* BusEntry = (SCH_BUS_ENTRY*) Panel->GetScreen()->GetCurItem(); if( BusEntry ) { diff --git a/eeschema/class_drawsheet.cpp b/eeschema/class_drawsheet.cpp index 1f0cded178..429ab17995 100644 --- a/eeschema/class_drawsheet.cpp +++ b/eeschema/class_drawsheet.cpp @@ -13,18 +13,23 @@ #include "fctsys.h" #include "gr_basic.h" #include "common.h" +#include "macros.h" #include "class_drawpanel.h" #include "drawtxt.h" #include "confirm.h" #include "trigo.h" +#include "richio.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" +#include "class_drawsheet.h" +#include "class_drawsheetpath.h" +#include "class_sch_component.h" -SCH_SHEET::SCH_SHEET( const wxPoint& pos ) : - SCH_ITEM( NULL, DRAW_SHEET_STRUCT_TYPE ) +SCH_SHEET::SCH_SHEET( const wxPoint& pos ) : SCH_ITEM( NULL, DRAW_SHEET_STRUCT_TYPE ) { m_Layer = LAYER_SHEET; m_Pos = pos; @@ -96,6 +101,152 @@ bool SCH_SHEET::Save( FILE* aFile ) const } +bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg ) +{ + int ii, fieldNdx, size; + char Name1[256]; + SCH_SHEET_PIN* SheetLabel; + char* ptcar; + + m_TimeStamp = GetTimeStamp(); + + // sheets are added to the EEDrawList like other schematic components. + // however, in order to preserve the hierarchy (through m_Parent pointers), + // a duplicate of the sheet is added to m_SubSheet array. + // must be a duplicate, references just work for a two-layer structure. + // this is accomplished through the Sync() function. + + if( ((char*)aLine)[0] == '$' ) // line should be "$Sheet" + { + if( !aLine.ReadLine() ) + { + aErrorMsg.Printf( wxT( "Read File Errror" ) ); + return false; + } + } + + /* Next line: must be "S xx yy nn mm" with xx, yy = sheet position + * ( upper left corner ) et nn,mm = sheet size */ + if( ( sscanf( &((char*)aLine)[1], "%d %d %d %d", + &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Size.y ) != 4 ) + || ( ((char*)aLine)[0] != 'S' ) ) + { + aErrorMsg.Printf( wxT( " ** EESchema file sheet struct error at line %d, aborted\n" ), + aLine.LineNumber() ); + + aErrorMsg << CONV_FROM_UTF8( ((char*)aLine) ); + return false; + } + + /* Read fields */ + for( ; ; ) /* Analysis of lines "Fn" text. */ + { + if( !aLine.ReadLine() ) + return false; + + if( ((char*)aLine)[0] == 'U' ) + { + sscanf( ((char*)aLine) + 1, "%lX", &m_TimeStamp ); + if( m_TimeStamp == 0 ) // zero is not unique! + m_TimeStamp = GetTimeStamp(); + continue; + } + + if( ((char*)aLine)[0] != 'F' ) + break; + + sscanf( ((char*)aLine) + 1, "%d", &fieldNdx ); + + /* Read the field: + * If fieldNdx> = 2: Fn "text" t s posx posy + * If F0 "text" for SheetName + * F1 and "text" for filename + */ + ptcar = ((char*)aLine); + while( *ptcar && ( *ptcar != '"' ) ) + ptcar++; + + if( *ptcar != '"' ) + { + aErrorMsg.Printf( wxT( "EESchema file sheet label F%d at line %d, aborted\n" ), + fieldNdx, aLine.LineNumber() ); + aErrorMsg << CONV_FROM_UTF8( (char*) aLine ); + return false; + } + + for( ptcar++, ii = 0; ; ii++, ptcar++ ) + { + Name1[ii] = *ptcar; + + if( *ptcar == 0 ) + { + aErrorMsg.Printf( wxT( "EESchema file sheet field F at line %d, aborted\n" ), + aLine.LineNumber() ); + aErrorMsg << CONV_FROM_UTF8( (char*) aLine ); + return false; + } + + if( *ptcar == '"' ) + { + Name1[ii] = 0; + ptcar++; + break; + } + } + + if( ( fieldNdx == 0 ) || ( fieldNdx == 1 ) ) + { + if( sscanf( ptcar, "%d", &size ) != 1 ) + { + aErrorMsg.Printf( wxT( "EESchema file sheet Label error line %d, aborted\n" ), + aLine.LineNumber() ); + + aErrorMsg << CONV_FROM_UTF8( (char*) aLine ); + } + if( size == 0 ) + size = DEFAULT_SIZE_TEXT; + + if( fieldNdx == 0 ) + { + m_SheetName = CONV_FROM_UTF8( Name1 ); + m_SheetNameSize = size; + } + else + { + SetFileName( CONV_FROM_UTF8( Name1 ) ); + + //printf( "in ReadSheetDescr : m_FileName = %s \n", Name1 ); + m_FileNameSize = size; + } + } + + if( fieldNdx > 1 ) + { + SheetLabel = new SCH_SHEET_PIN( this ); + + if( !SheetLabel->Load( aLine, aErrorMsg ) ) + { + delete SheetLabel; + SheetLabel = NULL; + return false; + } + + AddLabel( SheetLabel ); + } + } + + if( strnicmp( "$End", ((char*)aLine), 4 ) != 0 ) + { + aErrorMsg.Printf( wxT( "**EESchema file end_sheet struct error at line %d, aborted\n" ), + aLine.LineNumber() ); + aErrorMsg << CONV_FROM_UTF8( ((char*)aLine) ); + return false; + } + + return true; +} + + /* creates a copy of a sheet * The linked data itself (EEDrawList) is not duplicated */ diff --git a/eeschema/class_drawsheet.h b/eeschema/class_drawsheet.h index 03ddac4d1b..c3ff7ece59 100644 --- a/eeschema/class_drawsheet.h +++ b/eeschema/class_drawsheet.h @@ -5,12 +5,19 @@ #ifndef CLASS_DRAWSHEET_H #define CLASS_DRAWSHEET_H -#include "base_struct.h" #include #include #include "class_text-label.h" -extern SCH_SHEET* g_RootSheet; + +class LINE_READER; +class SCH_SCREEN; +class SCH_SHEET; +class SCH_SHEET_PIN; +class SCH_SHEET_PATH; +class DANGLING_END_ITEM; +class WinEDA_SchematicFrame; + /** * Pin (label) used in sheets to create hierarchical schematics. @@ -117,6 +124,16 @@ public: */ bool Save( FILE* aFile ) const; + /** + * Load schematic sheet hierarchical lable from \a aLine in a .sch file. + * + * @param aLine - Essentially this is file to read the sheet hierarchical label from. + * @param aErrorMsg - Description of the error if an error occurs while loading the sheet + * hierarchical label. + * @return True if the sheet heirarchical label loaded successfully. + */ + virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); + #if defined(DEBUG) // comment inherited by Doxygen from Base_Struct @@ -169,7 +186,7 @@ public: */ virtual bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ); - virtual void GetEndPoints( std::vector & aItemList ); + virtual void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ); }; @@ -229,6 +246,15 @@ public: */ bool Save( FILE* aFile ) const; + /** + * Load schematic sheet from \a aLine in a .sch file. + * + * @param aLine - Essentially this is file to read the component from. + * @param aErrorMsg - Description of the error if an error occurs while loading the sheet. + * @return True if the sheet loaded successfully. + */ + virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); + void Place( WinEDA_SchematicFrame* frame, wxDC* DC ); SCH_SHEET* GenCopy(); void DisplayInfo( WinEDA_DrawFrame* frame ); diff --git a/eeschema/class_drawsheetpath.cpp b/eeschema/class_drawsheetpath.cpp index c47b6a1643..7381e81e85 100644 --- a/eeschema/class_drawsheetpath.cpp +++ b/eeschema/class_drawsheetpath.cpp @@ -10,9 +10,15 @@ #include "fctsys.h" #include "common.h" -#include "program.h" #include "general.h" #include "dlist.h" +#include "class_sch_screen.h" +#include "sch_item_struct.h" + +#include "class_drawsheet.h" +#include "class_drawsheetpath.h" +#include "class_sch_component.h" +#include "template_fieldnames.h" #include "dialogs/dialog_schematic_find.h" diff --git a/eeschema/class_drawsheetpath.h b/eeschema/class_drawsheetpath.h index f32d096fad..b142fe863a 100644 --- a/eeschema/class_drawsheetpath.h +++ b/eeschema/class_drawsheetpath.h @@ -50,7 +50,11 @@ */ +class wxFindReplaceData; +class SCH_SCREEN; class SCH_MARKER; +class SCH_SHEET; +class SCH_ITEM; /** diff --git a/eeschema/class_hierarchical_PIN_sheet.cpp b/eeschema/class_hierarchical_PIN_sheet.cpp index 3a43994b9d..02603df048 100644 --- a/eeschema/class_hierarchical_PIN_sheet.cpp +++ b/eeschema/class_hierarchical_PIN_sheet.cpp @@ -18,10 +18,13 @@ #include "drawtxt.h" #include "plot_common.h" #include "trigo.h" +#include "richio.h" +#include "class_sch_screen.h" -#include "program.h" #include "general.h" #include "protos.h" +#include "class_drawsheet.h" + /* m_Edge define on which edge the pin is positionned: * @@ -259,6 +262,74 @@ bool SCH_SHEET_PIN::Save( FILE* aFile ) const } +bool SCH_SHEET_PIN::Load( LINE_READER& aLine, wxString& aErrorMsg ) +{ + int size; + char number[256]; + char name[256]; + char connectType[256]; + char sheetSide[256]; + + /* Read coordinates. */ + if( sscanf( ((char*)aLine), "%s %s %s %s %d %d %d", + number, name, connectType, sheetSide, &m_Pos.x, &m_Pos.y, &size ) != 7 ) + { + aErrorMsg.Printf( wxT( "EESchema file sheet hierarchical label error at line %d.\n" ), + aLine.LineNumber() ); + aErrorMsg << CONV_FROM_UTF8( ((char*)aLine) ); + return false; + } + + m_Text = CONV_FROM_UTF8( name ); + + m_Text = m_Text.AfterFirst( wxChar( '"' ) ); + m_Text = m_Text.BeforeLast( wxChar( '"' ) ); + + if( size == 0 ) + size = DEFAULT_SIZE_TEXT; + + m_Size.x = m_Size.y = size; + + switch( connectType[0] ) + { + case 'I': + m_Shape = NET_INPUT; + break; + case 'O': + m_Shape = NET_OUTPUT; + break; + case 'B': + m_Shape = NET_BIDI; + break; + case 'T': + m_Shape = NET_TRISTATE; + break; + case 'U': + m_Shape = NET_UNSPECIFIED; + break; + } + + switch( sheetSide[0] ) + { + case 'R' : /* pin on right side */ + SetEdge( 1 ); + break; + case 'T' : /* pin on top side */ + SetEdge( 2 ); + break; + case 'B' : /* pin on bottom side */ + SetEdge( 3 ); + break; + case 'L' : /* pin on left side */ + default : + SetEdge( 0 ); + break; + } + + return true; +} + + /** function Matches * Compare hierarchical pin name against search string. * @param aSearchData - Criteria to search against. diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index 535438c471..bcd8efe1a4 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -4,14 +4,17 @@ #include "fctsys.h" #include "common.h" +#include "macros.h" #include "kicad_string.h" #include "class_drawpanel.h" #include "plot_common.h" #include "gr_basic.h" +#include "class_sch_screen.h" -#include "program.h" #include "general.h" #include "protos.h" +#include "template_fieldnames.h" +#include "transform.h" #include "class_library.h" #include "class_libentry.h" #include "lib_pin.h" diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h index 13ebf18fa9..ab5004b05a 100644 --- a/eeschema/class_libentry.h +++ b/eeschema/class_libentry.h @@ -5,6 +5,7 @@ #ifndef CLASS_LIBENTRY_H #define CLASS_LIBENTRY_H +#include "general.h" #include "lib_draw_item.h" #include "lib_field.h" diff --git a/eeschema/class_library.cpp b/eeschema/class_library.cpp index c6d0093ae7..c8361259f8 100644 --- a/eeschema/class_library.cpp +++ b/eeschema/class_library.cpp @@ -5,12 +5,13 @@ #include "fctsys.h" #include "gr_basic.h" #include "common.h" +#include "macros.h" #include "kicad_string.h" #include "confirm.h" #include "gestfich.h" #include "eda_doc.h" +#include "wxstruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "class_library.h" diff --git a/eeschema/class_library.h b/eeschema/class_library.h index 77a650d83b..309a78fd1d 100644 --- a/eeschema/class_library.h +++ b/eeschema/class_library.h @@ -6,8 +6,11 @@ #define CLASS_LIBRARY_H +#include + #include "class_libentry.h" + /* * Component Library version and file header macros. */ diff --git a/eeschema/class_marker_sch.cpp b/eeschema/class_marker_sch.cpp index 4ef1ef7320..b0dbc950ba 100644 --- a/eeschema/class_marker_sch.cpp +++ b/eeschema/class_marker_sch.cpp @@ -3,16 +3,16 @@ /*******************************************/ #include "fctsys.h" +#include "wxstruct.h" #include "class_drawpanel.h" - #include "common.h" -#include "program.h" -#include "general.h" #include "trigo.h" +#include "general.h" #include "class_marker_sch.h" #include "erc.h" + /* Marker are mainly used to show an ERC error * but they could be used to give a specific info */ @@ -51,8 +51,7 @@ SCH_MARKER::~SCH_MARKER() SCH_MARKER* SCH_MARKER::GenCopy() { - SCH_MARKER* newitem = new SCH_MARKER( GetPos(), - GetReporter().GetMainText() ); + SCH_MARKER* newitem = new SCH_MARKER( GetPos(), GetReporter().GetMainText() ); newitem->SetMarkerType( GetMarkerType() ); newitem->SetErrorLevel( GetErrorLevel() ); diff --git a/eeschema/class_netlist_object.cpp b/eeschema/class_netlist_object.cpp index 7fa0c7a2bf..9a9d7c581c 100644 --- a/eeschema/class_netlist_object.cpp +++ b/eeschema/class_netlist_object.cpp @@ -5,9 +5,11 @@ #include "fctsys.h" #include "common.h" -#include "program.h" -#include "general.h" +#include "macros.h" +#include "wxEeschemaStruct.h" +#include "general.h" +#include "class_sch_component.h" #include "class_netlist_object.h" #if defined(DEBUG) diff --git a/eeschema/class_netlist_object.h b/eeschema/class_netlist_object.h index 9147151a32..f955ac4285 100644 --- a/eeschema/class_netlist_object.h +++ b/eeschema/class_netlist_object.h @@ -6,6 +6,8 @@ #ifndef _CLASS_NETLIST_OBJECT_H_ #define _CLASS_NETLIST_OBJECT_H_ +#include "class_drawsheetpath.h" + #include "lib_pin.h" // LIB_PIN::ReturnPinStringNum( m_PinNum ) diff --git a/eeschema/class_sch_cmp_field.cpp b/eeschema/class_sch_cmp_field.cpp index d4a7942ca8..5c40540975 100644 --- a/eeschema/class_sch_cmp_field.cpp +++ b/eeschema/class_sch_cmp_field.cpp @@ -18,11 +18,15 @@ #include "drawtxt.h" #include "macros.h" #include "trigo.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "class_library.h" +#include "class_sch_component.h" +#include "class_sch_cmp_field.h" +#include "template_fieldnames.h" SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, diff --git a/eeschema/class_sch_cmp_field.h b/eeschema/class_sch_cmp_field.h index bccc8ee23f..7c5a8285a9 100644 --- a/eeschema/class_sch_cmp_field.h +++ b/eeschema/class_sch_cmp_field.h @@ -14,6 +14,12 @@ */ +#include "sch_item_struct.h" + +#include "general.h" + + +class WinEDA_SchematicFrame; class SCH_COMPONENT; class LIB_FIELD; diff --git a/eeschema/class_sch_component.cpp b/eeschema/class_sch_component.cpp index de22999356..96caa58367 100644 --- a/eeschema/class_sch_component.cpp +++ b/eeschema/class_sch_component.cpp @@ -8,16 +8,23 @@ #include "gr_basic.h" #include "common.h" #include "trigo.h" +#include "kicad_string.h" +#include "richio.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "macros.h" #include "protos.h" #include "class_library.h" -#include "dialogs/dialog_schematic_find.h" #include "lib_rectangle.h" #include "lib_pin.h" #include "lib_text.h" +#include "class_sch_component.h" +#include "class_drawsheet.h" +#include "class_drawsheetpath.h" +#include "template_fieldnames.h" + +#include "dialogs/dialog_schematic_find.h" #include @@ -1092,6 +1099,320 @@ bool SCH_COMPONENT::Save( FILE* f ) const } +bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) +{ + int ii; + char Name1[256], Name2[256], + Char1[256], Char2[256], Char3[256]; + int newfmt = 0; + char* ptcar; + wxString fieldName; + + m_Convert = 1; + + if( ((char*)aLine)[0] == '$' ) + { + newfmt = 1; + + if( !aLine.ReadLine() ) + return TRUE; + } + + if( sscanf( &((char*)aLine)[1], "%s %s", Name1, Name2 ) != 2 ) + { + aErrorMsg.Printf( wxT( "EESchema Component descr error at line %d, aborted" ), + aLine.LineNumber() ); + aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( ((char*)aLine) ); + return false; + } + + if( strcmp( Name1, NULL_STRING ) != 0 ) + { + for( ii = 0; ii < (int) strlen( Name1 ); ii++ ) + if( Name1[ii] == '~' ) + Name1[ii] = ' '; + + m_ChipName = CONV_FROM_UTF8( Name1 ); + if( !newfmt ) + GetField( VALUE )->m_Text = CONV_FROM_UTF8( Name1 ); + } + else + { + m_ChipName.Empty(); + GetField( VALUE )->m_Text.Empty(); + GetField( VALUE )->m_Orient = TEXT_ORIENT_HORIZ; + GetField( VALUE )->m_Attributs = TEXT_NO_VISIBLE; + } + + if( strcmp( Name2, NULL_STRING ) != 0 ) + { + bool isDigit = false; + for( ii = 0; ii < (int) strlen( Name2 ); ii++ ) + { + if( Name2[ii] == '~' ) + Name2[ii] = ' '; + + // get RefBase from this, too. store in Name1. + if( Name2[ii] >= '0' && Name2[ii] <= '9' ) + { + isDigit = true; + Name1[ii] = 0; //null-terminate. + } + if( !isDigit ) + { + Name1[ii] = Name2[ii]; + } + } + + Name1[ii] = 0; //just in case + int jj; + for( jj = 0; jjm_PrefixString)); + } + + if( !newfmt ) + GetField( REFERENCE )->m_Text = CONV_FROM_UTF8( Name2 ); + } + else + { + GetField( REFERENCE )->m_Attributs = TEXT_NO_VISIBLE; + } + + /* Parse component description + * These lines begin with: + * "P" = Position + * U = Num Unit and Conversion + * "Fn" = Fields (0 .. n = = number of field) + * "Ar" = Alternate reference in the case of multiple sheets referring to + * one schematic file. + */ + for( ; ; ) + { + if( !aLine.ReadLine() ) + return false; + + if( ((char*)aLine)[0] == 'U' ) + { + sscanf( ((char*)aLine) + 1, "%d %d %lX", &m_Multi, &m_Convert, &m_TimeStamp ); + } + else if( ((char*)aLine)[0] == 'P' ) + { + sscanf( ((char*)aLine) + 1, "%d %d", &m_Pos.x, &m_Pos.y ); + + // Set fields position to a default position (that is the + // component position. For existing fields, the real position + // will be set later + for( int i = 0; im_Text.IsEmpty() ) + GetField( i )->m_Pos = m_Pos; + } + } + else if( ((char*)aLine)[0] == 'A' && ((char*)aLine)[1] == 'R' ) + { + /* format: + * AR Path="/9086AF6E/67452AA0" Ref="C99" Part="1" + * where 9086AF6E is the unique timestamp of the containing sheet + * and 67452AA0 is the timestamp of this component. + * C99 is the reference given this path. + */ + int ii; + ptcar = ((char*)aLine) + 2; + + //copy the path. + ii = ReadDelimitedText( Name1, ptcar, 255 ); + ptcar += ii + 1; + wxString path = CONV_FROM_UTF8( Name1 ); + + // copy the reference + ii = ReadDelimitedText( Name1, ptcar, 255 ); + ptcar += ii + 1; + wxString ref = CONV_FROM_UTF8( Name1 ); + + // copy the multi, if exists + ii = ReadDelimitedText( Name1, ptcar, 255 ); + if( Name1[0] == 0 ) // Nothing read, put a default value + sprintf( Name1, "%d", m_Multi ); + int multi = atoi( Name1 ); + if( multi < 0 || multi > 25 ) + multi = 1; + AddHierarchicalReference( path, ref, multi ); + GetField( REFERENCE )->m_Text = ref; + } + else if( ((char*)aLine)[0] == 'F' ) + { + int fieldNdx; + + char FieldUserName[1024]; + GRTextHorizJustifyType hjustify = GR_TEXT_HJUSTIFY_CENTER; + GRTextVertJustifyType vjustify = GR_TEXT_VJUSTIFY_CENTER; + + FieldUserName[0] = 0; + + ptcar = (char*) aLine; + + while( *ptcar && (*ptcar != '"') ) + ptcar++; + + if( *ptcar != '"' ) + { + aErrorMsg.Printf( wxT( "EESchema file lib field F at line %d, aborted" ), + aLine.LineNumber() ); + return false; + } + + for( ptcar++, ii = 0; ; ii++, ptcar++ ) + { + Name1[ii] = *ptcar; + if( *ptcar == 0 ) + { + aErrorMsg.Printf( wxT( "Component field F at line %d, aborted" ), + aLine.LineNumber() ); + return false; + } + + if( *ptcar == '"' ) + { + Name1[ii] = 0; + ptcar++; + break; + } + } + + fieldNdx = atoi( ((char*)aLine) + 2 ); + + ReadDelimitedText( FieldUserName, ptcar, sizeof(FieldUserName) ); + + if( !FieldUserName[0] ) + fieldName = TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx ); + else + fieldName = CONV_FROM_UTF8( FieldUserName ); + + if( fieldNdx >= GetFieldCount() ) + { + // The first MANDATOR_FIELDS _must_ be constructed within + // the SCH_COMPONENT constructor. This assert is simply here + // to guard against a change in that constructor. + wxASSERT( GetFieldCount() >= MANDATORY_FIELDS ); + + // Ignore the _supplied_ fieldNdx. It is not important anymore + // if within the user defined fields region (i.e. >= MANDATORY_FIELDS). + // We freely renumber the index to fit the next available field slot. + + fieldNdx = GetFieldCount(); // new has this index after insertion + + SCH_FIELD field( wxPoint( 0, 0 ), + -1, // field id is not relavant for user defined fields + this, fieldName ); + + AddField( field ); + } + else + { + GetField( fieldNdx )->m_Name = fieldName; + } + + GetField( fieldNdx )->m_Text = CONV_FROM_UTF8( Name1 ); + memset( Char3, 0, sizeof(Char3) ); + if( ( ii = sscanf( ptcar, "%s %d %d %d %X %s %s", Char1, + &GetField( fieldNdx )->m_Pos.x, + &GetField( fieldNdx )->m_Pos.y, + &GetField( fieldNdx )->m_Size.x, + &GetField( fieldNdx )->m_Attributs, + Char2, Char3 ) ) < 4 ) + { + aErrorMsg.Printf( wxT( "Component Field error line %d, aborted" ), + aLine.LineNumber() ); + continue; + } + + if( (GetField( fieldNdx )->m_Size.x == 0 ) || (ii == 4) ) + GetField( fieldNdx )->m_Size.x = DEFAULT_SIZE_TEXT; + + GetField( fieldNdx )->m_Orient = TEXT_ORIENT_HORIZ; + GetField( fieldNdx )->m_Size.y = GetField( fieldNdx )->m_Size.x; + + if( Char1[0] == 'V' ) + GetField( fieldNdx )->m_Orient = TEXT_ORIENT_VERT; + + if( ii >= 7 ) + { + if( *Char2 == 'L' ) + hjustify = GR_TEXT_HJUSTIFY_LEFT; + else if( *Char2 == 'R' ) + hjustify = GR_TEXT_HJUSTIFY_RIGHT; + if( Char3[0] == 'B' ) + vjustify = GR_TEXT_VJUSTIFY_BOTTOM; + else if( Char3[0] == 'T' ) + vjustify = GR_TEXT_VJUSTIFY_TOP; + if( Char3[1] == 'I' ) + GetField( fieldNdx )->m_Italic = true; + else + GetField( fieldNdx )->m_Italic = false; + if( Char3[2] == 'B' ) + GetField( fieldNdx )->m_Bold = true; + else + GetField( fieldNdx )->m_Bold = false; + + GetField( fieldNdx )->m_HJustify = hjustify; + GetField( fieldNdx )->m_VJustify = vjustify; + } + + if( fieldNdx == REFERENCE ) + if( GetField( fieldNdx )->m_Text[0] == '#' ) + GetField( fieldNdx )->m_Attributs |= TEXT_NO_VISIBLE; + } + else + break; + } + + if( sscanf( ((char*)aLine), "%d %d %d", &m_Multi, &m_Pos.x, &m_Pos.y ) != 3 ) + { + aErrorMsg.Printf( wxT( "Component unit & pos error at line %d, aborted" ), + aLine.LineNumber() ); + return false; + } + + if( !aLine.ReadLine() || + sscanf( ((char*)aLine), "%d %d %d %d", + &m_Transform.x1, + &m_Transform.y1, + &m_Transform.x2, + &m_Transform.y2 ) != 4 ) + { + aErrorMsg.Printf( wxT( "Component orient error at line %d, aborted" ), + aLine.LineNumber() ); + return false; + } + + if( newfmt ) + { + if( !aLine.ReadLine() ) + return false; + + if( strnicmp( "$End", ((char*)aLine), 4 ) != 0 ) + { + aErrorMsg.Printf( wxT( "Component End expected at line %d, aborted" ), + aLine.LineNumber() ); + return false; + } + } + + return true; +} + + /** * Function GetBoundingBox * returns the orthogonal, bounding box of this object for display purposes. diff --git a/eeschema/class_sch_component.h b/eeschema/class_sch_component.h index ca6b1980d3..2331410237 100644 --- a/eeschema/class_sch_component.h +++ b/eeschema/class_sch_component.h @@ -6,12 +6,14 @@ #define COMPONENT_CLASS_H -#include "class_sch_screen.h" #include "class_sch_cmp_field.h" #include "transform.h" +#include "general.h" class SCH_SHEET_PATH; +class LIB_PIN; +class LIB_COMPONENT; /** @@ -132,6 +134,14 @@ public: */ bool Save( FILE* aFile ) const; + /** + * Load schematic component from \a aLine in a .sch file. + * + * @param aLine - Essentially this is file to read the component from. + * @param aErrorMsg - Description of the error if an error occurs while loading the component. + * @return True if the component loaded successfully. + */ + virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); /** * Function Load diff --git a/eeschema/class_sch_screen.cpp b/eeschema/class_sch_screen.cpp index 4842158f7e..54b669c753 100644 --- a/eeschema/class_sch_screen.cpp +++ b/eeschema/class_sch_screen.cpp @@ -6,11 +6,17 @@ #include "eeschema_id.h" #include "appl_wxstruct.h" #include "class_drawpanel.h" +#include "sch_item_struct.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "class_library.h" +#include "class_schematic_items.h" +#include "class_drawsheet.h" + +#include void SetaParent( EDA_BaseStruct* Struct, BASE_SCREEN* Screen ) diff --git a/eeschema/class_schematic_items.cpp b/eeschema/class_schematic_items.cpp index 289fa14647..c052818084 100644 --- a/eeschema/class_schematic_items.cpp +++ b/eeschema/class_schematic_items.cpp @@ -4,12 +4,18 @@ #include "fctsys.h" #include "gr_basic.h" +#include "macros.h" #include "class_drawpanel.h" #include "trigo.h" #include "common.h" -#include "program.h" +#include "richio.h" + #include "general.h" #include "protos.h" +#include "class_schematic_items.h" + +#include + /* used to calculate the pen size from default value * the actual pen size is default value * BUS_WIDTH_EXPAND @@ -94,6 +100,44 @@ bool SCH_BUS_ENTRY::Save( FILE* aFile ) const } +bool SCH_BUS_ENTRY::Load( LINE_READER& aLine, wxString& aErrorMsg ) +{ + char Name1[256]; + char Name2[256]; + char* line = (char*) aLine; + + while( (*line != ' ' ) && *line ) + line++; + + if( sscanf( line, "%s %s", Name1, Name2 ) != 2 ) + { + aErrorMsg.Printf( wxT( "EESchema file bus entry load error at line %d" ), + aLine.LineNumber() ); + aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine ); + return false; + } + + m_Layer = LAYER_WIRE; + + if( Name1[0] == 'B' ) + m_Layer = LAYER_BUS; + + if( !aLine.ReadLine() || sscanf( (char*) aLine, "%d %d %d %d ", &m_Pos.x, &m_Pos.y, + &m_Size.x, &m_Size.y ) != 4 ) + { + aErrorMsg.Printf( wxT( "EESchema file bus entry load error at line %d" ), + aLine.LineNumber() ); + aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine ); + return false; + } + + m_Size.x -= m_Pos.x; + m_Size.y -= m_Pos.y; + + return true; +} + + EDA_Rect SCH_BUS_ENTRY::GetBoundingBox() { EDA_Rect box; @@ -246,6 +290,26 @@ bool SCH_JUNCTION::Save( FILE* aFile ) const } +bool SCH_JUNCTION::Load( LINE_READER& aLine, wxString& aErrorMsg ) +{ + char name[256]; + char* line = (char*) aLine; + + while( (*line != ' ' ) && *line ) + line++; + + if( sscanf( line, "%s %d %d", name, &m_Pos.x, &m_Pos.y ) != 3 ) + { + aErrorMsg.Printf( wxT( "EESchema file connection load error at line %d, aborted" ), + aLine.LineNumber() ); + aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine ); + return false; + } + + return true; +} + + EDA_Rect SCH_JUNCTION::GetBoundingBox() { EDA_Rect rect; @@ -435,6 +499,26 @@ bool SCH_NO_CONNECT::Save( FILE* aFile ) const } +bool SCH_NO_CONNECT::Load( LINE_READER& aLine, wxString& aErrorMsg ) +{ + char name[256]; + char* line = (char*) aLine; + + while( (*line != ' ' ) && *line ) + line++; + + if( sscanf( line, "%s %d %d", name, &m_Pos.x, &m_Pos.y ) != 3 ) + { + aErrorMsg.Printf( wxT( "EESchema file No Connect load error at line %d" ), + aLine.LineNumber() ); + aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( ((char*)aLine) ); + return false; + } + + return true; +} + + /** Function GetPenSize * @return the size of the "pen" that be used to draw or plot this item */ @@ -631,6 +715,43 @@ bool SCH_LINE::Save( FILE* aFile ) const } +bool SCH_LINE::Load( LINE_READER& aLine, wxString& aErrorMsg ) +{ + char Name1[256]; + char Name2[256]; + char* line = (char*) aLine; + + while( (*line != ' ' ) && *line ) + line++; + + if( sscanf( line, "%s %s", Name1, Name2 ) != 2 ) + { + aErrorMsg.Printf( wxT( "EESchema file segment error at line %d, aborted" ), + aLine.LineNumber() ); + aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine ); + return false; + } + + m_Layer = LAYER_NOTES; + + if( Name1[0] == 'W' ) + m_Layer = LAYER_WIRE; + if( Name1[0] == 'B' ) + m_Layer = LAYER_BUS; + + if( !aLine.ReadLine() || sscanf( (char*) aLine, "%d %d %d %d ", + &m_Start.x, &m_Start.y, &m_End.x, &m_End.y ) != 4 ) + { + aErrorMsg.Printf( wxT( "EESchema file Segment struct error at line %d, aborted" ), + aLine.LineNumber() ); + aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine ); + return false; + } + + return true; +} + + /** Function GetPenSize * @return the size of the "pen" that be used to draw or plot this item */ @@ -917,6 +1038,50 @@ bool SCH_POLYLINE::Save( FILE* aFile ) const } +bool SCH_POLYLINE::Load( LINE_READER& aLine, wxString& aErrorMsg ) +{ + char Name1[256]; + char Name2[256]; + wxPoint pt; + int ii; + char* line = (char*) aLine; + + while( (*line != ' ' ) && *line ) + line++; + + if( sscanf( line, "%s %s %d", Name1, Name2, &ii ) != 3 ) + { + aErrorMsg.Printf( wxT( "EESchema file polyline struct error at line %d, aborted" ), + aLine.LineNumber() ); + aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine ); + return false; + } + + m_Layer = LAYER_NOTES; + if( Name2[0] == 'W' ) + m_Layer = LAYER_WIRE; + if( Name2[0] == 'B' ) + m_Layer = LAYER_BUS; + + for( unsigned jj = 0; jj < (unsigned)ii; jj++ ) + { + wxPoint point; + + if( !aLine.ReadLine() || sscanf( ((char*) aLine), "%d %d", &pt.x, &pt.y ) != 2 ) + { + aErrorMsg.Printf( wxT( "EESchema file polyline struct error at line %d, aborted" ), + aLine.LineNumber() ); + aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine ); + return false; + } + + AddPoint( pt ); + } + + return true; +} + + /** Function GetPenSize * @return the size of the "pen" that be used to draw or plot this item */ diff --git a/eeschema/class_schematic_items.h b/eeschema/class_schematic_items.h index 62d4be162e..6ecbfef36b 100644 --- a/eeschema/class_schematic_items.h +++ b/eeschema/class_schematic_items.h @@ -5,6 +5,12 @@ #ifndef CLASS_SCHEMATIC_ITEMS_H #define CLASS_SCHEMATIC_ITEMS_H + +#include "sch_item_struct.h" + +#include "general.h" + + /* Flags for BUS ENTRY (bus to bus or wire to bus */ #define WIRE_TO_BUS 0 #define BUS_TO_BUS 1 @@ -26,7 +32,7 @@ public: bool m_EndIsDangling; // TRUE if not connected (wires, tracks...) public: - SCH_LINE( const wxPoint& pos, int layer ); + SCH_LINE( const wxPoint& pos = wxPoint( 0, 0 ), int layer = LAYER_NOTES ); ~SCH_LINE() { } SCH_LINE* Next() const { return (SCH_LINE*) Pnext; } @@ -68,6 +74,16 @@ public: */ bool Save( FILE* aFile ) const; + /** + * Load schematic line from \a aLine in a .sch file. + * + * @param aLine - Essentially this is file to read schematic line from. + * @param aErrorMsg - Description of the error if an error occurs while loading the + * schematic line. + * @return True if the schematic line loaded successfully. + */ + virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); + /** Function GetPenSize * @return the size of the "pen" that be used to draw or plot this item */ @@ -132,7 +148,7 @@ public: wxSize m_Size; // size of this symbol public: - SCH_NO_CONNECT( const wxPoint& pos ); + SCH_NO_CONNECT( const wxPoint& pos = wxPoint( 0, 0 ) ); ~SCH_NO_CONNECT() { } virtual wxString GetClass() const { @@ -160,6 +176,16 @@ public: */ bool Save( FILE* aFile ) const; + /** + * Load schematic no connect entry from \a aLine in a .sch file. + * + * @param aLine - Essentially this is file to read schematic no connect from. + * @param aErrorMsg - Description of the error if an error occurs while loading the + * schematic no connect. + * @return True if the schematic no connect loaded successfully. + */ + virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); + /** Function HitTest * @return true if the point aPosRef is within item area * @param aPosRef = a wxPoint to test @@ -215,7 +241,7 @@ public: wxSize m_Size; public: - SCH_BUS_ENTRY( const wxPoint& pos, int shape, int id ); + SCH_BUS_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), int shape = '\\', int id = WIRE_TO_BUS ); ~SCH_BUS_ENTRY() { } virtual wxString GetClass() const @@ -239,6 +265,16 @@ public: */ bool Save( FILE* aFile ) const; + /** + * Load schematic bus entry from \a aLine in a .sch file. + * + * @param aLine - Essentially this is file to read schematic bus entry from. + * @param aErrorMsg - Description of the error if an error occurs while loading the + * schematic bus entry. + * @return True if the schematic bus entry loaded successfully. + */ + virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); + /** * Function GetBoundingBox * returns the orthogonal, bounding box of this object for display @@ -288,7 +324,7 @@ public: std::vector m_PolyPoints; // list of points (>= 2) public: - SCH_POLYLINE( int layer ); + SCH_POLYLINE( int layer = LAYER_NOTES ); ~SCH_POLYLINE(); virtual wxString GetClass() const @@ -311,6 +347,16 @@ public: */ bool Save( FILE* aFile ) const; + /** + * Load schematic poly line entry from \a aLine in a .sch file. + * + * @param aLine - Essentially this is file to read schematic poly line from. + * @param aErrorMsg - Description of the error if an error occurs while loading the + * schematic poly line. + * @return True if the schematic poly line loaded successfully. + */ + virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); + /** Function AddPoint * add a corner to m_PolyPoints */ @@ -361,7 +407,7 @@ public: wxSize m_Size; public: - SCH_JUNCTION( const wxPoint& pos ); + SCH_JUNCTION( const wxPoint& pos = wxPoint( 0, 0 ) ); ~SCH_JUNCTION() { } virtual wxString GetClass() const @@ -405,6 +451,16 @@ public: */ bool Save( FILE* aFile ) const; + /** + * Load schematic junction entry from \a aLine in a .sch file. + * + * @param aLine - Essentially this is file to read schematic junction from. + * @param aErrorMsg - Description of the error if an error occurs while loading the + * schematic junction. + * @return True if the schematic junction loaded successfully. + */ + virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); + // Geometric transforms (used in block operations): /** virtual function Move diff --git a/eeschema/class_text-label.cpp b/eeschema/class_text-label.cpp index a95060a900..d8c5eaf867 100644 --- a/eeschema/class_text-label.cpp +++ b/eeschema/class_text-label.cpp @@ -5,14 +5,16 @@ #include "fctsys.h" #include "gr_basic.h" #include "common.h" +#include "macros.h" #include "trigo.h" #include "eeschema_id.h" #include "class_drawpanel.h" #include "drawtxt.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" +#include "class_text-label.h" /************************/ @@ -490,6 +492,80 @@ bool SCH_TEXT::Save( FILE* aFile ) const } +bool SCH_TEXT::Load( LINE_READER& aLine, wxString& aErrorMsg ) +{ + char Name1[256]; + char Name2[256]; + char Name3[256]; + int thickness = 0, size = 0, orient = 0; + + Name1[0] = 0; Name2[0] = 0; Name3[0] = 0; + + char* sline = (char*) aLine; + + while( ( *sline != ' ' ) && *sline ) + sline++; + + // sline points the start of parameters + int ii = sscanf( sline, "%s %d %d %d %d %s %s %d", Name1, &m_Pos.x, &m_Pos.y, + &orient, &size, Name2, Name3, &thickness ); + + if( ii < 4 ) + { + aErrorMsg.Printf( wxT( "EESchema file text load error at line %d" ), + aLine.LineNumber() ); + return false; + } + + if( !aLine.ReadLine() ) + { + aErrorMsg.Printf( wxT( "EESchema file text load error at line %d" ), + aLine.LineNumber() ); + return false; + } + + if( size == 0 ) + size = DEFAULT_SIZE_TEXT; + + char* text = strtok( (char*) aLine, "\n\r" ); + + if( text == NULL ) + { + aErrorMsg.Printf( wxT( "EESchema file text load error at line %d" ), + aLine.LineNumber() ); + return false; + } + + wxString val = CONV_FROM_UTF8( text ); + + for( ;; ) + { + int i = val.find( wxT( "\\n" ) ); + + if( i == wxNOT_FOUND ) + break; + val.erase( i, 2 ); + val.insert( i, wxT( "\n" ) ); + } + + m_Text = val; + m_Size.x = m_Size.y = size; + SetSchematicTextOrientation( orient ); + + if( isdigit( Name3[0] ) ) + { + thickness = atol( Name3 ); + m_Bold = ( thickness != 0 ); + m_Width = m_Bold ? GetPenSizeForBold( size ) : 0; + } + + if( strnicmp( Name2, "Italic", 6 ) == 0 ) + m_Italic = 1; + + return true; +} + + void SCH_TEXT::GetEndPoints( std::vector & aItemList ) { // Normal text labels cannot be tested for dangling ends. @@ -713,6 +789,68 @@ bool SCH_LABEL::Save( FILE* aFile ) const } +bool SCH_LABEL::Load( LINE_READER& aLine, wxString& aErrorMsg ) +{ + char Name1[256]; + char Name2[256]; + char Name3[256]; + int thickness = 0, size = 0, orient = 0; + + Name1[0] = 0; Name2[0] = 0; Name3[0] = 0; + + char* sline = (char*) aLine; + + while( ( *sline != ' ' ) && *sline ) + sline++; + + // sline points the start of parameters + int ii = sscanf( sline, "%s %d %d %d %d %s %s %d", Name1, &m_Pos.x, &m_Pos.y, + &orient, &size, Name2, Name3, &thickness ); + + if( ii < 4 ) + { + aErrorMsg.Printf( wxT( "EESchema file label load error at line %d" ), + aLine.LineNumber() ); + return false; + } + + if( !aLine.ReadLine() ) + { + aErrorMsg.Printf( wxT( "EESchema file label load error atline %d" ), + aLine.LineNumber() ); + return false; + } + + if( size == 0 ) + size = DEFAULT_SIZE_TEXT; + + char* text = strtok( (char*) aLine, "\n\r" ); + + if( text == NULL ) + { + aErrorMsg.Printf( wxT( "EESchema file label load error at line %d" ), + aLine.LineNumber() ); + return false; + } + + m_Text = CONV_FROM_UTF8( text ); + m_Size.x = m_Size.y = size; + SetSchematicTextOrientation( orient ); + + if( isdigit( Name3[0] ) ) + { + thickness = atol( Name3 ); + m_Bold = ( thickness != 0 ); + m_Width = m_Bold ? GetPenSizeForBold( size ) : 0; + } + + if( stricmp( Name2, "Italic" ) == 0 ) + m_Italic = 1; + + return true; +} + + /** Function SCH_LABEL::Draw * a label is drawn like a text. So just call SCH_TEXT::Draw */ @@ -805,6 +943,71 @@ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const } +bool SCH_GLOBALLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg ) +{ + char Name1[256]; + char Name2[256]; + char Name3[256]; + int thickness = 0, size = 0, orient = 0; + + Name1[0] = 0; Name2[0] = 0; Name3[0] = 0; + + char* sline = (char*) aLine; + while( (*sline != ' ' ) && *sline ) + sline++; + + // sline points the start of parameters + int ii = sscanf( sline, "%s %d %d %d %d %s %s %d", Name1, &m_Pos.x, &m_Pos.y, + &orient, &size, Name2, Name3, &thickness ); + + if( ii < 4 ) + { + aErrorMsg.Printf( wxT( "EESchema file global label load error at line %d" ), + aLine.LineNumber() ); + return false; + } + + if( !aLine.ReadLine() ) + { + aErrorMsg.Printf( wxT( "EESchema file global label load error at line %d" ), + aLine.LineNumber() ); + return false; + } + + if( size == 0 ) + size = DEFAULT_SIZE_TEXT; + + char* text = strtok( (char*) aLine, "\n\r" ); + + if( text == NULL ) + { + aErrorMsg.Printf( wxT( "EESchema file global label load error at line %d" ), + aLine.LineNumber() ); + return false; + } + + m_Text = CONV_FROM_UTF8( text ); + m_Size.x = m_Size.y = size; + SetSchematicTextOrientation( orient ); + m_Shape = NET_INPUT; + m_Bold = ( thickness != 0 ); + m_Width = m_Bold ? GetPenSizeForBold( size ) : 0; + + if( stricmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 ) + m_Shape = NET_OUTPUT; + if( stricmp( Name2, SheetLabelType[NET_BIDI] ) == 0 ) + m_Shape = NET_BIDI; + if( stricmp( Name2, SheetLabelType[NET_TRISTATE] ) == 0 ) + m_Shape = NET_TRISTATE; + if( stricmp( Name2, SheetLabelType[NET_UNSPECIFIED] ) == 0 ) + m_Shape = NET_UNSPECIFIED; + if( stricmp( Name3, "Italic" ) == 0 ) + m_Italic = 1; + + return true; +} + + /** Function HitTest * @return true if the point aPosRef is within item area * @param aPosRef = a wxPoint to test @@ -1193,6 +1396,70 @@ bool SCH_HIERLABEL::Save( FILE* aFile ) const } +bool SCH_HIERLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg ) +{ + char Name1[256]; + char Name2[256]; + char Name3[256]; + int thickness = 0, size = 0, orient = 0; + + Name1[0] = 0; Name2[0] = 0; Name3[0] = 0; + + char* sline = (char*) aLine; + while( (*sline != ' ' ) && *sline ) + sline++; + + // sline points the start of parameters + int ii = sscanf( sline, "%s %d %d %d %d %s %s %d", Name1, &m_Pos.x, &m_Pos.y, + &orient, &size, Name2, Name3, &thickness ); + + if( ii < 4 ) + { + aErrorMsg.Printf( wxT( "EESchema file hierarchical label load error at line %d" ), + aLine.LineNumber() ); + return false; + } + + if( !aLine.ReadLine() ) + { + aErrorMsg.Printf( wxT( "EESchema file hierarchical label load error at line %d" ), + aLine.LineNumber() ); + return false; + } + + if( size == 0 ) + size = DEFAULT_SIZE_TEXT; + + char* text = strtok( (char*) aLine, "\n\r" ); + + if( text == NULL ) + { + aErrorMsg.Printf( wxT( "EESchema file hierarchical label load error at line %d" ), + aLine.LineNumber() ); + return false; + } + + m_Text = CONV_FROM_UTF8( text ); + m_Size.x = m_Size.y = size; + SetSchematicTextOrientation( orient ); + m_Shape = NET_INPUT; + m_Bold = ( thickness != 0 ); + m_Width = m_Bold ? GetPenSizeForBold( size ) : 0; + + if( stricmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 ) + m_Shape = NET_OUTPUT; + if( stricmp( Name2, SheetLabelType[NET_BIDI] ) == 0 ) + m_Shape = NET_BIDI; + if( stricmp( Name2, SheetLabelType[NET_TRISTATE] ) == 0 ) + m_Shape = NET_TRISTATE; + if( stricmp( Name2, SheetLabelType[NET_UNSPECIFIED] ) == 0 ) + m_Shape = NET_UNSPECIFIED; + if( stricmp( Name3, "Italic" ) == 0 ) + m_Italic = 1; + + return true; +} + /** Function HitTest * @return true if the point aPosRef is within item area diff --git a/eeschema/class_text-label.h b/eeschema/class_text-label.h index 141f02a711..b8901be9c6 100644 --- a/eeschema/class_text-label.h +++ b/eeschema/class_text-label.h @@ -5,8 +5,13 @@ #ifndef CLASS_TEXT_LABEL_H #define CLASS_TEXT_LABEL_H + #include "macros.h" -#include "base_struct.h" +#include "sch_item_struct.h" + + +class LINE_READER; + /* Type of SCH_HIERLABEL and SCH_GLOBALLABEL * mainly used to handle the graphic associated shape @@ -23,8 +28,7 @@ typedef enum { extern const char* SheetLabelType[]; /* names of types of labels */ -class SCH_TEXT : public SCH_ITEM, - public EDA_TextStruct +class SCH_TEXT : public SCH_ITEM, public EDA_TextStruct { public: int m_Layer; @@ -133,6 +137,16 @@ public: */ bool Save( FILE* aFile ) const; + /** + * Load schematic text entry from \a aLine in a .sch file. + * + * @param aLine - Essentially this is file to read schematic text from. + * @param aErrorMsg - Description of the error if an error occurs while loading the + * schematic text. + * @return True if the schematic text loaded successfully. + */ + virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); + /** Function GetPenSize * @return the size of the "pen" that be used to draw or plot this item */ @@ -246,6 +260,16 @@ public: * @return bool - true if success writing else false. */ bool Save( FILE* aFile ) const; + + /** + * Load schematic label entry from \a aLine in a .sch file. + * + * @param aLine - Essentially this is file to read schematic label from. + * @param aErrorMsg - Description of the error if an error occurs while loading the + * schematic label. + * @return True if the schematic label loaded successfully. + */ + virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); }; @@ -299,6 +323,16 @@ public: */ bool Save( FILE* aFile ) const; + /** + * Load schematic global label entry from \a aLine in a .sch file. + * + * @param aLine - Essentially this is file to read schematic global label from. + * @param aErrorMsg - Description of the error if an error occurs while loading the + * schematic global label. + * @return True if the schematic global label loaded successfully. + */ + virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); + /** Function HitTest * @return true if the point aPosRef is within item area * @param aPosRef = a wxPoint to test @@ -390,6 +424,16 @@ public: */ bool Save( FILE* aFile ) const; + /** + * Load schematic hierarchical label entry from \a aLine in a .sch file. + * + * @param aLine - Essentially this is file to read schematic hierarchical label from. + * @param aErrorMsg - Description of the error if an error occurs while loading the + * schematic hierarchical label. + * @return True if the schematic hierarchical label loaded successfully. + */ + virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); + /** Function HitTest * @return true if the point aPosRef is within item area * @param aPosRef = a wxPoint to test diff --git a/eeschema/cleanup.cpp b/eeschema/cleanup.cpp index 1cbca2cf24..69c85328de 100644 --- a/eeschema/cleanup.cpp +++ b/eeschema/cleanup.cpp @@ -7,11 +7,12 @@ #include "trigo.h" #include "confirm.h" #include "macros.h" +#include "class_sch_screen.h" -#include "program.h" #include "general.h" #include "protos.h" #include "netlist.h" +#include "class_schematic_items.h" /* Routine to start/end segment (BUS or wires) on junctions. diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index 858faf8051..4f9c64c63e 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -7,16 +7,19 @@ #include "common.h" #include "class_drawpanel.h" #include "eda_dde.h" -#include "eeschema_id.h" +#include "wxEeschemaStruct.h" -#include "program.h" +#include "eeschema_id.h" #include "general.h" #include "protos.h" #include "libeditframe.h" #include "viewlib_frame.h" #include "lib_draw_item.h" #include "lib_pin.h" +#include "class_drawsheet.h" +#include "class_drawsheetpath.h" #include "class_marker_sch.h" +#include "class_sch_component.h" /** Function SchematicGeneralLocateAndDisplay diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp index ac85a666c6..b07a1941d6 100644 --- a/eeschema/cross-probing.cpp +++ b/eeschema/cross-probing.cpp @@ -5,14 +5,16 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include "common.h" +#include "macros.h" #include "eda_dde.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "eeschema_id.h" #include "protos.h" #include "lib_draw_item.h" #include "lib_pin.h" +#include "class_sch_component.h" /***************************************************************/ diff --git a/eeschema/dangling_ends.cpp b/eeschema/dangling_ends.cpp index 163c35150a..754ed58c48 100644 --- a/eeschema/dangling_ends.cpp +++ b/eeschema/dangling_ends.cpp @@ -4,12 +4,14 @@ #include "fctsys.h" #include "gr_basic.h" +#include "sch_item_struct.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "class_libentry.h" #include "lib_pin.h" +#include "class_sch_component.h" /* Returns true if the point P is on the segment S. */ diff --git a/eeschema/database.cpp b/eeschema/database.cpp index 5fcbd93afd..db6b8b75ea 100644 --- a/eeschema/database.cpp +++ b/eeschema/database.cpp @@ -5,11 +5,12 @@ #include "fctsys.h" #include "gr_basic.h" #include "common.h" +#include "macros.h" #include "confirm.h" #include "eda_doc.h" #include "kicad_string.h" +#include "wxstruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "class_library.h" @@ -29,8 +30,7 @@ * Place the name of the component has loaded, select from a list in * BufName */ -wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys, - wxString& BufName ) +wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys, wxString& BufName ) { wxArrayString nameList; wxString msg; diff --git a/eeschema/delete.cpp b/eeschema/delete.cpp index 8db642d115..ec67ad80f4 100644 --- a/eeschema/delete.cpp +++ b/eeschema/delete.cpp @@ -5,15 +5,19 @@ #include "fctsys.h" #include "gr_basic.h" #include "common.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "class_marker_sch.h" +#include "class_schematic_items.h" +#include "class_drawsheet.h" +#include "class_text-label.h" + // Imported function: -void DeleteItemsInList( WinEDA_DrawPanel* panel, - PICKED_ITEMS_LIST& aItemsList ); +void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList ); /* @@ -28,7 +32,7 @@ static int CountConnectedItems( WinEDA_SchematicFrame* frame, bool TstJunction ) { SCH_ITEM* Struct; - int count = 0; + int count = 0; if( frame->LocatePinEnd( ListStruct, pos ) ) count++; diff --git a/eeschema/delsheet.cpp b/eeschema/delsheet.cpp index 7fd857293f..4708004e7e 100644 --- a/eeschema/delsheet.cpp +++ b/eeschema/delsheet.cpp @@ -6,10 +6,12 @@ #include "appl_wxstruct.h" #include "common.h" #include "confirm.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" +#include "class_drawsheet.h" /**************************************************************************/ diff --git a/eeschema/dialog_SVG_print.cpp b/eeschema/dialog_SVG_print.cpp index d570b76884..5adbccf5c9 100644 --- a/eeschema/dialog_SVG_print.cpp +++ b/eeschema/dialog_SVG_print.cpp @@ -12,13 +12,16 @@ #include "class_drawpanel.h" #include "confirm.h" #include "gestfich.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" #include "dialog_SVG_print_base.h" #include "dcsvg.h" -#include "program.h" #include "general.h" #include "libeditframe.h" +#include "class_drawsheetpath.h" + // Keys for configuration #define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" ) diff --git a/eeschema/dialog_build_BOM.cpp b/eeschema/dialog_build_BOM.cpp index e46fcd4a6d..8b86d39211 100644 --- a/eeschema/dialog_build_BOM.cpp +++ b/eeschema/dialog_build_BOM.cpp @@ -10,8 +10,8 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include "common.h" +#include "wxstruct.h" -#include "program.h" #include "general.h" #include "netlist.h" diff --git a/eeschema/dialog_build_BOM.h b/eeschema/dialog_build_BOM.h index 68a21d9100..80115117cb 100644 --- a/eeschema/dialog_build_BOM.h +++ b/eeschema/dialog_build_BOM.h @@ -10,6 +10,11 @@ #include "dialog_build_BOM_base.h" +class WinEDA_DrawFrame; +class SCH_COMPONENT; +class wxConfig; + + class DIALOG_BUILD_BOM : public DIALOG_BUILD_BOM_BASE { private: diff --git a/eeschema/dialog_create_component.cpp b/eeschema/dialog_create_component.cpp index 3606c4df4b..8912322f07 100644 --- a/eeschema/dialog_create_component.cpp +++ b/eeschema/dialog_create_component.cpp @@ -19,7 +19,6 @@ #include "common.h" #include "confirm.h" -#include "program.h" #include "class_libentry.h" #include "libeditframe.h" diff --git a/eeschema/dialog_edit_component_in_lib.cpp b/eeschema/dialog_edit_component_in_lib.cpp index 6f487b6b9c..3abd98f3fd 100644 --- a/eeschema/dialog_edit_component_in_lib.cpp +++ b/eeschema/dialog_edit_component_in_lib.cpp @@ -9,12 +9,10 @@ #include "confirm.h" #include "gestfich.h" -#include "program.h" #include "general.h" #include "protos.h" #include "libeditframe.h" #include "class_library.h" -//#include "class_libentry.h" #include "dialog_edit_component_in_lib.h" diff --git a/eeschema/dialog_edit_component_in_schematic.cpp b/eeschema/dialog_edit_component_in_schematic.cpp index 9e33348520..a28860ac94 100644 --- a/eeschema/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialog_edit_component_in_schematic.cpp @@ -8,11 +8,13 @@ #include "common.h" #include "class_drawpanel.h" #include "confirm.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "class_library.h" +#include "class_sch_component.h" #include "dialog_edit_component_in_schematic.h" diff --git a/eeschema/dialog_edit_component_in_schematic.h b/eeschema/dialog_edit_component_in_schematic.h index da07811160..2bb39797cd 100644 --- a/eeschema/dialog_edit_component_in_schematic.h +++ b/eeschema/dialog_edit_component_in_schematic.h @@ -3,6 +3,9 @@ #define __dialog_edit_component_in_schematic__ +#include "class_sch_cmp_field.h" +#include "template_fieldnames.h" + #include "dialog_edit_component_in_schematic_fbp.h" /** diff --git a/eeschema/dialog_edit_label.cpp b/eeschema/dialog_edit_label.cpp index 9b5d79e5fc..438b7a8ce4 100644 --- a/eeschema/dialog_edit_label.cpp +++ b/eeschema/dialog_edit_label.cpp @@ -8,13 +8,15 @@ #include "fctsys.h" #include "wx/valgen.h" +#include "wxEeschemaStruct.h" #include "common.h" #include "class_drawpanel.h" -#include "program.h" #include "general.h" #include "drawtxt.h" #include "confirm.h" +#include "class_text-label.h" + #include "dialog_edit_label.h" diff --git a/eeschema/dialog_edit_label.h b/eeschema/dialog_edit_label.h index c95d51c0a0..3db275a0be 100644 --- a/eeschema/dialog_edit_label.h +++ b/eeschema/dialog_edit_label.h @@ -10,6 +10,11 @@ #include "dialog_edit_label_base.h" + +class WinEDA_SchematicFrame; +class SCH_TEXT; + + class DialogLabelEditor : public DialogLabelEditor_Base { private: diff --git a/eeschema/dialog_edit_libentry_fields_in_lib.cpp b/eeschema/dialog_edit_libentry_fields_in_lib.cpp index 23dbd6dd23..c3349488d1 100644 --- a/eeschema/dialog_edit_libentry_fields_in_lib.cpp +++ b/eeschema/dialog_edit_libentry_fields_in_lib.cpp @@ -9,12 +9,14 @@ #include "common.h" #include "confirm.h" #include "class_drawpanel.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "libeditframe.h" #include "class_library.h" +#include "class_sch_cmp_field.h" +#include "template_fieldnames.h" #include "dialog_edit_libentry_fields_in_lib_base.h" diff --git a/eeschema/dialog_eeschema_config.cpp b/eeschema/dialog_eeschema_config.cpp index ba8be14bc7..299fd87c25 100644 --- a/eeschema/dialog_eeschema_config.cpp +++ b/eeschema/dialog_eeschema_config.cpp @@ -12,8 +12,8 @@ #include "common.h" #include "confirm.h" #include "gestfich.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "netlist.h" diff --git a/eeschema/dialog_erc.cpp b/eeschema/dialog_erc.cpp index 793445bb99..9f5173d013 100644 --- a/eeschema/dialog_erc.cpp +++ b/eeschema/dialog_erc.cpp @@ -10,8 +10,9 @@ #include "common.h" #include "class_drawpanel.h" #include "bitmaps.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "netlist.h" #include "class_marker_sch.h" diff --git a/eeschema/dialog_erc_listbox.h b/eeschema/dialog_erc_listbox.h index a97ac5226c..8f80109097 100644 --- a/eeschema/dialog_erc_listbox.h +++ b/eeschema/dialog_erc_listbox.h @@ -12,7 +12,7 @@ #include "fctsys.h" #include "class_drawpanel.h" -#include "program.h" +//#include "general.h" #include "class_marker_sch.h" /** diff --git a/eeschema/dialog_libedit_dimensions.cpp b/eeschema/dialog_libedit_dimensions.cpp index b87808bf6f..2325378579 100644 --- a/eeschema/dialog_libedit_dimensions.cpp +++ b/eeschema/dialog_libedit_dimensions.cpp @@ -3,15 +3,12 @@ * Handles the dialog so set current texts and pins sizes in LibEdit */ #include "fctsys.h" -//#include "appl_wxstruct.h" #include "common.h" -//#include "class_drawpanel.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "libeditframe.h" - #include "dialog_libedit_dimensions_base.h" diff --git a/eeschema/dialog_print_using_printer.cpp b/eeschema/dialog_print_using_printer.cpp index a37e217d0b..459887d770 100644 --- a/eeschema/dialog_print_using_printer.cpp +++ b/eeschema/dialog_print_using_printer.cpp @@ -8,10 +8,13 @@ #include "common.h" #include "class_drawpanel.h" #include "confirm.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "eeschema_config.h" +#include "class_drawsheet.h" +#include "class_drawsheetpath.h" #include "dialog_print_using_printer_base.h" diff --git a/eeschema/dialogs/dialog_plot_schematic_DXF.cpp b/eeschema/dialogs/dialog_plot_schematic_DXF.cpp index 1f74a30f66..32da0bc8ba 100644 --- a/eeschema/dialogs/dialog_plot_schematic_DXF.cpp +++ b/eeschema/dialogs/dialog_plot_schematic_DXF.cpp @@ -28,13 +28,16 @@ #include "fctsys.h" #include "gr_basic.h" #include "common.h" +#include "macros.h" #include "plot_common.h" #include "confirm.h" #include "worksheet.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" +#include "class_drawsheetpath.h" #include "dialog_plot_schematic_DXF_base.h" diff --git a/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp b/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp index b13ccef79b..47fb68e88b 100644 --- a/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp +++ b/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp @@ -31,10 +31,13 @@ #include "confirm.h" #include "plot_common.h" #include "worksheet.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" +#include "class_drawsheetpath.h" + #include "dialog_plot_schematic_HPGL_base.h" enum PageFormatReq diff --git a/eeschema/dialogs/dialog_plot_schematic_PS.cpp b/eeschema/dialogs/dialog_plot_schematic_PS.cpp index c0eb7a3a0b..46c4af4fb6 100644 --- a/eeschema/dialogs/dialog_plot_schematic_PS.cpp +++ b/eeschema/dialogs/dialog_plot_schematic_PS.cpp @@ -31,10 +31,13 @@ #include "confirm.h" #include "worksheet.h" #include "plot_common.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" +#include "class_drawsheetpath.h" + enum PageFormatReq { PAGE_SIZE_AUTO, diff --git a/eeschema/edit_component_in_lib.cpp b/eeschema/edit_component_in_lib.cpp index ea5d08f81b..3aca9d4f01 100644 --- a/eeschema/edit_component_in_lib.cpp +++ b/eeschema/edit_component_in_lib.cpp @@ -5,11 +5,12 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include "common.h" +#include "macros.h" #include "class_drawpanel.h" #include "confirm.h" #include "gestfich.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "libeditframe.h" diff --git a/eeschema/edit_component_in_schematic.cpp b/eeschema/edit_component_in_schematic.cpp index 4ef26cb0ee..aa161726dc 100644 --- a/eeschema/edit_component_in_schematic.cpp +++ b/eeschema/edit_component_in_schematic.cpp @@ -7,11 +7,13 @@ #include "common.h" #include "class_drawpanel.h" #include "confirm.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "class_library.h" +#include "class_sch_component.h" static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC ); diff --git a/eeschema/edit_graphic_bodyitem_text.cpp b/eeschema/edit_graphic_bodyitem_text.cpp index 1b25f1013f..52b73cb031 100644 --- a/eeschema/edit_graphic_bodyitem_text.cpp +++ b/eeschema/edit_graphic_bodyitem_text.cpp @@ -9,7 +9,6 @@ #include "common.h" #include "class_drawpanel.h" -#include "program.h" #include "general.h" #include "protos.h" #include "libeditframe.h" diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 1d4891a283..4c42746310 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -10,10 +10,13 @@ #include "drawtxt.h" #include "class_drawpanel.h" #include "confirm.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" +#include "class_text-label.h" + static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void ExitMoveTexte( WinEDA_DrawPanel* panel, wxDC* DC ); diff --git a/eeschema/eelayer.cpp b/eeschema/eelayer.cpp index f09debc1e6..2b94665806 100644 --- a/eeschema/eelayer.cpp +++ b/eeschema/eelayer.cpp @@ -9,9 +9,9 @@ #include "gr_basic.h" #include "common.h" #include "eeschema_id.h" +#include "wxstruct.h" #include "class_drawpanel.h" -#include "program.h" #include "general.h" #include "protos.h" diff --git a/eeschema/eelayer.h b/eeschema/eelayer.h index b04091777f..6a8edf24bc 100644 --- a/eeschema/eelayer.h +++ b/eeschema/eelayer.h @@ -7,6 +7,9 @@ #include "wx/statline.h" +#include "general.h" + + class wxBoxSizer; class wxStaticLine; class wxStdDialogButtonSizer; diff --git a/eeschema/eelibs_read_libraryfiles.cpp b/eeschema/eelibs_read_libraryfiles.cpp index 3c0f9c367a..fa9b9d50e1 100644 --- a/eeschema/eelibs_read_libraryfiles.cpp +++ b/eeschema/eelibs_read_libraryfiles.cpp @@ -4,9 +4,10 @@ #include "fctsys.h" #include "confirm.h" +#include "macros.h" #include "appl_wxstruct.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "class_library.h" diff --git a/eeschema/eeredraw.cpp b/eeschema/eeredraw.cpp index e652cd6591..f7a6ec9714 100644 --- a/eeschema/eeredraw.cpp +++ b/eeschema/eeredraw.cpp @@ -8,14 +8,20 @@ #include "common.h" #include "class_drawpanel.h" #include "appl_wxstruct.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "class_library.h" +#include "class_drawsheet.h" +#include "class_drawsheetpath.h" +#include "class_sch_component.h" +#include "class_schematic_items.h" #include "build_version.h" + static EDA_BaseStruct* HighLightStruct = NULL; diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index aa14d8edba..6b4f6c0d1f 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -11,8 +11,9 @@ #include "bitmaps.h" #include "eda_dde.h" #include "id.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "hotkeys.h" diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index e24eb74843..62b1722184 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -5,11 +5,12 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include "common.h" -#include "eeschema_id.h" #include "class_drawpanel.h" #include "confirm.h" #include "gestfich.h" -#include "program.h" +#include "wxEeschemaStruct.h" + +#include "eeschema_id.h" #include "general.h" #include "netlist.h" #include "protos.h" @@ -17,6 +18,8 @@ #include "eeschema_config.h" #include "worksheet.h" #include "hotkeys.h" +#include "class_drawsheet.h" + #include "dialog_eeschema_options.h" #include "dialog_hotkeys_editor.h" diff --git a/eeschema/eeschema_config.h b/eeschema/eeschema_config.h index 78cf8619c4..bc8d03d640 100644 --- a/eeschema/eeschema_config.h +++ b/eeschema/eeschema_config.h @@ -8,8 +8,6 @@ #define GROUPCOMMON wxT( "/common" ) #define GROUPLIB wxT( "libraries" ) -#include "netlist.h" - extern int g_PenMinWidth; /* saving parameters option : */ diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index 2008e82b50..a71019fad6 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -9,14 +9,17 @@ #include "gestfich.h" #include "appl_wxstruct.h" #include "bitmaps.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "netlist.h" #include "class_marker_sch.h" #include "lib_pin.h" #include "protos.h" #include "erc.h" +#include "class_sch_component.h" +#include "class_drawsheet.h" #include "dialog_erc.h" diff --git a/eeschema/events_called_functions_for_edit.cpp b/eeschema/events_called_functions_for_edit.cpp index 2b31d434bd..d11dc17798 100644 --- a/eeschema/events_called_functions_for_edit.cpp +++ b/eeschema/events_called_functions_for_edit.cpp @@ -2,15 +2,20 @@ * events_called_functions.cpp * some events functions */ + #include "fctsys.h" #include "gr_basic.h" #include "common.h" #include "class_drawpanel.h" -#include "program.h" #include "general.h" #include "kicad_device_context.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" #include "protos.h" +#include "class_sch_component.h" +#include "class_text-label.h" + /** Event function WinEDA_SchematicFrame::OnCopySchematicItemRequest * duplicate the current located item diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index ae5fed0842..d8568a0e74 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -7,13 +7,14 @@ #include "class_drawpanel.h" #include "confirm.h" #include "gestfich.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "eeschema_id.h" #include "class_library.h" #include "libeditframe.h" +#include "class_drawsheet.h" diff --git a/eeschema/find.cpp b/eeschema/find.cpp index fc6000fa78..8c14aed03d 100644 --- a/eeschema/find.cpp +++ b/eeschema/find.cpp @@ -14,13 +14,17 @@ #include "confirm.h" #include "kicad_string.h" #include "gestfich.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "class_marker_sch.h" #include "protos.h" #include "class_library.h" #include "lib_pin.h" +#include "class_sch_component.h" +#include "class_drawsheet.h" +#include "class_drawsheetpath.h" #include "kicad_device_context.h" diff --git a/eeschema/general.h b/eeschema/general.h index f09863fe9b..b81fae02b1 100644 --- a/eeschema/general.h +++ b/eeschema/general.h @@ -10,11 +10,11 @@ #include "block_commande.h" -#include "program.h" - class SCH_ITEM; class SCH_SHEET; +class TRANSFORM; + #define EESCHEMA_VERSION 2 @@ -28,14 +28,14 @@ class SCH_SHEET; #define MAX_PIN_INFO 10 -#define TXTMARGE 10 /* Offset in mils for placement of labels - * and pin numbers. */ +#define TXTMARGE 10 // Offset in mils for placement of labels and pin numbers. #define HIGHLIGHT_COLOR WHITE /* Used for EDA_BaseStruct, .m_Select member */ #define IS_SELECTED 1 +#define TEXT_NO_VISIBLE 1 //#define GR_DEFAULT_DRAWMODE GR_COPY #define GR_DEFAULT_DRAWMODE GR_COPY @@ -105,6 +105,31 @@ typedef enum } FileSaveType; +/* Rotation, mirror of graphic items in components bodies are handled by a + * transform matrix. The default matix is useful to draw lib entries with + * a defualt matix ( no rotation, no mirror but Y axis is bottom to top, and + * Y draw axis is to to bottom so we must have a default matix that reverses + * the Y coordinate and keeps the X coordiate + */ +extern TRANSFORM DefaultTransform; + +#define MIN_BUSLINES_THICKNESS 12 // min bus lines and entries thickness + +#define MAX_LAYERS 44 + +class LayerStruct +{ +public: + char LayerNames[MAX_LAYERS + 1][8]; + int LayerColor[MAX_LAYERS + 1]; + char LayerStatus[MAX_LAYERS + 1]; + int NumberOfLayers; + int CurrentLayer; + int CurrentWidth; + int CommonColor; + int Flags; +}; + extern SCH_ITEM* g_ItemToRepeat; /* Pointer to the last structure used * by the repeat command. NULL if no * item to repeat */ diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index eb14e60fb9..cc352df8d3 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -8,11 +8,13 @@ #include "common.h" #include "class_drawpanel.h" #include "confirm.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "class_library.h" +#include "class_sch_component.h" #include "viewlib_frame.h" #include "get_component_dialog.h" diff --git a/eeschema/hierarch.cpp b/eeschema/hierarch.cpp index f90bcaf201..ae252610c0 100644 --- a/eeschema/hierarch.cpp +++ b/eeschema/hierarch.cpp @@ -8,9 +8,12 @@ #include "class_drawpanel.h" #include "confirm.h" #include "bitmaps.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" +#include "class_drawsheet.h" +#include "class_drawsheetpath.h" #include "wx/imaglist.h" #include "wx/treectrl.h" diff --git a/eeschema/hotkeys.cpp b/eeschema/hotkeys.cpp index b557a5202b..e533d76ce3 100644 --- a/eeschema/hotkeys.cpp +++ b/eeschema/hotkeys.cpp @@ -6,12 +6,15 @@ #include "common.h" #include "eeschema_id.h" #include "hotkeys.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "libeditframe.h" #include "class_libentry.h" +#include "class_schematic_items.h" +#include "class_sch_component.h" +#include "class_drawsheet.h" #include "dialogs/dialog_schematic_find.h" diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index 5ba66af66a..ae45a8d4e5 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -5,9 +5,11 @@ #include "fctsys.h" #include "gr_basic.h" #include "common.h" +#include "macros.h" #include "class_drawpanel.h" #include "plot_common.h" #include "trigo.h" +#include "wxstruct.h" #include "general.h" #include "protos.h" diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index 22aff0a61d..267c8ee976 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -5,9 +5,11 @@ #include "fctsys.h" #include "gr_basic.h" #include "common.h" +#include "macros.h" #include "class_drawpanel.h" #include "plot_common.h" #include "trigo.h" +#include "wxstruct.h" #include "bezier_curves.h" #include "general.h" diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index 7f9094afe6..4baf7b26d2 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -8,6 +8,7 @@ #include "class_drawpanel.h" #include "plot_common.h" #include "trigo.h" +#include "wxstruct.h" #include "general.h" #include "protos.h" diff --git a/eeschema/lib_export.cpp b/eeschema/lib_export.cpp index 98a8830d29..40c7d071b3 100644 --- a/eeschema/lib_export.cpp +++ b/eeschema/lib_export.cpp @@ -15,7 +15,6 @@ #include "gestfich.h" #include "eeschema_id.h" -#include "program.h" #include "general.h" #include "protos.h" #include "libeditframe.h" diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 68bbeef55d..b5c1b2eb50 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -6,6 +6,7 @@ #include "appl_wxstruct.h" #include "gr_basic.h" #include "common.h" +#include "macros.h" #include "base_struct.h" #include "drawtxt.h" #include "kicad_string.h" @@ -13,12 +14,12 @@ #include "plot_common.h" #include "trigo.h" -#include "program.h" #include "general.h" #include "protos.h" #include "class_libentry.h" #include "transform.h" #include "lib_field.h" +#include "template_fieldnames.h" /*******************/ diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index 614b393dc1..d7aec0b583 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -5,7 +5,7 @@ #ifndef CLASS_LIBENTRY_FIELDS_H #define CLASS_LIBENTRY_FIELDS_H -#include "program.h" +//#include "general.h" #include "lib_draw_item.h" diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 4e78f0aa26..7aa8676a61 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -5,12 +5,13 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include "gr_basic.h" +#include "macros.h" #include "trigo.h" #include "class_drawpanel.h" #include "drawtxt.h" #include "plot_common.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "libeditframe.h" diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index 54ea4fd686..e29546ea00 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -5,15 +5,19 @@ #include "fctsys.h" #include "gr_basic.h" #include "common.h" +#include "macros.h" #include "class_drawpanel.h" #include "plot_common.h" #include "trigo.h" +#include "wxstruct.h" #include "general.h" #include "protos.h" #include "lib_polyline.h" #include "transform.h" +#include + LIB_POLYLINE::LIB_POLYLINE( LIB_COMPONENT* aParent ) : LIB_DRAW_ITEM( COMPONENT_POLYLINE_DRAW_TYPE, aParent ) diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index 0f022654bf..23844d53a1 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -8,6 +8,7 @@ #include "class_drawpanel.h" #include "plot_common.h" #include "trigo.h" +#include "wxstruct.h" #include "general.h" #include "protos.h" diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 91c22afc9a..0fa8766391 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -10,12 +10,13 @@ #include "fctsys.h" #include "gr_basic.h" #include "common.h" +#include "macros.h" #include "class_drawpanel.h" #include "plot_common.h" #include "drawtxt.h" #include "trigo.h" +#include "wxstruct.h" -#include "program.h" #include "lib_draw_item.h" #include "general.h" #include "protos.h" diff --git a/eeschema/libarch.cpp b/eeschema/libarch.cpp index 86e70ab6c4..58e6e9edd5 100644 --- a/eeschema/libarch.cpp +++ b/eeschema/libarch.cpp @@ -5,12 +5,15 @@ #include "fctsys.h" #include "common.h" #include "confirm.h" +#include "class_sch_screen.h" +#include "wxstruct.h" +#include "sch_item_struct.h" -#include "program.h" #include "general.h" #include "netlist.h" #include "protos.h" #include "class_library.h" +#include "class_sch_component.h" /* diff --git a/eeschema/libedit.cpp b/eeschema/libedit.cpp index 194ada4ce6..30c9a6a0c8 100644 --- a/eeschema/libedit.cpp +++ b/eeschema/libedit.cpp @@ -5,17 +5,19 @@ #include "fctsys.h" #include "gr_basic.h" #include "common.h" +#include "macros.h" #include "appl_wxstruct.h" #include "class_drawpanel.h" #include "confirm.h" #include "gestfich.h" -#include "eeschema_id.h" +#include "class_sch_screen.h" -#include "program.h" +#include "eeschema_id.h" #include "general.h" #include "protos.h" #include "libeditframe.h" #include "class_library.h" +#include "template_fieldnames.h" #include "dialog_lib_new_component.h" diff --git a/eeschema/libedit_onleftclick.cpp b/eeschema/libedit_onleftclick.cpp index 316c085aee..693cba1129 100644 --- a/eeschema/libedit_onleftclick.cpp +++ b/eeschema/libedit_onleftclick.cpp @@ -12,7 +12,6 @@ #include "confirm.h" #include "eeschema_id.h" -#include "program.h" #include "general.h" #include "protos.h" #include "libeditframe.h" diff --git a/eeschema/libedit_onrightclick.cpp b/eeschema/libedit_onrightclick.cpp index cc92be985b..dc99e240ad 100644 --- a/eeschema/libedit_onrightclick.cpp +++ b/eeschema/libedit_onrightclick.cpp @@ -8,12 +8,13 @@ #include "fctsys.h" #include "gr_basic.h" #include "common.h" +#include "macros.h" #include "confirm.h" #include "bitmaps.h" #include "eeschema_id.h" #include "hotkeys.h" +#include "class_sch_screen.h" -#include "program.h" #include "general.h" #include "protos.h" #include "libeditframe.h" diff --git a/eeschema/libedit_plot_component.cpp b/eeschema/libedit_plot_component.cpp index d0f7217e5f..6b594dbf4c 100644 --- a/eeschema/libedit_plot_component.cpp +++ b/eeschema/libedit_plot_component.cpp @@ -11,14 +11,13 @@ #include "confirm.h" #include "gestfich.h" #include "eeschema_id.h" +#include "class_sch_screen.h" -#include "program.h" #include "general.h" - -//#include "protos.h" #include "libeditframe.h" #include "class_library.h" + /** function OnPlotCurrentComponent * plot in SVG or PNG format the curren component */ diff --git a/eeschema/libedit_undo_redo.cpp b/eeschema/libedit_undo_redo.cpp index 0e80ca4ec5..062761230b 100644 --- a/eeschema/libedit_undo_redo.cpp +++ b/eeschema/libedit_undo_redo.cpp @@ -6,7 +6,6 @@ #include "class_drawpanel.h" #include "common.h" -#include "program.h" #include "general.h" #include "protos.h" #include "libeditframe.h" diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index a6714863e5..b2000e7002 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -7,13 +7,15 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include "common.h" +#include "macros.h" #include "class_drawpanel.h" #include "confirm.h" #include "eda_doc.h" #include "bitmaps.h" #include "gr_basic.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "eeschema_id.h" diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index fb24556f7f..a073c8dda3 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -6,14 +6,16 @@ #define __LIBEDITFRM_H__ #include "wxstruct.h" +#include "class_sch_screen.h" #include "lib_draw_item.h" -class SCH_SCREEN; +class WinEDA_SchematicFrame; class CMP_LIBRARY; class LIB_COMPONENT; class LIB_ALIAS; +class LIB_FIELD; class WinEDA_bodygraphics_PropertiesFrame; class Dialog_BodyGraphicText_Properties; diff --git a/eeschema/libfield.cpp b/eeschema/libfield.cpp index b8b01ea07b..4309cad7d8 100644 --- a/eeschema/libfield.cpp +++ b/eeschema/libfield.cpp @@ -7,12 +7,13 @@ #include "common.h" #include "class_drawpanel.h" #include "confirm.h" +#include "class_sch_screen.h" -#include "program.h" #include "general.h" #include "protos.h" #include "libeditframe.h" #include "class_library.h" +#include "template_fieldnames.h" void WinEDA_LibeditFrame::EditField( wxDC* DC, LIB_FIELD* Field ) diff --git a/eeschema/load_one_schematic_file.cpp b/eeschema/load_one_schematic_file.cpp index 1eec680fb7..cca4408437 100644 --- a/eeschema/load_one_schematic_file.cpp +++ b/eeschema/load_one_schematic_file.cpp @@ -5,23 +5,21 @@ #include "fctsys.h" #include "confirm.h" #include "kicad_string.h" +#include "wxEeschemaStruct.h" +#include "class_sch_screen.h" +#include "richio.h" -#include "program.h" #include "general.h" #include "protos.h" #include "class_marker_sch.h" -#include "richio.h" +#include "class_schematic_items.h" +#include "class_sch_component.h" +#include "class_text-label.h" +#include "class_drawsheet.h" -/* in read_from_file_schematic_items_description.cpp */ -SCH_ITEM* ReadTextDescr( LINE_READER* aLine, wxString& aMsgDiag, int aSchematicFileVersion ); - -int ReadSheetDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ); - bool ReadSchemaDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ); -int ReadPartDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ); - static void LoadLayers( LINE_READER* aLine ); @@ -31,17 +29,11 @@ static void LoadLayers( LINE_READER* aLine ); */ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& FullFileName ) { - char Name1[256], - Name2[256]; - int ii, layer; - wxPoint pos; - bool Failed = FALSE; - SCH_ITEM* Phead, * Pnext; - SCH_JUNCTION* ConnectionStruct; - SCH_POLYLINE* PolylineStruct; - SCH_LINE* SegmentStruct; - SCH_BUS_ENTRY* busEntry; - SCH_NO_CONNECT* NoConnectStruct; + char Name1[256]; + bool itemLoaded; + SCH_ITEM* Phead; + SCH_ITEM* Pnext; + SCH_ITEM* item; wxString MsgDiag; // Error and log messages #define line ((char*)reader) @@ -72,8 +64,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F PrintMsg( MsgDiag ); if( !reader.ReadLine() - || strncmp( line + 9, SCHEMATIC_HEAD_STRING, - sizeof(SCHEMATIC_HEAD_STRING) - 1 ) != 0 ) + || strncmp( line + 9, SCHEMATIC_HEAD_STRING, sizeof(SCHEMATIC_HEAD_STRING) - 1 ) != 0 ) { MsgDiag = FullFileName + _( " is NOT an EESchema file!" ); DisplayError( this, MsgDiag ); @@ -113,6 +104,8 @@ again." ); while( reader.ReadLine() ) { + item = NULL; + char* sline = line; while( (*sline != ' ' ) && *sline ) sline++; @@ -121,186 +114,31 @@ again." ); { case '$': // identification block if( line[1] == 'C' ) - Failed = ReadPartDescr( &reader, MsgDiag, screen ); - + item = new SCH_COMPONENT(); else if( line[1] == 'S' ) - Failed = ReadSheetDescr( &reader, MsgDiag, screen ); - + item = new SCH_SHEET(); else if( line[1] == 'D' ) - Failed = ReadSchemaDescr( &reader, MsgDiag, screen ); - - else if( line[1] == 'T' ) // text part - { - printf( "**** TEXT PART\n" ); - SCH_ITEM* Struct = ReadTextDescr( &reader, MsgDiag, version ); - - if( Struct ) - { - Struct->SetNext( screen->EEDrawList ); - screen->EEDrawList = Struct; - } - else - { - Failed = true; - } - } + itemLoaded = ReadSchemaDescr( &reader, MsgDiag, screen ); break; case 'L': // Its a library item. - Failed = ReadPartDescr( &reader, MsgDiag, screen ); + item = new SCH_COMPONENT(); break; case 'W': // Its a Segment (WIRE or BUS) item. - if( sscanf( sline, "%s %s", Name1, Name2 ) != 2 ) - { - MsgDiag.Printf( wxT( "EESchema file segment error at line %d, aborted" ), - reader.LineNumber() ); - MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( line ); - Failed = true; - break; - } - - layer = LAYER_NOTES; - - if( Name1[0] == 'W' ) - layer = LAYER_WIRE; - if( Name1[0] == 'B' ) - layer = LAYER_BUS; - - SegmentStruct = new SCH_LINE( wxPoint( 0, 0 ), layer ); - - if( !reader.ReadLine() - || sscanf( line, "%d %d %d %d ", &SegmentStruct->m_Start.x, - &SegmentStruct->m_Start.y, &SegmentStruct->m_End.x, - &SegmentStruct->m_End.y ) != 4 ) - { - MsgDiag.Printf( wxT( "EESchema file Segment struct error at line %d, aborted" ), - reader.LineNumber() ); - MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( line ); - Failed = true; - SAFE_DELETE( SegmentStruct ); - break; - } - - if( !Failed ) - { - SegmentStruct->SetNext( screen->EEDrawList ); - screen->EEDrawList = SegmentStruct; - } + item = new SCH_LINE(); break; case 'E': // Its a WIRE or BUS item. - if( sscanf( sline, "%s %s", Name1, Name2 ) != 2 ) - { - MsgDiag.Printf( wxT( "EESchema file record struct error at line %d, aborted" ), - reader.LineNumber() ); - MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( line ); - Failed = true; - break; - } - - ii = WIRE_TO_BUS; - if( Name1[0] == 'B' ) - ii = BUS_TO_BUS; - - busEntry = new SCH_BUS_ENTRY( wxPoint( 0, 0 ), '\\', ii ); - - if( !reader.ReadLine() - || sscanf( line, "%d %d %d %d ", &busEntry->m_Pos.x, &busEntry->m_Pos.y, - &busEntry->m_Size.x, &busEntry->m_Size.y ) != 4 ) - { - MsgDiag.Printf( wxT( "EESchema file Bus Entry struct error at line %d, aborted" ), - reader.LineNumber() ); - MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( line ); - Failed = true; - SAFE_DELETE( busEntry ); - break; - } - - if( !Failed ) - { - busEntry->m_Size.x -= busEntry->m_Pos.x; - busEntry->m_Size.y -= busEntry->m_Pos.y; - busEntry->SetNext( screen->EEDrawList ); - screen->EEDrawList = busEntry; - } + item = new SCH_BUS_ENTRY(); break; case 'P': // Its a polyline item. - if( sscanf( sline, "%s %s %d", Name1, Name2, &ii ) != 3 ) - { - MsgDiag.Printf( wxT( "EESchema file polyline struct error at line %d, aborted" ), - reader.LineNumber() ); - MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( line ); - Failed = true; - break; - } - layer = LAYER_NOTES; - if( Name2[0] == 'W' ) - layer = LAYER_WIRE; - if( Name2[0] == 'B' ) - layer = LAYER_BUS; - - PolylineStruct = new SCH_POLYLINE( layer ); - - for( unsigned jj = 0; jj < (unsigned)ii; jj++ ) - { - wxPoint point; - - if( !reader.ReadLine() - || sscanf( line, "%d %d", &point.x, &point.y ) != 2 ) - { - MsgDiag.Printf( wxT( "EESchema file polyline struct error at line %d, aborted" ), - reader.LineNumber() ); - MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( line ); - Failed = true; - SAFE_DELETE( PolylineStruct ); - break; - } - - PolylineStruct->AddPoint( point ); - } - - if( !Failed ) - { - PolylineStruct->SetNext( screen->EEDrawList ); - screen->EEDrawList = PolylineStruct; - } + item = new SCH_POLYLINE(); break; - case 'C': // It is a connection item. - ConnectionStruct = new SCH_JUNCTION( wxPoint( 0, 0 ) ); - - if( sscanf( sline, "%s %d %d", Name1, &ConnectionStruct->m_Pos.x, - &ConnectionStruct->m_Pos.y ) != 3 ) - { - MsgDiag.Printf( wxT( "EESchema file connection struct error at line %d, aborted" ), - reader.LineNumber() ); - MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( line ); - Failed = true; - SAFE_DELETE( ConnectionStruct ); - } - else - { - ConnectionStruct->SetNext( screen->EEDrawList ); - screen->EEDrawList = ConnectionStruct; - } - break; - - case 'N': // It is a NoConnect item. - if( sscanf( sline, "%s %d %d", Name1, &pos.x, &pos.y ) != 3 ) - { - MsgDiag.Printf( wxT( "EESchema file NoConnect struct error at line %d, aborted" ), - reader.LineNumber() ); - MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( line ); - Failed = true; - } - else - { - NoConnectStruct = new SCH_NO_CONNECT( pos ); - NoConnectStruct->SetNext( screen->EEDrawList ); - screen->EEDrawList = NoConnectStruct; - } + case 'C': // It is a connection item. + item = new SCH_JUNCTION(); break; case 'K': // It is a Marker item. @@ -308,28 +146,50 @@ again." ); // demand in schematic break; + case 'N': // It is a NoConnect item. + item = new SCH_NO_CONNECT(); + break; + case 'T': // It is a text item. + if( sscanf( sline, "%s", Name1 ) != 1 ) { - SCH_ITEM* Struct = ReadTextDescr( &reader, MsgDiag, version); - if( Struct ) - { - Struct->SetNext( screen->EEDrawList ); - screen->EEDrawList = Struct; - } - else - Failed = true; + MsgDiag.Printf( wxT( "EESchema file text load error at line %d" ), + reader.LineNumber() ); + itemLoaded = false; } + else if( Name1[0] == 'L' ) + item = new SCH_LABEL(); + else if( Name1[0] == 'G' && ver > '1' ) + item = new SCH_GLOBALLABEL(); + else if( (Name1[0] == 'H') || (Name1[0] == 'G' && ver == '1') ) + item = new SCH_HIERLABEL(); + else + item = new SCH_TEXT(); break; default: - Failed = true; + itemLoaded = false; MsgDiag.Printf( wxT( "EESchema file undefined object at line %d, aborted" ), reader.LineNumber() ); MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( line ); - break; } - if( Failed ) + if( item ) + { + itemLoaded = item->Load( reader, MsgDiag ); + + if( !itemLoaded ) + { + SAFE_DELETE( item ); + } + else + { + item->SetNext( screen->EEDrawList ); + screen->EEDrawList = item; + } + } + + if( !itemLoaded ) { DisplayError( this, MsgDiag ); break; @@ -390,3 +250,117 @@ static void LoadLayers( LINE_READER* aLine ) break; } } + + +/* Read the schematic header. */ +bool ReadSchemaDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ) +{ + char Text[256], buf[1024]; + int ii; + Ki_PageDescr* wsheet = &g_Sheet_A4; + static Ki_PageDescr* SheetFormatList[] = + { + &g_Sheet_A4, &g_Sheet_A3, &g_Sheet_A2, &g_Sheet_A1, &g_Sheet_A0, + &g_Sheet_A, &g_Sheet_B, &g_Sheet_C, &g_Sheet_D, &g_Sheet_E, + &g_Sheet_user, NULL + }; + wxSize PageSize; + + sscanf( ((char*)(*aLine)), "%s %s %d %d", Text, Text, &PageSize.x, &PageSize.y ); + + wxString pagename = CONV_FROM_UTF8( Text ); + for( ii = 0; SheetFormatList[ii] != NULL; ii++ ) + { + wsheet = SheetFormatList[ii]; + if( wsheet->m_Name.CmpNoCase( pagename ) == 0 ) /* Descr found ! */ + { + // Get the user page size and make it the default + if( wsheet == &g_Sheet_user ) + { + g_Sheet_user.m_Size = PageSize; + } + break; + } + } + + if( SheetFormatList[ii] == NULL ) + { + aMsgDiag.Printf( wxT( "EESchema file dimension definition error \ +line %d, \aAbort reading file.\n" ), + aLine->LineNumber() ); + aMsgDiag << CONV_FROM_UTF8( ((char*)(*aLine)) ); + } + + Window->m_CurrentSheetDesc = wsheet; + + for( ; ; ) + { + if( !aLine->ReadLine() ) + return TRUE; + + if( strnicmp( ((char*)(*aLine)), "$End", 4 ) == 0 ) + break; + + if( strnicmp( ((char*)(*aLine)), "Sheet", 2 ) == 0 ) + sscanf( ((char*)(*aLine)) + 5, " %d %d", + &Window->m_ScreenNumber, &Window->m_NumberOfScreen ); + + if( strnicmp( ((char*)(*aLine)), "Title", 2 ) == 0 ) + { + ReadDelimitedText( buf, ((char*)(*aLine)), 256 ); + Window->m_Title = CONV_FROM_UTF8( buf ); + continue; + } + + if( strnicmp( ((char*)(*aLine)), "Date", 2 ) == 0 ) + { + ReadDelimitedText( buf, ((char*)(*aLine)), 256 ); + Window->m_Date = CONV_FROM_UTF8( buf ); + continue; + } + + if( strnicmp( ((char*)(*aLine)), "Rev", 2 ) == 0 ) + { + ReadDelimitedText( buf, ((char*)(*aLine)), 256 ); + Window->m_Revision = CONV_FROM_UTF8( buf ); + continue; + } + + if( strnicmp( ((char*)(*aLine)), "Comp", 4 ) == 0 ) + { + ReadDelimitedText( buf, ((char*)(*aLine)), 256 ); + Window->m_Company = CONV_FROM_UTF8( buf ); + continue; + } + + if( strnicmp( ((char*)(*aLine)), "Comment1", 8 ) == 0 ) + { + ReadDelimitedText( buf, ((char*)(*aLine)), 256 ); + Window->m_Commentaire1 = CONV_FROM_UTF8( buf ); + continue; + } + + if( strnicmp( ((char*)(*aLine)), "Comment2", 8 ) == 0 ) + { + ReadDelimitedText( buf, ((char*)(*aLine)), 256 ); + Window->m_Commentaire2 = CONV_FROM_UTF8( buf ); + continue; + } + + if( strnicmp( ((char*)(*aLine)), "Comment3", 8 ) == 0 ) + { + ReadDelimitedText( buf, ((char*)(*aLine)), 256 ); + Window->m_Commentaire3 = CONV_FROM_UTF8( buf ); + continue; + } + + if( strnicmp( ((char*)(*aLine)), "Comment4", 8 ) == 0 ) + { + ReadDelimitedText( buf, ((char*)(*aLine)), 256 ); + Window->m_Commentaire4 = CONV_FROM_UTF8( buf ); + continue; + } + } + + return true; +} diff --git a/eeschema/locate.cpp b/eeschema/locate.cpp index e95395cfa0..3938441832 100644 --- a/eeschema/locate.cpp +++ b/eeschema/locate.cpp @@ -4,14 +4,19 @@ #include "fctsys.h" #include "common.h" -#include "program.h" #include "trigo.h" #include "macros.h" +#include "class_sch_screen.h" #include "general.h" #include "class_marker_sch.h" #include "protos.h" #include "class_library.h" +#include "class_schematic_items.h" +#include "class_sch_component.h" +#include "class_drawsheet.h" +#include "lib_pin.h" +#include "template_fieldnames.h" static bool IsItemInBox(EDA_Rect& aBox, SCH_ITEM* DrawStruct ); diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index a499cb7156..c8aa734ec2 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -10,8 +10,8 @@ #include "common.h" #include "appl_wxstruct.h" #include "bitmaps.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "eeschema_id.h" diff --git a/eeschema/menubar_libedit.cpp b/eeschema/menubar_libedit.cpp index 6b23b3963c..4fa588b6e5 100644 --- a/eeschema/menubar_libedit.cpp +++ b/eeschema/menubar_libedit.cpp @@ -7,9 +7,7 @@ #include "appl_wxstruct.h" #include "bitmaps.h" -#include "program.h" #include "general.h" -//#include "protos.h" #include "libeditframe.h" #include "eeschema_id.h" #include "hotkeys.h" diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index 7547a56aff..4d743e474b 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -37,13 +37,18 @@ #include "kicad_string.h" #include "gestfich.h" #include "appl_wxstruct.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "netlist.h" #include "protos.h" #include "class_library.h" #include "lib_pin.h" +#include "class_sch_component.h" +#include "class_text-label.h" +#include "class_drawsheet.h" +#include "template_fieldnames.h" #include "xnode.h" // also nests: @@ -353,7 +358,7 @@ wxString EXPORT_HELP::MakeCommandLine( const wxString& aFormatString, * @return true if success. */ bool WinEDA_SchematicFrame::WriteNetListFile( int aFormat, const wxString& aFullFileName, - bool aUse_netnames ) + bool aUse_netnames ) { bool ret = true; FILE* f = NULL; diff --git a/eeschema/netlist.cpp b/eeschema/netlist.cpp index 8bd6e4c824..1c759a3d22 100644 --- a/eeschema/netlist.cpp +++ b/eeschema/netlist.cpp @@ -4,16 +4,23 @@ #include "fctsys.h" #include "common.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "netlist.h" #include "protos.h" #include "class_library.h" #include "lib_pin.h" +#include "class_schematic_items.h" +#include "class_sch_component.h" +#include "class_text-label.h" +#include "class_drawsheet.h" #include "algorithm" +#include + // Buffer to build the list of items used in netlist and erc calculations NETLIST_OBJECT_LIST g_NetObjectslist; diff --git a/eeschema/netlist.h b/eeschema/netlist.h index cf7cc49a86..91ade5f843 100644 --- a/eeschema/netlist.h +++ b/eeschema/netlist.h @@ -6,9 +6,14 @@ #define _NETLIST_H_ +#include "macros.h" + #include "class_libentry.h" +class SCH_COMPONENT; + + #define NETLIST_HEAD_STRING "EESchema Netlist Version 1.1" #define ISBUS 1 diff --git a/eeschema/netlist_control.cpp b/eeschema/netlist_control.cpp index 36d721a0b2..974a3b2713 100644 --- a/eeschema/netlist_control.cpp +++ b/eeschema/netlist_control.cpp @@ -17,12 +17,15 @@ #include "common.h" #include "confirm.h" #include "gestfich.h" +#include "wxEeschemaStruct.h" +#include "class_sch_screen.h" -#include "program.h" #include "general.h" #include "netlist.h" #include "protos.h" #include "netlist_control.h" +#include "class_drawsheet.h" + //Imported function: int TestDuplicateSheetNames( bool aCreateMarker ); diff --git a/eeschema/onleftclick.cpp b/eeschema/onleftclick.cpp index 7d23887512..17d49d572d 100644 --- a/eeschema/onleftclick.cpp +++ b/eeschema/onleftclick.cpp @@ -7,11 +7,16 @@ #include "eeschema_id.h" #include "class_drawpanel.h" #include "confirm.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "class_marker_sch.h" #include "protos.h" +#include "class_text-label.h" +#include "class_schematic_items.h" +#include "class_sch_component.h" +#include "class_drawsheet.h" static wxArrayString s_CmpNameList; diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index 32ec62f709..7261faa2d2 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -8,13 +8,20 @@ #include "class_drawpanel.h" #include "confirm.h" #include "bitmaps.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "class_marker_sch.h" #include "protos.h" #include "hotkeys.h" #include "class_library.h" +#include "class_text-label.h" +#include "class_schematic_items.h" +#include "class_sch_component.h" +#include "class_drawsheet.h" +#include "class_drawsheetpath.h" + #include using namespace std; diff --git a/eeschema/operations_on_items_lists.cpp b/eeschema/operations_on_items_lists.cpp index fcc137d3f7..a73a1d2a3f 100644 --- a/eeschema/operations_on_items_lists.cpp +++ b/eeschema/operations_on_items_lists.cpp @@ -8,11 +8,16 @@ #include "appl_wxstruct.h" #include "common.h" #include "class_drawpanel.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "class_marker_sch.h" #include "protos.h" +#include "class_drawsheet.h" +#include "class_sch_component.h" +#include "class_schematic_items.h" + void RotateListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& rotationPoint ) { diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index 2afd3162c7..23bbef453e 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -7,8 +7,8 @@ #include "gr_basic.h" #include "class_drawpanel.h" #include "confirm.h" +#include "class_sch_screen.h" -#include "program.h" #include "libeditframe.h" #include "eeschema_id.h" #include "class_libentry.h" diff --git a/eeschema/plot.cpp b/eeschema/plot.cpp index 1aeb361ec6..dbf9793936 100644 --- a/eeschema/plot.cpp +++ b/eeschema/plot.cpp @@ -10,11 +10,15 @@ #include "drawtxt.h" #include "trigo.h" -#include "program.h" #include "general.h" #include "protos.h" #include "class_library.h" #include "lib_pin.h" +#include "class_schematic_items.h" +#include "class_sch_component.h" +#include "class_drawsheet.h" +#include "class_text-label.h" +#include "template_fieldnames.h" /* Local functions : */ diff --git a/eeschema/program.h b/eeschema/program.h deleted file mode 100644 index 377774077d..0000000000 --- a/eeschema/program.h +++ /dev/null @@ -1,54 +0,0 @@ -/********************************************/ -/* Definitions for the EESchema program: */ -/********************************************/ - -#ifndef PROGRAM_H -#define PROGRAM_H - - -class TRANSFORM; - - -#define HIGHLIGHT_COLOR WHITE -#define TEXT_NO_VISIBLE 1 - -#include "wxEeschemaStruct.h" -#include "macros.h" -#include "base_struct.h" - -#include "sch_item_struct.h" -#include "class_sch_component.h" -#include "class_sch_screen.h" -#include "class_drawsheet.h" -#include "class_drawsheetpath.h" -#include "class_text-label.h" -#include "class_schematic_items.h" - - -/* Rotation, mirror of graphic items in components bodies are handled by a - * transform matrix. The default matix is useful to draw lib entries with - * a defualt matix ( no rotation, no mirror but Y axis is bottom to top, and - * Y draw axis is to to bottom so we must have a default matix that reverses - * the Y coordinate and keeps the X coordiate - */ -extern TRANSFORM DefaultTransform; - -#define MIN_BUSLINES_THICKNESS 12 // min bus lines and entries thickness - -#define MAX_LAYERS 44 - -class LayerStruct -{ -public: - char LayerNames[MAX_LAYERS + 1][8]; - int LayerColor[MAX_LAYERS + 1]; - char LayerStatus[MAX_LAYERS + 1]; - int NumberOfLayers; - int CurrentLayer; - int CurrentWidth; - int CommonColor; - int Flags; -}; - - -#endif /* PROGRAM_H */ diff --git a/eeschema/read_from_file_schematic_items_descriptions.cpp b/eeschema/read_from_file_schematic_items_descriptions.cpp deleted file mode 100644 index 121c658616..0000000000 --- a/eeschema/read_from_file_schematic_items_descriptions.cpp +++ /dev/null @@ -1,843 +0,0 @@ -/* read_from_file_schematic_items_descriptions.cpp */ - -/*functions to read schematic items descriptions from file - */ -#include "fctsys.h" -#include "common.h" -#include "confirm.h" -#include "kicad_string.h" -#include "drawtxt.h" - -#include "program.h" -#include "general.h" -#include "protos.h" -#include "richio.h" - -#define line ((char*)(*aLine)) - -SCH_ITEM* ReadTextDescr( LINE_READER* aLine, wxString& aMsgDiag, int aSchematicFileVersion ) -{ -/** - * Function ReadTextDescr - * Reads the data structures for a Text (Comment, label, Hlabel and Hlabel - * from a FILE in "*.sch" format. - * @param aLine is a LINE_READER to use. - * @return a pointer to the new created object if success reading else NULL. - */ - SCH_ITEM* Struct = NULL; - char Name1[256]; - char Name2[256]; - char Name3[256]; - int thickness = 0, size = 0, orient = 0; - wxPoint pos; - - - Name1[0] = 0; Name2[0] = 0; Name3[0] = 0; - - char* sline = line; - while( (*sline != ' ' ) && *sline ) - sline++; - - // sline points the start of parameters - int ii = sscanf( sline, "%s %d %d %d %d %s %s %d", Name1, &pos.x, &pos.y, - &orient, &size, Name2, Name3, &thickness ); - - if( ii < 4 ) - { - aMsgDiag.Printf( - wxT( "EESchema file text struct error line %d, aborted" ), - aLine->LineNumber() ); - return NULL; - } - - if( !aLine->ReadLine() ) - { - aMsgDiag.Printf( - wxT( "EESchema file text struct error line %d (No text), aborted" ), - aLine->LineNumber() ); - return NULL; - } - - if( size == 0 ) - size = DEFAULT_SIZE_TEXT; - - char* text = strtok( line, "\n\r" ); - if( text == NULL ) - return NULL; - - if( Name1[0] == 'L' ) // Reading a simple label (SCH_LABEL item) - { - SCH_LABEL* TextStruct = new SCH_LABEL( pos, CONV_FROM_UTF8( text ) ); - - TextStruct->m_Size.x = TextStruct->m_Size.y = size; - TextStruct->SetSchematicTextOrientation( orient ); - if( isdigit( Name3[0] ) ) - { - thickness = atol( Name3 ); - TextStruct->m_Bold = (thickness != 0); - TextStruct->m_Width = - TextStruct->m_Bold ? GetPenSizeForBold( size ) : 0; - } - Struct = TextStruct; - if( stricmp( Name2, "Italic" ) == 0 ) - TextStruct->m_Italic = 1; - } - else if( Name1[0] == 'G' && aSchematicFileVersion > '1' ) - { - // Reading a global label (SCH_GLOBALLABEL item). - SCH_GLOBALLABEL* TextStruct = - new SCH_GLOBALLABEL( pos, CONV_FROM_UTF8( text ) ); - - Struct = TextStruct; - TextStruct->m_Size.x = TextStruct->m_Size.y = size; - TextStruct->SetSchematicTextOrientation( orient ); - TextStruct->m_Shape = NET_INPUT; - TextStruct->m_Bold = (thickness != 0); - TextStruct->m_Width = - TextStruct->m_Bold ? GetPenSizeForBold( size ) : 0; - - if( stricmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 ) - TextStruct->m_Shape = NET_OUTPUT; - if( stricmp( Name2, SheetLabelType[NET_BIDI] ) == 0 ) - TextStruct->m_Shape = NET_BIDI; - if( stricmp( Name2, SheetLabelType[NET_TRISTATE] ) == 0 ) - TextStruct->m_Shape = NET_TRISTATE; - if( stricmp( Name2, SheetLabelType[NET_UNSPECIFIED] ) == 0 ) - TextStruct->m_Shape = NET_UNSPECIFIED; - if( stricmp( Name3, "Italic" ) == 0 ) - TextStruct->m_Italic = 1; - } - else if( (Name1[0] == 'H') - || (Name1[0] == 'G' && aSchematicFileVersion == '1') ) - { - // Reading a hierarchical label (SCH_HIERLABEL item). - // In schematic file version 1, glabels were actually hierarchical - // labels. - SCH_HIERLABEL* TextStruct = new SCH_HIERLABEL( pos, - CONV_FROM_UTF8( text ) ); - - Struct = TextStruct; - TextStruct->m_Size.x = TextStruct->m_Size.y = size; - TextStruct->SetSchematicTextOrientation( orient ); - TextStruct->m_Shape = NET_INPUT; - TextStruct->m_Bold = (thickness != 0); - TextStruct->m_Width = - TextStruct->m_Bold ? GetPenSizeForBold( size ) : 0; - - if( stricmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 ) - TextStruct->m_Shape = NET_OUTPUT; - if( stricmp( Name2, SheetLabelType[NET_BIDI] ) == 0 ) - TextStruct->m_Shape = NET_BIDI; - if( stricmp( Name2, SheetLabelType[NET_TRISTATE] ) == 0 ) - TextStruct->m_Shape = NET_TRISTATE; - if( stricmp( Name2, SheetLabelType[NET_UNSPECIFIED] ) == 0 ) - TextStruct->m_Shape = NET_UNSPECIFIED; - if( stricmp( Name3, "Italic" ) == 0 ) - TextStruct->m_Italic = 1; - } - else // reading a graphic text (comment) - { - wxString val = CONV_FROM_UTF8( text ); - - for( ;; ) - { - int i=val.find( wxT( "\\n" ) ); - - if( i == wxNOT_FOUND ) - break; - val.erase( i, 2 ); - val.insert( i, wxT( "\n" ) ); - } - - SCH_TEXT* TextStruct = new SCH_TEXT( pos, val ); - - TextStruct->m_Size.x = TextStruct->m_Size.y = size; - TextStruct->SetSchematicTextOrientation( orient ); - - if( isdigit( Name3[0] ) ) - { - thickness = atol( Name3 ); - TextStruct->m_Bold = (thickness != 0); - TextStruct->m_Width = - TextStruct->m_Bold ? GetPenSizeForBold( size ) : 0; - } - - if( strnicmp( Name2, "Italic", 6 ) == 0 ) - TextStruct->m_Italic = 1; - - Struct = TextStruct; - } - - return Struct; -} - - -/* Function used by LoadEEFile(). - * Get the lines for a description of a piece of hierarchy. - */ -int ReadSheetDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ) -{ - int ii, fieldNdx, size; - char Name1[256], Char1[256], Char2[256]; - SCH_SHEET* SheetStruct; - SCH_SHEET_PIN* SheetLabelStruct; - int Failed = FALSE; - char* ptcar; - - SheetStruct = new SCH_SHEET(); - - SheetStruct->m_TimeStamp = GetTimeStamp(); - - // sheets are added to the EEDrawList like other schematic components. - // however, in order to preserve the hierarchy (through m_Parent pointers), - // a duplicate of the sheet is added to m_SubSheet array. - // must be a duplicate, references just work for a two-layer structure. - // this is accomplished through the Sync() function. - - if( line[0] == '$' ) // line should be "$Sheet" - { - if( !aLine->ReadLine() ) - { - aMsgDiag.Printf( wxT( "Read File Errror" ) ); - return TRUE; - } - } - - /* Next line: must be "S xx yy nn mm" with xx, yy = sheet position - * ( upper left corner ) et nn,mm = sheet size */ - if( (sscanf( &line[1], "%d %d %d %d", - &SheetStruct->m_Pos.x, &SheetStruct->m_Pos.y, - &SheetStruct->m_Size.x, &SheetStruct->m_Size.y ) != 4) - || (line[0] != 'S' ) ) - { - aMsgDiag.Printf( - wxT( " ** EESchema file sheet struct error at line %d, aborted\n" ), - aLine->LineNumber() ); - - aMsgDiag << CONV_FROM_UTF8( line ); - Failed = TRUE; - return Failed; - } - - /* Read fields */ - for( ; ; ) /* Analysis of lines "Fn" text. */ - { - if( !aLine->ReadLine() ) - return TRUE; - - if( line[0] == 'U' ) - { - sscanf( line + 1, "%lX", &SheetStruct->m_TimeStamp ); - if( SheetStruct->m_TimeStamp == 0 ) // zero is not unique! - SheetStruct->m_TimeStamp = GetTimeStamp(); - continue; - } - - if( line[0] != 'F' ) - break; - - sscanf( line + 1, "%d", &fieldNdx ); - - - /* Read the field: - * If fieldNdx> = 2: Fn "text" t s posx posy - * If F0 "text" for SheetName - * F1 and "text" for filename - */ - ptcar = line; - while( *ptcar && ( *ptcar != '"' ) ) - ptcar++; - - if( *ptcar != '"' ) - { - aMsgDiag.Printf( - wxT( "EESchema file sheet label F%d at line %d, aborted\n" ), - fieldNdx, aLine->LineNumber() ); - aMsgDiag << CONV_FROM_UTF8( line ); - return TRUE; - } - - for( ptcar++, ii = 0; ; ii++, ptcar++ ) - { - Name1[ii] = *ptcar; - - if( *ptcar == 0 ) - { - aMsgDiag.Printf( - wxT( "EESchema file sheet field F at line %d, aborted\n" ), - aLine->LineNumber() ); - aMsgDiag << CONV_FROM_UTF8( line ); - return TRUE; - } - - if( *ptcar == '"' ) - { - Name1[ii] = 0; - ptcar++; - break; - } - } - - if( ( fieldNdx == 0 ) || ( fieldNdx == 1 ) ) - { - if( sscanf( ptcar, "%d", &size ) != 1 ) - { - aMsgDiag.Printf( wxT( "EESchema file sheet Label Caract error line %d, aborted\n" ), - aLine->LineNumber() ); - - aMsgDiag << CONV_FROM_UTF8( line ); - } - if( size == 0 ) - size = DEFAULT_SIZE_TEXT; - - if( fieldNdx == 0 ) - { - SheetStruct->m_SheetName = CONV_FROM_UTF8( Name1 ); - SheetStruct->m_SheetNameSize = size; - } - else - { - SheetStruct->SetFileName( CONV_FROM_UTF8( Name1 ) ); - - //printf( "in ReadSheetDescr : SheetStruct->m_FileName = %s \n", - // Name1 ); - SheetStruct->m_FileNameSize = size; - } - } - - if( fieldNdx > 1 ) - { - int x, y; - - /* Read coordinates. */ - if( sscanf( ptcar, "%s %s %d %d %d", Char1, Char2, &x, &y, &size ) != 5 ) - { - aMsgDiag.Printf( wxT( "EESchema file sheet label error at line %d, ignoring.\n" ), - aLine->LineNumber() ); - aMsgDiag << CONV_FROM_UTF8( line ); - continue; - } - - SheetLabelStruct = new SCH_SHEET_PIN( SheetStruct, wxPoint( x, y ), - CONV_FROM_UTF8( Name1 ) ); - - if( size == 0 ) - size = DEFAULT_SIZE_TEXT; - - SheetLabelStruct->m_Size.x = SheetLabelStruct->m_Size.y = size; - SheetLabelStruct->m_Pos.x=x; //to readjust x of first label if vertical - switch( Char1[0] ) - { - case 'I': - SheetLabelStruct->m_Shape = NET_INPUT; - break; - - case 'O': - SheetLabelStruct->m_Shape = NET_OUTPUT; - break; - - case 'B': - SheetLabelStruct->m_Shape = NET_BIDI; - break; - - case 'T': - SheetLabelStruct->m_Shape = NET_TRISTATE; - break; - - case 'U': - SheetLabelStruct->m_Shape = NET_UNSPECIFIED; - break; - } - - switch( Char2[0] ) - { - case 'R' : /* pin on right side */ - SheetLabelStruct->SetEdge(1); - break; - case 'T' : /* pin on top side */ - SheetLabelStruct->SetEdge(2); - break; - case 'B' : /* pin on bottom side */ - SheetLabelStruct->SetEdge(3); - break; - case 'L' : /* pin on left side */ - default : - SheetLabelStruct->SetEdge(0); - break; - } - SheetStruct->AddLabel( SheetLabelStruct ); - } - } - - if( strnicmp( "$End", line, 4 ) != 0 ) - { - aMsgDiag.Printf( wxT( "**EESchema file end_sheet struct error at line %d, aborted\n" ), - aLine->LineNumber() ); - aMsgDiag << CONV_FROM_UTF8( line ); - Failed = TRUE; - } - - if( !Failed ) - { - SheetStruct->SetNext( Window->EEDrawList ); - Window->EEDrawList = SheetStruct; - SheetStruct->SetParent( Window ); - } - - return Failed; -} - - -/* Read the schematic header. */ -bool ReadSchemaDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ) -{ - char Text[256], buf[1024]; - int ii; - Ki_PageDescr* wsheet = &g_Sheet_A4; - static Ki_PageDescr* SheetFormatList[] = - { - &g_Sheet_A4, &g_Sheet_A3, &g_Sheet_A2, &g_Sheet_A1, &g_Sheet_A0, - &g_Sheet_A, &g_Sheet_B, &g_Sheet_C, &g_Sheet_D, &g_Sheet_E, - &g_Sheet_user, NULL - }; - wxSize PageSize; - - sscanf( line, "%s %s %d %d", Text, Text, &PageSize.x, &PageSize.y ); - - wxString pagename = CONV_FROM_UTF8( Text ); - for( ii = 0; SheetFormatList[ii] != NULL; ii++ ) - { - wsheet = SheetFormatList[ii]; - if( wsheet->m_Name.CmpNoCase( pagename ) == 0 ) /* Descr found ! */ - { - // Get the user page size and make it the default - if( wsheet == &g_Sheet_user ) - { - g_Sheet_user.m_Size = PageSize; - } - break; - } - } - - if( SheetFormatList[ii] == NULL ) - { - aMsgDiag.Printf( wxT( "EESchema file dimension definition error \ -line %d, \aAbort reading file.\n" ), - aLine->LineNumber() ); - aMsgDiag << CONV_FROM_UTF8( line ); - } - - Window->m_CurrentSheetDesc = wsheet; - - for( ; ; ) - { - if( !aLine->ReadLine() ) - return TRUE; - - if( strnicmp( line, "$End", 4 ) == 0 ) - break; - - if( strnicmp( line, "Sheet", 2 ) == 0 ) - sscanf( line + 5, " %d %d", - &Window->m_ScreenNumber, &Window->m_NumberOfScreen ); - - if( strnicmp( line, "Title", 2 ) == 0 ) - { - ReadDelimitedText( buf, line, 256 ); - Window->m_Title = CONV_FROM_UTF8( buf ); - continue; - } - - if( strnicmp( line, "Date", 2 ) == 0 ) - { - ReadDelimitedText( buf, line, 256 ); - Window->m_Date = CONV_FROM_UTF8( buf ); - continue; - } - - if( strnicmp( line, "Rev", 2 ) == 0 ) - { - ReadDelimitedText( buf, line, 256 ); - Window->m_Revision = CONV_FROM_UTF8( buf ); - continue; - } - - if( strnicmp( line, "Comp", 4 ) == 0 ) - { - ReadDelimitedText( buf, line, 256 ); - Window->m_Company = CONV_FROM_UTF8( buf ); - continue; - } - - if( strnicmp( line, "Comment1", 8 ) == 0 ) - { - ReadDelimitedText( buf, line, 256 ); - Window->m_Commentaire1 = CONV_FROM_UTF8( buf ); - continue; - } - - if( strnicmp( line, "Comment2", 8 ) == 0 ) - { - ReadDelimitedText( buf, line, 256 ); - Window->m_Commentaire2 = CONV_FROM_UTF8( buf ); - continue; - } - - if( strnicmp( line, "Comment3", 8 ) == 0 ) - { - ReadDelimitedText( buf, line, 256 ); - Window->m_Commentaire3 = CONV_FROM_UTF8( buf ); - continue; - } - - if( strnicmp( line, "Comment4", 8 ) == 0 ) - { - ReadDelimitedText( buf, line, 256 ); - Window->m_Commentaire4 = CONV_FROM_UTF8( buf ); - continue; - } - } - - return false; -} - - -/* Function used by LoadEEFile (). - * Get the lines for a description of a schematic component. - */ - -int ReadPartDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ) -{ - int ii; - char Name1[256], Name2[256], - Char1[256], Char2[256], Char3[256]; - SCH_COMPONENT* component; - int Failed = 0, newfmt = 0; - char* ptcar; - wxString fieldName; - - component = new SCH_COMPONENT(); - - component->m_Convert = 1; - - if( line[0] == '$' ) - { - newfmt = 1; - - if( !aLine->ReadLine() ) - return TRUE; - } - - if( sscanf( &line[1], "%s %s", Name1, Name2 ) != 2 ) - { - aMsgDiag.Printf( - wxT( "EESchema Component descr error at line %d, aborted" ), - aLine->LineNumber() ); - aMsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( line ); - Failed = TRUE; - return Failed; - } - - if( strcmp( Name1, NULL_STRING ) != 0 ) - { - for( ii = 0; ii < (int) strlen( Name1 ); ii++ ) - if( Name1[ii] == '~' ) - Name1[ii] = ' '; - - component->m_ChipName = CONV_FROM_UTF8( Name1 ); - if( !newfmt ) - component->GetField( VALUE )->m_Text = CONV_FROM_UTF8( Name1 ); - } - else - { - component->m_ChipName.Empty(); - component->GetField( VALUE )->m_Text.Empty(); - component->GetField( VALUE )->m_Orient = TEXT_ORIENT_HORIZ; - component->GetField( VALUE )->m_Attributs = TEXT_NO_VISIBLE; - } - - if( strcmp( Name2, NULL_STRING ) != 0 ) - { - bool isDigit = false; - for( ii = 0; ii < (int) strlen( Name2 ); ii++ ) - { - if( Name2[ii] == '~' ) - Name2[ii] = ' '; - - // get RefBase from this, too. store in Name1. - if( Name2[ii] >= '0' && Name2[ii] <= '9' ) - { - isDigit = true; - Name1[ii] = 0; //null-terminate. - } - if( !isDigit ) - { - Name1[ii] = Name2[ii]; - } - } - - Name1[ii] = 0; //just in case - int jj; - for( jj = 0; jjm_PrefixString = wxT( "U" ); - } - else - { - component->m_PrefixString = CONV_FROM_UTF8( &Name1[jj] ); - - //printf("prefix: %s\n", CONV_TO_UTF8(component->m_PrefixString)); - } - if( !newfmt ) - component->GetField( REFERENCE )->m_Text = CONV_FROM_UTF8( Name2 ); - } - else - { - component->GetField( REFERENCE )->m_Attributs = TEXT_NO_VISIBLE; - } - - /* Parse component description - * These lines begin with: - * "P" = Position - * U = Num Unit and Conversion - * "Fn" = Fields (0 .. n = = number of field) - * "Ar" = Alternate reference in the case of multiple sheets referring to - * one schematic file. - */ - for( ; ; ) - { - if( !aLine->ReadLine() ) - return TRUE; - - if( line[0] == 'U' ) - { - sscanf( line + 1, "%d %d %lX", - &component->m_Multi, &component->m_Convert, - &component->m_TimeStamp ); - } - else if( line[0] == 'P' ) - { - sscanf( line + 1, "%d %d", - &component->m_Pos.x, &component->m_Pos.y ); - - // Set fields position to a default position (that is the - // component position. For existing fields, the real position - // will be set later - for( int i = 0; iGetFieldCount(); ++i ) - { - if( component->GetField( i )->m_Text.IsEmpty() ) - component->GetField( i )->m_Pos = component->m_Pos; - } - } - else if( line[0] == 'A' && line[1] == 'R' ) - { - /* format: - * AR Path="/9086AF6E/67452AA0" Ref="C99" Part="1" - * where 9086AF6E is the unique timestamp of the containing sheet - * and 67452AA0 is the timestamp of this component. - * C99 is the reference given this path. - */ - int ii; - ptcar = line + 2; - - //copy the path. - ii = ReadDelimitedText( Name1, ptcar, 255 ); - ptcar += ii + 1; - wxString path = CONV_FROM_UTF8( Name1 ); - - // copy the reference - ii = ReadDelimitedText( Name1, ptcar, 255 ); - ptcar += ii + 1; - wxString ref = CONV_FROM_UTF8( Name1 ); - - // copy the multi, if exists - ii = ReadDelimitedText( Name1, ptcar, 255 ); - if( Name1[0] == 0 ) // Nothing read, put a default value - sprintf( Name1, "%d", component->m_Multi ); - int multi = atoi( Name1 ); - if( multi < 0 || multi > 25 ) - multi = 1; - component->AddHierarchicalReference( path, ref, multi ); - component->GetField( REFERENCE )->m_Text = ref; - } - else if( line[0] == 'F' ) - { - int fieldNdx; - - char FieldUserName[1024]; - GRTextHorizJustifyType hjustify = GR_TEXT_HJUSTIFY_CENTER; - GRTextVertJustifyType vjustify = GR_TEXT_VJUSTIFY_CENTER; - - FieldUserName[0] = 0; - - ptcar = line; - - while( *ptcar && (*ptcar != '"') ) - ptcar++; - - if( *ptcar != '"' ) - { - aMsgDiag.Printf( - wxT( "EESchema file lib field F at line %d, aborted" ), - aLine->LineNumber() ); - return TRUE; - } - - for( ptcar++, ii = 0; ; ii++, ptcar++ ) - { - Name1[ii] = *ptcar; - if( *ptcar == 0 ) - { - aMsgDiag.Printf( - wxT( "Component field F at line %d, aborted" ), - aLine->LineNumber() ); - return TRUE; - } - - if( *ptcar == '"' ) - { - Name1[ii] = 0; - ptcar++; - break; - } - } - - fieldNdx = atoi( line + 2 ); - - ReadDelimitedText( FieldUserName, ptcar, sizeof(FieldUserName) ); - - if( !FieldUserName[0] ) - fieldName = TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx ); - else - fieldName = CONV_FROM_UTF8( FieldUserName ); - - if( fieldNdx >= component->GetFieldCount() ) - { - // The first MANDATOR_FIELDS _must_ be constructed within - // the SCH_COMPONENT constructor. This assert is simply here - // to guard against a change in that constructor. - wxASSERT( component->GetFieldCount() >= MANDATORY_FIELDS ); - - // Ignore the _supplied_ fieldNdx. It is not important anymore - // if within the user defined fields region (i.e. >= MANDATORY_FIELDS). - // We freely renumber the index to fit the next available field slot. - - fieldNdx = component->GetFieldCount(); // new has this index after insertion - - SCH_FIELD field( wxPoint( 0, 0 ), - -1, // field id is not relavant for user defined fields - component, fieldName ); - - component->AddField( field ); - } - else - { - component->GetField( fieldNdx )->m_Name = fieldName; - } - - component->GetField( fieldNdx )->m_Text = CONV_FROM_UTF8( Name1 ); - memset( Char3, 0, sizeof(Char3) ); - if( ( ii = sscanf( ptcar, "%s %d %d %d %X %s %s", Char1, - &component->GetField( fieldNdx )->m_Pos.x, - &component->GetField( fieldNdx )->m_Pos.y, - &component->GetField( fieldNdx )->m_Size.x, - &component->GetField( fieldNdx )->m_Attributs, - Char2, Char3 ) ) < 4 ) - { - aMsgDiag.Printf( - wxT( "Component Field error line %d, aborted" ), - aLine->LineNumber() ); - continue; - } - - if( (component->GetField( fieldNdx )->m_Size.x == 0 ) || (ii == 4) ) - component->GetField( fieldNdx )->m_Size.x = DEFAULT_SIZE_TEXT; - - component->GetField( fieldNdx )->m_Orient = TEXT_ORIENT_HORIZ; - component->GetField( fieldNdx )->m_Size.y = - component->GetField( fieldNdx )->m_Size.x; - - if( Char1[0] == 'V' ) - component->GetField( fieldNdx )->m_Orient = TEXT_ORIENT_VERT; - - if( ii >= 7 ) - { - if( *Char2 == 'L' ) - hjustify = GR_TEXT_HJUSTIFY_LEFT; - else if( *Char2 == 'R' ) - hjustify = GR_TEXT_HJUSTIFY_RIGHT; - if( Char3[0] == 'B' ) - vjustify = GR_TEXT_VJUSTIFY_BOTTOM; - else if( Char3[0] == 'T' ) - vjustify = GR_TEXT_VJUSTIFY_TOP; - if( Char3[1] == 'I' ) - component->GetField( fieldNdx )->m_Italic = true; - else - component->GetField( fieldNdx )->m_Italic = false; - if( Char3[2] == 'B' ) - component->GetField( fieldNdx )->m_Bold = true; - else - component->GetField( fieldNdx )->m_Bold = false; - - component->GetField( fieldNdx )->m_HJustify = hjustify; - component->GetField( fieldNdx )->m_VJustify = vjustify; - } - - if( fieldNdx == REFERENCE ) - if( component->GetField( fieldNdx )->m_Text[0] == '#' ) - component->GetField( fieldNdx )->m_Attributs |= - TEXT_NO_VISIBLE; - } - else - break; - } - - if( sscanf( line, "%d %d %d", &component->m_Multi, - &component->m_Pos.x, &component->m_Pos.y ) != 3 ) - { - aMsgDiag.Printf( - wxT( "Component unit & pos error at line %d, aborted" ), - aLine->LineNumber() ); - Failed = TRUE; - return Failed; - } - - if( !aLine->ReadLine() || - sscanf( line, "%d %d %d %d", - &component->m_Transform.x1, - &component->m_Transform.y1, - &component->m_Transform.x2, - &component->m_Transform.y2 ) != 4 ) - { - aMsgDiag.Printf( wxT( "Component orient error at line %d, aborted" ), aLine->LineNumber() ); - Failed = TRUE; - return Failed; - } - - if( newfmt ) - { - if( !aLine->ReadLine() ) - return TRUE; - - if( strnicmp( "$End", line, 4 ) != 0 ) - { - aMsgDiag.Printf( - wxT( "Component End expected at line %d, aborted" ), - aLine->LineNumber() ); - Failed = TRUE; - } - } - - if( !Failed ) - { - component->SetNext( Window->EEDrawList ); - Window->EEDrawList = component; - component->SetParent( Window ); - } - - return Failed; -} diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 16b237fec7..a8f8bba1e3 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -9,14 +9,18 @@ #include "class_drawpanel.h" #include "confirm.h" #include "eda_doc.h" +#include "wxEeschemaStruct.h" +#include "class_sch_screen.h" +#include "kicad_device_context.h" #include "class_marker_sch.h" -#include "program.h" #include "general.h" #include "eeschema_id.h" #include "protos.h" #include "class_library.h" -#include "kicad_device_context.h" +#include "class_sch_component.h" +#include "class_schematic_items.h" +#include "class_drawsheet.h" void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index ff46f7a829..2ee566be21 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -5,11 +5,15 @@ #include "fctsys.h" #include "common.h" #include "class_drawpanel.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "class_marker_sch.h" +#include "class_schematic_items.h" +#include "class_sch_component.h" +#include "class_drawsheet.h" /* Functions to undo and redo edit commands. diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 690facda08..27b6b48998 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -13,13 +13,14 @@ #include "gestfich.h" #include "bitmaps.h" -#include "program.h" #include "general.h" #include "protos.h" #include "eeschema_id.h" #include "netlist.h" #include "lib_pin.h" #include "class_library.h" +#include "wxEeschemaStruct.h" +#include "class_sch_screen.h" #include "annotate_dialog.h" #include "dialog_build_BOM.h" @@ -29,6 +30,7 @@ #include "libeditframe.h" #include "viewlib_frame.h" #include "hotkeys.h" +#include "class_drawsheet.h" #include "dialogs/dialog_schematic_find.h" diff --git a/eeschema/selpart.cpp b/eeschema/selpart.cpp index 3cc774a493..0dcf13158f 100644 --- a/eeschema/selpart.cpp +++ b/eeschema/selpart.cpp @@ -6,8 +6,8 @@ #include "gr_basic.h" #include "common.h" #include "confirm.h" +#include "wxstruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "class_library.h" diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 5389ba3317..29a6b212b7 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -12,16 +12,21 @@ #include "fctsys.h" #include "gr_basic.h" #include "common.h" +#include "macros.h" #include "class_drawpanel.h" #include "confirm.h" #include "gestfich.h" +#include "wxEeschemaStruct.h" +#include "class_sch_screen.h" -#include "program.h" #include "general.h" #include "protos.h" +#include "class_drawsheet.h" #include "dialog_sch_sheet_props.h" +#include + static int s_PreviousSheetWidth; static int s_PreviousSheetHeight; diff --git a/eeschema/sheetlab.cpp b/eeschema/sheetlab.cpp index 458fa91d49..288f2d67e6 100644 --- a/eeschema/sheetlab.cpp +++ b/eeschema/sheetlab.cpp @@ -5,12 +5,15 @@ #include "fctsys.h" #include "gr_basic.h" #include "common.h" +#include "macros.h" #include "class_drawpanel.h" #include "confirm.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" +#include "class_drawsheet.h" static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC ); diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp index 8d1845d25e..98d86c51f4 100644 --- a/eeschema/symbdraw.cpp +++ b/eeschema/symbdraw.cpp @@ -8,9 +8,9 @@ #include "gr_basic.h" #include "class_drawpanel.h" #include "confirm.h" +#include "class_sch_screen.h" #include "eeschema_id.h" -#include "program.h" #include "general.h" #include "libeditframe.h" #include "class_libentry.h" diff --git a/eeschema/symbedit.cpp b/eeschema/symbedit.cpp index 470c35f78e..6c6b601a16 100644 --- a/eeschema/symbedit.cpp +++ b/eeschema/symbedit.cpp @@ -8,12 +8,13 @@ #include "fctsys.h" #include "appl_wxstruct.h" #include "common.h" +#include "macros.h" #include "class_drawpanel.h" #include "confirm.h" #include "kicad_string.h" #include "gestfich.h" +#include "class_sch_screen.h" -#include "program.h" #include "general.h" #include "protos.h" #include "libeditframe.h" diff --git a/eeschema/tool_lib.cpp b/eeschema/tool_lib.cpp index 1d056d1273..7e04a6cbc4 100644 --- a/eeschema/tool_lib.cpp +++ b/eeschema/tool_lib.cpp @@ -8,7 +8,6 @@ #include "bitmaps.h" #include "eeschema_id.h" -#include "program.h" #include "general.h" #include "protos.h" #include "libeditframe.h" diff --git a/eeschema/tool_sch.cpp b/eeschema/tool_sch.cpp index da441add61..547f4e4d8c 100644 --- a/eeschema/tool_sch.cpp +++ b/eeschema/tool_sch.cpp @@ -7,8 +7,8 @@ #include "class_drawpanel.h" #include "confirm.h" #include "bitmaps.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "hotkeys.h" diff --git a/eeschema/tool_viewlib.cpp b/eeschema/tool_viewlib.cpp index e057a7fe2b..d745ff10db 100644 --- a/eeschema/tool_viewlib.cpp +++ b/eeschema/tool_viewlib.cpp @@ -5,9 +5,10 @@ #include "fctsys.h" #include "common.h" #include "bitmaps.h" +#include "macros.h" #include "eeschema_id.h" +#include "wxstruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "hotkeys.h" diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 071978f68e..f1fd8f0d51 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -8,8 +8,9 @@ #include "eeschema_id.h" #include "class_drawpanel.h" #include "bitmaps.h" +#include "class_sch_screen.h" +#include "wxEeschemaStruct.h" -#include "program.h" #include "general.h" #include "protos.h" #include "viewlib_frame.h" diff --git a/eeschema/viewlib_frame.h b/eeschema/viewlib_frame.h index 72e4c9b639..e361773bef 100644 --- a/eeschema/viewlib_frame.h +++ b/eeschema/viewlib_frame.h @@ -2,6 +2,14 @@ #define __LIBVIEWFRM_H__ +#include + +#include "wxstruct.h" + + +class wxSashLayoutWindow; +class wxListBox; +class wxSemaphore; class WinEDAChoiceBox; class SCH_SCREEN; class CMP_LIBRARY; diff --git a/eeschema/viewlibs.cpp b/eeschema/viewlibs.cpp index cd01699226..ee6d5f92a5 100644 --- a/eeschema/viewlibs.cpp +++ b/eeschema/viewlibs.cpp @@ -9,8 +9,9 @@ #include "class_drawpanel.h" #include "confirm.h" #include "eda_doc.h" +#include "wxstruct.h" +#include "class_sch_screen.h" -#include "program.h" #include "general.h" #include "protos.h" #include "viewlib_frame.h" diff --git a/include/sch_item_struct.h b/include/sch_item_struct.h index 6eadb588d9..2d0cf68b68 100644 --- a/include/sch_item_struct.h +++ b/include/sch_item_struct.h @@ -12,6 +12,7 @@ using namespace std; class SCH_ITEM; +class LINE_READER; class WinEDA_SchematicFrame; class wxFindReplaceData; @@ -127,6 +128,15 @@ public: */ virtual bool Save( FILE* aFile ) const = 0; + /** + * Load schematic item from \a aLine in a .sch file. + * + * @param aLine - Essentially this is file to read the object from. + * @param aErrorMsg - Description of the error if an error occurs while loading the object. + * @return True if the object loaded successfully. + */ + virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ) { return false; } + /** * Compare schematic item against search string. *