diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f72329925..c095557860 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,8 +47,6 @@ option( KICAD_SCRIPTING_WXPYTHON # python binary file should be is exec path. -option( USE_FP_LIB_TABLE "Use the new footprint library table implementation. ( default OFF)" ) - option( BUILD_GITHUB_PLUGIN "Build the GITHUB_PLUGIN for pcbnew." OFF ) diff --git a/CMakeModules/PerformFeatureChecks.cmake b/CMakeModules/PerformFeatureChecks.cmake index 86ad7c5a84..6f8bc8586b 100644 --- a/CMakeModules/PerformFeatureChecks.cmake +++ b/CMakeModules/PerformFeatureChecks.cmake @@ -77,6 +77,7 @@ macro(perform_feature_checks) check_symbol_exists(strcasecmp "strings.h" HAVE_STRCASECMP) check_symbol_exists(strncasecmp "string.h" HAVE_STRNCASECMP) check_symbol_exists(strncasecmp "strings.h" HAVE_STRNCASECMP) + check_symbol_exists( strtok_r "string.h" HAVE_STRTOKR ) # Some platforms define malloc and free in malloc.h instead of stdlib.h. check_symbol_exists(malloc "stdlib.h" MALLOC_IN_STDLIB_H) @@ -92,7 +93,7 @@ macro(perform_feature_checks) # CMakes check_cxx_symbol_exists() doesn't work for templates so we must create a # small program to verify isinf() exists in cmath. - check_cxx_source_compiles( "#include \nusing namespace std;\nint main(int argc, char** argv)\n{\n (void)argv;\n isinf(1.0); (void)argc;\n return 0;\n}\n" HAVE_CMATH_ISINF ) + check_cxx_source_compiles( "#include \nint main(int argc, char** argv)\n{\n (void)argv;\n std::isinf(1.0); (void)argc;\n return 0;\n}\n" HAVE_CMATH_ISINF ) #check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME) non-standard library, does not work check_library_exists(rt clock_gettime "" HAVE_CLOCK_GETTIME) diff --git a/CMakeModules/config.h.cmake b/CMakeModules/config.h.cmake index da209b0b39..dc30b0a2ad 100644 --- a/CMakeModules/config.h.cmake +++ b/CMakeModules/config.h.cmake @@ -7,6 +7,8 @@ #cmakedefine HAVE_STRNCASECMP +#cmakedefine HAVE_STRTOKR // spelled odly to differ from wx's similar test + // Handle platform differences in math.h #cmakedefine HAVE_MATH_H @@ -56,9 +58,6 @@ /// The legacy file format revision of the *.brd file created by this build #define LEGACY_BOARD_FILE_VERSION 2 -/// Definition to compile with Pcbnew footprint library table implementation. -#cmakedefine USE_FP_LIB_TABLE - /// The install prefix defined in CMAKE_INSTALL_PREFIX. #define DEFAULT_INSTALL_PATH "@CMAKE_INSTALL_PREFIX" diff --git a/Documentation/guidelines/UIpolicies.txt b/Documentation/guidelines/UIpolicies.txt index 7d80c6197e..98a2c180c8 100644 --- a/Documentation/guidelines/UIpolicies.txt +++ b/Documentation/guidelines/UIpolicies.txt @@ -74,10 +74,12 @@ Dialogs: size should the user have selected a font size of 13 points. Quoting: - Filenames and paths should be emphasized with <> angle brackets. Anything - else should be emphasized with single quotes ''. e.g.: - - + Filenames, paths or other text should be with single quotes ''. e.g.: + 'filename.kicad_pcb' + 'longpath/subdir' 'FOOTPRINTNAME' 'anything else' + Often text strings like this end up in panels which use HTML rendering, and this + can happen in the future. Previously used angle brackets only cause grief there. + diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index b4d676ef67..b70b8b4660 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -141,6 +141,7 @@ set(COMMON_SRCS selcolor.cpp string.cpp trigo.cpp + utf8.cpp wildcards_and_files_ext.cpp worksheet.cpp wxwineda.cpp @@ -148,6 +149,10 @@ set(COMMON_SRCS zoom.cpp ) +if( NOT HAVE_STRTOKR ) + set( COMMON_SRCS ${COMMON_SRCS} strtok_r.c ) +endif() + enable_language(C CXX ASM) set_source_files_properties(system/fcontext.s PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp") diff --git a/common/basicframe.cpp b/common/basicframe.cpp index d513ac5839..702a4d2654 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -56,6 +56,10 @@ const wxChar* traceAutoSave = wxT( "KicadAutoSave" ); /// Configuration file entry name for auto save interval. static const wxChar* entryAutoSaveInterval = wxT( "AutoSaveInterval" ); +/// Configuration file entry for wxAuiManger perspective. +static const wxChar* entryPerspective = wxT( "Perspective" ); + + EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType, @@ -213,6 +217,11 @@ void EDA_BASE_FRAME::LoadSettings() if( maximized ) Maximize(); + + // Once this is fully implemented, wxAuiManager will be used to maintain the persistance of + // the main frame and all it's managed windows and all of the legacy frame persistence + // position code can be removed. + config->Read( m_FrameName + entryPerspective, &m_perspective ); } @@ -247,6 +256,11 @@ void EDA_BASE_FRAME::SaveSettings() text = m_FrameName + entryAutoSaveInterval; config->Write( text, m_autoSaveInterval ); } + + // Once this is fully implemented, wxAuiManager will be used to maintain the persistance of + // the main frame and all it's managed windows and all of the legacy frame persistence + // position code can be removed. + config->Write( m_FrameName + entryPerspective, m_auimgr.SavePerspective() ); } @@ -552,12 +566,7 @@ void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent& event ) tmp << wxT( "OFF\n" ); #endif - tmp << wxT( " USE_FP_LIB_TABLE=" ); -#ifdef USE_FP_LIB_TABLE - tmp << wxT( "ON\n" ); -#else - tmp << wxT( "OFF\n" ); -#endif + tmp << wxT( " USE_FP_LIB_TABLE=HARD_CODED_ON\n" ); tmp << wxT( " BUILD_GITHUB_PLUGIN=" ); #ifdef BUILD_GITHUB_PLUGIN diff --git a/common/class_plotter.cpp b/common/class_plotter.cpp index a6be0a315a..e726e93c3e 100644 --- a/common/class_plotter.cpp +++ b/common/class_plotter.cpp @@ -30,7 +30,9 @@ PLOTTER::PLOTTER( ) defaultPenWidth = 0; currentPenWidth = -1; // To-be-set marker penState = 'Z'; // End-of-path idle - plotMirror = false; // Mirror flag + m_plotMirror = false; // Mirror flag + m_mirrorIsHorizontal = true; + m_yaxisReversed = false; outputFile = 0; colorMode = false; // Starts as a BW plot negativeMode = false; @@ -74,16 +76,27 @@ bool PLOTTER::OpenFile( const wxString& aFullFilename ) * scale factor, and offsets trace. Also convert from a wxPoint to DPOINT, * since some output engines needs floating point coordinates. */ -DPOINT PLOTTER::userToDeviceCoordinates( const wxPoint& pos ) +DPOINT PLOTTER::userToDeviceCoordinates( const wxPoint& aCoordinate ) { - double x = (pos.x - plotOffset.x) * plotScale * iuPerDeviceUnit; - double y; + wxPoint pos = aCoordinate - plotOffset; + + double x = pos.x * plotScale; + double y = ( paperSize.y - pos.y * plotScale ); + + if( m_plotMirror ) + { + if( m_mirrorIsHorizontal ) + x = ( paperSize.x - pos.x * plotScale ); + else + y = pos.y * plotScale; + } + + if( m_yaxisReversed ) + y = paperSize.y - y; + + x *= iuPerDeviceUnit; + y *= iuPerDeviceUnit; - if( plotMirror ) - y = ( pos.y - plotOffset.y ) * plotScale * iuPerDeviceUnit ; - else - y = ( paperSize.y - ( pos.y - plotOffset.y ) - * plotScale ) * iuPerDeviceUnit ; return DPOINT( x, y ); } diff --git a/common/common_plotDXF_functions.cpp b/common/common_plotDXF_functions.cpp index e76d6805c1..cf216e03d4 100644 --- a/common/common_plotDXF_functions.cpp +++ b/common/common_plotDXF_functions.cpp @@ -44,7 +44,7 @@ void DXF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, iuPerDeviceUnit *= 0.00254; // ... now in mm SetDefaultLineWidth( 0 ); // No line width on DXF - plotMirror = false; // No mirroring on DXF + m_plotMirror = false; // No mirroring on DXF m_currentColor = BLACK; } diff --git a/common/common_plotGERBER_functions.cpp b/common/common_plotGERBER_functions.cpp index 5ed5ec0f55..e8b5273ded 100644 --- a/common/common_plotGERBER_functions.cpp +++ b/common/common_plotGERBER_functions.cpp @@ -21,7 +21,7 @@ void GERBER_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, { wxASSERT( !outputFile ); wxASSERT( aMirror == false ); - plotMirror = false; + m_plotMirror = false; plotOffset = aOffset; wxASSERT( aScale == 1 ); plotScale = 1; diff --git a/common/common_plotHPGL_functions.cpp b/common/common_plotHPGL_functions.cpp index 15893dfeeb..d3ff46b6f4 100644 --- a/common/common_plotHPGL_functions.cpp +++ b/common/common_plotHPGL_functions.cpp @@ -196,7 +196,7 @@ void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, paperSize.x *= 10.0 * aIusPerDecimil; paperSize.y *= 10.0 * aIusPerDecimil; SetDefaultLineWidth( 0 ); // HPGL has pen sizes instead - plotMirror = aMirror; + m_plotMirror = aMirror; } @@ -392,14 +392,15 @@ void HPGL_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, DPOINT centre_dev = userToDeviceCoordinates( centre ); - if( plotMirror ) + if( m_plotMirror ) angle = StAngle - EndAngle; else angle = EndAngle - StAngle; + NORMALIZE_ANGLE_180( angle ); angle /= 10; - // Calculate start point, + // Calculate arc start point: wxPoint cmap; cmap.x = centre.x + KiROUND( cosdecideg( radius, StAngle ) ); cmap.y = centre.y - KiROUND( sindecideg( radius, StAngle ) ); @@ -407,10 +408,8 @@ void HPGL_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, fprintf( outputFile, "PU;PA %.0f,%.0f;PD;AA %.0f,%.0f,", - cmap_dev.x, - cmap_dev.y, - centre_dev.x, - centre_dev.y ); + cmap_dev.x, cmap_dev.y, + centre_dev.x, centre_dev.y ); fprintf( outputFile, "%.0f", angle ); fprintf( outputFile, ";PU;\n" ); PenFinish(); @@ -431,7 +430,7 @@ void HPGL_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, double */ if( size.x > size.y ) { - EXCHG( size.x, size.y ); + EXCHG( size.x, size.y ); orient = AddAngles( orient, 900 ); } diff --git a/common/common_plotPDF_functions.cpp b/common/common_plotPDF_functions.cpp index b053121c48..8349c5ff45 100644 --- a/common/common_plotPDF_functions.cpp +++ b/common/common_plotPDF_functions.cpp @@ -71,7 +71,7 @@ void PDF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, double aScale, bool aMirror ) { wxASSERT( !workFile ); - plotMirror = aMirror; + m_plotMirror = aMirror; plotOffset = aOffset; plotScale = aScale; m_IUsPerDecimil = aIusPerDecimil; diff --git a/common/common_plotPS_functions.cpp b/common/common_plotPS_functions.cpp index 2a0057e081..cad37ae694 100644 --- a/common/common_plotPS_functions.cpp +++ b/common/common_plotPS_functions.cpp @@ -306,7 +306,7 @@ void PS_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, double aScale, bool aMirror ) { wxASSERT( !outputFile ); - plotMirror = aMirror; + m_plotMirror = aMirror; plotOffset = aOffset; plotScale = aScale; m_IUsPerDecimil = aIusPerDecimil; @@ -471,7 +471,7 @@ void PS_PLOTTER::Circle( const wxPoint& pos, int diametre, FILL_T fill, int widt } -void PS_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, +void PS_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, int radius, FILL_T fill, int width ) { wxASSERT( outputFile ); @@ -486,14 +486,24 @@ void PS_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, // Calculate start point. DPOINT centre_dev = userToDeviceCoordinates( centre ); double radius_dev = userToDeviceSize( radius ); - if( plotMirror ) - fprintf( outputFile, "%g %g %g %g %g arc%d\n", centre_dev.x, centre_dev.y, - radius_dev, -EndAngle / 10.0, -StAngle / 10.0, - fill ); - else - fprintf( outputFile, "%g %g %g %g %g arc%d\n", centre_dev.x, centre_dev.y, - radius_dev, StAngle / 10.0, EndAngle / 10.0, - fill ); + + if( m_plotMirror ) + { + if( m_mirrorIsHorizontal ) + { + StAngle = 1800.0 -StAngle; + EndAngle = 1800.0 -EndAngle; + EXCHG( StAngle, EndAngle ); + } + else + { + StAngle = -StAngle; + EndAngle = -EndAngle; + } + } + + fprintf( outputFile, "%g %g %g %g %g arc%d\n", centre_dev.x, centre_dev.y, + radius_dev, StAngle / 10.0, EndAngle / 10.0, fill ); } diff --git a/common/common_plotSVG_functions.cpp b/common/common_plotSVG_functions.cpp index 03d53698b0..b883107c84 100644 --- a/common/common_plotSVG_functions.cpp +++ b/common/common_plotSVG_functions.cpp @@ -172,7 +172,8 @@ void SVG_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, double aScale, bool aMirror ) { wxASSERT( !outputFile ); - plotMirror = not aMirror; // unlike other plotters, SVG has Y axis reversed + m_plotMirror = aMirror; + m_yaxisReversed = true; // unlike other plotters, SVG has Y axis reversed plotOffset = aOffset; plotScale = aScale; m_IUsPerDecimil = aIusPerDecimil; @@ -345,13 +346,28 @@ void SVG_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, i DPOINT centre_dev = userToDeviceCoordinates( centre ); double radius_dev = userToDeviceSize( radius ); - if( !plotMirror ) + if( m_yaxisReversed ) // Should be always the case { double tmp = StAngle; StAngle = -EndAngle; EndAngle = -tmp; } + if( m_plotMirror ) + { + if( m_mirrorIsHorizontal ) + { + StAngle = 1800.0 -StAngle; + EndAngle = 1800.0 -EndAngle; + EXCHG( StAngle, EndAngle ); + } + else + { + StAngle = -StAngle; + EndAngle = -EndAngle; + } + } + DPOINT start; start.x = radius_dev; RotatePoint( &start.x, &start.y, StAngle ); diff --git a/common/common_plot_functions.cpp b/common/common_plot_functions.cpp index 0178c8db02..1a7312756b 100644 --- a/common/common_plot_functions.cpp +++ b/common/common_plot_functions.cpp @@ -81,7 +81,6 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock, EDA_COLOR_T plotColor = plotter->GetColorMode() ? RED : BLACK; plotter->SetColor( plotColor ); - plotter->SetCurrentLineWidth( PLOTTER::DEFAULT_LINE_WIDTH ); WS_DRAW_ITEM_LIST drawList; // Print only a short filename, if aFilename is the full filename @@ -103,11 +102,14 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock, for( WS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item; item = drawList.GetNext() ) { + plotter->SetCurrentLineWidth( PLOTTER::DEFAULT_LINE_WIDTH ); + switch( item->GetType() ) { case WS_DRAW_ITEM_BASE::wsg_line: { WS_DRAW_ITEM_LINE* line = (WS_DRAW_ITEM_LINE*) item; + plotter->SetCurrentLineWidth( line->GetPenWidth() ); plotter->MoveTo( line->GetStart() ); plotter->FinishTo( line->GetEnd() ); } @@ -116,7 +118,11 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock, case WS_DRAW_ITEM_BASE::wsg_rect: { WS_DRAW_ITEM_RECT* rect = (WS_DRAW_ITEM_RECT*) item; - plotter->Rect( rect->GetStart(), rect->GetEnd(), NO_FILL ); } + plotter->Rect( rect->GetStart(), + rect->GetEnd(), + NO_FILL, + rect->GetPenWidth() ); + } break; case WS_DRAW_ITEM_BASE::wsg_text: @@ -135,7 +141,8 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock, { WS_DRAW_ITEM_POLYGON* poly = (WS_DRAW_ITEM_POLYGON*) item; plotter->PlotPoly( poly->m_Corners, - poly->IsFilled() ? FILLED_SHAPE : NO_FILL ); + poly->IsFilled() ? FILLED_SHAPE : NO_FILL, + poly->GetPenWidth() ); } break; diff --git a/common/confirm.cpp b/common/confirm.cpp index 738ad17003..d14109ce42 100644 --- a/common/confirm.cpp +++ b/common/confirm.cpp @@ -102,10 +102,10 @@ void DisplayInfoMessage( wxWindow* parent, const wxString& text, int displaytime void DisplayHtmlInfoMessage( wxWindow* parent, const wxString& title, const wxString& text, const wxSize& size ) { - HTML_MESSAGE_BOX *dlg = new HTML_MESSAGE_BOX(parent,title, wxDefaultPosition, size ); - dlg->AddHTML_Text( text ); - dlg->ShowModal(); - dlg->Destroy(); + HTML_MESSAGE_BOX dlg( parent, title, wxDefaultPosition, size ); + + dlg.AddHTML_Text( text ); + dlg.ShowModal(); } diff --git a/common/dialogs/dialog_display_info_HTML_base.cpp b/common/dialogs/dialog_display_info_HTML_base.cpp index 346b78692f..5a693c8e7c 100644 --- a/common/dialogs/dialog_display_info_HTML_base.cpp +++ b/common/dialogs/dialog_display_info_HTML_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 8 2012) +// C++ code generated with wxFormBuilder (version Nov 5 2013) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -21,7 +21,7 @@ DIALOG_DISPLAY_HTML_TEXT_BASE::DIALOG_DISPLAY_HTML_TEXT_BASE( wxWindow* parent, m_buttonClose = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); m_buttonClose->SetDefault(); - bMainSizer->Add( m_buttonClose, 0, wxALIGN_RIGHT|wxRIGHT|wxLEFT, 5 ); + bMainSizer->Add( m_buttonClose, 0, wxALIGN_RIGHT|wxALL, 10 ); this->SetSizer( bMainSizer ); diff --git a/common/dialogs/dialog_display_info_HTML_base.fbp b/common/dialogs/dialog_display_info_HTML_base.fbp index 8b7ed6f157..6608c5cd50 100644 --- a/common/dialogs/dialog_display_info_HTML_base.fbp +++ b/common/dialogs/dialog_display_info_HTML_base.fbp @@ -20,8 +20,10 @@ . 1 + 1 1 1 + UI 0 0 @@ -42,7 +44,7 @@ 400,120 DIALOG_DISPLAY_HTML_TEXT_BASE - 431,120 + 465,202 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h @@ -176,8 +178,8 @@ - 5 - wxALIGN_RIGHT|wxRIGHT|wxLEFT + 10 + wxALIGN_RIGHT|wxALL 0 1 diff --git a/common/dialogs/dialog_display_info_HTML_base.h b/common/dialogs/dialog_display_info_HTML_base.h index a184872866..4cfa053813 100644 --- a/common/dialogs/dialog_display_info_HTML_base.h +++ b/common/dialogs/dialog_display_info_HTML_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 8 2012) +// C++ code generated with wxFormBuilder (version Nov 5 2013) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -45,7 +45,7 @@ class DIALOG_DISPLAY_HTML_TEXT_BASE : public DIALOG_SHIM public: wxHtmlWindow* m_htmlWindow; - DIALOG_DISPLAY_HTML_TEXT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 431,120 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_DISPLAY_HTML_TEXT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 465,202 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_DISPLAY_HTML_TEXT_BASE(); }; diff --git a/common/drawpanel_gal.cpp b/common/drawpanel_gal.cpp index bbfefd3c10..e0d9dcdf89 100644 --- a/common/drawpanel_gal.cpp +++ b/common/drawpanel_gal.cpp @@ -187,6 +187,13 @@ void EDA_DRAW_PANEL_GAL::Refresh( bool eraseBackground, const wxRect* rect ) } +void EDA_DRAW_PANEL_GAL::StopDrawing() +{ + Disconnect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), NULL, this ); + m_refreshTimer.Stop(); +} + + void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType ) { // Protect from refreshing during backend switch diff --git a/common/footprint_info.cpp b/common/footprint_info.cpp index b2561a697a..4fe00f4108 100644 --- a/common/footprint_info.cpp +++ b/common/footprint_info.cpp @@ -2,7 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2011 Jean-Pierre Charras, - * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -27,10 +28,13 @@ */ +#define USE_WORKER_THREADS 1 // 1:yes, 0:no. use worker thread to load libraries + /* * Functions to read footprint libraries and fill m_footprints by available footprints names * and their documentation (comments and keywords) */ + #include #include #include @@ -40,206 +44,289 @@ #include #include #include - #include +#include -#if !defined( USE_FP_LIB_TABLE ) -bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintLibNames ) +/* +static wxString ToHTMLFragment( const IO_ERROR* aDerivative ) { - bool retv = true; + @todo - // Clear data before reading files - m_filesNotFound.Empty(); - m_filesInvalid.Empty(); - m_List.clear(); + 1) change up IO_ERROR so it keeps linenumbers, source file name and + error message in separate strings. - // try + 2) Add a summarizing virtual member like + virtual wxString What() + to combine all portions of an IO_ERROR's text into a single wxString. + + 3) Do same for PARSE_ERROR. + + 4) Add a "reason or error category" to IO_ERROR and thereby also PARSE_ERROR? + + msg += " + + for( int i=0; i" ); + + for ( unsigned ii = 0; ii < strings_list->GetCount(); ii++ ) + { + msg += wxT( "
  • " ); + msg += strings_list->Item( ii ) + wxT( "
  • " ); + } + + msg += wxT( "" ); + + m_htmlWindow->AppendToPage( msg ); + + delete strings_list; +} +*/ + + +void FOOTPRINT_INFO::load() +{ + FP_LIB_TABLE* fptable = m_owner->GetTable(); + + wxASSERT( fptable ); + + std::auto_ptr m( fptable->FootprintLoad( m_nickname, m_fpname ) ); + + m_pad_count = m->GetPadCount( MODULE::DO_NOT_INCLUDE_NPTH ); + m_keywords = m->GetKeywords(); + m_doc = m->GetDescription(); + + // tell ensure_loaded() I'm loaded. + m_loaded = true; +} + + +#define JOBZ 6 // no. libraries per worker thread. It takes about + // a second to load a GITHUB library, so assigning + // this no. libraries to each thread should give a little + // over this no. seconds total time if the original delay + // were caused by latencies alone. + // (If https://github.com does not mind.) + +#define NTOLERABLE_ERRORS 4 // max errors before aborting, although threads + // in progress will still pile on for a bit. e.g. if 9 threads + // expect 9 greater than this. + +void FOOTPRINT_LIST::loader_job( const wxString* aNicknameList, int aJobZ ) +{ + //DBG(printf( "%s: first:'%s' count:%d\n", __func__, (char*) TO_UTF8( *aNicknameList ), aJobZ );) + + for( int i=0; i= NTOLERABLE_ERRORS ) + break; + + const wxString& nickname = aNicknameList[i]; + + try { - // Footprint library file names can be fully qualified or file name only. - wxFileName filename = aFootprintLibNames[ii]; + wxArrayString fpnames = m_lib_table->FootprintEnumerate( nickname ); - if( !filename.FileExists() ) + for( unsigned ni=0; ni -> <%s>." ), GetChars( aFootprintLibNames[ii] ), - GetChars( filename.GetFullPath() ) ); + ++m_error_count; // modify only under lock + m_errors.push_back( new IO_ERROR( pe ) ); + } + catch( const IO_ERROR& ioe ) + { + MUTLOCK lock( m_errors_lock ); - if( !filename.IsOk() || !filename.FileExists() ) - { - m_filesNotFound << aFootprintLibNames[ii] << wxT( "\n" ); - retv = false; - continue; - } + ++m_error_count; + m_errors.push_back( new IO_ERROR( ioe ) ); + } + // Catch anything unexpected and map it into the expected. + // Likely even more important since this function runs on GUI-less + // worker threads. + catch( const std::exception& se ) + { + // This is a round about way to do this, but who knows what THROW_IO_ERROR() + // may be tricked out to do someday, keep it in the game. try { - wxArrayString fpnames = pi->FootprintEnumerate( filename.GetFullPath() ); - - for( unsigned i=0; i m( pi->FootprintLoad( filename.GetFullPath(), - fpnames[i] ) ); - - // we're loading what we enumerated, all must be there. - wxASSERT( m.get() ); - - FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO(); - - fpinfo->SetNickname( filename.GetName() ); - fpinfo->SetLibPath( filename.GetFullPath() ); - fpinfo->m_Module = fpnames[i]; - fpinfo->m_padCount = m->GetPadCount( MODULE::DO_NOT_INCLUDE_NPTH ); - fpinfo->m_KeyWord = m->GetKeywords(); - fpinfo->m_Doc = m->GetDescription(); - - AddItem( fpinfo ); - } + THROW_IO_ERROR( se.what() ); } - catch( IO_ERROR ioe ) + catch( const IO_ERROR& ioe ) { - m_filesInvalid << ioe.errorText << wxT( "\n" ); - retv = false; + MUTLOCK lock( m_errors_lock ); + + ++m_error_count; + m_errors.push_back( new IO_ERROR( ioe ) ); } } } - - /* caller should catch this, UI seems not wanted here. - catch( IO_ERROR ioe ) - { - DisplayError( NULL, ioe.errorText ); - return false; - } - */ - - m_List.sort(); - - return retv; } -#else bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* aNickname ) { bool retv = true; + m_lib_table = aTable; + // Clear data before reading files - m_filesNotFound.Empty(); - m_filesInvalid.Empty(); - m_List.clear(); + m_error_count = 0; + m_errors.clear(); + m_list.clear(); - std::vector< wxString > nicknames; + if( aNickname ) + // single footprint + loader_job( aNickname, 1 ); + else + { + std::vector< wxString > nicknames; - if( !aNickname ) // do all of them nicknames = aTable->GetLogicalLibs(); - else - nicknames.push_back( *aNickname ); - for( unsigned ii = 0; ii < nicknames.size(); ii++ ) - { - const wxString& nickname = nicknames[ii]; +#if USE_WORKER_THREADS - try + // Something which will not invoke a thread copy constructor, one of many ways obviously: + typedef boost::ptr_vector< boost::thread > MYTHREADS; + + MYTHREADS threads; + + // Give each thread JOBZ nicknames to process. The last portion of, or if the entire + // size() is small, I'll do myself. + for( unsigned i=0; iFootprintEnumerate( nickname ); - - for( unsigned i=0; i= NTOLERABLE_ERRORS ) { - std::auto_ptr m( aTable->FootprintLoad( nickname, fpnames[i] ) ); - - // we're loading what we enumerated, all must be there. - wxASSERT( m.get() ); - - FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO(); - - fpinfo->SetNickname( nickname ); - - fpinfo->m_Module = fpnames[i]; - fpinfo->m_padCount = m->GetPadCount( MODULE::DO_NOT_INCLUDE_NPTH ); - fpinfo->m_KeyWord = m->GetKeywords(); - fpinfo->m_Doc = m->GetDescription(); - - AddItem( fpinfo ); + // abort the remaining nicknames. + retv = false; + break; } + + int jobz = JOBZ; + + if( i + jobz >= nicknames.size() ) + { + jobz = nicknames.size() - i; + + // Only a little bit to do, I'll do it myself, on current thread. + loader_job( &nicknames[i], jobz ); + } + else + { + // Delegate the job to a worker thread created here. + threads.push_back( new boost::thread( &FOOTPRINT_LIST::loader_job, + this, &nicknames[i], jobz ) ); + } + + i += jobz; } - catch( IO_ERROR ioe ) + + // Wait for all the worker threads to complete, it does not matter in what order + // we wait for them as long as a full sweep is made. Think of the great race, + // everyone must finish. + for( unsigned i=0; i // until scaffolding goes. - wxFileName filename = aLibrary; +void FOOTPRINT_LIST::DisplayErrors( wxTopLevelWindow* aWindow ) +{ +#if 1 + // scaffolding until a better one is written, hopefully below. - if( filename.GetExt().IsEmpty() ) - filename.SetExt( LegacyFootprintLibPathExtension ); + DBG(printf( "m_error_count:%d\n", m_error_count );) - if( filename.GetFullPath() == m_lib_path ) - return true; + wxString msg = _( "Errors were encountered loading footprints" ); - if( filename.GetPath().IsEmpty() ) - filename = wxGetApp().FindLibraryPath( filename.GetFullName() ); + msg += wxT( '\n' ); + + for( unsigned i = 0; i! ? centric output, possibly with + // recommendations for remedy of errors. Add numeric error codes + // to PARSE_ERROR, and switch on them for remedies, etc. Full + // access is provided to everything in every exception! + + HTML_MESSAGE_BOX dlg( aWindow, _( "Load Error" ) ); + + dlg.MessageSet( _( "Errors were encountered loading footprints" ) ); + + wxString msg = my html wizardry. + + dlg.AddHTML_Text( msg ); + + dlg.ShowModal(); - return filename.GetFullPath() == m_lib_path; #endif } diff --git a/common/fp_lib_table.cpp b/common/fp_lib_table.cpp index f6e8cc64d0..09bcf826e9 100644 --- a/common/fp_lib_table.cpp +++ b/common/fp_lib_table.cpp @@ -172,6 +172,12 @@ MODULE* FP_LIB_TABLE::FootprintLoad( const wxString& aNickname, const wxString& // having to copy the FPID and its two strings, twice each. FPID& fpid = (FPID&) ret->GetFPID(); + // Catch any misbehaving plugin, which should be setting internal footprint name properly: + wxASSERT( aFootprintName == FROM_UTF8( fpid.GetFootprintName().c_str() ) ); + + // and clearing nickname + wxASSERT( !fpid.GetLibNickname().size() ); + fpid.SetLibNickname( row->GetNickName() ); } @@ -631,6 +637,26 @@ const FP_LIB_TABLE::ROW* FP_LIB_TABLE::FindRow( const wxString& aNickname ) } +// wxGetenv( wchar_t* ) is not re-entrant on linux. +// Put a lock on multithreaded use of wxGetenv( wchar_t* ), called from wxEpandEnvVars(), +// needed by bool ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* aNickname = NULL ); +#if 1 + +#include + +const wxString FP_LIB_TABLE::ExpandSubstitutions( const wxString& aString ) +{ + static MUTEX getenv_mutex; + + MUTLOCK lock( getenv_mutex ); + + // We reserve the right to do this another way, by providing our own member + // function. + return wxExpandEnvVars( aString ); +} + +#else + const wxString FP_LIB_TABLE::ExpandSubstitutions( const wxString& aString ) { // We reserve the right to do this another way, by providing our own member @@ -638,6 +664,7 @@ const wxString FP_LIB_TABLE::ExpandSubstitutions( const wxString& aString ) return wxExpandEnvVars( aString ); } +#endif bool FP_LIB_TABLE::IsEmpty( bool aIncludeFallback ) { diff --git a/common/gal/stroke_font.cpp b/common/gal/stroke_font.cpp index 2ec1b43a0d..ab83eba22e 100644 --- a/common/gal/stroke_font.cpp +++ b/common/gal/stroke_font.cpp @@ -3,6 +3,8 @@ * * Copyright (C) 2012 Torsten Hueter, torstenhtr gmx.de * Copyright (C) 2012 Kicad Developers, see change_log.txt for contributors. + * Copyright (C) 2013 CERN + * @author Maciej Suminski * * Stroke font class * @@ -26,12 +28,13 @@ #include #include +#include using namespace KIGFX; - -const double STROKE_FONT::LINE_HEIGHT_RATIO = 1.6; - +const double STROKE_FONT::OVERBAR_HEIGHT = 0.45; +const double STROKE_FONT::BOLD_FACTOR = 1.3; +const double STROKE_FONT::HERSHEY_SCALE = 1.0 / 21.0; STROKE_FONT::STROKE_FONT( GAL* aGal ) : m_gal( aGal ), @@ -40,22 +43,18 @@ STROKE_FONT::STROKE_FONT( GAL* aGal ) : m_mirrored( false ) { // Default values - m_scaleFactor = 1.0 / 21.0; m_glyphSize = VECTOR2D( 10.0, 10.0 ); m_verticalJustify = GR_TEXT_VJUSTIFY_BOTTOM; m_horizontalJustify = GR_TEXT_HJUSTIFY_LEFT; } -STROKE_FONT::~STROKE_FONT() -{ -} - - bool STROKE_FONT::LoadNewStrokeFont( const char* const aNewStrokeFont[], int aNewStrokeFontSize ) { m_glyphs.clear(); m_glyphBoundingBoxes.clear(); + m_glyphs.resize( aNewStrokeFontSize ); + m_glyphBoundingBoxes.resize( aNewStrokeFontSize ); for( int j = 0; j < aNewStrokeFontSize; j++ ) { @@ -81,8 +80,8 @@ bool STROKE_FONT::LoadNewStrokeFont( const char* const aNewStrokeFont[], int aNe if( i < 2 ) { // The first two values contain the width of the char - glyphStartX = coordinate[0] - 'R'; - glyphEndX = coordinate[1] - 'R'; + glyphStartX = ( coordinate[0] - 'R' ) * HERSHEY_SCALE; + glyphEndX = ( coordinate[1] - 'R' ) * HERSHEY_SCALE; glyphBoundingX = VECTOR2D( 0, glyphEndX - glyphStartX ); } else if( ( coordinate[0] == ' ' ) && ( coordinate[1] == 'R' ) ) @@ -97,8 +96,8 @@ bool STROKE_FONT::LoadNewStrokeFont( const char* const aNewStrokeFont[], int aNe { // Every coordinate description of the Hershey format has an offset, // it has to be subtracted - point.x = (double) ( coordinate[0] - 'R' ) - glyphStartX; - point.y = (double) ( coordinate[1] - 'R' ) - 11.0; + point.x = (double) ( coordinate[0] - 'R' ) * HERSHEY_SCALE - glyphStartX; + point.y = (double) ( coordinate[1] - 'R' ) * HERSHEY_SCALE; pointList.push_back( point ); } @@ -108,16 +107,22 @@ bool STROKE_FONT::LoadNewStrokeFont( const char* const aNewStrokeFont[], int aNe if( pointList.size() > 0 ) glyph.push_back( pointList ); - m_glyphs.push_back( glyph ); + m_glyphs[j] = glyph; // Compute the bounding box of the glyph - m_glyphBoundingBoxes.push_back( computeBoundingBox( glyph, glyphBoundingX ) ); + m_glyphBoundingBoxes[j] = computeBoundingBox( glyph, glyphBoundingX ); } return true; } +int STROKE_FONT::getInterline() const +{ + return ( m_glyphSize.y * 14 ) / 10 + m_gal->GetLineWidth(); +} + + BOX2D STROKE_FONT::computeBoundingBox( const GLYPH& aGLYPH, const VECTOR2D& aGLYPHBoundingX ) const { BOX2D boundingBox; @@ -142,133 +147,162 @@ BOX2D STROKE_FONT::computeBoundingBox( const GLYPH& aGLYPH, const VECTOR2D& aGLY } -void STROKE_FONT::Draw( std::string aText, const VECTOR2D& aPosition, double aRotationAngle ) +void STROKE_FONT::Draw( const wxString& aText, const VECTOR2D& aPosition, double aRotationAngle ) { - // By default overbar is turned off - m_overbar = false; - // Context needs to be saved before any transformations m_gal->Save(); m_gal->Translate( aPosition ); - m_gal->Rotate( -aRotationAngle ); - // Split multiline strings into separate ones and draw them line by line - size_t newlinePos = aText.find( '\n' ); + // Single line height + int lineHeight = getInterline(); - if( newlinePos != std::string::npos ) - { - VECTOR2D nextlinePosition = VECTOR2D( 0.0, m_glyphSize.y * LINE_HEIGHT_RATIO ); - - Draw( aText.substr( newlinePos + 1 ), nextlinePosition, 0.0 ); - aText = aText.substr( 0, newlinePos ); - } - - // Compute the text size - VECTOR2D textsize = computeTextSize( aText ); - - // Adjust the text position to the given alignment - switch( m_horizontalJustify ) - { - case GR_TEXT_HJUSTIFY_CENTER: - m_gal->Translate( VECTOR2D( -textsize.x / 2.0, 0 ) ); - break; - - case GR_TEXT_HJUSTIFY_RIGHT: - if( !m_mirrored ) - m_gal->Translate( VECTOR2D( -textsize.x, 0 ) ); - - break; - - case GR_TEXT_HJUSTIFY_LEFT: - if( m_mirrored ) - m_gal->Translate( VECTOR2D( -textsize.x, 0 ) ); - - break; - - default: - break; - } + // The overall height of all lines of text + double textBlockHeight = lineHeight * ( linesCount( aText ) - 1 ); switch( m_verticalJustify ) { case GR_TEXT_VJUSTIFY_CENTER: - m_gal->Translate( VECTOR2D( 0, textsize.y / 2.0 ) ); - break; - - case GR_TEXT_VJUSTIFY_TOP: - m_gal->Translate( VECTOR2D( 0, textsize.y ) ); + m_gal->Translate( VECTOR2D( 0, -textBlockHeight / 2.0 ) ); break; case GR_TEXT_VJUSTIFY_BOTTOM: + m_gal->Translate( VECTOR2D( 0, -textBlockHeight ) ); + break; + + case GR_TEXT_VJUSTIFY_TOP: break; default: break; } - double xOffset, glyphSizeX; - - if( m_mirrored ) - { - // In case of mirrored text invert the X scale of points and their X direction - // (m_glyphSize.x) and start drawing from the position where text normally should end - // (textsize.x) - xOffset = textsize.x; - glyphSizeX = -m_glyphSize.x; - } - else - { - xOffset = 0.0; - glyphSizeX = m_glyphSize.x; - } - double scaleY = m_scaleFactor * m_glyphSize.y; - double scaleX = m_scaleFactor * glyphSizeX; + m_gal->Rotate( -aRotationAngle ); m_gal->SetIsStroke( true ); m_gal->SetIsFill( false ); if( m_bold ) + m_gal->SetLineWidth( m_gal->GetLineWidth() * BOLD_FACTOR ); + + // Split multiline strings into separate ones and draw them line by line + size_t begin = 0; + size_t newlinePos = aText.find( '\n' ); + + while( newlinePos != aText.npos ) { - m_gal->SetLineWidth( m_gal->GetLineWidth() * 1.3 ); + size_t length = newlinePos - begin; + + drawSingleLineText( aText.Mid( begin, length ) ); + m_gal->Translate( VECTOR2D( 0.0, lineHeight ) ); + + begin = newlinePos + 1; + newlinePos = aText.find( '\n', begin ); } - for( std::string::const_iterator chIt = aText.begin(); chIt != aText.end(); chIt++ ) + // Draw the last (or the only one) line + if( !aText.IsEmpty() ) + drawSingleLineText( aText.Mid( begin ) ); + + m_gal->Restore(); +} + + +void STROKE_FONT::drawSingleLineText( const wxString& aText ) +{ + // By default the overbar is turned off + m_overbar = false; + + double xOffset; + VECTOR2D glyphSize( m_glyphSize ); + + // Compute the text size + VECTOR2D textSize = computeTextSize( aText ); + + m_gal->Save(); + + // Adjust the text position to the given alignment + switch( m_horizontalJustify ) { + case GR_TEXT_HJUSTIFY_CENTER: + m_gal->Translate( VECTOR2D( -textSize.x / 2.0, 0 ) ); + break; + + case GR_TEXT_HJUSTIFY_RIGHT: + if( !m_mirrored ) + m_gal->Translate( VECTOR2D( -textSize.x, 0 ) ); + break; + + case GR_TEXT_HJUSTIFY_LEFT: + if( m_mirrored ) + m_gal->Translate( VECTOR2D( -textSize.x, 0 ) ); + break; + + default: + break; + } + + if( m_mirrored ) + { + // In case of mirrored text invert the X scale of points and their X direction + // (m_glyphSize.x) and start drawing from the position where text normally should end + // (textSize.x) + xOffset = textSize.x; + glyphSize.x = -m_glyphSize.x; + } + else + { + xOffset = 0.0; + } + + for( wxString::const_iterator chIt = aText.begin(); chIt != aText.end(); ++chIt ) + { + // Toggle overbar if( *chIt == '~' ) { - m_overbar = !m_overbar; - continue; + if( ++chIt == aText.end() ) + break; + + if( *chIt != '~' ) // It was a single tilda, it toggles overbar + m_overbar = !m_overbar; + + // If it is a double tilda, just process the second one } - GLYPH_LIST::iterator glyphIt = m_glyphs.begin(); - std::deque::iterator bbIt = m_glyphBoundingBoxes.begin(); + unsigned dd = *chIt - ' '; - unsigned dd = (unsigned) ((unsigned char) *chIt ) - (unsigned) ' '; - - if( dd >= m_glyphBoundingBoxes.size() ) + if( dd >= m_glyphBoundingBoxes.size() || dd < 0 ) dd = '?' - ' '; - advance( glyphIt, dd ); - advance( bbIt, dd ); + GLYPH& glyph = m_glyphs[dd]; + BOX2D& bbox = m_glyphBoundingBoxes[dd]; - GLYPH glyph = *glyphIt; + if( m_overbar ) + { + VECTOR2D startOverbar( xOffset, -getInterline() * OVERBAR_HEIGHT ); + VECTOR2D endOverbar( xOffset + glyphSize.x * bbox.GetEnd().x, + -getInterline() * OVERBAR_HEIGHT ); + m_gal->DrawLine( startOverbar, endOverbar ); + } for( GLYPH::iterator pointListIt = glyph.begin(); pointListIt != glyph.end(); - pointListIt++ ) + ++pointListIt ) { std::deque pointListScaled; for( std::deque::iterator pointIt = pointListIt->begin(); - pointIt != pointListIt->end(); pointIt++ ) + pointIt != pointListIt->end(); ++pointIt ) { - VECTOR2D pointPos( pointIt->x * scaleX + xOffset, pointIt->y * scaleY ); + VECTOR2D pointPos( pointIt->x * glyphSize.x + xOffset, pointIt->y * glyphSize.y ); if( m_italic ) { // FIXME should be done other way - referring to the lowest Y value of point // because now italic fonts are translated a bit - pointPos.x += pointPos.y * 0.1; + if( m_mirrored ) + pointPos.x += pointPos.y * 0.1; + else + pointPos.x -= pointPos.y * 0.1; } pointListScaled.push_back( pointPos ); @@ -277,39 +311,37 @@ void STROKE_FONT::Draw( std::string aText, const VECTOR2D& aPosition, double aRo m_gal->DrawPolyline( pointListScaled ); } - if( m_overbar ) - { - VECTOR2D startOverbar( xOffset, -textsize.y * 1.2 ); - VECTOR2D endOverbar( xOffset + m_scaleFactor * glyphSizeX * bbIt->GetEnd().x, - -textsize.y * 1.2 ); - m_gal->DrawLine( startOverbar, endOverbar ); - } - - xOffset += m_scaleFactor * glyphSizeX * bbIt->GetEnd().x; + xOffset += glyphSize.x * bbox.GetEnd().x; } m_gal->Restore(); } -VECTOR2D STROKE_FONT::computeTextSize( const std::string& aText ) const +VECTOR2D STROKE_FONT::computeTextSize( const wxString& aText ) const { VECTOR2D result = VECTOR2D( 0.0, m_glyphSize.y ); - for( std::string::const_iterator chIt = aText.begin(); chIt != aText.end(); chIt++ ) + for( wxString::const_iterator chIt = aText.begin(); chIt != aText.end(); ++chIt ) { + wxASSERT_MSG( *chIt != '\n', + wxT( "This function is intended to work with single line strings" ) ); + + // If it is double tilda, then it is displayed as a single tilda + // If it is single tilda, then it is toggling overbar, so we need to skip it if( *chIt == '~' ) - continue; + { + if( ++chIt == aText.end() ) + break; + } - std::deque::const_iterator bbIt = m_glyphBoundingBoxes.begin(); - unsigned dd = (unsigned) ((unsigned char)*chIt) - (unsigned) ' '; + // Index in the bounding boxes table + unsigned dd = *chIt - ' '; - if( dd >= m_glyphBoundingBoxes.size() ) + if( dd >= m_glyphBoundingBoxes.size() || dd < 0 ) dd = '?' - ' '; - advance( bbIt, dd ); - - result.x += m_scaleFactor * m_glyphSize.x * bbIt->GetEnd().x; + result.x += m_glyphSize.x * m_glyphBoundingBoxes[dd].GetEnd().x; } return result; diff --git a/common/geometry/shape_line_chain.cpp b/common/geometry/shape_line_chain.cpp index a78e94a584..7ac8c10eae 100644 --- a/common/geometry/shape_line_chain.cpp +++ b/common/geometry/shape_line_chain.cpp @@ -25,7 +25,6 @@ #include #include -using namespace std; using boost::optional; bool SHAPE_LINE_CHAIN::Collide( const VECTOR2I& aP, int aClearance ) const @@ -137,7 +136,7 @@ int SHAPE_LINE_CHAIN::Distance( const VECTOR2I& aP ) const int d = INT_MAX; for( int s = 0; s < SegmentCount(); s++ ) - d = min( d, CSegment( s ).Distance( aP ) ); + d = std::min( d, CSegment( s ).Distance( aP ) ); return d; } @@ -437,7 +436,7 @@ const optional SHAPE_LINE_CHAIN::SelfIntersectin SHAPE_LINE_CHAIN& SHAPE_LINE_CHAIN::Simplify() { - vector pts_unique; + std::vector pts_unique; if( PointCount() < 2 ) { @@ -524,9 +523,9 @@ const VECTOR2I SHAPE_LINE_CHAIN::NearestPoint( const VECTOR2I& aP ) const } -const string SHAPE_LINE_CHAIN::Format() const +const std::string SHAPE_LINE_CHAIN::Format() const { - stringstream ss; + std::stringstream ss; ss << m_points.size() << " " << ( m_closed ? 1 : 0 ) << " "; diff --git a/common/gr_basic.cpp b/common/gr_basic.cpp index 8c7f70131d..9052ac74f5 100644 --- a/common/gr_basic.cpp +++ b/common/gr_basic.cpp @@ -1358,8 +1358,8 @@ void ClipAndDrawPoly( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPoints[], int n ) } // A clip box exists: clip and draw the polygon. - static vector clippedPolygon; - static pointVector inputPolygon, outputPolygon; + static std::vector clippedPolygon; + static pointVector inputPolygon, outputPolygon; inputPolygon.clear(); outputPolygon.clear(); diff --git a/common/html_messagebox.cpp b/common/html_messagebox.cpp index c86879eae2..25532fb1e8 100644 --- a/common/html_messagebox.cpp +++ b/common/html_messagebox.cpp @@ -1,83 +1,78 @@ #include #include #include +#include -HTML_MESSAGE_BOX::HTML_MESSAGE_BOX( wxWindow* parent, const wxString & aTitle, - wxPoint aPos, wxSize aSize) - : DIALOG_DISPLAY_HTML_TEXT_BASE( parent, wxID_ANY, aTitle, aPos, aSize ) + +HTML_MESSAGE_BOX::HTML_MESSAGE_BOX( wxWindow* parent, const wxString& aTitle, + wxPoint aPos, wxSize aSize) : + DIALOG_DISPLAY_HTML_TEXT_BASE( parent, wxID_ANY, aTitle, aPos, aSize ) { ListClear(); Center(); } + void HTML_MESSAGE_BOX::OnCloseButtonClick( wxCommandEvent& event ) { - EndModal(0); + EndModal( 0 ); } -void HTML_MESSAGE_BOX::ListClear(void) +void HTML_MESSAGE_BOX::ListClear() { - m_htmlWindow->SetPage(wxEmptyString); + m_htmlWindow->SetPage( wxEmptyString ); } -/** - * Function ListSet - * Add a list of items. - * @param aList = a string containing items. Items are separated by '\n' - */ -void HTML_MESSAGE_BOX::ListSet(const wxString &aList) -{ - wxArrayString* wxStringSplit( wxString txt, wxChar splitter ); - wxArrayString* strings_list = wxStringSplit( aList, wxChar('\n') ); - wxString msg = wxT("
      "); - for ( unsigned ii = 0; ii < strings_list->GetCount(); ii ++ ) +void HTML_MESSAGE_BOX::ListSet( const wxString& aList ) +{ + // wxArrayString* wxStringSplit( wxString txt, wxChar splitter ); + + wxArrayString* strings_list = wxStringSplit( aList, wxChar( '\n' ) ); + + wxString msg = wxT( "
        " ); + + for ( unsigned ii = 0; ii < strings_list->GetCount(); ii++ ) { - msg += wxT("
      • "); - msg += strings_list->Item(ii) + wxT("
      • "); + msg += wxT( "
      • " ); + msg += strings_list->Item( ii ) + wxT( "
      • " ); } - msg += wxT("
      "); + + msg += wxT( "
    " ); + m_htmlWindow->AppendToPage( msg ); delete strings_list; } -/** - * Function ListSet - * Add a list of items. - * @param aList = a wxArrayString containing items - */ -void HTML_MESSAGE_BOX::ListSet(const wxArrayString &aList) + +void HTML_MESSAGE_BOX::ListSet( const wxArrayString& aList ) { - wxString msg = wxT("
      "); - for ( unsigned ii = 0; ii < aList.GetCount(); ii ++ ) + wxString msg = wxT( "
        " ); + + for( unsigned ii = 0; ii < aList.GetCount(); ii++ ) { - msg += wxT("
      • "); - msg += aList.Item(ii) + wxT("
      • "); + msg += wxT( "
      • " ); + msg += aList.Item( ii ) + wxT( "
      • " ); } - msg += wxT("
      "); + + msg += wxT( "
    " ); + m_htmlWindow->AppendToPage( msg ); } -/** - * Function MessageSet - * Add a message (in bold) to message list. - * @param message = the message - */ -void HTML_MESSAGE_BOX::MessageSet(const wxString &message) + +void HTML_MESSAGE_BOX::MessageSet( const wxString& message ) { - wxString message_value; - message_value.Printf(wxT("%s
    "), GetChars( message ) ); + wxString message_value = wxString::Format( + wxT( "%s
    " ), GetChars( message ) ); + m_htmlWindow->AppendToPage( message_value ); } -/** - * Function AddHTML_Text - * Add a text to message list. - * @param message = the text to add - */ -void HTML_MESSAGE_BOX::AddHTML_Text(const wxString &message) + +void HTML_MESSAGE_BOX::AddHTML_Text( const wxString& message ) { m_htmlWindow->AppendToPage( message ); } diff --git a/common/pcbcommon.cpp b/common/pcbcommon.cpp index da36d48c09..ddfd0e5f68 100644 --- a/common/pcbcommon.cpp +++ b/common/pcbcommon.cpp @@ -55,9 +55,6 @@ LAYER_MSK g_TabAllCopperLayerMask[NB_COPPER_LAYERS] = { DISPLAY_OPTIONS DisplayOpt; // Display options for board items -// This will be always be 450 or 900 (by UI design) at the moment -int g_RotationAngle; - int g_AnchorColor = BLUE; int g_ModuleTextCMPColor = LIGHTGRAY; int g_ModuleTextCUColor = MAGENTA; diff --git a/common/string.cpp b/common/string.cpp index 7d3a74f0c4..86b60d938f 100644 --- a/common/string.cpp +++ b/common/string.cpp @@ -477,3 +477,18 @@ bool ReplaceIllegalFileNameChars( std::string* aName ) return changed; } + + +wxString RemoveTrailingZeros( const wxString& aString ) +{ + wxString retv = aString; + int i = retv.Length(); + + while( --i > 0 && retv[i] == wxChar( '0' ) ) + retv.RemoveLast(); + + if( retv[i] == wxChar( '.' ) ) + retv.RemoveLast(); + + return retv; +} diff --git a/common/strtok_r.c b/common/strtok_r.c new file mode 100644 index 0000000000..a0b099706a --- /dev/null +++ b/common/strtok_r.c @@ -0,0 +1,35 @@ +/* + * public domain strtok_r() + */ + +#include + +char* strtok_r( char* str, const char* delim, char** nextp ) +{ + char* ret; + + if( str == NULL ) + { + str = *nextp; + } + + str += strspn( str, delim ); + + if( *str == '\0' ) + { + return NULL; + } + + ret = str; + + str += strcspn( str, delim ); + + if( *str ) + { + *str++ = '\0'; + } + + *nextp = str; + + return ret; +} diff --git a/common/tool/tool_event.cpp b/common/tool/tool_event.cpp index 978550406b..481b8c1b95 100644 --- a/common/tool/tool_event.cpp +++ b/common/tool/tool_event.cpp @@ -31,8 +31,6 @@ #include -using namespace std; - struct FlagString { int flag; @@ -154,7 +152,7 @@ const std::string TOOL_EVENT::Format() const const std::string TOOL_EVENT_LIST::Format() const { - string s; + std::string s; BOOST_FOREACH( TOOL_EVENT e, m_events ) s += e.Format() + " "; diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index ffc5a2d44b..937a178653 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -47,7 +47,6 @@ #include using boost::optional; -using namespace std; /// Struct describing the current execution state of a TOOL struct TOOL_MANAGER::TOOL_STATE diff --git a/common/utf8.cpp b/common/utf8.cpp new file mode 100644 index 0000000000..48478bb15b --- /dev/null +++ b/common/utf8.cpp @@ -0,0 +1,260 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 2013 KiCad Developers, see CHANGELOG.TXT for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include + +/* THROW_IO_ERROR needs this, but it will soon be including this file, so until some + factoring of THROW_IO_ERROR into a separate header, defer and use the asserts. +#include +*/ + +#include + +/* + These are not inlined so that code space is saved by encapsulating the + creation of intermediate objects and referencing wxConvUTF8. +*/ + + +UTF8::UTF8( const wxString& o ) : + std::string( (const char*) o.utf8_str() ) +{ +} + + +UTF8::operator wxString () const +{ + return wxString( c_str(), wxConvUTF8 ); +} + + +UTF8& UTF8::operator=( const wxString& o ) +{ + std::string::operator=( (const char*) o.utf8_str() ); + return *this; +} + + +#ifndef THROW_IO_ERROR + #define THROW_IO_ERROR(x) // nothing +#endif + +// There is no wxWidgets function that does this, because wchar_t is 16 bits +// on windows and wx wants to encode the output in UTF16 for such. + +int UTF8::uni_forward( const unsigned char* aSequence, unsigned* aResult ) +{ + unsigned ch = *aSequence; + + if( ch < 0x80 ) + { + if( aResult ) + *aResult = ch; + return 1; + } + + const unsigned char* s = aSequence; + + static const unsigned char utf8_len[] = { + // Map encoded prefix byte to sequence length. Zero means + // illegal prefix. See RFC 3629 for details + /* + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 00-0F + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 70-7F + */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 80-8F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // B0-BF + 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C0-C1 + C2-CF + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // D0-DF + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // E0-EF + 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // F0-F4 + F5-FF + }; + + int len = utf8_len[ *s - 0x80 /* top half of table is missing */ ]; + + switch( len ) + { + default: + case 0: + THROW_IO_ERROR( "invalid start byte" ); + break; + + case 2: + if( ( s[1] & 0xc0 ) != 0x80 ) + { + THROW_IO_ERROR( "invalid continuation byte" ); + } + + ch = ((s[0] & 0x1f) << 6) + + ((s[1] & 0x3f) << 0); + + assert( ch > 0x007F && ch <= 0x07FF ); + break; + + case 3: + if( (s[1] & 0xc0) != 0x80 || + (s[2] & 0xc0) != 0x80 || + (s[0] == 0xE0 && s[1] < 0xA0) + // || (s[0] == 0xED && s[1] > 0x9F) + ) + { + THROW_IO_ERROR( "invalid continuation byte" ); + } + + ch = ((s[0] & 0x0f) << 12) + + ((s[1] & 0x3f) << 6 ) + + ((s[2] & 0x3f) << 0 ); + + assert( ch > 0x07FF && ch <= 0xFFFF ); + break; + + case 4: + if( (s[1] & 0xc0) != 0x80 || + (s[2] & 0xc0) != 0x80 || + (s[3] & 0xc0) != 0x80 || + (s[0] == 0xF0 && s[1] < 0x90) || + (s[0] == 0xF4 && s[1] > 0x8F) ) + { + THROW_IO_ERROR( "invalid continuation byte" ); + } + + ch = ((s[0] & 0x7) << 18) + + ((s[1] & 0x3f) << 12) + + ((s[2] & 0x3f) << 6 ) + + ((s[3] & 0x3f) << 0 ); + + assert( ch > 0xFFFF && ch <= 0x10ffff ); + break; + } + + if( aResult ) + { + *aResult = ch; + } + + return len; +} + + +UTF8::UTF8( const wchar_t* txt ) : + // size initial string safely large enough, then shrink to known size later. + std::string( wcslen( txt ) * 4, 0 ) +{ + /* + + "this" string was sized to hold the worst case UTF8 encoded byte + sequence, and was initialized with all nul bytes. Overwrite some of + those nuls, then resize, shrinking down to actual size. + + Use the wx 2.8 function, not new FromWChar(). It knows about wchar_t + possibly being 16 bits wide on Windows and holding UTF16 input. + + */ + + int sz = wxConvUTF8.WC2MB( (char*) data(), txt, size() ); + + resize( sz ); +} + + +#if 0 // some unit tests: + +#include + +wxString wxFunctionTaking_wxString( const wxString& wx ) +{ + printf( "%s:'%s'\n", __func__, (char*) UTF8( wx ) ); + printf( "%s:'%s'\n", __func__, (const char*) UTF8( wx ) ); + printf( "%s:'%s'\n", __func__, UTF8( wx ).c_str() ); + + return wx; +} + +int main() +{ + std::string str = "input"; + + UTF8 u0 = L"wide string"; + UTF8 u1 = "initial"; + wxString wx = wxT( "input2" ); + + printf( "u0:'%s'\n", u0.c_str() ); + printf( "u1:'%s'\n", u1.c_str() ); + + u1 = str; + + wxString wx2 = u1; + + // force a std::string into a UTF8, then into a wxString, then copy construct: + wxString wx3 = (UTF8&) u1; + + UTF8 u2 = wx2; + + u2 += 'X'; + + printf( "u2:'%s'\n", u2.c_str() ); + + // key accomplishments here: + // 1) passing a UTF8 to a function which normally takes a wxString. + // 2) return a wxString back into a UTF8. + UTF8 result = wxFunctionTaking_wxString( u2 ); + + printf( "result:'%s'\n", result.c_str() ); + + // test the unicode iterator: + for( UTF8::uni_iter it = u2.ubegin(); it < u2.uend(); ) + { + // test post-increment: + printf( " _%c_", *it++ ); + + // after UTF8::uni_forward() is implemented, %c is no longer useable. + // printf( " _%02x_", *it++ ); + } + + printf( "\n" ); + + UTF8::uni_iter it = u2.ubegin(); + + UTF8::uni_iter it2 = it++; + + printf( "post_inc:'%c' should be 'i'\n", *it2 ); + + it2 = ++it; + + printf( "pre_inc:'%c' should be 'p'\n", *it2 ); + + printf( "u[1]:'%c' should be 'n'\n", u2[1] ); + + return 0; +} + +#endif diff --git a/common/view/view.cpp b/common/view/view.cpp index 0ff8708ed0..e27751bb76 100644 --- a/common/view/view.cpp +++ b/common/view/view.cpp @@ -159,10 +159,12 @@ struct queryVisitor { } - void operator()( VIEW_ITEM* aItem ) + bool operator()( VIEW_ITEM* aItem ) { if( aItem->ViewIsVisible() ) m_cont.push_back( VIEW::LAYER_ITEM_PAIR( aItem, m_layer ) ); + + return true; } Container& m_cont; @@ -393,7 +395,7 @@ struct VIEW::updateItemsColor { } - void operator()( VIEW_ITEM* aItem ) + bool operator()( VIEW_ITEM* aItem ) { // Obtain the color that should be used for coloring the item const COLOR4D color = painter->GetSettings()->GetColor( aItem, layer ); @@ -401,6 +403,8 @@ struct VIEW::updateItemsColor if( group >= 0 ) gal->ChangeGroupColor( group, color ); + + return true; } int layer; @@ -453,12 +457,14 @@ struct VIEW::changeItemsDepth { } - void operator()( VIEW_ITEM* aItem ) + bool operator()( VIEW_ITEM* aItem ) { int group = aItem->getGroup( layer ); if( group >= 0 ) gal->ChangeGroupDepth( group, depth ); + + return true; } int layer, depth; @@ -577,15 +583,17 @@ struct VIEW::drawItem { } - void operator()( VIEW_ITEM* aItem ) + bool operator()( VIEW_ITEM* aItem ) { // Conditions that have te be fulfilled for an item to be drawn bool drawCondition = aItem->ViewIsVisible() && aItem->ViewGetLOD( currentLayer->id ) < view->m_scale; if( !drawCondition ) - return; + return true; view->draw( aItem, currentLayer->id ); + + return true; } const VIEW_LAYER* currentLayer; @@ -682,9 +690,11 @@ bool VIEW::IsDirty() const struct VIEW::unlinkItem { - void operator()( VIEW_ITEM* aItem ) + bool operator()( VIEW_ITEM* aItem ) { aItem->m_view = NULL; + + return true; } }; @@ -696,7 +706,7 @@ struct VIEW::recacheItem { } - void operator()( VIEW_ITEM* aItem ) + bool operator()( VIEW_ITEM* aItem ) { // Remove previously cached group int prevGroup = aItem->getGroup( layer ); @@ -718,6 +728,8 @@ struct VIEW::recacheItem { aItem->setGroup( layer, -1 ); } + + return true; } VIEW* view; @@ -798,12 +810,14 @@ struct VIEW::clearLayerCache { } - void operator()( VIEW_ITEM* aItem ) + bool operator()( VIEW_ITEM* aItem ) { if( aItem->storesGroups() ) { aItem->deleteGroups(); } + + return true; } VIEW* view; diff --git a/common/worksheet_viewitem.cpp b/common/worksheet_viewitem.cpp index 5ad38bc46a..7ecf6de8d7 100644 --- a/common/worksheet_viewitem.cpp +++ b/common/worksheet_viewitem.cpp @@ -191,7 +191,7 @@ void WORKSHEET_VIEWITEM::draw( const WS_DRAW_ITEM_TEXT* aItem, GAL* aGal ) const aGal->SetStrokeColor( COLOR4D( aItem->GetColor() ) ); aGal->SetLineWidth( aItem->GetThickness() ); aGal->SetTextAttributes( aItem ); - aGal->StrokeText( std::string( aItem->GetText().mb_str() ), position, 0.0 ); + aGal->StrokeText( std::wstring( aItem->GetText().wc_str() ), position, 0.0 ); } diff --git a/cvpcb/CMakeLists.txt b/cvpcb/CMakeLists.txt index cc337a40b1..8498688eaf 100644 --- a/cvpcb/CMakeLists.txt +++ b/cvpcb/CMakeLists.txt @@ -112,13 +112,13 @@ target_link_libraries( cvpcb # Only for win32 cross compilation using MXE if( WIN32 AND MSYS AND CMAKE_CROSSCOMPILING ) target_link_libraries(cvpcb - opengl32 - glu32 - pixman-1 - fontconfig - freetype - bz2 - ) + opengl32 + glu32 + pixman-1 + fontconfig + freetype + bz2 + ) endif() @@ -126,6 +126,9 @@ if( BUILD_GITHUB_PLUGIN ) target_link_libraries( cvpcb github_plugin ) endif() +# Must follow github_plugin +target_link_libraries( cvpcb ${Boost_LIBRARIES} ) + ### # Add cvpcb as install target diff --git a/cvpcb/autosel.cpp b/cvpcb/autosel.cpp index 7079a280ba..f9252eddbd 100644 --- a/cvpcb/autosel.cpp +++ b/cvpcb/autosel.cpp @@ -176,7 +176,7 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event ) /* filter alias so one can use multiple aliases (for polar and nonpolar caps for * example) */ - FOOTPRINT_INFO *module = m_footprints.GetModuleInfo( alias.m_FootprintName ); + const FOOTPRINT_INFO *module = m_footprints.GetModuleInfo( alias.m_FootprintName ); if( module ) { @@ -185,7 +185,7 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event ) for( size_t jj = 0; jj < filtercount && !found; jj++ ) { - found = module->m_Module.Matches( component->GetFootprintFilters()[jj] ); + found = module->GetFootprintName().Matches( component->GetFootprintFilters()[jj] ); } } else @@ -210,7 +210,7 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event ) { /* we do not need to analyse wildcards: single footprint do not contain them */ /* and if there are wildcards it just will not match any */ - FOOTPRINT_INFO *module = m_footprints.GetModuleInfo( component->GetFootprintFilters()[0] ); + const FOOTPRINT_INFO* module = m_footprints.GetModuleInfo( component->GetFootprintFilters()[0] ); if( module ) { diff --git a/cvpcb/cfg.cpp b/cvpcb/cfg.cpp index 9bface0d68..6823daa777 100644 --- a/cvpcb/cfg.cpp +++ b/cvpcb/cfg.cpp @@ -89,7 +89,6 @@ void CVPCB_MAINFRAME::LoadProjectFile( const wxString& aFileName ) // User library path takes precedent over default library search paths. wxGetApp().InsertLibraryPath( m_UserLibraryPath, 1 ); -#if defined( USE_FP_LIB_TABLE ) delete m_footprintLibTable; // Attempt to load the project footprint library table if it exists. @@ -111,7 +110,6 @@ void CVPCB_MAINFRAME::LoadProjectFile( const wxString& aFileName ) { DisplayError( this, ioe.errorText ); } -#endif } diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index 381e90dd97..244712d5a9 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -479,7 +479,6 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName ) try { -#if defined( USE_FP_LIB_TABLE ) FPID fpid; if( fpid.Parse( aFootprintName ) >= 0 ) @@ -496,35 +495,6 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName ) fpname.c_str(), nickname.c_str() ); footprint = m_footprintLibTable->FootprintLoad( FROM_UTF8( nickname.c_str() ), FROM_UTF8( fpname.c_str() ) ); -#else - CVPCB_MAINFRAME* parent = ( CVPCB_MAINFRAME* ) GetParent(); - - PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) ); - - for( unsigned i = 0; i < parent->m_ModuleLibNames.GetCount(); ++i ) - { - wxFileName fn( wxEmptyString, parent->m_ModuleLibNames[i], - LegacyFootprintLibPathExtension ); - - wxString libPath = wxGetApp().FindLibraryPath( fn ); - - if( !libPath ) - { - wxString msg = wxString::Format( _( "PCB footprint library file <%s> could not " - "be found in the default search paths." ), - fn.GetFullName().GetData() ); - - // @todo we should not be using wxMessageBox directly. - wxMessageBox( msg, wxEmptyString, wxOK | wxICON_ERROR, this ); - continue; - } - - footprint = pi->FootprintLoad( libPath, aFootprintName ); - - if( footprint != NULL ) - break; - } -#endif } catch( IO_ERROR ioe ) { @@ -558,9 +528,9 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay() msg.Printf( _( "Footprint: %s" ), GetChars( footprintName ) ); SetTitle( msg ); - FOOTPRINT_INFO* module_info = parentframe->m_footprints.GetModuleInfo( footprintName ); + const FOOTPRINT_INFO* module_info = parentframe->m_footprints.GetModuleInfo( footprintName ); - const wxChar *libname; + const wxChar* libname; if( module_info ) libname = GetChars( module_info->GetNickname() ); diff --git a/cvpcb/class_footprints_listbox.cpp b/cvpcb/class_footprints_listbox.cpp index 0fab83706a..fe3b38e572 100644 --- a/cvpcb/class_footprints_listbox.cpp +++ b/cvpcb/class_footprints_listbox.cpp @@ -135,14 +135,9 @@ void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& a { if( aFilterType == UNFILTERED ) { -#if !defined( USE_FP_LIB_TABLE ) - msg.Printf( wxT( "%3zu %s" ), newList.GetCount() + 1, - GetChars( aList.GetItem( ii ).m_Module ) ); -#else msg.Printf( wxT( "%3zu %s:%s" ), newList.GetCount() + 1, GetChars( aList.GetItem( ii ).GetNickname() ), - GetChars( aList.GetItem( ii ).m_Module ) ); -#endif + GetChars( aList.GetItem( ii ).GetFootprintName() ) ); newList.Add( msg ); continue; } @@ -151,22 +146,17 @@ void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& a && !aList.GetItem( ii ).InLibrary( aLibName ) ) continue; - if( (aFilterType & BY_COMPONENT) && (aComponent != NULL) - && !aComponent->MatchesFootprintFilters( aList.GetItem( ii ).m_Module ) ) + if( (aFilterType & BY_COMPONENT) && aComponent + && !aComponent->MatchesFootprintFilters( aList.GetItem( ii ).GetFootprintName() ) ) continue; - if( (aFilterType & BY_PIN_COUNT) && (aComponent!= NULL) - && (aComponent->GetNetCount() != aList.GetItem( ii ).m_padCount) ) + if( (aFilterType & BY_PIN_COUNT) && aComponent + && aComponent->GetNetCount() != aList.GetItem( ii ).GetPadCount() ) continue; -#if !defined( USE_FP_LIB_TABLE ) - msg.Printf( wxT( "%3zu %s" ), newList.GetCount() + 1, - aList.GetItem( ii ).m_Module.GetData() ); -#else msg.Printf( wxT( "%3zu %s:%s" ), newList.GetCount() + 1, GetChars( aList.GetItem( ii ).GetNickname() ), - GetChars( aList.GetItem( ii ).m_Module ) ); -#endif + GetChars( aList.GetItem( ii ).GetFootprintName() ) ); newList.Add( msg ); } diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index 11fb2d261d..f8cf599338 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -73,9 +73,7 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME ) EVT_MENU( ID_SAVE_PROJECT_AS, CVPCB_MAINFRAME::SaveProjectFile ) EVT_MENU( ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, CVPCB_MAINFRAME::OnKeepOpenOnSave ) -#if defined( USE_FP_LIB_TABLE ) EVT_MENU( ID_CVPCB_LIB_TABLE_EDIT, CVPCB_MAINFRAME::OnEditFootprintLibraryTable ) -#endif EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, CVPCB_MAINFRAME::SetLanguage ) @@ -122,10 +120,8 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) : m_undefinedComponentCnt = 0; m_skipComponentSelect = false; -#if defined( USE_FP_LIB_TABLE ) m_globalFootprintTable = NULL; m_footprintLibTable = NULL; -#endif /* Name of the document footprint list * usually located in share/modules/footprints_doc @@ -199,7 +195,6 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) : m_auimgr.Update(); -#if defined( USE_FP_LIB_TABLE ) if( m_globalFootprintTable == NULL ) { try @@ -229,8 +224,6 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) : m_footprintLibTable = new FP_LIB_TABLE( m_globalFootprintTable ); } -#endif - } @@ -511,7 +504,6 @@ void CVPCB_MAINFRAME::ConfigCvpcb( wxCommandEvent& event ) } -#if defined( USE_FP_LIB_TABLE ) void CVPCB_MAINFRAME::OnEditFootprintLibraryTable( wxCommandEvent& aEvent ) { bool tableChanged = false; @@ -556,9 +548,11 @@ void CVPCB_MAINFRAME::OnEditFootprintLibraryTable( wxCommandEvent& aEvent ) } if( tableChanged ) + { BuildLIBRARY_LISTBOX(); + m_footprints.ReadFootprintFiles( m_footprintLibTable ); + } } -#endif void CVPCB_MAINFRAME::OnKeepOpenOnSave( wxCommandEvent& event ) @@ -703,20 +697,20 @@ void CVPCB_MAINFRAME::DisplayStatus() } else { - wxString footprintName = m_FootprintList->GetSelectedFootprint(); + wxString footprintName = m_FootprintList->GetSelectedFootprint(); + FOOTPRINT_INFO* module = m_footprints.GetModuleInfo( footprintName ); if( module ) // can be NULL if no netlist loaded { - msg = _( "Description: " ) + module->m_Doc; + msg = _( "Description: " ) + module->GetDoc(); SetStatusText( msg, 0 ); - msg = _( "Key words: " ) + module->m_KeyWord; + msg = _( "Key words: " ) + module->GetKeywords(); SetStatusText( msg, 1 ); } } - msg.Empty(); if( m_FootprintList ) @@ -762,33 +756,12 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles() return false; } -#if !defined( USE_FP_LIB_TABLE ) - m_footprints.ReadFootprintFiles( m_ModuleLibNames ); -#else if( m_footprintLibTable != NULL ) m_footprints.ReadFootprintFiles( m_footprintLibTable ); -#endif - // Display error messages, if any. - if( !m_footprints.m_filesNotFound.IsEmpty() || !m_footprints.m_filesInvalid.IsEmpty() ) + if( m_footprints.GetErrorCount() ) { - HTML_MESSAGE_BOX dialog( this, _( "Load Error" ) ); - - if( !m_footprints.m_filesNotFound.IsEmpty() ) - { - wxString message = _( "Some files could not be found!" ); - dialog.MessageSet( message ); - dialog.ListSet( m_footprints.m_filesNotFound ); - } - - // Display if there are invalid files. - if( !m_footprints.m_filesInvalid.IsEmpty() ) - { - dialog.MessageSet( _( "Some files are invalid!" ) ); - dialog.ListSet( m_footprints.m_filesInvalid ); - } - - dialog.ShowModal(); + m_footprints.DisplayErrors( this ); } return true; @@ -953,9 +926,7 @@ void CVPCB_MAINFRAME::CreateScreenCmp() wxSize( 600, 400 ), KICAD_DEFAULT_DRAWFRAME_STYLE ); -#if defined( USE_FP_LIB_TABLE ) m_DisplayFootprintFrame->SetFootprintLibTable( m_footprintLibTable ); -#endif m_DisplayFootprintFrame->Show( true ); } @@ -1052,7 +1023,6 @@ void CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX() wxFONTWEIGHT_NORMAL ) ); } -#if defined( USE_FP_LIB_TABLE ) if( m_footprintLibTable ) { wxArrayString libNames; @@ -1064,9 +1034,6 @@ void CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX() m_LibraryList->SetLibraryList( libNames ); } -#else - m_LibraryList->SetLibraryList( m_ModuleLibNames ); -#endif } diff --git a/cvpcb/cvpcb.cpp b/cvpcb/cvpcb.cpp index 2b78d7aca6..a40e48f17e 100644 --- a/cvpcb/cvpcb.cpp +++ b/cvpcb/cvpcb.cpp @@ -99,9 +99,7 @@ bool EDA_APP::OnInit() InitEDA_Appl( wxT( "CvPcb" ), APP_CVPCB_T ); -#if defined( USE_FP_LIB_TABLE ) SetFootprintLibTablePath(); -#endif if( m_Checker && m_Checker->IsAnotherRunning() ) { diff --git a/cvpcb/cvpcb_mainframe.h b/cvpcb/cvpcb_mainframe.h index 7fea960ec2..01e2962a0d 100644 --- a/cvpcb/cvpcb_mainframe.h +++ b/cvpcb/cvpcb_mainframe.h @@ -55,7 +55,6 @@ class CVPCB_MAINFRAME : public EDA_BASE_FRAME { wxArrayString m_footprintListEntries; -#if defined( USE_FP_LIB_TABLE ) /// The global footprint library table. FP_LIB_TABLE* m_globalFootprintTable; @@ -63,7 +62,6 @@ class CVPCB_MAINFRAME : public EDA_BASE_FRAME /// footprint library table and the global footprint table. This is the one to /// use when finding a #MODULE. FP_LIB_TABLE* m_footprintLibTable; -#endif public: bool m_KeepCvpcbOpen; @@ -148,9 +146,7 @@ public: * Function OnEditLibraryTable * envokes the footpirnt library table edit dialog. */ -#if defined( USE_FP_LIB_TABLE ) void OnEditFootprintLibraryTable( wxCommandEvent& aEvent ); -#endif void OnKeepOpenOnSave( wxCommandEvent& event ); void DisplayModule( wxCommandEvent& event ); diff --git a/cvpcb/menubar.cpp b/cvpcb/menubar.cpp index bceb5170bf..f20fcd33d9 100644 --- a/cvpcb/menubar.cpp +++ b/cvpcb/menubar.cpp @@ -110,17 +110,9 @@ void CVPCB_MAINFRAME::ReCreateMenuBar() // Menu Preferences: wxMenu* preferencesMenu = new wxMenu; -#if !defined( USE_FP_LIB_TABLE ) - // Libraries to load - AddMenuItem( preferencesMenu, wxID_PREFERENCES, - _( "&Libraries" ), - _( "Set footprint libraries to load and library search paths" ), - KiBitmap( config_xpm ) ); -#else AddMenuItem( preferencesMenu, ID_CVPCB_LIB_TABLE_EDIT, _( "Li&brary Tables" ), _( "Setup footprint libraries" ), KiBitmap( library_table_xpm ) ); -#endif // Language submenu wxGetApp().AddMenuLanguageList( preferencesMenu ); diff --git a/cvpcb/readwrite_dlgs.cpp b/cvpcb/readwrite_dlgs.cpp index f24820d31b..ea28775faf 100644 --- a/cvpcb/readwrite_dlgs.cpp +++ b/cvpcb/readwrite_dlgs.cpp @@ -159,8 +159,6 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles() isLegacy = false; // None of the components have footprints assigned. } - -#if defined( USE_FP_LIB_TABLE ) wxString missingLibs; // Check if footprint links were generated before the footprint library table was implemented. @@ -217,7 +215,6 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles() } } } -#endif for( unsigned i = 0; i < m_netlist.GetCount(); i++ ) { @@ -272,7 +269,6 @@ int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName ) if( !fn.HasExt() ) fn.SetExt( ComponentFileExtension ); -#if defined( USE_FP_LIB_TABLE ) // Save the project specific footprint library table. if( !m_footprintLibTable->IsEmpty( false ) ) { @@ -298,8 +294,6 @@ int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName ) } } } -#endif - } if( !IsWritable( fn.GetFullPath() ) ) diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp index c59d48efde..30881e4fa1 100644 --- a/eeschema/annotate.cpp +++ b/eeschema/annotate.cpp @@ -26,8 +26,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include // to use sort vector -#include +#include #include #include diff --git a/eeschema/component_references_lister.cpp b/eeschema/component_references_lister.cpp index e352f785df..10b67d3678 100644 --- a/eeschema/component_references_lister.cpp +++ b/eeschema/component_references_lister.cpp @@ -30,7 +30,7 @@ #include -#include // to use sort vector +#include #include #include diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index f10a58628d..91449c9399 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2013 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -863,7 +863,19 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel() // Disable unit selection if only one unit exists: if( choiceCount <= 1 ) + { unitChoice->Enable( false ); + unitsInterchageableLabel->Show( false ); + unitsInterchageableText->Show( false ); + } + else + { + // Show the "Units are not interchangeable" message option? + if( !m_LibEntry || !m_LibEntry->UnitsLocked() ) + unitsInterchageableLabel->SetLabel( _("Yes") ); + else + unitsInterchageableLabel->SetLabel( _("No") ); + } int orientation = m_Cmp->GetOrientation() & ~( CMP_MIRROR_X | CMP_MIRROR_Y ); @@ -895,24 +907,17 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel() // Activate/Desactivate the normal/convert option ? (activated only if // the component has more than one shape) if( m_Cmp->GetConvert() > 1 ) - { convertCheckBox->SetValue( true ); - } if( m_LibEntry == NULL || !m_LibEntry->HasConversion() ) - { convertCheckBox->Enable( false ); - } - - // Show the "Parts Locked" option? - if( !m_LibEntry || !m_LibEntry->UnitsLocked() ) - { - DBG( printf( "partsAreLocked->false\n" ); ) - partsAreLockedLabel->Show( false ); - } // Set the component's library name. chipnameTextCtrl->SetValue( m_Cmp->m_ChipName ); + + // Set the component's unique ID time stamp. + m_textCtrlTimeStamp->SetValue( wxString::Format( wxT("%8.8lX"), + (unsigned long) m_Cmp->GetTimeStamp() ) ); } diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.cpp index 29bd666ee7..fa3398448e 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 30 2013) +// C++ code generated with wxFormBuilder (version Nov 6 2013) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -32,22 +32,27 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( unitChoice->SetSelection( 0 ); optionsSizer->Add( unitChoice, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - wxBoxSizer* orientationSizer; - orientationSizer = new wxBoxSizer( wxHORIZONTAL ); + wxBoxSizer* bSizerUnitsInterchangeable; + bSizerUnitsInterchangeable = new wxBoxSizer( wxHORIZONTAL ); + + unitsInterchageableText = new wxStaticText( this, wxID_ANY, _("Units are interchangeable:"), wxDefaultPosition, wxDefaultSize, 0 ); + unitsInterchageableText->Wrap( -1 ); + bSizerUnitsInterchangeable->Add( unitsInterchageableText, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 ); + + unitsInterchageableLabel = new wxStaticText( this, wxID_ANY, _("Yes"), wxDefaultPosition, wxDefaultSize, 0 ); + unitsInterchageableLabel->Wrap( -1 ); + bSizerUnitsInterchangeable->Add( unitsInterchageableLabel, 0, wxALL, 5 ); + + + optionsSizer->Add( bSizerUnitsInterchangeable, 1, wxEXPAND, 5 ); wxString orientationRadioBoxChoices[] = { _("0"), _("+90"), _("180"), _("-90") }; int orientationRadioBoxNChoices = sizeof( orientationRadioBoxChoices ) / sizeof( wxString ); orientationRadioBox = new wxRadioBox( this, wxID_ANY, _("Orientation (Degrees)"), wxDefaultPosition, wxDefaultSize, orientationRadioBoxNChoices, orientationRadioBoxChoices, 1, wxRA_SPECIFY_COLS ); - orientationRadioBox->SetSelection( 0 ); + orientationRadioBox->SetSelection( 1 ); orientationRadioBox->SetToolTip( _("Select if the component is to be rotated when drawn") ); - orientationSizer->Add( orientationRadioBox, 1, wxALL|wxEXPAND, 8 ); - - - optionsSizer->Add( orientationSizer, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 0 ); - - wxBoxSizer* mirrorSizer; - mirrorSizer = new wxBoxSizer( wxHORIZONTAL ); + optionsSizer->Add( orientationRadioBox, 0, wxEXPAND|wxALL, 5 ); wxString mirrorRadioBoxChoices[] = { _("Normal"), _("Mirror ---"), _("Mirror |") }; int mirrorRadioBoxNChoices = sizeof( mirrorRadioBoxChoices ) / sizeof( wxString ); @@ -55,10 +60,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( mirrorRadioBox->SetSelection( 0 ); mirrorRadioBox->SetToolTip( _("Pick the graphical transformation to be used when displaying the component, if any") ); - mirrorSizer->Add( mirrorRadioBox, 1, wxALL, 8 ); - - - optionsSizer->Add( mirrorSizer, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 0 ); + optionsSizer->Add( mirrorRadioBox, 0, wxALL|wxEXPAND, 5 ); m_staticTextChipname = new wxStaticText( this, wxID_ANY, _("Chip Name"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextChipname->Wrap( -1 ); @@ -73,19 +75,24 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( convertCheckBox = new wxCheckBox( this, wxID_ANY, _("Convert"), wxDefaultPosition, wxDefaultSize, 0 ); convertCheckBox->SetToolTip( _("Use the alternate shape of this component.\nFor gates, this is the \"De Morgan\" conversion") ); - optionsSizer->Add( convertCheckBox, 0, wxALL, 8 ); - - partsAreLockedLabel = new wxStaticText( this, wxID_ANY, _("Parts are locked"), wxDefaultPosition, wxDefaultSize, 0 ); - partsAreLockedLabel->Wrap( -1 ); - optionsSizer->Add( partsAreLockedLabel, 0, wxALL|wxEXPAND, 8 ); + optionsSizer->Add( convertCheckBox, 0, wxALL, 5 ); defaultsButton = new wxButton( this, wxID_ANY, _("Reset to Library Defaults"), wxDefaultPosition, wxDefaultSize, 0 ); defaultsButton->SetToolTip( _("Set position and style of fields and component orientation to default lib value.\nFields texts are not modified.") ); optionsSizer->Add( defaultsButton, 0, wxALL|wxEXPAND, 5 ); + m_staticTextTimeStamp = new wxStaticText( this, wxID_ANY, _("Timestamp"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextTimeStamp->Wrap( -1 ); + optionsSizer->Add( m_staticTextTimeStamp, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - upperSizer->Add( optionsSizer, 0, wxALIGN_TOP|wxALL|wxEXPAND, 5 ); + m_textCtrlTimeStamp = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); + m_textCtrlTimeStamp->SetToolTip( _("An unique ID (a time stamp) to identify the component.\nThis is an alternate identifier to the reference.") ); + + optionsSizer->Add( m_textCtrlTimeStamp, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + + + upperSizer->Add( optionsSizer, 0, wxALIGN_TOP|wxEXPAND|wxALL, 5 ); wxStaticBoxSizer* fieldsSizer; fieldsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Fields") ), wxHORIZONTAL ); @@ -265,7 +272,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( stdDialogButtonSizer->AddButton( stdDialogButtonSizerCancel ); stdDialogButtonSizer->Realize(); - mainSizer->Add( stdDialogButtonSizer, 0, wxALL|wxEXPAND, 8 ); + mainSizer->Add( stdDialogButtonSizer, 0, wxALL|wxEXPAND, 5 ); this->SetSizer( mainSizer ); diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp index b9eadc9576..ccd8b6d803 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp @@ -20,8 +20,10 @@ . 1 + 1 1 1 + UI 0 0 @@ -102,9 +104,9 @@ none 5 - wxALIGN_TOP|wxALL|wxEXPAND + wxALIGN_TOP|wxEXPAND|wxALL 0 - + wxID_ANY Component @@ -283,20 +285,20 @@ - - 0 - wxLEFT|wxRIGHT|wxTOP|wxEXPAND - 0 - + + 5 + wxEXPAND + 1 + - orientationSizer + bSizerUnitsInterchangeable wxHORIZONTAL none - 8 - wxALL|wxEXPAND - 1 - + 5 + wxEXPAND|wxTOP|wxBOTTOM|wxLEFT + 0 + 1 1 1 @@ -310,7 +312,6 @@ 1 0 - "0" "+90" "180" "-90" 1 1 @@ -325,8 +326,7 @@ 0 0 wxID_ANY - Orientation (Degrees) - 1 + Units are interchangeable: 0 @@ -334,7 +334,7 @@ 0 1 - orientationRadioBox + unitsInterchageableText 1 @@ -342,20 +342,99 @@ 1 Resizable - 0 1 - wxRA_SPECIFY_COLS + 0 - Select if the component is to be rotated when drawn - - wxFILTER_NONE - wxDefaultValidator - + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Yes + + 0 + + + 0 + + 1 + unitsInterchageableLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 @@ -373,7 +452,6 @@ - @@ -385,104 +463,183 @@ - 0 - wxLEFT|wxRIGHT|wxTOP|wxEXPAND + 5 + wxEXPAND|wxALL 0 - + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "0" "+90" "180" "-90" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Orientation (Degrees) + 1 + + 0 + + + 0 - mirrorSizer - wxHORIZONTAL - none - - 8 - wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Normal" "Mirror ---" "Mirror |" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Mirror - 1 - - 0 - - - 0 - - 1 - mirrorRadioBox - 1 - - - protected - 1 - - Resizable - 0 - 1 - - wxRA_SPECIFY_COLS - - 0 - Pick the graphical transformation to be used when displaying the component, if any - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 1 + orientationRadioBox + 1 + + + protected + 1 + + Resizable + 1 + 1 + + wxRA_SPECIFY_COLS + + 0 + Select if the component is to be rotated when drawn + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Normal" "Mirror ---" "Mirror |" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Mirror + 1 + + 0 + + + 0 + + 1 + mirrorRadioBox + 1 + + + protected + 1 + + Resizable + 0 + 1 + + wxRA_SPECIFY_COLS + + 0 + Pick the graphical transformation to be used when displaying the component, if any + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -660,7 +817,7 @@ - 8 + 5 wxALL 0 @@ -747,89 +904,6 @@ - - 8 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Parts are locked - - 0 - - - 0 - - 1 - partsAreLockedLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - 5 wxALL|wxEXPAND @@ -918,6 +992,180 @@ + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Timestamp + + 0 + + + 0 + + 1 + m_staticTextTimeStamp + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_textCtrlTimeStamp + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_READONLY + + 0 + An unique ID (a time stamp) to identify the component. This is an alternate identifier to the reference. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -944,11 +1192,11 @@ wxVERTICAL none - + 8 wxALL|wxEXPAND 1 - + 1 1 1 @@ -1049,11 +1297,11 @@ - + 5 wxEXPAND|wxTOP|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -1137,11 +1385,11 @@ - + 5 wxEXPAND|wxTOP|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -1225,11 +1473,11 @@ - + 5 wxALL|wxEXPAND 0 - + 1 1 1 @@ -1333,11 +1581,11 @@ bSizerJustification wxHORIZONTAL none - + 5 wxRIGHT|wxLEFT 1 - + 1 1 1 @@ -1423,11 +1671,11 @@ - + 5 wxRIGHT|wxLEFT 1 - + 1 1 1 @@ -1536,11 +1784,11 @@ wxVERTICAL none - + 5 wxALL 0 - + 1 1 1 @@ -1624,11 +1872,11 @@ - + 5 wxALL 0 - + 1 1 1 @@ -1714,11 +1962,11 @@ - + 5 wxEXPAND|wxALL 1 - + 1 1 1 @@ -1806,11 +2054,11 @@ - + 5 wxBOTTOM|wxEXPAND 0 - + fieldNameBoxSizer wxVERTICAL @@ -2072,11 +2320,11 @@ - + 5 wxEXPAND 0 - + 1 1 1 @@ -2163,11 +2411,11 @@ - + 5 wxBOTTOM|wxEXPAND 0 - + 1 1 1 @@ -2253,11 +2501,11 @@ - + 5 wxEXPAND|wxTOP 1 - + 3 wxBOTH 1 @@ -2443,11 +2691,11 @@ - + 5 wxALL|wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -2526,11 +2774,11 @@ - + 5 wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -2609,11 +2857,11 @@ - + 5 wxEXPAND|wxTOP|wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -2700,11 +2948,11 @@ - + 5 wxALL|wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -2783,11 +3031,11 @@ - + 5 wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -2866,11 +3114,11 @@ - + 5 wxEXPAND|wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -2957,11 +3205,11 @@ - + 5 wxALL|wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -3049,7 +3297,7 @@ - 8 + 5 wxALL|wxEXPAND 0 diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.h b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.h index 834031945e..92fb092691 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.h +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 30 2013) +// C++ code generated with wxFormBuilder (version Nov 6 2013) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -21,8 +21,8 @@ class DIALOG_SHIM; #include #include #include -#include #include +#include #include #include #include @@ -43,13 +43,16 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public DIALOG_SHIM protected: wxStaticText* m_staticTextUnit; wxChoice* unitChoice; + wxStaticText* unitsInterchageableText; + wxStaticText* unitsInterchageableLabel; wxRadioBox* orientationRadioBox; wxRadioBox* mirrorRadioBox; wxStaticText* m_staticTextChipname; wxTextCtrl* chipnameTextCtrl; wxCheckBox* convertCheckBox; - wxStaticText* partsAreLockedLabel; wxButton* defaultsButton; + wxStaticText* m_staticTextTimeStamp; + wxTextCtrl* m_textCtrlTimeStamp; wxListCtrl* fieldListCtrl; wxButton* addFieldButton; wxButton* deleteFieldButton; diff --git a/eeschema/dialogs/dialog_lib_new_component.cpp b/eeschema/dialogs/dialog_lib_new_component.cpp index 3ffb0e8569..76e22aaba3 100644 --- a/eeschema/dialogs/dialog_lib_new_component.cpp +++ b/eeschema/dialogs/dialog_lib_new_component.cpp @@ -3,7 +3,9 @@ DIALOG_LIB_NEW_COMPONENT::DIALOG_LIB_NEW_COMPONENT( wxWindow* parent ) : DIALOG_LIB_NEW_COMPONENT_BASE( parent ) { - /* Required to make escape key work correctly in wxGTK. */ - m_sdbSizerOK->SetFocus(); + // initial focus should be on first editable field. + m_textName->SetFocus(); + + // What happens when user presses "Enter"? OK button! OK? m_sdbSizerOK->SetDefault(); } diff --git a/eeschema/dialogs/dialog_lib_new_component.fbp b/eeschema/dialogs/dialog_lib_new_component.fbp index eabf24c837..611c679807 100644 --- a/eeschema/dialogs/dialog_lib_new_component.fbp +++ b/eeschema/dialogs/dialog_lib_new_component.fbp @@ -20,8 +20,10 @@ . 1 + 1 1 1 + UI 1 0 @@ -88,23 +90,23 @@ - mainSizer - wxHORIZONTAL + bSizer7 + wxVERTICAL none - 12 + 5 wxALL|wxEXPAND - 1 + 0 - bSizer5 + bSizer16 wxVERTICAL none - - 3 - wxALIGN_LEFT + + 5 + wxALL 0 - + 1 1 1 @@ -140,7 +142,7 @@ 0 1 - m_staticText6 + m_staticText8 1 @@ -183,30 +185,27 @@ - - 0 - wxALL|wxEXPAND - 0 - + + 20 + wxEXPAND|wxLEFT|wxRIGHT + 1 + + 2 + wxBOTH + 1 + + 0 - bSizer2 - wxHORIZONTAL + fgSizer31 + wxFLEX_GROWMODE_SPECIFIED none - - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - - + 0 + 0 + 3 wxALIGN_CENTER_VERTICAL|wxALL 0 - + 1 1 1 @@ -285,21 +284,11 @@ - + 3 - wxEXPAND + wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND 1 - - 0 - protected - 0 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - + 1 1 1 @@ -386,42 +375,11 @@ - - 3 - wxEXPAND + + 5 + wxALL 0 - - 0 - protected - 30 - - - - - - 0 - wxALL|wxEXPAND - 0 - - - bSizer3 - wxHORIZONTAL - none - - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - + 1 1 1 @@ -449,7 +407,7 @@ 0 0 wxID_ANY - Default &reference designator: + Default reference designator: 0 @@ -457,7 +415,7 @@ 0 1 - m_staticText3 + m_staticText9 1 @@ -470,7 +428,7 @@ 0 - This is the reference used in schematic for annotation. Do not use digits in reference. + @@ -500,21 +458,11 @@ - + 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL + wxALL|wxEXPAND 0 - + 1 1 1 @@ -545,7 +493,7 @@ 0 - 0 + 0 @@ -559,7 +507,7 @@ Resizable 1 - 100,-1 + 0 @@ -601,42 +549,11 @@ - + 5 - wxEXPAND + wxALL 0 - - 0 - protected - 30 - - - - - - 0 - wxALL|wxEXPAND - 0 - - - bSizer4 - wxHORIZONTAL - none - - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - + 1 1 1 @@ -664,7 +581,7 @@ 0 0 wxID_ANY - Number of units per &package: + Number of units per package: 0 @@ -672,7 +589,7 @@ 0 1 - m_staticText4 + m_staticText10 1 @@ -685,7 +602,7 @@ 0 - This is the number of parts in this component package. A 74LS00 gate has 4 parts per packages. + @@ -715,21 +632,11 @@ - - 3 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL + + 5 + wxALL 0 - + 1 1 1 @@ -776,7 +683,7 @@ Resizable 1 - 100,-1 + wxSP_ARROW_KEYS 0 @@ -812,42 +719,22 @@ - - 3 - wxEXPAND - 0 - - 0 - protected - 30 - - - - 0 - wxALL|wxEXPAND - 0 - + + 15 + wxEXPAND|wxLEFT|wxRIGHT + 1 + - bSizer7 - wxHORIZONTAL + bSizer17 + wxVERTICAL none - - 3 - wxEXPAND + + 5 + wxALL 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - + 1 1 1 @@ -876,7 +763,7 @@ 0 0 wxID_ANY - Create component with &alternate body style (DeMorgan) + Create component with alternate body style (DeMorgan) 0 @@ -897,7 +784,7 @@ 0 - Check this option for components that have a De Morgan representation. This is usual for gates. + wxFILTER_NONE wxDefaultValidator @@ -931,32 +818,11 @@ - - - - 0 - wxALL|wxEXPAND - 0 - - - bSizer8 - wxHORIZONTAL - none - - 3 - wxEXPAND + + 5 + wxALL 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - + 1 1 1 @@ -985,7 +851,7 @@ 0 0 wxID_ANY - Create component as power &symbol + Create component as power symbol 0 @@ -1006,7 +872,7 @@ 0 - Check this option for power symbols. Power symbols have specific properties for Eeschema: - Value cannot be edited (to avoid mistakes) because this is the pin name that is important for a power symbol - Reference is updated automatically when a netlist is created (no need to run Annotate) + wxFILTER_NONE wxDefaultValidator @@ -1040,32 +906,11 @@ - - - - 0 - wxALL|wxEXPAND - 0 - - - bSizer9 - wxHORIZONTAL - none - - 3 - wxEXPAND + + 5 + wxALL 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - + 1 1 1 @@ -1094,7 +939,7 @@ 0 0 wxID_ANY - Units are not &interchangeable + Units are not interchangeable 0 @@ -1115,7 +960,7 @@ 0 - Check this option if Eeschema cannot change parts selections inside a given package This happens when parts are different in this package. When this option is not checked, Eeschema automatically choose the parts in packages to minimize packages count + wxFILTER_NONE wxDefaultValidator @@ -1151,19 +996,30 @@ + + + + 5 + wxALL|wxEXPAND + 1 + + + bSizer18 + wxVERTICAL + none - 10 - wxALL|wxEXPAND + 5 + wxEXPAND 0 - 0 + 10 protected 0 - 3 - wxALIGN_LEFT|wxBOTTOM + 5 + wxALL 0 1 @@ -1193,7 +1049,7 @@ 0 0 wxID_ANY - Global Pin Settings + General Pin Settings 0 @@ -1201,7 +1057,7 @@ 0 1 - m_staticText7 + m_staticText11 1 @@ -1245,27 +1101,24 @@ - 0 - wxALL|wxEXPAND - 1 - + 20 + wxLEFT|wxRIGHT + 0 + + 2 + wxBOTH + + + 55 - bSizer6 - wxHORIZONTAL + fgSizer4 + wxFLEX_GROWMODE_SPECIFIED none + 0 + 0 - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL + 5 + wxALL 0 1 @@ -1295,7 +1148,7 @@ 0 0 wxID_ANY - Pin text position &offset: + Pin text position offset: 0 @@ -1303,7 +1156,7 @@ 0 1 - m_staticText41 + m_staticText12 1 @@ -1316,7 +1169,7 @@ 0 - Margin (in 0.001 inches) between a pin name position and the component body. A value from 10 to 40 is usually good. + @@ -1347,18 +1200,8 @@ - 3 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL + 5 + wxALL 0 1 @@ -1407,7 +1250,7 @@ Resizable 1 - 100,-1 + wxSP_ARROW_KEYS 0 @@ -1443,113 +1286,20 @@ - - 3 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - mils - - 0 - - - 0 - - 1 - m_staticText5 - 1 - - - protected - 1 - - Resizable - 1 - 30,-1 - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - wxALL|wxEXPAND + 15 + wxEXPAND|wxLEFT|wxRIGHT 0 - bSizer10 - wxHORIZONTAL + bSizer19 + wxVERTICAL none - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL + 5 + wxALL 0 1 @@ -1580,7 +1330,7 @@ 0 0 wxID_ANY - Show pin n&umber text + Show pin number text 0 @@ -1635,30 +1385,9 @@ - - - - 0 - wxALL|wxEXPAND - 0 - - - bSizer12 - wxHORIZONTAL - none - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL + 5 + wxALL 0 1 @@ -1689,7 +1418,7 @@ 0 0 wxID_ANY - Show pin name te&xt + Show pin name text 0 @@ -1744,30 +1473,9 @@ - - - - 5 - wxEXPAND - 1 - - - bSizer121 - wxHORIZONTAL - none - 3 - wxEXPAND - 0 - - 0 - protected - 12 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL + 5 + wxALL 0 1 @@ -1798,7 +1506,7 @@ 0 0 wxID_ANY - Pin name &inside + Pin name inside 0 @@ -1855,42 +1563,32 @@ - - 10 - wxALL|wxEXPAND - 0 - - 5 - protected - 0 - - - - 0 - wxALL|wxEXPAND - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizer - protected - - - - - - - - - - + + + + 10 + wxALL|wxEXPAND + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer + protected + + + + + + + + diff --git a/eeschema/dialogs/dialog_lib_new_component_base.cpp b/eeschema/dialogs/dialog_lib_new_component_base.cpp index 744f72fa5f..0bc9fe1253 100644 --- a/eeschema/dialogs/dialog_lib_new_component_base.cpp +++ b/eeschema/dialogs/dialog_lib_new_component_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 8 2012) +// C++ code generated with wxFormBuilder (version Nov 5 2013) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -13,209 +13,116 @@ DIALOG_LIB_NEW_COMPONENT_BASE::DIALOG_LIB_NEW_COMPONENT_BASE( wxWindow* parent, { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - wxBoxSizer* mainSizer; - mainSizer = new wxBoxSizer( wxHORIZONTAL ); + wxBoxSizer* bSizer7; + bSizer7 = new wxBoxSizer( wxVERTICAL ); - wxBoxSizer* bSizer5; - bSizer5 = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bSizer16; + bSizer16 = new wxBoxSizer( wxVERTICAL ); - m_staticText6 = new wxStaticText( this, wxID_ANY, _("General Settings"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText6->Wrap( -1 ); - m_staticText6->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); + m_staticText8 = new wxStaticText( this, wxID_ANY, _("General Settings"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText8->Wrap( -1 ); + m_staticText8->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); - bSizer5->Add( m_staticText6, 0, wxALIGN_LEFT, 3 ); + bSizer16->Add( m_staticText8, 0, wxALL, 5 ); - wxBoxSizer* bSizer2; - bSizer2 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer2->Add( 12, 0, 0, wxEXPAND, 3 ); + wxFlexGridSizer* fgSizer31; + fgSizer31 = new wxFlexGridSizer( 0, 2, 0, 0 ); + fgSizer31->AddGrowableCol( 1 ); + fgSizer31->SetFlexibleDirection( wxBOTH ); + fgSizer31->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); m_staticText2 = new wxStaticText( this, wxID_ANY, _("Component &name:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText2->Wrap( -1 ); m_staticText2->SetToolTip( _("This is the component name in library,\nand also the default component value when loaded in the schematic.") ); - bSizer2->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - - bSizer2->Add( 0, 0, 1, wxEXPAND, 3 ); + fgSizer31->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_textName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 100,-1 ), 0 ); m_textName->SetMaxLength( 0 ); - bSizer2->Add( m_textName, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + fgSizer31->Add( m_textName, 1, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 ); + m_staticText9 = new wxStaticText( this, wxID_ANY, _("Default reference designator:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText9->Wrap( -1 ); + fgSizer31->Add( m_staticText9, 0, wxALL, 5 ); - bSizer2->Add( 30, 0, 0, wxEXPAND, 3 ); + m_textReference = new wxTextCtrl( this, wxID_ANY, _("U"), wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer31->Add( m_textReference, 0, wxALL|wxEXPAND, 5 ); + m_staticText10 = new wxStaticText( this, wxID_ANY, _("Number of units per package:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText10->Wrap( -1 ); + fgSizer31->Add( m_staticText10, 0, wxALL, 5 ); - bSizer5->Add( bSizer2, 0, wxALL|wxEXPAND, 0 ); + m_spinPartCount = new wxSpinCtrl( this, wxID_ANY, wxT("1"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 26, 0 ); + fgSizer31->Add( m_spinPartCount, 0, wxALL, 5 ); - wxBoxSizer* bSizer3; - bSizer3 = new wxBoxSizer( wxHORIZONTAL ); + bSizer16->Add( fgSizer31, 1, wxEXPAND|wxLEFT|wxRIGHT, 20 ); - bSizer3->Add( 12, 0, 0, wxEXPAND, 3 ); + wxBoxSizer* bSizer17; + bSizer17 = new wxBoxSizer( wxVERTICAL ); - m_staticText3 = new wxStaticText( this, wxID_ANY, _("Default &reference designator:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText3->Wrap( -1 ); - m_staticText3->SetToolTip( _("This is the reference used in schematic for annotation.\nDo not use digits in reference.") ); + m_checkHasConversion = new wxCheckBox( this, wxID_ANY, _("Create component with alternate body style (DeMorgan)"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer17->Add( m_checkHasConversion, 0, wxALL, 5 ); - bSizer3->Add( m_staticText3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + m_checkIsPowerSymbol = new wxCheckBox( this, wxID_ANY, _("Create component as power symbol"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer17->Add( m_checkIsPowerSymbol, 0, wxALL, 5 ); + m_checkLockItems = new wxCheckBox( this, wxID_ANY, _("Units are not interchangeable"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer17->Add( m_checkLockItems, 0, wxALL, 5 ); - bSizer3->Add( 0, 0, 1, wxEXPAND, 5 ); - m_textReference = new wxTextCtrl( this, wxID_ANY, _("U"), wxDefaultPosition, wxSize( 100,-1 ), 0 ); - m_textReference->SetMaxLength( 0 ); - bSizer3->Add( m_textReference, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + bSizer16->Add( bSizer17, 1, wxEXPAND|wxLEFT|wxRIGHT, 15 ); - bSizer3->Add( 30, 0, 0, wxEXPAND, 5 ); + bSizer7->Add( bSizer16, 0, wxALL|wxEXPAND, 5 ); + wxBoxSizer* bSizer18; + bSizer18 = new wxBoxSizer( wxVERTICAL ); - bSizer5->Add( bSizer3, 0, wxALL|wxEXPAND, 0 ); - wxBoxSizer* bSizer4; - bSizer4 = new wxBoxSizer( wxHORIZONTAL ); + bSizer18->Add( 0, 10, 0, wxEXPAND, 5 ); + m_staticText11 = new wxStaticText( this, wxID_ANY, _("General Pin Settings"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText11->Wrap( -1 ); + m_staticText11->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); - bSizer4->Add( 12, 0, 0, wxEXPAND, 3 ); + bSizer18->Add( m_staticText11, 0, wxALL, 5 ); - m_staticText4 = new wxStaticText( this, wxID_ANY, _("Number of units per &package:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText4->Wrap( -1 ); - m_staticText4->SetToolTip( _("This is the number of parts in this component package.\nA 74LS00 gate has 4 parts per packages.") ); + wxFlexGridSizer* fgSizer4; + fgSizer4 = new wxFlexGridSizer( 0, 2, 0, 55 ); + fgSizer4->SetFlexibleDirection( wxBOTH ); + fgSizer4->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - bSizer4->Add( m_staticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + m_staticText12 = new wxStaticText( this, wxID_ANY, _("Pin text position offset:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText12->Wrap( -1 ); + fgSizer4->Add( m_staticText12, 0, wxALL, 5 ); + m_spinPinTextPosition = new wxSpinCtrl( this, wxID_ANY, wxT("40"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 100, 40 ); + fgSizer4->Add( m_spinPinTextPosition, 0, wxALL, 5 ); - bSizer4->Add( 0, 0, 1, wxEXPAND, 3 ); - m_spinPartCount = new wxSpinCtrl( this, wxID_ANY, wxT("1"), wxDefaultPosition, wxSize( 100,-1 ), wxSP_ARROW_KEYS, 1, 26, 0 ); - bSizer4->Add( m_spinPartCount, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + bSizer18->Add( fgSizer4, 0, wxLEFT|wxRIGHT, 20 ); + wxBoxSizer* bSizer19; + bSizer19 = new wxBoxSizer( wxVERTICAL ); - bSizer4->Add( 30, 0, 0, wxEXPAND, 3 ); - - - bSizer5->Add( bSizer4, 0, wxALL|wxEXPAND, 0 ); - - wxBoxSizer* bSizer7; - bSizer7 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer7->Add( 12, 0, 0, wxEXPAND, 3 ); - - m_checkHasConversion = new wxCheckBox( this, wxID_ANY, _("Create component with &alternate body style (DeMorgan)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_checkHasConversion->SetToolTip( _("Check this option for components that have a De Morgan representation.\nThis is usual for gates.") ); - - bSizer7->Add( m_checkHasConversion, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - - bSizer5->Add( bSizer7, 0, wxALL|wxEXPAND, 0 ); - - wxBoxSizer* bSizer8; - bSizer8 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer8->Add( 12, 0, 0, wxEXPAND, 3 ); - - m_checkIsPowerSymbol = new wxCheckBox( this, wxID_ANY, _("Create component as power &symbol"), wxDefaultPosition, wxDefaultSize, 0 ); - m_checkIsPowerSymbol->SetToolTip( _("Check this option for power symbols.\nPower symbols have specific properties for Eeschema:\n- Value cannot be edited (to avoid mistakes) because this is the pin name that is important for a power symbol\n- Reference is updated automatically when a netlist is created (no need to run Annotate)") ); - - bSizer8->Add( m_checkIsPowerSymbol, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - - bSizer5->Add( bSizer8, 0, wxALL|wxEXPAND, 0 ); - - wxBoxSizer* bSizer9; - bSizer9 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer9->Add( 12, 0, 0, wxEXPAND, 3 ); - - m_checkLockItems = new wxCheckBox( this, wxID_ANY, _("Units are not &interchangeable"), wxDefaultPosition, wxDefaultSize, 0 ); - m_checkLockItems->SetToolTip( _("Check this option if Eeschema cannot change parts selections inside a given package\nThis happens when parts are different in this package.\nWhen this option is not checked, Eeschema automatically choose the parts in packages to minimize packages count") ); - - bSizer9->Add( m_checkLockItems, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - - bSizer5->Add( bSizer9, 0, wxALL|wxEXPAND, 0 ); - - - bSizer5->Add( 0, 0, 0, wxALL|wxEXPAND, 10 ); - - m_staticText7 = new wxStaticText( this, wxID_ANY, _("Global Pin Settings"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText7->Wrap( -1 ); - m_staticText7->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); - - bSizer5->Add( m_staticText7, 0, wxALIGN_LEFT|wxBOTTOM, 3 ); - - wxBoxSizer* bSizer6; - bSizer6 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer6->Add( 12, 0, 0, wxEXPAND, 3 ); - - m_staticText41 = new wxStaticText( this, wxID_ANY, _("Pin text position &offset:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText41->Wrap( -1 ); - m_staticText41->SetToolTip( _("Margin (in 0.001 inches) between a pin name position and the component body.\nA value from 10 to 40 is usually good.") ); - - bSizer6->Add( m_staticText41, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - - bSizer6->Add( 0, 0, 1, wxEXPAND, 3 ); - - m_spinPinTextPosition = new wxSpinCtrl( this, wxID_ANY, wxT("40"), wxDefaultPosition, wxSize( 100,-1 ), wxSP_ARROW_KEYS, 1, 100, 40 ); - bSizer6->Add( m_spinPinTextPosition, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - - m_staticText5 = new wxStaticText( this, wxID_ANY, _("mils"), wxDefaultPosition, wxSize( 30,-1 ), 0 ); - m_staticText5->Wrap( -1 ); - bSizer6->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL, 3 ); - - - bSizer5->Add( bSizer6, 1, wxALL|wxEXPAND, 0 ); - - wxBoxSizer* bSizer10; - bSizer10 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer10->Add( 12, 0, 0, wxEXPAND, 3 ); - - m_checkShowPinNumber = new wxCheckBox( this, wxID_ANY, _("Show pin n&umber text"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkShowPinNumber = new wxCheckBox( this, wxID_ANY, _("Show pin number text"), wxDefaultPosition, wxDefaultSize, 0 ); m_checkShowPinNumber->SetValue(true); - bSizer10->Add( m_checkShowPinNumber, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + bSizer19->Add( m_checkShowPinNumber, 0, wxALL, 5 ); - - bSizer5->Add( bSizer10, 0, wxALL|wxEXPAND, 0 ); - - wxBoxSizer* bSizer12; - bSizer12 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer12->Add( 12, 0, 0, wxEXPAND, 3 ); - - m_checkShowPinName = new wxCheckBox( this, wxID_ANY, _("Show pin name te&xt"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkShowPinName = new wxCheckBox( this, wxID_ANY, _("Show pin name text"), wxDefaultPosition, wxDefaultSize, 0 ); m_checkShowPinName->SetValue(true); - bSizer12->Add( m_checkShowPinName, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + bSizer19->Add( m_checkShowPinName, 0, wxALL, 5 ); - - bSizer5->Add( bSizer12, 0, wxALL|wxEXPAND, 0 ); - - wxBoxSizer* bSizer121; - bSizer121 = new wxBoxSizer( wxHORIZONTAL ); - - - bSizer121->Add( 12, 0, 0, wxEXPAND, 3 ); - - m_checkShowPinNameInside = new wxCheckBox( this, wxID_ANY, _("Pin name &inside"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkShowPinNameInside = new wxCheckBox( this, wxID_ANY, _("Pin name inside"), wxDefaultPosition, wxDefaultSize, 0 ); m_checkShowPinNameInside->SetValue(true); - bSizer121->Add( m_checkShowPinNameInside, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + bSizer19->Add( m_checkShowPinNameInside, 0, wxALL, 5 ); - bSizer5->Add( bSizer121, 1, wxEXPAND, 5 ); + bSizer18->Add( bSizer19, 0, wxEXPAND|wxLEFT|wxRIGHT, 15 ); - bSizer5->Add( 0, 5, 0, wxALL|wxEXPAND, 10 ); + bSizer7->Add( bSizer18, 1, wxALL|wxEXPAND, 5 ); m_sdbSizer = new wxStdDialogButtonSizer(); m_sdbSizerOK = new wxButton( this, wxID_OK ); @@ -224,15 +131,12 @@ DIALOG_LIB_NEW_COMPONENT_BASE::DIALOG_LIB_NEW_COMPONENT_BASE( wxWindow* parent, m_sdbSizer->AddButton( m_sdbSizerCancel ); m_sdbSizer->Realize(); - bSizer5->Add( m_sdbSizer, 0, wxALL|wxEXPAND, 0 ); + bSizer7->Add( m_sdbSizer, 0, wxALL|wxEXPAND, 10 ); - mainSizer->Add( bSizer5, 1, wxALL|wxEXPAND, 12 ); - - - this->SetSizer( mainSizer ); + this->SetSizer( bSizer7 ); this->Layout(); - mainSizer->Fit( this ); + bSizer7->Fit( this ); this->Centre( wxBOTH ); } diff --git a/eeschema/dialogs/dialog_lib_new_component_base.h b/eeschema/dialogs/dialog_lib_new_component_base.h index 0d07e105e1..e48977dcfe 100644 --- a/eeschema/dialogs/dialog_lib_new_component_base.h +++ b/eeschema/dialogs/dialog_lib_new_component_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 8 2012) +// C++ code generated with wxFormBuilder (version Nov 5 2013) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -21,8 +21,8 @@ class DIALOG_SHIM; #include #include #include -#include #include +#include #include #include #include @@ -37,20 +37,19 @@ class DIALOG_LIB_NEW_COMPONENT_BASE : public DIALOG_SHIM private: protected: - wxStaticText* m_staticText6; + wxStaticText* m_staticText8; wxStaticText* m_staticText2; wxTextCtrl* m_textName; - wxStaticText* m_staticText3; + wxStaticText* m_staticText9; wxTextCtrl* m_textReference; - wxStaticText* m_staticText4; + wxStaticText* m_staticText10; wxSpinCtrl* m_spinPartCount; wxCheckBox* m_checkHasConversion; wxCheckBox* m_checkIsPowerSymbol; wxCheckBox* m_checkLockItems; - wxStaticText* m_staticText7; - wxStaticText* m_staticText41; + wxStaticText* m_staticText11; + wxStaticText* m_staticText12; wxSpinCtrl* m_spinPinTextPosition; - wxStaticText* m_staticText5; wxCheckBox* m_checkShowPinNumber; wxCheckBox* m_checkShowPinName; wxCheckBox* m_checkShowPinNameInside; diff --git a/eeschema/dialogs/dialog_sch_sheet_props.fbp b/eeschema/dialogs/dialog_sch_sheet_props.fbp index e58d771c39..a2f5db4cc0 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props.fbp +++ b/eeschema/dialogs/dialog_sch_sheet_props.fbp @@ -20,8 +20,10 @@ . 1 + 1 1 1 + UI 1 0 @@ -42,7 +44,7 @@ DIALOG_SCH_SHEET_PROPS_BASE - 453,170 + 519,198 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Schematic Sheet Properties @@ -92,901 +94,1288 @@ wxVERTICAL none - 12 - wxALL|wxEXPAND - 1 - - 6 - wxBOTH - 1 - - 0 + 5 + wxEXPAND + 0 + - fgSizer1 - wxFLEX_GROWMODE_SPECIFIED + bupperSizer + wxVERTICAL none - 2 - 0 - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - &File name: - - 0 - - - 0 - - 1 - m_staticText1 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 3 - wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM - 5 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - 200,-1 - 1 - m_textFileName - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3 - wxALIGN_CENTER_HORIZONTAL|wxALL + 12 + wxALL|wxEXPAND 1 - - 0 - protected - 0 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Si&ze: - - 0 - - - 0 + + 6 + wxBOTH + 1 + + 0 - 1 - m_staticText2 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 3 - wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_textFileNameSize - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - units - - 0 - - - 0 - - 1 - m_staticFileNameSizeUnits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - &Sheet name: - - 0 - - - 0 - - 1 - m_staticText4 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 3 - wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM - 5 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_textSheetName - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 1 - - 0 - protected - 0 - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - &Size: - - 0 - - - 0 - - 1 - m_staticText5 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 3 - wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_textSheetNameSize - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - units - - 0 - - - 0 - - 1 - m_staticSheetNameSizeUnits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - + fgSizer1 + wxFLEX_GROWMODE_SPECIFIED + none + 0 + 0 + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + &File name: + + 0 + + + 0 + + 1 + m_staticText1 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM + 5 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + 200,-1 + 1 + m_textFileName + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_HORIZONTAL|wxALL + 1 + + 0 + protected + 0 + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Si&ze: + + 0 + + + 0 + + 1 + m_staticText2 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_textFileNameSize + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + units + + 0 + + + 0 + + 1 + m_staticFileNameSizeUnits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + &Sheet name: + + 0 + + + 0 + + 1 + m_staticText4 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM + 5 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_textSheetName + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 1 + + 0 + protected + 0 + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + &Size: + + 0 + + + 0 + + 1 + m_staticText5 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_textSheetNameSize + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + units + + 0 + + + 0 + + 1 + m_staticSheetNameSizeUnits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline2 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND | wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline3 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Unique timestamp: + + 0 + + + 0 + + 1 + m_staticTextTimeStamp + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_textCtrlTimeStamp + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_READONLY + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eeschema/dialogs/dialog_sch_sheet_props.h b/eeschema/dialogs/dialog_sch_sheet_props.h index edaa75f066..615020cf0c 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props.h +++ b/eeschema/dialogs/dialog_sch_sheet_props.h @@ -45,6 +45,12 @@ public: { m_staticSheetNameSizeUnits->SetLabel( aUnits ); } + + void SetSheetTimeStamp(const wxString& aTimeStamp) + { + m_textCtrlTimeStamp->SetValue( aTimeStamp ); + } + }; #endif // __dialog_sch_sheet_props__ diff --git a/eeschema/dialogs/dialog_sch_sheet_props_base.cpp b/eeschema/dialogs/dialog_sch_sheet_props_base.cpp index 4c6416c54d..f8096707ee 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props_base.cpp +++ b/eeschema/dialogs/dialog_sch_sheet_props_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 10 2012) +// C++ code generated with wxFormBuilder (version Nov 6 2013) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -16,8 +16,11 @@ DIALOG_SCH_SHEET_PROPS_BASE::DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWi wxBoxSizer* mainSizer; mainSizer = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bupperSizer; + bupperSizer = new wxBoxSizer( wxVERTICAL ); + wxFlexGridSizer* fgSizer1; - fgSizer1 = new wxFlexGridSizer( 2, 6, 0, 0 ); + fgSizer1 = new wxFlexGridSizer( 0, 6, 0, 0 ); fgSizer1->AddGrowableCol( 1 ); fgSizer1->SetFlexibleDirection( wxBOTH ); fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); @@ -27,6 +30,7 @@ DIALOG_SCH_SHEET_PROPS_BASE::DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWi fgSizer1->Add( m_staticText1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_textFileName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_textFileName->SetMaxLength( 0 ); m_textFileName->SetMinSize( wxSize( 200,-1 ) ); fgSizer1->Add( m_textFileName, 5, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM, 3 ); @@ -39,6 +43,7 @@ DIALOG_SCH_SHEET_PROPS_BASE::DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWi fgSizer1->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_textFileNameSize = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_textFileNameSize->SetMaxLength( 0 ); fgSizer1->Add( m_textFileNameSize, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 3 ); m_staticFileNameSizeUnits = new wxStaticText( this, wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -50,6 +55,7 @@ DIALOG_SCH_SHEET_PROPS_BASE::DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWi fgSizer1->Add( m_staticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_textSheetName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_textSheetName->SetMaxLength( 0 ); fgSizer1->Add( m_textSheetName, 5, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM, 3 ); @@ -60,14 +66,43 @@ DIALOG_SCH_SHEET_PROPS_BASE::DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWi fgSizer1->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_textSheetNameSize = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_textSheetNameSize->SetMaxLength( 0 ); fgSizer1->Add( m_textSheetNameSize, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 3 ); m_staticSheetNameSizeUnits = new wxStaticText( this, wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticSheetNameSizeUnits->Wrap( -1 ); fgSizer1->Add( m_staticSheetNameSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); + m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + fgSizer1->Add( m_staticline2, 0, wxEXPAND|wxALL, 5 ); - mainSizer->Add( fgSizer1, 1, wxALL|wxEXPAND, 12 ); + m_staticline3 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + fgSizer1->Add( m_staticline3, 0, wxEXPAND | wxALL, 5 ); + + + fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); + + + fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); + + + fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); + + + fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_staticTextTimeStamp = new wxStaticText( this, wxID_ANY, _("Unique timestamp:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextTimeStamp->Wrap( -1 ); + fgSizer1->Add( m_staticTextTimeStamp, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_textCtrlTimeStamp = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); + fgSizer1->Add( m_textCtrlTimeStamp, 0, wxEXPAND|wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 ); + + + bupperSizer->Add( fgSizer1, 1, wxALL|wxEXPAND, 12 ); + + + mainSizer->Add( bupperSizer, 0, wxEXPAND, 5 ); mainSizer->Add( 0, 0, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); diff --git a/eeschema/dialogs/dialog_sch_sheet_props_base.h b/eeschema/dialogs/dialog_sch_sheet_props_base.h index 2b239505f7..2260e9fc77 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props_base.h +++ b/eeschema/dialogs/dialog_sch_sheet_props_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 10 2012) +// C++ code generated with wxFormBuilder (version Nov 6 2013) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -11,6 +11,8 @@ #include #include #include +class DIALOG_SHIM; + #include "dialog_shim.h" #include #include @@ -19,8 +21,8 @@ #include #include #include -#include #include +#include #include #include @@ -44,6 +46,10 @@ class DIALOG_SCH_SHEET_PROPS_BASE : public DIALOG_SHIM wxStaticText* m_staticText5; wxTextCtrl* m_textSheetNameSize; wxStaticText* m_staticSheetNameSizeUnits; + wxStaticLine* m_staticline2; + wxStaticLine* m_staticline3; + wxStaticText* m_staticTextTimeStamp; + wxTextCtrl* m_textCtrlTimeStamp; wxStaticLine* m_staticline1; wxStdDialogButtonSizer* m_sdbSizer1; wxButton* m_sdbSizer1OK; @@ -51,7 +57,7 @@ class DIALOG_SCH_SHEET_PROPS_BASE : public DIALOG_SHIM public: - DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Schematic Sheet Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 453,170 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Schematic Sheet Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 519,198 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_SCH_SHEET_PROPS_BASE(); }; diff --git a/eeschema/hierarch.cpp b/eeschema/hierarch.cpp index ff00871935..6ff3cba4f8 100644 --- a/eeschema/hierarch.cpp +++ b/eeschema/hierarch.cpp @@ -169,7 +169,7 @@ HIERARCHY_NAVIG_DLG::HIERARCHY_NAVIG_DLG( SCH_EDIT_FRAME* parent, wxDC* DC, cons // Set dialog window size to be large enough m_TreeSize.x = itemrect.GetWidth() + 20; - m_TreeSize.x = max( m_TreeSize.x, 250 ); + m_TreeSize.x = std::max( m_TreeSize.x, 250 ); // Readjust the size of the frame to an optimal value. m_TreeSize.y = m_nbsheets * itemrect.GetHeight(); diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index 8a92a95908..6f14824083 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -246,7 +246,7 @@ bool SCH_BUS_ENTRY_BASE::IsSelectStateChanged( const wxRect& aRect ) } -void SCH_BUS_ENTRY_BASE::GetConnectionPoints( vector< wxPoint >& aPoints ) const +void SCH_BUS_ENTRY_BASE::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const { aPoints.push_back( m_pos ); aPoints.push_back( m_End() ); diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h index 771469830e..1b0a8ab0de 100644 --- a/eeschema/sch_bus_entry.h +++ b/eeschema/sch_bus_entry.h @@ -96,7 +96,7 @@ public: bool IsConnectable() const { return true; } - void GetConnectionPoints( vector< wxPoint >& aPoints ) const; + void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const; BITMAP_DEF GetMenuImage() const { return add_entry_xpm; } diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 3b0bdd7d6a..d83c892591 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -1605,7 +1605,7 @@ bool SCH_COMPONENT::IsSelectStateChanged( const wxRect& aRect ) } -void SCH_COMPONENT::GetConnectionPoints( vector< wxPoint >& aPoints ) const +void SCH_COMPONENT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const { LIB_PIN* pin; LIB_COMPONENT* component = CMP_LIBRARY::FindLibraryComponent( m_ChipName ); @@ -1876,7 +1876,7 @@ bool SCH_COMPONENT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccura bool SCH_COMPONENT::doIsConnected( const wxPoint& aPosition ) const { - vector< wxPoint > pts; + std::vector< wxPoint > pts; GetConnectionPoints( pts ); diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index d145f78404..aac7dac913 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -357,7 +357,7 @@ public: bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ); - void GetEndPoints( std::vector & aItemList ); + void GetEndPoints( std::vector& aItemList ); wxPoint GetPinPhysicalPosition( LIB_PIN* Pin ); @@ -372,7 +372,7 @@ public: */ bool IsInNetlist() const; - void GetConnectionPoints( vector< wxPoint >& aPoints ) const; + void GetConnectionPoints( std::vector& aPoints ) const; SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData, const KICAD_T scanTypes[] ); diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index cc26dc5f3a..44e6a03d83 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -168,7 +168,7 @@ bool SCH_JUNCTION::IsSelectStateChanged( const wxRect& aRect ) } -void SCH_JUNCTION::GetConnectionPoints( vector< wxPoint >& aPoints ) const +void SCH_JUNCTION::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const { aPoints.push_back( m_pos ); } diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h index 1e8d90fc29..0e93d846b2 100644 --- a/eeschema/sch_junction.h +++ b/eeschema/sch_junction.h @@ -81,7 +81,7 @@ public: bool IsConnectable() const { return true; } - void GetConnectionPoints( vector< wxPoint >& aPoints ) const; + void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const; wxString GetSelectMenuText() const { return wxString( _( "Junction" ) ); } diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 20929a8c61..96e36ebc59 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -461,7 +461,7 @@ bool SCH_LINE::IsConnectable() const } -void SCH_LINE::GetConnectionPoints( vector< wxPoint >& aPoints ) const +void SCH_LINE::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const { aPoints.push_back( m_start ); aPoints.push_back( m_end ); diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index 08f983db2f..87a3972a8d 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -113,9 +113,9 @@ public: */ bool MergeOverlap( SCH_LINE* aLine ); - void GetEndPoints( vector & aItemList ); + void GetEndPoints( std::vector& aItemList ); - bool IsDanglingStateChanged( vector< DANGLING_END_ITEM >& aItemList ); + bool IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList ); bool IsDangling() const { return m_startIsDangling || m_endIsDangling; } @@ -123,7 +123,7 @@ public: bool IsConnectable() const; - void GetConnectionPoints( vector< wxPoint >& aPoints ) const; + void GetConnectionPoints(std::vector< wxPoint >& aPoints ) const; wxString GetSelectMenuText() const; diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp index ecda593c83..b92ebe5003 100644 --- a/eeschema/sch_no_connect.cpp +++ b/eeschema/sch_no_connect.cpp @@ -182,7 +182,7 @@ bool SCH_NO_CONNECT::IsSelectStateChanged( const wxRect& aRect ) } -void SCH_NO_CONNECT::GetConnectionPoints( vector< wxPoint >& aPoints ) const +void SCH_NO_CONNECT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const { aPoints.push_back( m_pos ); } diff --git a/eeschema/sch_no_connect.h b/eeschema/sch_no_connect.h index acd9ec4aa9..65ecd423bc 100644 --- a/eeschema/sch_no_connect.h +++ b/eeschema/sch_no_connect.h @@ -81,7 +81,7 @@ public: bool IsConnectable() const { return true; } - void GetConnectionPoints( vector< wxPoint >& aPoints ) const; + void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const; wxString GetSelectMenuText() const { return wxString( _( "No Connect" ) ); } diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 4cc05e83d6..dd54465b99 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -1000,7 +1000,7 @@ bool SCH_SHEET::IsSelectStateChanged( const wxRect& aRect ) } -void SCH_SHEET::GetConnectionPoints( vector< wxPoint >& aPoints ) const +void SCH_SHEET::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const { for( size_t i = 0; i < GetPins().size(); i++ ) aPoints.push_back( GetPins()[i].GetPosition() ); diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 8eb016963c..a663c11e28 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -533,7 +533,7 @@ public: bool IsConnectable() const { return true; } - void GetConnectionPoints( vector< wxPoint >& aPoints ) const; + void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const; SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData, const KICAD_T scanTypes[] ); diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index e6e3bbf915..90f932cf2d 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -564,7 +564,7 @@ bool SCH_TEXT::IsSelectStateChanged( const wxRect& aRect ) } -void SCH_TEXT::GetConnectionPoints( vector< wxPoint >& aPoints ) const +void SCH_TEXT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const { // Normal text labels do not have connection points. All others do. if( Type() == SCH_TEXT_T ) diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index 12efd1a967..a2384ace36 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -189,7 +189,7 @@ public: virtual bool IsSelectStateChanged( const wxRect& aRect ); - virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const; + virtual void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const; virtual bool CanIncrementLabel() const { return true; } diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 4b907f2693..ab9730b3ea 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -27,13 +27,13 @@ */ #include -#include +//#include #include #include #include #include -#include +//#include #include #include @@ -55,6 +55,8 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC ) dlg.SetSheetName( aSheet->GetName() ); dlg.SetSheetNameTextSize( ReturnStringFromValue( g_UserUnit, aSheet->GetSheetNameSize() ) ); dlg.SetSheetNameTextSizeUnits( units ); + dlg.SetSheetTimeStamp( wxString::Format( wxT("%8.8lX"), + (unsigned long) aSheet->GetTimeStamp() ) ); /* This ugly hack fixes a bug in wxWidgets 2.8.7 and likely earlier * versions for the flex grid sizer in wxGTK that prevents the last diff --git a/include/class_drawpanel_gal.h b/include/class_drawpanel_gal.h index 4d9acac711..b7f92c2209 100644 --- a/include/class_drawpanel_gal.h +++ b/include/class_drawpanel_gal.h @@ -111,6 +111,12 @@ public: m_eventDispatcher = aEventDispatcher; } + /** + * Function StopDrawing() + * Prevents the GAL canvas from further drawing till it is recreated. + */ + void StopDrawing(); + protected: void onPaint( wxPaintEvent& WXUNUSED( aEvent ) ); void onSize( wxSizeEvent& aEvent ); diff --git a/include/footprint_info.h b/include/footprint_info.h index 3ba4392e2b..54a7c1af7c 100644 --- a/include/footprint_info.h +++ b/include/footprint_info.h @@ -33,10 +33,16 @@ #include #include +#include #include +#define USE_FPI_LAZY 0 // 1:yes lazy, 0:no early + + class FP_LIB_TABLE; +class FOOTPRINT_LIST; +class wxTopLevelWindow; /* @@ -46,38 +52,52 @@ class FP_LIB_TABLE; */ class FOOTPRINT_INFO { + friend bool operator<( const FOOTPRINT_INFO& item1, const FOOTPRINT_INFO& item2 ); + public: - // friend bool operator<( const FOOTPRINT_INFO& item1, const FOOTPRINT_INFO& item2 ); + // These two accessors do not have to call ensure_loaded(), because constructor + // fills in these fields: - wxString m_nickname; ///< the library nickname, eventually - -#if !defined(USE_FP_LIB_TABLE) - wxString m_lib_path; -#endif - - - wxString m_Module; ///< Module name. - int m_Num; ///< Order number in the display list. - wxString m_Doc; ///< Footprint description. - wxString m_KeyWord; ///< Footprint key words. - unsigned m_padCount; ///< Number of pads - - FOOTPRINT_INFO() - { - m_Num = 0; - m_padCount = 0; - } - - const wxString& GetFootprintName() const { return m_Module; } - - void SetNickname( const wxString& aLibNickname ) { m_nickname = aLibNickname; } + const wxString& GetFootprintName() const { return m_fpname; } const wxString& GetNickname() const { return m_nickname; } -#if !defined(USE_FP_LIB_TABLE) - void SetLibPath( const wxString& aLibPath ) { m_lib_path = aLibPath; } - const wxString& GetLibPath() const { return m_lib_path; } + FOOTPRINT_INFO( FOOTPRINT_LIST* aOwner, const wxString& aNickname, const wxString& aFootprintName ) : + m_owner( aOwner ), + m_loaded( false ), + m_nickname( aNickname ), + m_fpname( aFootprintName ), + m_num( 0 ), + m_pad_count( 0 ) + { +#if !USE_FPI_LAZY + load(); #endif + } + + const wxString& GetDoc() + { + ensure_loaded(); + return m_doc; + } + + const wxString& GetKeywords() + { + ensure_loaded(); + return m_keywords; + } + + unsigned GetPadCount() + { + ensure_loaded(); + return m_pad_count; + } + + int GetOrderNum() + { + ensure_loaded(); + return m_num; + } /** * Function InLibrary @@ -89,81 +109,140 @@ public: * false. */ bool InLibrary( const wxString& aLibrary ) const; + +private: + + void ensure_loaded() + { + if( !m_loaded ) + load(); + } + + /// lazily load stuff not filled in by constructor. This may throw IO_ERRORS. + void load(); + + FOOTPRINT_LIST* m_owner; ///< provides access to FP_LIB_TABLE + + bool m_loaded; + + wxString m_nickname; ///< library as known in FP_LIB_TABLE + wxString m_fpname; ///< Module name. + int m_num; ///< Order number in the display list. + int m_pad_count; ///< Number of pads + wxString m_doc; ///< Footprint description. + wxString m_keywords; ///< Footprint keywords. }; /// FOOTPRINT object list sort function. inline bool operator<( const FOOTPRINT_INFO& item1, const FOOTPRINT_INFO& item2 ) { -#if defined( USE_FP_LIB_TABLE ) int retv = StrNumCmp( item1.m_nickname, item2.m_nickname, INT_MAX, true ); if( retv != 0 ) return retv < 0; -#endif - return StrNumCmp( item1.m_Module, item2.m_Module, INT_MAX, true ) < 0; + return StrNumCmp( item1.m_fpname, item2.m_fpname, INT_MAX, true ) < 0; } - +/** + * Class FOOTPRINT_LIST + * holds a list of FOOTPRINT_INFO objects, along with a list of IO_ERRORs or + * PARSE_ERRORs that were thrown acquiring the FOOTPRINT_INFOs. + */ class FOOTPRINT_LIST { -public: - boost::ptr_vector< FOOTPRINT_INFO > m_List; - wxString m_filesNotFound; - wxString m_filesInvalid; + FP_LIB_TABLE* m_lib_table; ///< no ownership + volatile int m_error_count; ///< thread safe to read. + + typedef boost::ptr_vector< FOOTPRINT_INFO > FPILIST; + typedef boost::ptr_vector< IO_ERROR > ERRLIST; + + FPILIST m_list; + ERRLIST m_errors; ///< some can be PARSE_ERRORs also + + MUTEX m_errors_lock; + MUTEX m_list_lock; + + /** + * Function loader_job + * loads footprints from @a aNicknameList and calls AddItem() on to help fill + * m_list. + * + * @param aNicknameList is a wxString[] holding libraries to load all footprints from. + * @param aJobZ is the size of the job, i.e. the count of nicknames. + */ + void loader_job( const wxString* aNicknameList, int aJobZ ); + + void addItem( FOOTPRINT_INFO* aItem ) + { + // m_list is not thread safe, and this function is called from + // worker threads, lock m_list. + MUTLOCK lock( m_list_lock ); + + m_list.push_back( aItem ); + } + public: + FOOTPRINT_LIST() : + m_lib_table( 0 ), + m_error_count( 0 ) + { + } + /** * Function GetCount * @return the number of items stored in list */ - unsigned GetCount() const { return m_List.size(); } + unsigned GetCount() const { return m_list.size(); } + + /// Was forced to add this by modview_frame.cpp + const FPILIST& GetList() const { return m_list; } /** * Function GetModuleInfo - * @return the item stored in list if found - * @param aFootprintName = the name of item + * @param aFootprintName = the footprint name inside the FOOTPRINT_INFO of interest. + * @return FOOTPRINT_INF* - the item stored in list if found */ - FOOTPRINT_INFO* GetModuleInfo( const wxString & aFootprintName ); + FOOTPRINT_INFO* GetModuleInfo( const wxString& aFootprintName ); /** * Function GetItem - * @return the aIdx item in list * @param aIdx = index of the given item + * @return the aIdx item in list */ - FOOTPRINT_INFO & GetItem( unsigned aIdx ) - { - return m_List[aIdx]; - } + FOOTPRINT_INFO& GetItem( unsigned aIdx ) { return m_list[aIdx]; } /** * Function AddItem * add aItem in list * @param aItem = item to add */ - void AddItem( FOOTPRINT_INFO* aItem ) - { - m_List.push_back( aItem ); - } + void AddItem( FOOTPRINT_INFO* aItem ); - /** - * Function ReadFootprintFiles - * - * @param aFootprintsLibNames = an array string giving the list of libraries to load - */ - bool ReadFootprintFiles( wxArrayString& aFootprintsLibNames ); + unsigned GetErrorCount() const { return m_errors.size(); } + + const IO_ERROR* GetError( unsigned aIdx ) const { return &m_errors[aIdx]; } /** * Function ReadFootprintFiles * reads all the footprints provided by the combination of aTable and aNickname. + * * @param aTable defines all the libraries. * @param aNickname is the library to read from, or if NULL means read all - * footprints from all known libraries. + * footprints from all known libraries in aTable. + * @return bool - true if it ran to completion, else false if it aborted after + * some number of errors. If true, it does not mean there were no errors, check + * GetErrorCount() for that, should be zero to indicate success. */ bool ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* aNickname = NULL ); + + void DisplayErrors( wxTopLevelWindow* aCaller = NULL ); + + FP_LIB_TABLE* GetTable() const { return m_lib_table; } }; #endif // FOOTPRINT_INFO_H_ diff --git a/include/fp_lib_table.h b/include/fp_lib_table.h index 5a754320b6..43dcf7e62a 100644 --- a/include/fp_lib_table.h +++ b/include/fp_lib_table.h @@ -640,26 +640,4 @@ protected: FP_LIB_TABLE* fallBack; }; - -#if 0 // I don't think this is going to be needed. - - /** - * Function LookupPart - * finds and loads a MODULE, and parses it. As long as the part is - * accessible in any LIB_SOURCE, opened or not opened, this function - * will find it and load it into its containing LIB, even if that means - * having to open a LIB in this table that was not previously opened. - * - * @param aFootprintId The fully qualified name of the footprint to look up. - * - * @return MODULE* - this will never be NULL, and no ownership is transferred because - * all MODULEs live in LIBs. You only get to point to them in some LIB. If the MODULE - * cannot be found, then an exception is thrown. - * - * @throw IO_ERROR if any problem occurs or if the footprint cannot be found. - */ - MODULE* LookupFootprint( const FP_LIB_ID& aFootprintId ) throw( IO_ERROR ); -#endif - - #endif // FP_LIB_TABLE_H_ diff --git a/include/gal/graphics_abstraction_layer.h b/include/gal/graphics_abstraction_layer.h index f374979531..7745dfa172 100644 --- a/include/gal/graphics_abstraction_layer.h +++ b/include/gal/graphics_abstraction_layer.h @@ -277,7 +277,7 @@ public: * @param aPosition is the text position in world coordinates. * @param aRotationAngle is the text rotation angle. */ - inline virtual void StrokeText( const std::string& aText, const VECTOR2D& aPosition, + inline virtual void StrokeText( const wxString& aText, const VECTOR2D& aPosition, double aRotationAngle ) { strokeFont.Draw( aText, aPosition, aRotationAngle ); diff --git a/include/gal/stroke_font.h b/include/gal/stroke_font.h index 50882ee142..afa8d7f61c 100644 --- a/include/gal/stroke_font.h +++ b/include/gal/stroke_font.h @@ -3,6 +3,8 @@ * * Copyright (C) 2012 Torsten Hueter, torstenhtr gmx.de * Copyright (C) 2012 Kicad Developers, see change_log.txt for contributors. + * Copyright (C) 2013 CERN + * @author Maciej Suminski * * Stroke font class * @@ -39,7 +41,7 @@ namespace KIGFX class GAL; typedef std::deque< std::deque > GLYPH; -typedef std::deque GLYPH_LIST; +typedef std::vector GLYPH_LIST; /** * @brief Class STROKE_FONT implements stroke font drawing. @@ -52,11 +54,6 @@ public: /// Constructor STROKE_FONT( GAL* aGal ); - /// Destructor - ~STROKE_FONT(); - - // TODO Load font from a text file - /** * @brief Load the new stroke font. * @@ -73,17 +70,7 @@ public: * @param aPosition is the text position in world coordinates. * @param aRotationAngle is the text rotation angle. */ - void Draw( std::string aText, const VECTOR2D& aPosition, double aRotationAngle ); - - /** - * @brief Set the scale factor of the font for the glyph size. - * - * @param aScaleFactor is the scale factor of the font. - */ - inline void SetScaleFactor( const double aScaleFactor ) - { - m_scaleFactor = aScaleFactor; - } + void Draw( const wxString& aText, const VECTOR2D& aPosition, double aRotationAngle ); /** * @brief Set the glyph size. @@ -158,13 +145,19 @@ public: private: GAL* m_gal; ///< Pointer to the GAL GLYPH_LIST m_glyphs; ///< Glyph list - std::deque m_glyphBoundingBoxes; ///< Bounding boxes of the glyphs - double m_scaleFactor; ///< Scale factor for the glyph + std::vector m_glyphBoundingBoxes; ///< Bounding boxes of the glyphs VECTOR2D m_glyphSize; ///< Size of the glyphs EDA_TEXT_HJUSTIFY_T m_horizontalJustify; ///< Horizontal justification EDA_TEXT_VJUSTIFY_T m_verticalJustify; ///< Vertical justification bool m_bold, m_italic, m_mirrored, m_overbar; ///< Properties of text + /** + * @brief Returns a single line height using current settings. + * + * @return The line height. + */ + int getInterline() const; + /** * @brief Compute the bounding box of a given glyph. * @@ -174,15 +167,50 @@ private: */ BOX2D computeBoundingBox( const GLYPH& aGlyph, const VECTOR2D& aGlyphBoundingX ) const; + /** + * @brief Draws a single line of text. Multiline texts should be split before using the + * function. + * + * @param aText is the text to be drawn. + */ + void drawSingleLineText( const wxString& aText ); + /** * @brief Compute the size of a given text. * * @param aText is the text string. * @return is the text size. */ - VECTOR2D computeTextSize( const std::string& aText ) const; + VECTOR2D computeTextSize( const wxString& aText ) const; - static const double LINE_HEIGHT_RATIO; + /** + * @brief Returns number of lines for a given text. + * + * @param aText is the text to be checked. + * @return Number of lines of aText. + */ + unsigned int linesCount( const wxString& aText ) const + { + wxString::const_iterator it, itEnd; + unsigned int lines = 1; + + for( it = aText.begin(), itEnd = aText.end(); it != itEnd; ++it ) + { + if( *it == '\n' ) + ++lines; + } + + return lines; + } + + ///> Factor that determines relative height of overbar. + static const double OVERBAR_HEIGHT; + + ///> Factor that determines relative line width for bold text. + static const double BOLD_FACTOR; + + ///> Scale factor for the glyph + static const double HERSHEY_SCALE; }; } // namespace KIGFX diff --git a/include/geometry/rtree.h b/include/geometry/rtree.h index efc0f6e082..6d5a5561d7 100644 --- a/include/geometry/rtree.h +++ b/include/geometry/rtree.h @@ -163,7 +163,7 @@ public: /// Calculate Statistics - Statistics CalcStats( ); + Statistics CalcStats(); /// Remove all entries from tree void RemoveAll(); @@ -396,7 +396,7 @@ protected: bool IsInternalNode() { return m_level > 0; } // Not a leaf, but a internal node bool IsLeaf() { return m_level == 0; } // A leaf, contains data - int m_count; ///< Count + int m_count; ///< Count int m_level; ///< Leaf is zero, others positive Branch m_branch[MAXNODES]; ///< Branch }; @@ -830,18 +830,18 @@ RTREE_TEMPLATE bool RTREE_QUAL::Load( RTFileStream& a_stream ) { // Write some kind of header - int _dataFileId = ('R' << 0) | ('T' << 8) | ('R' << 16) | ('E' << 24); - int _dataSize = sizeof(DATATYPE); - int _dataNumDims = NUMDIMS; - int _dataElemSize = sizeof(ELEMTYPE); + int _dataFileId = ('R' << 0) | ('T' << 8) | ('R' << 16) | ('E' << 24); + int _dataSize = sizeof(DATATYPE); + int _dataNumDims = NUMDIMS; + int _dataElemSize = sizeof(ELEMTYPE); int _dataElemRealSize = sizeof(ELEMTYPEREAL); int _dataMaxNodes = TMAXNODES; int _dataMinNodes = TMINNODES; - int dataFileId = 0; - int dataSize = 0; - int dataNumDims = 0; - int dataElemSize = 0; + int dataFileId = 0; + int dataSize = 0; + int dataNumDims = 0; + int dataElemSize = 0; int dataElemRealSize = 0; int dataMaxNodes = 0; int dataMinNodes = 0; @@ -932,10 +932,10 @@ RTREE_TEMPLATE bool RTREE_QUAL::Save( RTFileStream& a_stream ) { // Write some kind of header - int dataFileId = ('R' << 0) | ('T' << 8) | ('R' << 16) | ('E' << 24); - int dataSize = sizeof(DATATYPE); - int dataNumDims = NUMDIMS; - int dataElemSize = sizeof(ELEMTYPE); + int dataFileId = ('R' << 0) | ('T' << 8) | ('R' << 16) | ('E' << 24); + int dataSize = sizeof(DATATYPE); + int dataNumDims = NUMDIMS; + int dataElemSize = sizeof(ELEMTYPE); int dataElemRealSize = sizeof(ELEMTYPEREAL); int dataMaxNodes = TMAXNODES; int dataMinNodes = TMINNODES; @@ -1286,27 +1286,27 @@ int RTREE_QUAL::PickBranch( Rect* a_rect, Node* a_node ) ELEMTYPEREAL increase; ELEMTYPEREAL bestIncr = (ELEMTYPEREAL) -1; ELEMTYPEREAL area; - ELEMTYPEREAL bestArea; + ELEMTYPEREAL bestArea = 0; int best = 0; Rect tempRect; for( int index = 0; index < a_node->m_count; ++index ) { Rect* curRect = &a_node->m_branch[index].m_rect; - area = CalcRectVolume( curRect ); + area = CalcRectVolume( curRect ); tempRect = CombineRect( a_rect, curRect ); increase = CalcRectVolume( &tempRect ) - area; if( (increase < bestIncr) || firstTime ) { - best = index; + best = index; bestArea = area; bestIncr = increase; firstTime = false; } else if( (increase == bestIncr) && (area < bestArea) ) { - best = index; + best = index; bestArea = area; bestIncr = increase; } @@ -1594,8 +1594,8 @@ void RTREE_QUAL::InitParVars( PartitionVars* a_parVars, int a_maxRects, int a_mi for( int index = 0; index < a_maxRects; ++index ) { - a_parVars->m_taken[index] = false; - a_parVars->m_partition[index] = -1; + a_parVars->m_taken[index] = false; + a_parVars->m_partition[index] = -1; } } @@ -1622,7 +1622,7 @@ void RTREE_QUAL::PickSeeds( PartitionVars* a_parVars ) &a_parVars->m_branchBuf[indexB].m_rect ); waste = CalcRectVolume( &oneRect ) - area[indexA] - area[indexB]; - if( waste > worst ) + if( waste >= worst ) { worst = waste; seed0 = indexA; @@ -1856,8 +1856,6 @@ bool RTREE_QUAL::Search( Node* a_node, Rect* a_rect, int& a_foundCount, bool a_r } - - //calculate the minimum distance between a point and a rectangle as defined by Manolopoulos et al. //it uses the square distance to avoid the use of ELEMTYPEREAL values, which are slower. RTREE_TEMPLATE diff --git a/include/html_messagebox.h b/include/html_messagebox.h index fa83e33d7a..72c79dad3f 100644 --- a/include/html_messagebox.h +++ b/include/html_messagebox.h @@ -1,6 +1,7 @@ #ifndef _html_messagebox_ #define _html_messagebox_ + /** @file Subclass of DIALOG_DISPLAY_HTML_TEXT_BASE, which is generated by wxFormBuilder. @@ -8,7 +9,10 @@ Subclass of DIALOG_DISPLAY_HTML_TEXT_BASE, which is generated by wxFormBuilder. #include <../common/dialogs/dialog_display_info_HTML_base.h> -/** Implementing HTML_MESSAGE_BOX */ + +/** + * Class HTML_MESSAGE_BOX + */ class HTML_MESSAGE_BOX : public DIALOG_DISPLAY_HTML_TEXT_BASE { protected: @@ -16,8 +20,10 @@ protected: void OnCloseButtonClick( wxCommandEvent& event ); public: - /** Constructor */ - HTML_MESSAGE_BOX( wxWindow* parent, const wxString & aTitle, + /** + * Constructor + */ + HTML_MESSAGE_BOX( wxWindow* parent, const wxString& aTitle, wxPoint aPos = wxDefaultPosition, wxSize aSize = wxSize( 450,250 ) ); @@ -26,28 +32,30 @@ public: * Add a list of items. * @param aList = a string containing items. Items are separated by '\n' */ - void ListSet(const wxString &aList); + void ListSet( const wxString& aList ); + /** * Function ListSet * Add a list of items. * @param aList = a wxArrayString containing items. */ - void ListSet(const wxArrayString &aList); + void ListSet( const wxArrayString& aList ); void ListClear(); + /** * Function MessageSet - * Add a message (in bold) to message list. + * adds a message (in bold) to message list. * @param message = the message */ - void MessageSet(const wxString &message); + void MessageSet( const wxString& message ); /** * Function AddHTML_Text - * Add a html text (without any change) to message list. + * adds html text (without any change) to message list. * @param message = the text to add */ - void AddHTML_Text(const wxString &message); + void AddHTML_Text( const wxString& message ); }; #endif // _html_messagebox_ diff --git a/include/ki_mutex.h b/include/ki_mutex.h new file mode 100644 index 0000000000..1721de5c67 --- /dev/null +++ b/include/ki_mutex.h @@ -0,0 +1,33 @@ + +#ifndef KI_MUTEX_H_ +#define KI_MUTEX_H_ + + +/// Establish KiCad MUTEX choices here in this file: +/// typedef MUTEX and typedef MUTLOCK. +/// +/// Using an unnamed resource is easier, providing a textual name for a +/// constructor is cumbersome, so we make choice on that criteria mostly: + +#if 1 + +// This is a fine choice between the two, but requires linking to ${Boost_LIBRARIES} + +#include +#include + +typedef boost::interprocess::interprocess_mutex MUTEX; +typedef boost::interprocess::scoped_lock MUTLOCK; + +#else + +// This choice also works. + +#include + +typedef wxMutex MUTEX; +typedef wxMutexLocker MUTLOCK; + +#endif + +#endif // KI_MUTEX_H_ diff --git a/include/kicad_string.h b/include/kicad_string.h index 49d23742c1..ee13446132 100644 --- a/include/kicad_string.h +++ b/include/kicad_string.h @@ -164,4 +164,21 @@ wxString GetIllegalFileNameWxChars(); */ bool ReplaceIllegalFileNameChars( std::string* aName ); +/** + * Function RemoveTrailingZeros + * removes the trailing zeros from \a aString. + * + * All trailing zeros and the '.' character from floating point numbers are removed from + * \a aString. + * + * @param aString is a wxString object to remove the trailing zeros from. + * @return a wxString with the trailing zeros removed. + */ +wxString RemoveTrailingZeros( const wxString& aString ); + +#ifndef HAVE_STRTOKR +// common/strtok_r.c optionally: +extern "C" char* strtok_r( char* str, const char* delim, char** nextp ); +#endif + #endif // KICAD_STRING_H_ diff --git a/include/pcbcommon.h b/include/pcbcommon.h index 6aec7cf240..cdec3783b5 100644 --- a/include/pcbcommon.h +++ b/include/pcbcommon.h @@ -25,8 +25,6 @@ extern DISPLAY_OPTIONS DisplayOpt; extern int g_CurrentVersionPCB; -extern int g_RotationAngle; - /// List of segments of the trace currently being drawn. extern DLIST g_CurrentTrackList; diff --git a/include/plot_common.h b/include/plot_common.h index cdb6ff049b..1dff640eb4 100644 --- a/include/plot_common.h +++ b/include/plot_common.h @@ -153,7 +153,7 @@ public: int width = DEFAULT_LINE_WIDTH ) = 0; virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill, int width = DEFAULT_LINE_WIDTH ) = 0; - virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle, + virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle, int rayon, FILL_T fill, int width = DEFAULT_LINE_WIDTH ); /** @@ -214,7 +214,7 @@ public: // Higher level primitives -- can be drawn as line, sketch or 'filled' virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width, EDA_DRAW_MODE_T tracemode ); - virtual void ThickArc( const wxPoint& centre, double StAngle, double EndAngle, + virtual void ThickArc( const wxPoint& centre, double StAngle, double EndAngle, int rayon, int width, EDA_DRAW_MODE_T tracemode ); virtual void ThickRect( const wxPoint& p1, const wxPoint& p2, int width, EDA_DRAW_MODE_T tracemode ); @@ -301,7 +301,7 @@ protected: int width ); // Coordinate and scaling conversion functions - virtual DPOINT userToDeviceCoordinates( const wxPoint& pos ); + virtual DPOINT userToDeviceCoordinates( const wxPoint& aCoordinate ); virtual DPOINT userToDeviceSize( const wxSize& size ); virtual double userToDeviceSize( double size ); @@ -320,6 +320,12 @@ protected: /// Plot offset (in IUs) wxPoint plotOffset; + /// X axis orientation (SVG) + /// and plot mirrored (only for PS, PDF HPGL and SVG) + bool m_plotMirror; + bool m_mirrorIsHorizontal; /// true to mirror horizontally (else vertically) + bool m_yaxisReversed; /// true if the Y axis is top to bottom (SVG) + /// Output file FILE* outputFile; @@ -332,7 +338,6 @@ protected: char penState; /// Last pen positions; set to -1,-1 when the pen is at rest wxPoint penLastpos; - bool plotMirror; wxString creator; wxString filename; PAGE_INFO pageInfo; @@ -402,7 +407,7 @@ public: virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width, EDA_DRAW_MODE_T tracemode ); - virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle, + virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle, int rayon, FILL_T fill, int width = DEFAULT_LINE_WIDTH ); virtual void PenTo( const wxPoint& pos, char plume ); virtual void FlashPadCircle( const wxPoint& pos, int diametre, @@ -786,7 +791,7 @@ public: int width = DEFAULT_LINE_WIDTH ); virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill, int width = DEFAULT_LINE_WIDTH ); - virtual void Arc( const wxPoint& aCenter, double aStAngle, double aEndAngle, + virtual void Arc( const wxPoint& aCenter, double aStAngle, double aEndAngle, int aRadius, FILL_T aFill, int aWidth = DEFAULT_LINE_WIDTH ); virtual void PlotPoly( const std::vector< wxPoint >& aCornerList, FILL_T aFill, int aWidth = DEFAULT_LINE_WIDTH ); @@ -877,7 +882,7 @@ public: FILL_T aFill, int aWidth = DEFAULT_LINE_WIDTH ); virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width, EDA_DRAW_MODE_T tracemode ); - virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle, + virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle, int rayon, FILL_T fill, int width = DEFAULT_LINE_WIDTH ); virtual void PenTo( const wxPoint& pos, char plume ); virtual void FlashPadCircle( const wxPoint& pos, int diametre, diff --git a/include/richio.h b/include/richio.h index dba6e95952..dc66d6c82b 100644 --- a/include/richio.h +++ b/include/richio.h @@ -93,7 +93,7 @@ std::string /** * Struct IO_ERROR - * is a class used to hold an error message and may be used to throw exceptions + * is a class used to hold an error message and may be used when throwing exceptions * containing meaningful error messages. * @author Dick Hollenbeck */ @@ -148,7 +148,9 @@ struct IO_ERROR // : std::exception IO_ERROR() {} - ~IO_ERROR() throw ( /*none*/ ){} + // Destructor is virtual because PARSE_ERROR is derived from it and + // boost::ptr_vector lists consisting of both will need a virtual destructor. + virtual ~IO_ERROR() throw ( /*none*/ ){} }; diff --git a/include/rtree.h b/include/rtree.h deleted file mode 100644 index cfb6c86d3c..0000000000 --- a/include/rtree.h +++ /dev/null @@ -1,1758 +0,0 @@ -/* - * R-Tree index - * - * from http://www.superliminal.com/ - * - * LICENSE : Entirely free for all uses. Enjoy! - * - * AUTORS - * - 1983 Original algorithm and test code by Antonin Guttman and Michael Stonebraker, UC Berkely - * - 1994 ANCI C ported from original test code by Melinda Green - melinda@superliminal.com - * - 1995 Sphere volume fix for degeneracy problem submitted by Paul Brook - * - 2004 Templated C++ port by Greg Douglas - * - 2008 Portability issues fixed by Maxence Laurent - */ - -#ifndef RTREE_H -#define RTREE_H - -// NOTE This file compiles under MSVC 6 SP5 and MSVC .Net 2003 it may not work on other compilers without modification. - -// NOTE These next few lines may be win32 specific, you may need to modify them to compile on other platform -#include -#include -#include -#include - -#define ASSERT assert // RTree uses ASSERT( condition ) -#ifndef Min - #define Min std::min -#endif // Min -#ifndef Max - #define Max std::max -#endif // Max - -// -// RTree.h -// - -#define RTREE_TEMPLATE template -#define RTREE_SEARCH_TEMPLATE template -#define RTREE_QUAL RTree -#define RTREE_SEARCH_QUAL RTree - -#define RTREE_DONT_USE_MEMPOOLS // This version does not contain a fixed memory allocator, fill in lines with EXAMPLE to implement one. -#define RTREE_USE_SPHERICAL_VOLUME // Better split classification, may be slower on some systems - -// Fwd decl -class RTFileStream; // File I/O helper class, look below for implementation and notes. - - -/// \class RTree -/// Implementation of RTree, a multidimensional bounding rectangle tree. -/// Example usage: For a 3-dimensional tree use RTree myTree; -/// -/// This modified, templated C++ version by Greg Douglas at Auran (http://www.auran.com) -/// -/// DATATYPE Referenced data, should be int, void*, obj* etc. no larger than sizeof and simple type -/// ELEMTYPE Type of element such as int or float -/// NUMDIMS Number of dimensions such as 2 or 3 -/// ELEMTYPEREAL Type of element that allows fractional and large values such as float or double, for use in volume calcs -/// -/// NOTES: Inserting and removing data requires the knowledge of its constant Minimal Bounding Rectangle. -/// This version uses new/delete for nodes, I recommend using a fixed size allocator for efficiency. -/// Instead of using a callback function for returned results, I recommend and efficient pre-sized, grow-only memory -/// array similar to MFC CArray or STL Vector for returning search query result. -/// -template -class RTree -{ -protected: - - struct Node; // Fwd decl. Used by other internal structs and iterator -public: - - // These constant must be declared after Branch and before Node struct - // Stuck up here for MSVC 6 compiler. NSVC .NET 2003 is much happier. - enum { - MAXNODES = TMAXNODES, ///< Max elements in node - MINNODES = TMINNODES, ///< Min elements in node - }; -public: - - RTree(); - virtual ~RTree(); - - /// Insert entry - /// \param a_min Min of bounding rect - /// \param a_max Max of bounding rect - /// \param a_dataId Positive Id of data. Maybe zero, but negative numbers not allowed. - void Insert( const ELEMTYPE a_min[NUMDIMS], - const ELEMTYPE a_max[NUMDIMS], - const DATATYPE& a_dataId ); - - /// Remove entry - /// \param a_min Min of bounding rect - /// \param a_max Max of bounding rect - /// \param a_dataId Positive Id of data. Maybe zero, but negative numbers not allowed. - void Remove( const ELEMTYPE a_min[NUMDIMS], - const ELEMTYPE a_max[NUMDIMS], - const DATATYPE& a_dataId ); - - /// Find all within search rectangle - /// \param a_min Min of search bounding rect - /// \param a_max Max of search bounding rect - /// \param a_searchResult Search result array. Caller should set grow size. Function will reset, not append to array. - /// \param a_resultCallback Callback function to return result. Callback should return 'true' to continue searching - /// \param a_context User context to pass as parameter to a_resultCallback - /// \return Returns the number of entries found - int Search( const ELEMTYPE a_min[NUMDIMS], - const ELEMTYPE a_max[NUMDIMS], - bool a_resultCallback( DATATYPE a_data, void* a_context ), - void* a_context ); - - template - int Search( const ELEMTYPE a_min[NUMDIMS], const ELEMTYPE a_max[NUMDIMS], VISITOR& a_visitor ) - { - #ifdef _DEBUG - - for( int index = 0; index 0; } - - /// Access the current data element. Caller must be sure iterator is not NULL first. - DATATYPE& operator*() - { - ASSERT( IsNotNull() ); - StackElement& curTos = m_stack[m_tos - 1]; - return curTos.m_node->m_branch[curTos.m_branchIndex].m_data; - } - - /// Access the current data element. Caller must be sure iterator is not NULL first. - const DATATYPE& operator*() const - { - ASSERT( IsNotNull() ); - StackElement& curTos = m_stack[m_tos - 1]; - return curTos.m_node->m_branch[curTos.m_branchIndex].m_data; - } - - /// Find the next data element - bool operator++() { return FindNextData(); } - - /// Get the bounds for this node - void GetBounds( ELEMTYPE a_min[NUMDIMS], ELEMTYPE a_max[NUMDIMS] ) - { - ASSERT( IsNotNull() ); - StackElement& curTos = m_stack[m_tos - 1]; - Branch& curBranch = curTos.m_node->m_branch[curTos.m_branchIndex]; - - for( int index = 0; index < NUMDIMS; ++index ) - { - a_min[index] = curBranch.m_rect.m_min[index]; - a_max[index] = curBranch.m_rect.m_max[index]; - } - } - -private: - - /// Reset iterator - void Init() { m_tos = 0; } - - /// Find the next data element in the tree (For internal use only) - bool FindNextData() - { - for( ; ; ) - { - if( m_tos <= 0 ) - { - return false; - } - - StackElement curTos = Pop(); // Copy stack top cause it may change as we use it - - if( curTos.m_node->IsLeaf() ) - { - // Keep walking through data while we can - if( curTos.m_branchIndex + 1 < curTos.m_node->m_count ) - { - // There is more data, just point to the next one - Push( curTos.m_node, curTos.m_branchIndex + 1 ); - return true; - } - - // No more data, so it will fall back to previous level - } - else - { - if( curTos.m_branchIndex + 1 < curTos.m_node->m_count ) - { - // Push sibling on for future tree walk - // This is the 'fall back' node when we finish with the current level - Push( curTos.m_node, curTos.m_branchIndex + 1 ); - } - - // Since cur node is not a leaf, push first of next level to get deeper into the tree - Node* nextLevelnode = curTos.m_node->m_branch[curTos.m_branchIndex].m_child; - Push( nextLevelnode, 0 ); - - // If we pushed on a new leaf, exit as the data is ready at TOS - if( nextLevelnode->IsLeaf() ) - { - return true; - } - } - } - } - - /// Push node and branch onto iteration stack (For internal use only) - void Push( Node* a_node, int a_branchIndex ) - { - m_stack[m_tos].m_node = a_node; - m_stack[m_tos].m_branchIndex = a_branchIndex; - ++m_tos; - ASSERT( m_tos <= MAX_STACK ); - } - - /// Pop element off iteration stack (For internal use only) - StackElement& Pop() - { - ASSERT( m_tos > 0 ); - --m_tos; - return m_stack[m_tos]; - } - - StackElement m_stack[MAX_STACK]; ///< Stack as we are doing iteration instead of recursion - int m_tos; ///< Top Of Stack index - - friend class RTree; // Allow hiding of non-public functions while allowing manipulation by logical owner - }; - - - /// Get 'first' for iteration - void GetFirst( Iterator& a_it ) - { - a_it.Init(); - Node* first = m_root; - - while( first ) - { - if( first->IsInternalNode() && first->m_count > 1 ) - { - a_it.Push( first, 1 ); // Descend sibling branch later - } - else if( first->IsLeaf() ) - { - if( first->m_count ) - { - a_it.Push( first, 0 ); - } - - break; - } - - first = first->m_branch[0].m_child; - } - } - - /// Get Next for iteration - void GetNext( Iterator& a_it ) { ++a_it; } - - /// Is iterator NULL, or at end? - bool IsNull( Iterator& a_it ) { return a_it.IsNull(); } - - /// Get object at iterator position - DATATYPE& GetAt( Iterator& a_it ) { return *a_it; } -protected: - - /// Minimal bounding rectangle (n-dimensional) - struct Rect - { - ELEMTYPE m_min[NUMDIMS]; ///< Min dimensions of bounding box - ELEMTYPE m_max[NUMDIMS]; ///< Max dimensions of bounding box - }; - - /// May be data or may be another subtree - /// The parents level determines this. - /// If the parents level is 0, then this is data - struct Branch - { - Rect m_rect; ///< Bounds - union - { - Node* m_child; ///< Child node - DATATYPE m_data; ///< Data Id or Ptr - }; - }; - - /// Node for each branch level - struct Node - { - bool IsInternalNode() { return m_level > 0; } // Not a leaf, but a internal node - bool IsLeaf() { return m_level == 0; } // A leaf, contains data - - int m_count; ///< Count - int m_level; ///< Leaf is zero, others positive - Branch m_branch[MAXNODES]; ///< Branch - }; - - /// A link list of nodes for reinsertion after a delete operation - struct ListNode - { - ListNode* m_next; ///< Next in list - Node* m_node; ///< Node - }; - - /// Variables for finding a split partition - struct PartitionVars - { - int m_partition[MAXNODES + 1]; - int m_total; - int m_minFill; - int m_taken[MAXNODES + 1]; - int m_count[2]; - Rect m_cover[2]; - ELEMTYPEREAL m_area[2]; - - Branch m_branchBuf[MAXNODES + 1]; - int m_branchCount; - Rect m_coverSplit; - ELEMTYPEREAL m_coverSplitArea; - }; - - Node* AllocNode(); - void FreeNode( Node* a_node ); - void InitNode( Node* a_node ); - void InitRect( Rect* a_rect ); - bool InsertRectRec( Rect* a_rect, - const DATATYPE& a_id, - Node* a_node, - Node** a_newNode, - int a_level ); - bool InsertRect( Rect* a_rect, const DATATYPE& a_id, Node** a_root, int a_level ); - Rect NodeCover( Node* a_node ); - bool AddBranch( Branch* a_branch, Node* a_node, Node** a_newNode ); - void DisconnectBranch( Node* a_node, int a_index ); - int PickBranch( Rect* a_rect, Node* a_node ); - Rect CombineRect( Rect* a_rectA, Rect* a_rectB ); - void SplitNode( Node* a_node, Branch* a_branch, Node** a_newNode ); - ELEMTYPEREAL RectSphericalVolume( Rect* a_rect ); - ELEMTYPEREAL RectVolume( Rect* a_rect ); - ELEMTYPEREAL CalcRectVolume( Rect* a_rect ); - void GetBranches( Node* a_node, Branch* a_branch, PartitionVars* a_parVars ); - void ChoosePartition( PartitionVars* a_parVars, int a_minFill ); - void LoadNodes( Node* a_nodeA, Node* a_nodeB, PartitionVars* a_parVars ); - void InitParVars( PartitionVars* a_parVars, int a_maxRects, int a_minFill ); - void PickSeeds( PartitionVars* a_parVars ); - void Classify( int a_index, int a_group, PartitionVars* a_parVars ); - bool RemoveRect( Rect* a_rect, const DATATYPE& a_id, Node** a_root ); - bool RemoveRectRec( Rect* a_rect, - const DATATYPE& a_id, - Node* a_node, - ListNode** a_listNode ); - ListNode* AllocListNode(); - void FreeListNode( ListNode* a_listNode ); - bool Overlap( Rect* a_rectA, Rect* a_rectB ); - void ReInsert( Node* a_node, ListNode** a_listNode ); - - bool Search( Node * a_node, Rect * a_rect, int& a_foundCount, bool a_resultCallback( - DATATYPE a_data, - void* a_context ), void* a_context ); - - template - bool Search( Node* a_node, Rect* a_rect, VISITOR& a_visitor ) - { - ASSERT( a_node ); - ASSERT( a_node->m_level >= 0 ); - ASSERT( a_rect ); - - if( a_node->IsInternalNode() ) // This is an internal node in the tree - { - for( int index = 0; index < a_node->m_count; ++index ) - { - if( Overlap( a_rect, &a_node->m_branch[index].m_rect ) ) - { - if( !Search( a_node->m_branch[index].m_child, a_rect, a_visitor ) ) - { - return false; // Don't continue searching - } - } - } - } - else // This is a leaf node - { - for( int index = 0; index < a_node->m_count; ++index ) - { - if( Overlap( a_rect, &a_node->m_branch[index].m_rect ) ) - { - DATATYPE& id = a_node->m_branch[index].m_data; - - a_visitor( id ); - } - } - } - - return true; // Continue searching - } - - void RemoveAllRec( Node* a_node ); - void Reset(); - void CountRec( Node* a_node, int& a_count ); - - bool SaveRec( Node* a_node, RTFileStream& a_stream ); - bool LoadRec( Node* a_node, RTFileStream& a_stream ); - - Node* m_root; ///< Root of tree - ELEMTYPEREAL m_unitSphereVolume; ///< Unit sphere constant for required number of dimensions -}; - - -// Because there is not stream support, this is a quick and dirty file I/O helper. -// Users will likely replace its usage with a Stream implementation from their favorite API. -class RTFileStream -{ - FILE* m_file; -public: - - - RTFileStream() - { - m_file = NULL; - } - - ~RTFileStream() - { - Close(); - } - - bool OpenRead( const char* a_fileName ) - { - m_file = fopen( a_fileName, "rb" ); - - if( !m_file ) - { - return false; - } - - return true; - } - - bool OpenWrite( const char* a_fileName ) - { - m_file = fopen( a_fileName, "wb" ); - - if( !m_file ) - { - return false; - } - - return true; - } - - void Close() - { - if( m_file ) - { - fclose( m_file ); - m_file = NULL; - } - } - - template - size_t Write( const TYPE& a_value ) - { - ASSERT( m_file ); - return fwrite( (void*) &a_value, sizeof(a_value), 1, m_file ); - } - - template - size_t WriteArray( const TYPE* a_array, int a_count ) - { - ASSERT( m_file ); - return fwrite( (void*) a_array, sizeof(TYPE) * a_count, 1, m_file ); - } - - template - size_t Read( TYPE& a_value ) - { - ASSERT( m_file ); - return fread( (void*) &a_value, sizeof(a_value), 1, m_file ); - } - - template - size_t ReadArray( TYPE* a_array, int a_count ) - { - ASSERT( m_file ); - return fread( (void*) a_array, sizeof(TYPE) * a_count, 1, m_file ); - } -}; - - -RTREE_TEMPLATE RTREE_QUAL::RTree() -{ - ASSERT( MAXNODES > MINNODES ); - ASSERT( MINNODES > 0 ); - - - // We only support machine word size simple data type eg. integer index or object pointer. - // Since we are storing as union with non data branch - ASSERT( sizeof(DATATYPE) == sizeof(void*) || sizeof(DATATYPE) == sizeof(int) ); - - // Precomputed volumes of the unit spheres for the first few dimensions - const float UNIT_SPHERE_VOLUMES[] = - { - 0.000000f, 2.000000f, 3.141593f, // Dimension 0,1,2 - 4.188790f, 4.934802f, 5.263789f, // Dimension 3,4,5 - 5.167713f, 4.724766f, 4.058712f, // Dimension 6,7,8 - 3.298509f, 2.550164f, 1.884104f, // Dimension 9,10,11 - 1.335263f, 0.910629f, 0.599265f, // Dimension 12,13,14 - 0.381443f, 0.235331f, 0.140981f, // Dimension 15,16,17 - 0.082146f, 0.046622f, 0.025807f, // Dimension 18,19,20 - }; - - m_root = AllocNode(); - m_root->m_level = 0; - m_unitSphereVolume = (ELEMTYPEREAL) UNIT_SPHERE_VOLUMES[NUMDIMS]; -} - - -RTREE_TEMPLATE -RTREE_QUAL::~RTree() { - Reset(); // Free, or reset node memory -} - - -RTREE_TEMPLATE -void RTREE_QUAL::Insert( const ELEMTYPE a_min[NUMDIMS], - const ELEMTYPE a_max[NUMDIMS], - const DATATYPE& a_dataId ) -{ -#ifdef _DEBUG - - for( int index = 0; indexIsInternalNode() ) // not a leaf node - { - for( int index = 0; index < a_node->m_count; ++index ) - { - CountRec( a_node->m_branch[index].m_child, a_count ); - } - } - else // A leaf node - { - a_count += a_node->m_count; - } -} - - -RTREE_TEMPLATE -bool RTREE_QUAL::Load( const char* a_fileName ) -{ - RemoveAll(); // Clear existing tree - - RTFileStream stream; - - if( !stream.OpenRead( a_fileName ) ) - { - return false; - } - - bool result = Load( stream ); - - stream.Close(); - - return result; -}; - - -RTREE_TEMPLATE -bool RTREE_QUAL::Load( RTFileStream& a_stream ) -{ - // Write some kind of header - int _dataFileId = ('R' << 0) | ('T' << 8) | ('R' << 16) | ('E' << 24); - int _dataSize = sizeof(DATATYPE); - int _dataNumDims = NUMDIMS; - int _dataElemSize = sizeof(ELEMTYPE); - int _dataElemRealSize = sizeof(ELEMTYPEREAL); - int _dataMaxNodes = TMAXNODES; - int _dataMinNodes = TMINNODES; - - int dataFileId = 0; - int dataSize = 0; - int dataNumDims = 0; - int dataElemSize = 0; - int dataElemRealSize = 0; - int dataMaxNodes = 0; - int dataMinNodes = 0; - - a_stream.Read( dataFileId ); - a_stream.Read( dataSize ); - a_stream.Read( dataNumDims ); - a_stream.Read( dataElemSize ); - a_stream.Read( dataElemRealSize ); - a_stream.Read( dataMaxNodes ); - a_stream.Read( dataMinNodes ); - - bool result = false; - - // Test if header was valid and compatible - if( (dataFileId == _dataFileId) - && (dataSize == _dataSize) - && (dataNumDims == _dataNumDims) - && (dataElemSize == _dataElemSize) - && (dataElemRealSize == _dataElemRealSize) - && (dataMaxNodes == _dataMaxNodes) - && (dataMinNodes == _dataMinNodes) - ) - { - // Recursively load tree - result = LoadRec( m_root, a_stream ); - } - - return result; -} - - -RTREE_TEMPLATE -bool RTREE_QUAL::LoadRec( Node* a_node, RTFileStream& a_stream ) -{ - a_stream.Read( a_node->m_level ); - a_stream.Read( a_node->m_count ); - - if( a_node->IsInternalNode() ) // not a leaf node - { - for( int index = 0; index < a_node->m_count; ++index ) - { - Branch* curBranch = &a_node->m_branch[index]; - - a_stream.ReadArray( curBranch->m_rect.m_min, NUMDIMS ); - a_stream.ReadArray( curBranch->m_rect.m_max, NUMDIMS ); - - curBranch->m_child = AllocNode(); - LoadRec( curBranch->m_child, a_stream ); - } - } - else // A leaf node - { - for( int index = 0; index < a_node->m_count; ++index ) - { - Branch* curBranch = &a_node->m_branch[index]; - - a_stream.ReadArray( curBranch->m_rect.m_min, NUMDIMS ); - a_stream.ReadArray( curBranch->m_rect.m_max, NUMDIMS ); - - a_stream.Read( curBranch->m_data ); - } - } - - return true; // Should do more error checking on I/O operations -} - - -RTREE_TEMPLATE -bool RTREE_QUAL::Save( const char* a_fileName ) -{ - RTFileStream stream; - - if( !stream.OpenWrite( a_fileName ) ) - { - return false; - } - - bool result = Save( stream ); - - stream.Close(); - - return result; -} - - -RTREE_TEMPLATE -bool RTREE_QUAL::Save( RTFileStream& a_stream ) -{ - // Write some kind of header - int dataFileId = ('R' << 0) | ('T' << 8) | ('R' << 16) | ('E' << 24); - int dataSize = sizeof(DATATYPE); - int dataNumDims = NUMDIMS; - int dataElemSize = sizeof(ELEMTYPE); - int dataElemRealSize = sizeof(ELEMTYPEREAL); - int dataMaxNodes = TMAXNODES; - int dataMinNodes = TMINNODES; - - a_stream.Write( dataFileId ); - a_stream.Write( dataSize ); - a_stream.Write( dataNumDims ); - a_stream.Write( dataElemSize ); - a_stream.Write( dataElemRealSize ); - a_stream.Write( dataMaxNodes ); - a_stream.Write( dataMinNodes ); - - // Recursively save tree - bool result = SaveRec( m_root, a_stream ); - - return result; -} - - -RTREE_TEMPLATE -bool RTREE_QUAL::SaveRec( Node* a_node, RTFileStream& a_stream ) -{ - a_stream.Write( a_node->m_level ); - a_stream.Write( a_node->m_count ); - - if( a_node->IsInternalNode() ) // not a leaf node - { - for( int index = 0; index < a_node->m_count; ++index ) - { - Branch* curBranch = &a_node->m_branch[index]; - - a_stream.WriteArray( curBranch->m_rect.m_min, NUMDIMS ); - a_stream.WriteArray( curBranch->m_rect.m_max, NUMDIMS ); - - SaveRec( curBranch->m_child, a_stream ); - } - } - else // A leaf node - { - for( int index = 0; index < a_node->m_count; ++index ) - { - Branch* curBranch = &a_node->m_branch[index]; - - a_stream.WriteArray( curBranch->m_rect.m_min, NUMDIMS ); - a_stream.WriteArray( curBranch->m_rect.m_max, NUMDIMS ); - - a_stream.Write( curBranch->m_data ); - } - } - - return true; // Should do more error checking on I/O operations -} - - -RTREE_TEMPLATE -void RTREE_QUAL::RemoveAll() -{ - // Delete all existing nodes - Reset(); - - m_root = AllocNode(); - m_root->m_level = 0; -} - - -RTREE_TEMPLATE -void RTREE_QUAL::Reset() -{ -#ifdef RTREE_DONT_USE_MEMPOOLS - // Delete all existing nodes - RemoveAllRec( m_root ); -#else // RTREE_DONT_USE_MEMPOOLS - // Just reset memory pools. We are not using complex types - // EXAMPLE -#endif // RTREE_DONT_USE_MEMPOOLS -} - - -RTREE_TEMPLATE -void RTREE_QUAL::RemoveAllRec( Node* a_node ) -{ - ASSERT( a_node ); - ASSERT( a_node->m_level >= 0 ); - - if( a_node->IsInternalNode() ) // This is an internal node in the tree - { - for( int index = 0; index < a_node->m_count; ++index ) - { - RemoveAllRec( a_node->m_branch[index].m_child ); - } - } - - FreeNode( a_node ); -} - - -RTREE_TEMPLATE -typename RTREE_QUAL::Node* RTREE_QUAL::AllocNode() -{ - Node* newNode; - -#ifdef RTREE_DONT_USE_MEMPOOLS - newNode = new Node; -#else // RTREE_DONT_USE_MEMPOOLS - // EXAMPLE -#endif // RTREE_DONT_USE_MEMPOOLS - InitNode( newNode ); - return newNode; -} - - -RTREE_TEMPLATE -void RTREE_QUAL::FreeNode( Node* a_node ) -{ - ASSERT( a_node ); - -#ifdef RTREE_DONT_USE_MEMPOOLS - delete a_node; -#else // RTREE_DONT_USE_MEMPOOLS - // EXAMPLE -#endif // RTREE_DONT_USE_MEMPOOLS -} - - -// Allocate space for a node in the list used in DeletRect to -// store Nodes that are too empty. -RTREE_TEMPLATE -typename RTREE_QUAL::ListNode* RTREE_QUAL::AllocListNode() -{ -#ifdef RTREE_DONT_USE_MEMPOOLS - return new ListNode; -#else // RTREE_DONT_USE_MEMPOOLS - // EXAMPLE -#endif // RTREE_DONT_USE_MEMPOOLS -} - - -RTREE_TEMPLATE -void RTREE_QUAL::FreeListNode( ListNode* a_listNode ) -{ -#ifdef RTREE_DONT_USE_MEMPOOLS - delete a_listNode; -#else // RTREE_DONT_USE_MEMPOOLS - // EXAMPLE -#endif // RTREE_DONT_USE_MEMPOOLS -} - - -RTREE_TEMPLATE -void RTREE_QUAL::InitNode( Node* a_node ) -{ - a_node->m_count = 0; - a_node->m_level = -1; -} - - -RTREE_TEMPLATE -void RTREE_QUAL::InitRect( Rect* a_rect ) -{ - for( int index = 0; index < NUMDIMS; ++index ) - { - a_rect->m_min[index] = (ELEMTYPE) 0; - a_rect->m_max[index] = (ELEMTYPE) 0; - } -} - - -// Inserts a new data rectangle into the index structure. -// Recursively descends tree, propagates splits back up. -// Returns 0 if node was not split. Old node updated. -// If node was split, returns 1 and sets the pointer pointed to by -// new_node to point to the new node. Old node updated to become one of two. -// The level argument specifies the number of steps up from the leaf -// level to insert; e.g. a data rectangle goes in at level = 0. -RTREE_TEMPLATE -bool RTREE_QUAL::InsertRectRec( Rect* a_rect, - const DATATYPE& a_id, - Node* a_node, - Node** a_newNode, - int a_level ) -{ - ASSERT( a_rect && a_node && a_newNode ); - ASSERT( a_level >= 0 && a_level <= a_node->m_level ); - - int index; - Branch branch; - Node* otherNode; - - // Still above level for insertion, go down tree recursively - if( a_node->m_level > a_level ) - { - index = PickBranch( a_rect, a_node ); - - if( !InsertRectRec( a_rect, a_id, a_node->m_branch[index].m_child, &otherNode, a_level ) ) - { - // Child was not split - a_node->m_branch[index].m_rect = - CombineRect( a_rect, &(a_node->m_branch[index].m_rect) ); - return false; - } - else // Child was split - { - a_node->m_branch[index].m_rect = NodeCover( a_node->m_branch[index].m_child ); - branch.m_child = otherNode; - branch.m_rect = NodeCover( otherNode ); - return AddBranch( &branch, a_node, a_newNode ); - } - } - else if( a_node->m_level == a_level ) // Have reached level for insertion. Add rect, split if necessary - { - branch.m_rect = *a_rect; - branch.m_child = (Node*) a_id; - // Child field of leaves contains id of data record - return AddBranch( &branch, a_node, a_newNode ); - } - else - { - // Should never occur - ASSERT( 0 ); - return false; - } -} - - -// Insert a data rectangle into an index structure. -// InsertRect provides for splitting the root; -// returns 1 if root was split, 0 if it was not. -// The level argument specifies the number of steps up from the leaf -// level to insert; e.g. a data rectangle goes in at level = 0. -// InsertRect2 does the recursion. -// -RTREE_TEMPLATE -bool RTREE_QUAL::InsertRect( Rect* a_rect, const DATATYPE& a_id, Node** a_root, int a_level ) -{ - ASSERT( a_rect && a_root ); - ASSERT( a_level >= 0 && a_level <= (*a_root)->m_level ); -#ifdef _DEBUG - - for( int index = 0; index < NUMDIMS; ++index ) - { - ASSERT( a_rect->m_min[index] <= a_rect->m_max[index] ); - } - -#endif // _DEBUG - - Node* newRoot; - Node* newNode; - Branch branch; - - if( InsertRectRec( a_rect, a_id, *a_root, &newNode, a_level ) ) // Root split - { - newRoot = AllocNode(); // Grow tree taller and new root - newRoot->m_level = (*a_root)->m_level + 1; - branch.m_rect = NodeCover( *a_root ); - branch.m_child = *a_root; - AddBranch( &branch, newRoot, NULL ); - branch.m_rect = NodeCover( newNode ); - branch.m_child = newNode; - AddBranch( &branch, newRoot, NULL ); - *a_root = newRoot; - return true; - } - - return false; -} - - -// Find the smallest rectangle that includes all rectangles in branches of a node. -RTREE_TEMPLATE -typename RTREE_QUAL::Rect RTREE_QUAL::NodeCover( Node* a_node ) -{ - ASSERT( a_node ); - - int firstTime = true; - Rect rect; - InitRect( &rect ); - - for( int index = 0; index < a_node->m_count; ++index ) - { - if( firstTime ) - { - rect = a_node->m_branch[index].m_rect; - firstTime = false; - } - else - { - rect = CombineRect( &rect, &(a_node->m_branch[index].m_rect) ); - } - } - - return rect; -} - - -// Add a branch to a node. Split the node if necessary. -// Returns 0 if node not split. Old node updated. -// Returns 1 if node split, sets *new_node to address of new node. -// Old node updated, becomes one of two. -RTREE_TEMPLATE -bool RTREE_QUAL::AddBranch( Branch* a_branch, Node* a_node, Node** a_newNode ) -{ - ASSERT( a_branch ); - ASSERT( a_node ); - - if( a_node->m_count < MAXNODES ) // Split won't be necessary - { - a_node->m_branch[a_node->m_count] = *a_branch; - ++a_node->m_count; - - return false; - } - else - { - ASSERT( a_newNode ); - - SplitNode( a_node, a_branch, a_newNode ); - return true; - } -} - - -// Disconnect a dependent node. -// Caller must return (or stop using iteration index) after this as count has changed -RTREE_TEMPLATE -void RTREE_QUAL::DisconnectBranch( Node* a_node, int a_index ) -{ - ASSERT( a_node && (a_index >= 0) && (a_index < MAXNODES) ); - ASSERT( a_node->m_count > 0 ); - - // Remove element by swapping with the last element to prevent gaps in array - a_node->m_branch[a_index] = a_node->m_branch[a_node->m_count - 1]; - - --a_node->m_count; -} - - -// Pick a branch. Pick the one that will need the smallest increase -// in area to accomodate the new rectangle. This will result in the -// least total area for the covering rectangles in the current node. -// In case of a tie, pick the one which was smaller before, to get -// the best resolution when searching. -RTREE_TEMPLATE -int RTREE_QUAL::PickBranch( Rect* a_rect, Node* a_node ) -{ - ASSERT( a_rect && a_node ); - - bool firstTime = true; - ELEMTYPEREAL increase; - ELEMTYPEREAL bestIncr = (ELEMTYPEREAL) -1; - ELEMTYPEREAL area; - ELEMTYPEREAL bestArea; - int best = 0; // avoid compil complaint about uninitialized - Rect tempRect; - - for( int index = 0; index < a_node->m_count; ++index ) - { - Rect* curRect = &a_node->m_branch[index].m_rect; - area = CalcRectVolume( curRect ); - tempRect = CombineRect( a_rect, curRect ); - increase = CalcRectVolume( &tempRect ) - area; - - if( (increase < bestIncr) || firstTime ) - { - best = index; - bestArea = area; - bestIncr = increase; - firstTime = false; - } - else if( (increase == bestIncr) && (area < bestArea) ) - { - best = index; - bestArea = area; - bestIncr = increase; - } - } - - return best; -} - - -// Combine two rectangles into larger one containing both -RTREE_TEMPLATE -typename RTREE_QUAL::Rect RTREE_QUAL::CombineRect( Rect* a_rectA, Rect* a_rectB ) -{ - ASSERT( a_rectA && a_rectB ); - - Rect newRect; - - for( int index = 0; index < NUMDIMS; ++index ) - { - newRect.m_min[index] = Min( a_rectA->m_min[index], a_rectB->m_min[index] ); - newRect.m_max[index] = Max( a_rectA->m_max[index], a_rectB->m_max[index] ); - } - - return newRect; -} - - -// Split a node. -// Divides the nodes branches and the extra one between two nodes. -// Old node is one of the new ones, and one really new one is created. -// Tries more than one method for choosing a partition, uses best result. -RTREE_TEMPLATE -void RTREE_QUAL::SplitNode( Node* a_node, Branch* a_branch, Node** a_newNode ) -{ - ASSERT( a_node ); - ASSERT( a_branch ); - - // Could just use local here, but member or external is faster since it is reused - PartitionVars localVars; - PartitionVars* parVars = &localVars; - int level; - - // Load all the branches into a buffer, initialize old node - level = a_node->m_level; - GetBranches( a_node, a_branch, parVars ); - - // Find partition - ChoosePartition( parVars, MINNODES ); - - // Put branches from buffer into 2 nodes according to chosen partition - *a_newNode = AllocNode(); - (*a_newNode)->m_level = a_node->m_level = level; - LoadNodes( a_node, *a_newNode, parVars ); - - ASSERT( (a_node->m_count + (*a_newNode)->m_count) == parVars->m_total ); -} - - -// Calculate the n-dimensional volume of a rectangle -RTREE_TEMPLATE -ELEMTYPEREAL RTREE_QUAL::RectVolume( Rect* a_rect ) -{ - ASSERT( a_rect ); - - ELEMTYPEREAL volume = (ELEMTYPEREAL) 1; - - for( int index = 0; indexm_max[index] - a_rect->m_min[index]; - } - - ASSERT( volume >= (ELEMTYPEREAL) 0 ); - - return volume; -} - - -// The exact volume of the bounding sphere for the given Rect -RTREE_TEMPLATE -ELEMTYPEREAL RTREE_QUAL::RectSphericalVolume( Rect* a_rect ) -{ - ASSERT( a_rect ); - - ELEMTYPEREAL sumOfSquares = (ELEMTYPEREAL) 0; - ELEMTYPEREAL radius; - - for( int index = 0; index < NUMDIMS; ++index ) - { - ELEMTYPEREAL halfExtent = - ( (ELEMTYPEREAL) a_rect->m_max[index] - (ELEMTYPEREAL) a_rect->m_min[index] ) * 0.5f; - sumOfSquares += halfExtent * halfExtent; - } - - radius = (ELEMTYPEREAL) sqrt( sumOfSquares ); - - // Pow maybe slow, so test for common dims like 2,3 and just use x*x, x*x*x. - if( NUMDIMS == 3 ) - { - return radius * radius * radius * m_unitSphereVolume; - } - else if( NUMDIMS == 2 ) - { - return radius * radius * m_unitSphereVolume; - } - else - { - return (ELEMTYPEREAL) (pow( radius, NUMDIMS ) * m_unitSphereVolume); - } -} - - -// Use one of the methods to calculate retangle volume -RTREE_TEMPLATE -ELEMTYPEREAL RTREE_QUAL::CalcRectVolume( Rect* a_rect ) -{ -#ifdef RTREE_USE_SPHERICAL_VOLUME - return RectSphericalVolume( a_rect ); // Slower but helps certain merge cases -#else // RTREE_USE_SPHERICAL_VOLUME - return RectVolume( a_rect ); // Faster but can cause poor merges -#endif // RTREE_USE_SPHERICAL_VOLUME -} - - -// Load branch buffer with branches from full node plus the extra branch. -RTREE_TEMPLATE -void RTREE_QUAL::GetBranches( Node* a_node, Branch* a_branch, PartitionVars* a_parVars ) -{ - ASSERT( a_node ); - ASSERT( a_branch ); - - ASSERT( a_node->m_count == MAXNODES ); - - // Load the branch buffer - for( int index = 0; index < MAXNODES; ++index ) - { - a_parVars->m_branchBuf[index] = a_node->m_branch[index]; - } - - a_parVars->m_branchBuf[MAXNODES] = *a_branch; - a_parVars->m_branchCount = MAXNODES + 1; - - // Calculate rect containing all in the set - a_parVars->m_coverSplit = a_parVars->m_branchBuf[0].m_rect; - - for( int index = 1; index < MAXNODES + 1; ++index ) - { - a_parVars->m_coverSplit = - CombineRect( &a_parVars->m_coverSplit, &a_parVars->m_branchBuf[index].m_rect ); - } - - a_parVars->m_coverSplitArea = CalcRectVolume( &a_parVars->m_coverSplit ); - - InitNode( a_node ); -} - - -// Method #0 for choosing a partition: -// As the seeds for the two groups, pick the two rects that would waste the -// most area if covered by a single rectangle, i.e. evidently the worst pair -// to have in the same group. -// Of the remaining, one at a time is chosen to be put in one of the two groups. -// The one chosen is the one with the greatest difference in area expansion -// depending on which group - the rect most strongly attracted to one group -// and repelled from the other. -// If one group gets too full (more would force other group to violate min -// fill requirement) then other group gets the rest. -// These last are the ones that can go in either group most easily. -RTREE_TEMPLATE -void RTREE_QUAL::ChoosePartition( PartitionVars* a_parVars, int a_minFill ) -{ - ASSERT( a_parVars ); - - ELEMTYPEREAL biggestDiff; - int group, chosen=0, betterGroup=0; - - InitParVars( a_parVars, a_parVars->m_branchCount, a_minFill ); - PickSeeds( a_parVars ); - - while( ( (a_parVars->m_count[0] + a_parVars->m_count[1]) < a_parVars->m_total ) - && ( a_parVars->m_count[0] < (a_parVars->m_total - a_parVars->m_minFill) ) - && ( a_parVars->m_count[1] < (a_parVars->m_total - a_parVars->m_minFill) ) ) - { - biggestDiff = (ELEMTYPEREAL) -1; - - for( int index = 0; indexm_total; ++index ) - { - if( !a_parVars->m_taken[index] ) - { - Rect* curRect = &a_parVars->m_branchBuf[index].m_rect; - Rect rect0 = CombineRect( curRect, &a_parVars->m_cover[0] ); - Rect rect1 = CombineRect( curRect, &a_parVars->m_cover[1] ); - ELEMTYPEREAL growth0 = CalcRectVolume( &rect0 ) - a_parVars->m_area[0]; - ELEMTYPEREAL growth1 = CalcRectVolume( &rect1 ) - a_parVars->m_area[1]; - ELEMTYPEREAL diff = growth1 - growth0; - - if( diff >= 0 ) - { - group = 0; - } - else - { - group = 1; - diff = -diff; - } - - if( diff > biggestDiff ) - { - biggestDiff = diff; - chosen = index; - betterGroup = group; - } - else if( (diff == biggestDiff) - && (a_parVars->m_count[group] < a_parVars->m_count[betterGroup]) ) - { - chosen = index; - betterGroup = group; - } - } - } - - Classify( chosen, betterGroup, a_parVars ); - } - - // If one group too full, put remaining rects in the other - if( (a_parVars->m_count[0] + a_parVars->m_count[1]) < a_parVars->m_total ) - { - if( a_parVars->m_count[0] >= a_parVars->m_total - a_parVars->m_minFill ) - { - group = 1; - } - else - { - group = 0; - } - - for( int index = 0; indexm_total; ++index ) - { - if( !a_parVars->m_taken[index] ) - { - Classify( index, group, a_parVars ); - } - } - } - - ASSERT( (a_parVars->m_count[0] + a_parVars->m_count[1]) == a_parVars->m_total ); - ASSERT( (a_parVars->m_count[0] >= a_parVars->m_minFill) - && (a_parVars->m_count[1] >= a_parVars->m_minFill) ); -} - - -// Copy branches from the buffer into two nodes according to the partition. -RTREE_TEMPLATE -void RTREE_QUAL::LoadNodes( Node* a_nodeA, Node* a_nodeB, PartitionVars* a_parVars ) -{ - ASSERT( a_nodeA ); - ASSERT( a_nodeB ); - ASSERT( a_parVars ); - - for( int index = 0; index < a_parVars->m_total; ++index ) - { - ASSERT( a_parVars->m_partition[index] == 0 || a_parVars->m_partition[index] == 1 ); - - if( a_parVars->m_partition[index] == 0 ) - { - AddBranch( &a_parVars->m_branchBuf[index], a_nodeA, NULL ); - } - else if( a_parVars->m_partition[index] == 1 ) - { - AddBranch( &a_parVars->m_branchBuf[index], a_nodeB, NULL ); - } - } -} - - -// Initialize a PartitionVars structure. -RTREE_TEMPLATE -void RTREE_QUAL::InitParVars( PartitionVars* a_parVars, int a_maxRects, int a_minFill ) -{ - ASSERT( a_parVars ); - - a_parVars->m_count[0] = a_parVars->m_count[1] = 0; - a_parVars->m_area[0] = a_parVars->m_area[1] = (ELEMTYPEREAL) 0; - a_parVars->m_total = a_maxRects; - a_parVars->m_minFill = a_minFill; - - for( int index = 0; index < a_maxRects; ++index ) - { - a_parVars->m_taken[index] = false; - a_parVars->m_partition[index] = -1; - } -} - - -RTREE_TEMPLATE -void RTREE_QUAL::PickSeeds( PartitionVars* a_parVars ) -{ - int seed0 = 0, seed1 = 0; // avoid compil complaint about uninitialized - ELEMTYPEREAL worst, waste; - ELEMTYPEREAL area[MAXNODES + 1]; - - for( int index = 0; indexm_total; ++index ) - { - area[index] = CalcRectVolume( &a_parVars->m_branchBuf[index].m_rect ); - } - - worst = -a_parVars->m_coverSplitArea - 1; - - for( int indexA = 0; indexA < a_parVars->m_total - 1; ++indexA ) - { - for( int indexB = indexA + 1; indexB < a_parVars->m_total; ++indexB ) - { - Rect oneRect = CombineRect( &a_parVars->m_branchBuf[indexA].m_rect, - &a_parVars->m_branchBuf[indexB].m_rect ); - waste = CalcRectVolume( &oneRect ) - area[indexA] - area[indexB]; - - if( waste > worst ) - { - worst = waste; - seed0 = indexA; - seed1 = indexB; - } - } - } - - Classify( seed0, 0, a_parVars ); - Classify( seed1, 1, a_parVars ); -} - - -// Put a branch in one of the groups. -RTREE_TEMPLATE -void RTREE_QUAL::Classify( int a_index, int a_group, PartitionVars* a_parVars ) -{ - ASSERT( a_parVars ); - ASSERT( !a_parVars->m_taken[a_index] ); - - a_parVars->m_partition[a_index] = a_group; - a_parVars->m_taken[a_index] = true; - - if( a_parVars->m_count[a_group] == 0 ) - { - a_parVars->m_cover[a_group] = a_parVars->m_branchBuf[a_index].m_rect; - } - else - { - a_parVars->m_cover[a_group] = CombineRect( &a_parVars->m_branchBuf[a_index].m_rect, - &a_parVars->m_cover[a_group] ); - } - - a_parVars->m_area[a_group] = CalcRectVolume( &a_parVars->m_cover[a_group] ); - ++a_parVars->m_count[a_group]; -} - - -// Delete a data rectangle from an index structure. -// Pass in a pointer to a Rect, the tid of the record, ptr to ptr to root node. -// Returns 1 if record not found, 0 if success. -// RemoveRect provides for eliminating the root. -RTREE_TEMPLATE -bool RTREE_QUAL::RemoveRect( Rect* a_rect, const DATATYPE& a_id, Node** a_root ) -{ - ASSERT( a_rect && a_root ); - ASSERT( *a_root ); - - Node* tempNode; - ListNode* reInsertList = NULL; - - if( !RemoveRectRec( a_rect, a_id, *a_root, &reInsertList ) ) - { - // Found and deleted a data item - // Reinsert any branches from eliminated nodes - while( reInsertList ) - { - tempNode = reInsertList->m_node; - - for( int index = 0; index < tempNode->m_count; ++index ) - { - InsertRect( &(tempNode->m_branch[index].m_rect), - tempNode->m_branch[index].m_data, - a_root, - tempNode->m_level ); - } - - ListNode* remLNode = reInsertList; - reInsertList = reInsertList->m_next; - - FreeNode( remLNode->m_node ); - FreeListNode( remLNode ); - } - - // Check for redundant root (not leaf, 1 child) and eliminate - if( (*a_root)->m_count == 1 && (*a_root)->IsInternalNode() ) - { - tempNode = (*a_root)->m_branch[0].m_child; - - ASSERT( tempNode ); - FreeNode( *a_root ); - *a_root = tempNode; - } - - return false; - } - else - { - return true; - } -} - - -// Delete a rectangle from non-root part of an index structure. -// Called by RemoveRect. Descends tree recursively, -// merges branches on the way back up. -// Returns 1 if record not found, 0 if success. -RTREE_TEMPLATE -bool RTREE_QUAL::RemoveRectRec( Rect* a_rect, - const DATATYPE& a_id, - Node* a_node, - ListNode** a_listNode ) -{ - ASSERT( a_rect && a_node && a_listNode ); - ASSERT( a_node->m_level >= 0 ); - - if( a_node->IsInternalNode() ) // not a leaf node - { - for( int index = 0; index < a_node->m_count; ++index ) - { - if( Overlap( a_rect, &(a_node->m_branch[index].m_rect) ) ) - { - if( !RemoveRectRec( a_rect, a_id, a_node->m_branch[index].m_child, a_listNode ) ) - { - if( a_node->m_branch[index].m_child->m_count >= MINNODES ) - { - // child removed, just resize parent rect - a_node->m_branch[index].m_rect = - NodeCover( a_node->m_branch[index].m_child ); - } - else - { - // child removed, not enough entries in node, eliminate node - ReInsert( a_node->m_branch[index].m_child, a_listNode ); - DisconnectBranch( a_node, index ); // Must return after this call as count has changed - } - - return false; - } - } - } - - return true; - } - else // A leaf node - { - for( int index = 0; index < a_node->m_count; ++index ) - { - if( a_node->m_branch[index].m_child == (Node*) a_id ) - { - DisconnectBranch( a_node, index ); // Must return after this call as count has changed - return false; - } - } - - return true; - } -} - - -// Decide whether two rectangles overlap. -RTREE_TEMPLATE -bool RTREE_QUAL::Overlap( Rect* a_rectA, Rect* a_rectB ) -{ - ASSERT( a_rectA && a_rectB ); - - for( int index = 0; index < NUMDIMS; ++index ) - { - if( a_rectA->m_min[index] > a_rectB->m_max[index] - || a_rectB->m_min[index] > a_rectA->m_max[index] ) - { - return false; - } - } - - return true; -} - - -// Add a node to the reinsertion list. All its branches will later -// be reinserted into the index structure. -RTREE_TEMPLATE -void RTREE_QUAL::ReInsert( Node* a_node, ListNode** a_listNode ) -{ - ListNode* newListNode; - - newListNode = AllocListNode(); - newListNode->m_node = a_node; - newListNode->m_next = *a_listNode; - *a_listNode = newListNode; -} - - -// Search in an index tree or subtree for all data retangles that overlap the argument rectangle. -RTREE_TEMPLATE -bool RTREE_QUAL::Search( Node* a_node, Rect* a_rect, int& a_foundCount, bool a_resultCallback( - DATATYPE a_data, - void* a_context ), void* a_context ) -{ - ASSERT( a_node ); - ASSERT( a_node->m_level >= 0 ); - ASSERT( a_rect ); - - if( a_node->IsInternalNode() ) // This is an internal node in the tree - { - for( int index = 0; index < a_node->m_count; ++index ) - { - if( Overlap( a_rect, &a_node->m_branch[index].m_rect ) ) - { - if( !Search( a_node->m_branch[index].m_child, a_rect, a_foundCount, - a_resultCallback, a_context ) ) - { - return false; // Don't continue searching - } - } - } - } - else // This is a leaf node - { - for( int index = 0; index < a_node->m_count; ++index ) - { - if( Overlap( a_rect, &a_node->m_branch[index].m_rect ) ) - { - DATATYPE& id = a_node->m_branch[index].m_data; - - // NOTE: There are different ways to return results. Here's where to modify - if( &a_resultCallback ) - { - ++a_foundCount; - - if( !a_resultCallback( id, a_context ) ) - { - return false; // Don't continue searching - } - } - } - } - } - - return true; // Continue searching -} - - -#undef RTREE_TEMPLATE -#undef RTREE_QUAL -#undef RTREE_SEARCH_TEMPLATE -#undef RTREE_SEARCH_QUAL - -#endif // RTREE_H diff --git a/include/sch_item_struct.h b/include/sch_item_struct.h index 788ef66160..e425e1d6b1 100644 --- a/include/sch_item_struct.h +++ b/include/sch_item_struct.h @@ -34,9 +34,6 @@ #include #include -using namespace std; - - class SCH_ITEM; class SCH_SHEET_PATH; class LINE_READER; @@ -49,7 +46,7 @@ class NETLIST_OBJECT_LIST; typedef boost::ptr_vector< SCH_ITEM > SCH_ITEMS; typedef SCH_ITEMS::iterator SCH_ITEMS_ITR; -typedef vector< SCH_ITEMS_ITR > SCH_ITEMS_ITRS; +typedef std::vector< SCH_ITEMS_ITR > SCH_ITEMS_ITRS; #define FMT_IU SCH_ITEM::FormatInternalUnits @@ -228,7 +225,7 @@ public: * * @param aItemList - List of DANGLING_END_ITEMS to add to. */ - virtual void GetEndPoints( vector< DANGLING_END_ITEM >& aItemList ) {} + virtual void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) {} /** * Function IsDanglingStateChanged @@ -243,7 +240,7 @@ public: * @param aItemList - List of items to test item against. * @return True if the dangling state has changed from it's current setting. */ - virtual bool IsDanglingStateChanged( vector< DANGLING_END_ITEM >& aItemList ) { return false; } + virtual bool IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList ) { return false; } virtual bool IsDangling() const { return false; } @@ -273,7 +270,7 @@ public: * * @param aPoints List of connection points to add to. */ - virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const { } + virtual void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const { } /** * Function ClearConnections diff --git a/include/tool/examples/coroutine_example.cpp b/include/tool/examples/coroutine_example.cpp index 64fbcdc518..c36de8bbef 100644 --- a/include/tool/examples/coroutine_example.cpp +++ b/include/tool/examples/coroutine_example.cpp @@ -3,8 +3,6 @@ #include -using namespace std; - typedef COROUTINE MyCoroutine; class MyClass diff --git a/include/tool/examples/delegate_example.cpp b/include/tool/examples/delegate_example.cpp index b01a5caeea..3d3c7829a3 100644 --- a/include/tool/examples/delegate_example.cpp +++ b/include/tool/examples/delegate_example.cpp @@ -3,8 +3,6 @@ #include -using namespace std; - class MyClass { public: diff --git a/include/utf8.h b/include/utf8.h new file mode 100644 index 0000000000..4f5bf6d856 --- /dev/null +++ b/include/utf8.h @@ -0,0 +1,203 @@ +#ifndef UTF8_H_ +#define UTF8_H_ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 2013 KiCad Developers, see CHANGELOG.TXT for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include + +/** + * Class UTF8 + * is an 8 bit std::string that is assuredly encoded in UTF8, and supplies special + * conversion support to and from wxString, and has iteration over unicode characters. + * + *

    I've been careful to supply only conversion facilities and not try + * and duplicate wxString() with many member functions. In the end it is + * to be a std::string. There are multiple ways to create text into a std::string + * without the need of too many member functions: + * + *

      + *
    • richio.h's StrPrintf()
    • + *
    • std::ostringstream.
    • + *
    + * + *

    Because this class used no virtuals, it should be possible to cast any + * std::string into a UTF8 using this kind of cast: (UTF8 &) without construction + * or copying being the effect of the cast. Be sure the source std::string holds + * UTF8 encoded text before you do that. + * + * @author Dick Hollenbeck + */ +class UTF8 : public std::string +{ +public: + + UTF8( const wxString& o ); + + /// This is the only constructor for which you could end up with + /// non-UTF8 encoding, but that would be your fault. + UTF8( const char* txt ) : + std::string( txt ) + { + } + + /// For use with _() function on wx 2.8: + UTF8( const wchar_t* txt ); + + explicit UTF8( const std::string& o ) : + std::string( o ) + { + } + + UTF8() : + std::string() + { + } + + UTF8& operator=( const wxString& o ); + + UTF8& operator=( const std::string& o ) + { + std::string::operator=( o ); + return *this; + } + + operator wxString () const; + + /// This one is not in std::string, and one wonders why... might be a solid + /// enough reason to remove it still. + operator char* () const + { + return (char*) c_str(); + } + + /** + * Function uni_forward + * advances over a single UTF8 encoded multibyte character, capturing the + * unicode character as it goes, and returning the number of bytes consumed. + * + * @param aSequence is the UTF8 byte sequence, must be aligned on start of character. + * @param aResult is where to put the unicode character, and may be NULL if no interest. + * @return int - the count of bytes consumed. + */ + static int uni_forward( const unsigned char* aSequence, unsigned* aResult = NULL ); + + /** + * class uni_iter + * is a non-muting iterator that walks through unicode code points in the UTF8 encoded + * string. The normal ++(), ++(int), ->(), and *() operators are all supported + * for read only access and they return an unsigned holding the unicode character + * appropriate for the respective operator. + */ + class uni_iter + { + friend class UTF8; + + const unsigned char* it; + + // private constructor. + uni_iter( const char* start ) : + it( (const unsigned char*) start ) + { + // for the human: assert( sizeof(unsigned) >= 4 ); + } + + + public: + + uni_iter( const uni_iter& o ) + { + it = o.it; + } + + /// pre-increment and return uni_iter at new position + const uni_iter& operator++() + { + it += uni_forward( it ); + + return *this; + } + + /// post-increment and return uni_iter at initial position + uni_iter operator++( int ) + { + uni_iter ret = *this; + + it += uni_forward( it ); + return ret; + } + + /* + /// return unicode at current position + unsigned operator->() const + { + unsigned result; + + // grab the result, do not advance + uni_forward( it, &result ); + return result; + } + */ + + /// return unicode at current position + unsigned operator*() const + { + unsigned result; + + // grab the result, do not advance + uni_forward( it, &result ); + return result; + } + + bool operator==( const uni_iter& other ) const { return it == other.it; } + bool operator!=( const uni_iter& other ) const { return it != other.it; } + + /// Since the ++ operators advance more than one byte, this is your best + /// loop termination test, < end(), not == end(). + bool operator< ( const uni_iter& other ) const { return it < other.it; } + bool operator<=( const uni_iter& other ) const { return it <= other.it; } + bool operator> ( const uni_iter& other ) const { return it > other.it; } + bool operator>=( const uni_iter& other ) const { return it >= other.it; } + }; + + /** + * Function ubegin + * returns a @a uni_iter initialized to the start of "this" UTF8 byte sequence. + */ + uni_iter ubegin() const + { + return uni_iter( data() ); + } + + /** + * Function uend + * returns a @a uni_iter initialized to the end of "this" UTF8 byte sequence. + */ + uni_iter uend() const + { + return uni_iter( data() + size() ); + } +}; + +#endif // UTF8_H__ diff --git a/include/view/view_rtree.h b/include/view/view_rtree.h index 973ac7943e..b9ddb58a4b 100644 --- a/include/view/view_rtree.h +++ b/include/view/view_rtree.h @@ -27,7 +27,7 @@ #include -#include +#include namespace KIGFX { @@ -76,7 +76,6 @@ public: * Executes a function object aVisitor for each item whose bounding box intersects * with aBounds. */ - template void Query( const BOX2I& aBounds, Visitor& aVisitor ) // const { diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 33ab87d567..f85395da93 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -87,6 +87,9 @@ class PCB_EDIT_FRAME : public PCB_BASE_FRAME /// The global footprint library table. FP_LIB_TABLE* m_globalFootprintTable; + /// User defined rotation angle (in tenths of a degree). + int m_rotationAngle; + /** * Function loadFootprints * loads the footprints for each #COMPONENT in \a aNetlist from the list of libraries. @@ -330,6 +333,9 @@ public: */ virtual void SetGridColor(EDA_COLOR_T aColor); + int GetRotationAngle() const { return m_rotationAngle; } + void SetRotationAngle( int aRotationAngle ); + // Configurations: void InstallConfigFrame(); void Process_Config( wxCommandEvent& event ); diff --git a/include/wxstruct.h b/include/wxstruct.h index 5b91ee655d..b26dfeeca2 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -136,6 +136,8 @@ protected: /// The timer used to implement the auto save feature; wxTimer* m_autoSaveTimer; + wxString m_perspective; ///< wxAuiManager perspective. + /** * Function onAutoSaveTimer * handles the auto save timer event. diff --git a/kicad/dialogs/dialog_template_selector.h b/kicad/dialogs/dialog_template_selector.h index f4ea0f3229..2b59ea66c0 100644 --- a/kicad/dialogs/dialog_template_selector.h +++ b/kicad/dialogs/dialog_template_selector.h @@ -79,7 +79,7 @@ public: class DIALOG_TEMPLATE_SELECTOR : public DIALOG_TEMPLATE_SELECTOR_BASE { protected: - vector m_panels; + std::vector m_panels; void AddTemplate( int aPage, PROJECT_TEMPLATE* aTemplate ); TEMPLATE_WIDGET* m_selectedWidget; diff --git a/kicad/project_template.cpp b/kicad/project_template.cpp index 125f6896e6..5ac5db4ff6 100644 --- a/kicad/project_template.cpp +++ b/kicad/project_template.cpp @@ -33,8 +33,6 @@ #include #include -using namespace std; - #define SEP() wxFileName::GetPathSeparator() @@ -71,9 +69,9 @@ PROJECT_TEMPLATE::PROJECT_TEMPLATE( const wxString& aPath ) metaIcon = new wxBitmap( templateMetaIconFile.GetFullPath(), wxBITMAP_TYPE_PNG ); } -vector PROJECT_TEMPLATE::GetFileList() +std::vector PROJECT_TEMPLATE::GetFileList() { - vector files; + std::vector files; wxString f = templateBasePath.GetPath(); wxArrayString allfiles; wxFileName p; @@ -122,8 +120,8 @@ bool PROJECT_TEMPLATE::CreateProject( wxFileName& aNewProjectPath ) { bool result = true; - vector srcFiles = GetFileList(); - vector dstFiles; + std::vector srcFiles = GetFileList(); + std::vector dstFiles; for( size_t i=0; i < srcFiles.size(); i++ ) { diff --git a/kicad/project_template.h b/kicad/project_template.h index 98234755a9..4ab96fac71 100644 --- a/kicad/project_template.h +++ b/kicad/project_template.h @@ -110,9 +110,6 @@ #include #include -using namespace std; - - /** * @brief A directory which contains information about the project template and does not get * copied. This define is the default filename for this directory @@ -200,7 +197,7 @@ public: * @brief Get a vector list of filenames for the template. The files are the source files, * and have not yet been through any renaming */ - vector GetFileList(); + std::vector GetFileList(); }; #endif diff --git a/new/sch_dir_lib_source.cpp b/new/sch_dir_lib_source.cpp index 8edf331bbb..5b3913d7ac 100644 --- a/new/sch_dir_lib_source.cpp +++ b/new/sch_dir_lib_source.cpp @@ -52,9 +52,6 @@ #include #include -#include -using namespace std; - #include using namespace SCH; diff --git a/new/sch_lib_table.cpp b/new/sch_lib_table.cpp index 1950371826..0e4fbb0903 100644 --- a/new/sch_lib_table.cpp +++ b/new/sch_lib_table.cpp @@ -31,7 +31,6 @@ #include -//using namespace std; // screws up Doxygen using namespace SCH; using namespace LT; // tokens, enum T for LIB_TABLE diff --git a/pcb_calculator/UnitSelector.cpp b/pcb_calculator/UnitSelector.cpp index dca045cab1..4ede6764fe 100644 --- a/pcb_calculator/UnitSelector.cpp +++ b/pcb_calculator/UnitSelector.cpp @@ -28,20 +28,20 @@ double UNIT_SELECTOR_LEN::GetUnitScale() { switch( GetCurrentSelection() ) { - case 0: return UNIT_MM; break; - case 1: return UNIT_MICRON; break; - case 2: return UNIT_CM; break; - case 3: return UNIT_MIL; break; - case 4: return UNIT_INCH; break; + case 0: return UNIT_MM; break; + case 1: return UNIT_MICRON; break; + case 2: return UNIT_CM; break; + case 3: return UNIT_MIL; break; + case 4: return UNIT_INCH; break; } return 1.0; } -UNIT_SELECTOR_FREQUENCY::UNIT_SELECTOR_FREQUENCY(wxWindow *parent, wxWindowID id, - const wxPoint& pos, const wxSize& size, - const wxArrayString& choices, long style ) - : UNIT_SELECTOR( parent, id, pos, size, choices, style ) +UNIT_SELECTOR_FREQUENCY::UNIT_SELECTOR_FREQUENCY( wxWindow *parent, wxWindowID id, + const wxPoint& pos, const wxSize& size, + const wxArrayString& choices, long style ): + UNIT_SELECTOR( parent, id, pos, size, choices, style ) { Append( _("GHz") ); Append( _("MHz") ); @@ -58,19 +58,19 @@ double UNIT_SELECTOR_FREQUENCY::GetUnitScale() { switch( GetCurrentSelection() ) { - case 0: return UNIT_GHZ; break; - case 1: return UNIT_MHZ; break; - case 2: return UNIT_KHZ; break; - case 3: return 1.0; break; + case 0: return UNIT_GHZ; + case 1: return UNIT_MHZ; + case 2: return UNIT_KHZ; + case 3: return 1.0; } return 1.0; } -UNIT_SELECTOR_ANGLE::UNIT_SELECTOR_ANGLE(wxWindow *parent, wxWindowID id, - const wxPoint& pos, const wxSize& size, - const wxArrayString& choices, long style ) - : UNIT_SELECTOR( parent, id, pos, size, choices, style ) +UNIT_SELECTOR_ANGLE::UNIT_SELECTOR_ANGLE( wxWindow *parent, wxWindowID id, + const wxPoint& pos, const wxSize& size, + const wxArrayString& choices, long style ) : + UNIT_SELECTOR( parent, id, pos, size, choices, style ) { Append( _("Radian") ); Append( _("Degree") ); @@ -85,8 +85,8 @@ double UNIT_SELECTOR_ANGLE::GetUnitScale() { switch( GetCurrentSelection() ) { - case 0: return UNIT_RADIAN; break; - case 1: return UNIT_DEGREE; break; + case 0: return UNIT_RADIAN; break; + case 1: return UNIT_DEGREE; break; } return 1.0; } @@ -111,8 +111,8 @@ double UNIT_SELECTOR_RESISTOR::GetUnitScale() { switch( GetCurrentSelection() ) { - case 0: return UNIT_OHM; break; - case 1: return UNIT_KOHM; break; + case 0: return UNIT_OHM; break; + case 1: return UNIT_KOHM; break; } return 1.0; } diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 770554f2c0..e33f3327a4 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -372,13 +372,14 @@ if( KICAD_SCRIPTING_MODULES ) polygon bitmaps gal - ${GLEW_LIBRARIES} - ${CAIRO_LIBRARIES} + ${GLEW_LIBRARIES} + ${CAIRO_LIBRARIES} ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES} ${GDI_PLUS_LIBRARIES} ${PYTHON_LIBRARIES} ${PCBNEW_EXTRA_LIBS} + ${Boost_LIBRARIES} # must follow GITHUB ) # create .i files from XML doxygen parsing, docstrings.i will include all of them @@ -548,20 +549,21 @@ target_link_libraries( pcbnew ${GDI_PLUS_LIBRARIES} ${PYTHON_LIBRARIES} ${PCBNEW_EXTRA_LIBS} - ${GLEW_LIBRARIES} - ${CAIRO_LIBRARIES} + ${GLEW_LIBRARIES} + ${CAIRO_LIBRARIES} + ${Boost_LIBRARIES} # must follow GITHUB ) # Only for win32 cross compilation using MXE if( WIN32 AND MSYS AND CMAKE_CROSSCOMPILING ) -target_link_libraries(pcbnew - opengl32 - glu32 - pixman-1 - fontconfig - freetype - bz2 - ) +target_link_libraries( pcbnew + opengl32 + glu32 + pixman-1 + fontconfig + freetype + bz2 + ) endif() if( MAKE_LINK_MAPS ) diff --git a/pcbnew/board_undo_redo.cpp b/pcbnew/board_undo_redo.cpp index 85b8e5b194..25f0e10c00 100644 --- a/pcbnew/board_undo_redo.cpp +++ b/pcbnew/board_undo_redo.cpp @@ -575,13 +575,13 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed break; case UR_ROTATED: - item->Rotate( aList->m_TransformPoint, aRedoCommand ? 900 : -900 ); - item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); + item->Rotate( aList->m_TransformPoint, + aRedoCommand ? m_rotationAngle : -m_rotationAngle ); break; case UR_ROTATED_CLOCKWISE: - item->Rotate( aList->m_TransformPoint, aRedoCommand ? -900 : 900 ); - item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); + item->Rotate( aList->m_TransformPoint, + aRedoCommand ? -m_rotationAngle : m_rotationAngle ); break; case UR_FLIPPED: diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 1885eb16c9..d2cb7868aa 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -473,9 +473,9 @@ void MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) msg = FROM_UTF8( bufcar ); aList.push_back( MSG_PANEL_ITEM( _( "Last Change" ), msg, BROWN ) ); - // display time stamp in schematic - msg.Printf( wxT( "%8.8lX" ), m_TimeStamp ); + // display schematic path aList.push_back( MSG_PANEL_ITEM( _( "Netlist path" ), m_Path, BROWN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), RED ) ); EDA_ITEM* PtStruct = m_Pads; diff --git a/pcbnew/dialogs/dialog_copper_zones.cpp b/pcbnew/dialogs/dialog_copper_zones.cpp index 1a4948bd8e..133749a9cf 100644 --- a/pcbnew/dialogs/dialog_copper_zones.cpp +++ b/pcbnew/dialogs/dialog_copper_zones.cpp @@ -446,7 +446,7 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aPromptForErrors, bool aUseExportab if( m_settings.m_ThermalReliefCopperBridge <= m_settings.m_ZoneMinThickness ) { DisplayError( this, - _( "Thermal relief spoke width is smaller than the minimum width." ) ); + _( "Thermal relief spoke must be greater than the minimum width." ) ); return false; } diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp index 0c38c9d0ac..66f3e7b7ef 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp @@ -1,13 +1,13 @@ -/****************************************************************************** - * Module editor: Dialog box for editing module properties in the pcb editor. * - ******************************************************************************/ +/** + * Module editor: Dialog for editing module properties in the pcb editor. + */ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2011 Jean-Pierre Charras - * Copyright (C) 2012 Dick Hollenbeck, dick@softplc.com - * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2013 Jean-Pierre Charras + * Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com + * Copyright (C) 2004-2013 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -266,6 +266,9 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties() m_ReferenceCtrl->SetValue( m_ReferenceCopy->GetText() ); m_ValueCtrl->SetValue( m_ValueCopy->GetText() ); + // Shows the footprint's schematic path. + m_textCtrlSheetPath->SetValue( m_CurrentModule->GetPath() ); + m_AttributsCtrl->SetItemToolTip( 0, _( "Use this attribute for most non SMD components\n" "Components with this option are not put in the footprint position list file" ) ); diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.cpp index c8b532004d..99efb9008e 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 8 2012) +// C++ code generated with wxFormBuilder (version Nov 6 2013) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -114,6 +114,15 @@ DIALOG_MODULE_BOARD_EDITOR_BASE::DIALOG_MODULE_BOARD_EDITOR_BASE( wxWindow* pare bSizerLeft->Add( fgSizerPos, 0, wxEXPAND|wxBOTTOM, 5 ); + m_TextSheetPath = new wxStaticText( m_PanelProperties, wxID_ANY, _("Sheet path:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_TextSheetPath->Wrap( -1 ); + bSizerLeft->Add( m_TextSheetPath, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_textCtrlSheetPath = new wxTextCtrl( m_PanelProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); + m_textCtrlSheetPath->SetToolTip( _("An unique ID (a time stamp) to identify the component.\nThis is an alternate identifier to the reference.") ); + + bSizerLeft->Add( m_textCtrlSheetPath, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + m_PanelPropertiesBoxSizer->Add( bSizerLeft, 1, wxEXPAND, 5 ); diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.fbp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.fbp index 9d1de2b965..131c722600 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.fbp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.fbp @@ -20,8 +20,10 @@ . 1 + 1 1 1 + UI 0 0 @@ -42,7 +44,7 @@ DIALOG_MODULE_BOARD_EDITOR_BASE - 499,561 + 499,591 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Module Properties @@ -95,7 +97,7 @@ 5 wxEXPAND | wxALL 1 - + 1 1 1 @@ -173,11 +175,11 @@ - + Properties 1 - + 1 1 1 @@ -251,25 +253,25 @@ - + m_PanelPropertiesBoxSizer wxHORIZONTAL none - + 5 wxEXPAND 1 - + bSizerLeft wxVERTICAL none - + 5 wxTOP|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -348,11 +350,11 @@ - + 5 wxEXPAND 0 - + bSizerRef wxHORIZONTAL @@ -538,11 +540,11 @@ - + 5 wxTOP|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -621,11 +623,11 @@ - + 5 wxEXPAND 0 - + bSizerVal wxHORIZONTAL @@ -811,11 +813,11 @@ - + 5 wxALL|wxEXPAND 0 - + 1 1 1 @@ -1165,11 +1167,11 @@ - + 5 wxTOP|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -1248,11 +1250,11 @@ - + 5 wxEXPAND|wxBOTTOM 0 - + 3 wxHORIZONTAL 1 @@ -1438,11 +1440,11 @@ - + 5 wxALIGN_CENTER_VERTICAL|wxRIGHT 0 - + 1 1 1 @@ -1695,11 +1697,11 @@ - + 5 wxALIGN_CENTER_VERTICAL|wxRIGHT 0 - + 1 1 1 @@ -1780,13 +1782,187 @@ + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Sheet path: + + 0 + + + 0 + + 1 + m_TextSheetPath + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_textCtrlSheetPath + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_READONLY + + 0 + An unique ID (a time stamp) to identify the component. This is an alternate identifier to the reference. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + 5 0 - + m_PropRightSizer wxVERTICAL @@ -1967,11 +2143,11 @@ - + 5 wxEXPAND 0 - + bSizerAttrib wxHORIZONTAL @@ -2158,11 +2334,11 @@ - + 5 wxEXPAND|wxALL 0 - + wxID_ANY Auto Place @@ -2372,11 +2548,11 @@ - + 5 wxEXPAND 1 - + bSizerMoveOpt wxVERTICAL @@ -2576,11 +2752,11 @@ - + 5 wxALL|wxEXPAND 0 - + wxID_ANY Local Settings @@ -2588,20 +2764,20 @@ wxVERTICAL none - + 5 wxEXPAND 0 - + bSizer11 wxVERTICAL none - + 5 wxEXPAND|wxALIGN_CENTER_HORIZONTAL 1 - + bSizer10 wxHORIZONTAL @@ -2864,11 +3040,11 @@ - + 5 wxEXPAND 1 - + 3 wxBOTH 1 @@ -4160,11 +4336,11 @@ - + 3D settings 0 - + 1 1 1 @@ -4238,16 +4414,16 @@ - + bSizerMain3D wxVERTICAL none - + 5 wxTOP|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -4326,11 +4502,11 @@ - + 5 wxALL|wxEXPAND 0 - + 1 1 1 @@ -4414,20 +4590,20 @@ - + 5 wxEXPAND 1 - + bLowerSizer3D wxHORIZONTAL none - + 5 wxALL|wxEXPAND 1 - + wxID_ANY 3D Scale and Position @@ -4435,20 +4611,20 @@ wxVERTICAL public - + 5 wxEXPAND 0 - + m_bSizerShapeScale wxVERTICAL protected - + 5 wxTOP|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -4529,20 +4705,20 @@ - + 5 wxEXPAND 0 - + m_bSizerShapeOffset wxVERTICAL protected - + 5 wxTOP|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -4623,20 +4799,20 @@ - + 5 wxEXPAND 0 - + m_bSizerShapeRotation wxVERTICAL protected - + 5 wxTOP|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -4719,20 +4895,20 @@ - + 5 wxALIGN_CENTER_VERTICAL 0 - + bSizer3DButtons wxVERTICAL none - + 5 wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND 0 - + 1 1 1 @@ -4816,11 +4992,11 @@ - + 5 wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND 0 - + 1 1 1 @@ -4904,11 +5080,11 @@ - + 5 wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND 0 - + 1 1 1 diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.h b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.h index 79806831cc..234f5b09f6 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.h +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 8 2012) +// C++ code generated with wxFormBuilder (version Nov 6 2013) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -75,6 +75,8 @@ class DIALOG_MODULE_BOARD_EDITOR_BASE : public DIALOG_SHIM wxStaticText* m_YPosLabel; wxTextCtrl* m_ModPositionY; wxStaticText* m_YPosUnit; + wxStaticText* m_TextSheetPath; + wxTextCtrl* m_textCtrlSheetPath; wxButton* m_buttonExchange; wxButton* m_buttonModuleEditor; wxRadioBox* m_AttributsCtrl; @@ -134,7 +136,7 @@ class DIALOG_MODULE_BOARD_EDITOR_BASE : public DIALOG_SHIM public: wxStaticBoxSizer* m_Sizer3DValues; - DIALOG_MODULE_BOARD_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Module Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 499,561 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_MODULE_BOARD_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Module Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 499,591 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_MODULE_BOARD_EDITOR_BASE(); }; diff --git a/pcbnew/dialogs/dialog_general_options.cpp b/pcbnew/dialogs/dialog_general_options.cpp index 0c4e43290b..3470426f2c 100644 --- a/pcbnew/dialogs/dialog_general_options.cpp +++ b/pcbnew/dialogs/dialog_general_options.cpp @@ -37,7 +37,7 @@ #include #include #include - +#include #include #include @@ -69,15 +69,9 @@ void DIALOG_GENERALOPTIONS::init() m_CursorShape->SetSelection( GetParent()->GetCursorShape() ? 1 : 0 ); - switch( g_RotationAngle ) - { - case 450: - m_RotationAngle->SetSelection( 0 ); - break; - - default: - m_RotationAngle->SetSelection( 1 ); - } + wxString rotationAngle; + rotationAngle.Printf( wxT( "%.1f" ), ((double)GetParent()->GetRotationAngle()) / 10.0 ); + m_RotationAngle->SetValue( RemoveTrailingZeros( rotationAngle ) ); wxString timevalue; timevalue << GetParent()->GetAutoSaveInterval() / 60; @@ -121,8 +115,7 @@ void DIALOG_GENERALOPTIONS::OnOkClick( wxCommandEvent& event ) GetParent()->SetCursorShape( m_CursorShape->GetSelection() ); GetParent()->SetAutoSaveInterval( m_SaveTime->GetValue() * 60 ); - - g_RotationAngle = 10 * wxAtoi( m_RotationAngle->GetStringSelection() ); + GetParent()->SetRotationAngle( wxRound( 10.0 * wxAtof( m_RotationAngle->GetValue() ) ) ); /* Updating the combobox to display the active layer. */ g_MaxLinksShowed = m_MaxShowLinks->GetValue(); diff --git a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.cpp b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.cpp index a368448e28..6a2daad28a 100644 --- a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.cpp +++ b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.cpp @@ -79,13 +79,10 @@ DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE::DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE( m_staticTextRotationAngle->Wrap( -1 ); fgSizer1->Add( m_staticTextRotationAngle, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - wxString m_RotationAngleChoices[] = { _("45"), _("90") }; - int m_RotationAngleNChoices = sizeof( m_RotationAngleChoices ) / sizeof( wxString ); - m_RotationAngle = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_RotationAngleNChoices, m_RotationAngleChoices, 0 ); - m_RotationAngle->SetSelection( 0 ); - m_RotationAngle->SetToolTip( _("Footprints rotation increment, for rotate menu or hot key.") ); + m_RotationAngle = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_RotationAngle->SetToolTip( _("Context menu and hot key footprint rotation increment.") ); - fgSizer1->Add( m_RotationAngle, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + fgSizer1->Add( m_RotationAngle, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 5 ); bMiddleLeftSizer->Add( fgSizer1, 0, wxEXPAND, 5 ); diff --git a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp index 715589dd05..e4b73b36fa 100644 --- a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp +++ b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.fbp @@ -831,9 +831,9 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALL + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT 0 - + 1 1 1 @@ -847,7 +847,6 @@ 1 0 - "45" "90" 1 1 @@ -865,6 +864,7 @@ 0 + 0 @@ -877,22 +877,21 @@ 1 Resizable - 0 1 0 - Footprints rotation increment, for rotate menu or hot key. + Context menu and hot key footprint rotation increment. wxFILTER_NONE wxDefaultValidator + - @@ -914,6 +913,10 @@ + + + + diff --git a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.h b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.h index e5eeb92afd..b66bb0c3f7 100644 --- a/pcbnew/dialogs/dialog_general_options_BoardEditor_base.h +++ b/pcbnew/dialogs/dialog_general_options_BoardEditor_base.h @@ -23,7 +23,7 @@ class DIALOG_SHIM; #include #include #include -#include +#include #include #include #include @@ -64,7 +64,7 @@ class DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE : public DIALOG_SHIM wxStaticText* m_staticTextautosave; wxSpinCtrl* m_SaveTime; wxStaticText* m_staticTextRotationAngle; - wxChoice* m_RotationAngle; + wxTextCtrl* m_RotationAngle; wxCheckBox* m_DrcOn; wxCheckBox* m_ShowGlobalRatsnest; wxCheckBox* m_ShowModuleRatsnest; diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index cf90c3fad9..a742523dbe 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -745,9 +745,9 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) // This is a simple rotation, no other editing in progress if( !GetCurItem()->IsMoving() ) - SaveCopyInUndoList( GetCurItem(), UR_ROTATED, ((MODULE*)GetCurItem())->GetPosition() ); + SaveCopyInUndoList( GetCurItem(), UR_CHANGED, ((MODULE*)GetCurItem())->GetPosition() ); - Rotate_Module( &dc, (MODULE*) GetCurItem(), g_RotationAngle, true ); + Rotate_Module( &dc, (MODULE*) GetCurItem(), m_rotationAngle, true ); break; case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE: @@ -773,10 +773,9 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) // This is a simple rotation, no other editing in progress if( !GetCurItem()->IsMoving() ) - SaveCopyInUndoList( GetCurItem(), UR_ROTATED_CLOCKWISE, - ((MODULE*)GetCurItem())->GetPosition() ); + SaveCopyInUndoList( GetCurItem(), UR_CHANGED, ((MODULE*)GetCurItem())->GetPosition() ); - Rotate_Module( &dc, (MODULE*) GetCurItem(), -g_RotationAngle, true ); + Rotate_Module( &dc, (MODULE*) GetCurItem(), -m_rotationAngle, true ); break; case ID_POPUP_PCB_CHANGE_SIDE_MODULE: diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 7d979fd584..77dfeea698 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -141,7 +141,6 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event ) { Clear_Pcb( true ); -#if defined( USE_FP_LIB_TABLE ) // Create a new empty footprint library table for the new board. delete m_footprintLibTable; m_footprintLibTable = new FP_LIB_TABLE( m_globalFootprintTable ); @@ -158,7 +157,6 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event ) wxFileName emptyFileName; FP_LIB_TABLE::SetProjectPathEnvVariable( emptyFileName ); -#endif wxFileName fn; fn.AssignCwd(); @@ -535,7 +533,6 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF GetChars( pcbFileName.GetFullPath() ) )) ) return false; -#if defined( USE_FP_LIB_TABLE ) // Save the project specific footprint library table. if( !m_footprintLibTable->IsEmpty( false ) ) { @@ -561,8 +558,6 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF } } } -#endif - } else { diff --git a/pcbnew/github/CMakeLists.txt b/pcbnew/github/CMakeLists.txt index 7228f0f504..34bf3c9cef 100644 --- a/pcbnew/github/CMakeLists.txt +++ b/pcbnew/github/CMakeLists.txt @@ -58,9 +58,9 @@ add_library( github_plugin github_plugin.cpp ) -# No, you don't get github without boost and openssl +# No, you don't get github without boost and openssl. Boost_LIBRARIES now moved up +# into CMakeLists.txt for pcbnew and cvpcb: target_link_libraries( github_plugin - ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ) diff --git a/pcbnew/github/github_plugin.cpp b/pcbnew/github/github_plugin.cpp index 8b2d31ca92..b552669381 100644 --- a/pcbnew/github/github_plugin.cpp +++ b/pcbnew/github/github_plugin.cpp @@ -157,9 +157,14 @@ MODULE* GITHUB_PLUGIN::FootprintLoad( const wxString& aLibraryPath, MODULE* local = PCB_IO::FootprintLoad( m_pretty_dir, aFootprintName, aProperties ); if( local ) - return local; - } + { + // It has worked, see /scripts/test_kicad_plugin.py. So this was not firing: + // wxASSERT( aFootprintName == FROM_UTF8( local->GetFPID().GetFootprintName().c_str() ) ); + // Moving it to higher API layer FP_LIB_TABLE::FootprintLoad(). + return local; + } + } string fp_name = TO_UTF8( aFootprintName ); @@ -178,13 +183,21 @@ MODULE* GITHUB_PLUGIN::FootprintLoad( const wxString& aLibraryPath, if( zis.OpenEntry( *entry ) ) { INPUTSTREAM_LINE_READER reader( &zis ); +#if 1 + // I am a PCB_IO derivative with my own PCB_PARSER + m_parser->SetLineReader( &reader ); // ownership not passed + + MODULE* ret = (MODULE*) m_parser->Parse(); +#else PCB_PARSER parser( &reader ); MODULE* ret = (MODULE*) parser.Parse(); +#endif // Dude, the footprint name comes from the file name in // a github library. Zero out the library name, we don't know it here. - // Caller always has to set the library nickname if it knows it. + // Some caller may set the library nickname, one such instance is + // FP_LIB_TABLE::FootprintLoad(). ret->SetFPID( fp_name ); return ret; diff --git a/pcbnew/gpcb_plugin.cpp b/pcbnew/gpcb_plugin.cpp index 3c294c9135..7585aad4f9 100644 --- a/pcbnew/gpcb_plugin.cpp +++ b/pcbnew/gpcb_plugin.cpp @@ -48,9 +48,6 @@ #include #include -using namespace std; - - /** * Definition for enabling and disabling footprint library trace output. See the * wxWidgets documentation on using the WXTRACE environment variable. @@ -118,7 +115,7 @@ class GPCB_FPL_CACHE_ITEM wxFileName m_file_name; ///< The the full file name and path of the footprint to cache. bool m_writable; ///< Writability status of the footprint file. wxDateTime m_mod_time; ///< The last file modified time stamp. - auto_ptr< MODULE > m_module; + std::auto_ptr m_module; public: GPCB_FPL_CACHE_ITEM( MODULE* aModule, const wxFileName& aFileName ); @@ -135,12 +132,19 @@ GPCB_FPL_CACHE_ITEM::GPCB_FPL_CACHE_ITEM( MODULE* aModule, const wxFileName& aFi m_module( aModule ) { m_file_name = aFileName; - m_mod_time.Now(); + + if( m_file_name.FileExists() ) + m_mod_time = m_file_name.GetModificationTime(); + else + m_mod_time.Now(); } bool GPCB_FPL_CACHE_ITEM::IsModified() const { + if( !m_file_name.FileExists() ) + return false; + return m_file_name.GetModificationTime() != m_mod_time; } @@ -207,9 +211,35 @@ public: void Remove( const wxString& aFootprintName ); - wxDateTime GetLibModificationTime(); + wxDateTime GetLibModificationTime() const; - bool IsModified(); + /** + * Function IsModified + * check if the footprint cache has been modified relative to \a aLibPath + * and \a aFootprintName. + * + * @param aLibPath is a path to test the current cache library path against. + * @param aFootprintName is the footprint name in the cache to test. If the footprint + * name is empty, the all the footprint files in the library are + * checked to see if they have been modified. + * @return true if the cache has been modified. + */ + bool IsModified( const wxString& aLibPath, + const wxString& aFootprintName = wxEmptyString ) const; + + /** + * Function IsPath + * checks if \a aPath is the same as the current cache path. + * + * This tests paths by converting \a aPath using the native separators. Internally + * #FP_CACHE stores the current path using native separators. This prevents path + * miscompares on Windows due to the fact that paths can be stored with / instead of \\ + * in the footprint library table. + * + * @param aPath is the library path to test against. + * @return true if \a aPath is the same as the cache path. + */ + bool IsPath( const wxString& aPath ) const; }; @@ -220,8 +250,11 @@ GPCB_FPL_CACHE::GPCB_FPL_CACHE( GPCB_PLUGIN* aOwner, const wxString& aLibraryPat } -wxDateTime GPCB_FPL_CACHE::GetLibModificationTime() +wxDateTime GPCB_FPL_CACHE::GetLibModificationTime() const { + if( !m_lib_path.DirExists() ) + return wxDateTime::Now(); + return m_lib_path.GetModificationTime(); } @@ -232,7 +265,7 @@ void GPCB_FPL_CACHE::Load() if( !dir.IsOpened() ) { - THROW_IO_ERROR( wxString::Format( _( "footprint library path <%s> does not exist" ), + THROW_IO_ERROR( wxString::Format( _( "footprint library path '%s' does not exist" ), m_lib_path.GetPath().GetData() ) ); } @@ -244,21 +277,16 @@ void GPCB_FPL_CACHE::Load() do { - wxFileName fn = fpFileName; - fn.SetPath( m_lib_path.GetPath() ); + wxFileName fn( m_lib_path.GetPath(), fpFileName ); // reader now owns fp, will close on exception or return FILE_LINE_READER reader( fn.GetFullPath() ); std::string name = TO_UTF8( fn.GetName() ); - MODULE* module = parseMODULE( &reader ); + MODULE* footprint = parseMODULE( &reader ); - // Set the module name to the file name sans path and extension. - if( module->Reference().GetText().IsEmpty() ) - { - module->Reference().SetText( fn.GetName() ); - } - - m_modules.insert( name, new GPCB_FPL_CACHE_ITEM( module, fn.GetName() ) ); + // The footprint name is the file name without the extension. + footprint->SetFPID( fn.GetName() ); + m_modules.insert( name, new GPCB_FPL_CACHE_ITEM( footprint, fn.GetName() ) ); } while( dir.GetNext( &fpFileName ) ); @@ -290,30 +318,57 @@ void GPCB_FPL_CACHE::Remove( const wxString& aFootprintName ) } -bool GPCB_FPL_CACHE::IsModified() +bool GPCB_FPL_CACHE::IsPath( const wxString& aPath ) const { - if( !m_lib_path.DirExists() ) + // Converts path separators to native path separators + wxFileName newPath; + newPath.AssignDir( aPath ); + + return m_lib_path == newPath; +} + + +bool GPCB_FPL_CACHE::IsModified( const wxString& aLibPath, const wxString& aFootprintName ) const +{ + // The library is modified if the library path got deleted or changed. + if( !m_lib_path.DirExists() || !IsPath( aLibPath ) ) return true; - for( MODULE_ITER it = m_modules.begin(); it != m_modules.end(); ++it ) + // If no footprint was specified, check every file modification time against the time + // it was loaded. + if( aFootprintName.IsEmpty() ) { - wxFileName fn = it->second->GetFileName(); - - if( !fn.FileExists() ) + for( MODULE_CITER it = m_modules.begin(); it != m_modules.end(); ++it ) { - wxLogTrace( traceFootprintLibrary, wxT( "Footprint cache file '%s' does not exist." ), - fn.GetFullPath().GetData() ); - return true; - } + wxFileName fn = m_lib_path; - if( it->second->IsModified() ) - { - wxLogTrace( traceFootprintLibrary, - wxT( "Footprint cache file '%s' has been modified." ), - fn.GetFullPath().GetData() ); - return true; + fn.SetName( it->second->GetFileName().GetName() ); + fn.SetExt( KiCadFootprintFileExtension ); + + if( !fn.FileExists() ) + { + wxLogTrace( traceFootprintLibrary, + wxT( "Footprint cache file '%s' does not exist." ), + fn.GetFullPath().GetData() ); + return true; + } + + if( it->second->IsModified() ) + { + wxLogTrace( traceFootprintLibrary, + wxT( "Footprint cache file '%s' has been modified." ), + fn.GetFullPath().GetData() ); + return true; + } } } + else + { + MODULE_CITER it = m_modules.find( TO_UTF8( aFootprintName ) ); + + if( it == m_modules.end() || it->second->IsModified() ) + return true; + } return false; } @@ -327,13 +382,13 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader ) throw( IO_ERROR, // Old version unit = 1 mil, so conv_unit is 10 or 0.1 #define NEW_GPCB_UNIT_CONV ( 0.01*IU_PER_MILS ) - int paramCnt; - double conv_unit = NEW_GPCB_UNIT_CONV; // GPCB unit = 0.01 mils and Pcbnew 0.1 - wxPoint refPos( 0, 0 ); - wxPoint textPos; - wxString msg; - wxArrayString parameters; - auto_ptr< MODULE > module( new MODULE( NULL ) ); + int paramCnt; + double conv_unit = NEW_GPCB_UNIT_CONV; // GPCB unit = 0.01 mils and Pcbnew 0.1 + wxPoint refPos( 0, 0 ); + wxPoint textPos; + wxString msg; + wxArrayString parameters; + std::auto_ptr module( new MODULE( NULL ) ); if( aLineReader->ReadLine() == NULL ) @@ -811,9 +866,9 @@ void GPCB_PLUGIN::init( const PROPERTIES* aProperties ) } -void GPCB_PLUGIN::cacheLib( const wxString& aLibraryPath ) +void GPCB_PLUGIN::cacheLib( const wxString& aLibraryPath, const wxString& aFootprintName ) { - if( !m_cache || m_cache->GetPath() != aLibraryPath || m_cache->IsModified() ) + if( !m_cache || m_cache->IsModified( aLibraryPath, aFootprintName ) ) { // a spectacular episode in memory management: delete m_cache; @@ -823,23 +878,44 @@ void GPCB_PLUGIN::cacheLib( const wxString& aLibraryPath ) } -wxArrayString GPCB_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, - const PROPERTIES* aProperties ) +wxArrayString GPCB_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, + const PROPERTIES* aProperties ) { - LOCALE_IO toggle; // toggles on, then off, the C locale. + LOCALE_IO toggle; // toggles on, then off, the C locale. + wxArrayString ret; + wxDir dir( aLibraryPath ); + + if( !dir.IsOpened() ) + { + THROW_IO_ERROR( wxString::Format( _( "footprint library path '%s' does not exist" ), + GetChars( aLibraryPath ) ) ); + } init( aProperties ); +#if 1 // Set to 0 to only read directory contents, not load cache. cacheLib( aLibraryPath ); const MODULE_MAP& mods = m_cache->GetModules(); - wxArrayString ret; for( MODULE_CITER it = mods.begin(); it != mods.end(); ++it ) { ret.Add( FROM_UTF8( it->first.c_str() ) ); } +#else + wxString fpFileName; + wxString wildcard = wxT( "*." ) + GedaPcbFootprintLibFileExtension; + + if( dir.GetFirst( &fpFileName, wildcard, wxDIR_FILES ) ) + { + do + { + wxFileName fn( aLibraryPath, fpFileName ); + ret.Add( fn.GetName() ); + } while( dir.GetNext( &fpFileName ) ); + } +#endif return ret; } @@ -852,7 +928,7 @@ MODULE* GPCB_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString init( aProperties ); - cacheLib( aLibraryPath ); + cacheLib( aLibraryPath, aFootprintName ); const MODULE_MAP& mods = m_cache->GetModules(); @@ -868,7 +944,8 @@ MODULE* GPCB_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString } -void GPCB_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties ) +void GPCB_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName, + const PROPERTIES* aProperties ) { LOCALE_IO toggle; // toggles on, then off, the C locale. @@ -878,7 +955,7 @@ void GPCB_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& if( !m_cache->IsWritable() ) { - THROW_IO_ERROR( wxString::Format( _( "Library <%s> is read only" ), + THROW_IO_ERROR( wxString::Format( _( "Library '%s' is read only" ), aLibraryPath.GetData() ) ); } @@ -897,7 +974,7 @@ bool GPCB_PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const PROPER if( !fn.IsDirWritable() ) { - THROW_IO_ERROR( wxString::Format( _( "user does not have permission to delete directory <%s>" ), + THROW_IO_ERROR( wxString::Format( _( "user does not have permission to delete directory '%s'" ), aLibraryPath.GetData() ) ); } @@ -905,7 +982,7 @@ bool GPCB_PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const PROPER if( dir.HasSubDirs() ) { - THROW_IO_ERROR( wxString::Format( _( "library directory <%s> has unexpected sub-directories" ), + THROW_IO_ERROR( wxString::Format( _( "library directory '%s' has unexpected sub-directories" ), aLibraryPath.GetData() ) ); } @@ -924,7 +1001,7 @@ bool GPCB_PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const PROPER if( tmp.GetExt() != KiCadFootprintFileExtension ) { - THROW_IO_ERROR( wxString::Format( _( "unexpected file <%s> was found in library path '%s'" ), + THROW_IO_ERROR( wxString::Format( _( "unexpected file '%s' was found in library path '%s'" ), files[i].GetData(), aLibraryPath.GetData() ) ); } } @@ -942,7 +1019,7 @@ bool GPCB_PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const PROPER // we don't want that. we want bare metal portability with no UI here. if( !wxRmdir( aLibraryPath ) ) { - THROW_IO_ERROR( wxString::Format( _( "footprint library <%s> cannot be deleted" ), + THROW_IO_ERROR( wxString::Format( _( "footprint library '%s' cannot be deleted" ), aLibraryPath.GetData() ) ); } diff --git a/pcbnew/gpcb_plugin.h b/pcbnew/gpcb_plugin.h index b1fb4a9c72..4ae65563f9 100644 --- a/pcbnew/gpcb_plugin.h +++ b/pcbnew/gpcb_plugin.h @@ -62,12 +62,14 @@ public: return wxT( "fp" ); } - wxArrayString FootprintEnumerate( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL); + wxArrayString FootprintEnumerate( const wxString& aLibraryPath, + const PROPERTIES* aProperties = NULL); MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties = NULL ); - void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties = NULL ); + void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName, + const PROPERTIES* aProperties = NULL ); bool FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL ); @@ -83,17 +85,16 @@ public: protected: - wxString m_error; ///< for throwing exceptions - const PROPERTIES* m_props; ///< passed via Save() or Load(), no ownership, may be NULL. - GPCB_FPL_CACHE* m_cache; ///< Footprint library cache. - int m_ctl; - - LINE_READER* m_reader; ///< no ownership here. - wxString m_filename; ///< for saves only, name is in m_reader for loads + wxString m_error; ///< for throwing exceptions + const PROPERTIES* m_props; ///< passed via Save() or Load(), no ownership, may be NULL. + GPCB_FPL_CACHE* m_cache; ///< Footprint library cache. + int m_ctl; + LINE_READER* m_reader; ///< no ownership here. + wxString m_filename; ///< for saves only, name is in m_reader for loads private: /// we only cache one footprint library for now, this determines which one. - void cacheLib( const wxString& aLibraryPath ); + void cacheLib( const wxString& aLibraryPath, const wxString& aFootprintName = wxEmptyString ); void init( const PROPERTIES* aProperties ); }; diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index a50a299663..5a2caa377b 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -52,9 +52,6 @@ #include #include -using namespace std; - - #define FMTIU BOARD_ITEM::FormatInternalUnits /** @@ -78,7 +75,7 @@ class FP_CACHE_ITEM wxFileName m_file_name; ///< The the full file name and path of the footprint to cache. bool m_writable; ///< Writability status of the footprint file. wxDateTime m_mod_time; ///< The last file modified time stamp. - auto_ptr< MODULE > m_module; + std::auto_ptr m_module; public: FP_CACHE_ITEM( MODULE* aModule, const wxFileName& aFileName ); @@ -1691,22 +1688,44 @@ void PCB_IO::cacheLib( const wxString& aLibraryPath, const wxString& aFootprintN } -wxArrayString PCB_IO::FootprintEnumerate( const wxString& aLibraryPath, const PROPERTIES* aProperties ) +wxArrayString PCB_IO::FootprintEnumerate( const wxString& aLibraryPath, + const PROPERTIES* aProperties ) { - LOCALE_IO toggle; // toggles on, then off, the C locale. + LOCALE_IO toggle; // toggles on, then off, the C locale. + wxArrayString ret; + wxDir dir( aLibraryPath ); + + if( !dir.IsOpened() ) + { + THROW_IO_ERROR( wxString::Format( _( "footprint library path '%s' does not exist" ), + GetChars( aLibraryPath ) ) ); + } init( aProperties ); +#if 1 // Set to 0 to only read directory contents, not load cache. cacheLib( aLibraryPath ); const MODULE_MAP& mods = m_cache->GetModules(); - wxArrayString ret; for( MODULE_CITER it = mods.begin(); it != mods.end(); ++it ) { ret.Add( FROM_UTF8( it->first.c_str() ) ); } +#else + wxString fpFileName; + wxString wildcard = wxT( "*." ) + KiCadFootprintFileExtension; + + if( dir.GetFirst( &fpFileName, wildcard, wxDIR_FILES ) ) + { + do + { + wxFileName fn( aLibraryPath, fpFileName ); + ret.Add( fn.GetName() ); + } while( dir.GetNext( &fpFileName ) ); + } +#endif return ret; } diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index c941c00210..11afe8aa0f 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -409,6 +409,7 @@ void LEGACY_PLUGIN::checkVersion() void LEGACY_PLUGIN::loadGENERAL() { char* line; + char* saveptr; while( ( line = READLINE( m_reader ) ) != NULL ) { @@ -417,7 +418,7 @@ void LEGACY_PLUGIN::loadGENERAL() if( TESTLINE( "Units" ) ) { // what are the engineering units of the lengths in the BOARD? - data = strtok( line + SZ("Units"), delims ); + data = strtok_r( line + SZ("Units"), delims, &saveptr ); if( !strcmp( data, "mm" ) ) { @@ -520,6 +521,7 @@ void LEGACY_PLUGIN::loadSHEET() char buf[260]; TITLE_BLOCK tb; char* line; + char* saveptr; while( ( line = READLINE( m_reader ) ) != NULL ) { @@ -529,7 +531,7 @@ void LEGACY_PLUGIN::loadSHEET() // width and height are in 1/1000th of an inch, always PAGE_INFO page; - char* sname = strtok( line + SZ( "Sheet" ), delims ); + char* sname = strtok_r( line + SZ( "Sheet" ), delims, &saveptr ); if( sname ) { @@ -541,9 +543,9 @@ void LEGACY_PLUGIN::loadSHEET() THROW_IO_ERROR( m_error ); } - char* width = strtok( NULL, delims ); - char* height = strtok( NULL, delims ); - char* orient = strtok( NULL, delims ); + char* width = strtok_r( NULL, delims, &saveptr ); + char* height = strtok_r( NULL, delims, &saveptr ); + char* orient = strtok_r( NULL, delims, &saveptr ); // only parse the width and height if page size is custom ("User") if( wname == PAGE_INFO::Custom ) @@ -634,6 +636,7 @@ void LEGACY_PLUGIN::loadSETUP() BOARD_DESIGN_SETTINGS bds = m_board->GetDesignSettings(); ZONE_SETTINGS zs = m_board->GetZoneSettings(); char* line; + char* saveptr; while( ( line = READLINE( m_reader ) ) != NULL ) { @@ -671,13 +674,13 @@ void LEGACY_PLUGIN::loadSETUP() LAYER_NUM layer = layerParse( line + SZ( "Layer[" ), &data ); - data = strtok( (char*) data+1, delims ); // +1 for ']' + data = strtok_r( (char*) data+1, delims, &saveptr ); // +1 for ']' if( data ) { wxString layerName = FROM_UTF8( data ); m_board->SetLayerName( layer, layerName ); - data = strtok( NULL, delims ); + data = strtok_r( NULL, delims, &saveptr ); if( data ) // optional in old board files { LAYER_T type = LAYER::ParseType( data ); @@ -747,7 +750,7 @@ void LEGACY_PLUGIN::loadSETUP() BIU drill = 0; BIU diameter = biuParse( line + SZ( "ViaSizeList" ), &data ); - data = strtok( (char*) data, delims ); + data = strtok_r( (char*) data, delims, &saveptr ); if( data ) // DRILL may not be present ? drill = biuParse( data ); @@ -929,7 +932,8 @@ void LEGACY_PLUGIN::loadSETUP() void LEGACY_PLUGIN::LoadMODULE( MODULE* aModule ) { - char* line; + char* line; + char* saveptr; while( ( line = READLINE( m_reader ) ) != NULL ) { @@ -989,7 +993,7 @@ void LEGACY_PLUGIN::LoadMODULE( MODULE* aModule ) long edittime = hexParse( data, &data ); time_t timestamp = hexParse( data, &data ); - data = strtok( (char*) data+1, delims ); + data = strtok_r( (char*) data+1, delims, &saveptr ); // data is now a two character long string // Note: some old files do not have this field @@ -1061,7 +1065,7 @@ void LEGACY_PLUGIN::LoadMODULE( MODULE* aModule ) else if( TESTLINE( "AR" ) ) // Alternate Reference { // e.g. "AR /47BA2624/45525076" - data = strtok( line + SZ( "AR" ), delims ); + data = strtok_r( line + SZ( "AR" ), delims, &saveptr ); if( data ) aModule->SetPath( FROM_UTF8( data ) ); } @@ -1151,6 +1155,7 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule ) { auto_ptr pad( new D_PAD( aModule ) ); char* line; + char* saveptr; while( ( line = READLINE( m_reader ) ) != NULL ) { @@ -1239,17 +1244,17 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule ) PAD_SHAPE_T drShape = PAD_CIRCLE; - data = strtok( (char*) data, delims ); + data = strtok_r( (char*) data, delims, &saveptr ); if( data ) // optional shape { if( data[0] == 'O' ) { drShape = PAD_OVAL; - data = strtok( NULL, delims ); + data = strtok_r( NULL, delims, &saveptr ); drill_x = biuParse( data ); - data = strtok( NULL, delims ); + data = strtok_r( NULL, delims, &saveptr ); drill_y = biuParse( data ); } } @@ -1266,7 +1271,7 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule ) PAD_ATTR_T attribute; - data = strtok( line + SZ( "At" ), delims ); + data = strtok_r( line + SZ( "At" ), delims, &saveptr ); if( !strcmp( data, "SMD" ) ) attribute = PAD_SMD; @@ -1277,8 +1282,8 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule ) else attribute = PAD_STANDARD; - data = strtok( NULL, delims ); // skip BufCar - data = strtok( NULL, delims ); + data = strtok_r( NULL, delims, &saveptr ); // skip BufCar + data = strtok_r( NULL, delims, &saveptr ); LAYER_MSK layer_mask = hexParse( data ); @@ -1532,6 +1537,7 @@ void LEGACY_PLUGIN::loadMODULE_TEXT( TEXTE_MODULE* aText ) const char* data; const char* txt_end; const char* line = m_reader->Line(); // current (old) line + char* saveptr; // sscanf( line + 1, "%d %d %d %d %d %d %d %s %s %d %s", // &type, &m_Pos0.x, &m_Pos0.y, &m_Size.y, &m_Size.x, @@ -1571,14 +1577,14 @@ void LEGACY_PLUGIN::loadMODULE_TEXT( TEXTE_MODULE* aText ) // after switching to strtok, there's no easy coming back because of the // embedded nul(s?) placed to the right of the current field. // (that's the reason why strtok was deprecated...) - char* mirror = strtok( (char*) data, delims ); - char* hide = strtok( NULL, delims ); - char* tmp = strtok( NULL, delims ); + char* mirror = strtok_r( (char*) data, delims, &saveptr ); + char* hide = strtok_r( NULL, delims, &saveptr ); + char* tmp = strtok_r( NULL, delims, &saveptr ); LAYER_NUM layer = tmp ? layerParse( tmp ) : SILKSCREEN_N_FRONT; - char* italic = strtok( NULL, delims ); + char* italic = strtok_r( NULL, delims, &saveptr ); - char* hjust = strtok( (char*) txt_end, delims ); - char* vjust = strtok( NULL, delims ); + char* hjust = strtok_r( (char*) txt_end, delims, &saveptr ); + char* vjust = strtok_r( NULL, delims, &saveptr ); if( type != TEXTE_MODULE::TEXT_is_REFERENCE && type != TEXTE_MODULE::TEXT_is_VALUE ) @@ -1697,7 +1703,9 @@ void LEGACY_PLUGIN::loadPCB_LINE() */ auto_ptr dseg( new DRAWSEGMENT( m_board ) ); - char* line; + + char* line; + char* saveptr; while( ( line = READLINE( m_reader ) ) != NULL ) { @@ -1727,8 +1735,8 @@ void LEGACY_PLUGIN::loadPCB_LINE() BIU x = 0; BIU y; - data = strtok( line + SZ( "De" ), delims ); - for( int i = 0; data; ++i, data = strtok( NULL, delims ) ) + data = strtok_r( line + SZ( "De" ), delims, &saveptr ); + for( int i = 0; data; ++i, data = strtok_r( NULL, delims, &saveptr ) ) { switch( i ) { @@ -1864,7 +1872,8 @@ void LEGACY_PLUGIN::loadPCB_TEXT() TEXTE_PCB* pcbtxt = new TEXTE_PCB( m_board ); m_board->Add( pcbtxt, ADD_APPEND ); - char* line; + char* line; + char* saveptr; while( ( line = READLINE( m_reader ) ) != NULL ) { @@ -1928,9 +1937,9 @@ void LEGACY_PLUGIN::loadPCB_TEXT() LAYER_NUM layer = layerParse( line + SZ( "De" ), &data ); int notMirrored = intParse( data, &data ); time_t timestamp = hexParse( data, &data ); - char* style = strtok( (char*) data, delims ); - char* hJustify = strtok( NULL, delims ); - char* vJustify = strtok( NULL, delims ); + char* style = strtok_r( (char*) data, delims, &saveptr ); + char* hJustify = strtok_r( NULL, delims, &saveptr ); + char* vJustify = strtok_r( NULL, delims, &saveptr ); pcbtxt->SetMirrored( !notMirrored ); pcbtxt->SetTimeStamp( timestamp ); @@ -1968,6 +1977,7 @@ void LEGACY_PLUGIN::loadPCB_TEXT() void LEGACY_PLUGIN::loadTrackList( int aStructType ) { char* line; + char* saveptr; while( ( line = READLINE( m_reader ) ) != NULL ) { @@ -1993,7 +2003,7 @@ void LEGACY_PLUGIN::loadTrackList( int aStructType ) BIU width = biuParse( data, &data ); // optional 7th drill parameter (must be optional in an old format?) - data = strtok( (char*) data, delims ); + data = strtok_r( (char*) data, delims, &saveptr ); BIU drill = data ? biuParse( data ) : -1; // SetDefault() if < 0 @@ -2188,6 +2198,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER() bool sawCorner = false; char buf[1024]; char* line; + char* saveptr; while( ( line = READLINE( m_reader ) ) != NULL ) { @@ -2240,7 +2251,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER() { // e.g. "ZAux 7 E" int ignore = intParse( line + SZ( "ZAux" ), &data ); - char* hopt = strtok( (char*) data, delims ); + char* hopt = strtok_r( (char*) data, delims, &saveptr ); if( !hopt ) { @@ -2284,27 +2295,27 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER() { zc->SetIsKeepout( true ); // e.g. "ZKeepout tracks N vias N pads Y" - data = strtok( line + SZ( "ZKeepout" ), delims ); + data = strtok_r( line + SZ( "ZKeepout" ), delims, &saveptr ); while( data ) { if( !strcmp( data, "tracks" ) ) { - data = strtok( NULL, delims ); + data = strtok_r( NULL, delims, &saveptr ); zc->SetDoNotAllowTracks( data && *data == 'N' ); } else if( !strcmp( data, "vias" ) ) { - data = strtok( NULL, delims ); + data = strtok_r( NULL, delims, &saveptr ); zc->SetDoNotAllowVias( data && *data == 'N' ); } else if( !strcmp( data, "copperpour" ) ) { - data = strtok( NULL, delims ); + data = strtok_r( NULL, delims, &saveptr ); zc->SetDoNotAllowCopperPour( data && *data == 'N' ); } - data = strtok( NULL, delims ); + data = strtok_r( NULL, delims, &saveptr ); } } @@ -2335,7 +2346,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER() { // e.g. "ZClearance 40 I" BIU clearance = biuParse( line + SZ( "ZClearance" ), &data ); - char* padoption = strtok( (char*) data, delims ); // data: " I" + char* padoption = strtok_r( (char*) data, delims, &saveptr ); // data: " I" ZoneConnection popt; switch( *padoption ) @@ -2447,7 +2458,9 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER() void LEGACY_PLUGIN::loadDIMENSION() { auto_ptr dim( new DIMENSION( m_board ) ); - char* line; + + char* line; + char* saveptr; while( ( line = READLINE( m_reader ) ) != NULL ) { @@ -2504,7 +2517,7 @@ void LEGACY_PLUGIN::loadDIMENSION() BIU height = biuParse( data, &data ); BIU thickn = biuParse( data, &data ); double orient = degParse( data, &data ); - char* mirror = strtok( (char*) data, delims ); + char* mirror = strtok_r( (char*) data, delims, &saveptr ); // This sets both DIMENSION's position and internal m_Text's. // @todo: But why do we even know about internal m_Text? @@ -3962,6 +3975,7 @@ void LP_CACHE::Load() void LP_CACHE::ReadAndVerifyHeader( LINE_READER* aReader ) { char* line = aReader->ReadLine(); + char* saveptr; if( !line ) goto L_bad_library; @@ -3973,7 +3987,7 @@ void LP_CACHE::ReadAndVerifyHeader( LINE_READER* aReader ) { if( TESTLINE( "Units" ) ) { - const char* units = strtok( line + SZ( "Units" ), delims ); + const char* units = strtok_r( line + SZ( "Units" ), delims, &saveptr ); if( !strcmp( units, "mm" ) ) { diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index f1badcc0f5..ab4c32630b 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -57,25 +57,25 @@ #define FMT_OK_OVERWRITE _( "Library '%s' exists, OK to replace ?" ) #define FMT_CREATE_LIB _( "Create New Library" ) #define FMT_OK_DELETE _( "OK to delete module %s in library '%s'" ) -#define FMT_IMPORT_MODULE _( "Import Footprint Module" ) +#define FMT_IMPORT_MODULE _( "Import Footprint" ) #define FMT_FILE_NOT_FOUND _( "File '%s' not found" ) -#define FMT_NOT_MODULE _( "Not a module file" ) +#define FMT_NOT_MODULE _( "Not a footprint file" ) #define FMT_MOD_NOT_FOUND _( "Unable to find or load footprint %s from lib path '%s'" ) #define FMT_BAD_PATH _( "Unable to find or load footprint from path '%s'" ) #define FMT_BAD_PATHS _( "The footprint library '%s' could not be found in any of the search paths." ) #define FMT_LIB_READ_ONLY _( "Library '%s' is read only, not writable" ) -#define FMT_EXPORT_MODULE _( "Export Module" ) -#define FMT_SAVE_MODULE _( "Save Module" ) -#define FMT_MOD_REF _( "Module Reference:" ) -#define FMT_EXPORTED _( "Module exported to file '%s'" ) -#define FMT_MOD_DELETED _( "Module %s deleted from library '%s'" ) -#define FMT_MOD_CREATE _( "Module Creation" ) +#define FMT_EXPORT_MODULE _( "Export Footprint" ) +#define FMT_SAVE_MODULE _( "Save Footprint" ) +#define FMT_MOD_REF _( "Enter footprint name:" ) +#define FMT_EXPORTED _( "Footprint exported to file '%s'" ) +#define FMT_MOD_DELETED _( "Footprint %s deleted from library '%s'" ) +#define FMT_MOD_CREATE _( "New Footprint" ) -#define FMT_NO_MODULES _( "No modules to archive!" ) +#define FMT_NO_MODULES _( "No footprints to archive!" ) #define FMT_LIBRARY _( "Library" ) // window title -#define FMT_MOD_EXISTS _( "Module %s already exists in library '%s'" ) -#define FMT_NO_REF_ABORTED _( "No reference, aborted" ) +#define FMT_MOD_EXISTS _( "Footprint %s already exists in library '%s'" ) +#define FMT_NO_REF_ABORTED _( "No footprint name defined." ) #define FMT_SELECT_LIB _( "Select Library" ) @@ -464,8 +464,6 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary() bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary() { -#if defined(USE_FP_LIB_TABLE) - wxString nickname = getLibNickName(); if( !m_footprintLibTable->IsFootprintLibWritable( nickname ) ) @@ -509,48 +507,9 @@ bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary() SetStatusText( msg ); return true; - -#else - PCB_EDIT_FRAME* parent = (PCB_EDIT_FRAME*) GetParent(); - wxString libPath = getLibPath(); - wxString footprintName = PCB_BASE_FRAME::SelectFootprint( this, libPath, - wxEmptyString, wxEmptyString, - parent->GetFootprintLibraryTable() ); - - if( !footprintName ) - return false; - - // Confirmation - wxString msg = wxString::Format( FMT_OK_DELETE, footprintName.GetData(), libPath.GetData() ); - - if( !IsOK( this, msg ) ) - return false; - - IO_MGR::PCB_FILE_T pluginType = IO_MGR::GuessPluginTypeFromLibPath( libPath ); - - try - { - PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) ); - - pi->FootprintDelete( libPath, footprintName ); - } - catch( IO_ERROR ioe ) - { - DisplayError( NULL, ioe.errorText ); - return false; - } - - msg.Printf( FMT_MOD_DELETED, footprintName.GetData(), libPath.GetData() ); - - SetStatusText( msg ); - - return true; - -#endif } -#if defined(USE_FP_LIB_TABLE) void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aNewModulesOnly ) { if( GetBoard()->m_Modules == NULL ) @@ -608,90 +567,6 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aNewModulesOnly ) DisplayError( this, ioe.errorText ); } } -#else -void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aNewModulesOnly ) -{ - wxString fileName; - wxString path; - - if( GetBoard()->m_Modules == NULL ) - { - DisplayInfoMessage( this, FMT_NO_MODULES ); - return; - } - - path = wxGetApp().ReturnLastVisitedLibraryPath(); - - { - wxFileDialog dlg( this, FMT_LIBRARY, path, - wxEmptyString, - wxGetTranslation( LegacyFootprintLibPathWildcard ), - wxFD_SAVE ); - - if( dlg.ShowModal() == wxID_CANCEL ) - return; - - fileName = dlg.GetPath(); - } - - wxFileName fn( fileName ); - - wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() ); - - bool lib_exists = wxFileExists( fileName ); - - if( !aNewModulesOnly && lib_exists ) - { - wxString msg = wxString::Format( FMT_OK_OVERWRITE, GetChars( fileName ) ); - - if( !IsOK( this, msg ) ) - return; - } - - m_canvas->SetAbortRequest( false ); - - try - { - PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) ); - - // Delete old library if we're replacing it entirely. - if( lib_exists && !aNewModulesOnly ) - { - pi->FootprintLibDelete( fileName ); - lib_exists = false; - } - - if( !lib_exists ) - { - pi->FootprintLibCreate( fileName ); - } - - if( !aNewModulesOnly ) - { - for( MODULE* m = GetBoard()->m_Modules; m; m = m->Next() ) - { - pi->FootprintSave( fileName, m ); - } - } - else - { - for( MODULE* m = GetBoard()->m_Modules; m; m = m->Next() ) - { - if( !Save_Module_In_Library( fileName, m, false, false ) ) - break; - - // Check for request to stop backup (ESCAPE key actuated) - if( m_canvas->GetAbortRequest() ) - break; - } - } - } - catch( IO_ERROR ioe ) - { - DisplayError( this, ioe.errorText ); - } -} -#endif bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibrary, @@ -744,7 +619,6 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibrary, bool module_exists = false; -#if defined(USE_FP_LIB_TABLE) try { MODULE* m = m_footprintLibTable->FootprintLoad( aLibrary, footprintName ); @@ -774,45 +648,6 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibrary, // this always overwrites any existing footprint, but should yell on its // own if the library or footprint is not writable. m_footprintLibTable->FootprintSave( aLibrary, aModule ); - -#else - - - IO_MGR::PCB_FILE_T pluginType = IO_MGR::GuessPluginTypeFromLibPath( aLibrary ); - - try - { - PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) ); - - MODULE* m = pi->FootprintLoad( aLibrary, footprintName ); - - if( m ) - { - delete m; - - module_exists = true; - - // an existing footprint is found in current lib - if( aDisplayDialog ) - { - wxString msg = wxString::Format( FMT_MOD_EXISTS, - footprintName.GetData(), aLibrary.GetData() ); - - SetStatusText( msg ); - } - - if( !aOverwrite ) - { - // Do not save the given footprint: an old one exists - return true; - } - } - - // this always overwrites any existing footprint, but should yell on its - // own if the library or footprint is not writable. - pi->FootprintSave( aLibrary, aModule ); -#endif - } catch( IO_ERROR ioe ) { @@ -846,18 +681,16 @@ MODULE* PCB_BASE_FRAME::Create_1_Module( const wxString& aModuleName ) if( moduleName.IsEmpty() ) { wxTextEntryDialog dlg( this, FMT_MOD_REF, FMT_MOD_CREATE, moduleName ); - dlg.SetTextValidator( FOOTPRINT_NAME_VALIDATOR() ); + dlg.SetTextValidator( FOOTPRINT_NAME_VALIDATOR( &moduleName ) ); if( dlg.ShowModal() != wxID_OK ) return NULL; //Aborted by user - - moduleName = dlg.GetValue(); } moduleName.Trim( true ); moduleName.Trim( false ); - if( moduleName.IsEmpty( ) ) + if( moduleName.IsEmpty() ) { DisplayInfoMessage( this, FMT_NO_REF_ABORTED ); return NULL; @@ -892,50 +725,6 @@ MODULE* PCB_BASE_FRAME::Create_1_Module( const wxString& aModuleName ) } -#if !defined( USE_FP_LIB_TABLE ) - -wxString PCB_BASE_FRAME::SelectLibrary( const wxString& aNicknameExisting ) -{ - if( g_LibraryNames.GetCount() == 0 ) - return wxEmptyString; - - wxArrayString headers; - headers.Add( _( "Library" ) ); - - std::vector itemsToDisplay; - - // Conversion from wxArrayString to vector of ArrayString - for( unsigned i = 0; i < g_LibraryNames.GetCount(); i++ ) - { - wxArrayString item; - item.Add( g_LibraryNames[i] ); - itemsToDisplay.push_back( item ); - } - - EDA_LIST_DIALOG dlg( this, FMT_SELECT_LIB, headers, itemsToDisplay, aNicknameExisting ); - - if( dlg.ShowModal() != wxID_OK ) - return wxEmptyString; - - wxFileName fileName = wxFileName( wxEmptyString, dlg.GetTextSelection(), - LegacyFootprintLibPathExtension ); - - fileName = wxGetApp().FindLibraryPath( fileName ); - - if( !fileName.IsOk() || !fileName.FileExists() ) - { - wxString msg = wxString::Format( FMT_BAD_PATHS, GetChars( dlg.GetTextSelection() ) ); - - DisplayError( this, msg ); - - return wxEmptyString; - } - - return fileName.GetFullPath(); -} - -#else - wxString PCB_BASE_FRAME::SelectLibrary( const wxString& aNicknameExisting ) { wxArrayString headers; @@ -967,5 +756,3 @@ wxString PCB_BASE_FRAME::SelectLibrary( const wxString& aNicknameExisting ) return nickname; } - -#endif diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index a38c5aa9f9..85ae9335f8 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -138,13 +138,7 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser() if( !!fpname ) { -#if !defined( USE_FP_LIB_TABLE ) - // Returns the full fp name, i.e. the lib name and the fp name, - // separated by a '/' (/ is now an illegal char in fp names) - fpid = viewer->GetSelectedLibraryFullName() + wxT( "/" ) + fpname; -#else fpid = viewer->GetSelectedLibrary() + wxT( ":" ) + fpname; -#endif } viewer->Destroy(); @@ -179,13 +173,7 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary, { // SelectFootprintFromLibBrowser() returns the "full" footprint name, i.e. // / or FPID format "lib_name:fp_name:rev#" -#if !defined( USE_FP_LIB_TABLE ) - wxString full_fpname = SelectFootprintFromLibBrowser(); - moduleName = full_fpname.AfterLast( '/' ); - libName = full_fpname.BeforeLast( '/' ); -#else moduleName = SelectFootprintFromLibBrowser(); -#endif } else { @@ -223,9 +211,6 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary, } } -#if !defined( USE_FP_LIB_TABLE ) - module = GetModuleLibrary( libName, moduleName, false ); -#else FPID fpid; wxCHECK_MSG( fpid.Parse( moduleName ) < 0, NULL, @@ -241,7 +226,6 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary, wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ), fpid.Format().c_str(), GetChars( ioe.errorText ) ); } -#endif if( !module && allowWildSeach ) // Search with wild card { @@ -259,9 +243,6 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary, } else { -#if !defined( USE_FP_LIB_TABLE ) - module = GetModuleLibrary( libName, moduleName, true ); -#else FPID fpid; wxCHECK_MSG( fpid.Parse( moduleName ) < 0, NULL, @@ -277,7 +258,6 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary, wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ), fpid.Format().c_str(), GetChars( ioe.errorText ) ); } -#endif } } @@ -514,46 +494,16 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow, std::vector< wxArrayString > rows; -#if !defined( USE_FP_LIB_TABLE ) - - if( aLibraryName.IsEmpty() ) - { - libraries = g_LibraryNames; - } - else - { - libraries.Add( aLibraryName ); - } - - if( libraries.IsEmpty() ) - { - DisplayError( aWindow, _( "No footprint libraries were specified." ) ); - return wxEmptyString; - } - - MList.ReadFootprintFiles( libraries ); - -#else - wxASSERT( aTable != NULL ); - if( !MList.ReadFootprintFiles( aTable, !aLibraryName ? NULL : &aLibraryName ) ) + MList.ReadFootprintFiles( aTable, !aLibraryName ? NULL : &aLibraryName ); + + if( MList.GetErrorCount() ) { - msg.Format( _( "Error occurred attempting to load footprint library '%s':\n\n" ), - GetChars( aLibraryName ) ); - - if( !MList.m_filesNotFound.IsEmpty() ) - msg += _( "Files not found:\n\n" ) + MList.m_filesNotFound; - - if( !MList.m_filesInvalid.IsEmpty() ) - msg += _("\n\nFile load errors:\n\n" ) + MList.m_filesInvalid; - - DisplayError( this, msg ); + MList.DisplayErrors( this ); return wxEmptyString; } -#endif - if( MList.GetCount() == 0 ) { wxString tmp; @@ -574,7 +524,7 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow, { for( unsigned ii = 0; ii < MList.GetCount(); ii++ ) { - if( KeyWordOk( aKeyWord, MList.GetItem( ii ).m_KeyWord ) ) + if( KeyWordOk( aKeyWord, MList.GetItem( ii ).GetKeywords() ) ) { wxArrayString cols; cols.Add( MList.GetItem( ii ).GetFootprintName() ); @@ -587,7 +537,7 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow, { for( unsigned ii = 0; ii < MList.GetCount(); ii++ ) { - wxString& candidate = MList.GetItem( ii ).m_Module; + const wxString& candidate = MList.GetItem( ii ).GetFootprintName(); if( WildCompareString( aMask, candidate, false ) ) { @@ -624,9 +574,7 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow, { fpname = dlg.GetTextSelection(); -#if defined( USE_FP_LIB_TABLE ) fpname = dlg.GetTextSelection( 1 ) + wxT( ":" ) + fpname; -#endif SkipNextLeftButtonReleaseEvent(); } @@ -648,18 +596,18 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow, } -static void DisplayCmpDoc( wxString& Name ) +static void DisplayCmpDoc( wxString& aName ) { - FOOTPRINT_INFO* module_info = MList.GetModuleInfo( Name ); + FOOTPRINT_INFO* module_info = MList.GetModuleInfo( aName ); if( !module_info ) { - Name.Empty(); + aName.Empty(); return; } - Name = _( "Description: " ) + module_info->m_Doc; - Name += _( "\nKey words: " ) + module_info->m_KeyWord; + aName = _( "Description: " ) + module_info->GetDoc(); + aName += _( "\nKey words: " ) + module_info->GetKeywords(); } diff --git a/pcbnew/menubar_pcbframe.cpp b/pcbnew/menubar_pcbframe.cpp index 9db3c5e309..b905717490 100644 --- a/pcbnew/menubar_pcbframe.cpp +++ b/pcbnew/menubar_pcbframe.cpp @@ -142,8 +142,8 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() KiBitmap( tools_xpm ) ); AddMenuItem( fabricationOutputsMenu, ID_PCB_GEN_D356_FILE, - _( "IPC-D-356 Netlist File" ), - _( "Generate IPC-D-356 netlist file" ), + _( "IPC-D-356 Netlist File" ), + _( "Generate IPC-D-356 netlist file" ), KiBitmap( netlist_xpm ) ); // Component File @@ -462,15 +462,9 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() wxMenu* configmenu = new wxMenu; // Library -#if !defined( USE_FP_LIB_TABLE ) - AddMenuItem( configmenu, ID_CONFIG_REQ, - _( "Li&brary" ), _( "Setting libraries, directories and others..." ), - KiBitmap( library_xpm ) ); -#else AddMenuItem( configmenu, ID_PCB_LIB_TABLE_EDIT, _( "Li&brary Tables" ), _( "Setup footprint libraries" ), KiBitmap( library_table_xpm ) ); -#endif // Colors and Visibility are also handled by the layers manager toolbar AddMenuItem( configmenu, ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER_DIALOG, diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 25c24e1e5a..e4d13c9952 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -254,14 +254,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( library.size() ) { -#if defined(USE_FP_LIB_TABLE) setLibNickName( library ); -#else - wxFileName fileName( library ); - - setLibNickName( fileName.GetName() ); - setLibPath( fileName.GetFullPath() ); -#endif updateTitle(); } } @@ -364,19 +357,11 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_MODEDIT_SAVE_LIBMODULE: -#if defined(USE_FP_LIB_TABLE) if( GetBoard()->m_Modules && getLibNickName().size() ) { Save_Module_In_Library( getLibNickName(), GetBoard()->m_Modules, true, true ); GetScreen()->ClrModify(); } -#else - if( GetBoard()->m_Modules && getLibPath() != wxEmptyString ) - { - Save_Module_In_Library( getLibPath(), GetBoard()->m_Modules, true, true ); - GetScreen()->ClrModify(); - } -#endif break; case ID_MODEDIT_INSERT_MODULE_IN_BOARD: @@ -507,11 +492,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) Clear_Pcb( true ); SetCrossHairPosition( wxPoint( 0, 0 ) ); -#if !defined( USE_FP_LIB_TABLE ) - LoadModuleFromLibrary( getLibPath(), m_footprintLibTable, true ); -#else LoadModuleFromLibrary( getLibNickName(), m_footprintLibTable, true ); -#endif redraw = true; if( GetBoard()->m_Modules ) diff --git a/pcbnew/module_editor_frame.h b/pcbnew/module_editor_frame.h index 49682348e5..1c2a6128ed 100644 --- a/pcbnew/module_editor_frame.h +++ b/pcbnew/module_editor_frame.h @@ -437,18 +437,8 @@ protected: void setLibNickName( const wxString& aNickname ); -#if !defined(USE_FP_LIB_TABLE) - wxString m_lib_path; - - void setLibPath( const wxString& aLibPath ) { m_lib_path = aLibPath; } - - /// The libPath is the full string used in the PLUGIN::Footprint*() calls. - wxString getLibPath() const { return m_lib_path; } - -#else /// The libPath is not publicly visible, grab it from the FP_LIB_TABLE if we must. wxString getLibPath(); -#endif }; #endif // MODULE_EDITOR_FRAME_H_ diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 31cb657ea5..1c9da5ed87 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -268,7 +268,6 @@ void FOOTPRINT_EDIT_FRAME::setLibNickName( const wxString& aNickname ) } -#if 1 && defined(USE_FP_LIB_TABLE) wxString FOOTPRINT_EDIT_FRAME::getLibPath() { try @@ -284,7 +283,7 @@ wxString FOOTPRINT_EDIT_FRAME::getLibPath() return wxEmptyString; } } -#endif + const wxChar* FOOTPRINT_EDIT_FRAME::GetFootprintEditorFrameName() { @@ -363,15 +362,9 @@ void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) case wxID_YES: // code from FOOTPRINT_EDIT_FRAME::Process_Special_Functions, // at case ID_MODEDIT_SAVE_LIBMODULE -#if defined(USE_FP_LIB_TABLE) if( GetBoard()->m_Modules && getLibNickName().size() ) { if( Save_Module_In_Library( getLibNickName(), GetBoard()->m_Modules, true, true ) ) -#else - if( GetBoard()->m_Modules && getLibPath() != wxEmptyString ) - { - if( Save_Module_In_Library( getLibPath(), GetBoard()->m_Modules, true, true ) ) -#endif { // save was correct GetScreen()->ClrModify(); @@ -492,11 +485,7 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateReplaceModuleInBoard( wxUpdateUIEvent& aEvent void FOOTPRINT_EDIT_FRAME::OnUpdateSelectCurrentLib( wxUpdateUIEvent& aEvent ) { -#if defined( USE_FP_LIB_TABLE ) aEvent.Enable( m_footprintLibTable && !m_footprintLibTable->IsEmpty() ); -#else - aEvent.Enable( !g_LibraryNames.IsEmpty() ); -#endif } @@ -623,42 +612,6 @@ void FOOTPRINT_EDIT_FRAME::updateTitle() { wxString title = _( "Module Editor " ); -#if !defined(USE_FP_LIB_TABLE) - wxString libPath = getLibPath(); - - if( !libPath ) - { - L_none: - title += _( "(no active library)" ); - } - else - { - // See if we can open and test write-ability of the library. - IO_MGR::PCB_FILE_T pluginType = IO_MGR::GuessPluginTypeFromLibPath( libPath ); - - PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) ); - - try - { - bool writable = pi->IsFootprintLibWritable( libPath ); - - // no exception was thrown, this means libPath is valid, but it may be read only. - title = _( "Module Editor (active library: " ) + getLibNickName() + wxT( ")" ); - - if( !writable ) - title += _( " [Read Only]" ); - } - catch( IO_ERROR ioe ) - { - // user may be bewildered as to why after selecting a library it is not showing up - // in the title, we could show an error message, but that should have been done at time - // of libary selection UI. - goto L_none; - } - } - -#else - wxString nickname = getLibNickName(); if( !nickname ) @@ -686,7 +639,6 @@ void FOOTPRINT_EDIT_FRAME::updateTitle() goto L_none; } } -#endif SetTitle( title ); } diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp index 9976912a69..08b93c170f 100644 --- a/pcbnew/modview_frame.cpp +++ b/pcbnew/modview_frame.cpp @@ -59,9 +59,6 @@ #define PREVIOUS_PART -1 -static wxString entryPerspective( wxT( "ModViewPerspective" ) ); - - /** * Save previous component library viewer state. */ @@ -198,18 +195,10 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* aParent, // If a footprint was previously loaded, reload it if( !m_libraryName.IsEmpty() && !m_footprintName.IsEmpty() ) { -#if !defined( USE_FP_LIB_TABLE ) - MODULE* footprint = GetModuleLibrary( m_libraryName + wxT( "." ) + LegacyFootprintLibPathExtension, - m_footprintName, false ); - - if( footprint ) - GetBoard()->Add( footprint, ADD_APPEND ); -#else FPID id; id.SetLibNickname( m_libraryName ); id.SetFootprintName( m_footprintName ); GetBoard()->Add( loadFootprint( id ) ); -#endif } if( m_canvas ) @@ -217,11 +206,13 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* aParent, m_auimgr.SetManagedWindow( this ); - EDA_PANEINFO horiz; - horiz.HorizontalToolbarPane(); - - EDA_PANEINFO vert; - vert.VerticalToolbarPane(); + // Main toolbar is initially docked at the top of the main window and dockable on any side. + // The close button is disable because the footprint viewer has no main menu to re-enable it. + // The tool bar will only be dockable on the top or bottom of the main frame window. This is + // most likely due to the fact that the other windows are not dockable and are preventing the + // tool bar from docking on the right and left. + wxAuiPaneInfo toolbarPaneInfo; + toolbarPaneInfo.Name( wxT( "m_mainToolBar" ) ).ToolbarPane().Top().CloseButton( false ); EDA_PANEINFO info; info.InfoToolbarPane(); @@ -229,27 +220,25 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* aParent, EDA_PANEINFO mesg; mesg.MessageToolbarPane(); - // Manage main toolbar - m_auimgr.AddPane( m_mainToolBar, - wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) ); + // Manage main toolbar, top pane + m_auimgr.AddPane( m_mainToolBar, toolbarPaneInfo ); - // Manage the left window (list of libraries) + // Manage the list of libraries, left pane. if( m_LibListWindow ) m_auimgr.AddPane( m_LibListWindow, wxAuiPaneInfo( info ).Name( wxT( "m_LibList" ) ). - Left().Row( 0 ) ); + Left().Row( 1 ) ); - // Manage the list of components) + // Manage the list of footprints, center pane. m_auimgr.AddPane( m_FootprintListWindow, - wxAuiPaneInfo( info ).Name( wxT( "m_FootprintList" ) ). - Left().Row( 1 ) ); + wxAuiPaneInfo( info ).Name( wxT( "m_FootprintList" ) ).Centre().Row( 1 ) ); - // Manage the draw panel + // Manage the draw panel, right pane. m_auimgr.AddPane( m_canvas, - wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).Centre().CloseButton( false ) ); + wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).Right().Row( 1 ).CloseButton( false ) ); - // Manage the message panel + // Manage the message panel, bottom pane. m_auimgr.AddPane( m_messagePanel, - wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer( 10 ) ); + wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom() ); /* Now the minimum windows are fixed, set library list * and component list of the previous values from last viewlib use @@ -284,6 +273,8 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* aParent, FOOTPRINT_VIEWER_FRAME::~FOOTPRINT_VIEWER_FRAME() { + SaveSettings(); + if( m_Draw3DFrame ) m_Draw3DFrame->Destroy(); } @@ -304,8 +295,6 @@ FOOTPRINT_VIEWER_FRAME* FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer() void FOOTPRINT_VIEWER_FRAME::OnCloseWindow( wxCloseEvent& Event ) { - SaveSettings(); - if( m_Semaphore ) { m_Semaphore->Post(); @@ -341,17 +330,10 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList() m_LibList->Clear(); -#if !defined( USE_FP_LIB_TABLE ) - for( unsigned ii = 0; ii < g_LibraryNames.GetCount(); ii++ ) - { - m_LibList->Append( g_LibraryNames[ii] ); - } -#else std::vector< wxString > libName = m_footprintLibTable->GetLogicalLibs(); for( unsigned ii = 0; ii < libName.size(); ii++ ) m_LibList->Append( libName[ii] ); -#endif // Search for a previous selection: int index = m_LibList->FindString( m_libraryName ); @@ -388,45 +370,22 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList() return; } - bool libLoaded = false; FOOTPRINT_LIST fp_info_list; wxArrayString libsList; -#if !defined( USE_FP_LIB_TABLE ) + fp_info_list.ReadFootprintFiles( m_footprintLibTable, &m_libraryName ); - libsList.Add( m_libraryName ); - libLoaded = fp_info_list.ReadFootprintFiles( libsList ); - -#else - - libLoaded = fp_info_list.ReadFootprintFiles( m_footprintLibTable, &m_libraryName ); - -#endif - - if( !libLoaded ) + if( fp_info_list.GetErrorCount() ) { - m_footprintName = wxEmptyString; - m_libraryName = wxEmptyString; - - wxString msg; - msg.Format( _( "Error occurred attempting to load footprint library <%s>:\n\n" ), - GetChars( m_libraryName ) ); - - if( !fp_info_list.m_filesNotFound.IsEmpty() ) - msg += _( "Files not found:\n\n" ) + fp_info_list.m_filesNotFound; - - if( !fp_info_list.m_filesInvalid.IsEmpty() ) - msg += _( "\n\nFile load errors:\n\n" ) + fp_info_list.m_filesInvalid; - - DisplayError( this, msg ); + fp_info_list.DisplayErrors( this ); return; } wxArrayString fpList; - BOOST_FOREACH( FOOTPRINT_INFO& footprint, fp_info_list.m_List ) + BOOST_FOREACH( const FOOTPRINT_INFO& footprint, fp_info_list.GetList() ) { - fpList.Add( footprint.m_Module ); + fpList.Add( footprint.GetFootprintName() ); } m_FootprintList->Append( fpList ); @@ -478,13 +437,6 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event ) SetCurItem( NULL ); // Delete the current footprint GetBoard()->m_Modules.DeleteAll(); -#if !defined( USE_FP_LIB_TABLE ) - MODULE* footprint = GetModuleLibrary( m_libraryName + wxT( "." ) + LegacyFootprintLibPathExtension, - m_footprintName, true ); - - if( footprint ) - GetBoard()->Add( footprint, ADD_APPEND ); -#else FPID id; id.SetLibNickname( m_libraryName ); id.SetFootprintName( m_footprintName ); @@ -501,7 +453,6 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event ) GetChars( ioe.errorText ) ); DisplayError( this, msg ); } -#endif DisplayLibInfos(); Zoom_Automatique( false ); @@ -541,27 +492,23 @@ void FOOTPRINT_VIEWER_FRAME::ExportSelectedFootprint( wxCommandEvent& event ) void FOOTPRINT_VIEWER_FRAME::LoadSettings( ) { - wxConfig* cfg ; - EDA_DRAW_FRAME::LoadSettings(); wxConfigPathChanger cpc( wxGetApp().GetSettings(), m_configPath ); - cfg = wxGetApp().GetSettings(); - cfg->Read( entryPerspective, &m_perspective ); + // wxConfig* cfg = + wxGetApp().GetSettings(); } void FOOTPRINT_VIEWER_FRAME::SaveSettings() { - wxConfig* cfg; - EDA_DRAW_FRAME::SaveSettings(); wxConfigPathChanger cpc( wxGetApp().GetSettings(), m_configPath ); - cfg = wxGetApp().GetSettings(); - cfg->Write( entryPerspective, m_auimgr.SavePerspective() ); + // wxConfig* cfg = + wxGetApp().GetSettings(); } @@ -576,21 +523,6 @@ void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event ) m_selectedFootprintName.Empty(); // Ensure we have the right library list: -#if !defined( USE_FP_LIB_TABLE ) - if( g_LibraryNames.GetCount() == m_LibList->GetCount() ) - { - unsigned ii; - - for( ii = 0; ii < g_LibraryNames.GetCount(); ii++ ) - { - if( m_LibList->GetString( ii ) != g_LibraryNames[ii] ) - break; - } - - if( ii == g_LibraryNames.GetCount() ) - return; - } -#else std::vector< wxString > libNicknames = m_footprintLibTable->GetLogicalLibs(); if( libNicknames.size() == m_LibList->GetCount() ) @@ -606,7 +538,6 @@ void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event ) if( ii == libNicknames.size() ) return; } -#endif // If we are here, the library list has changed, rebuild it ReCreateLibraryList(); diff --git a/pcbnew/modview_frame.h b/pcbnew/modview_frame.h index 0e099e4fea..26130a8bc1 100644 --- a/pcbnew/modview_frame.h +++ b/pcbnew/modview_frame.h @@ -55,7 +55,6 @@ private: // Flags wxSemaphore* m_Semaphore; // != NULL if the frame must emulate a modal dialog wxString m_configPath; // subpath for configuration - wxString m_perspective; // wxAuiManager perspective. protected: static wxString m_libraryName; // Current selected library diff --git a/pcbnew/netlist.cpp b/pcbnew/netlist.cpp index 54855d33f2..18d60f8cfd 100644 --- a/pcbnew/netlist.cpp +++ b/pcbnew/netlist.cpp @@ -161,164 +161,8 @@ MODULE* PCB_EDIT_FRAME::ListAndSelectModuleName() } -#if !defined( USE_FP_LIB_TABLE ) - -void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter ) - throw( IO_ERROR, PARSE_ERROR ) -{ - wxString msg; - FPID lastFPID; - std::vector< FPID > nofoundFootprints; // A list of footprints used in netlist - // but not found in any library - // to avoid a full search in all libs - // each time a non existent footprint is needed - COMPONENT* component; - MODULE* module = 0; - MODULE* fpOnBoard; - - if( aNetlist.IsEmpty() ) - return; - - aNetlist.SortByFPID(); - - wxString libPath; - wxFileName fn; - - PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) ); - - for( unsigned ii = 0; ii < aNetlist.GetCount(); ii++ ) - { - component = aNetlist.GetComponent( ii ); - - if( component->GetFPID().empty() ) - { - if( aReporter ) - { - msg.Printf( _( "No footprint defined for component '%s'.\n" ), - GetChars( component->GetReference() ) ); - aReporter->Report( msg ); - } - - continue; - } - - // Check if component footprint is already on BOARD and only load the footprint from - // the library if it's needed. - if( aNetlist.IsFindByTimeStamp() ) - fpOnBoard = m_Pcb->FindModule( aNetlist.GetComponent( ii )->GetTimeStamp(), true ); - else - fpOnBoard = m_Pcb->FindModule( aNetlist.GetComponent( ii )->GetReference() ); - - bool footprintMisMatch = fpOnBoard && - fpOnBoard->GetFPID() != component->GetFPID(); - - if( footprintMisMatch && !aNetlist.GetReplaceFootprints() ) - { - if( aReporter ) - { - msg.Printf( _( "* Warning: component '%s' has footprint '%s' and should be '%s'\n" ), - GetChars( component->GetReference() ), - fpOnBoard->GetFPID().Format().c_str(), - component->GetFPID().GetFootprintName().c_str() ); - aReporter->Report( msg ); - } - - continue; - } - - if( !aNetlist.GetReplaceFootprints() ) - footprintMisMatch = false; - - bool loadFootprint = (fpOnBoard == NULL) || footprintMisMatch; - - if( loadFootprint && (component->GetFPID() != lastFPID) ) - { - module = NULL; - - // Speed up the search: a search for a non existent footprint - // is hightly costly in time becuse the full set of libs is read. - // So it should be made only once. - // Therefore search in not found list first: - bool alreadySearched = false; - - for( unsigned ii = 0; ii < nofoundFootprints.size(); ii++ ) - { - if( component->GetFPID() == nofoundFootprints[ii] ) - { - alreadySearched = true; - break; - } - } - - if( alreadySearched ) - continue; - - for( unsigned ii = 0; ii < g_LibraryNames.GetCount(); ii++ ) - { - fn = wxFileName( wxEmptyString, g_LibraryNames[ii], - LegacyFootprintLibPathExtension ); - - libPath = wxGetApp().FindLibraryPath( fn ); - - if( !libPath ) - { - if( aReporter ) - { - msg.Printf( _( "*** Warning: Cannot find footprint library file \"%s\" " - "in any of the standard KiCad library search paths. ***\n" ), - GetChars( fn.GetFullPath() ) ); - aReporter->Report( msg ); - } - - continue; - } - - module = pi->FootprintLoad( libPath, - FROM_UTF8( component->GetFPID().GetFootprintName().c_str() ) ); - - if( module ) - { - lastFPID = component->GetFPID(); - break; - } - } - - if( module == NULL && !alreadySearched ) - { - if( aReporter ) - { - msg.Printf( _( "*** Warning: component '%s' footprint '%s' was not found in " - "any libraries. ***\n" ), - GetChars( component->GetReference() ), - component->GetFPID().GetFootprintName().c_str() ); - aReporter->Report( msg ); - } - - nofoundFootprints.push_back( component->GetFPID() ); - - continue; - } - } - else - { - // Footprint already loaded from a library, duplicate it (faster) - if( module == NULL ) - continue; // Module does not exist in any library. - - module = new MODULE( *module ); - } - - if( loadFootprint && module != NULL ) - component->SetModule( module ); - } -} - -#else - - #define ALLOW_PARTIAL_FPID 1 - void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter ) throw( IO_ERROR, PARSE_ERROR ) { @@ -444,4 +288,3 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter ) } } -#endif diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 692f73f5e7..902c21f991 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -280,7 +280,7 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer ) if( !net ) return; - std::string netName = std::string( net->GetShortNetname().mb_str() ); + std::wstring netName = std::wstring( net->GetShortNetname().wc_str() ); VECTOR2D textPosition = start + line / 2.0; // center of the track double textOrientation = -atan( line.y / line.x ); double textSize = std::min( static_cast( width ), length / netName.length() ); @@ -456,7 +456,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) VECTOR2D namesize( tsize, tsize ); m_gal->SetGlyphSize( namesize ); m_gal->SetLineWidth( namesize.x / 12.0 ); - m_gal->StrokeText( std::string( aPad->GetShortNetname().mb_str() ), + m_gal->StrokeText( std::wstring( aPad->GetShortNetname().wc_str() ), textpos, 0.0 ); } @@ -474,8 +474,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) m_gal->SetGlyphSize( numsize ); m_gal->SetLineWidth( numsize.x / 12.0 ); - m_gal->StrokeText( std::string( aPad->GetPadName().mb_str() ), - textpos, 0.0 ); + m_gal->StrokeText( std::wstring( aPad->GetPadName().wc_str() ), textpos, 0.0 ); } m_gal->Restore(); @@ -720,7 +719,7 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer ) m_gal->SetStrokeColor( strokeColor ); m_gal->SetLineWidth( aText->GetThickness() ); m_gal->SetTextAttributes( aText ); - m_gal->StrokeText( std::string( aText->GetText().mb_str() ), position, orientation ); + m_gal->StrokeText( aText->GetText(), position, orientation ); } @@ -736,7 +735,7 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer ) m_gal->SetStrokeColor( strokeColor ); m_gal->SetLineWidth( aText->GetThickness() ); m_gal->SetTextAttributes( aText ); - m_gal->StrokeText( std::string( aText->GetText().mb_str() ), position, orientation ); + m_gal->StrokeText( aText->GetText(), position, orientation ); } @@ -836,7 +835,7 @@ void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer ) m_gal->SetLineWidth( text.GetThickness() ); m_gal->SetTextAttributes( &text ); - m_gal->StrokeText( std::string( text.GetText().mb_str() ), position, orientation ); + m_gal->StrokeText( std::wstring( text.GetText().wc_str() ), position, orientation ); } diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index 055dd02cee..1b47c69158 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -51,9 +51,6 @@ #include -using namespace std; - - void PCB_PARSER::init() { m_layerIndices.clear(); @@ -263,7 +260,7 @@ S3D_MASTER* PCB_PARSER::parse3DModel() throw( PARSE_ERROR ) T token; - auto_ptr< S3D_MASTER > n3D( new S3D_MASTER( NULL ) ); + std::auto_ptr< S3D_MASTER > n3D( new S3D_MASTER( NULL ) ); NeedSYMBOLorNUMBER(); n3D->m_Shape3DName = FromUTF8(); @@ -1084,7 +1081,7 @@ void PCB_PARSER::parseNETCLASS() throw( IO_ERROR, PARSE_ERROR ) T token; - auto_ptr nc( new NETCLASS( m_board, wxEmptyString ) ); + std::auto_ptr nc( new NETCLASS( m_board, wxEmptyString ) ); // Read netclass name (can be a name or just a number like track width) NeedSYMBOLorNUMBER(); @@ -1164,7 +1161,7 @@ DRAWSEGMENT* PCB_PARSER::parseDRAWSEGMENT() throw( IO_ERROR, PARSE_ERROR ) T token; wxPoint pt; - auto_ptr< DRAWSEGMENT > segment( new DRAWSEGMENT( NULL ) ); + std::auto_ptr< DRAWSEGMENT > segment( new DRAWSEGMENT( NULL ) ); switch( CurTok() ) { @@ -1325,7 +1322,7 @@ TEXTE_PCB* PCB_PARSER::parseTEXTE_PCB() throw( IO_ERROR, PARSE_ERROR ) T token; - auto_ptr< TEXTE_PCB > text( new TEXTE_PCB( m_board ) ); + std::auto_ptr text( new TEXTE_PCB( m_board ) ); NeedSYMBOLorNUMBER(); text->SetText( FromUTF8() ); @@ -1393,7 +1390,7 @@ DIMENSION* PCB_PARSER::parseDIMENSION() throw( IO_ERROR, PARSE_ERROR ) T token; - auto_ptr< DIMENSION > dimension( new DIMENSION( NULL ) ); + std::auto_ptr dimension( new DIMENSION( NULL ) ); dimension->SetValue( parseBoardUnits( "dimension value" ) ); NeedLEFT(); @@ -1545,7 +1542,7 @@ MODULE* PCB_PARSER::parseMODULE( wxArrayString* aInitialComments ) throw( IO_ERR T token; FPID fpid; - auto_ptr< MODULE > module( new MODULE( m_board ) ); + std::auto_ptr module( new MODULE( m_board ) ); module->SetInitialComments( aInitialComments ); @@ -1773,7 +1770,7 @@ TEXTE_MODULE* PCB_PARSER::parseTEXTE_MODULE() throw( IO_ERROR, PARSE_ERROR ) T token = NextTok(); - auto_ptr< TEXTE_MODULE > text( new TEXTE_MODULE( NULL ) ); + std::auto_ptr text( new TEXTE_MODULE( NULL ) ); switch( token ) { @@ -1858,7 +1855,7 @@ EDGE_MODULE* PCB_PARSER::parseEDGE_MODULE() throw( IO_ERROR, PARSE_ERROR ) wxPoint pt; T token; - auto_ptr< EDGE_MODULE > segment( new EDGE_MODULE( NULL ) ); + std::auto_ptr< EDGE_MODULE > segment( new EDGE_MODULE( NULL ) ); switch( CurTok() ) { @@ -2023,7 +2020,7 @@ D_PAD* PCB_PARSER::parseD_PAD() throw( IO_ERROR, PARSE_ERROR ) wxSize sz; wxPoint pt; - auto_ptr< D_PAD > pad( new D_PAD( NULL ) ); + std::auto_ptr< D_PAD > pad( new D_PAD( NULL ) ); NeedSYMBOLorNUMBER(); pad->SetPadName( FromUTF8() ); @@ -2260,7 +2257,7 @@ TRACK* PCB_PARSER::parseTRACK() throw( IO_ERROR, PARSE_ERROR ) wxPoint pt; T token; - auto_ptr< TRACK > track( new TRACK( m_board ) ); + std::auto_ptr< TRACK > track( new TRACK( m_board ) ); for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { @@ -2322,7 +2319,7 @@ SEGVIA* PCB_PARSER::parseSEGVIA() throw( IO_ERROR, PARSE_ERROR ) wxPoint pt; T token; - auto_ptr< SEGVIA > via( new SEGVIA( m_board ) ); + std::auto_ptr< SEGVIA > via( new SEGVIA( m_board ) ); for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { @@ -2407,7 +2404,7 @@ ZONE_CONTAINER* PCB_PARSER::parseZONE_CONTAINER() throw( IO_ERROR, PARSE_ERROR ) // bigger scope since each filled_polygon is concatenated in here CPOLYGONS_LIST pts; - auto_ptr< ZONE_CONTAINER > zone( new ZONE_CONTAINER( m_board ) ); + std::auto_ptr< ZONE_CONTAINER > zone( new ZONE_CONTAINER( m_board ) ); zone->SetPriority( 0 ); @@ -2721,8 +2718,7 @@ PCB_TARGET* PCB_PARSER::parsePCB_TARGET() throw( IO_ERROR, PARSE_ERROR ) wxPoint pt; T token; - auto_ptr< PCB_TARGET > target( new PCB_TARGET( NULL ) ); - + std::auto_ptr< PCB_TARGET > target( new PCB_TARGET( NULL ) ); for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 963581d197..6fb80890fc 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -313,10 +313,9 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, m_microWaveToolBar = NULL; m_useCmpFileForFpNames = true; -#if defined( USE_FP_LIB_TABLE ) m_footprintLibTable = NULL; m_globalFootprintTable = NULL; -#endif + m_rotationAngle = 900; #ifdef KICAD_SCRIPTING_WXPYTHON m_pythonPanel = NULL; @@ -469,7 +468,6 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, m_auimgr.Update(); -#if defined( USE_FP_LIB_TABLE ) if( m_globalFootprintTable == NULL ) { try @@ -497,7 +495,6 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, DisplayError( this, msg ); } } -#endif setupTools(); } @@ -513,10 +510,8 @@ PCB_EDIT_FRAME::~PCB_EDIT_FRAME() delete m_drc; -#if defined( USE_FP_LIB_TABLE ) delete m_footprintLibTable; delete m_globalFootprintTable; -#endif } @@ -554,6 +549,7 @@ void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event ) void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) { m_canvas->SetAbortRequest( true ); + m_galCanvas->StopDrawing(); if( GetScreen()->IsModify() ) { @@ -1075,3 +1071,12 @@ void PCB_EDIT_FRAME::ToPlotter( wxCommandEvent& event ) DIALOG_PLOT dlg( this ); dlg.ShowModal(); } + + +void PCB_EDIT_FRAME::SetRotationAngle( int aRotationAngle ) +{ + wxCHECK2_MSG( aRotationAngle > 0 && aRotationAngle <= 900, aRotationAngle = 900, + wxT( "Invalid rotation angle, defaulting to 90." ) ); + + m_rotationAngle = aRotationAngle; +} diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 2d9a50d654..28dbb0d518 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -213,10 +213,8 @@ bool EDA_APP::OnInit() * display the real hotkeys in menus or tool tips */ ReadHotkeyConfig( wxT( "PcbFrame" ), g_Board_Editor_Hokeys_Descr ); -#if defined( USE_FP_LIB_TABLE ) // Set any environment variables before loading FP_LIB_TABLE SetFootprintLibTablePath(); -#endif frame = new PCB_EDIT_FRAME( NULL, wxT( "Pcbnew" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) ); diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 79f0af03d2..9d5b1c9724 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -158,27 +158,27 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) break; case ID_CONFIG_READ: + { + fn = GetBoard()->GetFileName(); + fn.SetExt( ProjectFileExtension ); + + wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(), + fn.GetFullName(), ProjectFileWildcard, + wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR ); + + if( dlg.ShowModal() == wxID_CANCEL ) + break; + + if( !wxFileExists( dlg.GetPath() ) ) { - fn = GetBoard()->GetFileName(); - fn.SetExt( ProjectFileExtension ); - - wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(), - fn.GetFullName(), ProjectFileWildcard, - wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR ); - - if( dlg.ShowModal() == wxID_CANCEL ) - break; - - if( !wxFileExists( dlg.GetPath() ) ) - { - wxString msg; - msg.Printf( _( "File %s not found" ), GetChars( dlg.GetPath() ) ); - DisplayError( this, msg ); - break; - } - - LoadProjectSettings( dlg.GetPath() ); + wxString msg; + msg.Printf( _( "File %s not found" ), GetChars( dlg.GetPath() ) ); + DisplayError( this, msg ); + break; } + + LoadProjectSettings( dlg.GetPath() ); + } break; // Hotkey IDs @@ -256,7 +256,6 @@ bool PCB_EDIT_FRAME::LoadProjectSettings( const wxString& aProjectFileName ) // Check if a project footprint table is defined and load it. If no project footprint // table is defined, then the global library table is the footprint library table. -#if defined( USE_FP_LIB_TABLE ) FP_LIB_TABLE::SetProjectPathEnvVariable( fn ); delete m_footprintLibTable; @@ -284,7 +283,6 @@ bool PCB_EDIT_FRAME::LoadProjectSettings( const wxString& aProjectFileName ) if( viewFrame ) viewFrame->SetFootprintLibTable( m_footprintLibTable ); -#endif // Load the page layout decr file, from the filename stored in // BASE_SCREEN::m_PageLayoutDescrFileName, read in config project file @@ -480,16 +478,16 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() WHITE ) ); // Miscellaneous: - m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "RotationAngle" ), &g_RotationAngle, - 900, 450, 900 ) ); + m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "RotationAngle" ), &m_rotationAngle, + 900, 1, 900 ) ); m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "MaxLnkS" ), &g_MaxLinksShowed, 3, 0, 15 ) ); m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "ShowMRa" ), &g_Show_Module_Ratsnest, true ) ); m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "TwoSegT" ), &g_TwoSegmentTrackBuild, true ) ); - m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "SegmPcb45Only" ), &g_Segments_45_Only, - true ) ); + m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "SegmPcb45Only" ) + , &g_Segments_45_Only, true ) ); return m_configSettings; } diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 8ba01ab009..34d708195b 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -797,7 +797,15 @@ PLOTTER* StartPlotBoard( BOARD *aBoard, PCB_PLOT_PARAMS *aPlotOpts, } // Compute the viewport and set the other options - initializePlotter( plotter, aBoard, aPlotOpts ); + + // page layout is not mirrored, so temporary change mirror option + // just to plot the page layout + PCB_PLOT_PARAMS plotOpts = *aPlotOpts; + + if( plotOpts.GetPlotFrameRef() && plotOpts.GetMirror() ) + plotOpts.SetMirror( false ); + + initializePlotter( plotter, aBoard, &plotOpts ); if( plotter->OpenFile( aFullFileName ) ) { @@ -805,11 +813,16 @@ PLOTTER* StartPlotBoard( BOARD *aBoard, PCB_PLOT_PARAMS *aPlotOpts, // Plot the frame reference if requested if( aPlotOpts->GetPlotFrameRef() ) + { PlotWorkSheet( plotter, aBoard->GetTitleBlock(), aBoard->GetPageSettings(), 1, 1, // Only one page aSheetDesc, aBoard->GetFileName() ); + if( aPlotOpts->GetMirror() ) + initializePlotter( plotter, aBoard, aPlotOpts ); + } + /* When plotting a negative board: draw a black rectangle * (background for plot board in white) and switch the current * color to WHITE; note the color inversion is actually done diff --git a/pcbnew/router/pns_line.cpp b/pcbnew/router/pns_line.cpp index 7600d65400..63011b6b75 100644 --- a/pcbnew/router/pns_line.cpp +++ b/pcbnew/router/pns_line.cpp @@ -29,7 +29,6 @@ #include "pns_utils.h" #include "pns_router.h" -using namespace std; using boost::optional; PNS_LINE* PNS_LINE::Clone() const @@ -321,10 +320,10 @@ void PNS_LINE::NewWalkaround( const SHAPE_LINE_CHAIN& aObstacle, SHAPE_LINE_CHAIN l_orig( m_line ); SHAPE_LINE_CHAIN l_hull; - vector outside, on_edge, inside; + std::vector outside, on_edge, inside; SHAPE_LINE_CHAIN path; - vector isects; + std::vector isects; // don't calculate walkaround for empty lines if( m_line.PointCount() < 2 ) diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index 294da09695..a03183c45c 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -18,7 +18,6 @@ * with this program. If not, see . */ -#include #include #include @@ -30,7 +29,6 @@ #include "pns_shove.h" #include "pns_utils.h" -using namespace std; using boost::optional; PNS_LINE_PLACER::PNS_LINE_PLACER( PNS_NODE* aWorld ) @@ -528,7 +526,7 @@ bool PNS_LINE_PLACER::optimizeTailHeadTransition() const int TailLookbackSegments = 5; - int threshold = min( tail.PointCount(), TailLookbackSegments + 1 ); + int threshold = std::min( tail.PointCount(), TailLookbackSegments + 1 ); if( tail.SegmentCount() < 3 ) return false; diff --git a/pcbnew/router/pns_node.cpp b/pcbnew/router/pns_node.cpp index c1a14d81a8..e2349c4800 100644 --- a/pcbnew/router/pns_node.cpp +++ b/pcbnew/router/pns_node.cpp @@ -37,8 +37,6 @@ #include "pns_joint.h" #include "pns_index.h" -using namespace std; - using boost::unordered_set; using boost::unordered_map; @@ -138,7 +136,7 @@ void PNS_NODE::unlinkParent() if( isRoot() ) return; - for( vector::iterator i = m_parent->m_children.begin(); + for( std::vector::iterator i = m_parent->m_children.begin(); i != m_parent->m_children.end(); ++i ) { if( *i == this ) @@ -284,7 +282,7 @@ PNS_NODE::OptObstacle PNS_NODE::NearestObstacle( const PNS_LINE* aItem, int aKin VECTOR2I ip_first, ip_last; int dist_max = INT_MIN; - vector isect_list; + std::vector isect_list; int clearance = GetClearance( obs.item, &aLine ); @@ -564,7 +562,7 @@ void PNS_NODE::removeSegment( PNS_SEGMENT* aSeg ) void PNS_NODE::removeLine( PNS_LINE* aLine ) { - vector* segRefs = aLine->GetLinkedSegments(); + std::vector* segRefs = aLine->GetLinkedSegments(); if( !segRefs ) return; @@ -700,7 +698,7 @@ void PNS_NODE::FindLineEnds( PNS_LINE* aLine, PNS_JOINT& a, PNS_JOINT& b ) } -int PNS_NODE::FindLinesBetweenJoints( PNS_JOINT& a, PNS_JOINT& b, vector& aLines ) +int PNS_NODE::FindLinesBetweenJoints( PNS_JOINT& a, PNS_JOINT& b, std::vector& aLines ) { BOOST_FOREACH( PNS_ITEM* item, a.GetLinkList() ) { @@ -763,7 +761,7 @@ PNS_JOINT& PNS_NODE::touchJoint( const VECTOR2I& aPos, const PNS_LAYERSET& aLaye // try to find the joint in this node. JointMap::iterator f = m_joints.find( tag ); - pair range; + std::pair range; // not found and we are not root? find in the root and copy results here. if( f == m_joints.end() && !isRoot() ) @@ -895,7 +893,7 @@ void PNS_NODE::Dump( bool aLong ) printf( "Line: %s, net %d ", l->GetLine().Format().c_str(), l->GetNet() ); - for( vector::iterator j = seg_refs->begin(); j != seg_refs->end(); ++j ) + for( std::vector::iterator j = seg_refs->begin(); j != seg_refs->end(); ++j ) { printf( "%s ", (*j)->GetSeg().A.Format().c_str() ); @@ -932,7 +930,7 @@ void PNS_NODE::GetUpdatedItems( ItemVector& aRemoved, ItemVector& aAdded ) void PNS_NODE::releaseChildren() { // copy the kids as the PNS_NODE destructor erases the item from the parent node. - vector kids = m_children; + std::vector kids = m_children; BOOST_FOREACH( PNS_NODE * node, kids ) { node->releaseChildren(); diff --git a/pcbnew/router/pns_optimizer.cpp b/pcbnew/router/pns_optimizer.cpp index 49e3f8cc5c..48e84207e5 100644 --- a/pcbnew/router/pns_optimizer.cpp +++ b/pcbnew/router/pns_optimizer.cpp @@ -28,8 +28,6 @@ #include "pns_optimizer.h" #include "pns_utils.h" -using namespace std; - /** * * Cost Estimator Methods @@ -620,8 +618,8 @@ int PNS_OPTIMIZER::smartPadsSingle( PNS_LINE* aLine, PNS_ITEM* aPad, bool aEnd, const int ForbiddenAngles = DIRECTION_45::ANG_ACUTE | DIRECTION_45::ANG_RIGHT | DIRECTION_45::ANG_HALF_FULL | DIRECTION_45::ANG_UNDEFINED; - typedef pair RtVariant; - vector variants; + typedef std::pair RtVariant; + std::vector variants; BreakoutList breakouts = computeBreakouts( aLine->GetWidth(), aPad, true ); @@ -629,7 +627,7 @@ int PNS_OPTIMIZER::smartPadsSingle( PNS_LINE* aLine, PNS_ITEM* aPad, bool aEnd, // bool startDiagonal = DIRECTION_45( line.CSegment(0) ).IsDiagonal(); - int p_end = min( aEndVertex, min( 3, line.PointCount() - 1 ) ); + int p_end = std::min( aEndVertex, std::min( 3, line.PointCount() - 1 ) ); for( int p = 1; p <= p_end; p++ ) { diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index 7921feab19..5b6b5f6b31 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -51,8 +51,6 @@ #include #include -using namespace std; - // an ugly singleton for drawing debug items within the router context. // To be fixed sometime in the future. static PNS_ROUTER* theRouter; @@ -89,7 +87,7 @@ public: } private: - vector m_clearanceCache; + std::vector m_clearanceCache; int m_defaultClearance; }; @@ -232,7 +230,7 @@ int PNS_ROUTER::NextCopperLayer( bool aUp ) void PNS_ROUTER::SyncWorld() { - vector pads; + std::vector pads; if( !m_board ) { @@ -662,7 +660,7 @@ PNS_NODE* PNS_ROUTER::removeLoops( PNS_NODE* aNode, PNS_SEGMENT* aLatestSeg ) PNS_NODE* cleaned = aNode->Branch(); PNS_JOINT a, b; - vector lines; + std::vector lines; cleaned->FindLineEnds( ourLine, a, b ); cleaned->FindLinesBetweenJoints( a, b, lines ); @@ -699,7 +697,7 @@ bool PNS_ROUTER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem ) if( aEndItem && m_currentNet >= 0 && m_currentNet == aEndItem->GetNet() ) real_end = true; - int last = ( real_end || m_placingVia ) ? l.SegmentCount() : max( 1, l.SegmentCount() - 1 ); + int last = ( real_end || m_placingVia ) ? l.SegmentCount() : std::max( 1, l.SegmentCount() - 1 ); PNS_NODE* latest = m_placer->GetCurrentNode(); @@ -771,7 +769,7 @@ void PNS_ROUTER::FlipPosture() if( m_placer->GetTail().GetCLine().SegmentCount() == 0 ) { m_start_diagonal = !m_start_diagonal; - m_placer->SetInitialDirection( m_start_diagonal ? + m_placer->SetInitialDirection( m_start_diagonal ? DIRECTION_45( DIRECTION_45::NE ) : DIRECTION_45( DIRECTION_45::N ) ); } else diff --git a/pcbnew/router/pns_shove.cpp b/pcbnew/router/pns_shove.cpp index 35677230bd..ad58ee1feb 100644 --- a/pcbnew/router/pns_shove.cpp +++ b/pcbnew/router/pns_shove.cpp @@ -35,8 +35,6 @@ #include -using namespace std; - PNS_SHOVE::PNS_SHOVE( PNS_NODE* aWorld ) { m_root = aWorld; @@ -280,9 +278,9 @@ const PNS_COST_ESTIMATOR PNS_SHOVE::TotalCost() const PNS_SHOVE::ShoveStatus PNS_SHOVE::ShoveLines( PNS_LINE* aCurrentHead ) { - stack lineStack; + std::stack lineStack; PNS_NODE* node, * parent; - PNS_VIA* headVia = NULL; + PNS_VIA* headVia = NULL; bool fail = false; int iter = 0; diff --git a/pcbnew/router/pns_walkaround.cpp b/pcbnew/router/pns_walkaround.cpp index e2a13ac358..185def64d2 100644 --- a/pcbnew/router/pns_walkaround.cpp +++ b/pcbnew/router/pns_walkaround.cpp @@ -18,8 +18,6 @@ * with this program. If not, see . */ -#include - #include #include @@ -29,8 +27,6 @@ #include "pns_optimizer.h" #include "pns_utils.h" #include "pns_router.h" - -using namespace std; using boost::optional; void PNS_WALKAROUND::start( const PNS_LINE& aInitialPath ) diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 19b92a42cf..d43ea3ece4 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -39,7 +39,6 @@ #include "trace.h" using namespace KIGFX; -using namespace std; using boost::optional; static TOOL_ACTION ACT_AutoEndRoute( "AutoEndRoute", AS_CONTEXT, 'F' ); diff --git a/pcbnew/tool_modview.cpp b/pcbnew/tool_modview.cpp index 85237ce72c..8d40fa2601 100644 --- a/pcbnew/tool_modview.cpp +++ b/pcbnew/tool_modview.cpp @@ -44,10 +44,10 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar() { wxString msg; - if( m_mainToolBar == NULL ) + if( m_mainToolBar == NULL ) { m_mainToolBar = new wxAuiToolBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, - wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT ); + wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_OVERFLOW ); // Set up toolbar m_mainToolBar->AddTool( ID_MODVIEW_SELECT_LIB, wxEmptyString, diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 3d2191f5a8..7f35d8a01e 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -153,8 +153,8 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent ) if( restore ) { // Modifications has to be rollbacked, so restore the previous state of items - wxCommandEvent undoEvent( wxEVT_TOOL, wxID_UNDO ); - wxPostEvent( editFrame, undoEvent ); + wxCommandEvent dummy; + editFrame->GetBoardFromUndoList( dummy ); } else { diff --git a/pcbnew/xchgmod.cpp b/pcbnew/xchgmod.cpp index a267cb8f41..184d650e3f 100644 --- a/pcbnew/xchgmod.cpp +++ b/pcbnew/xchgmod.cpp @@ -397,11 +397,7 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* aModule, wxString moduleName = FROM_UTF8( aNewFootprintFPID.GetFootprintName().c_str() ); wxString libName = FROM_UTF8( aNewFootprintFPID.GetLibNickname().c_str() ); -#if !defined( USE_FP_LIB_TABLE ) - newModule = m_parent->GetModuleLibrary( libName, moduleName, aShowError ); -#else newModule = m_parent->LoadFootprint( aNewFootprintFPID ); -#endif if( newModule == NULL ) // New module not found, redraw the old one. { diff --git a/polygon/PolyLine.cpp b/polygon/PolyLine.cpp index 6947b79eaa..41a562a154 100644 --- a/polygon/PolyLine.cpp +++ b/polygon/PolyLine.cpp @@ -1187,7 +1187,7 @@ void CPOLYGONS_LIST::ExportTo( KI_POLYGON_WITH_HOLES& aPolygoneWithHole ) { cornerslist.push_back( KI_POLY_POINT( GetX( ic ), GetY( ic ) ) ); - if( IsEndContour( ic ) ) + if( IsEndContour( ic++ ) ) break; } diff --git a/polygon/SutherlandHodgmanClipPoly.h b/polygon/SutherlandHodgmanClipPoly.h index 4e0378448b..43512bf9f8 100644 --- a/polygon/SutherlandHodgmanClipPoly.h +++ b/polygon/SutherlandHodgmanClipPoly.h @@ -31,7 +31,6 @@ #include #include -using namespace std; #ifndef _GDIPLUS_H // I designed this with GDI+ in mind. However, this particular code doesn't @@ -80,9 +79,9 @@ public: #endif // _GDIPLUS_H -typedef vector pointVector; -typedef vector::iterator pointIterator; -typedef vector::const_iterator cpointIterator; +typedef std::vector pointVector; +typedef std::vector::iterator pointIterator; +typedef std::vector::const_iterator cpointIterator; class SutherlandHodgman { @@ -249,10 +248,10 @@ private: // rectangles, we include the left and top boundaries, but not the right and bottom boundaries. // In other words: a vertex on the left boundary is considered to be inside, but a vertex // on the right boundary is considered to be outside. - typedef BoundaryVert < less > BoundaryRight; - typedef BoundaryHor < greater_equal > BoundaryTop; - typedef BoundaryVert < greater_equal > BoundaryLeft; - typedef BoundaryHor < less > BoundaryBottom; + typedef BoundaryVert > BoundaryRight; + typedef BoundaryHor > BoundaryTop; + typedef BoundaryVert > BoundaryLeft; + typedef BoundaryHor > BoundaryBottom; // Next typedefs define the four stages. First template parameter is the boundary, // second template parameter is the next stage. diff --git a/polygon/poly2tri/common/shapes.cc b/polygon/poly2tri/common/shapes.cc index 77bafa1501..b8c4c2f9b0 100644 --- a/polygon/poly2tri/common/shapes.cc +++ b/polygon/poly2tri/common/shapes.cc @@ -1,4 +1,4 @@ -/* +/* * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors * http://code.google.com/p/poly2tri/ * @@ -96,14 +96,14 @@ void Triangle::ClearNeighbor(Triangle *triangle ) } else if( neighbors_[1] == triangle ) { - neighbors_[1] = NULL; + neighbors_[1] = NULL; } else { neighbors_[2] = NULL; } } - + void Triangle::ClearNeighbors() { neighbors_[0] = NULL; @@ -357,10 +357,9 @@ Triangle& Triangle::NeighborAcross(Point& opoint) void Triangle::DebugPrint() { - using namespace std; - cout << points_[0]->x << "," << points_[0]->y << " "; - cout << points_[1]->x << "," << points_[1]->y << " "; - cout << points_[2]->x << "," << points_[2]->y << endl; + std::cout << points_[0]->x << "," << points_[0]->y << " "; + std::cout << points_[1]->x << "," << points_[1]->y << " "; + std::cout << points_[2]->x << "," << points_[2]->y << "\n"; } } diff --git a/scripting/kicad.i b/scripting/kicad.i index 42c1bc41ab..5887886204 100644 --- a/scripting/kicad.i +++ b/scripting/kicad.i @@ -63,8 +63,6 @@ #include #include - using namespace std; - #include #include #include diff --git a/scripts/kicad-install.sh b/scripts/kicad-install.sh index 260dbcb8a7..b527a7d8ea 100755 --- a/scripts/kicad-install.sh +++ b/scripts/kicad-install.sh @@ -30,7 +30,6 @@ WORKING_TREES=~/kicad_sources # CMake Options OPTS="$OPTS -DCMAKE_BUILD_TYPE=Release" -OPTS="$OPTS -DUSE_FP_LIB_TABLE=ON" OPTS="$OPTS -DBUILD_GITHUB_PLUGIN=ON" # Python scripting, uncomment to enable @@ -72,6 +71,7 @@ install_prerequisites() cmake-curses-gui \ debhelper \ doxygen \ + grep \ libbz2-dev \ libcairo2-dev \ libglew-dev \ @@ -87,13 +87,14 @@ install_prerequisites() sudo yum install \ bzr \ bzrtools \ + bzip2-libs \ + bzip2-devel \ cmake \ cmake-gui \ doxygen \ - bzip2-libs \ - bzip2-devel \ cairo-devel \ glew-devel \ + grep \ openssl-devel \ wxGTK-devel \ wxPython @@ -137,6 +138,33 @@ cmake_uninstall() } +# Function set_env_var +# sets an environment variable globally. +set_env_var() +{ + local VAR=$1 + local VAL=$2 + + if [ -d /etc/profile.d ]; then + if [ ! -e /etc/profile.d/kicad.sh ] || ! grep "$VAR" /etc/profile.d/kicad.sh; then + echo + echo "Adding environment variable $VAR to file /etc/profile.d/kicad.sh" + echo "Please logout and back in after this script completes for environment" + echo "variable to get set into environment." + sudo sh -c "echo export $VAR=$VAL >> /etc/profile.d/kicad.sh" + fi + + elif [ -e /etc/environment ]; then + if ! grep "$VAR" /etc/environment; then + echo + echo "Adding environment variable $VAR to file /etc/environment" + echo "Please reboot after this script completes for environment variable to get set into environment." + sudo sh -c "echo $VAR=$VAL >> /etc/environment" + fi + fi +} + + install_or_update() { echo "step 1) installing pre-requisites" @@ -230,6 +258,10 @@ install_or_update() echo echo 'All KiCad "--install-or-update" steps completed, you are up to date.' + + if [ -z "${KIGITHUB}" ]; then + set_env_var KIGITHUB https://github.com/KiCad + fi } diff --git a/scripts/library-repos-install.sh b/scripts/library-repos-install.sh index 71b3930f8f..2ec26f04f7 100755 --- a/scripts/library-repos-install.sh +++ b/scripts/library-repos-install.sh @@ -17,9 +17,10 @@ # on https://github.com using Github plugin. After running this script you should be able to # a) $ cp ~/kicad_sources/library-repos/kicad-library/template/fp-lib-table.for-pretty ~/fp-lib-table # and then -# b) set your environment variable KISYSMOD to "~/kicad_sources/library-repos" -# before starting pcbnew. This will use the KiCad plugin against the *.pretty dirs in that base dir. - +# b) set your environment variable KISYSMOD to "~/kicad_sources/library-repos". +# Edit /etc/profile.d/kicad.sh, then reboot. +# +# This will use the KiCad plugin against the *.pretty dirs in that base dir. # Set where the library repos will go, use a full path diff --git a/scripts/test_kicad_plugin.py b/scripts/test_kicad_plugin.py new file mode 100755 index 0000000000..fc2934cebb --- /dev/null +++ b/scripts/test_kicad_plugin.py @@ -0,0 +1,87 @@ +#!/usr/bin/python + +# Test the KiCad plugin regarding some expected features. + +# 1) Build target _pcbnew after enabling scripting in cmake. +# $ make _pcbnew + +# 2) Changed dir to pcbnew +# $ cd pcbnew +# $ pwd +# build/pcbnew + +# 3) Entered following command line, script takes no arguments +# $ PYTHONPATH=. /test_kicad_plugin.py + + +from __future__ import print_function +from pcbnew import * +import sys +import os + + +lib_path1='/tmp/lib1.pretty' +lib_path2='/tmp/lib2.pretty' + + +plugin = IO_MGR.PluginFind( IO_MGR.KICAD ) + +# Expecting "KiCad": +print( "Plugin Type", plugin.PluginName() ) + +try: + plugin.FootprintLibDelete( lib_path1 ) +except: + None # ignore, new may not exist if first run + +try: + plugin.FootprintLibDelete( lib_path2 ) +except: + None # ignore, new may not exist if first run + + +plugin.FootprintLibCreate( lib_path1 ) + +# Verify that the same plugin instance can edge trigger on a lib_path change +# for a FootprintLibCreate() +plugin.FootprintLibCreate( lib_path2 ) + + +board = BOARD() + +# The only way to construct a MODULE is to pass it a BOARD? Yep. +module = MODULE( board ) + +fpid=FPID( 'mine' ) + +module.SetFPID( fpid ) + +plugin.FootprintSave( lib_path2, module ) + +# Verify that the same plugin instance can edge trigger on a lib_path change +# for a FootprintSave() +plugin.FootprintSave( lib_path1, module ) + +# create a disparity between the library's name ("footprint"), +# and the module's internal useless name ("mine"). Module is officially named "footprint" now +# but has (module mine ...) internally: +os.rename( '/tmp/lib2.pretty/mine.kicad_mod', '/tmp/lib2.pretty/footprint.kicad_mod' ) + +footprint=plugin.FootprintLoad( lib_path2, 'footprint' ) + +fpid = footprint.GetFPID() + +# Always after a FootprintLoad() the internal name should match the one used to load it. +print( "internal name should be 'footprint':", fpid.GetFootprintName() ) + +# Verify that the same plugin instance can edge trigger on a lib_path change +# for FootprintLoad() +footprint=plugin.FootprintLoad( lib_path1, 'mine' ) + +fpid = footprint.GetFPID() + +# Always after a FootprintLoad() the internal name should match the one used to load it. +print( "internal name should be 'mine':", fpid.GetFootprintName() ) + +# As of 3-Dec-2013 this test is passed by KICAD_PLUGIN and Wayne is owed an atta boy! + diff --git a/tools/make-UTF8.sh b/tools/make-UTF8.sh new file mode 100755 index 0000000000..8e57cf1ae2 --- /dev/null +++ b/tools/make-UTF8.sh @@ -0,0 +1,7 @@ + + +WXCONFIG=wx-config +#WXCONFIG=/opt/wx2.9/bin/wx-config + +g++ -g $($WXCONFIG --cppflags) UTF8.cpp -o test $($WXCONFIG --libs) +