diff --git a/3d-viewer/3d_canvas.cpp b/3d-viewer/3d_canvas.cpp index 248cd3bb3d..1764d6faa0 100644 --- a/3d-viewer/3d_canvas.cpp +++ b/3d-viewer/3d_canvas.cpp @@ -228,8 +228,6 @@ void EDA_3D_CANVAS::SetView3D( int keycode ) void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent& event ) { - wxSize size( GetClientSize() ); - if( event.ShiftDown() ) { if( event.GetWheelRotation() < 0 ) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5acfa0ac2..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 ) @@ -459,11 +457,6 @@ add_custom_target( uninstall # Installation #================================================ -add_custom_target( install_user_configuration_files - "${CMAKE_COMMAND}" -E copy "${PROJECT_SOURCE_DIR}/template/fp-lib-table" ${KICAD_USER_CONFIG_DIR}/ - COMMENT "Install template fp-lib-table into your home directory." - ) - install( FILES INSTALL.txt DESTINATION ${KICAD_DOCS} COMPONENT resources ) @@ -534,10 +527,6 @@ if( UNIX AND NOT APPLE ) #set( CPACK_PACKAGE_CONTACT Firstname Lastname ) set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "KiCad built by CMake build system." ) - # Tell debian CPack about all files which are configuration files - add_conffiles() # clear file - add_conffiles( ${KICAD_USER_CONFIG_DIR}/fp-lib-table ) # append to it - include( CPack ) endif() 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/TODO.txt b/TODO.txt index 8e8aa2df07..7a534122bb 100644 --- a/TODO.txt +++ b/TODO.txt @@ -62,10 +62,6 @@ PCBNew Dick's Final TODO List: ====================== -*) Rewrite - PCB_BASE_FRAME::Save_Module_In_Library - PCB_EDIT_FRAME::ArchiveModulesOnBoard - to use FP_LIB_TABLE mechanisms. *) Apply Fabrizio and Alexander's linux desktop patches after unifying them. *) Get licensing cleaned up. *) Re-arrange the repo architecture. diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index c701b467cc..dc0697f357 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..2368cb98f7 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; } @@ -386,7 +386,7 @@ void DXF_PLOTTER::ThickSegment( const wxPoint& aStart, const wxPoint& aEnd, int } } -/** Plot an arc in DXF format +/* Plot an arc in DXF format * Filling is not supported */ void DXF_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, int radius, @@ -397,6 +397,14 @@ void DXF_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, i if( radius <= 0 ) return; + // In DXF, arcs are drawn CCW. + // In Kicad, arcs are CW or CCW + // If StAngle > EndAngle, it is CW. So transform it to CCW + if( StAngle > EndAngle ) + { + EXCHG( StAngle, EndAngle ); + } + DPOINT centre_dev = userToDeviceCoordinates( centre ); double radius_dev = userToDeviceSize( radius ); @@ -425,6 +433,7 @@ void DXF_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, double EXCHG( size.x, size.y ); orient = AddAngles( orient, 900 ); } + sketchOval( pos, size, orient, -1 ); } 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/displlst.cpp b/common/displlst.cpp index e03910ee55..1717f2a0f8 100644 --- a/common/displlst.cpp +++ b/common/displlst.cpp @@ -1,7 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2007 Jean-Pierre Charras, jp.charras at wanadoo.fr + * 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 @@ -56,15 +57,39 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl InsertItems( aItemList, 0 ); - for( unsigned i = 0; i < aItemHeaders.Count(); i++ ) - m_listBox->SetColumnWidth( i, wxLIST_AUTOSIZE ); - if( m_callBackFct == NULL ) { m_messages->Show( false ); m_staticTextMsg->Show( false ); } + for( unsigned col = 0; col < aItemHeaders.Count(); ++col ) + { + m_listBox->SetColumnWidth( col, wxLIST_AUTOSIZE ); + +#if !wxCHECK_VERSION( 2, 9, 0 ) + // include the column header in the width decision, wx 2.8 forgets this: + wxListItem col_info; + + m_listBox->GetColumn( col, col_info ); + + wxString header = col_info.GetText(); + int headerz = GetTextSize( header, m_listBox ).x; + + // A reasonable column header has about 14 pixels of whitespace + // in addition to the width of the text itself. + headerz += 14; + + if( headerz > col_info.GetWidth() ) + { + col_info.SetWidth( headerz ); + + m_listBox->SetColumn( col, col_info ); + } +#endif + } + + #if !wxCHECK_VERSION( 2, 9, 0 ) // wx 2.8.x has bug in wxListCtrl WRT honoring the omission of wxHSCROLL, at least // on gtk2. Fix by setting minimum width so horizontal wxListCtrl scrolling is @@ -77,8 +102,6 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl width += m_listBox->GetColumnWidth( col ) + 2; } - //width += 40; // vert scroll bar. - wxSize sz = m_listBox->GetSize(); sz.SetWidth( width ); @@ -112,11 +135,6 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl } -EDA_LIST_DIALOG::~EDA_LIST_DIALOG() -{ -} - - void EDA_LIST_DIALOG::textChangeInFilterBox( wxCommandEvent& event ) { wxString filter; @@ -143,22 +161,24 @@ void EDA_LIST_DIALOG::textChangeInFilterBox( wxCommandEvent& event ) wxString EDA_LIST_DIALOG::GetTextSelection( int aColumn ) { - wxCHECK_MSG( aColumn < m_listBox->GetColumnCount(), wxEmptyString, + wxCHECK_MSG( unsigned( aColumn ) < unsigned( m_listBox->GetColumnCount() ), wxEmptyString, wxT( "Invalid list control column." ) ); - wxListItem info; - wxString text; - long item = -1; - item = m_listBox->GetNextItem( item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ); + long item = m_listBox->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ); - info.m_mask = wxLIST_MASK_TEXT; - info.m_itemId = item; - info.m_col = aColumn; + if( item >= 0 ) // if something is selected. + { + wxListItem info; - if( !m_listBox->GetItem( info ) ) - return wxEmptyString; + info.m_mask = wxLIST_MASK_TEXT; + info.m_itemId = item; + info.m_col = aColumn; - return info.m_text; + if( m_listBox->GetItem( info ) ) + return info.m_text; + } + + return wxEmptyString; } @@ -182,9 +202,9 @@ void EDA_LIST_DIALOG::InsertItems( const std::vector< wxArrayString >& itemList, { wxASSERT( (int) itemList[row].GetCount() == m_listBox->GetColumnCount() ); + long itemIndex = 0; for( unsigned col = 0; col < itemList[row].GetCount(); col++ ) { - long itemIndex; if( col == 0 ) { diff --git a/common/drawpanel.cpp b/common/drawpanel.cpp index 030f1328c9..a055fb83b8 100644 --- a/common/drawpanel.cpp +++ b/common/drawpanel.cpp @@ -906,11 +906,22 @@ void EDA_DRAW_PANEL::OnMouseWheel( wxMouseEvent& event ) bool offCenterReq = event.ControlDown() && event.ShiftDown(); offCenterReq = offCenterReq || m_enableZoomNoCenter; +#if wxMAJOR_VERSION >= 2 && wxMINOR_VERSION >= 9 + int axis = event.GetWheelAxis(); +#else + const int axis = 0; +#endif + // This is a zoom in or out command if( event.GetWheelRotation() > 0 ) { if( event.ShiftDown() && !event.ControlDown() ) - cmd.SetId( ID_PAN_UP ); + { + if( axis == 0 ) + cmd.SetId( ID_PAN_UP ); + else + cmd.SetId( ID_PAN_RIGHT ); + } else if( event.ControlDown() && !event.ShiftDown() ) cmd.SetId( ID_PAN_LEFT ); else if( offCenterReq ) @@ -921,7 +932,12 @@ void EDA_DRAW_PANEL::OnMouseWheel( wxMouseEvent& event ) else if( event.GetWheelRotation() < 0 ) { if( event.ShiftDown() && !event.ControlDown() ) - cmd.SetId( ID_PAN_DOWN ); + { + if( axis == 0 ) + cmd.SetId( ID_PAN_DOWN ); + else + cmd.SetId( ID_PAN_LEFT ); + } else if( event.ControlDown() && !event.ShiftDown() ) cmd.SetId( ID_PAN_RIGHT ); else if( offCenterReq ) diff --git a/common/drawpanel_gal.cpp b/common/drawpanel_gal.cpp index 3ec9568fde..aa30b5ba92 100644 --- a/common/drawpanel_gal.cpp +++ b/common/drawpanel_gal.cpp @@ -184,6 +184,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/eda_text.cpp b/common/eda_text.cpp index b1bda567cd..fdadf86c82 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -265,47 +265,17 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, { if( m_MultilineAllowed ) { + std::vector positions; wxArrayString* list = wxStringSplit( m_Text, '\n' ); + positions.reserve( list->Count() ); - wxPoint pos = m_Pos; // Position of first line of the - // multiline text according to - // the center of the multiline text block + GetPositionsOfLinesOfMultilineText(positions, list->Count() ); - wxPoint offset; // Offset to next line. - - offset.y = GetInterline(); - -#ifdef FIX_MULTILINE_VERT_JUSTIF - if( list->Count() > 1 ) + for( unsigned ii = 0; ii < list->Count(); ii++ ) { - switch( m_VJustify ) - { - case GR_TEXT_VJUSTIFY_TOP: - break; - - case GR_TEXT_VJUSTIFY_CENTER: - pos.y -= ( list->Count() - 1 ) * offset.y / 2; - break; - - case GR_TEXT_VJUSTIFY_BOTTOM: - pos.y -= ( list->Count() - 1 ) * offset.y; - break; - } - } - - // Rotate the position of the first line - // around the center of the multiline text block - RotatePoint( &pos, m_Pos, m_Orient ); -#endif - // Rotate the offset lines to increase happened in the right direction - RotatePoint( &offset, m_Orient ); - - for( unsigned i = 0; iCount(); i++ ) - { - wxString txt = list->Item( i ); + wxString& txt = list->Item( ii ); drawOneLineOfText( aClipBox, aDC, aOffset, aColor, - aDrawMode, aFillMode, txt, pos ); - pos += offset; + aDrawMode, aFillMode, txt, positions[ii] ); } delete (list); @@ -324,6 +294,49 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, } +void EDA_TEXT::GetPositionsOfLinesOfMultilineText( + std::vector& aPositions, int aLineCount ) +{ + wxPoint pos = m_Pos; // Position of first line of the + // multiline text according to + // the center of the multiline text block + + wxPoint offset; // Offset to next line. + + offset.y = GetInterline(); + +#ifdef FIX_MULTILINE_VERT_JUSTIF + if( aLineCount > 1 ) + { + switch( m_VJustify ) + { + case GR_TEXT_VJUSTIFY_TOP: + break; + + case GR_TEXT_VJUSTIFY_CENTER: + pos.y -= ( aLineCount - 1 ) * offset.y / 2; + break; + + case GR_TEXT_VJUSTIFY_BOTTOM: + pos.y -= ( aLineCount - 1 ) * offset.y; + break; + } + } + + // Rotate the position of the first line + // around the center of the multiline text block + RotatePoint( &pos, m_Pos, m_Orient ); +#endif + // Rotate the offset lines to increase happened in the right direction + RotatePoint( &offset, m_Orient ); + + for( int ii = 0; ii < aLineCount; ii++ ) + { + aPositions.push_back( pos ); + pos += offset; + } +} + void EDA_TEXT::drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode, 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 61166e4016..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() ); } @@ -179,11 +185,27 @@ MODULE* FP_LIB_TABLE::FootprintLoad( const wxString& aNickname, const wxString& } -void FP_LIB_TABLE::FootprintSave( const wxString& aNickname, const MODULE* aFootprint ) +FP_LIB_TABLE::SAVE_T FP_LIB_TABLE::FootprintSave( const wxString& aNickname, const MODULE* aFootprint, bool aOverwrite ) { const ROW* row = FindRow( aNickname ); wxASSERT( (PLUGIN*) row->plugin ); - return row->plugin->FootprintSave( row->GetFullURI( true ), aFootprint, row->GetProperties() ); + + if( !aOverwrite ) + { + // Try loading the footprint to see if it already exists, caller wants overwrite + // protection, which is atypical, not the default. + + wxString fpname = FROM_UTF8( aFootprint->GetFPID().GetFootprintName().c_str() ); + + std::auto_ptr m( row->plugin->FootprintLoad( row->GetFullURI( true ), fpname, row->GetProperties() ) ); + + if( m.get() ) + return SAVE_SKIPPED; + } + + row->plugin->FootprintSave( row->GetFullURI( true ), aFootprint, row->GetProperties() ); + + return SAVE_OK; } @@ -203,6 +225,22 @@ bool FP_LIB_TABLE::IsFootprintLibWritable( const wxString& aNickname ) } +void FP_LIB_TABLE::FootprintLibDelete( const wxString& aNickname ) +{ + const ROW* row = FindRow( aNickname ); + wxASSERT( (PLUGIN*) row->plugin ); + row->plugin->FootprintLibDelete( row->GetFullURI( true ), row->GetProperties() ); +} + + +void FP_LIB_TABLE::FootprintLibCreate( const wxString& aNickname ) +{ + const ROW* row = FindRow( aNickname ); + wxASSERT( (PLUGIN*) row->plugin ); + row->plugin->FootprintLibCreate( row->GetFullURI( true ), row->GetProperties() ); +} + + const wxString FP_LIB_TABLE::GetDescription( const wxString& aNickname ) { // use "no exception" form of find row: @@ -599,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 @@ -606,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/opengl/gpu_manager.cpp b/common/gal/opengl/gpu_manager.cpp index c3f15829ce..8b556b32ce 100644 --- a/common/gal/opengl/gpu_manager.cpp +++ b/common/gal/opengl/gpu_manager.cpp @@ -189,7 +189,7 @@ void GPU_CACHED_MANAGER::uploadToGpu() { #ifdef __WXDEBUG__ prof_counter totalTime; - prof_start( &totalTime, false ); + prof_start( &totalTime ); #endif /* __WXDEBUG__ */ if( !m_buffersInitialized ) @@ -214,8 +214,7 @@ void GPU_CACHED_MANAGER::uploadToGpu() #ifdef __WXDEBUG__ prof_end( &totalTime ); - wxLogDebug( wxT( "Uploading %d vertices to GPU / %.1f ms" ), - bufferSize, (double) totalTime.value / 1000.0 ); + wxLogDebug( wxT( "Uploading %d vertices to GPU / %.1f ms" ), bufferSize, totalTime.msecs() ); #endif /* __WXDEBUG__ */ } 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/math/math_util.cpp b/common/math/math_util.cpp index 9743acb1b2..d3f69e81a7 100644 --- a/common/math/math_util.cpp +++ b/common/math/math_util.cpp @@ -68,7 +68,7 @@ int64_t rescale( int64_t aNumerator, int64_t aValue, int64_t aDenominator ) a0 = a0 * b0 + t1a; a1 = a1 * b1 + ( t1 >> 32 ) + ( a0 < t1a ); a0 += r; - a1 += ( (uint64_t) a0 ) < r; + a1 += a0 < (uint64_t)r; for( i = 63; i >= 0; i-- ) { 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/profile.h b/common/profile.h deleted file mode 100644 index f779dfae59..0000000000 --- a/common/profile.h +++ /dev/null @@ -1,147 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2013 CERN - * @author Tomasz Wlostowski - * - * 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 - */ - -/** - * @file profile.h: - * @brief Simple profiling functions for measuring code execution time. - */ - -#ifndef __TPROFILE_H -#define __TPROFILE_H - -#include -#include - -/** - * Function rdtsc - * Returns processor's time-stamp counter. Main purpose is precise time measuring of code - * execution time. - * @return unsigned long long - Value of time-stamp counter. - */ -#if defined(__i386__) -static __inline__ unsigned long long rdtsc() -{ - unsigned long long int x; - __asm__ volatile ( ".byte 0x0f, 0x31" : "=A" ( x ) ); - - return x; -} - - -#elif defined(__x86_64__) -static __inline__ unsigned long long rdtsc() -{ - unsigned hi, lo; - __asm__ __volatile__ ( "rdtsc" : "=a" ( lo ), "=d" ( hi ) ); - - return ( (unsigned long long) lo ) | ( ( (unsigned long long) hi ) << 32 ); -} - - -#elif defined(__powerpc__) -static __inline__ unsigned long long rdtsc() -{ - unsigned long long int result = 0; - unsigned long int upper, lower, tmp; - __asm__ volatile ( - "0: \n" - "\tmftbu %0 \n" - "\tmftb %1 \n" - "\tmftbu %2 \n" - "\tcmpw %2,%0 \n" - "\tbne 0b \n" - : "=r" ( upper ), "=r" ( lower ), "=r" ( tmp ) - ); - - result = upper; - result = result << 32; - result = result | lower; - - return result; -} - - -#endif /* __powerpc__ */ - -// Fixme: OS X version -/** - * Function get_tics - * Returns the number of microseconds that have elapsed since the system was started. - * @return uint64_t Number of microseconds. - */ -static inline uint64_t get_tics() -{ - struct timeval tv; - gettimeofday( &tv, NULL ); - - return (uint64_t) tv.tv_sec * 1000000ULL + (uint64_t) tv.tv_usec; -} - - -/** - * Structure for storing data related to profiling counters. - */ -struct prof_counter -{ - uint64_t value; /// Stored timer value - bool use_rdtsc; /// Method of time measuring (rdtsc or tics) -}; - -/** - * Function prof_start - * Begins code execution time counting for a given profiling counter. - * @param cnt is the counter which should be started. - * @param use_rdtsc tells if processor's time-stamp counter should be used for time counting. - * Otherwise is system tics method will be used. IMPORTANT: time-stamp counter should not - * be used on multicore machines executing threaded code. - */ -static inline void prof_start( prof_counter* cnt, bool use_rdtsc ) -{ - cnt->use_rdtsc = use_rdtsc; - - if( use_rdtsc ) - { - cnt->value = rdtsc(); - } - else - { - cnt->value = get_tics(); - } -} - - -/** - * Function prof_stop - * Ends code execution time counting for a given profiling counter. - * @param cnt is the counter which should be stopped. - */ -static inline void prof_end( prof_counter* cnt ) -{ - if( cnt->use_rdtsc ) - cnt->value = rdtsc() - cnt->value; - else - cnt->value = get_tics() - cnt->value; -} - -#endif diff --git a/common/string.cpp b/common/string.cpp index 7bef64abb5..86b60d938f 100644 --- a/common/string.cpp +++ b/common/string.cpp @@ -1,3 +1,26 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2004 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 + * 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 + */ + /** * @file string.cpp * @brief Some useful functions to handle strings. @@ -5,9 +28,18 @@ #include #include +#include // StrPrintf #include +/** + * Illegal file name characters used to insure file names will be valid on all supported + * platforms. This is the list of illegal file name characters for Windows which includes + * the illegal file name characters for Linux and OSX. + */ +static const char illegalFileNameChars[] = "\\/:\"<>|"; + + int ReadDelimitedText( wxString* aDest, const char* aSource ) { std::string utf8; // utf8 but without escapes and quotes. @@ -414,3 +446,49 @@ int SplitString( wxString strToSplit, return 0; } + + +wxString GetIllegalFileNameWxChars() +{ + return FROM_UTF8( illegalFileNameChars ); +} + + +bool ReplaceIllegalFileNameChars( std::string* aName ) +{ + bool changed = false; + std::string result; + + for( std::string::iterator it = aName->begin(); it != aName->end(); ++it ) + { + if( strchr( illegalFileNameChars, *it ) ) + { + StrPrintf( &result, "%%%02x", *it ); + changed = true; + } + else + { + result += *it; + } + } + + if( changed ) + *aName = result; + + 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/system/fcontext.s b/common/system/fcontext.s index 7e6e8f9a86..fb81fbde7e 100644 --- a/common/system/fcontext.s +++ b/common/system/fcontext.s @@ -33,6 +33,10 @@ #include "jump_x86_64_sysv_elf_gas.S" #include "make_x86_64_sysv_elf_gas.S" + #elif __arm__ + #include "jump_arm_aapcs_elf_gas.S" + #include "make_arm_aapcs_elf_gas.S" + #else #error "Missing make_fcontext & jump_fcontext routines for this architecture" #endif diff --git a/common/system/jump_arm_aapcs_elf_gas.S b/common/system/jump_arm_aapcs_elf_gas.S new file mode 100644 index 0000000000..7c406f65ac --- /dev/null +++ b/common/system/jump_arm_aapcs_elf_gas.S @@ -0,0 +1,76 @@ +/* + Copyright Oliver Kowalke 2009. + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +*/ + +/******************************************************************* + * * + * ------------------------------------------------------------- * + * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | * + * ------------------------------------------------------------- * + * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| 0x20| 0x24| * + * ------------------------------------------------------------- * + * | v1 | v2 | v3 | v4 | v5 | v6 | v7 | v8 | sp | lr | * + * ------------------------------------------------------------- * + * ------------------------------------------------------------- * + * | 10 | | * + * ------------------------------------------------------------- * + * | 0x28| | * + * ------------------------------------------------------------- * + * | pc | | * + * ------------------------------------------------------------- * + * ------------------------------------------------------------- * + * | 11 | 12 | | * + * ------------------------------------------------------------- * + * | 0x2c| 0x30| | * + * ------------------------------------------------------------- * + * | sp | size| | * + * ------------------------------------------------------------- * + * ------------------------------------------------------------- * + * | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | * + * ------------------------------------------------------------- * + * | 0x34| 0x38|0x3c| 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58 | * + * ------------------------------------------------------------- * + * | s16 | s17 | s18 | s19 | s20 | s21 | s22 | s23 | s24 | s25 | * + * ------------------------------------------------------------- * + * ------------------------------------------------------------- * + * | 23 | 24 | 25 | 26 | 27 | 28 | | * + * ------------------------------------------------------------- * + * | 0x5c| 0x60| 0x64| 0x68| 0x6c| 0x70| | * + * ------------------------------------------------------------- * + * | s26 | s27 | s28 | s29 | s30 | s31 | | * + * ------------------------------------------------------------- * + * * + * *****************************************************************/ + +.text +.globl jump_fcontext +.align 2 +.type jump_fcontext,%function +jump_fcontext: + stmia a1, {v1-v8,sp-lr} @ save V1-V8,SP-LR + str lr, [a1,#40] @ save LR as PC + +#if (defined(__VFP_FP__) && !defined(__SOFTFP__)) + cmp a4, #0 @ test if fpu env should be preserved + beq 1f + + mov a4, a1 + add a4, #52 + vstmia a4, {d8-d15} @ save S16-S31 + + mov a4, a2 + add a4, #52 + vldmia a4, {d8-d15} @ restore S16-S31 +1: +#endif + + mov a1, a3 @ use third arg as return value after jump + @ and as first arg in context function + ldmia a2, {v1-v8,sp-pc} @ restore v1-V8,SP-PC +.size jump_fcontext,.-jump_fcontext + +/* Mark that we don't need executable stack. */ +.section .note.GNU-stack,"",%progbits diff --git a/common/system/make_arm_aapcs_elf_gas.S b/common/system/make_arm_aapcs_elf_gas.S new file mode 100644 index 0000000000..ca3206067a --- /dev/null +++ b/common/system/make_arm_aapcs_elf_gas.S @@ -0,0 +1,79 @@ +/* + Copyright Oliver Kowalke 2009. + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +*/ + +/******************************************************************* + * * + * ------------------------------------------------------------- * + * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | * + * ------------------------------------------------------------- * + * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| 0x20| 0x24| * + * ------------------------------------------------------------- * + * | v1 | v2 | v3 | v4 | v5 | v6 | v7 | v8 | sp | lr | * + * ------------------------------------------------------------- * + * ------------------------------------------------------------- * + * | 10 | | * + * ------------------------------------------------------------- * + * | 0x28| | * + * ------------------------------------------------------------- * + * | pc | | * + * ------------------------------------------------------------- * + * ------------------------------------------------------------- * + * | 11 | 12 | | * + * ------------------------------------------------------------- * + * | 0x2c| 0x30| | * + * ------------------------------------------------------------- * + * | sp | size| | * + * ------------------------------------------------------------- * + * ------------------------------------------------------------- * + * | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | * + * ------------------------------------------------------------- * + * | 0x34| 0x38|0x3c| 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58 | * + * ------------------------------------------------------------- * + * | s16 | s17 | s18 | s19 | s20 | s21 | s22 | s23 | s24 | s25 | * + * ------------------------------------------------------------- * + * ------------------------------------------------------------- * + * | 23 | 24 | 25 | 26 | 27 | 28 | | * + * ------------------------------------------------------------- * + * | 0x5c| 0x60| 0x64| 0x68| 0x6c| 0x70| | * + * ------------------------------------------------------------- * + * | s26 | s27 | s28 | s29 | s30 | s31 | | * + * ------------------------------------------------------------- * + * * + * *****************************************************************/ + +.text +.globl make_fcontext +.align 2 +.type make_fcontext,%function +make_fcontext: + mov a4, a1 @ save address of context stack (base) A4 + sub a1, a1, #116 @ reserve space for fcontext_t at top of context stack + + @ shift address in A1 to lower 16 byte boundary + @ == pointer to fcontext_t and address of context stack + bic a1, a1, #15 + + str a4, [a1,#44] @ save address of context stack (base) in fcontext_t + str a2, [a1,#48] @ save context stack size in fcontext_t + str a3, [a1,#40] @ save address of context function in fcontext_t + + str a1, [a1,#32] @ save address in A4 as stack pointer for context function + + adr a2, finish @ compute abs address of label finish + str a2, [a1,#36] @ save address of finish as return address for context function + @ entered after context function returns + + bx lr + +finish: + @ SP points to same addras SP on entry of context function + mov a1, #0 @ exit code is zero + bl _exit@PLT @ exit application +.size make_fcontext,.-make_fcontext + +/* Mark that we don't need executable stack. */ +.section .note.GNU-stack,"",%progbits diff --git a/common/tool/tool_event.cpp b/common/tool/tool_event.cpp index 15ae3314e7..402f9798f2 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; @@ -153,7 +151,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 75ac02574e..6d887a291c 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/validators.cpp b/common/validators.cpp new file mode 100644 index 0000000000..86a2a6d1db --- /dev/null +++ b/common/validators.cpp @@ -0,0 +1,48 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2013 Wayne Stambaugh + * 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 + * 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 + */ + +/** + * @file validators.cpp + * @brief Custom text control validator implementations. + */ + +#include +#include + + +FOOTPRINT_NAME_VALIDATOR::FOOTPRINT_NAME_VALIDATOR( wxString* aValue ) : + wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue ) +{ + // The Windows (DOS) file system forbidden characters already include the forbidden + // file name characters for both Posix and OSX systems. The characters \/*?|"<> are + // illegal and filtered by the validator. + wxString illegalChars = GetIllegalFileNameWxChars(); + wxTextValidator nameValidator( wxFILTER_EXCLUDE_CHAR_LIST ); + wxArrayString illegalCharList; + + for( unsigned i = 0; i < illegalChars.size(); i++ ) + illegalCharList.Add( wxString( illegalChars[i] ) ); + + SetExcludes( illegalCharList ); +} diff --git a/common/view/view.cpp b/common/view/view.cpp index 078fa0b907..8bde0d5aca 100644 --- a/common/view/view.cpp +++ b/common/view/view.cpp @@ -153,10 +153,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; @@ -387,7 +389,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 ); @@ -395,6 +397,8 @@ struct VIEW::updateItemsColor if( group >= 0 ) gal->ChangeGroupColor( group, color ); + + return true; } int layer; @@ -447,12 +451,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; @@ -571,15 +577,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; @@ -676,9 +684,11 @@ bool VIEW::IsDirty() const struct VIEW::unlinkItem { - void operator()( VIEW_ITEM* aItem ) + bool operator()( VIEW_ITEM* aItem ) { aItem->m_view = NULL; + + return true; } }; @@ -690,7 +700,7 @@ struct VIEW::recacheItem { } - void operator()( VIEW_ITEM* aItem ) + bool operator()( VIEW_ITEM* aItem ) { // Remove previously cached group int prevGroup = aItem->getGroup( layer ); @@ -712,6 +722,8 @@ struct VIEW::recacheItem { aItem->setGroup( layer, -1 ); } + + return true; } VIEW* view; @@ -792,12 +804,14 @@ struct VIEW::clearLayerCache { } - void operator()( VIEW_ITEM* aItem ) + bool operator()( VIEW_ITEM* aItem ) { if( aItem->storesGroups() ) { aItem->deleteGroups(); } + + return true; } VIEW* view; @@ -971,7 +985,7 @@ void VIEW::RecacheAllItems( bool aImmediately ) #ifdef __WXDEBUG__ prof_counter totalRealTime; - prof_start( &totalRealTime, false ); + prof_start( &totalRealTime ); #endif /* __WXDEBUG__ */ for( LAYER_MAP_ITER i = m_layers.begin(); i != m_layers.end(); ++i ) @@ -992,7 +1006,7 @@ void VIEW::RecacheAllItems( bool aImmediately ) prof_end( &totalRealTime ); wxLogDebug( wxT( "RecacheAllItems::immediately: %u %.1f ms" ), - aImmediately, (double) totalRealTime.value / 1000.0 ); + aImmediately, totalRealTime.msecs() ); #endif /* __WXDEBUG__ */ } 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_edit_libentry_fields_in_lib_base.cpp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.cpp index f46a64ed50..a859617859 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.cpp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 30 2013) +// C++ code generated with wxFormBuilder (version Nov 5 2013) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -43,7 +43,7 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE bSizerFiledsList->Add( moveUpButton, 0, wxALL|wxEXPAND, 5 ); - bSizerFieldsSetup->Add( bSizerFiledsList, 1, wxEXPAND, 5 ); + bSizerFieldsSetup->Add( bSizerFiledsList, 3, wxEXPAND, 5 ); wxBoxSizer* fieldEditBoxSizer; fieldEditBoxSizer = new wxBoxSizer( wxVERTICAL ); @@ -179,7 +179,7 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE fieldEditBoxSizer->Add( fgSizerPosSize, 1, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 ); - bSizerFieldsSetup->Add( fieldEditBoxSizer, 0, wxEXPAND, 5 ); + bSizerFieldsSetup->Add( fieldEditBoxSizer, 2, wxEXPAND, 5 ); mainSizer->Add( bSizerFieldsSetup, 1, wxEXPAND, 5 ); diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.fbp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.fbp index 6cb1bc0d36..d6a0535ca9 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.fbp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.fbp @@ -20,8 +20,10 @@ . 1 + 1 1 1 + UI 0 0 @@ -45,7 +47,7 @@ -1,-1 wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU - Fields Properties + Field Properties @@ -103,17 +105,17 @@ 5 wxEXPAND - 1 - + 3 + bSizerFiledsList wxVERTICAL none - + 8 wxEXPAND|wxTOP|wxRIGHT|wxLEFT 1 - + 1 1 1 @@ -214,11 +216,11 @@ - + 5 wxEXPAND|wxTOP|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -302,11 +304,11 @@ - + 5 wxEXPAND|wxTOP|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -390,11 +392,11 @@ - + 5 wxALL|wxEXPAND 0 - + 1 1 1 @@ -483,7 +485,7 @@ 5 wxEXPAND - 0 + 2 fieldEditBoxSizer diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.h b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.h index d08d4756dc..82188f2008 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.h +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 30 2013) +// C++ code generated with wxFormBuilder (version Nov 5 2013) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -80,7 +80,7 @@ class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE : public wxDialog public: - DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Fields Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU ); + DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Field Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU ); ~DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE(); }; 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 ea7c521d00..d83c892591 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -1229,7 +1229,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg ) int multi = atoi( name1 ); - if( multi < 0 || multi > 25 ) + if( multi < 0 || multi > 26 ) multi = 1; AddHierarchicalReference( path, ref, multi ); @@ -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 c719cff2b1..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 ) @@ -673,20 +673,17 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter ) if( m_MultilineAllowed ) { - wxPoint pos = textpos; + std::vector positions; wxArrayString* list = wxStringSplit( m_Text, '\n' ); - wxPoint offset; + positions.reserve( list->Count() ); - offset.y = GetInterline(); + GetPositionsOfLinesOfMultilineText(positions, list->Count() ); - RotatePoint( &offset, m_Orient ); - - for( unsigned i = 0; iCount(); i++ ) + for( unsigned ii = 0; ii < list->Count(); ii++ ) { - wxString txt = list->Item( i ); - aPlotter->Text( pos, color, txt, m_Orient, m_Size, m_HJustify, + wxString& txt = list->Item( ii ); + aPlotter->Text( positions[ii], color, txt, m_Orient, m_Size, m_HJustify, m_VJustify, thickness, m_Italic, m_Bold ); - pos += offset; } delete (list); 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/dialog_helpers.h b/include/dialog_helpers.h index dc621cab8a..9b33e23d37 100644 --- a/include/dialog_helpers.h +++ b/include/dialog_helpers.h @@ -74,7 +74,8 @@ public: const wxString& aRefText, void(*aCallBackFunction)(wxString& Text) = NULL, bool aSortList = false ); - ~EDA_LIST_DIALOG(); + + // ~EDA_LIST_DIALOG() {} void Append( const wxArrayString& aItemStr ); void InsertItems( const std::vector& aItemList, int aPosition = 0 ); diff --git a/include/eda_text.h b/include/eda_text.h index b5988c244f..7de9dbd2c7 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -265,6 +265,17 @@ public: void SetHorizJustify( EDA_TEXT_HJUSTIFY_T aType ) { m_HJustify = aType; }; void SetVertJustify( EDA_TEXT_VJUSTIFY_T aType ) { m_VJustify = aType; }; + /** + * Function GetPositionsOfLinesOfMultilineText + * Populates aPositions with the position of each line of + * a multiline text, according to the vertical justification and the + * rotation of the whole text + * @param aPositions is the list to populate by the wxPoint positions + * @param aLineCount is the number of lines (not recalculated here + * for efficiency reasons + */ + void GetPositionsOfLinesOfMultilineText( + std::vector& aPositions, int aLineCount ); /** * Function Format * outputs the object to \a aFormatter in s-expression form. 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 4b7b3d9a43..43dcf7e62a 100644 --- a/include/fp_lib_table.h +++ b/include/fp_lib_table.h @@ -394,6 +394,16 @@ public: */ MODULE* FootprintLoad( const wxString& aNickname, const wxString& aFootprintName ); + /** + * Enum SAVE_T + * is the set of return values from FootprintSave() below. + */ + enum SAVE_T + { + SAVE_OK, + SAVE_SKIPPED, + }; + /** * Function FootprintSave * will write @a aFootprint to an existing library given by @a aNickname. @@ -405,9 +415,14 @@ public: * @param aFootprint is what to store in the library. The caller continues * to own the footprint after this call. * + * @param aOverwrite when true means overwrite any existing footprint by the + * same name, else if false means skip the write and return SAVE_SKIPPED. + * + * @return SAVE_T - SAVE_OK or SAVE_SKIPPED. If error saving, then IO_ERROR is thrown. + * * @throw IO_ERROR if there is a problem saving. */ - void FootprintSave( const wxString& aNickname, const MODULE* aFootprint ); + SAVE_T FootprintSave( const wxString& aNickname, const MODULE* aFootprint, bool aOverwrite = true ); /** * Function FootprintDelete @@ -431,6 +446,10 @@ public: */ bool IsFootprintLibWritable( const wxString& aNickname ); + void FootprintLibDelete( const wxString& aNickname ); + + void FootprintLibCreate( const wxString& aNickname ); + //-------------------------------- /** @@ -621,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 91d5a0ad0c..ee13446132 100644 --- a/include/kicad_string.h +++ b/include/kicad_string.h @@ -1,6 +1,27 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2004 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 + * 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 + */ + /** - * This file is part of the common library \n - * Custom string manipulation routines. * @file kicad_string.h * @see common.h, string.cpp */ @@ -10,6 +31,7 @@ #define KICAD_STRING_H_ #include +#include /** @@ -57,7 +79,7 @@ std::string EscapedUTF8( const wxString& aString ); char* GetLine( FILE* aFile, char* Line, int* LineNum = NULL, int SizeLine = 255 ); /** - * Funxtion StrPurge + * Function StrPurge * removes leading and training spaces, tabs and end of line chars in \a text * return a pointer on the first n char in text */ @@ -79,7 +101,7 @@ wxString DateAndTime(); * * @param aString1 A wxChar pointer to the reference string. * @param aString2 A wxChar pointer to the comparison string. - * @param aLength The numbere of characters to compare. Set to -1 to compare + * @param aLength The number of characters to compare. Set to -1 to compare * the entire string. * @param aIgnoreCase Use true to make the comparison case insensitive. * @return An integer value of -1 if \a aString1 is less than \a aString2, 0 if @@ -121,4 +143,42 @@ int SplitString( wxString strToSplit, wxString* strDigits, wxString* strEnd ); +/** + * Function GetIllegalFileNameWxChars + * @return a wString object containing the illegal file name characters for all platforms. + */ +wxString GetIllegalFileNameWxChars(); + +/** + * Function ReplaceIllegalFileNameChars + * checks \a aName for illegal file name characters. + * + * The Windows (DOS) file system forbidden characters already include the forbidden file + * name characters for both Posix and OSX systems. The characters \/?*|"\<\> are illegal + * and are replaced with %xx where xx the hexadecimal equivalent of the replaced character. + * This replacement may not be as elegant as using an underscore ('_') or hyphen ('-') but + * it guarentees that there will be no naming conflicts when fixing footprint library names. + * + * @param aName is a point to a std::string object containing the footprint name to verify. + * @return true if any characters have been replaced in \a aName. + */ +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/profile.h b/include/profile.h index f779dfae59..c0b1010faa 100644 --- a/include/profile.h +++ b/include/profile.h @@ -31,60 +31,9 @@ #define __TPROFILE_H #include +#include #include -/** - * Function rdtsc - * Returns processor's time-stamp counter. Main purpose is precise time measuring of code - * execution time. - * @return unsigned long long - Value of time-stamp counter. - */ -#if defined(__i386__) -static __inline__ unsigned long long rdtsc() -{ - unsigned long long int x; - __asm__ volatile ( ".byte 0x0f, 0x31" : "=A" ( x ) ); - - return x; -} - - -#elif defined(__x86_64__) -static __inline__ unsigned long long rdtsc() -{ - unsigned hi, lo; - __asm__ __volatile__ ( "rdtsc" : "=a" ( lo ), "=d" ( hi ) ); - - return ( (unsigned long long) lo ) | ( ( (unsigned long long) hi ) << 32 ); -} - - -#elif defined(__powerpc__) -static __inline__ unsigned long long rdtsc() -{ - unsigned long long int result = 0; - unsigned long int upper, lower, tmp; - __asm__ volatile ( - "0: \n" - "\tmftbu %0 \n" - "\tmftb %1 \n" - "\tmftbu %2 \n" - "\tcmpw %2,%0 \n" - "\tbne 0b \n" - : "=r" ( upper ), "=r" ( lower ), "=r" ( tmp ) - ); - - result = upper; - result = result << 32; - result = result | lower; - - return result; -} - - -#endif /* __powerpc__ */ - -// Fixme: OS X version /** * Function get_tics * Returns the number of microseconds that have elapsed since the system was started. @@ -98,14 +47,22 @@ static inline uint64_t get_tics() return (uint64_t) tv.tv_sec * 1000000ULL + (uint64_t) tv.tv_usec; } - /** * Structure for storing data related to profiling counters. */ struct prof_counter { - uint64_t value; /// Stored timer value - bool use_rdtsc; /// Method of time measuring (rdtsc or tics) + uint64_t start, end; // Stored timer value + + uint64_t usecs() const + { + return end - start; + } + + float msecs() const + { + return ( end - start ) / 1000.0; + } }; /** @@ -116,32 +73,19 @@ struct prof_counter * Otherwise is system tics method will be used. IMPORTANT: time-stamp counter should not * be used on multicore machines executing threaded code. */ -static inline void prof_start( prof_counter* cnt, bool use_rdtsc ) +static inline void prof_start( prof_counter* aCnt ) { - cnt->use_rdtsc = use_rdtsc; - - if( use_rdtsc ) - { - cnt->value = rdtsc(); - } - else - { - cnt->value = get_tics(); - } + aCnt->start = get_tics(); } - /** * Function prof_stop * Ends code execution time counting for a given profiling counter. * @param cnt is the counter which should be stopped. */ -static inline void prof_end( prof_counter* cnt ) +static inline void prof_end( prof_counter* aCnt ) { - if( cnt->use_rdtsc ) - cnt->value = rdtsc() - cnt->value; - else - cnt->value = get_tics() - cnt->value; + aCnt->end = get_tics(); } #endif 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/validators.h b/include/validators.h new file mode 100644 index 0000000000..ca98be89ab --- /dev/null +++ b/include/validators.h @@ -0,0 +1,57 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2013 Wayne Stambaugh + * 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 + * 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 + */ + +/** + * @file validators.h + * @brief Custom text control validator definitions. + */ + +#include + +/** + * Class FOOTPRINT_NAME_VALIDATOR + * + * This class provides a custom wxValidator object for limiting the allowable characters when + * defining footprint names. Since the introduction of the PRETTY footprint library format, + * footprint names cannot have any characters that would prevent file creation on any platform. + */ +class FOOTPRINT_NAME_VALIDATOR : public wxTextValidator +{ +public: + FOOTPRINT_NAME_VALIDATOR( wxString* aValue = NULL ) : + wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue ) + { + // The Windows (DOS) file system forbidden characters already include the forbidden + // file name characters for both Posix and OSX systems. The characters \/*?|"<> are + // illegal and filtered by the validator. + wxString illegalChars = wxFileName::GetForbiddenChars( wxPATH_DOS ); + wxTextValidator nameValidator( wxFILTER_EXCLUDE_CHAR_LIST ); + wxArrayString illegalCharList; + + for( unsigned i = 0; i < illegalChars.size(); i++ ) + illegalCharList.Add( wxString( illegalChars[i] ) ); + + SetExcludes( illegalCharList ); + } +}; 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/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index 1eaae3598f..2587881354 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -293,7 +293,7 @@ public: * @param aLibName = name of the library to use * @param aModule = the given footprint * @param aOverwrite = true to overwrite an existing footprint, false to - * abort an existing footprint is found + * abort if an existing footprint with same name is found * @param aDisplayDialog = true to display a dialog to enter or confirm the * footprint name * @return : true if OK, false if abort @@ -303,6 +303,16 @@ public: bool aOverwrite, bool aDisplayDialog ); + /** + * Function SelectLibrary + * puts up a dialog and allows the user to pick a library, for unspecified use. + * + * @param aNicknameExisting is the current choice to highlight + * + * @return wxString - the library or wxEmptyString on abort. + */ + wxString SelectLibrary( const wxString& aNicknameExisting ); + MODULE* GetModuleByName(); /** diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index c6b67b8086..05e4e0dbfc 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. @@ -119,7 +122,7 @@ protected: void setupTools(); void destroyTools(); - void onGenericCommand( wxCommandEvent& aEvent ); + void onGenericCommand( wxCommandEvent& aEvent ); // we'll use lower case function names for private member functions. void createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu* aPopMenu ); @@ -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 ); @@ -922,12 +928,11 @@ public: /** * Function ArchiveModulesOnBoard * Save modules in a library: - * @param aLibName: the full filename of the library to create or modify * @param aNewModulesOnly: * true : save modules not already existing in this lib * false: save all modules */ - void ArchiveModulesOnBoard( const wxString& aLibName, bool aNewModulesOnly ); + void ArchiveModulesOnBoard( bool aNewModulesOnly ); /** * Function RecreateBOMFileFromBoard @@ -1511,7 +1516,7 @@ public: // Autoplacement: - void AutoPlace( wxCommandEvent& event ); + void OnPlaceOrRouteFootprints( wxCommandEvent& event ); /** * Function ScriptingConsoleEnableDisable @@ -1537,7 +1542,17 @@ public: */ bool ReOrientModules( const wxString& ModuleMask, double Orient, bool include_fixe ); void LockModule( MODULE* aModule, bool aLocked ); - void AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ); + + /** + * Function SpreadFootprints + * Footprints (after loaded by reading a netlist for instance) are moved + * to be in a small free area (outside the current board) without overlapping. + * @param aFootprintsOutsideBoardOnly: true to move only + * footprints outside the board outlines + * (they are outside if the position of a footprint is outside + * the board outlines bounding box + */ + void SpreadFootprints( bool aFootprintsOutsideBoardOnly ); /** * Function AutoPlaceModule 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/lib_dxf/libdxfrw.cpp b/lib_dxf/libdxfrw.cpp index ffbba1161a..2390b38bed 100644 --- a/lib_dxf/libdxfrw.cpp +++ b/lib_dxf/libdxfrw.cpp @@ -1683,7 +1683,7 @@ DRW_ImageDef* dxfRW::writeImage( DRW_Image* ent, std::string name ) writer->writeInt16( 282, ent->contrast ); writer->writeInt16( 283, ent->fade ); writer->writeString( 360, idReactor ); - id->reactors[idReactor] = ent->handle; + id->reactors[idReactor] = toHexStr( ent->handle ); return id; } @@ -3817,9 +3817,9 @@ bool dxfRW::processImageDef() std::string dxfRW::toHexStr( int n ) { #if defined(__APPLE__) - std::string buffer( 9, '\0' ); - snprintf( &buffer[0], 9, "%X", n ); - return buffer; + char buffer[9] = { '\0' }; + snprintf( buffer, 9, "%X", n ); + return std::string( buffer ); #else std::ostringstream Convert; Convert << std::uppercase << std::hex << n; 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 b5f5e621fe..24c30ccea8 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -124,12 +124,14 @@ set( PCBNEW_IMPORT_DXF ) set( PCBNEW_AUTOROUTER_SRCS - autorouter/automove.cpp - autorouter/autoplac.cpp + autorouter/rect_placement/rect_placement.cpp + autorouter/move_and_route_event_functions.cpp + autorouter/auto_place_footprints.cpp autorouter/autorout.cpp autorouter/routing_matrix.cpp autorouter/dist.cpp autorouter/queue.cpp + autorouter/spread_footprints.cpp autorouter/solve.cpp autorouter/graphpcb.cpp autorouter/work.cpp @@ -379,6 +381,7 @@ if( KICAD_SCRIPTING_MODULES ) ${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 +551,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/autorouter/autoplac.cpp b/pcbnew/autorouter/auto_place_footprints.cpp similarity index 99% rename from pcbnew/autorouter/autoplac.cpp rename to pcbnew/autorouter/auto_place_footprints.cpp index fb604103e0..7322f5690b 100644 --- a/pcbnew/autorouter/autoplac.cpp +++ b/pcbnew/autorouter/auto_place_footprints.cpp @@ -1085,7 +1085,7 @@ static bool Tri_PlaceModules( MODULE* ref, MODULE* compare ) } -static bool Tri_RatsModules( MODULE* ref, MODULE* compare ) +static bool sortFootprintsByRatsnestSize( MODULE* ref, MODULE* compare ) { double ff1, ff2; @@ -1141,7 +1141,7 @@ static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC ) pcbframe->GetBoard()->m_Status_Pcb &= ~RATSNEST_ITEM_LOCAL_OK; - sort( moduleList.begin(), moduleList.end(), Tri_RatsModules ); + sort( moduleList.begin(), moduleList.end(), sortFootprintsByRatsnestSize ); // Search for "best" module. MODULE* bestModule = NULL; diff --git a/pcbnew/autorouter/automove.cpp b/pcbnew/autorouter/move_and_route_event_functions.cpp similarity index 55% rename from pcbnew/autorouter/automove.cpp rename to pcbnew/autorouter/move_and_route_event_functions.cpp index 19d04e5885..8fb6ffcf56 100644 --- a/pcbnew/autorouter/automove.cpp +++ b/pcbnew/autorouter/move_and_route_event_functions.cpp @@ -55,15 +55,13 @@ typedef enum { } SelectFixeFct; -static bool sortModulesbySize( MODULE* ref, MODULE* compare ); - wxString ModulesMaskSelection = wxT( "*" ); /* Called on events (popup menus) relative to automove and autoplace footprints */ -void PCB_EDIT_FRAME::AutoPlace( wxCommandEvent& event ) +void PCB_EDIT_FRAME::OnPlaceOrRouteFootprints( wxCommandEvent& event ) { int id = event.GetId(); @@ -130,12 +128,19 @@ void PCB_EDIT_FRAME::AutoPlace( wxCommandEvent& event ) AutoPlaceModule( NULL, PLACE_INCREMENTAL, &dc ); break; - case ID_POPUP_PCB_AUTOMOVE_ALL_MODULES: - AutoMoveModulesOnPcb( false ); - break; + case ID_POPUP_PCB_SPREAD_ALL_MODULES: + if( !IsOK( this, + _("Not locked footprints inside the board will be moved. OK?") ) ) + break; + // Fall through + case ID_POPUP_PCB_SPREAD_NEW_MODULES: + if( GetBoard()->m_Modules == NULL ) + { + DisplayError( this, _( "No modules found!" ) ); + return; + } - case ID_POPUP_PCB_AUTOMOVE_NEW_MODULES: - AutoMoveModulesOnPcb( true ); + SpreadFootprints( id == ID_POPUP_PCB_SPREAD_NEW_MODULES ); break; case ID_POPUP_PCB_AUTOROUTE_ALL_MODULES: @@ -159,7 +164,7 @@ void PCB_EDIT_FRAME::AutoPlace( wxCommandEvent& event ) break; default: - wxMessageBox( wxT( "AutoPlace command error" ) ); + wxMessageBox( wxT( "OnPlaceOrRouteFootprints command error" ) ); break; } @@ -168,135 +173,6 @@ void PCB_EDIT_FRAME::AutoPlace( wxCommandEvent& event ) } -/* Function to move components in a rectangular area format 4 / 3, - * starting from the mouse cursor - * The components with the FIXED status set are not moved - */ -void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) -{ - std::vector moduleList; - wxPoint start, current; - int Ymax_size, Xsize_allowed; - int pas_grille = (int) GetScreen()->GetGridSize().x; - double surface; - - // Undo: init list - PICKED_ITEMS_LIST newList; - newList.m_Status = UR_CHANGED; - ITEM_PICKER picker( NULL, UR_CHANGED ); - - if( GetBoard()->m_Modules == NULL ) - { - DisplayError( this, _( "No modules found!" ) ); - return; - } - - // Confirmation - if( !IsOK( this, _( "Move modules?" ) ) ) - return; - - EDA_RECT bbbox = GetBoard()->ComputeBoundingBox( true ); - - bool edgesExist = ( bbbox.GetWidth() || bbbox.GetHeight() ); - - // no edges exist - if( PlaceModulesHorsPcb && !edgesExist ) - { - DisplayError( this, - _( "Could not automatically place modules. No board outlines detected." ) ); - return; - } - - // Build sorted footprints list (sort by decreasing size ) - MODULE* Module = GetBoard()->m_Modules; - - for( ; Module != NULL; Module = Module->Next() ) - { - Module->CalculateBoundingBox(); - moduleList.push_back(Module); - } - - sort( moduleList.begin(), moduleList.end(), sortModulesbySize ); - - /* to move modules outside the board, the cursor is placed below - * the current board, to avoid placing components in board area. - */ - if( PlaceModulesHorsPcb && edgesExist ) - { - if( GetCrossHairPosition().y < (bbbox.GetBottom() + 2000) ) - { - wxPoint pos = GetCrossHairPosition(); - pos.y = bbbox.GetBottom() + 2000; - SetCrossHairPosition( pos ); - } - } - - // calculate the area needed by footprints - surface = 0.0; - - for( unsigned ii = 0; ii < moduleList.size(); ii++ ) - { - Module = moduleList[ii]; - - if( PlaceModulesHorsPcb && edgesExist ) - { - if( bbbox.Contains( Module->GetPosition() ) ) - continue; - } - - surface += Module->GetArea(); - } - - Xsize_allowed = (int) ( sqrt( surface ) * 4.0 / 3.0 ); - - start = current = GetCrossHairPosition(); - Ymax_size = 0; - - for( unsigned ii = 0; ii < moduleList.size(); ii++ ) - { - Module = moduleList[ii]; - - if( Module->IsLocked() ) - continue; - - if( PlaceModulesHorsPcb && edgesExist ) - { - if( bbbox.Contains( Module->GetPosition() ) ) - continue; - } - - // Undo: add copy of old Module to undo - picker.SetItem( Module ); - picker.SetLink( Module->Clone() ); - - if( current.x > (Xsize_allowed + start.x) ) - { - current.x = start.x; - current.y += Ymax_size + pas_grille; - Ymax_size = 0; - } - - SetCrossHairPosition( current + Module->GetPosition() - - Module->GetBoundingBox().GetPosition() ); - - Ymax_size = std::max( Ymax_size, Module->GetBoundingBox().GetHeight() ); - - PlaceModule( Module, NULL, true ); - - // Undo: add new Module to undo - newList.PushItem( picker ); - - current.x += Module->GetBoundingBox().GetWidth() + pas_grille; - } - - // Undo: commit - if( newList.GetCount() ) - SaveCopyInUndoList( newList, UR_CHANGED ); - - m_canvas->Refresh(); -} - - /* Set or reset (true or false) Lock attribute of aModule or all modules if aModule == NULL */ void PCB_EDIT_FRAME::LockModule( MODULE* aModule, bool aLocked ) @@ -322,8 +198,3 @@ void PCB_EDIT_FRAME::LockModule( MODULE* aModule, bool aLocked ) } } - -static bool sortModulesbySize( MODULE* ref, MODULE* compare ) -{ - return compare->GetArea() < ref->GetArea(); -} diff --git a/pcbnew/autorouter/rect_placement/RectanglePlacement.txt b/pcbnew/autorouter/rect_placement/RectanglePlacement.txt new file mode 100644 index 0000000000..cecbf2efd9 --- /dev/null +++ b/pcbnew/autorouter/rect_placement/RectanglePlacement.txt @@ -0,0 +1,38 @@ +A class that fits subrectangles into a power-of-2 rectangle + +(C) Copyright 2000-2002 by Javier Arevalo +This code is free to use and modify for all purposes + +You have a bunch of rectangular pieces. You need to arrange them in a +rectangular surface so that they don't overlap, keeping the total area of the +rectangle as small as possible. This is fairly common when arranging characters +in a bitmapped font, lightmaps for a 3D engine, and I guess other situations as +well. + +The idea of this algorithm is that, as we add rectangles, we can pre-select +"interesting" places where we can try to add the next rectangles. For optimal +results, the rectangles should be added in order. I initially tried using area +as a sorting criteria, but it didn't work well with very tall or very flat +rectangles. I then tried using the longest dimension as a selector, and it +worked much better. So much for intuition... + +These "interesting" places are just to the right and just below the currently +added rectangle. The first rectangle, obviously, goes at the top left, the next +one would go either to the right or below this one, and so on. It is a weird way +to do it, but it seems to work very nicely. + +The way we search here is fairly brute-force, the fact being that for most off- +line purposes the performance seems more than adequate. I have generated a +japanese font with around 8500 characters and all the time was spent generating +the bitmaps. + +Also, for all we care, we could grow the parent rectangle in a different way +than power of two. It just happens that power of 2 is very convenient for +graphics hardware textures. + +I'd be interested in hearing of other approaches to this problem. Make sure +to post them on http://www.flipcode.com + +See also +http://www.flipcode.com/archives/Rectangle_Placement.shtml +http://kossovsky.net/index.php/2009/07/cshar-rectangle-packing diff --git a/pcbnew/autorouter/rect_placement/rect_placement.cpp b/pcbnew/autorouter/rect_placement/rect_placement.cpp new file mode 100644 index 0000000000..f562c2b9ae --- /dev/null +++ b/pcbnew/autorouter/rect_placement/rect_placement.cpp @@ -0,0 +1,259 @@ +// ---------------------------------------------------------------------------------------- +// Name : rect_placement.cpp +// Description : A class that fits subrectangles into a power-of-2 rectangle +// (C) Copyright 2000-2002 by Javier Arevalo +// This code is free to use and modify for all purposes +// ---------------------------------------------------------------------------------------- + +/* + * You have a bunch of rectangular pieces. You need to arrange them in a + * rectangular surface so that they don't overlap, keeping the total area of the + * rectangle as small as possible. This is fairly common when arranging characters + * in a bitmapped font, lightmaps for a 3D engine, and I guess other situations as + * well. + * + * The idea of this algorithm is that, as we add rectangles, we can pre-select + * "interesting" places where we can try to add the next rectangles. For optimal + * results, the rectangles should be added in order. I initially tried using area + * as a sorting criteria, but it didn't work well with very tall or very flat + * rectangles. I then tried using the longest dimension as a selector, and it + * worked much better. So much for intuition... + * + * These "interesting" places are just to the right and just below the currently + * added rectangle. The first rectangle, obviously, goes at the top left, the next + * one would go either to the right or below this one, and so on. It is a weird way + * to do it, but it seems to work very nicely. + * + * The way we search here is fairly brute-force, the fact being that for most off- + * line purposes the performance seems more than adequate. I have generated a + * japanese font with around 8500 characters and all the time was spent generating + * the bitmaps. + * + * Also, for all we care, we could grow the parent rectangle. + * + * I'd be interested in hearing of other approaches to this problem. Make sure + * to post them on http://www.flipcode.com + */ + +#include "rect_placement.h" + +// -------------------------------------------------------------------------------- +// Name : +// Description : +// -------------------------------------------------------------------------------- +void CRectPlacement::Init( int w, int h ) +{ + End(); + m_size = TRect( 0, 0, w, h ); + m_vPositions.push_back( TPos( 0, 0 ) ); + m_area = 0; +} + + +// -------------------------------------------------------------------------------- +// Name : +// Description : +// -------------------------------------------------------------------------------- +void CRectPlacement::End() +{ + m_vPositions.clear(); + m_vRects.clear(); + m_size.w = 0; +} + + +// -------------------------------------------------------------------------------- +// Name : IsFree +// Description : Check if the given rectangle is partially or totally used +// -------------------------------------------------------------------------------- +bool CRectPlacement::IsFree( const TRect& r ) const +{ + if( !m_size.Contains( r ) ) + return false; + + for( CRectArray::const_iterator it = m_vRects.begin(); + it != m_vRects.end(); ++it ) + { + if( it->Intersects( r ) ) + return false; + } + + return true; +} + + +// -------------------------------------------------------------------------------- +// Name : AddPosition +// Description : Add new anchor point +// -------------------------------------------------------------------------------- +void CRectPlacement::AddPosition( const TPos& p ) +{ + // Try to insert anchor as close as possible to the top left corner + // So it will be tried first + bool bFound = false; + CPosArray::iterator it; + + for( it = m_vPositions.begin(); + !bFound && it != m_vPositions.end(); + ++it ) + { + if( p.x + p.y < it->x + it->y ) + bFound = true; + } + + if( bFound ) + m_vPositions.insert( it, p ); + else + m_vPositions.push_back( p ); +} + + +// -------------------------------------------------------------------------------- +// Name : AddRect +// Description : Add the given rect and updates anchor points +// -------------------------------------------------------------------------------- +void CRectPlacement::AddRect( const TRect& r ) +{ + m_vRects.push_back( r ); + m_area += r.w * r.h; + + // Add two new anchor points + AddPosition( TPos( r.x, r.y + r.h ) ); + AddPosition( TPos( r.x + r.w, r.y ) ); +} + + +// -------------------------------------------------------------------------------- +// Name : AddAtEmptySpot +// Description : Add the given rectangle +// -------------------------------------------------------------------------------- +bool CRectPlacement::AddAtEmptySpot( TRect& r ) +{ + // Find a valid spot among available anchors. + bool bFound = false; + CPosArray::iterator it; + + for( it = m_vPositions.begin(); + !bFound && it != m_vPositions.end(); + ++it ) + { + TRect Rect( it->x, it->y, r.w, r.h ); + + if( IsFree( Rect ) ) + { + r = Rect; + bFound = true; + break; // Don't let the loop increase the iterator. + } + } + + if( bFound ) + { + int x, y; + + // Remove the used anchor point + m_vPositions.erase( it ); + + // Sometimes, anchors end up displaced from the optimal position + // due to irregular sizes of the subrects. + // So, try to adjut it up & left as much as possible. + for( x = 1; x <= r.x; x++ ) + { + if( !IsFree( TRect( r.x - x, r.y, r.w, r.h ) ) ) + break; + } + + for( y = 1; y <= r.y; y++ ) + { + if( !IsFree( TRect( r.x, r.y - y, r.w, r.h ) ) ) + break; + } + + if( y > x ) + r.y -= y - 1; + else + r.x -= x - 1; + + AddRect( r ); + } + + return bFound; +} + +#include +// -------------------------------------------------------------------------------- +// Name : AddAtEmptySpotAutoGrow +// Description : Add a rectangle of the given size, growing our area if needed +// Area grows only until the max given. +// Returns the placement of the rect in the rect's x,y coords +// -------------------------------------------------------------------------------- +bool CRectPlacement::AddAtEmptySpotAutoGrow( TRect* pRect, int maxW, int maxH ) +{ + double growing_factor = 1.2; // Must be > 1.0, and event > 1.1 for fast optimization + + #define GROW(x) ((x * growing_factor) + 1) + + if( pRect->w <= 0 ) + return true; + + int orgW = m_size.w; + int orgH = m_size.h; + + // Try to add it in the existing space + while( !AddAtEmptySpot( *pRect ) ) + { + int pw = m_size.w; + int ph = m_size.h; + + // Sanity check - if area is complete. + if( pw >= maxW && ph >= maxH ) + { + m_size.w = orgW; + m_size.h = orgH; + return false; + } + + // Try growing the smallest dim + if( pw < maxW && ( pw < ph || ( (pw == ph) && (pRect->w >= pRect->h) ) ) ) + m_size.w = GROW( pw ); + else + m_size.h = GROW( ph ); + + if( AddAtEmptySpot( *pRect ) ) + break; + + // Try growing the other dim instead + if( pw != m_size.w ) + { + m_size.w = pw; + + if( ph < maxW ) + m_size.h = GROW( ph ); + } + else + { + m_size.h = ph; + + if( pw < maxW ) + m_size.w = GROW( pw ); + } + + if( pw != m_size.w || ph != m_size.h ) + if( AddAtEmptySpot( *pRect ) ) + break; + + + + // Grow both if possible, and reloop. + m_size.w = pw; + m_size.h = ph; + + if( pw < maxW ) + m_size.w = GROW( pw ); + + if( ph < maxH ) + m_size.h = GROW( ph ); + } + + return true; +} diff --git a/pcbnew/autorouter/rect_placement/rect_placement.h b/pcbnew/autorouter/rect_placement/rect_placement.h new file mode 100644 index 0000000000..c9d9585f5d --- /dev/null +++ b/pcbnew/autorouter/rect_placement/rect_placement.h @@ -0,0 +1,104 @@ +// -------------------------------------------------------------------------------- +// Name : rect_placement.h +// Description : A class that allocates subrectangles into power-of-2 rectangles +// (C) Copyright 2000-2002 by Javier Arevalo +// This code is free to use and modify for all purposes +// -------------------------------------------------------------------------------- + +/** + * @file rect_placement.h + */ + +#ifndef _RECT_PLACEMENT_H_ +#define _RECT_PLACEMENT_H_ + +#include + +// -------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------- + +class CRectPlacement +{ +public: + + // Helper classes + struct TPos + { + int x, y; + + TPos() { } + TPos( int _x, int _y ) : x( _x ), y( _y ) { } + + bool operator ==( const TPos& p ) const { return x == p.x && y == p.y; } + }; + + struct TRect : public TPos + { + int w, h; + + TRect() { } + TRect( int _x, int _y, int _w, int _h ) : TPos( _x, _y ), w( _w > 0 ? _w : 0 ), h( + _h > 0 ? _h : 0 ) { } + + bool Contains( const TPos& p ) const + { + return p.x >= x && p.y >= y && p.x < (x + w) && p.y < (y + h); + } + bool Contains( const TRect& r ) const + { + return r.x >= x && r.y >= y && + (r.x + r.w) <= (x + w) && (r.y + r.h) <= (y + h); + } + bool Intersects( const TRect& r ) const + { + return w > 0 && h > 0 && r.w > 0 && r.h > 0 + && ( (r.x + r.w) > x && r.x < (x + w) && (r.y + r.h) > y && r.y < (y + h) ); + } + + // static bool Greater(const TRect &a, const TRect &b) + // { return a.w*a.h > b.w*b.h; } + // Greater rect area. Not as good as the next heuristic: + // Greater size in at least one dim. + static bool Greater( const TRect& a, const TRect& b ) + { + return (a.w > b.w && a.w > b.h) || (a.h > b.w && a.h > b.h); + } + }; + + // --------------------- + + typedef std::vector CPosArray; + typedef std::vector CRectArray; + + // --------------------- + + CRectPlacement() { Init(); } + ~CRectPlacement() { End(); } + + void Init( int w = 1, int h = 1 ); + void End(); + + bool IsOk() const { return m_size.w > 0; } + + int GetW() const { return m_size.w; } + int GetH() const { return m_size.h; } + double GetArea() const { return m_area; } + double GetTotalArea() const { return (double)m_size.w * m_size.h; } + + bool AddAtEmptySpotAutoGrow( TRect* pRect, int maxW, int maxH ); + +private: + TRect m_size; + CRectArray m_vRects; + CPosArray m_vPositions; + double m_area; + + // --------------------- + + bool IsFree( const TRect& r ) const; + void AddPosition( const TPos& p ); + void AddRect( const TRect& r ); + bool AddAtEmptySpot( TRect& r ); +}; + +#endif // _RECT_PLACEMENT_H_ diff --git a/pcbnew/autorouter/solve.cpp b/pcbnew/autorouter/solve.cpp index c3c174d352..c06d8545eb 100644 --- a/pcbnew/autorouter/solve.cpp +++ b/pcbnew/autorouter/solve.cpp @@ -324,7 +324,6 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int aLayersCount ) AppendMsgPanel( wxT( "Activity" ), msg, BROWN ); } - pt_cur_ch = pt_cur_ch; segm_oX = GetBoard()->GetBoundingBox().GetX() + (RoutingMatrix.m_GridRouting * col_source); segm_oY = GetBoard()->GetBoundingBox().GetY() + (RoutingMatrix.m_GridRouting * row_source); segm_fX = GetBoard()->GetBoundingBox().GetX() + (RoutingMatrix.m_GridRouting * col_target); diff --git a/pcbnew/autorouter/spread_footprints.cpp b/pcbnew/autorouter/spread_footprints.cpp new file mode 100644 index 0000000000..ee9ea8a6cb --- /dev/null +++ b/pcbnew/autorouter/spread_footprints.cpp @@ -0,0 +1,356 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2013 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr + * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 2013 Wayne Stambaugh + * + * 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 + * 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 + */ + +/** + * @file spread_footprints.cpp + * @brief functions to spread footprints on free areas outside a board. + * this is usefull after reading a netlist, when new footprints are loaded + * and stacked at 0,0 coordinate. + * Often, spread them on a free area near the board being edited make more easy + * their selection. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +struct TSubRect : public CRectPlacement::TRect +{ + int n; // Original index of this subrect, before sorting + + TSubRect() { } + TSubRect( int _w, int _h, int _n ) : + TRect( 0, 0, _w, _h ), n( _n ) { } +}; + +typedef std::vector CSubRectArray; + +// Use 0.01 mm units to calculate placement, to avoid long calculation time +const int scale = (int)(0.01 * IU_PER_MM); + +// Populates a list of rectangles, from a list of modules +void fillRectList( CSubRectArray& vecSubRects, std::vector & aModuleList ) +{ + vecSubRects.clear(); + + for( unsigned ii = 0; ii < aModuleList.size(); ii++ ) + { + EDA_RECT fpBox = aModuleList[ii]->GetBoundingBox(); + TSubRect fpRect( fpBox.GetWidth()/scale, fpBox.GetHeight()/scale, ii ); + vecSubRects.push_back( fpRect ); + } +} + +// Populates a list of rectangles, from a list of EDA_RECT +void fillRectList( CSubRectArray& vecSubRects, std::vector & aRectList ) +{ + vecSubRects.clear(); + + for( unsigned ii = 0; ii < aRectList.size(); ii++ ) + { + EDA_RECT& rect = aRectList[ii]; + TSubRect fpRect( rect.GetWidth()/scale, rect.GetHeight()/scale, ii ); + vecSubRects.push_back( fpRect ); + } +} + + + +// Spread a list of rectangles inside a placement area +void spreadRectangles( CRectPlacement& aPlacementArea, + CSubRectArray& vecSubRects, + int areaSizeX, int areaSizeY ) +{ + areaSizeX/= scale; + areaSizeY/= scale; + + // Sort the subRects based on dimensions, larger dimension goes first. + std::sort( vecSubRects.begin(), vecSubRects.end(), CRectPlacement::TRect::Greater ); + + // gives the initial size to the area + aPlacementArea.Init( areaSizeX, areaSizeY ); + + // Add all subrects + CSubRectArray::iterator it; + for( it = vecSubRects.begin(); it != vecSubRects.end(); ) + { + CRectPlacement::TRect r( 0, 0, it->w, it->h ); + + bool bPlaced = aPlacementArea.AddAtEmptySpotAutoGrow( &r, areaSizeX, areaSizeY ); + + if( !bPlaced ) // No room to place the rectangle: enlarge area and retry + { + areaSizeX = ceil(areaSizeX * 1.1); + areaSizeY = ceil(areaSizeY * 1.1); + aPlacementArea.Init( areaSizeX, areaSizeY ); + it = vecSubRects.begin(); + continue; + } + + // When correctly placed in a placement area, the coords are returned in r.x and r.y + // Store them. + it->x = r.x; + it->y = r.y; + + it++; + } +} + + +void moveFootprintsInArea( CRectPlacement& aPlacementArea, + std::vector & aModuleList, EDA_RECT& aFreeArea, + bool aFindAreaOnly ) +{ + CSubRectArray vecSubRects; + + fillRectList( vecSubRects, aModuleList ); + spreadRectangles( aPlacementArea, vecSubRects, + aFreeArea.GetWidth(), aFreeArea.GetHeight() ); + + if( aFindAreaOnly ) + return; + + for( unsigned it = 0; it < vecSubRects.size(); ++it ) + { + wxPoint pos( vecSubRects[it].x, vecSubRects[it].y ); + pos.x *= scale; + pos.y *= scale; + + MODULE * module = aModuleList[vecSubRects[it].n]; + + EDA_RECT fpBBox = module->GetBoundingBox(); + wxPoint mod_pos = pos + ( module->GetPosition() - fpBBox.GetOrigin() ) + + aFreeArea.GetOrigin(); + + module->Move( mod_pos - module->GetPosition() ); + } +} + +static bool sortModulesbySheetPath( MODULE* ref, MODULE* compare ); + +/* Function to move components in a rectangular area format 4 / 3, + * starting from the mouse cursor + * The components with the FIXED status set are not moved + */ +void PCB_EDIT_FRAME::SpreadFootprints( bool aFootprintsOutsideBoardOnly ) +{ + EDA_RECT bbox = GetBoard()->ComputeBoundingBox( true ); + bool edgesExist = ( bbox.GetWidth() || bbox.GetHeight() ); + + // no edges exist + if( aFootprintsOutsideBoardOnly && !edgesExist ) + { + DisplayError( this, + _( "Could not automatically place modules. No board outlines detected." ) ); + return; + } + + // if aFootprintsOutsideBoardOnly is true, and if board outline exists, + // wue have to filter footprints to move: + bool outsideBrdFilter = aFootprintsOutsideBoardOnly && edgesExist; + + // Build candidate list + // calculate also the area needed by these footprints + MODULE* Module = GetBoard()->m_Modules; + std::vector moduleList; + + for( ; Module != NULL; Module = Module->Next() ) + { + Module->CalculateBoundingBox(); + + if( outsideBrdFilter ) + { + if( bbox.Contains( Module->GetPosition() ) ) + continue; + } + + if( Module->IsLocked() ) + continue; + + moduleList.push_back(Module); + } + + if( moduleList.size() == 0 ) // Nothing to do + return; + + // sort footprints by sheet path. we group them later by sheet + sort( moduleList.begin(), moduleList.end(), sortModulesbySheetPath ); + + // Undo command: init undo list + PICKED_ITEMS_LIST undoList; + undoList.m_Status = UR_CHANGED; + ITEM_PICKER picker( NULL, UR_CHANGED ); + + for( unsigned ii = 0; ii < moduleList.size(); ii++ ) + { + Module = moduleList[ii]; + + // Undo: add copy of module to undo list + picker.SetItem( Module ); + picker.SetLink( Module->Clone() ); + undoList.PushItem( picker ); + } + + // Extract and place footprints by sheet + std::vector moduleListBySheet; + std::vector placementSheetAreas; + wxString curr_sheetPath ; + double subsurface; + double placementsurface = 0.0; + + wxPoint placementAreaPosition = GetCrossHairPosition(); + + // We do not want to move footprints inside an existing board. + // move the placement area position outside the board bounding box + // to the left of the board + if( edgesExist ) + { + if( placementAreaPosition.x < bbox.GetEnd().x && + placementAreaPosition.y < bbox.GetEnd().y ) + { + placementAreaPosition.x = bbox.GetEnd().x; + placementAreaPosition.y = bbox.GetOrigin().y; + } + } + + // The placement uses 2 passes: + // the first pass creates the rectangular areas to place footprints + // each sheet in schematic creates one rectangular area. + // the second pass moves footprints inside these areas + for( int pass = 0; pass < 2; pass++ ) + { + int subareaIdx = 0; + curr_sheetPath = moduleList[0]->GetPath().BeforeLast( '/' ); + moduleListBySheet.clear(); + subsurface = 0.0; + + for( unsigned ii = 0; ii < moduleList.size(); ii++ ) + { + Module = moduleList[ii]; + bool iscurrPath = curr_sheetPath == moduleList[ii]->GetPath().BeforeLast( '/' ); + + if( iscurrPath ) + { + moduleListBySheet.push_back( Module ); + subsurface += Module->GetArea(); + } + + if( !iscurrPath || (ii == moduleList.size()-1) ) + { + // end of the footprint sublist relative to the same sheet path + // calculate placement of the current sublist + EDA_RECT freeArea; + int Xsize_allowed = (int) ( sqrt( subsurface ) * 4.0 / 3.0 ); + int Ysize_allowed = (int) ( subsurface / Xsize_allowed ); + + freeArea.SetWidth( Xsize_allowed ); + freeArea.SetHeight( Ysize_allowed ); + CRectPlacement placementArea; + + if( pass == 1 ) + { + wxPoint areapos = placementSheetAreas[subareaIdx].GetOrigin() + + placementAreaPosition; + freeArea.SetOrigin( areapos ); + } + + bool findAreaOnly = pass == 0; + moveFootprintsInArea( placementArea, moduleListBySheet, + freeArea, findAreaOnly ); + + if( pass == 0 ) + { + // Populate sheet placement areas list + EDA_RECT sub_area; + sub_area.SetWidth( placementArea.GetW()*scale ); + sub_area.SetHeight( placementArea.GetH()*scale ); + // Add a margin around the sheet placement area: + sub_area.Inflate( Millimeter2iu( 1.5 ) ); + + placementSheetAreas.push_back( sub_area ); + + placementsurface += (double) sub_area.GetWidth()* + sub_area.GetHeight(); + } + + curr_sheetPath = moduleList[ii]->GetPath().BeforeLast( '/' ); + subsurface = 0.0; + moduleListBySheet.clear(); + + // Enter first module of next sheet + moduleListBySheet.push_back( Module ); + subsurface += Module->GetArea(); + + subareaIdx++; + } + } + + // End of pass: + // At the end of the first pass, we have to find position of each sheet + // placement area + if( pass == 0 ) + { + int Xsize_allowed = (int) ( sqrt( placementsurface ) * 4.0 / 3.0 ); + int Ysize_allowed = (int) ( placementsurface / Xsize_allowed ); + CRectPlacement placementArea; + CSubRectArray vecSubRects; + + fillRectList( vecSubRects, placementSheetAreas ); + spreadRectangles( placementArea, vecSubRects, Xsize_allowed, Ysize_allowed ); + + for( unsigned it = 0; it < vecSubRects.size(); ++it ) + { + TSubRect& srect = vecSubRects[it]; + wxPoint pos( srect.x*scale, srect.y*scale ); + wxSize size( srect.w*scale, srect.h*scale ); + placementSheetAreas[srect.n].SetOrigin( pos ); + placementSheetAreas[srect.n].SetSize( size ); + } + } + } // End pass + + // Undo: commit list + SaveCopyInUndoList( undoList, UR_CHANGED ); + OnModify(); + + m_canvas->Refresh(); +} + + +static bool sortModulesbySheetPath( MODULE* ref, MODULE* compare ) +{ + return compare->GetPath().Cmp( ref->GetPath() ) < 0; +} diff --git a/pcbnew/board_undo_redo.cpp b/pcbnew/board_undo_redo.cpp index e58e734320..cd058e172b 100644 --- a/pcbnew/board_undo_redo.cpp +++ b/pcbnew/board_undo_redo.cpp @@ -504,11 +504,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->Rotate( aList->m_TransformPoint, + aRedoCommand ? m_rotationAngle : -m_rotationAngle ); break; case UR_ROTATED_CLOCKWISE: - item->Rotate( aList->m_TransformPoint, aRedoCommand ? -900 : 900 ); + item->Rotate( aList->m_TransformPoint, + aRedoCommand ? -m_rotationAngle : m_rotationAngle ); break; case UR_FLIPPED: diff --git a/pcbnew/class_drawsegment.h b/pcbnew/class_drawsegment.h index 66fc4c1d4e..dacd8061d2 100644 --- a/pcbnew/class_drawsegment.h +++ b/pcbnew/class_drawsegment.h @@ -116,8 +116,9 @@ public: void SetEndY( int y ) { m_End.y = y; } void SetEndX( int x ) { m_End.x = x; } - // Arc attributes are read only, since they are "calculated" from - // m_Start, m_End, and m_Angle. No Set...() functions. + // Some attributes are read only, since they are "calculated" from + // m_Start, m_End, and m_Angle. + // No Set...() function for these attributes. const wxPoint& GetCenter() const { return m_Start; } const wxPoint& GetArcStart() const { return m_End; } @@ -140,6 +141,17 @@ public: return KiROUND( radius ); } + /** + * Initialize the start arc point. can be used for circles + * to initialize one point of the cicumference + */ + void SetArcStart( const wxPoint& aArcStartPoint ) + { m_End = aArcStartPoint; } + + /** For arcs and circles: + */ + void SetCenter( const wxPoint& aCenterPoint ) { m_Start = aCenterPoint; } + /** * Function GetParentModule * returns a pointer to the parent module, or NULL if DRAWSEGMENT does not diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index dd1aca96e5..cf887dabc4 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_edit_module_for_Modedit.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp index 364106624a..d2c81102fe 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp @@ -42,6 +42,8 @@ #include #include #include +#include +#include #include #include @@ -62,6 +64,7 @@ DIALOG_MODULE_MODULE_EDITOR::DIALOG_MODULE_MODULE_EDITOR( FOOTPRINT_EDIT_FRAME* icon.CopyFromBitmap( KiBitmap( icon_modedit_xpm ) ); SetIcon( icon ); + m_FootprintNameCtrl->SetValidator( FOOTPRINT_NAME_VALIDATOR() ); initModeditProperties(); m_sdbSizerStdButtonsOK->SetDefault(); GetSizer()->SetSizeHints( this ); @@ -100,15 +103,15 @@ void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties() S3D_MASTER* draw3DCopy = new S3D_MASTER(NULL); draw3DCopy->Copy( draw3D ); m_shapes3D_list.push_back( draw3DCopy ); - m_3D_ShapeNameListBox->Append(draw3DCopy->m_Shape3DName); + m_3D_ShapeNameListBox->Append( draw3DCopy->m_Shape3DName ); } draw3D = (S3D_MASTER*) draw3D->Next(); } m_DocCtrl->SetValue( m_currentModule->GetDescription() ); m_KeywordCtrl->SetValue( m_currentModule->GetKeywords() ); - m_referenceCopy = new TEXTE_MODULE(NULL); - m_valueCopy = new TEXTE_MODULE(NULL); + m_referenceCopy = new TEXTE_MODULE( NULL ); + m_valueCopy = new TEXTE_MODULE( NULL ); m_referenceCopy->Copy( &m_currentModule->Reference() ); m_valueCopy->Copy( &m_currentModule->Value() ); m_ReferenceCtrl->SetValue( m_referenceCopy->GetText() ); @@ -147,7 +150,6 @@ void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties() m_AutoPlaceCtrl->SetItemToolTip( 1, _( "Disable hotkey move commands and Auto Placement" ) ); m_CostRot90Ctrl->SetValue( m_currentModule->GetPlacementCost90() ); - m_CostRot180Ctrl->SetValue( m_currentModule->GetPlacementCost180() ); // Initialize 3D parameters @@ -168,7 +170,7 @@ void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties() PutValueInLocalUnits( *m_SolderPasteMarginCtrl, m_currentModule->GetLocalSolderPasteMargin() ); if( m_currentModule->GetLocalSolderPasteMargin() == 0 ) - m_SolderPasteMarginCtrl->SetValue( wxT("-") + m_SolderPasteMarginCtrl->GetValue() ); + m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) + m_SolderPasteMarginCtrl->GetValue() ); if( m_currentModule->GetLocalSolderPasteMarginRatio() == 0.0 ) msg.Printf( wxT( "-%f" ), m_currentModule->GetLocalSolderPasteMarginRatio() * 100.0 ); @@ -179,12 +181,11 @@ void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties() // Add solder paste margin ration in per cent // for the usual default value 0.0, display -0.0 (or -0,0 in some countries) - msg.Printf( wxT( "%f" ), - m_currentModule->GetLocalSolderPasteMarginRatio() * 100.0 ); + msg.Printf( wxT( "%f" ), m_currentModule->GetLocalSolderPasteMarginRatio() * 100.0 ); if( m_currentModule->GetLocalSolderPasteMarginRatio() == 0.0 && msg[0] == '0') // Sometimes Printf adds a sign if the value is very small (0.0) - m_SolderPasteMarginRatioCtrl->SetValue( wxT("-") + msg ); + m_SolderPasteMarginRatioCtrl->SetValue( wxT( "-" ) + msg ); else m_SolderPasteMarginRatioCtrl->SetValue( msg ); @@ -208,9 +209,7 @@ void DIALOG_MODULE_MODULE_EDITOR::Transfert3DValuesToDisplay( S3D_MASTER * aStru if( aStruct3DSource ) { m_3D_Scale->SetValue( aStruct3DSource->m_MatScale ); - m_3D_Offset->SetValue( aStruct3DSource->m_MatPosition ); - m_3D_Rotation->SetValue( aStruct3DSource->m_MatRotation ); } else @@ -221,6 +220,7 @@ void DIALOG_MODULE_MODULE_EDITOR::Transfert3DValuesToDisplay( S3D_MASTER * aStru } } + /** Copy 3D info displayed in dialog box to values in a item in m_shapes3D_list * @param aIndexSelection = item index in m_shapes3D_list */ @@ -240,6 +240,7 @@ void DIALOG_MODULE_MODULE_EDITOR::On3DShapeNameSelected(wxCommandEvent& event) { if( m_lastSelected3DShapeIndex >= 0 ) TransfertDisplayTo3DValues( m_lastSelected3DShapeIndex ); + m_lastSelected3DShapeIndex = m_3D_ShapeNameListBox->GetSelection(); if( m_lastSelected3DShapeIndex < 0 ) // happens under wxGTK when deleting an item in m_3D_ShapeNameListBox wxListBox @@ -247,10 +248,11 @@ void DIALOG_MODULE_MODULE_EDITOR::On3DShapeNameSelected(wxCommandEvent& event) if( m_lastSelected3DShapeIndex >= (int)m_shapes3D_list.size() ) { - wxMessageBox(wxT("On3DShapeNameSelected() error")); + wxMessageBox( wxT( "On3DShapeNameSelected() error" ) ); m_lastSelected3DShapeIndex = -1; return; } + Transfert3DValuesToDisplay( m_shapes3D_list[m_lastSelected3DShapeIndex] ); } @@ -261,18 +263,19 @@ void DIALOG_MODULE_MODULE_EDITOR::Remove3DShape(wxCommandEvent& event) TransfertDisplayTo3DValues( m_lastSelected3DShapeIndex ); int ii = m_3D_ShapeNameListBox->GetSelection(); + if( ii < 0 ) return; - m_shapes3D_list.erase(m_shapes3D_list.begin() + ii ); - m_3D_ShapeNameListBox->Delete(ii); + m_shapes3D_list.erase( m_shapes3D_list.begin() + ii ); + m_3D_ShapeNameListBox->Delete( ii ); if( m_3D_ShapeNameListBox->GetCount() == 0) Transfert3DValuesToDisplay( NULL ); else { m_lastSelected3DShapeIndex = 0; - m_3D_ShapeNameListBox->SetSelection(m_lastSelected3DShapeIndex); + m_3D_ShapeNameListBox->SetSelection( m_lastSelected3DShapeIndex ); Transfert3DValuesToDisplay( m_shapes3D_list[m_lastSelected3DShapeIndex] ); } } @@ -284,6 +287,7 @@ void DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DLib( wxCommandEvent& event ) wxString fullpath; fullpath = wxGetApp().ReturnLastVisitedLibraryPath( LIB3D_PATH ); + #ifdef __WINDOWS__ fullpath.Replace( wxT( "/" ), wxT( "\\" ) ); #endif @@ -313,6 +317,7 @@ void DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DLib( wxCommandEvent& event ) shortfilename = wxGetApp().ReturnFilenameWithRelativePathInLibPath( fullfilename ); wxFileName aux = shortfilename; + if( aux.IsAbsolute() ) { // Absolute path, ask if the user wants a relative one int diag = wxMessageBox( @@ -322,12 +327,13 @@ void DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DLib( wxCommandEvent& event ) if( diag == wxYES ) { // Make it relative - aux.MakeRelativeTo( wxT(".") ); + aux.MakeRelativeTo( wxT( "." ) ); shortfilename = aux.GetPathWithSep() + aux.GetFullName(); } } S3D_MASTER* new3DShape = new S3D_MASTER(NULL); + #ifdef __WINDOWS__ // Store filename in Unix notation shortfilename.Replace( wxT( "\\" ), wxT( "/" ) ); @@ -341,7 +347,7 @@ void DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DLib( wxCommandEvent& event ) TransfertDisplayTo3DValues( m_lastSelected3DShapeIndex ); m_lastSelected3DShapeIndex = m_3D_ShapeNameListBox->GetCount() - 1; - m_3D_ShapeNameListBox->SetSelection(m_lastSelected3DShapeIndex); + m_3D_ShapeNameListBox->SetSelection( m_lastSelected3DShapeIndex ); Transfert3DValuesToDisplay( m_shapes3D_list[m_lastSelected3DShapeIndex] ); } @@ -357,12 +363,13 @@ void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event ) { // First, test for invalid chars in module name wxString footprintName = m_FootprintNameCtrl->GetValue(); + if( ! footprintName.IsEmpty() ) { if( ! MODULE::IsLibNameValid( footprintName ) ) { wxString msg; - msg.Printf( _("Error:\none of invalid chars <%s> found\nin <%s>" ), + msg.Printf( _( "Error:\none of invalid chars <%s> found\nin <%s>" ), MODULE::ReturnStringLibNameInvalidChars( true ), GetChars( footprintName ) ); @@ -404,9 +411,7 @@ void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event ) // Initialize masks clearances m_currentModule->SetLocalClearance( ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl ) ); - m_currentModule->SetLocalSolderMaskMargin( ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl ) ); - m_currentModule->SetLocalSolderPasteMargin( ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl ) ); double dtmp; wxString msg = m_SolderPasteMarginRatioCtrl->GetValue(); @@ -415,6 +420,7 @@ void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event ) // A -50% margin ratio means no paste on a pad, the ratio must be >= -50 % if( dtmp < -50.0 ) dtmp = -50.0; + // A margin ratio is always <= 0 if( dtmp > 0.0 ) dtmp = 0.0; @@ -423,14 +429,19 @@ void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event ) // Update 3D shape list int ii = m_3D_ShapeNameListBox->GetSelection(); + if ( ii >= 0 ) - TransfertDisplayTo3DValues( ii ); + TransfertDisplayTo3DValues( ii ); + S3D_MASTER* draw3D = m_currentModule->Models(); + for( unsigned ii = 0; ii < m_shapes3D_list.size(); ii++ ) { S3D_MASTER* draw3DCopy = m_shapes3D_list[ii]; + if( draw3DCopy->m_Shape3DName.IsEmpty() ) continue; + if( draw3D == NULL ) { draw3D = new S3D_MASTER( draw3D ); @@ -447,6 +458,7 @@ void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event ) // Remove old extra 3D shapes S3D_MASTER* nextdraw3D; + for( ; draw3D != NULL; draw3D = nextdraw3D ) { nextdraw3D = (S3D_MASTER*) draw3D->Next(); @@ -484,4 +496,3 @@ void DIALOG_MODULE_MODULE_EDITOR::OnEditValue(wxCommandEvent& event) m_parent->SetCrossHairPosition( tmp ); m_ValueCtrl->SetValue( m_valueCopy->GetText() ); } - 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/dialogs/dialog_netlist.cpp b/pcbnew/dialogs/dialog_netlist.cpp index 6315e63a00..50ad5f0063 100644 --- a/pcbnew/dialogs/dialog_netlist.cpp +++ b/pcbnew/dialogs/dialog_netlist.cpp @@ -167,7 +167,7 @@ void DIALOG_NETLIST::OnReadNetlistFileClick( wxCommandEvent& event ) "sure you want to read the netlist?" ) ) ) return; - wxBusyCursor busy(); + wxBusyCursor busy; m_MessageWindow->Clear(); msg.Printf( _( "Reading netlist file \"%s\".\n" ), GetChars( netlistFileName ) ); diff --git a/pcbnew/eagle_plugin.cpp b/pcbnew/eagle_plugin.cpp index f1aa7d6bf7..703bb57ddd 100644 --- a/pcbnew/eagle_plugin.cpp +++ b/pcbnew/eagle_plugin.cpp @@ -66,6 +66,7 @@ Load() TODO's #include #include #include +#include #include #include @@ -94,34 +95,6 @@ typedef boost::optional opt_bool; const wxChar* traceEaglePlugin = wxT( "KicadEaglePlugin" ); -/// Test footprint name for kicad legality, fix if needed and return true if fixing was required. -static bool fix_eagle_package_name( string* aName ) -{ - string result; - bool changed = false; - - for( string::iterator it = aName->begin(); it != aName->end(); ++it ) - { - switch( *it ) - { - case ':': - case '/': - // replace *it with %xx, as in URL encoding - StrPrintf( &result, "%%%02x", *it ); - changed = true; - break; - - default: - result += *it; - } - } - - if( changed ) - *aName = result; - - return changed; -} - /// segment (element) of our XPATH into the Eagle XML document tree in PTREE form. struct TRIPLET @@ -939,7 +912,7 @@ EELEMENT::EELEMENT( CPTREE& aElement ) value = attribs.get( "value" ); package = attribs.get( "package" ); - fix_eagle_package_name( &package ); + ReplaceIllegalFileNameChars( &package ); x = attribs.get( "x" ); y = attribs.get( "y" ); @@ -1106,17 +1079,15 @@ EAGLE_PLUGIN::~EAGLE_PLUGIN() } -const wxString& EAGLE_PLUGIN::PluginName() const +const wxString EAGLE_PLUGIN::PluginName() const { - static const wxString name = wxT( "Eagle" ); - return name; + return wxT( "Eagle" ); } -const wxString& EAGLE_PLUGIN::GetFileExtension() const +const wxString EAGLE_PLUGIN::GetFileExtension() const { - static const wxString extension = wxT( "brd" ); - return extension; + return wxT( "brd" ); } @@ -1619,7 +1590,7 @@ void EAGLE_PLUGIN::loadLibrary( CPTREE& aLib, const string* aLibName ) string pack_name( pack_ref ); - fix_eagle_package_name( &pack_name ); + ReplaceIllegalFileNameChars( &pack_name ); #if 0 && defined(DEBUG) if( pack_name == "TO220H" ) @@ -2892,6 +2863,8 @@ MODULE* EAGLE_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxStrin void EAGLE_PLUGIN::FootprintLibOptions( PROPERTIES* aListToAppendTo ) const { + PLUGIN::FootprintLibOptions( aListToAppendTo ); + /* (*aListToAppendTo)["ignore_duplicates"] = wxString( _( "Ignore duplicately named footprints within the same Eagle library. " diff --git a/pcbnew/eagle_plugin.h b/pcbnew/eagle_plugin.h index 6fa626af29..1dde4a94e5 100644 --- a/pcbnew/eagle_plugin.h +++ b/pcbnew/eagle_plugin.h @@ -80,11 +80,11 @@ class EAGLE_PLUGIN : public PLUGIN public: //------------------------------------------------------- - const wxString& PluginName() const; + const wxString PluginName() const; BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties = NULL ); - const wxString& GetFileExtension() const; + const wxString GetFileExtension() const; wxArrayString FootprintEnumerate( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL); diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 9ca03faa0d..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: @@ -1177,11 +1176,11 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_MENU_ARCHIVE_NEW_MODULES: - ArchiveModulesOnBoard( wxEmptyString, true ); + ArchiveModulesOnBoard( true ); break; case ID_MENU_ARCHIVE_ALL_MODULES: - ArchiveModulesOnBoard( wxEmptyString, false ); + ArchiveModulesOnBoard( false ); break; case ID_GEN_IMPORT_DXF_FILE: 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/gen_modules_placefile.cpp b/pcbnew/gen_modules_placefile.cpp index 0c17cc06d9..6d4301df6b 100644 --- a/pcbnew/gen_modules_placefile.cpp +++ b/pcbnew/gen_modules_placefile.cpp @@ -200,6 +200,15 @@ bool DIALOG_GEN_MODULE_POSITION::CreateFiles() bool singleFile = OneFileOnly(); int fullcount = 0; + // Count the footprints to place, do not yet create a file + int fpcount = m_parent->DoGenFootprintsPositionFile( wxEmptyString, UnitsMM(), + ForceAllSmd(), 2 ); + if( fpcount == 0) + { + wxMessageBox( _( "No modules for automated placement." ) ); + return false; + } + fn = m_parent->GetBoard()->GetFileName(); fn.SetPath( GetOutputDirectory() ); frontLayerName = brd->GetLayerName( LAYER_N_FRONT ); @@ -208,18 +217,19 @@ bool DIALOG_GEN_MODULE_POSITION::CreateFiles() // Create the the Front or Top side placement file, // or the single file int side = 1; + if( singleFile ) { side = 2; fn.SetName( fn.GetName() + wxT( "-" ) + wxT("all") ); } - else + else fn.SetName( fn.GetName() + wxT( "-" ) + frontLayerName ); fn.SetExt( FootprintPlaceFileExtension ); - int fpcount = m_parent->DoGenFootprintsPositionFile( fn.GetFullPath(), UnitsMM(), - ForceAllSmd(), side ); + fpcount = m_parent->DoGenFootprintsPositionFile( fn.GetFullPath(), UnitsMM(), + ForceAllSmd(), side ); if( fpcount < 0 ) { msg.Printf( _( "Unable to create <%s>" ), GetChars( fn.GetFullPath() ) ); @@ -228,12 +238,6 @@ bool DIALOG_GEN_MODULE_POSITION::CreateFiles() return false; } - if( fpcount == 0) - { - wxMessageBox( _( "No modules for automated placement." ) ); - return false; - } - if( singleFile ) msg.Printf( _( "Place file: <%s>\n" ), GetChars( fn.GetFullPath() ) ); else @@ -339,6 +343,8 @@ void PCB_EDIT_FRAME::GenFootprintsPositionFile( wxCommandEvent& event ) * aSide = 0 -> Back (bottom) side) * aSide = 1 -> Front (top) side) * aSide = 2 -> both sides + * if aFullFileName is empty, the file is not crated, only the + * count of footprints to place is returned * * The format is: * ### Module positions - created on 04/12/2012 15:24:24 ### @@ -405,6 +411,9 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName, moduleCount++; } + if( aFullFileName.IsEmpty() ) + return moduleCount; + FILE * file = wxFopen( aFullFileName, wxT( "wt" ) ); if( file == NULL ) return -1; 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 dd521f5de1..b552669381 100644 --- a/pcbnew/github/github_plugin.cpp +++ b/pcbnew/github/github_plugin.cpp @@ -24,22 +24,6 @@ /* - This is a pcbnew PLUGIN which supports some of the PLUGIN::Footprint*() functions - in the PLUGIN interface, and could do so by utilizing the version 3 github.com - API documented here: - - http://developer.github.com - https://help.github.com/articles/creating-an-access-token-for-command-line-use - - but it does not. Rather it simply reads in a zip file of the repo and unzips it - from RAM as needed. Therefore the PLUGIN is read only for accessing - remote pretty libraries. If you want to support writing to the repo, then you - could use the above API. - -@todo: - Derive this PLUGIN from KICAD_PLUGIN so we can use its FootprintSave(). - Support local footprints if they are present in an optional directory. - Possibly cache the zip file locally. Use HTTP's "have changed" or whatever it is called. */ @@ -58,6 +42,7 @@ #include #include +#include #include #include @@ -76,9 +61,14 @@ #include #include #include +#include // ExpandSubstitutions() using namespace std; + +static const char* PRETTY_DIR = "allow_pretty_writing_to_this_dir"; + + typedef boost::ptr_map MODULE_MAP; typedef MODULE_MAP::iterator MODULE_ITER; typedef MODULE_MAP::const_iterator MODULE_CITER; @@ -95,28 +85,27 @@ struct GH_CACHE : public MODULE_MAP GITHUB_PLUGIN::GITHUB_PLUGIN() : - m_cache( 0 ) + PCB_IO(), + m_gh_cache( 0 ) { } GITHUB_PLUGIN::~GITHUB_PLUGIN() { - delete m_cache; + delete m_gh_cache; } -const wxString& GITHUB_PLUGIN::PluginName() const +const wxString GITHUB_PLUGIN::PluginName() const { - static wxString name( wxT( "Github" ) ); - return name; + return wxT( "Github" ); } -const wxString& GITHUB_PLUGIN::GetFileExtension() const +const wxString GITHUB_PLUGIN::GetFileExtension() const { - static wxString empty_ext; - return empty_ext; + return wxEmptyString; } @@ -124,14 +113,30 @@ wxArrayString GITHUB_PLUGIN::FootprintEnumerate( const wxString& aLibraryPath, const PROPERTIES* aProperties ) { //D(printf("%s: this:%p aLibraryPath:'%s'\n", __func__, this, TO_UTF8(aLibraryPath) );) + cacheLib( aLibraryPath, aProperties ); - cacheLib( aLibraryPath ); + typedef std::set MYSET; - wxArrayString ret; + MYSET unique; - for( MODULE_ITER it = m_cache->begin(); it!=m_cache->end(); ++it ) + if( m_pretty_dir.size() ) { - ret.Add( FROM_UTF8( it->first.c_str() ) ); + wxArrayString locals = PCB_IO::FootprintEnumerate( m_pretty_dir ); + + for( unsigned i=0; ibegin(); it!=m_gh_cache->end(); ++it ) + { + unique.insert( FROM_UTF8( it->first.c_str() ) ); + } + + wxArrayString ret; + + for( MYSET::const_iterator it = unique.begin(); it != unique.end(); ++it ) + { + ret.Add( *it ); } return ret; @@ -143,13 +148,29 @@ MODULE* GITHUB_PLUGIN::FootprintLoad( const wxString& aLibraryPath, { // D(printf("%s: this:%p aLibraryPath:'%s'\n", __func__, this, TO_UTF8(aLibraryPath) );) - cacheLib( aLibraryPath ); + // clear or set to valid the variable m_pretty_dir + cacheLib( aLibraryPath, aProperties ); + + if( m_pretty_dir.size() ) + { + // API has FootprintLoad() *not* throwing an exception if footprint not found. + MODULE* local = PCB_IO::FootprintLoad( m_pretty_dir, aFootprintName, aProperties ); + + if( 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 ); - MODULE_CITER it = m_cache->find( fp_name ); + MODULE_CITER it = m_gh_cache->find( fp_name ); - if( it != m_cache->end() ) // fp_name is present + if( it != m_gh_cache->end() ) // fp_name is present { wxMemoryInputStream mis( &m_zip_image[0], m_zip_image.size() ); @@ -162,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; @@ -181,7 +210,109 @@ MODULE* GITHUB_PLUGIN::FootprintLoad( const wxString& aLibraryPath, bool GITHUB_PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath ) { - return false; + if( m_pretty_dir.size() ) + return PCB_IO::IsFootprintLibWritable( m_pretty_dir ); + else + return false; +} + + +void GITHUB_PLUGIN::FootprintSave( const wxString& aLibraryPath, + const MODULE* aFootprint, const PROPERTIES* aProperties ) +{ + // set m_pretty_dir to either empty or something in aProperties + cacheLib( aLibraryPath, aProperties ); + + if( GITHUB_PLUGIN::IsFootprintLibWritable( aLibraryPath ) ) + { + PCB_IO::FootprintSave( m_pretty_dir, aFootprint, aProperties ); + } + else + { + // This typically will not happen if the caller first properly calls + // IsFootprintLibWritable() to determine if calling FootprintSave() is + // even legal, so I spend no time on internationalization here: + + string msg = StrPrintf( "Github library\n'%s'\nis only writable if you set option '%s' in Library Tables dialog.", + (const char*) TO_UTF8( aLibraryPath ), PRETTY_DIR ); + + THROW_IO_ERROR( msg ); + } +} + + +void GITHUB_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName, + const PROPERTIES* aProperties ) +{ + // set m_pretty_dir to either empty or something in aProperties + cacheLib( aLibraryPath, aProperties ); + + if( GITHUB_PLUGIN::IsFootprintLibWritable( aLibraryPath ) ) + { + // Does the PCB_IO base class have this footprint? + // We cannot write to github. + + wxArrayString pretties = PCB_IO::FootprintEnumerate( m_pretty_dir, aProperties ); + + if( pretties.Index( aFootprintName ) != wxNOT_FOUND ) + { + PCB_IO::FootprintDelete( m_pretty_dir, aFootprintName, aProperties ); + } + else + { + wxString msg = wxString::Format( + _( "Footprint\n'%s'\nis not in the writable portion of this Github library\n'%s'" ), + GetChars( aFootprintName ), + GetChars( aLibraryPath ) + ); + + THROW_IO_ERROR( msg ); + } + } + else + { + // This typically will not happen if the caller first properly calls + // IsFootprintLibWritable() to determine if calling FootprintSave() is + // even legal, so I spend no time on internationalization here: + + string msg = StrPrintf( "Github library\n'%s'\nis only writable if you set option '%s' in Library Tables dialog.", + (const char*) TO_UTF8( aLibraryPath ), PRETTY_DIR ); + + THROW_IO_ERROR( msg ); + } +} + + +void GITHUB_PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties ) +{ + // set m_pretty_dir to either empty or something in aProperties + cacheLib( aLibraryPath, aProperties ); + + if( m_pretty_dir.size() ) + { + PCB_IO::FootprintLibCreate( m_pretty_dir, aProperties ); + } + else + { + // THROW_IO_ERROR() @todo + } +} + + +bool GITHUB_PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties ) +{ + // set m_pretty_dir to either empty or something in aProperties + cacheLib( aLibraryPath, aProperties ); + + if( m_pretty_dir.size() ) + { + return PCB_IO::FootprintLibDelete( m_pretty_dir, aProperties ); + } + else + { + // THROW_IO_ERROR() @todo + return false; + } } @@ -190,32 +321,74 @@ void GITHUB_PLUGIN::FootprintLibOptions( PROPERTIES* aListToAppendTo ) const // inherit options supported by all PLUGINs. PLUGIN::FootprintLibOptions( aListToAppendTo ); - (*aListToAppendTo)["allow_pretty_writing_to_this_dir"] = wxString( _( + (*aListToAppendTo)[ PRETTY_DIR ] = wxString( _( "Set this property to a directory where footprints are to be written as pretty " "footprints when saving to this library. Anything saved will take precedence over " "footprints by the same name in the github repo. These saved footprints can then " "be sent to the library maintainer as updates. " - "

    The directory should have a .pretty file extension because the " - "Kicad plugin is used to do the saving.

    " + "

    The directory must have a .pretty file extension because the " + "format of the save is pretty.

    " )).utf8_str(); + /* (*aListToAppendTo)["cache_github_zip_in_this_dir"] = wxString( _( "Set this property to a directory where the github *.zip file will be cached. " "This should speed up subsequent visits to this library." )).utf8_str(); + */ } -void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath ) throw( IO_ERROR ) +void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath, const PROPERTIES* aProperties ) throw( IO_ERROR ) { - if( !m_cache || m_lib_path != aLibraryPath ) + // This is edge triggered based on a change in 'aLibraryPath', + // usually it does nothing. When the edge fires, m_pretty_dir is set + // to either: + // 1) empty or + // 2) a verified and validated, writable, *.pretty directory. + + if( !m_gh_cache || m_lib_path != aLibraryPath ) { + delete m_gh_cache; + m_gh_cache = 0; + + m_pretty_dir.clear(); + + if( aProperties ) + { + string pretty_dir; + + if( aProperties->Value( PRETTY_DIR, &pretty_dir ) ) + { + wxString wx_pretty_dir = FROM_UTF8( pretty_dir.c_str() ); + + wx_pretty_dir = FP_LIB_TABLE::ExpandSubstitutions( wx_pretty_dir ); + + wxFileName wx_pretty_fn = wx_pretty_dir; + + if( !wx_pretty_fn.IsOk() || + !wx_pretty_fn.IsDirWritable() || + wx_pretty_fn.GetExt() != wxT( "pretty" ) + ) + { + wxString msg = wxString::Format( + _( "option '%s' for Github library '%s' must point to a writable directory ending with '.pretty'." ), + GetChars( FROM_UTF8( PRETTY_DIR ) ), + GetChars( aLibraryPath ) + ); + + THROW_IO_ERROR( msg ); + } + + m_pretty_dir = wx_pretty_dir; + } + } + // operator==( wxString, wxChar* ) does not exist, construct wxString once here. const wxString kicad_mod( wxT( "kicad_mod" ) ); //D(printf("%s: this:%p m_lib_path:'%s' aLibraryPath:'%s'\n", __func__, this, TO_UTF8( m_lib_path), TO_UTF8(aLibraryPath) );) - delete m_cache; - m_cache = new GH_CACHE(); + m_gh_cache = new GH_CACHE(); // INIT_LOGGER( "/tmp", "test.log" ); remote_get_zip( aLibraryPath ); @@ -238,7 +411,7 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath ) throw( IO_ERROR ) { string fp_name = TO_UTF8( fn.GetName() ); // omit extension & path - m_cache->insert( fp_name, entry ); + m_gh_cache->insert( fp_name, entry ); } else delete entry; diff --git a/pcbnew/github/github_plugin.h b/pcbnew/github/github_plugin.h index 12d4629ecd..02a0f3536e 100644 --- a/pcbnew/github/github_plugin.h +++ b/pcbnew/github/github_plugin.h @@ -25,45 +25,182 @@ #ifndef GITHUB_PLUGIN_H_ #define GITHUB_PLUGIN_H_ +#include struct GH_CACHE; /** - * Class GITHUB_PLUGIN - * implements a portion of pcbnew PLUGIN to provide read only access to a github - * repo consisting of pretty footprints - * - * @author Dick Hollenbeck - * @date Original date: 10-Sep-2013 + Class GITHUB_PLUGIN + implements a portion of pcbnew's PLUGIN interface to provide read only access + to a github repo consisting of pretty footprints, and optionally provides "Copy On Write" + support of edited footprints. + +

    It could have used version 3 of the github.com API documented here: + +

    +       http://developer.github.com
    +       https://help.github.com/articles/creating-an-access-token-for-command-line-use
    +   
    + + but it does not, since a better technique was discovered. Cleverly this + plugin simply reads in a zip file of the repo and unzips it from RAM as + needed. Therefore this "Github" plugin is read only for accessing remote + pretty libraries at https://github.com. + +

    The fp-lib-table dialog is entered via menu choice "Preferences | Library + Tables". For easy options editing in the current row, click on the "Edit + Options" button. The "Library Path" in the fp-lib-table row for a Github + library should be set to the full https:// URL. + +

    For example: + +

    +        https://github.com/liftoff-sr/pretty_footprints
    +   
    + + This is typically + +
    +        https://github.com/user_name/repo_name
    +   
    +

    + + The "Plugin Type" should be set to "Github". + +

    This plugin also supports "Copy On Write", a.k.a. "COW". Thus a Github + library may take an optional option called + allow_pretty_writing_to_this_dir. This option is essentially the + "Library Path" for a local "KiCad" (pretty) type library which is combined to + make up the Github library found in the same fp-lib-table row. If the option + is missing, then the Github library is read only as always. If the option is + present for a Github library, then any writes to this hybrid library will go + to the local *.pretty directory. Note that the github.com resident portion of + this hybrid COW library is always read only, meaning you cannot delete + anything or modify any footprint at github directly. The aggregate library + type remains "Github" in your discussions, but it consists of a local R/W + portion and a remote R/O portion. + +

    Below is an fp-lib-table entry for the case without option + allow_pretty_writing_to_this_dir: + + + + + + + + + + +
    NicknameLibrary PathPlugin TypeOptionsDescription
    githubhttps://github.com/liftoff-sr/pretty_footprintsGithubLiftoff's GH footprints
    + + Below is an fp-lib-table entry with the COW option given. Note the use of the environment variable + ${HOME}, as an example only. The github.pretty directory is based in ${HOME}/pretty/. Anytime you + use option allow_pretty_writing_to_this_dir, you will create that directory manually and it must + end in extension .pretty. + + + + + + + + + + + + +
    NicknameLibrary PathPlugin TypeOptionsDescription
    githubhttps://github.com/liftoff-sr/pretty_footprintsGithuballow_pretty_writing_to_this_dir=${HOME}/pretty/github.prettyLiftoff's GH footprints
    + +

    Any footprint loads will always give precedence to the local footprints + found in the pretty dir given by option + allow_pretty_writing_to_this_dir. So once you have written to the COW + library's local directory by doing a footprint save, no github updates will + be seen when loading a footprint by the same name as one for which you've + written locally. + +

    Always keep a separate local *.pretty directory for each Github library, + never combine them by referring to the same directory more than once. Also, + do not also use the same COW (*.pretty) directory in a "KiCad" fp-lib-table + entry. This would likely create a mess. The COW directory should be manually + created in advance, and the directory name must end with ".pretty". The value + of the option allow_pretty_writing_to_this_dir will be path + substituted with any environment variable strings embedded, just like the + "Library Path" is. + +

    What's the point of COW? It is to turbo-charge the sharing of footprints. + If you periodically email your COW pretty footprint modifications to the + Github repo maintainer, you can help update the Github copy. Simply email the + individual *.kicad_mod files you find in your COW directories. After you've + received confirmation that your changes have been committed up at github.com, + you can safely delete your COW file(s) and those from github.com will flow + down. Your goal should be to keep the COW file set as small as possible by + contributing frequently to the shared master copies at https://github.com. + +

    Note that if you use the module editor to delete a footprint and it is + present in the COW local dir, it will get deleted from there. However, it may + not be deleted from the library as a whole if the footprint of the same name + also exists in the github repo. In this case deleting the local copy will + simply unmask the one at the github repo. Remember, it is masked out if there + is a local COW copy, since the local copy always takes precedence. And + remember you cannot modify the github copy except by emailing a COW + modification to the repo maintainer. + +

    If you happen to be the repo maintainer, then the obvious solution for you + is to make your COW directory be your working copy directory. From + there you can push to github. And you can receive *.kicad_mod files by email + and put them into your local working copy directory also and do diffs, + reverting or denying when appropriate, editing when appropriate before + pushing or denying the change. Ultimately you would owe the sender either a + note of acceptance or denial by email. + + @author Dick Hollenbeck + @date Original date: 10-Sep-2013 + */ -class GITHUB_PLUGIN : public PLUGIN +class GITHUB_PLUGIN : public PCB_IO { public: //--------------------------------------------------------------- - // ("read-only" subset) + const wxString PluginName() const; - const wxString& PluginName() const; + const wxString GetFileExtension() const; - const wxString& GetFileExtension() const; - - wxArrayString FootprintEnumerate( const wxString& aLibraryPath, const PROPERTIES* aProperties ); + wxArrayString FootprintEnumerate( const wxString& aLibraryPath, + const PROPERTIES* aProperties = NULL ); MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties ); + void FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint, + const PROPERTIES* aProperties = NULL ); + + void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName, + const PROPERTIES* aProperties = NULL ); + bool IsFootprintLibWritable( const wxString& aLibraryPath ); void FootprintLibOptions( PROPERTIES* aListToAppendTo ) const; + // Since I derive from PCB_IO, I have to implement this, else I'd inherit his, which is bad since + // my lib_path is not his. Note: it is impossible to create a Github library, but can the C.O.W. portion. + void FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties ); + + // Since I derive from PCB_IO, I have to implement this, else I'd inherit his, which is bad since + // my lib_path is not his. Note: it is impossible to delete a Github library, but can the C.O.W portion. + bool FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties ); + //-------------------------------------------------------------- GITHUB_PLUGIN(); // constructor, if any, must be zero arg ~GITHUB_PLUGIN(); -private: +protected: - void cacheLib( const wxString& aLibraryPath ) throw( IO_ERROR ); + void init( const PROPERTIES* aProperties ); + + void cacheLib( const wxString& aLibraryPath, const PROPERTIES* aProperties ) throw( IO_ERROR ); /** * Function repoURL_zipURL @@ -84,7 +221,9 @@ private: wxString m_lib_path; ///< from aLibraryPath, something like https://github.com/liftoff-sr/pretty_footprints std::string m_zip_image; ///< byte image of the zip file in its entirety. - GH_CACHE* m_cache; + GH_CACHE* m_gh_cache; + wxString m_pretty_dir; }; + #endif // GITHUB_PLUGIN_H_ 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 3e38d67e36..4ae65563f9 100644 --- a/pcbnew/gpcb_plugin.h +++ b/pcbnew/gpcb_plugin.h @@ -52,24 +52,24 @@ public: //-------------------------------------------------------------- - const wxString& PluginName() const + const wxString PluginName() const { - static const wxString name = wxT( "Geda PCB" ); - return name; + return wxT( "Geda PCB" ); } - const wxString& GetFileExtension() const + const wxString GetFileExtension() const { - static const wxString extension = wxT( "fp" ); - return extension; + 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 ); @@ -85,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/import_dxf/dxf2brd_items.cpp b/pcbnew/import_dxf/dxf2brd_items.cpp index a077dde28b..13a8c4b429 100644 --- a/pcbnew/import_dxf/dxf2brd_items.cpp +++ b/pcbnew/import_dxf/dxf2brd_items.cpp @@ -41,9 +41,11 @@ #include #include +#include #include #include #include +#include DXF2BRD_CONVERTER::DXF2BRD_CONVERTER() : DRW_Interface() { @@ -156,10 +158,10 @@ void DXF2BRD_CONVERTER::addCircle( const DRW_Circle& data ) segm->SetLayer( m_brdLayer ); segm->SetShape( S_CIRCLE ); wxPoint center( mapX( data.basePoint.x ), mapY( data.basePoint.y ) ); - segm->SetPosition( center ); + segm->SetCenter( center ); wxPoint circle_start( mapX( data.basePoint.x + data.radious ), mapY( data.basePoint.y ) ); - segm->SetEnd( circle_start ); + segm->SetArcStart( circle_start ); segm->SetWidth( mapDim( data.thickness == 0 ? m_defaultThickness : data.thickness ) ); appendToBoard( segm ); @@ -178,18 +180,21 @@ void DXF2BRD_CONVERTER::addArc( const DRW_Arc& data ) // Init arc centre: wxPoint center( mapX( data.basePoint.x ), mapY( data.basePoint.y ) ); - segm->SetPosition( center ); + segm->SetCenter( center ); // Init arc start point double arcStartx = data.radious; double arcStarty = 0; - RotatePoint( &arcStartx, &arcStarty, -RAD2DECIDEG( data.staangle ) ); + double startangle = data.staangle; + double endangle = data.endangle; + + RotatePoint( &arcStartx, &arcStarty, -RAD2DECIDEG( startangle ) ); wxPoint arcStart( mapX( arcStartx + data.basePoint.x ), mapY( arcStarty + data.basePoint.y ) ); - segm->SetEnd( arcStart ); + segm->SetArcStart( arcStart ); // calculate arc angle (arcs are CCW, and should be < 0 in Pcbnew) - double angle = -RAD2DECIDEG( data.endangle - data.staangle ); + double angle = -RAD2DECIDEG( endangle - startangle ); if( angle > 0.0 ) angle -= 3600.0; diff --git a/pcbnew/io_mgr.h b/pcbnew/io_mgr.h index bd5b92a61d..58f6459d17 100644 --- a/pcbnew/io_mgr.h +++ b/pcbnew/io_mgr.h @@ -220,13 +220,13 @@ public: * Function PluginName * returns a brief hard coded name for this PLUGIN. */ - virtual const wxString& PluginName() const = 0; + virtual const wxString PluginName() const = 0; /** * Function GetFileExtension * returns the file extension for the PLUGIN. */ - virtual const wxString& GetFileExtension() const = 0; + virtual const wxString GetFileExtension() const = 0; /** * Function Load @@ -286,11 +286,11 @@ public: * Function FootprintEnumerate * returns a list of footprint names contained within the library at @a aLibraryPath. * - * @param aLibraryPath is a locator for the "library", usually a directory - * or file containing several footprints. + * @param aLibraryPath is a locator for the "library", usually a directory, file, + * or URL containing several footprints. * * @param aProperties is an associative array that can be used to tell the - * plugin how to access the library. + * plugin anything needed about how to perform with respect to @a aLibraryPath. * The caller continues to own this object (plugin may not delete it), and * plugins should expect it to be optionally NULL. * @@ -307,8 +307,8 @@ public: * loads a footprint having @a aFootprintName from the @a aLibraryPath containing * a library format that this PLUGIN knows about. * - * @param aLibraryPath is a locator for the "library", usually a directory - * or file containing several footprints. + * @param aLibraryPath is a locator for the "library", usually a directory, file, + * or URL containing several footprints. * * @param aFootprintName is the name of the footprint to load. * @@ -331,9 +331,8 @@ public: * will write @a aModule to an existing library located at @a aLibraryPath. * If a footprint by the same name already exists, it is replaced. * - * @param aLibraryPath is a locator for the "library", usually a directory - * or file containing several footprints. This is where the footprint is - * to be stored. + * @param aLibraryPath is a locator for the "library", usually a directory, file, + * or URL containing several footprints. * * @param aFootprint is what to store in the library. The caller continues * to own the footprint after this call. @@ -351,15 +350,15 @@ public: /** * Function FootprintDelete - * deletes the @a aFootprintName from the library at @a aLibraryPath. + * deletes @a aFootprintName from the library at @a aLibraryPath. * - * @param aLibraryPath is a locator for the "library", usually a directory - * or file containing several footprints. + * @param aLibraryPath is a locator for the "library", usually a directory, file, + * or URL containing several footprints. * * @param aFootprintName is the name of a footprint to delete from the specified library. * * @param aProperties is an associative array that can be used to tell the - * library create function anything special, because it can take any number of + * library delete function anything special, because it can take any number of * additional named tuning arguments that the plugin is known to support. * The caller continues to own this object (plugin may not delete it), and * plugins should expect it to be optionally NULL. @@ -375,8 +374,8 @@ public: * error to attempt to create an existing library or to attempt to create * on a "read only" location. * - * @param aLibraryPath is a locator for the "library", usually a directory - * or file which will contain footprints. + * @param aLibraryPath is a locator for the "library", usually a directory, file, + * or URL containing several footprints. * * @param aProperties is an associative array that can be used to tell the * library create function anything special, because it can take any number of @@ -414,6 +413,9 @@ public: * returns true iff the library at @a aLibraryPath is writable. (Often * system libraries are read only because of where they are installed.) * + * @param aLibraryPath is a locator for the "library", usually a directory, file, + * or URL containing several footprints. + * * @throw IO_ERROR if no library at aLibraryPath exists. */ virtual bool IsFootprintLibWritable( const wxString& aLibraryPath ); diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 23092f07e5..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,14 +75,17 @@ 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 ); wxString GetName() const { return m_file_name.GetDirs().Last(); } wxFileName GetFileName() const { return m_file_name; } + + /// Tell if the disk content or the lib_path has changed. bool IsModified() const; + MODULE* GetModule() const { return m_module.get(); } void UpdateModificationTime() { m_mod_time = m_file_name.GetModificationTime(); } }; @@ -339,6 +339,7 @@ bool FP_CACHE::IsModified( const wxString& aLibPath, const wxString& aFootprintN for( MODULE_CITER it = m_modules.begin(); it != m_modules.end(); ++it ) { wxFileName fn = m_lib_path; + fn.SetName( it->second->GetFileName().GetName() ); fn.SetExt( KiCadFootprintFileExtension ); @@ -966,12 +967,15 @@ void PCB_IO::format( MODULE* aModule, int aNestLevel ) const else m_out->Print( 0, "\n" ); - m_out->Print( aNestLevel+1, "(at %s", FMT_IU( aModule->GetPosition() ).c_str() ); + if( !( m_ctl & CTL_OMIT_AT ) ) + { + m_out->Print( aNestLevel+1, "(at %s", FMT_IU( aModule->GetPosition() ).c_str() ); - if( aModule->GetOrientation() != 0.0 ) - m_out->Print( 0, " %s", FMT_ANGLE( aModule->GetOrientation() ).c_str() ); + if( aModule->GetOrientation() != 0.0 ) + m_out->Print( 0, " %s", FMT_ANGLE( aModule->GetOrientation() ).c_str() ); - m_out->Print( 0, ")\n" ); + m_out->Print( 0, ")\n" ); + } if( !aModule->GetDescription().IsEmpty() ) m_out->Print( aNestLevel+1, "(descr %s)\n", @@ -1684,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; } @@ -1804,7 +1830,7 @@ void PCB_IO::FootprintDelete( const wxString& aLibraryPath, const wxString& aFoo { LOCALE_IO toggle; // toggles on, then off, the C locale. - init( NULL ); + init( aProperties ); cacheLib( aLibraryPath ); diff --git a/pcbnew/kicad_plugin.h b/pcbnew/kicad_plugin.h index 515e1b1a71..ce7c40ef38 100644 --- a/pcbnew/kicad_plugin.h +++ b/pcbnew/kicad_plugin.h @@ -43,6 +43,8 @@ class PCB_PARSER; #define CTL_OMIT_TSTAMPS (1 << 2) #define CTL_OMIT_INITIAL_COMMENTS (1 << 3) ///< omit MODULE initial comments #define CTL_OMIT_PATH (1 << 4) +#define CTL_OMIT_AT (1 << 5) + // common combinations of the above: @@ -50,7 +52,7 @@ class PCB_PARSER; #define CTL_FOR_CLIPBOARD (CTL_STD_LAYER_NAMES|CTL_OMIT_NETS) /// Format output for a footprint library instead of clipboard or BOARD -#define CTL_FOR_LIBRARY (CTL_STD_LAYER_NAMES|CTL_OMIT_NETS|CTL_OMIT_TSTAMPS|CTL_OMIT_PATH) +#define CTL_FOR_LIBRARY (CTL_STD_LAYER_NAMES|CTL_OMIT_NETS|CTL_OMIT_TSTAMPS|CTL_OMIT_PATH|CTL_OMIT_AT) /// The zero arg constructor when PCB_IO is used for PLUGIN::Load() and PLUGIN::Save()ing /// a BOARD file underneath IO_MGR. @@ -83,20 +85,18 @@ public: //-------------------------------------------------------------- - const wxString& PluginName() const + const wxString PluginName() const { - static const wxString name = wxT( "KiCad" ); - return name; + return wxT( "KiCad" ); } - const wxString& GetFileExtension() const + const wxString GetFileExtension() const { // Would have used wildcards_and_files_ext.cpp's KiCadPcbFileExtension, // but to be pure, a plugin should not assume that it will always be linked // with the core of the pcbnew code. (Might someday be a DLL/DSO.) Besides, // file extension policy should be controlled by the plugin. - static const wxString extension = wxT( "kicad_pcb" ); - return extension; + return wxT( "kicad_pcb" ); } void Save( const wxString& aFileName, BOARD* aBoard, @@ -172,6 +172,10 @@ protected: int m_ctl; PCB_PARSER* m_parser; + /// we only cache one footprint library, this determines which one. + void cacheLib( const wxString& aLibraryPath, const wxString& aFootprintName = wxEmptyString ); + + void init( const PROPERTIES* aProperties ); private: void format( BOARD* aBoard, int aNestLevel = 0 ) const @@ -211,11 +215,6 @@ private: void formatLayers( LAYER_MSK aLayerMask, int aNestLevel = 0 ) const throw( IO_ERROR ); - - /// we only cache one footprint library for now, this determines which one. - void cacheLib( const wxString& aLibraryPath, const wxString& aFootprintName = wxEmptyString ); - - void init( const PROPERTIES* aProperties ); }; #endif // KICAD_PLUGIN_H_ diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index 9f912da92e..11afe8aa0f 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -281,6 +281,10 @@ void LEGACY_PLUGIN::loadAllSections( bool doAppend ) FPID fpid; std::string fpName = StrPurge( line + SZ( "$MODULE" ) ); + // The footprint names in legacy libraries can contain the '/' and ':' + // characters which will cause the FPID parser to choke. + ReplaceIllegalFileNameChars( &fpName ); + if( !fpName.empty() ) fpid = FPID( fpName ); @@ -405,6 +409,7 @@ void LEGACY_PLUGIN::checkVersion() void LEGACY_PLUGIN::loadGENERAL() { char* line; + char* saveptr; while( ( line = READLINE( m_reader ) ) != NULL ) { @@ -413,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" ) ) { @@ -516,6 +521,7 @@ void LEGACY_PLUGIN::loadSHEET() char buf[260]; TITLE_BLOCK tb; char* line; + char* saveptr; while( ( line = READLINE( m_reader ) ) != NULL ) { @@ -525,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 ) { @@ -537,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 ) @@ -630,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 ) { @@ -667,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 ); @@ -743,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 ); @@ -925,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 ) { @@ -985,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 @@ -1057,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 ) ); } @@ -1147,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 ) { @@ -1235,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 ); } } @@ -1262,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; @@ -1273,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 ); @@ -1528,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, @@ -1567,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 ) @@ -1693,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 ) { @@ -1723,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 ) { @@ -1860,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 ) { @@ -1924,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 ); @@ -1964,6 +1977,7 @@ void LEGACY_PLUGIN::loadPCB_TEXT() void LEGACY_PLUGIN::loadTrackList( int aStructType ) { char* line; + char* saveptr; while( ( line = READLINE( m_reader ) ) != NULL ) { @@ -1989,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 @@ -2184,6 +2198,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER() bool sawCorner = false; char buf[1024]; char* line; + char* saveptr; while( ( line = READLINE( m_reader ) ) != NULL ) { @@ -2236,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 ) { @@ -2280,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 ); } } @@ -2331,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 ) @@ -2443,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 ) { @@ -2500,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? @@ -3958,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; @@ -3969,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" ) ) { @@ -4031,6 +4049,10 @@ void LP_CACHE::LoadModules( LINE_READER* aReader ) std::string footprintName = StrPurge( line + SZ( "$MODULE" ) ); + // The footprint names in legacy libraries can contain the '/' and ':' + // characters which will cause the FPID parser to choke. + ReplaceIllegalFileNameChars( &footprintName ); + // set the footprint name first thing, so exceptions can use name. module->SetFPID( FPID( footprintName ) ); diff --git a/pcbnew/legacy_plugin.h b/pcbnew/legacy_plugin.h index b17aecb79d..c5eba40083 100644 --- a/pcbnew/legacy_plugin.h +++ b/pcbnew/legacy_plugin.h @@ -64,16 +64,14 @@ public: //--------------------------------------------------- - const wxString& PluginName() const + const wxString PluginName() const { - static const wxString name = wxT( "KiCad-Legacy" ); - return name; + return wxT( "KiCad-Legacy" ); } - const wxString& GetFileExtension() const + const wxString GetFileExtension() const { - static const wxString extension = wxT( "brd" ); - return extension; + return wxT( "brd" ); } BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties = NULL ); diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index 2db0b816a2..e767664afd 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -53,29 +54,29 @@ // unique, "file local" translations: -#define FMT_OK_OVERWRITE _( "Library <%s> exists, OK to replace ?" ) +#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_FILE_NOT_FOUND _( "File <%s> not found" ) -#define FMT_NOT_MODULE _( "Not a module 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_OK_DELETE _( "OK to delete module %s in library '%s'" ) +#define FMT_IMPORT_MODULE _( "Import Footprint" ) +#define FMT_FILE_NOT_FOUND _( "File '%s' not found" ) +#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_SELECT_LIB _( "Select Active Library" ) +#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" ) static const wxString ModExportFileWildcard( _( "KiCad foot print export files (*.emp)|*.emp" ) ); @@ -377,13 +378,14 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary() wxString wildcard; - wildcard << wxGetTranslation( LegacyFootprintLibPathWildcard ) << wxChar('|') - << wxGetTranslation( KiCadFootprintLibPathWildcard ); +// wildcard << wxGetTranslation( LegacyFootprintLibPathWildcard ) << wxChar( '|' ) +// << wxGetTranslation( KiCadFootprintLibPathWildcard ); + wildcard << wxGetTranslation( KiCadFootprintLibPathWildcard ) << wxChar( '|' ) + << wxGetTranslation( LegacyFootprintLibPathWildcard ); // prompt user for libPath and PLUGIN (library) type wxFileDialog dlg( this, FMT_CREATE_LIB, fn.GetPath(), wxEmptyString, - wildcard, - wxFD_SAVE + wildcard, wxFD_SAVE // | wxFD_OVERWRITE_PROMPT overwrite is tested below // after file extension has been added. ); @@ -399,7 +401,7 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary() } // wildcard's filter index has legacy in position 0. - IO_MGR::PCB_FILE_T piType = ( dlg.GetFilterIndex() == 0 ) ? IO_MGR::LEGACY : IO_MGR::KICAD; + IO_MGR::PCB_FILE_T piType = ( dlg.GetFilterIndex() == 1 ) ? IO_MGR::LEGACY : IO_MGR::KICAD; // wxFileDialog does not supply nor enforce the file extension, add it here. if( piType == IO_MGR::LEGACY ) @@ -463,36 +465,45 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary() bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary() { - PCB_EDIT_FRAME* parent = (PCB_EDIT_FRAME*) GetParent(); - wxString libPath = getLibPath(); - wxString footprintName = PCB_BASE_FRAME::SelectFootprint( this, libPath, - wxEmptyString, wxEmptyString, - parent->GetFootprintLibraryTable() ); + wxString nickname = getLibNickName(); - if( !footprintName ) + if( !m_footprintLibTable->IsFootprintLibWritable( nickname ) ) + { + wxString msg = wxString::Format( + _( "Library '%s' is read only" ), + GetChars( nickname ) + ); + + DisplayError( this, msg ); + return false; + } + + wxString fpid_txt = PCB_BASE_FRAME::SelectFootprint( this, nickname, + wxEmptyString, wxEmptyString, m_footprintLibTable ); + + if( !fpid_txt ) return false; + FPID fpid( fpid_txt ); + wxString fpname = FROM_UTF8( fpid.GetFootprintName().c_str() ); + // Confirmation - wxString msg = wxString::Format( FMT_OK_DELETE, footprintName.GetData(), libPath.GetData() ); + wxString msg = wxString::Format( FMT_OK_DELETE, fpname.GetData(), nickname.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 ); + m_footprintLibTable->FootprintDelete( nickname, fpname ); } catch( IO_ERROR ioe ) { - DisplayError( NULL, ioe.errorText ); + DisplayError( this, ioe.errorText ); return false; } - msg.Printf( FMT_MOD_DELETED, footprintName.GetData(), libPath.GetData() ); + msg.Printf( FMT_MOD_DELETED, fpname.GetData(), nickname.GetData() ); SetStatusText( msg ); @@ -500,44 +511,26 @@ bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary() } -/* Save modules in a library: - * param aNewModulesOnly: - * true : save modules not already existing in this lib - * false: save all modules - */ -void PCB_EDIT_FRAME::ArchiveModulesOnBoard( const wxString& aLibName, bool aNewModulesOnly ) +void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aNewModulesOnly ) { - wxString fileName = aLibName; - wxString path; - if( GetBoard()->m_Modules == NULL ) { DisplayInfoMessage( this, FMT_NO_MODULES ); return; } - path = wxGetApp().ReturnLastVisitedLibraryPath(); + wxString last_nickname = wxGetApp().ReturnLastVisitedLibraryPath(); - if( !aLibName ) + wxString nickname = SelectLibrary( last_nickname ); + + if( !nickname ) + return; + + wxGetApp().SaveLastVisitedLibraryPath( nickname ); + + if( !aNewModulesOnly ) { - 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 ) ); + wxString msg = wxString::Format( FMT_OK_OVERWRITE, GetChars( nickname ) ); if( !IsOK( this, msg ) ) return; @@ -547,33 +540,22 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( const wxString& aLibName, bool aNewM 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 ) { + m_footprintLibTable->FootprintLibDelete( nickname ); + m_footprintLibTable->FootprintLibCreate( nickname ); + for( MODULE* m = GetBoard()->m_Modules; m; m = m->Next() ) { - pi->FootprintSave( fileName, m ); + m_footprintLibTable->FootprintSave( nickname, m, true ); } } else { for( MODULE* m = GetBoard()->m_Modules; m; m = m->Next() ) { - if( !Save_Module_In_Library( fileName, m, false, false ) ) - break; + m_footprintLibTable->FootprintSave( nickname, m, false ); // Check for request to stop backup (ESCAPE key actuated) if( m_canvas->GetAbortRequest() ) @@ -584,12 +566,11 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( const wxString& aLibName, bool aNewM catch( IO_ERROR ioe ) { DisplayError( this, ioe.errorText ); - return; } } -bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibPath, +bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibrary, MODULE* aModule, bool aOverwrite, bool aDisplayDialog ) @@ -618,10 +599,10 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibPath, if( ! MODULE::IsLibNameValid( footprintName ) ) { - wxString msg; - msg.Printf( _("Error:\none of invalid chars '%s' found\nin '%s'" ), - MODULE::ReturnStringLibNameInvalidChars( true ), - GetChars( footprintName ) ); + wxString msg = wxString::Format( + _("Error:\none of invalid chars '%s' found\nin '%s'" ), + MODULE::ReturnStringLibNameInvalidChars( true ), + GetChars( footprintName ) ); DisplayError( NULL, msg ); return false; @@ -637,25 +618,23 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibPath, aModule->SetFPID( footprintName ); } - IO_MGR::PCB_FILE_T pluginType = IO_MGR::GuessPluginTypeFromLibPath( aLibPath ); - - MODULE* module_exists = NULL; + bool module_exists = false; try { - PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) ); + MODULE* m = m_footprintLibTable->FootprintLoad( aLibrary, footprintName ); - module_exists = pi->FootprintLoad( aLibPath, footprintName ); - - if( module_exists ) + if( m ) { - delete module_exists; + delete m; + + module_exists = true; // an existing footprint is found in current lib if( aDisplayDialog ) { wxString msg = wxString::Format( FMT_MOD_EXISTS, - footprintName.GetData(), aLibPath.GetData() ); + footprintName.GetData(), aLibrary.GetData() ); SetStatusText( msg ); } @@ -669,7 +648,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibPath, // this always overwrites any existing footprint, but should yell on its // own if the library or footprint is not writable. - pi->FootprintSave( aLibPath, aModule ); + m_footprintLibTable->FootprintSave( aLibrary, aModule ); } catch( IO_ERROR ioe ) { @@ -680,10 +659,10 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibPath, if( aDisplayDialog ) { wxString fmt = module_exists ? - _( "Component [%s] replaced in <%s>" ) : - _( "Component [%s] added in <%s>" ); + _( "Component [%s] replaced in '%s'" ) : + _( "Component [%s] added in '%s'" ); - wxString msg = wxString::Format( fmt, footprintName.GetData(), aLibPath.GetData() ); + wxString msg = wxString::Format( fmt, footprintName.GetData(), aLibrary.GetData() ); SetStatusText( msg ); } @@ -703,17 +682,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( &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; @@ -748,57 +726,7 @@ MODULE* PCB_BASE_FRAME::Create_1_Module( const wxString& aModuleName ) } -#if !defined( USE_FP_LIB_TABLE ) - -void FOOTPRINT_EDIT_FRAME::Select_Active_Library() -{ - if( g_LibraryNames.GetCount() == 0 ) - return; - - 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, getLibNickName() ); - - if( dlg.ShowModal() != wxID_OK ) - return; - - wxFileName fileName = wxFileName( wxEmptyString, dlg.GetTextSelection(), - LegacyFootprintLibPathExtension ); - - fileName = wxGetApp().FindLibraryPath( fileName ); - - if( fileName.IsOk() && fileName.FileExists() ) - { - setLibNickName( fileName.GetName() ); - setLibPath( fileName.GetFullPath() ); - } - else - { - wxString msg = wxString::Format( FMT_BAD_PATHS, GetChars( dlg.GetTextSelection() ) ); - - DisplayError( this, msg ); - - setLibNickName( wxEmptyString ); - setLibPath( wxEmptyString ); - } - - updateTitle(); -} - -#else - -void FOOTPRINT_EDIT_FRAME::Select_Active_Library() +wxString PCB_BASE_FRAME::SelectLibrary( const wxString& aNicknameExisting ) { wxArrayString headers; @@ -818,18 +746,14 @@ void FOOTPRINT_EDIT_FRAME::Select_Active_Library() itemsToDisplay.push_back( item ); } - EDA_LIST_DIALOG dlg( this, FMT_SELECT_LIB, headers, itemsToDisplay, getLibNickName() ); + EDA_LIST_DIALOG dlg( this, FMT_SELECT_LIB, headers, itemsToDisplay, aNicknameExisting ); if( dlg.ShowModal() != wxID_OK ) - return; + return wxEmptyString; wxString nickname = dlg.GetTextSelection(); - setLibNickName( nickname ); + wxLogDebug( wxT( "Chose footprint library '%s'." ), GetChars( nickname ) ); - wxLogDebug( wxT( "Chose footprint library <%s>." ), GetChars( nickname ) ); - - updateTitle(); + 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 766b563833..0070d7d837 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 @@ -467,15 +467,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 37fc32f77f..e4d13c9952 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -249,7 +249,15 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_MODEDIT_SELECT_CURRENT_LIB: - Select_Active_Library(); + { + wxString library = SelectLibrary( getLibNickName() ); + + if( library.size() ) + { + setLibNickName( library ); + updateTitle(); + } + } break; case ID_OPEN_MODULE_VIEWER: @@ -282,29 +290,29 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_MODEDIT_NEW_MODULE: + { + Clear_Pcb( true ); + GetScreen()->ClearUndoRedoList(); + SetCurItem( NULL ); + SetCrossHairPosition( wxPoint( 0, 0 ) ); + + MODULE* module = Create_1_Module( wxEmptyString ); + + if( module ) // i.e. if create module command not aborted { - Clear_Pcb( true ); - GetScreen()->ClearUndoRedoList(); - SetCurItem( NULL ); - SetCrossHairPosition( wxPoint( 0, 0 ) ); + // Initialize data relative to nets and netclasses (for a new + // module the defaults are used) + // This is mandatory to handle and draw pads + GetBoard()->BuildListOfNets(); + redraw = true; + module->SetPosition( wxPoint( 0, 0 ) ); - MODULE* module = Create_1_Module( wxEmptyString ); + if( GetBoard()->m_Modules ) + GetBoard()->m_Modules->ClearFlags(); - if( module ) // i.e. if create module command not aborted - { - // Initialize data relative to nets and netclasses (for a new - // module the defaults are used) - // This is mandatory to handle and draw pads - GetBoard()->BuildListOfNets(); - redraw = true; - module->SetPosition( wxPoint( 0, 0 ) ); - - if( GetBoard()->m_Modules ) - GetBoard()->m_Modules->ClearFlags(); - - Zoom_Automatique( false ); - } + Zoom_Automatique( false ); } + } break; case ID_MODEDIT_NEW_MODULE_FROM_WIZARD: @@ -349,9 +357,9 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_MODEDIT_SAVE_LIBMODULE: - if( GetBoard()->m_Modules && getLibPath() != wxEmptyString ) + if( GetBoard()->m_Modules && getLibNickName().size() ) { - Save_Module_In_Library( getLibPath(), GetBoard()->m_Modules, true, true ); + Save_Module_In_Library( getLibNickName(), GetBoard()->m_Modules, true, true ); GetScreen()->ClrModify(); } break; @@ -484,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/modedit_undo_redo.cpp b/pcbnew/modedit_undo_redo.cpp index 5e1fc518cc..4f273eb3c7 100644 --- a/pcbnew/modedit_undo_redo.cpp +++ b/pcbnew/modedit_undo_redo.cpp @@ -30,10 +30,17 @@ void FOOTPRINT_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem, lastcmd->PushItem( wrapper ); GetScreen()->PushCommandToUndoList( lastcmd ); + /* Clear current flags (which can be temporary set by a current edit command) */ for( item = CopyItem->GraphicalItems(); item != NULL; item = item->Next() ) item->ClearFlags(); + for( D_PAD* pad = CopyItem->Pads(); pad; pad = pad->Next() ) + pad->ClearFlags(); + + CopyItem->Reference().ClearFlags(); + CopyItem->Value().ClearFlags(); + /* Clear redo list, because after new save there is no redo to do */ GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList ); } diff --git a/pcbnew/module_editor_frame.h b/pcbnew/module_editor_frame.h index 4d50de7b49..5cb6ea1166 100644 --- a/pcbnew/module_editor_frame.h +++ b/pcbnew/module_editor_frame.h @@ -401,8 +401,6 @@ public: */ bool DeleteModuleFromCurrentLibrary(); - void Select_Active_Library(); - virtual EDA_COLOR_T GetGridColor( void ) const; DECLARE_EVENT_TABLE() @@ -439,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 50dd1e9d4c..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,9 +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( GetBoard()->m_Modules && getLibPath() != wxEmptyString ) + if( GetBoard()->m_Modules && getLibNickName().size() ) { - if( Save_Module_In_Library( getLibPath(), GetBoard()->m_Modules, true, true ) ) + if( Save_Module_In_Library( getLibNickName(), GetBoard()->m_Modules, true, true ) ) { // save was correct GetScreen()->ClrModify(); @@ -486,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 } @@ -617,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 ) @@ -680,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 c833e5c10c..19d09d6268 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/onrightclick.cpp b/pcbnew/onrightclick.cpp index 1923608adb..37d53b3795 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -386,25 +386,26 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) { wxMenu* commands = new wxMenu; AddMenuItem( aPopMenu, commands, ID_POPUP_PCB_AUTOPLACE_COMMANDS, - _( "Global Move and Place" ), KiBitmap( move_xpm ) ); + _( "Global Spread and Place" ), KiBitmap( move_xpm ) ); AddMenuItem( commands, ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES, - _( "Unlock All Modules" ), KiBitmap( unlocked_xpm ) ); + _( "Unlock All Footprints" ), KiBitmap( unlocked_xpm ) ); AddMenuItem( commands, ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES, - _( "Lock All Modules" ), KiBitmap( locked_xpm ) ); + _( "Lock All Footprints" ), KiBitmap( locked_xpm ) ); commands->AppendSeparator(); - AddMenuItem( commands, ID_POPUP_PCB_AUTOMOVE_ALL_MODULES, - _( "Move All Modules" ), KiBitmap( move_xpm ) ); - commands->Append( ID_POPUP_PCB_AUTOMOVE_NEW_MODULES, _( "Move New Modules" ) ); + AddMenuItem( commands, ID_POPUP_PCB_SPREAD_ALL_MODULES, + _( "Spread out All Footprints" ), KiBitmap( move_xpm ) ); + commands->Append( ID_POPUP_PCB_SPREAD_NEW_MODULES, + _( "Spread out Footprints not Already on Board" ) ); commands->AppendSeparator(); commands->Append( ID_POPUP_PCB_AUTOPLACE_ALL_MODULES, - _( "Automatically Place All Modules" ) ); + _( "Automatically Place All Footprints" ) ); commands->Append( ID_POPUP_PCB_AUTOPLACE_NEW_MODULES, - _( "Automatically Place New Modules" ) ); + _( "Automatically Place New Footprints" ) ); commands->Append( ID_POPUP_PCB_AUTOPLACE_NEXT_MODULE, - _( "Automatically Place Next Module" ) ); + _( "Automatically Place Next Footprints" ) ); commands->AppendSeparator(); AddMenuItem( commands, ID_POPUP_PCB_REORIENT_ALL_MODULES, - _( "Orient All Modules" ), KiBitmap( rotate_module_pos_xpm ) ); + _( "Orient All Footprints" ), KiBitmap( rotate_module_pos_xpm ) ); aPopMenu->AppendSeparator(); } diff --git a/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.cpp b/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.cpp index c605f42a26..0c7c75c974 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.cpp @@ -55,19 +55,15 @@ PCAD_PLUGIN::~PCAD_PLUGIN() } -const wxString& PCAD_PLUGIN::PluginName() const +const wxString PCAD_PLUGIN::PluginName() const { - static const wxString name = wxT( "P-Cad" ); - - return name; + return wxT( "P-Cad" ); } -const wxString& PCAD_PLUGIN::GetFileExtension() const +const wxString PCAD_PLUGIN::GetFileExtension() const { - static const wxString extension = wxT( "pcb" ); - - return extension; + return wxT( "pcb" ); } diff --git a/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.h b/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.h index 55949829ff..45ecbd92b4 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.h +++ b/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.h @@ -39,18 +39,19 @@ public: // ------------------------------------------------------- - const wxString& PluginName() const; + const wxString PluginName() const; BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties = NULL ); - const wxString& GetFileExtension() const; + const wxString GetFileExtension() const; // ------------------------------------------------------ PCAD_PLUGIN(); ~PCAD_PLUGIN(); + private: const PROPERTIES* m_props; BOARD* m_board; diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp index f69f81534d..0cac7b3db2 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_arc.cpp @@ -60,8 +60,8 @@ void PCB_ARC::Parse( XNODE* aNode, XNODE* lNode; double a = 0.0; int r = 0; - int endX; - int endY; + int endX = 0; + int endY = 0; m_PCadLayer = aLayer; m_KiCadLayer = GetKiCadLayer(); 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 c639f88024..3145afec51 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -1,10 +1,10 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004-2010 Jean-Pierre Charras, jean-pierre.charras@gpisa-lab.inpg.fr - * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2011 Wayne Stambaugh - * Copyright (C) 2010 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 2013 Wayne Stambaugh + * Copyright (C) 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 @@ -244,7 +244,7 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) PCB_EDIT_FRAME::ProcessMuWaveFunctions ) EVT_MENU_RANGE( ID_POPUP_PCB_AUTOPLACE_START_RANGE, ID_POPUP_PCB_AUTOPLACE_END_RANGE, - PCB_EDIT_FRAME::AutoPlace ) + PCB_EDIT_FRAME::OnPlaceOrRouteFootprints ) EVT_MENU( ID_POPUP_PCB_REORIENT_ALL_MODULES, PCB_EDIT_FRAME::OnOrientFootprints ) @@ -322,10 +322,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; @@ -488,7 +487,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 @@ -516,7 +514,6 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, DisplayError( this, msg ); } } -#endif setupTools(); } @@ -532,10 +529,8 @@ PCB_EDIT_FRAME::~PCB_EDIT_FRAME() delete m_drc; -#if defined( USE_FP_LIB_TABLE ) delete m_footprintLibTable; delete m_globalFootprintTable; -#endif } @@ -673,6 +668,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() ) { @@ -1205,3 +1201,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/pcbnew_id.h b/pcbnew/pcbnew_id.h index 4534b9d18c..1a03a3764c 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -216,8 +216,8 @@ enum pcbnew_ids ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES, ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES, ID_POPUP_PCB_AUTOPLACE_CURRENT_MODULE, - ID_POPUP_PCB_AUTOMOVE_ALL_MODULES, - ID_POPUP_PCB_AUTOMOVE_NEW_MODULES, + ID_POPUP_PCB_SPREAD_ALL_MODULES, + ID_POPUP_PCB_SPREAD_NEW_MODULES, ID_POPUP_PCB_AUTOPLACE_COMMANDS, ID_POPUP_PCB_AUTOPLACE_ALL_MODULES, ID_POPUP_PCB_AUTOPLACE_NEW_MODULES, 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/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index 1922a20091..e9272f1ca8 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -477,20 +477,18 @@ void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte ) if( pt_texte->IsMultilineAllowed() ) { + std::vector positions; wxArrayString* list = wxStringSplit( pt_texte->GetText(), '\n' ); - wxPoint offset; + positions.reserve( list->Count() ); - offset.y = pt_texte->GetInterline(); + pt_texte->GetPositionsOfLinesOfMultilineText( positions, list->Count() ); - RotatePoint( &offset, orient ); - - for( unsigned i = 0; i < list->Count(); i++ ) + for( unsigned ii = 0; ii < list->Count(); ii++ ) { - wxString txt = list->Item( i ); - m_plotter->Text( pos, UNSPECIFIED_COLOR, txt, orient, size, + wxString& txt = list->Item( ii ); + m_plotter->Text( positions[ii], UNSPECIFIED_COLOR, txt, orient, size, pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(), thickness, pt_texte->IsItalic(), allow_bold ); - pos += offset; } delete list; 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 ebde946a93..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; @@ -343,11 +341,11 @@ PNS_SHOVE::ShoveStatus PNS_SHOVE::ShoveLines( PNS_LINE* aCurrentHead ) PNS_LINE* currentLine = lineStack.top(); - prof_start( &totalRealTime, false ); + prof_start( &totalRealTime ); nearest = node->NearestObstacle( currentLine, PNS_ITEM::ANY ); prof_end( &totalRealTime ); - TRACE( 2, "t-nearestObstacle %lld us", (totalRealTime.value ) ); + TRACE( 2, "t-nearestObstacle %lld us", totalRealTime.usecs() ); if( !nearest ) { @@ -362,7 +360,7 @@ PNS_SHOVE::ShoveStatus PNS_SHOVE::ShoveLines( PNS_LINE* aCurrentHead ) TRACE( 1, "Iter %d optimize-line [range %d-%d, total %d]", iter % r_start % r_end % original->GetCLine().PointCount() ); // lastWalkSolid = NULL; - prof_start( &totalRealTime, false ); + prof_start( &totalRealTime ); if( optimizer.Optimize( original, &optimized ) ) { @@ -376,7 +374,7 @@ PNS_SHOVE::ShoveStatus PNS_SHOVE::ShoveLines( PNS_LINE* aCurrentHead ) prof_end( &totalRealTime ); - TRACE( 2, "t-optimizeObstacle %lld us", (totalRealTime.value ) ); + TRACE( 2, "t-optimizeObstacle %lld us", totalRealTime.usecs() ); } lineStack.pop(); @@ -393,12 +391,12 @@ PNS_SHOVE::ShoveStatus PNS_SHOVE::ShoveLines( PNS_LINE* aCurrentHead ) PNS_LINE* collidingLine = node->AssembleLine( pseg ); PNS_LINE* shovedLine = collidingLine->CloneProperties(); - prof_start( &totalRealTime, false ); + prof_start( &totalRealTime ); ShoveStatus st = shoveSingleLine( node, currentLine, collidingLine, *pseg, shovedLine ); prof_end( &totalRealTime ); - TRACE( 2, "t-shoveSingle %lld us", (totalRealTime.value ) ); + TRACE( 2, "t-shoveSingle %lld us", totalRealTime.usecs() ); if( st == SH_OK ) { @@ -441,11 +439,11 @@ PNS_SHOVE::ShoveStatus PNS_SHOVE::ShoveLines( PNS_LINE* aCurrentHead ) walkaround.SetSolidsOnly( true ); walkaround.SetSingleDirection( true ); - prof_start( &totalRealTime, false ); + prof_start( &totalRealTime ); walkaround.Route( *currentLine, *walkaroundLine, false ); prof_end( &totalRealTime ); - TRACE( 2, "t-walkSolid %lld us", (totalRealTime.value ) ); + TRACE( 2, "t-walkSolid %lld us", totalRealTime.usecs() ); node->Replace( currentLine, walkaroundLine ); 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 d85b1470ae..116e27f316 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/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 262d93ac45..fbd2aee6f6 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -67,9 +67,6 @@ SELECTION_TOOL::~SELECTION_TOOL() void SELECTION_TOOL::Reset() { - m_selection.group->Clear(); - m_selection.items.clear(); - // Reinsert the VIEW_GROUP, in case it was removed from the VIEW getView()->Remove( m_selection.group ); getView()->Add( m_selection.group ); 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 dcee75d64b..b527a7d8ea 100755 --- a/scripts/kicad-install.sh +++ b/scripts/kicad-install.sh @@ -4,8 +4,25 @@ # -> a Red Hat # compatible linux system. # -# The "install_prerequisites" step is the only "distro dependent" one. Could modify -# that step for other linux distros. +# The "install_prerequisites" step is the only "distro dependent" one. That step could be modified +# for other linux distros. +# +# There are 3 package groups in a KiCad install: +# 1) Compiled source code in the form of executable programs. +# 2) User manuals and other documentation typically as *.pdf files. +# 3) a) Schematic parts, b) layout footprints, and c) 3D models for footprints. +# +# To achieve 1) source is checked out from its repo and compiled by this script then executables +# are installed using CMake. +# To achieve 2) documentation is checked out from its repo and installed using CMake. +# TO achieve 3a) and 3c) they are checked out from their repos and installed using CMake. +# To achieve 3b) a global fp-lib-table is put into your home directory which points to +# http://github.com/KiCad. No actual footprints are installed locally, internet access is used +# during program operation to fetch footprints from github as if it was a remote drive in the cloud. +# If you want to install those same KiCad footprints locally, you may run a separate script +# named library-repos-install.sh found in this same directory. That script requires that "git" be on +# your system whereas this script does not. The footprints require some means to download them and +# bzr-git seems not up to the task. wget or curl would also work. # Set where the 3 source trees will go, use a full path @@ -13,12 +30,13 @@ 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 #OPTS="$OPTS -DKICAD_SCRIPTING=ON -DKICAD_SCRIPTING_MODULES=ON -DKICAD_SCRIPTING_WXPYTHON=ON" +LIB_REPO=~kicad-testing-committers/kicad/library + usage() { @@ -27,9 +45,10 @@ usage() echo "" echo "./kicad-install.sh " echo " where is one of:" - echo " --install-or-update (does full installation or update.)" - echo " --remove-sources (removes source trees for another attempt.)" - echo " --uninstall-libraries (removes KiCad supplied libraries.)" + echo " --install-or-update (does full installation or update.)" + echo " --remove-sources (removes source trees for another attempt.)" + echo " --uninstall-libraries (removes KiCad supplied libraries.)" + echo " --uninstall-kicad (uninstalls all of KiCad but leaves source trees.)" echo "" echo "example:" echo ' $ ./kicad-install.sh --install-or-update' @@ -52,6 +71,7 @@ install_prerequisites() cmake-curses-gui \ debhelper \ doxygen \ + grep \ libbz2-dev \ libcairo2-dev \ libglew-dev \ @@ -63,19 +83,21 @@ install_prerequisites() elif [ "$(expr match "$PM" '.*\(yum\)')" == "yum" ]; then #echo "red hat compatible system" # Note: if you find this list not to be accurate, please submit a patch: - sudo yum install + sudo yum groupinstall "Development Tools" + sudo yum install \ bzr \ bzrtools \ - build-essential \ + bzip2-libs \ + bzip2-devel \ cmake \ - cmake-curses-gui \ + cmake-gui \ doxygen \ - libbz2-dev \ - libcairo2-dev \ - libglew-dev \ - libssl-dev \ - libwxgtk2.8-dev \ - python-wxgtk2.8 + cairo-devel \ + glew-devel \ + grep \ + openssl-devel \ + wxGTK-devel \ + wxPython else echo echo "Incompatible System. Neither 'yum' nor 'apt-get' found. Not possible to continue." @@ -108,8 +130,6 @@ cmake_uninstall() elif [ ! -e install_manifest.txt ]; then echo echo "Missing file $dir/install_manifest.txt." - echo "Libraries may have already been uinstalled, or were not" - echo 'originally installed with an "uninstall" knowledgable CMakeLists.txt file.' else echo "uninstalling from $dir" sudo make uninstall @@ -118,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" @@ -144,10 +191,8 @@ install_or_update() cd ../ fi - - echo "step 4) checking out the libraries from launchpad repo..." if [ ! -d "$WORKING_TREES/kicad-lib.bzr" ]; then - bzr checkout lp:~kicad-lib-committers/kicad/library kicad-lib.bzr + bzr checkout "lp:$LIB_REPO" kicad-lib.bzr echo ' kicad-lib checked out.' else cd kicad-lib.bzr @@ -175,7 +220,6 @@ install_or_update() cmake $OPTS ../ else cd build - # Although a "make clean" is sometimes needed, more often than not it slows down the update # more than it is worth. Do it manually if you need to in this directory. # make clean @@ -189,13 +233,7 @@ install_or_update() echo " kicad program files installed." - echo "step 8) as non-root, install user configuration files..." - # install ~/fp-lib-table [and friends] - make install_user_configuration_files - echo " kicad user-configuration files installed." - - - echo "step 9) installing libraries..." + echo "step 8) installing libraries..." cd ../../kicad-lib.bzr rm_build_dir build mkdir build && cd build @@ -204,6 +242,12 @@ install_or_update() echo " kicad-lib installed." + echo "step 9) as non-root, install user configuration files..." + # install ~/fp-lib-table + make install_github_fp-lib-table + echo " kicad user-configuration files installed." + + echo "step 10) installing documentation..." cd ../../kicad-doc.bzr rm_build_dir build @@ -214,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 } @@ -239,4 +287,20 @@ if [ $# -eq 1 -a "$1" == "--uninstall-libraries" ]; then exit fi + +if [ $# -eq 1 -a "$1" == "--uninstall-kicad" ]; then + cd "$WORKING_TREES/kicad.bzr/build" + cmake_uninstall "$WORKING_TREES/kicad.bzr/build" + + cd "$WORKING_TREES/kicad-lib.bzr/build" + cmake_uninstall "$WORKING_TREES/kicad-lib.bzr/build" + + # this may fail since "uninstall" support is a recent feature of this repo: + cd "$WORKING_TREES/kicad-doc.bzr/build" + cmake_uninstall "$WORKING_TREES/kicad-doc.bzr/build" + + exit +fi + + usage diff --git a/scripts/library-repos-install.sh b/scripts/library-repos-install.sh new file mode 100755 index 0000000000..2ec26f04f7 --- /dev/null +++ b/scripts/library-repos-install.sh @@ -0,0 +1,169 @@ +#!/bin/bash +# Git KiCad library repos: +# +# The "install_prerequisites" step is the only "distro dependent" one. Could modify +# that step for other linux distros. +# This script requires "git". The package bzr-git is not up to the task. +# The first time you run with option --install-or-update that is the slowest, because +# git clone from github.com is slow. +# After that updates should run faster. + +# There are two reasons why you might want to run this script: +# +# 1) You want to contribute to the KiCad library team maintained libraries and have yet to +# discover or have chosen not to use the COW feature in the Github "Plugin Type". +# +# 2) You want to run with local pretty footprint libraries and not those remotely located +# 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". +# 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 +WORKING_TREES=~/kicad_sources + + +usage() +{ + echo "" + echo " usage:" + echo "" + echo "./library-sources-install.sh " + echo " where is one of:" + echo " --install-or-update (of the library sources.)" + echo " --remove-all-sources (remove all source trees.)" + echo " --install-prerequisites (install command tools needed here, run once first.)" +# echo " --uninstall-libraries (remove KiCad supplied libraries which have been installed.)" + echo "" + echo "example:" + echo ' $ ./library-sources-install.sh --install-or-update' +} + + +install_prerequisites() +{ + # Find a package manager, PM + PM=$( command -v yum || command -v apt-get ) + + # assume all these Debian, Mint, Ubuntu systems have same prerequisites + if [ "$(expr match "$PM" '.*\(apt-get\)')" == "apt-get" ]; then + #echo "debian compatible system" + sudo apt-get install \ + git \ + curl \ + sed + + # assume all yum systems have same prerequisites + elif [ "$(expr match "$PM" '.*\(yum\)')" == "yum" ]; then + #echo "red hat compatible system" + # Note: if you find this list not to be accurate, please submit a patch: + sudo yum install \ + git \ + curl \ + sed + else + echo + echo "Incompatible System. Neither 'yum' nor 'apt-get' found. Not possible to continue." + echo + exit 1 + fi +} + + +rm_build_dir() +{ + local dir="$1" + # this file is often created as root, so remove as root + sudo rm "$dir/install_manifest.txt" 2> /dev/null + rm -rf "$dir" +} + + +cmake_uninstall() +{ + # assume caller set the CWD, and is only telling us about it in $1 + local dir="$1" + + cwd=`pwd` + if [ "$cwd" != "$dir" ]; then + echo "missing dir $dir" + elif [ ! -e install_manifest.txt ]; then + echo + echo "Missing file $dir/install_manifest.txt." + else + echo "uninstalling from $dir" + sudo make uninstall + sudo rm install_manifest.txt + fi +} + + +detect_pretty_repos() +{ + # Use github API to list repos for org KiCad, then subset the JSON reply for only + # *.pretty repos + PRETTY_REPOS=`curl https://api.github.com/orgs/KiCad/repos?per_page=2000 2> /dev/null \ + | grep full_name | grep pretty \ + | sed -r 's:.+ "KiCad/(.+)",:\1:'` + + #echo "PRETTY_REPOS:$PRETTY_REPOS" +} + + +checkout_or_update_libraries() +{ + if [ ! -d "$WORKING_TREES" ]; then + sudo mkdir -p "$WORKING_TREES" + echo " mark $WORKING_TREES as owned by me" + sudo chown -R `whoami` "$WORKING_TREES" + fi + cd $WORKING_TREES + + detect_pretty_repos + + if [ ! -e "$WORKING_TREES/library-repos" ]; then + mkdir -p "$WORKING_TREES/library-repos" + fi + + for repo in kicad-library $PRETTY_REPOS; do + # echo "repo:$repo" + + if [ ! -e "$WORKING_TREES/library-repos/$repo" ]; then + + # Be _sure_ and preserve the directory name, we want extension .pretty not .pretty.git. + # That way those repos can serve as pretty libraries directly if need be. + + echo "installing $WORKING_TREES/library-repos/$repo" + git clone "https://github.com/KiCad/$repo" "$WORKING_TREES/library-repos/$repo" + else + echo "updating $WORKING_TREES/library-repos/$repo" + cd "$WORKING_TREES/library-repos/$repo" + git pull + fi + done +} + + +if [ $# -eq 1 -a "$1" == "--install-or-update" ]; then + checkout_or_update_libraries + exit +fi + + +if [ $# -eq 1 -a "$1" == "--remove-all-sources" ]; then + rm -rf "$WORKING_TREES/library-repos" + exit +fi + + +if [ $# -eq 1 -a "$1" == "--install-prerequisites" ]; then + install_prerequisites + exit +fi + + +usage diff --git a/scripts/make_global_table.sh b/scripts/make_global_table.sh deleted file mode 100755 index d82c1f4368..0000000000 --- a/scripts/make_global_table.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh -# Generate a footprint library table which can serve as a sensible initial -# personal/global table assuming you have all the footprint libraries installed -# from the bazaar library repo. -# Copyright (C) 2007-2011 SoftPLC Corporation, Dick Hollenbeck -# License GPLv2 - -# This program makes the table either in s-expression or CSV format. -# The CSV format can be loaded into a spreadsheet and then from there rows -# can be copied into either of the fp_table_dialog's table editors: -# a) personal/global or b) project - - -# Usage: -# $ make_global_table.sh [--csv] > outputfile - -# Library Type: Legacy for now, Kicad in future -libtype="Legacy" - - -# Get a list of modules currently in the launchpad repo: -mods=`bzr ls -d lp:~kicad-lib-committers/kicad/library modules 2>/dev/null` -#echo "$mods" - -mods=`echo "$mods" | egrep '\.mod$' | sort` -#echo "$mods" - -csv=0 - -if [ $# -gt 0 -a "$1" == "--csv" ]; then - csv=1 -fi - -today=`date --rfc-3339=date` - -if [ $csv -eq 1 ]; then - echo "NICKNAME,TYPE,URI,OPTIONS,DESCR,,FP LIB TABLE: made from KiCad's Bazaar 'library' repository on $today" - echo - - echo "$mods" | while read mod; - do - # base filename w/o extension - bfn=`basename $mod .mod` - - printf '%s,%s,${KISYSMOD}/%s,"",""\n' \ - "$bfn" \ - "$libtype" \ - "$bfn.mod" - done - -else - - echo "# FP LIB TABLE: made from KiCad's Bazaar 'library' repository on $today" - echo "(fp_lib_table" - - echo "$mods" | while read mod; - do - # base filename w/o extension - bfn=`basename $mod .mod` - - printf ' (lib (name %s)(type %s)(uri ${KISYSMOD}/%s)(options "")(descr ""))\n' \ - "$bfn" \ - "$libtype" \ - "$bfn.mod" - done - - echo ")" -fi 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/template/CMakeLists.txt b/template/CMakeLists.txt index db48d66c42..a804e9ed24 100644 --- a/template/CMakeLists.txt +++ b/template/CMakeLists.txt @@ -1,9 +1,5 @@ install( FILES kicad.pro - fp-lib-table - fp-lib-table.csv - fp-lib-table.for-github - fp-lib-table.for-eagle-6.4.0 gost_landscape.kicad_wks gost_portrait.kicad_wks pagelayout_default.kicad_wks diff --git a/template/fp-lib-table b/template/fp-lib-table deleted file mode 100644 index a765b9979b..0000000000 --- a/template/fp-lib-table +++ /dev/null @@ -1,73 +0,0 @@ -(fp_lib_table - (lib (name Air_Coils_SML_NEOSID)(type Legacy)(uri ${KISYSMOD}/Air_Coils_SML_NEOSID.mod)(options "")(descr HAMxx31A_HDMxx31A)) - (lib (name Capacitors_Elko_ThroughHole)(type Legacy)(uri ${KISYSMOD}/Capacitors_Elko_ThroughHole.mod)(options "")(descr "The way you like them.")) - (lib (name Capacitors_SMD)(type Legacy)(uri ${KISYSMOD}/Capacitors_SMD.mod)(options "")(descr "The way you like them.")) - (lib (name Capacitors)(type Legacy)(uri ${KISYSMOD}/Capacitors.mod)(options "")(descr "The way you like them.")) - (lib (name Connectors_Serial_MOLEX)(type Legacy)(uri ${KISYSMOD}/Connectors_Serial_MOLEX.mod)(options "")(descr 53047-A123)) - (lib (name Connect)(type Legacy)(uri ${KISYSMOD}/Connect.mod)(options "")(descr "The way you like them.")) - (lib (name Converters_DCDC_ACDC)(type Legacy)(uri ${KISYSMOD}/Converters_DCDC_ACDC.mod)(options "")(descr "The way you like them.")) - (lib (name Crystals_Oscillators_SMD)(type Legacy)(uri ${KISYSMOD}/Crystals_Oscillators_SMD.mod)(options "")(descr "The way you like them.")) - (lib (name Crystals)(type Legacy)(uri ${KISYSMOD}/Crystals.mod)(options "")(descr "The way you like them.")) - (lib (name Diodes_SMD)(type Legacy)(uri ${KISYSMOD}/Diodes_SMD.mod)(options "")(descr "The way you like them.")) - (lib (name Diodes_ThroughHole)(type Legacy)(uri ${KISYSMOD}/Diodes_ThroughHole.mod)(options "")(descr "The way you like them.")) - (lib (name Discret)(type Legacy)(uri ${KISYSMOD}/Discret.mod)(options "")(descr "The way you like them.")) - (lib (name Display)(type Legacy)(uri ${KISYSMOD}/Display.mod)(options "")(descr "The way you like them.")) - (lib (name Divers)(type Legacy)(uri ${KISYSMOD}/Divers.mod)(options "")(descr "The way you like them.")) - (lib (name EuroBoard_Outline)(type Legacy)(uri ${KISYSMOD}/EuroBoard_Outline.mod)(options "")(descr "The way you like them.")) - (lib (name Fiducials)(type Legacy)(uri ${KISYSMOD}/Fiducials.mod)(options "")(descr "The way you like them.")) - (lib (name Filters_HF_Coils_NEOSID)(type Legacy)(uri ${KISYSMOD}/Filters_HF_Coils_NEOSID.mod)(options "")(descr "The way you like them.")) - (lib (name Footprint_Symbols)(type Legacy)(uri ${KISYSMOD}/Footprint_Symbols.mod)(options "")(descr "The way you like them.")) - (lib (name Fuse_Holders_and_Fuses)(type Legacy)(uri ${KISYSMOD}/Fuse_Holders_and_Fuses.mod)(options "")(descr "The way you like them.")) - (lib (name Heatsinks)(type Legacy)(uri ${KISYSMOD}/Heatsinks.mod)(options "")(descr "The way you like them.")) - (lib (name Housings_ROHM)(type Legacy)(uri ${KISYSMOD}/Housings_ROHM.mod)(options "")(descr VML0806)) - (lib (name Housings_SIP9)(type Legacy)(uri ${KISYSMOD}/Housings_SIP9.mod)(options "")(descr "The way you like them.")) - (lib (name Housings_SOT-23_SOT-143_TSOT-6)(type Legacy)(uri ${KISYSMOD}/Housings_SOT-23_SOT-143_TSOT-6.mod)(options "")(descr "The way you like them.")) - (lib (name Housings_SOT-89)(type Legacy)(uri ${KISYSMOD}/Housings_SOT-89.mod)(options "")(descr "The way you like them.")) - (lib (name Housings_SOT)(type Legacy)(uri ${KISYSMOD}/Housings_SOT.mod)(options "")(descr "SOT126, SOT32")) - (lib (name Housings_TO-50)(type Legacy)(uri ${KISYSMOD}/Housings_TO-50.mod)(options "")(descr "The way you like them.")) - (lib (name Housings_TO-78)(type Legacy)(uri ${KISYSMOD}/Housings_TO-78.mod)(options "")(descr "The way you like them.")) - (lib (name Housings_TO-92)(type Legacy)(uri ${KISYSMOD}/Housings_TO-92.mod)(options "")(descr "The way you like them.")) - (lib (name Inductors_NEOSID)(type Legacy)(uri ${KISYSMOD}/Inductors_NEOSID.mod)(options "")(descr "The way you like them.")) - (lib (name Inductors)(type Legacy)(uri ${KISYSMOD}/Inductors.mod)(options "")(descr "The way you like them.")) - (lib (name IR-DirectFETs)(type Legacy)(uri ${KISYSMOD}/IR-DirectFETs.mod)(options "")(descr "The way you like them.")) - (lib (name Iut)(type Legacy)(uri ${KISYSMOD}/Iut.mod)(options "")(descr "The way you like them.")) - (lib (name Labels)(type Legacy)(uri ${KISYSMOD}/Labels.mod)(options "")(descr "The way you like them.")) - (lib (name LEDs)(type Legacy)(uri ${KISYSMOD}/LEDs.mod)(options "")(descr "The way you like them.")) - (lib (name Measurement_Points)(type Legacy)(uri ${KISYSMOD}/Measurement_Points.mod)(options "")(descr "The way you like them.")) - (lib (name Measurement_Scales)(type Legacy)(uri ${KISYSMOD}/Measurement_Scales.mod)(options "")(descr "The way you like them.")) - (lib (name Mechanical_Sockets)(type Legacy)(uri ${KISYSMOD}/Mechanical_Sockets.mod)(options "")(descr DIN41612)) - (lib (name Mounting_Holes)(type Legacy)(uri ${KISYSMOD}/Mounting_Holes.mod)(options "")(descr "The way you like them.")) - (lib (name Muonde)(type Legacy)(uri ${KISYSMOD}/Muonde.mod)(options "")(descr "The way you like them.")) - (lib (name NF-Transformers_ETAL)(type Legacy)(uri ${KISYSMOD}/NF-Transformers_ETAL.mod)(options "")(descr "The way you like them.")) - (lib (name Oddities)(type Legacy)(uri ${KISYSMOD}/Oddities.mod)(options "")(descr "The way you like them.")) - (lib (name Opto-Devices)(type Legacy)(uri ${KISYSMOD}/Opto-Devices.mod)(options "")(descr "The way you like them.")) - (lib (name Oscillator-Modules)(type Legacy)(uri ${KISYSMOD}/Oscillator-Modules.mod)(options "")(descr "The way you like them.")) - (lib (name Oscillators)(type Legacy)(uri ${KISYSMOD}/Oscillators.mod)(options "")(descr "SI570, SI571")) - (lib (name Pentawatts)(type Legacy)(uri ${KISYSMOD}/Pentawatts.mod)(options "")(descr "The way you like them.")) - (lib (name PFF_PSF_PSS_Leadforms)(type Legacy)(uri ${KISYSMOD}/PFF_PSF_PSS_Leadforms.mod)(options "")(descr Allegro_ACS754_ACS755_ACS756_HallCurrentSensor)) - (lib (name Pin_Arrays)(type Legacy)(uri ${KISYSMOD}/Pin_Arrays.mod)(options "")(descr "The way you like them.")) - (lib (name Potentiometers)(type Legacy)(uri ${KISYSMOD}/Potentiometers.mod)(options "")(descr "The way you like them.")) - (lib (name Power_Integrations)(type Legacy)(uri ${KISYSMOD}/Power_Integrations.mod)(options "")(descr "The way you like them.")) - (lib (name Printtrafo_CHK)(type Legacy)(uri ${KISYSMOD}/Printtrafo_CHK.mod)(options "")(descr "The way you like them.")) - (lib (name Relays_ThroughHole)(type Legacy)(uri ${KISYSMOD}/Relays_ThroughHole.mod)(options "")(descr "The way you like them.")) - (lib (name Resistors_SMD)(type Legacy)(uri ${KISYSMOD}/Resistors_SMD.mod)(options "")(descr "The way you like them.")) - (lib (name Resistors_ThroughHole)(type Legacy)(uri ${KISYSMOD}/Resistors_ThroughHole.mod)(options "")(descr "The way you like them.")) - (lib (name Resistors_Universal)(type Legacy)(uri ${KISYSMOD}/Resistors_Universal.mod)(options "")(descr Experimental)) - (lib (name SMD_Packages)(type Legacy)(uri ${KISYSMOD}/SMD_Packages.mod)(options "")(descr "The way you like them.")) - (lib (name Sockets_DIP)(type Legacy)(uri ${KISYSMOD}/Sockets_DIP.mod)(options "")(descr "The way you like them.")) - (lib (name Sockets_Mini-Universal)(type Legacy)(uri ${KISYSMOD}/Sockets_Mini-Universal.mod)(options "")(descr Mate-N-Lok)) - (lib (name Sockets_MOLEX_KK-System)(type Legacy)(uri ${KISYSMOD}/Sockets_MOLEX_KK-System.mod)(options "")(descr "The way you like them.")) - (lib (name Sockets_PGA)(type Legacy)(uri ${KISYSMOD}/Sockets_PGA.mod)(options "")(descr "The way you like them.")) - (lib (name Sockets)(type Legacy)(uri ${KISYSMOD}/Sockets.mod)(options "")(descr "The way you like them.")) - (lib (name Sockets_WAGO734)(type Legacy)(uri ${KISYSMOD}/Sockets_WAGO734.mod)(options "")(descr "The way you like them.")) - (lib (name SOIC_Packages)(type Legacy)(uri ${KISYSMOD}/SOIC_Packages.mod)(options "")(descr "The way you like them.")) - (lib (name SSOP_Packages)(type Legacy)(uri ${KISYSMOD}/SSOP_Packages.mod)(options "")(descr "The way you like them.")) - (lib (name Terminal_Blocks)(type Legacy)(uri ${KISYSMOD}/Terminal_Blocks.mod)(options "")(descr WAGO236-RM5mm)) - (lib (name Transformers_SMPS_ThroughHole)(type Legacy)(uri ${KISYSMOD}/Transformers_SMPS_ThroughHole.mod)(options "")(descr "The way you like them.")) - (lib (name Transistors_SMD)(type Legacy)(uri ${KISYSMOD}/Transistors_SMD.mod)(options "")(descr "The way you like them.")) - (lib (name Transistors_TO-220)(type Legacy)(uri ${KISYSMOD}/Transistors_TO-220.mod)(options "")(descr "The way you like them.")) - (lib (name Transistors_TO-247)(type Legacy)(uri ${KISYSMOD}/Transistors_TO-247.mod)(options "")(descr "The way you like them.")) - (lib (name Valves)(type Legacy)(uri ${KISYSMOD}/Valves.mod)(options "")(descr "The way you like them.")) - (lib (name Wire_Connections_Bridges)(type Legacy)(uri ${KISYSMOD}/Wire_Connections_Bridges.mod)(options "")(descr "The way you like them.")) - (lib (name Wire_Pads)(type Legacy)(uri ${KISYSMOD}/Wire_Pads.mod)(options "")(descr "The way you like them.")) -) diff --git a/template/fp-lib-table.csv b/template/fp-lib-table.csv deleted file mode 100644 index 130d38df5d..0000000000 --- a/template/fp-lib-table.csv +++ /dev/null @@ -1,75 +0,0 @@ -NICKNAME,TYPE,URI,OPTIONS,DESCR,,FP LIB TABLE: made from KiCad's Bazaar 'library' repository on 2013-06-25 - -Allegro_ACS754_ACS755_ACS756_HallCurrentSensor_RevA,Legacy,${KISYSMOD}/Allegro_ACS754_ACS755_ACS756_HallCurrentSensor_RevA.mod,"","" -capacitors,Legacy,${KISYSMOD}/capacitors.mod,"","" -Capacitors_SMD_RevA,Legacy,${KISYSMOD}/Capacitors_SMD_RevA.mod,"","" -connect,Legacy,${KISYSMOD}/connect.mod,"","" -connectors_molex_serial_53047-A123,Legacy,${KISYSMOD}/connectors_molex_serial_53047-A123.mod,"","" -Crystals_RevB_20Apr2013,Legacy,${KISYSMOD}/Crystals_RevB_20Apr2013.mod,"","" -DCDC-ACDC-Converter_RevC_20Jul2012,Legacy,${KISYSMOD}/DCDC-ACDC-Converter_RevC_20Jul2012.mod,"","" -Dioden_SMD_RevA_31May2013,Legacy,${KISYSMOD}/Dioden_SMD_RevA_31May2013.mod,"","" -Dioden_ThroughHole_RevC,Legacy,${KISYSMOD}/Dioden_ThroughHole_RevC.mod,"","" -dip_sockets,Legacy,${KISYSMOD}/dip_sockets.mod,"","" -discret,Legacy,${KISYSMOD}/discret.mod,"","" -display,Legacy,${KISYSMOD}/display.mod,"","" -divers,Legacy,${KISYSMOD}/divers.mod,"","" -Elko_ThroughHole_RevB-3_30Dec2011,Legacy,${KISYSMOD}/Elko_ThroughHole_RevB-3_30Dec2011.mod,"","" -EuroBoardoutline_RevC,Legacy,${KISYSMOD}/EuroBoardoutline_RevC.mod,"","" -Fiducials_RevC_04Aug2012,Legacy,${KISYSMOD}/Fiducials_RevC_04Aug2012.mod,"","" -Footprint-Symbols_RevD_28Aug2012,Legacy,${KISYSMOD}/Footprint-Symbols_RevD_28Aug2012.mod,"","" -FuseholderAndFuses_RevD_28Aug2012,Legacy,${KISYSMOD}/FuseholderAndFuses_RevD_28Aug2012.mod,"","" -Heatsinks_RevC,Legacy,${KISYSMOD}/Heatsinks_RevC.mod,"","" -inductors,Legacy,${KISYSMOD}/inductors.mod,"","" -IR-directFET_Packages_RevB,Legacy,${KISYSMOD}/IR-directFET_Packages_RevB.mod,"","" -iut,Legacy,${KISYSMOD}/iut.mod,"","" -Label_RevA_21Mar2011,Legacy,${KISYSMOD}/Label_RevA_21Mar2011.mod,"","" -led,Legacy,${KISYSMOD}/led.mod,"","" -libcms,Legacy,${KISYSMOD}/libcms.mod,"","" -Measurement_Point_RevA,Legacy,${KISYSMOD}/Measurement_Point_RevA.mod,"","" -Measurement-Scala_RevA,Legacy,${KISYSMOD}/Measurement-Scala_RevA.mod,"","" -Mechanical_Socket-Plug_DIN41612-Stuff_RevA,Legacy,${KISYSMOD}/Mechanical_Socket-Plug_DIN41612-Stuff_RevA.mod,"","" -MiniUniversalMate-N-LokSockets_13Aug2012,Legacy,${KISYSMOD}/MiniUniversalMate-N-LokSockets_13Aug2012.mod,"","" -MountingHole_RevA,Legacy,${KISYSMOD}/MountingHole_RevA.mod,"","" -muonde,Legacy,${KISYSMOD}/muonde.mod,"","" -Neosid_Air-Coil_SML_HAMxx31A_HDMxx31A_RevA_25Apr2012,Legacy,${KISYSMOD}/Neosid_Air-Coil_SML_HAMxx31A_HDMxx31A_RevA_25Apr2012.mod,"","" -Neosid_Filter_HF-Coil_25Apr2012,Legacy,${KISYSMOD}/Neosid_Filter_HF-Coil_25Apr2012.mod,"","" -Neosid_Inductor_21Apr2012,Legacy,${KISYSMOD}/Neosid_Inductor_21Apr2012.mod,"","" -NF-Transformer_ETAL_RevA_28Aug2012,Legacy,${KISYSMOD}/NF-Transformer_ETAL_RevA_28Aug2012.mod,"","" -Oddities_RevA_10Mar2011,Legacy,${KISYSMOD}/Oddities_RevA_10Mar2011.mod,"","" -Opto-Devices_RevC_03Oct2012,Legacy,${KISYSMOD}/Opto-Devices_RevC_03Oct2012.mod,"","" -Oscillator-Modul_RevA,Legacy,${KISYSMOD}/Oscillator-Modul_RevA.mod,"","" -Pentawatt_RevB_30Apr2011,Legacy,${KISYSMOD}/Pentawatt_RevB_30Apr2011.mod,"","" -pga_sockets,Legacy,${KISYSMOD}/pga_sockets.mod,"","" -pin_array,Legacy,${KISYSMOD}/pin_array.mod,"","" -Potentiometer_RevB_02Aug2010,Legacy,${KISYSMOD}/Potentiometer_RevB_02Aug2010.mod,"","" -powerint,Legacy,${KISYSMOD}/powerint.mod,"","" -Printtrafo_CHK_RevA_04Aug2010,Legacy,${KISYSMOD}/Printtrafo_CHK_RevA_04Aug2010.mod,"","" -Relay_ThroughHole_RevB,Legacy,${KISYSMOD}/Relay_ThroughHole_RevB.mod,"","" -Resistor_SMD_RevA,Legacy,${KISYSMOD}/Resistor_SMD_RevA.mod,"","" -Resistor_ThroughHole_RevB_22Apr2011,Legacy,${KISYSMOD}/Resistor_ThroughHole_RevB_22Apr2011.mod,"","" -Resistor_Universal-Experimental_RevA,Legacy,${KISYSMOD}/Resistor_Universal-Experimental_RevA.mod,"","" -SI570_SI571_Oscillator_RevA_11Jun2012,Legacy,${KISYSMOD}/SI570_SI571_Oscillator_RevA_11Jun2012.mod,"","" -SIP9_Housing_14Jun2013,Legacy,${KISYSMOD}/SIP9_Housing_14Jun2013.mod,"","" -smd_capacitors,Legacy,${KISYSMOD}/smd_capacitors.mod,"","" -smd_crystal_and_oscillator,Legacy,${KISYSMOD}/smd_crystal_and_oscillator.mod,"","" -smd_resistors,Legacy,${KISYSMOD}/smd_resistors.mod,"","" -smd_soic_packages,Legacy,${KISYSMOD}/smd_soic_packages.mod,"","" -smd_ssop_packages,Legacy,${KISYSMOD}/smd_ssop_packages.mod,"","" -smd_transistors,Legacy,${KISYSMOD}/smd_transistors.mod,"","" -Socket_MOLEX-KK-System,Legacy,${KISYSMOD}/Socket_MOLEX-KK-System.mod,"","" -sockets,Legacy,${KISYSMOD}/sockets.mod,"","" -Socket_WAGO734_RevA,Legacy,${KISYSMOD}/Socket_WAGO734_RevA.mod,"","" -SOT126_SOT32_Housings_RevA_22Oct2012,Legacy,${KISYSMOD}/SOT126_SOT32_Housings_RevA_22Oct2012.mod,"","" -SOT23_SOT143_SOT143R_TSOT6_MK06A_SC70-6_Housing_26Jul2012,Legacy,${KISYSMOD}/SOT23_SOT143_SOT143R_TSOT6_MK06A_SC70-6_Housing_26Jul2012.mod,"","" -SOT89-3_SOT89-5_Housing_RevA_02Sep2012,Legacy,${KISYSMOD}/SOT89-3_SOT89-5_Housing_RevA_02Sep2012.mod,"","" -TerminalBlock_WAGO236-RM5mm_RevA2-cache,Legacy,${KISYSMOD}/TerminalBlock_WAGO236-RM5mm_RevA2-cache.mod,"","" -TO-50_Housings_RevA_21Apr2013,Legacy,${KISYSMOD}/TO-50_Housings_RevA_21Apr2013.mod,"","" -TO-78_Housing_RevA_04Jun2013,Legacy,${KISYSMOD}/TO-78_Housing_RevA_04Jun2013.mod,"","" -TO-92_Housings_06Jun2013,Legacy,${KISYSMOD}/TO-92_Housings_06Jun2013.mod,"","" -TransformerSMPS_ThroughHole_RevA,Legacy,${KISYSMOD}/TransformerSMPS_ThroughHole_RevA.mod,"","" -Transistor_TO-220_RevB_03Sep2012,Legacy,${KISYSMOD}/Transistor_TO-220_RevB_03Sep2012.mod,"","" -Transistor_TO-247_RevC,Legacy,${KISYSMOD}/Transistor_TO-247_RevC.mod,"","" -valves,Legacy,${KISYSMOD}/valves.mod,"","" -VML0806_Housing_Rohm_RevA_26Oct2012,Legacy,${KISYSMOD}/VML0806_Housing_Rohm_RevA_26Oct2012.mod,"","" -WireConnections-Bridges_RevA,Legacy,${KISYSMOD}/WireConnections-Bridges_RevA.mod,"","" -WirePads_RevA_15Jun2010,Legacy,${KISYSMOD}/WirePads_RevA_15Jun2010.mod,"","" diff --git a/template/fp-lib-table.for-eagle-6.4.0 b/template/fp-lib-table.for-eagle-6.4.0 deleted file mode 100644 index 4a38da2c61..0000000000 --- a/template/fp-lib-table.for-eagle-6.4.0 +++ /dev/null @@ -1,335 +0,0 @@ -(fp_lib_table - (lib (name 19inch.lbr)(type Eagle)(uri ${EGMOD}/19inch.lbr)(options "")(descr "Project Library")) - (lib (name 40xx.lbr)(type Eagle)(uri ${EGMOD}/40xx.lbr)(options "")(descr "")) - (lib (name 41xx.lbr)(type Eagle)(uri ${EGMOD}/41xx.lbr)(options "")(descr "")) - (lib (name 45xx.lbr)(type Eagle)(uri ${EGMOD}/45xx.lbr)(options "")(descr "")) - (lib (name 74ac-logic.lbr)(type Eagle)(uri ${EGMOD}/74ac-logic.lbr)(options "")(descr "")) - (lib (name 74ttl-din.lbr)(type Eagle)(uri ${EGMOD}/74ttl-din.lbr)(options "")(descr "")) - (lib (name 74xx-eu.lbr)(type Eagle)(uri ${EGMOD}/74xx-eu.lbr)(options "")(descr "")) - (lib (name 74xx-little-de.lbr)(type Eagle)(uri ${EGMOD}/74xx-little-de.lbr)(options "")(descr "")) - (lib (name 74xx-little-us.lbr)(type Eagle)(uri ${EGMOD}/74xx-little-us.lbr)(options "")(descr "")) - (lib (name 74xx-us.lbr)(type Eagle)(uri ${EGMOD}/74xx-us.lbr)(options "")(descr "")) - (lib (name 751xx.lbr)(type Eagle)(uri ${EGMOD}/751xx.lbr)(options "")(descr "")) - (lib (name advanced-test-technologies.lbr)(type Eagle)(uri ${EGMOD}/advanced-test-technologies.lbr)(options "")(descr "")) - (lib (name agilent-technologies.lbr)(type Eagle)(uri ${EGMOD}/agilent-technologies.lbr)(options "")(descr "")) - (lib (name allegro.lbr)(type Eagle)(uri ${EGMOD}/allegro.lbr)(options "")(descr "")) - (lib (name altera.lbr)(type Eagle)(uri ${EGMOD}/altera.lbr)(options "")(descr "")) - (lib (name altera-cyclone-II.lbr)(type Eagle)(uri ${EGMOD}/altera-cyclone-II.lbr)(options "")(descr "")) - (lib (name altera-cyclone-III.lbr)(type Eagle)(uri ${EGMOD}/altera-cyclone-III.lbr)(options "")(descr "")) - (lib (name altera-stratix-iv.lbr)(type Eagle)(uri ${EGMOD}/altera-stratix-iv.lbr)(options "")(descr "")) - (lib (name am29-memory.lbr)(type Eagle)(uri ${EGMOD}/am29-memory.lbr)(options "")(descr "")) - (lib (name amd.lbr)(type Eagle)(uri ${EGMOD}/amd.lbr)(options "")(descr "")) - (lib (name amd-mach.lbr)(type Eagle)(uri ${EGMOD}/amd-mach.lbr)(options "")(descr "")) - (lib (name amis.lbr)(type Eagle)(uri ${EGMOD}/amis.lbr)(options "")(descr "")) - (lib (name analog-devices.lbr)(type Eagle)(uri ${EGMOD}/analog-devices.lbr)(options "")(descr "")) - (lib (name ase.lbr)(type Eagle)(uri ${EGMOD}/ase.lbr)(options "")(descr "")) - (lib (name atmel.lbr)(type Eagle)(uri ${EGMOD}/atmel.lbr)(options "")(descr "")) - (lib (name austriamicrosystems.lbr)(type Eagle)(uri ${EGMOD}/austriamicrosystems.lbr)(options "")(descr "")) - (lib (name avago.lbr)(type Eagle)(uri ${EGMOD}/avago.lbr)(options "")(descr "")) - (lib (name axis.lbr)(type Eagle)(uri ${EGMOD}/axis.lbr)(options "")(descr "")) - (lib (name battery.lbr)(type Eagle)(uri ${EGMOD}/battery.lbr)(options "")(descr "")) - (lib (name belton-engineering.lbr)(type Eagle)(uri ${EGMOD}/belton-engineering.lbr)(options "")(descr "")) - (lib (name burr-brown.lbr)(type Eagle)(uri ${EGMOD}/burr-brown.lbr)(options "")(descr "")) - (lib (name busbar.lbr)(type Eagle)(uri ${EGMOD}/busbar.lbr)(options "")(descr "")) - (lib (name buzzer.lbr)(type Eagle)(uri ${EGMOD}/buzzer.lbr)(options "")(descr "")) - (lib (name california-micro-devices.lbr)(type Eagle)(uri ${EGMOD}/california-micro-devices.lbr)(options "")(descr "")) - (lib (name capacitor-wima.lbr)(type Eagle)(uri ${EGMOD}/capacitor-wima.lbr)(options "")(descr "")) - (lib (name chipcard-siemens.lbr)(type Eagle)(uri ${EGMOD}/chipcard-siemens.lbr)(options "")(descr "")) - (lib (name cirrus-logic.lbr)(type Eagle)(uri ${EGMOD}/cirrus-logic.lbr)(options "")(descr "")) - (lib (name con-3m.lbr)(type Eagle)(uri ${EGMOD}/con-3m.lbr)(options "")(descr "")) - (lib (name con-4ucon.lbr)(type Eagle)(uri ${EGMOD}/con-4ucon.lbr)(options "")(descr "")) - (lib (name con-amp.lbr)(type Eagle)(uri ${EGMOD}/con-amp.lbr)(options "")(descr "")) - (lib (name con-amp-champ.lbr)(type Eagle)(uri ${EGMOD}/con-amp-champ.lbr)(options "")(descr "")) - (lib (name con-amphenol.lbr)(type Eagle)(uri ${EGMOD}/con-amphenol.lbr)(options "")(descr "")) - (lib (name con-amp-micromatch.lbr)(type Eagle)(uri ${EGMOD}/con-amp-micromatch.lbr)(options "")(descr "")) - (lib (name con-amp-mt.lbr)(type Eagle)(uri ${EGMOD}/con-amp-mt.lbr)(options "")(descr "")) - (lib (name con-amp-mt6.lbr)(type Eagle)(uri ${EGMOD}/con-amp-mt6.lbr)(options "")(descr "")) - (lib (name con-amp-quick.lbr)(type Eagle)(uri ${EGMOD}/con-amp-quick.lbr)(options "")(descr "")) - (lib (name con-amp-te.lbr)(type Eagle)(uri ${EGMOD}/con-amp-te.lbr)(options "")(descr "")) - (lib (name con-avx.lbr)(type Eagle)(uri ${EGMOD}/con-avx.lbr)(options "")(descr "")) - (lib (name con-berg.lbr)(type Eagle)(uri ${EGMOD}/con-berg.lbr)(options "")(descr "")) - (lib (name con-bosch.lbr)(type Eagle)(uri ${EGMOD}/con-bosch.lbr)(options "")(descr "")) - (lib (name con-chipcard-iso7816.lbr)(type Eagle)(uri ${EGMOD}/con-chipcard-iso7816.lbr)(options "")(descr "")) - (lib (name con-coax.lbr)(type Eagle)(uri ${EGMOD}/con-coax.lbr)(options "")(descr "")) - (lib (name con-commcon.lbr)(type Eagle)(uri ${EGMOD}/con-commcon.lbr)(options "")(descr "")) - (lib (name con-conrad.lbr)(type Eagle)(uri ${EGMOD}/con-conrad.lbr)(options "")(descr "")) - (lib (name con-cpci.lbr)(type Eagle)(uri ${EGMOD}/con-cpci.lbr)(options "")(descr "")) - (lib (name con-cui.lbr)(type Eagle)(uri ${EGMOD}/con-cui.lbr)(options "")(descr "")) - (lib (name con-cypressindustries.lbr)(type Eagle)(uri ${EGMOD}/con-cypressindustries.lbr)(options "")(descr "")) - (lib (name con-deutsch.lbr)(type Eagle)(uri ${EGMOD}/con-deutsch.lbr)(options "")(descr "")) - (lib (name con-dil.lbr)(type Eagle)(uri ${EGMOD}/con-dil.lbr)(options "")(descr "")) - (lib (name con-ebyelectro.lbr)(type Eagle)(uri ${EGMOD}/con-ebyelectro.lbr)(options "")(descr "")) - (lib (name con-elco.lbr)(type Eagle)(uri ${EGMOD}/con-elco.lbr)(options "")(descr "")) - (lib (name con-erni.lbr)(type Eagle)(uri ${EGMOD}/con-erni.lbr)(options "")(descr "")) - (lib (name con-faston.lbr)(type Eagle)(uri ${EGMOD}/con-faston.lbr)(options "")(descr "")) - (lib (name con-fci.lbr)(type Eagle)(uri ${EGMOD}/con-fci.lbr)(options "")(descr "")) - (lib (name con-friwo.lbr)(type Eagle)(uri ${EGMOD}/con-friwo.lbr)(options "")(descr "")) - (lib (name con-garry.lbr)(type Eagle)(uri ${EGMOD}/con-garry.lbr)(options "")(descr "")) - (lib (name con-harting.lbr)(type Eagle)(uri ${EGMOD}/con-harting.lbr)(options "")(descr "")) - (lib (name con-harting-h.lbr)(type Eagle)(uri ${EGMOD}/con-harting-h.lbr)(options "")(descr "")) - (lib (name con-harting-ml.lbr)(type Eagle)(uri ${EGMOD}/con-harting-ml.lbr)(options "")(descr "")) - (lib (name con-harting-v.lbr)(type Eagle)(uri ${EGMOD}/con-harting-v.lbr)(options "")(descr "")) - (lib (name con-hirose.lbr)(type Eagle)(uri ${EGMOD}/con-hirose.lbr)(options "")(descr "")) - (lib (name con-hirschmann.lbr)(type Eagle)(uri ${EGMOD}/con-hirschmann.lbr)(options "")(descr "")) - (lib (name con-jack.lbr)(type Eagle)(uri ${EGMOD}/con-jack.lbr)(options "")(descr "")) - (lib (name con-jae.lbr)(type Eagle)(uri ${EGMOD}/con-jae.lbr)(options "")(descr "")) - (lib (name con-jst.lbr)(type Eagle)(uri ${EGMOD}/con-jst.lbr)(options "")(descr "")) - (lib (name con-kycon.lbr)(type Eagle)(uri ${EGMOD}/con-kycon.lbr)(options "")(descr "")) - (lib (name con-kyocera-elco.lbr)(type Eagle)(uri ${EGMOD}/con-kyocera-elco.lbr)(options "")(descr "")) - (lib (name con-lemo.lbr)(type Eagle)(uri ${EGMOD}/con-lemo.lbr)(options "")(descr "")) - (lib (name con-leotronics.lbr)(type Eagle)(uri ${EGMOD}/con-leotronics.lbr)(options "")(descr "")) - (lib (name con-lsta.lbr)(type Eagle)(uri ${EGMOD}/con-lsta.lbr)(options "")(descr "")) - (lib (name con-lstb.lbr)(type Eagle)(uri ${EGMOD}/con-lstb.lbr)(options "")(descr "")) - (lib (name con-lumberg.lbr)(type Eagle)(uri ${EGMOD}/con-lumberg.lbr)(options "")(descr "")) - (lib (name con-ml.lbr)(type Eagle)(uri ${EGMOD}/con-ml.lbr)(options "")(descr "")) - (lib (name con-molex.lbr)(type Eagle)(uri ${EGMOD}/con-molex.lbr)(options "")(descr "")) - (lib (name con-neutrik_ag.lbr)(type Eagle)(uri ${EGMOD}/con-neutrik_ag.lbr)(options "")(descr "")) - (lib (name con-omron.lbr)(type Eagle)(uri ${EGMOD}/con-omron.lbr)(options "")(descr "")) - (lib (name con-panasonic.lbr)(type Eagle)(uri ${EGMOD}/con-panasonic.lbr)(options "")(descr "")) - (lib (name con-panduit.lbr)(type Eagle)(uri ${EGMOD}/con-panduit.lbr)(options "")(descr "")) - (lib (name con-pc.lbr)(type Eagle)(uri ${EGMOD}/con-pc.lbr)(options "")(descr "")) - (lib (name con-pc104.lbr)(type Eagle)(uri ${EGMOD}/con-pc104.lbr)(options "")(descr "")) - (lib (name con-phoenix-3.81.lbr)(type Eagle)(uri ${EGMOD}/con-phoenix-3.81.lbr)(options "")(descr "")) - (lib (name con-phoenix-254.lbr)(type Eagle)(uri ${EGMOD}/con-phoenix-254.lbr)(options "")(descr "")) - (lib (name con-phoenix-350.lbr)(type Eagle)(uri ${EGMOD}/con-phoenix-350.lbr)(options "")(descr "")) - (lib (name con-phoenix-500.lbr)(type Eagle)(uri ${EGMOD}/con-phoenix-500.lbr)(options "")(descr "")) - (lib (name con-phoenix-508.lbr)(type Eagle)(uri ${EGMOD}/con-phoenix-508.lbr)(options "")(descr "")) - (lib (name con-phoenix-762.lbr)(type Eagle)(uri ${EGMOD}/con-phoenix-762.lbr)(options "")(descr "")) - (lib (name con-phoenix-me_max.lbr)(type Eagle)(uri ${EGMOD}/con-phoenix-me_max.lbr)(options "")(descr "")) - (lib (name con-phoenix-mkds_5.lbr)(type Eagle)(uri ${EGMOD}/con-phoenix-mkds_5.lbr)(options "")(descr "")) - (lib (name con-phoenix-smkdsp.lbr)(type Eagle)(uri ${EGMOD}/con-phoenix-smkdsp.lbr)(options "")(descr "")) - (lib (name con-ptr500.lbr)(type Eagle)(uri ${EGMOD}/con-ptr500.lbr)(options "")(descr "")) - (lib (name con-pulse.lbr)(type Eagle)(uri ${EGMOD}/con-pulse.lbr)(options "")(descr "")) - (lib (name con-rib.lbr)(type Eagle)(uri ${EGMOD}/con-rib.lbr)(options "")(descr "")) - (lib (name con-samtec.lbr)(type Eagle)(uri ${EGMOD}/con-samtec.lbr)(options "")(descr "")) - (lib (name con-shallin.lbr)(type Eagle)(uri ${EGMOD}/con-shallin.lbr)(options "")(descr "")) - (lib (name con-shiua-chyuan.lbr)(type Eagle)(uri ${EGMOD}/con-shiua-chyuan.lbr)(options "")(descr "")) - (lib (name con-stewart.lbr)(type Eagle)(uri ${EGMOD}/con-stewart.lbr)(options "")(descr "")) - (lib (name con-stocko.lbr)(type Eagle)(uri ${EGMOD}/con-stocko.lbr)(options "")(descr "")) - (lib (name con-subd.lbr)(type Eagle)(uri ${EGMOD}/con-subd.lbr)(options "")(descr "")) - (lib (name con-sullinselectronics.lbr)(type Eagle)(uri ${EGMOD}/con-sullinselectronics.lbr)(options "")(descr "")) - (lib (name con-thomas-betts.lbr)(type Eagle)(uri ${EGMOD}/con-thomas-betts.lbr)(options "")(descr "")) - (lib (name con-tyco.lbr)(type Eagle)(uri ${EGMOD}/con-tyco.lbr)(options "")(descr "")) - (lib (name con-tycoelectronics.lbr)(type Eagle)(uri ${EGMOD}/con-tycoelectronics.lbr)(options "")(descr "")) - (lib (name con-vg.lbr)(type Eagle)(uri ${EGMOD}/con-vg.lbr)(options "")(descr "")) - (lib (name con-wago.lbr)(type Eagle)(uri ${EGMOD}/con-wago.lbr)(options "")(descr "")) - (lib (name con-wago255.lbr)(type Eagle)(uri ${EGMOD}/con-wago255.lbr)(options "")(descr "")) - (lib (name con-wago-500.lbr)(type Eagle)(uri ${EGMOD}/con-wago-500.lbr)(options "")(descr "")) - (lib (name con-wago-508.lbr)(type Eagle)(uri ${EGMOD}/con-wago-508.lbr)(options "")(descr "")) - (lib (name con-weidmueller-sl35.lbr)(type Eagle)(uri ${EGMOD}/con-weidmueller-sl35.lbr)(options "")(descr "")) - (lib (name con-wenzhou-yihua.lbr)(type Eagle)(uri ${EGMOD}/con-wenzhou-yihua.lbr)(options "")(descr "")) - (lib (name con-xmultiple.lbr)(type Eagle)(uri ${EGMOD}/con-xmultiple.lbr)(options "")(descr "")) - (lib (name con-yamaichi.lbr)(type Eagle)(uri ${EGMOD}/con-yamaichi.lbr)(options "")(descr "")) - (lib (name crystal.lbr)(type Eagle)(uri ${EGMOD}/crystal.lbr)(options "")(descr "")) - (lib (name csr.lbr)(type Eagle)(uri ${EGMOD}/csr.lbr)(options "")(descr "")) - (lib (name c-trimm.lbr)(type Eagle)(uri ${EGMOD}/c-trimm.lbr)(options "")(descr "")) - (lib (name cypress.lbr)(type Eagle)(uri ${EGMOD}/cypress.lbr)(options "")(descr "")) - (lib (name davicom.lbr)(type Eagle)(uri ${EGMOD}/davicom.lbr)(options "")(descr "")) - (lib (name dc-dc-converter.lbr)(type Eagle)(uri ${EGMOD}/dc-dc-converter.lbr)(options "")(descr "")) - (lib (name dimensions.lbr)(type Eagle)(uri ${EGMOD}/dimensions.lbr)(options "")(descr "")) - (lib (name diode.lbr)(type Eagle)(uri ${EGMOD}/diode.lbr)(options "")(descr "")) - (lib (name discrete.lbr)(type Eagle)(uri ${EGMOD}/discrete.lbr)(options "")(descr "")) - (lib (name display-hp.lbr)(type Eagle)(uri ${EGMOD}/display-hp.lbr)(options "")(descr "")) - (lib (name display-kingbright.lbr)(type Eagle)(uri ${EGMOD}/display-kingbright.lbr)(options "")(descr "")) - (lib (name display-lcd.lbr)(type Eagle)(uri ${EGMOD}/display-lcd.lbr)(options "")(descr "")) - (lib (name docu-dummy.lbr)(type Eagle)(uri ${EGMOD}/docu-dummy.lbr)(options "")(descr "")) - (lib (name eagle-ltspice.lbr)(type Eagle)(uri ${EGMOD}/eagle-ltspice.lbr)(options "")(descr "")) - (lib (name ecl.lbr)(type Eagle)(uri ${EGMOD}/ecl.lbr)(options "")(descr "")) - (lib (name em-microelectronic.lbr)(type Eagle)(uri ${EGMOD}/em-microelectronic.lbr)(options "")(descr "")) - (lib (name etx-board.lbr)(type Eagle)(uri ${EGMOD}/etx-board.lbr)(options "")(descr "")) - (lib (name exar.lbr)(type Eagle)(uri ${EGMOD}/exar.lbr)(options "")(descr "")) - (lib (name fairchild-semic.lbr)(type Eagle)(uri ${EGMOD}/fairchild-semic.lbr)(options "")(descr "")) - (lib (name farnell.lbr)(type Eagle)(uri ${EGMOD}/farnell.lbr)(options "")(descr "")) - (lib (name fiber-optic-hp.lbr)(type Eagle)(uri ${EGMOD}/fiber-optic-hp.lbr)(options "")(descr "")) - (lib (name fiber-optic-siemens.lbr)(type Eagle)(uri ${EGMOD}/fiber-optic-siemens.lbr)(options "")(descr "")) - (lib (name fifo.lbr)(type Eagle)(uri ${EGMOD}/fifo.lbr)(options "")(descr "")) - (lib (name flexipanel.lbr)(type Eagle)(uri ${EGMOD}/flexipanel.lbr)(options "")(descr "")) - (lib (name fox-electronics.lbr)(type Eagle)(uri ${EGMOD}/fox-electronics.lbr)(options "")(descr "")) - (lib (name frames.lbr)(type Eagle)(uri ${EGMOD}/frames.lbr)(options "")(descr "")) - (lib (name freescale.lbr)(type Eagle)(uri ${EGMOD}/freescale.lbr)(options "")(descr "")) - (lib (name ftdichip.lbr)(type Eagle)(uri ${EGMOD}/ftdichip.lbr)(options "")(descr "")) - (lib (name fujitsu.lbr)(type Eagle)(uri ${EGMOD}/fujitsu.lbr)(options "")(descr "")) - (lib (name fuse.lbr)(type Eagle)(uri ${EGMOD}/fuse.lbr)(options "")(descr "")) - (lib (name gennum.lbr)(type Eagle)(uri ${EGMOD}/gennum.lbr)(options "")(descr "")) - (lib (name halo-electronics.lbr)(type Eagle)(uri ${EGMOD}/halo-electronics.lbr)(options "")(descr "")) - (lib (name heatsink.lbr)(type Eagle)(uri ${EGMOD}/heatsink.lbr)(options "")(descr "")) - (lib (name holes.lbr)(type Eagle)(uri ${EGMOD}/holes.lbr)(options "")(descr "")) - (lib (name holtek.lbr)(type Eagle)(uri ${EGMOD}/holtek.lbr)(options "")(descr "")) - (lib (name ic-package.lbr)(type Eagle)(uri ${EGMOD}/ic-package.lbr)(options "")(descr "")) - (lib (name inductor-coilcraft.lbr)(type Eagle)(uri ${EGMOD}/inductor-coilcraft.lbr)(options "")(descr "")) - (lib (name inductor-neosid.lbr)(type Eagle)(uri ${EGMOD}/inductor-neosid.lbr)(options "")(descr "")) - (lib (name inductor-nkl.lbr)(type Eagle)(uri ${EGMOD}/inductor-nkl.lbr)(options "")(descr "")) - (lib (name inductors.lbr)(type Eagle)(uri ${EGMOD}/inductors.lbr)(options "")(descr "")) - (lib (name infineon.lbr)(type Eagle)(uri ${EGMOD}/infineon.lbr)(options "")(descr "")) - (lib (name infineon-tricore.lbr)(type Eagle)(uri ${EGMOD}/infineon-tricore.lbr)(options "")(descr "")) - (lib (name intersil.lbr)(type Eagle)(uri ${EGMOD}/intersil.lbr)(options "")(descr "")) - (lib (name intersil-techwell.lbr)(type Eagle)(uri ${EGMOD}/intersil-techwell.lbr)(options "")(descr "")) - (lib (name ir.lbr)(type Eagle)(uri ${EGMOD}/ir.lbr)(options "")(descr "")) - (lib (name isd.lbr)(type Eagle)(uri ${EGMOD}/isd.lbr)(options "")(descr "")) - (lib (name johanson-technology.lbr)(type Eagle)(uri ${EGMOD}/johanson-technology.lbr)(options "")(descr "")) - (lib (name jump-0r-smd.lbr)(type Eagle)(uri ${EGMOD}/jump-0r-smd.lbr)(options "")(descr "")) - (lib (name jumper.lbr)(type Eagle)(uri ${EGMOD}/jumper.lbr)(options "")(descr "")) - (lib (name lantronix.lbr)(type Eagle)(uri ${EGMOD}/lantronix.lbr)(options "")(descr "")) - (lib (name lattice.lbr)(type Eagle)(uri ${EGMOD}/lattice.lbr)(options "")(descr "")) - (lib (name lc-filter.lbr)(type Eagle)(uri ${EGMOD}/lc-filter.lbr)(options "")(descr "")) - (lib (name led.lbr)(type Eagle)(uri ${EGMOD}/led.lbr)(options "")(descr "")) - (lib (name led-7-segment.lbr)(type Eagle)(uri ${EGMOD}/led-7-segment.lbr)(options "")(descr "")) - (lib (name led-citizen-electronics.lbr)(type Eagle)(uri ${EGMOD}/led-citizen-electronics.lbr)(options "")(descr "")) - (lib (name led-lumiled.lbr)(type Eagle)(uri ${EGMOD}/led-lumiled.lbr)(options "")(descr "")) - (lib (name lem.lbr)(type Eagle)(uri ${EGMOD}/lem.lbr)(options "")(descr "")) - (lib (name linear.lbr)(type Eagle)(uri ${EGMOD}/linear.lbr)(options "")(descr "")) - (lib (name linear-technology.lbr)(type Eagle)(uri ${EGMOD}/linear-technology.lbr)(options "")(descr "")) - (lib (name linx.lbr)(type Eagle)(uri ${EGMOD}/linx.lbr)(options "")(descr "")) - (lib (name logo.lbr)(type Eagle)(uri ${EGMOD}/logo.lbr)(options "")(descr "")) - (lib (name lprs.lbr)(type Eagle)(uri ${EGMOD}/lprs.lbr)(options "")(descr "")) - (lib (name lsi-computer-systems.lbr)(type Eagle)(uri ${EGMOD}/lsi-computer-systems.lbr)(options "")(descr "")) - (lib (name lumiled.lbr)(type Eagle)(uri ${EGMOD}/lumiled.lbr)(options "")(descr "")) - (lib (name marks.lbr)(type Eagle)(uri ${EGMOD}/marks.lbr)(options "")(descr "")) - (lib (name maxim.lbr)(type Eagle)(uri ${EGMOD}/maxim.lbr)(options "")(descr "")) - (lib (name maxstream.lbr)(type Eagle)(uri ${EGMOD}/maxstream.lbr)(options "")(descr "")) - (lib (name melexis.lbr)(type Eagle)(uri ${EGMOD}/melexis.lbr)(options "")(descr "")) - (lib (name memory.lbr)(type Eagle)(uri ${EGMOD}/memory.lbr)(options "")(descr "")) - (lib (name memory-hitachi.lbr)(type Eagle)(uri ${EGMOD}/memory-hitachi.lbr)(options "")(descr "")) - (lib (name memory-idt.lbr)(type Eagle)(uri ${EGMOD}/memory-idt.lbr)(options "")(descr "")) - (lib (name memory-micron.lbr)(type Eagle)(uri ${EGMOD}/memory-micron.lbr)(options "")(descr "")) - (lib (name memory-motorola-dram.lbr)(type Eagle)(uri ${EGMOD}/memory-motorola-dram.lbr)(options "")(descr "")) - (lib (name memory-nec.lbr)(type Eagle)(uri ${EGMOD}/memory-nec.lbr)(options "")(descr "")) - (lib (name memory-samsung.lbr)(type Eagle)(uri ${EGMOD}/memory-samsung.lbr)(options "")(descr "")) - (lib (name memory-sram.lbr)(type Eagle)(uri ${EGMOD}/memory-sram.lbr)(options "")(descr "")) - (lib (name mems.lbr)(type Eagle)(uri ${EGMOD}/mems.lbr)(options "")(descr "")) - (lib (name micrel.lbr)(type Eagle)(uri ${EGMOD}/micrel.lbr)(options "")(descr "")) - (lib (name microchip.lbr)(type Eagle)(uri ${EGMOD}/microchip.lbr)(options "")(descr "")) - (lib (name micro-cyrod.lbr)(type Eagle)(uri ${EGMOD}/micro-cyrod.lbr)(options "")(descr "")) - (lib (name micro-fujitsu.lbr)(type Eagle)(uri ${EGMOD}/micro-fujitsu.lbr)(options "")(descr "")) - (lib (name micro-harris.lbr)(type Eagle)(uri ${EGMOD}/micro-harris.lbr)(options "")(descr "")) - (lib (name micro-hitachi.lbr)(type Eagle)(uri ${EGMOD}/micro-hitachi.lbr)(options "")(descr "")) - (lib (name micro-infineon.lbr)(type Eagle)(uri ${EGMOD}/micro-infineon.lbr)(options "")(descr "")) - (lib (name micro-intel.lbr)(type Eagle)(uri ${EGMOD}/micro-intel.lbr)(options "")(descr "")) - (lib (name micro-mc68000.lbr)(type Eagle)(uri ${EGMOD}/micro-mc68000.lbr)(options "")(descr "")) - (lib (name micro-motorola.lbr)(type Eagle)(uri ${EGMOD}/micro-motorola.lbr)(options "")(descr "")) - (lib (name micron.lbr)(type Eagle)(uri ${EGMOD}/micron.lbr)(options "")(descr "")) - (lib (name micronas.lbr)(type Eagle)(uri ${EGMOD}/micronas.lbr)(options "")(descr "")) - (lib (name micro-philips.lbr)(type Eagle)(uri ${EGMOD}/micro-philips.lbr)(options "")(descr "")) - (lib (name microphon.lbr)(type Eagle)(uri ${EGMOD}/microphon.lbr)(options "")(descr "")) - (lib (name micro-renesas.lbr)(type Eagle)(uri ${EGMOD}/micro-renesas.lbr)(options "")(descr "")) - (lib (name micro-samsung.lbr)(type Eagle)(uri ${EGMOD}/micro-samsung.lbr)(options "")(descr "")) - (lib (name micro-siemens.lbr)(type Eagle)(uri ${EGMOD}/micro-siemens.lbr)(options "")(descr "")) - (lib (name microwave.lbr)(type Eagle)(uri ${EGMOD}/microwave.lbr)(options "")(descr "")) - (lib (name midori-sensor.lbr)(type Eagle)(uri ${EGMOD}/midori-sensor.lbr)(options "")(descr "")) - (lib (name minicircuits.lbr)(type Eagle)(uri ${EGMOD}/minicircuits.lbr)(options "")(descr "")) - (lib (name mitsubishi-semiconductor.lbr)(type Eagle)(uri ${EGMOD}/mitsubishi-semiconductor.lbr)(options "")(descr "")) - (lib (name motorola-sensor-driver.lbr)(type Eagle)(uri ${EGMOD}/motorola-sensor-driver.lbr)(options "")(descr "")) - (lib (name murata-filter.lbr)(type Eagle)(uri ${EGMOD}/murata-filter.lbr)(options "")(descr "")) - (lib (name murata-sensor.lbr)(type Eagle)(uri ${EGMOD}/murata-sensor.lbr)(options "")(descr "")) - (lib (name nanotec.lbr)(type Eagle)(uri ${EGMOD}/nanotec.lbr)(options "")(descr "")) - (lib (name national-instruments.lbr)(type Eagle)(uri ${EGMOD}/national-instruments.lbr)(options "")(descr "")) - (lib (name national-semiconductor.lbr)(type Eagle)(uri ${EGMOD}/national-semiconductor.lbr)(options "")(descr "")) - (lib (name nec.lbr)(type Eagle)(uri ${EGMOD}/nec.lbr)(options "")(descr "")) - (lib (name nec-lqfp100-pack.lbr)(type Eagle)(uri ${EGMOD}/nec-lqfp100-pack.lbr)(options "")(descr "")) - (lib (name nrj-semiconductor.lbr)(type Eagle)(uri ${EGMOD}/nrj-semiconductor.lbr)(options "")(descr "")) - (lib (name omnivision.lbr)(type Eagle)(uri ${EGMOD}/omnivision.lbr)(options "")(descr "")) - (lib (name on-semiconductor.lbr)(type Eagle)(uri ${EGMOD}/on-semiconductor.lbr)(options "")(descr "")) - (lib (name optocoupler.lbr)(type Eagle)(uri ${EGMOD}/optocoupler.lbr)(options "")(descr "")) - (lib (name opto-honeywell.lbr)(type Eagle)(uri ${EGMOD}/opto-honeywell.lbr)(options "")(descr "")) - (lib (name opto-honeywell-3000.lbr)(type Eagle)(uri ${EGMOD}/opto-honeywell-3000.lbr)(options "")(descr "")) - (lib (name opto-honeywell-4000.lbr)(type Eagle)(uri ${EGMOD}/opto-honeywell-4000.lbr)(options "")(descr "")) - (lib (name opto-micro-linear.lbr)(type Eagle)(uri ${EGMOD}/opto-micro-linear.lbr)(options "")(descr "")) - (lib (name opto-transmittter-hp.lbr)(type Eagle)(uri ${EGMOD}/opto-transmittter-hp.lbr)(options "")(descr "")) - (lib (name opto-trans-siemens.lbr)(type Eagle)(uri ${EGMOD}/opto-trans-siemens.lbr)(options "")(descr "")) - (lib (name opto-vishay.lbr)(type Eagle)(uri ${EGMOD}/opto-vishay.lbr)(options "")(descr "")) - (lib (name pal.lbr)(type Eagle)(uri ${EGMOD}/pal.lbr)(options "")(descr "")) - (lib (name philips-semiconductors.lbr)(type Eagle)(uri ${EGMOD}/philips-semiconductors.lbr)(options "")(descr "")) - (lib (name photo-elements.lbr)(type Eagle)(uri ${EGMOD}/photo-elements.lbr)(options "")(descr "")) - (lib (name piher.lbr)(type Eagle)(uri ${EGMOD}/piher.lbr)(options "")(descr "")) - (lib (name pinhead.lbr)(type Eagle)(uri ${EGMOD}/pinhead.lbr)(options "")(descr "")) - (lib (name plcc-socket.lbr)(type Eagle)(uri ${EGMOD}/plcc-socket.lbr)(options "")(descr "")) - (lib (name pld-intel.lbr)(type Eagle)(uri ${EGMOD}/pld-intel.lbr)(options "")(descr "")) - (lib (name plxtech.lbr)(type Eagle)(uri ${EGMOD}/plxtech.lbr)(options "")(descr "")) - (lib (name pot.lbr)(type Eagle)(uri ${EGMOD}/pot.lbr)(options "")(descr "")) - (lib (name pot-vitrohm.lbr)(type Eagle)(uri ${EGMOD}/pot-vitrohm.lbr)(options "")(descr "")) - (lib (name pot-xicor.lbr)(type Eagle)(uri ${EGMOD}/pot-xicor.lbr)(options "")(descr "")) - (lib (name ptc-ntc.lbr)(type Eagle)(uri ${EGMOD}/ptc-ntc.lbr)(options "")(descr "")) - (lib (name quantum-research-group.lbr)(type Eagle)(uri ${EGMOD}/quantum-research-group.lbr)(options "")(descr "")) - (lib (name rcl.lbr)(type Eagle)(uri ${EGMOD}/rcl.lbr)(options "")(descr "")) - (lib (name recom-international.lbr)(type Eagle)(uri ${EGMOD}/recom-international.lbr)(options "")(descr "")) - (lib (name rectifier.lbr)(type Eagle)(uri ${EGMOD}/rectifier.lbr)(options "")(descr "")) - (lib (name ref-packages.lbr)(type Eagle)(uri ${EGMOD}/ref-packages.lbr)(options "")(descr "")) - (lib (name ref-packages-longpad.lbr)(type Eagle)(uri ${EGMOD}/ref-packages-longpad.lbr)(options "")(descr "")) - (lib (name relay.lbr)(type Eagle)(uri ${EGMOD}/relay.lbr)(options "")(descr "")) - (lib (name renesas.lbr)(type Eagle)(uri ${EGMOD}/renesas.lbr)(options "")(descr "")) - (lib (name resistor.lbr)(type Eagle)(uri ${EGMOD}/resistor.lbr)(options "")(descr "")) - (lib (name resistor-bourns.lbr)(type Eagle)(uri ${EGMOD}/resistor-bourns.lbr)(options "")(descr "")) - (lib (name resistor-dil.lbr)(type Eagle)(uri ${EGMOD}/resistor-dil.lbr)(options "")(descr "")) - (lib (name resistor-net.lbr)(type Eagle)(uri ${EGMOD}/resistor-net.lbr)(options "")(descr "")) - (lib (name resistor-power.lbr)(type Eagle)(uri ${EGMOD}/resistor-power.lbr)(options "")(descr "")) - (lib (name resistor-ruf.lbr)(type Eagle)(uri ${EGMOD}/resistor-ruf.lbr)(options "")(descr "")) - (lib (name resistor-shunt.lbr)(type Eagle)(uri ${EGMOD}/resistor-shunt.lbr)(options "")(descr "")) - (lib (name resistor-sil.lbr)(type Eagle)(uri ${EGMOD}/resistor-sil.lbr)(options "")(descr "")) - (lib (name rf-micro-devices.lbr)(type Eagle)(uri ${EGMOD}/rf-micro-devices.lbr)(options "")(descr "")) - (lib (name rf-solutions.lbr)(type Eagle)(uri ${EGMOD}/rf-solutions.lbr)(options "")(descr "")) - (lib (name rohm.lbr)(type Eagle)(uri ${EGMOD}/rohm.lbr)(options "")(descr "")) - (lib (name semicon-smd-ipc.lbr)(type Eagle)(uri ${EGMOD}/semicon-smd-ipc.lbr)(options "")(descr "")) - (lib (name sensor-comus-group.lbr)(type Eagle)(uri ${EGMOD}/sensor-comus-group.lbr)(options "")(descr "")) - (lib (name sensor-heraeus.lbr)(type Eagle)(uri ${EGMOD}/sensor-heraeus.lbr)(options "")(descr "")) - (lib (name sensor-infratec.lbr)(type Eagle)(uri ${EGMOD}/sensor-infratec.lbr)(options "")(descr "")) - (lib (name sharp.lbr)(type Eagle)(uri ${EGMOD}/sharp.lbr)(options "")(descr "")) - (lib (name silabs.lbr)(type Eagle)(uri ${EGMOD}/silabs.lbr)(options "")(descr "")) - (lib (name sim-technology.lbr)(type Eagle)(uri ${EGMOD}/sim-technology.lbr)(options "")(descr "")) - (lib (name sipex.lbr)(type Eagle)(uri ${EGMOD}/sipex.lbr)(options "")(descr "")) - (lib (name smd-ipc.lbr)(type Eagle)(uri ${EGMOD}/smd-ipc.lbr)(options "")(descr "")) - (lib (name smd-special.lbr)(type Eagle)(uri ${EGMOD}/smd-special.lbr)(options "")(descr "")) - (lib (name solomon-systech.lbr)(type Eagle)(uri ${EGMOD}/solomon-systech.lbr)(options "")(descr "")) - (lib (name solpad.lbr)(type Eagle)(uri ${EGMOD}/solpad.lbr)(options "")(descr "")) - (lib (name special.lbr)(type Eagle)(uri ${EGMOD}/special.lbr)(options "")(descr "")) - (lib (name special-drill.lbr)(type Eagle)(uri ${EGMOD}/special-drill.lbr)(options "")(descr "")) - (lib (name st-microelectronics.lbr)(type Eagle)(uri ${EGMOD}/st-microelectronics.lbr)(options "")(descr "")) - (lib (name supertex.lbr)(type Eagle)(uri ${EGMOD}/supertex.lbr)(options "")(descr "")) - (lib (name supply1.lbr)(type Eagle)(uri ${EGMOD}/supply1.lbr)(options "")(descr "")) - (lib (name supply2.lbr)(type Eagle)(uri ${EGMOD}/supply2.lbr)(options "")(descr "")) - (lib (name switch.lbr)(type Eagle)(uri ${EGMOD}/switch.lbr)(options "")(descr "")) - (lib (name switch-alps.lbr)(type Eagle)(uri ${EGMOD}/switch-alps.lbr)(options "")(descr "")) - (lib (name switch-coto.lbr)(type Eagle)(uri ${EGMOD}/switch-coto.lbr)(options "")(descr "")) - (lib (name switch-dil.lbr)(type Eagle)(uri ${EGMOD}/switch-dil.lbr)(options "")(descr "")) - (lib (name switch-misc.lbr)(type Eagle)(uri ${EGMOD}/switch-misc.lbr)(options "")(descr "")) - (lib (name switch-omron.lbr)(type Eagle)(uri ${EGMOD}/switch-omron.lbr)(options "")(descr "")) - (lib (name switch-raychem.lbr)(type Eagle)(uri ${EGMOD}/switch-raychem.lbr)(options "")(descr "")) - (lib (name switch-reed.lbr)(type Eagle)(uri ${EGMOD}/switch-reed.lbr)(options "")(descr "")) - (lib (name telcom.lbr)(type Eagle)(uri ${EGMOD}/telcom.lbr)(options "")(descr "")) - (lib (name telecontrolli.lbr)(type Eagle)(uri ${EGMOD}/telecontrolli.lbr)(options "")(descr "")) - (lib (name telefunken.lbr)(type Eagle)(uri ${EGMOD}/telefunken.lbr)(options "")(descr "")) - (lib (name testpad.lbr)(type Eagle)(uri ${EGMOD}/testpad.lbr)(options "")(descr "")) - (lib (name texas.lbr)(type Eagle)(uri ${EGMOD}/texas.lbr)(options "")(descr "")) - (lib (name texas-sn55-sn75.lbr)(type Eagle)(uri ${EGMOD}/texas-sn55-sn75.lbr)(options "")(descr "")) - (lib (name toshiba.lbr)(type Eagle)(uri ${EGMOD}/toshiba.lbr)(options "")(descr "")) - (lib (name traco-electronic.lbr)(type Eagle)(uri ${EGMOD}/traco-electronic.lbr)(options "")(descr "")) - (lib (name trafo.lbr)(type Eagle)(uri ${EGMOD}/trafo.lbr)(options "")(descr "")) - (lib (name trafo-bei.lbr)(type Eagle)(uri ${EGMOD}/trafo-bei.lbr)(options "")(descr "")) - (lib (name trafo-hammondmfg.lbr)(type Eagle)(uri ${EGMOD}/trafo-hammondmfg.lbr)(options "")(descr "")) - (lib (name trafo-siemens.lbr)(type Eagle)(uri ${EGMOD}/trafo-siemens.lbr)(options "")(descr "")) - (lib (name trafo-xicon.lbr)(type Eagle)(uri ${EGMOD}/trafo-xicon.lbr)(options "")(descr "")) - (lib (name transformer-pulse.lbr)(type Eagle)(uri ${EGMOD}/transformer-pulse.lbr)(options "")(descr "")) - (lib (name transistor.lbr)(type Eagle)(uri ${EGMOD}/transistor.lbr)(options "")(descr "")) - (lib (name transistor-fet.lbr)(type Eagle)(uri ${EGMOD}/transistor-fet.lbr)(options "")(descr "")) - (lib (name transistor-neu-to92.lbr)(type Eagle)(uri ${EGMOD}/transistor-neu-to92.lbr)(options "")(descr "")) - (lib (name transistor-npn.lbr)(type Eagle)(uri ${EGMOD}/transistor-npn.lbr)(options "")(descr "")) - (lib (name transistor-pnp.lbr)(type Eagle)(uri ${EGMOD}/transistor-pnp.lbr)(options "")(descr "")) - (lib (name transistor-power.lbr)(type Eagle)(uri ${EGMOD}/transistor-power.lbr)(options "")(descr "")) - (lib (name transistor-small-signal.lbr)(type Eagle)(uri ${EGMOD}/transistor-small-signal.lbr)(options "")(descr "")) - (lib (name triac.lbr)(type Eagle)(uri ${EGMOD}/triac.lbr)(options "")(descr "")) - (lib (name trimble.lbr)(type Eagle)(uri ${EGMOD}/trimble.lbr)(options "")(descr "")) - (lib (name tripas.lbr)(type Eagle)(uri ${EGMOD}/tripas.lbr)(options "")(descr "")) - (lib (name u-blox.lbr)(type Eagle)(uri ${EGMOD}/u-blox.lbr)(options "")(descr "")) - (lib (name uln-udn.lbr)(type Eagle)(uri ${EGMOD}/uln-udn.lbr)(options "")(descr "")) - (lib (name varistor.lbr)(type Eagle)(uri ${EGMOD}/varistor.lbr)(options "")(descr "")) - (lib (name v-reg.lbr)(type Eagle)(uri ${EGMOD}/v-reg.lbr)(options "")(descr "")) - (lib (name v-reg-micrel.lbr)(type Eagle)(uri ${EGMOD}/v-reg-micrel.lbr)(options "")(descr "")) - (lib (name wafer-scale-psd.lbr)(type Eagle)(uri ${EGMOD}/wafer-scale-psd.lbr)(options "")(descr "")) - (lib (name wirepad.lbr)(type Eagle)(uri ${EGMOD}/wirepad.lbr)(options "")(descr "")) - (lib (name xicor.lbr)(type Eagle)(uri ${EGMOD}/xicor.lbr)(options "")(descr "")) - (lib (name xilinx-virtex-v5.lbr)(type Eagle)(uri ${EGMOD}/xilinx-virtex-v5.lbr)(options "")(descr "")) - (lib (name xilinx-xc9.lbr)(type Eagle)(uri ${EGMOD}/xilinx-xc9.lbr)(options "")(descr "")) - (lib (name xilinx-xc18v.lbr)(type Eagle)(uri ${EGMOD}/xilinx-xc18v.lbr)(options "")(descr "")) - (lib (name xilinx-xcv.lbr)(type Eagle)(uri ${EGMOD}/xilinx-xcv.lbr)(options "")(descr "")) - (lib (name zetex.lbr)(type Eagle)(uri ${EGMOD}/zetex.lbr)(options "")(descr "")) - (lib (name zilog.lbr)(type Eagle)(uri ${EGMOD}/zilog.lbr)(options "")(descr "")) -) diff --git a/template/fp-lib-table.for-github b/template/fp-lib-table.for-github deleted file mode 100644 index 2716610fdc..0000000000 --- a/template/fp-lib-table.for-github +++ /dev/null @@ -1,90 +0,0 @@ -# Set GH environment variable to "https://github.com/CarlPoirier" -# before starting KiCad to use this fp table. - -(fp_lib_table - (lib (name 7Segment_16Sep2013)(type Github)(uri ${GH}/7Segment_16Sep2013)(options "")(descr "")) - (lib (name Allegro_HallCurrentSensor)(type Github)(uri ${GH}/Allegro_ACS754_ACS755_ACS756_HallCurrentSensor_RevA)(options "")(descr "")) - (lib (name BNC-Sockets_RevA)(type Github)(uri ${GH}/BNC-Sockets_RevA)(options "")(descr "")) - (lib (name Buzzer_Beeper_RevA_25Oct2010)(type Github)(uri ${GH}/Buzzer_Beeper_RevA_25Oct2010)(options "")(descr "")) - (lib (name capacitors)(type Github)(uri ${GH}/capacitors)(options "")(descr "")) - (lib (name Capacitors_SMD) (type Github)(uri ${GH}/Capacitors_SMD_RevA)(options "")(descr "")) - (lib (name Capacitors_ThroughHole) (type Github)(uri ${GH}/Capacitors_ThroughHole_RevA)(options "")(descr "")) - (lib (name Choke_Axial_ThroughHole) (type Github)(uri ${GH}/Choke_Axial_ThroughHole_RevB)(options "")(descr "")) - (lib (name Choke_Radial_ThroughHole) (type Github)(uri ${GH}/Choke_Radial_ThroughHole_CD_Bobin_RevA)(options "")(descr "")) - (lib (name Choke_SMD_RevB_28Dez2012) (type Github)(uri ${GH}/Choke_SMD_RevB_28Dez2012)(options "")(descr "")) - (lib (name Choke_Toroid_ThroughHole)(type Github)(uri ${GH}/Choke_Toroid_ThroughHole_RevC_06Aug2010)(options "")(descr "")) - (lib (name CommonModeChoke_Wuerth)(type Github)(uri ${GH}/CommonModeChoke_Wuerth_Type-WE-CMB_RevA_24Oct2010)(options "")(descr "")) - (lib (name connect)(type Github)(uri ${GH}/connect)(options "")(descr "")) - (lib (name connectors_molex_serial)(type Github)(uri ${GH}/connectors_molex_serial_53047-A123)(options "")(descr "")) - (lib (name Crystals)(type Github)(uri ${GH}/Crystals_RevB_20Apr2013)(options "")(descr "")) - (lib (name DCDC-ACDC-Converter)(type Github)(uri ${GH}/DCDC-ACDC-Converter_RevC_20Jul2012)(options "")(descr "")) - (lib (name Dioden_SMD)(type Github)(uri ${GH}/Dioden_SMD_RevA_31May2013)(options "")(descr "")) - (lib (name Dioden_ThroughHole)(type Github)(uri ${GH}/Dioden_ThroughHole_RevC)(options "")(descr "")) - (lib (name dip_sockets)(type Github)(uri ${GH}/dip_sockets)(options "")(descr "")) - (lib (name discret)(type Github)(uri ${GH}/discret)(options "")(descr "")) - (lib (name display)(type Github)(uri ${GH}/display)(options "")(descr "")) - (lib (name divers)(type Github)(uri ${GH}/divers)(options "")(descr "")) - (lib (name Elko_ThroughHole)(type Github)(uri ${GH}/Elko_ThroughHole_RevB-3_30Dec2011)(options "")(descr "")) - (lib (name EuroBoardoutline)(type Github)(uri ${GH}/EuroBoardoutline_RevC)(options "")(descr "")) - (lib (name Fiducials)(type Github)(uri ${GH}/Fiducials_RevC_04Aug2012)(options "")(descr "")) - (lib (name Footprint-Symbols)(type Github)(uri ${GH}/Footprint-Symbols_RevD_28Aug2012)(options "")(descr "")) - (lib (name FuseholderAndFuses)(type Github)(uri ${GH}/FuseholderAndFuses_RevD_28Aug2012)(options "")(descr "")) - (lib (name Heatsinks)(type Github)(uri ${GH}/Heatsinks_RevC)(options "")(descr "")) - (lib (name inductors)(type Github)(uri ${GH}/inductors)(options "")(descr "")) - (lib (name IR-directFET)(type Github)(uri ${GH}/IR-directFET_Packages_RevB)(options "")(descr "")) - (lib (name iut)(type Github)(uri ${GH}/iut)(options "")(descr "")) - (lib (name Label)(type Github)(uri ${GH}/Label_RevA_21Mar2011)(options "")(descr "")) - (lib (name led)(type Github)(uri ${GH}/led)(options "")(descr "")) - (lib (name libcms)(type Github)(uri ${GH}/libcms)(options "")(descr "")) - (lib (name Measurement_Point)(type Github)(uri ${GH}/Measurement_Point_RevA)(options "")(descr "")) - (lib (name Measurement-Scala)(type Github)(uri ${GH}/Measurement-Scala_RevA)(options "")(descr "")) - (lib (name Mechanical_Socket-Plug_DIN41612)(type Github)(uri ${GH}/Mechanical_Socket-Plug_DIN41612-Stuff_RevA)(options "")(descr "")) - (lib (name MiniUniversalMate-N-LokSockets)(type Github)(uri ${GH}/MiniUniversalMate-N-LokSockets_13Aug2012)(options "")(descr "")) - (lib (name MountingHole)(type Github)(uri ${GH}/MountingHole_RevA)(options "")(descr "")) - (lib (name muonde)(type Github)(uri ${GH}/muonde)(options "")(descr "")) - (lib (name Neosid_Air-Coil)(type Github)(uri ${GH}/Neosid_Air-Coil_SML_HAMxx31A_HDMxx31A_RevA_25Apr2012)(options "")(descr "")) - (lib (name Neosid_Filter_HF-Coil)(type Github)(uri ${GH}/Neosid_Filter_HF-Coil_25Apr2012)(options "")(descr "")) - (lib (name Neosid_Inductor)(type Github)(uri ${GH}/Neosid_Inductor_21Apr2012)(options "")(descr "")) - (lib (name NF-Transformer_ETAL)(type Github)(uri ${GH}/NF-Transformer_ETAL_RevA_28Aug2012)(options "")(descr "")) - (lib (name Oddities)(type Github)(uri ${GH}/Oddities_RevA_10Mar2011)(options "")(descr "")) - (lib (name OldSowjetAera_Transistor)(type Github)(uri ${GH}/OldSowjetAera_Transistor_RevA)(options "")(descr "")) - (lib (name Opto-Devices)(type Github)(uri ${GH}/Opto-Devices_RevC_03Oct2012)(options "")(descr "")) - (lib (name Oscillator)(type Github)(uri ${GH}/Oscillator-Modul_RevA)(options "")(descr "")) - (lib (name Pentawatt)(type Github)(uri ${GH}/Pentawatt_RevB_30Apr2011)(options "")(descr "")) - (lib (name pga_sockets)(type Github)(uri ${GH}/pga_sockets)(options "")(descr "")) - (lib (name pin_array)(type Github)(uri ${GH}/pin_array)(options "")(descr "")) - (lib (name Potentiometer)(type Github)(uri ${GH}/Potentiometer_RevB_02Aug2010)(options "")(descr "")) - (lib (name powerint)(type Github)(uri ${GH}/powerint)(options "")(descr "")) - (lib (name Printtrafo)(type Github)(uri ${GH}/Printtrafo_CHK_RevA_04Aug2010)(options "")(descr "")) - (lib (name Relay_ThroughHole)(type Github)(uri ${GH}/Relay_ThroughHole_RevB)(options "")(descr "")) - (lib (name Resistor_SMD)(type Github)(uri ${GH}/Resistor_SMD_RevA)(options "")(descr "")) - (lib (name Resistor_ThroughHole)(type Github)(uri ${GH}/Resistor_ThroughHole_RevB_22Apr2011)(options "")(descr "")) - (lib (name Resistor_Universal)(type Github)(uri ${GH}/Resistor_Universal-Experimental_RevA)(options "")(descr "")) - (lib (name SI570_SI571_Oscillator)(type Github)(uri ${GH}/SI570_SI571_Oscillator_RevA_11Jun2012)(options "")(descr "")) - (lib (name SIP9_Housing)(type Github)(uri ${GH}/SIP9_Housing_14Jun2013)(options "")(descr "")) - (lib (name smd_capacitors)(type Github)(uri ${GH}/smd_capacitors)(options "")(descr "")) - (lib (name smd_crystal_and_oscillator)(type Github)(uri ${GH}/smd_crystal_and_oscillator)(options "")(descr "")) - (lib (name smd_lqfp)(type Github)(uri ${GH}/smd_lqfp)(options "")(descr "")) - (lib (name smd_resistors)(type Github)(uri ${GH}/smd_resistors)(options "")(descr "")) - (lib (name smd_soic_packages)(type Github)(uri ${GH}/smd_soic_packages)(options "")(descr "")) - (lib (name smd_ssop_packages)(type Github)(uri ${GH}/smd_ssop_packages)(options "")(descr "")) - (lib (name smd_transistors)(type Github)(uri ${GH}/smd_transistors)(options "")(descr "")) - (lib (name Socket_MOLEX-KK-System)(type Github)(uri ${GH}/Socket_MOLEX-KK-System)(options "")(descr "")) - (lib (name sockets)(type Github)(uri ${GH}/sockets)(options "")(descr "")) - (lib (name Socket_WAGO734)(type Github)(uri ${GH}/Socket_WAGO734_RevA)(options "")(descr "")) - (lib (name SOT126_SOT32)(type Github)(uri ${GH}/SOT126_SOT32_Housings_RevA_22Oct2012)(options "")(descr "")) - (lib (name SOT23_SOT143_SOT143R_TSOT6_MK06A_SC70)(type Github)(uri ${GH}/SOT23_SOT143_SOT143R_TSOT6_MK06A_SC70-6_Housing_26Jul2012)(options "")(descr "")) - (lib (name SOT89-3_SOT89-5)(type Github)(uri ${GH}/SOT89-3_SOT89-5_Housing_RevA_02Sep2012)(options "")(descr "")) - (lib (name TantalCapacitors_SMD)(type Github)(uri ${GH}/TantalCapacitors_SMD_RevA_28Aug2012)(options "")(descr "")) - (lib (name TerminalBlock_WAGO236-RM5mm)(type Github)(uri ${GH}/TerminalBlock_WAGO236-RM5mm_RevA2)(options "")(descr "")) - (lib (name TO-50)(type Github)(uri ${GH}/TO-50_Housings_RevA_21Apr2013)(options "")(descr "")) - (lib (name TO-78)(type Github)(uri ${GH}/TO-78_Housing_RevA_04Jun2013)(options "")(descr "")) - (lib (name TO-92)(type Github)(uri ${GH}/TO-92_Housings_06Jun2013)(options "")(descr "")) - (lib (name TransformerSMPS_ThroughHole)(type Github)(uri ${GH}/TransformerSMPS_ThroughHole_RevA)(options "")(descr "")) - (lib (name Transistor_TO-220)(type Github)(uri ${GH}/Transistor_TO-220_RevB_03Sep2012)(options "")(descr "")) - (lib (name Transistor_TO-247)(type Github)(uri ${GH}/Transistor_TO-247_RevC)(options "")(descr "")) - (lib (name valves)(type Github)(uri ${GH}/valves)(options "")(descr "")) - (lib (name VML0806_Housing_Rohm)(type Github)(uri ${GH}/VML0806_Housing_Rohm_RevA_26Oct2012)(options "")(descr "")) - (lib (name WireConnections-Bridges)(type Github)(uri ${GH}/WireConnections-Bridges_RevA)(options "")(descr "")) - (lib (name WirePads)(type Github)(uri ${GH}/WirePads_RevA_15Jun2010)(options "")(descr "")) -) 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) +