From 91c3f3bc839a97889978dccd2075ca81d0d53c05 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 5 Jun 2013 14:03:16 +0200 Subject: [PATCH 01/50] All: use a S expression to describe the page layout (title block and grid references). Work in progress. This should allow users to define their own page layout. --- .bzrignore | 2 + Documentation/compiling/COMPILING.txt | 18 +- Documentation/compiling/build-config.txt | 14 + Documentation/compiling/build-msw.txt | 22 +- Documentation/compiling/mac-osx.txt | 7 +- Documentation/releases/2010-mar-14.html | 530 ------------------- Documentation/releases/2010-mar-14.txt | 40 -- common/CMakeLists.txt | 12 + common/hotkeys_basic.cpp | 1 + common/page_layout_default_description.cpp | 72 +++ common/page_layout_reader.cpp | 461 +++++++++++++++++ common/page_layout_reader.keywords | 35 ++ common/title_block_shapes.cpp | 570 ++++++++------------- common/title_block_shapes_gost.cpp | 13 +- common/worksheet.cpp | 68 ++- include/class_title_block.h | 121 +++-- include/vector2d.h | 2 +- include/worksheet.h | 15 +- include/worksheet_shape_builder.h | 203 +++++++- pcbnew/kicad_plugin.cpp | 40 +- 20 files changed, 1174 insertions(+), 1072 deletions(-) delete mode 100644 Documentation/releases/2010-mar-14.html delete mode 100644 Documentation/releases/2010-mar-14.txt create mode 100644 common/page_layout_default_description.cpp create mode 100644 common/page_layout_reader.cpp create mode 100644 common/page_layout_reader.keywords diff --git a/.bzrignore b/.bzrignore index da05a16fca..3e97e8ac23 100644 --- a/.bzrignore +++ b/.bzrignore @@ -3,9 +3,11 @@ downloads-by-cmake common/netlist_keywords.* common/netlist_lexer.h common/pcb_plot_params_lexer.h +common/page_layout_reader_keywords.cpp common/fp_lib_table_keywords.* include/fp_lib_table_lexer.h include/netlist_lexer.h +include/page_layout_reader_lexer.h eeschema/cmp_library_lexer.h eeschema/cmp_library_keywords.* eeschema/template_fieldnames_keywords.* diff --git a/Documentation/compiling/COMPILING.txt b/Documentation/compiling/COMPILING.txt index 9a4a9dd6d7..3b8501a24f 100644 --- a/Documentation/compiling/COMPILING.txt +++ b/Documentation/compiling/COMPILING.txt @@ -28,16 +28,22 @@ development libaries. After a fresh install you need the following packages to compile and run KiCad from source. -CMake - Cross-platform make -GLUT - The OpenGL Utility Library -wxGTK or wxWidgets - The wxWidgets GUI toolkit with GTK+ bindings +* bzr - Bazaar version control system +* CMake - Cross-platform make +* GLUT - The OpenGL Utility Library +* wxGTK or wxWidgets - The wxWidgets GUI toolkit with GTK+ bindings -Boost - Collection of portable C++ source libraries -Because boost is in the repository of kicad you don't need to install them. +* Boost - Collection of portable C++ source libraries +boost will be automagically downloaded and copied in kicad sources tree, +the first time you compile kicad. Useful, but not required: -Doxygen - Documentation system for several programming languages +* Doxygen - Documentation system for several programming languages +KiCad uses the Bazaar version control system to track source code changes, +and download the boost libraries needed by Kicad. +Be sure you bzr install also includes bzrtools. +boost libraries will be downloaded the first time you build Kicad. Compiler and basic development tools ------------- diff --git a/Documentation/compiling/build-config.txt b/Documentation/compiling/build-config.txt index 228f5cdb18..058106fcb6 100644 --- a/Documentation/compiling/build-config.txt +++ b/Documentation/compiling/build-config.txt @@ -1,3 +1,17 @@ +Bazaar +------ +KiCad uses the Bazaar version control system to track source code changes, +and download the boost libraries needed by Kicad. +The easiest way to get a copy of the KiCad source is to use Bazaar. +Bazaar can be download from http://wiki.bazaar.canonical.com. +Your best bet is to use the stand alone version of Bazaar +(which includes bzrtools, needed by Kicad) rather than one of +the Python specific versions. +Be sure bzrtools is also installed. +boost libraries will be downloaded the first time you build Kicad. + +CMake +----- KiCad uses CMake to generate the build files specific for the target platform specified by the developer. This document attempts to define some of the more common CMake and KiCad build configuration settings. You can use CMake either diff --git a/Documentation/compiling/build-msw.txt b/Documentation/compiling/build-msw.txt index 12726d569c..e5e37ff1b7 100644 --- a/Documentation/compiling/build-msw.txt +++ b/Documentation/compiling/build-msw.txt @@ -26,10 +26,12 @@ languages. Only C is installed by default and C++ is required to build KiCad. Bazaar ------ -KiCad uses the Bazaar version control system to track source code changes. +KiCad uses the Bazaar version control system to track source code changes, +and download the boost libraries needed by Kicad. The easiest way to get a copy of the KiCad source is to use Bazaar. Bazaar -can be download from http://http://wiki.bazaar.canonical.com/WindowsDownloads. -Your best bet is to use the stand alone version of Bazaar rather than one of +can be download from http://wiki.bazaar.canonical.com/WindowsDownloads. +Your best bet is to use the stand alone version of Bazaar +(which includes bzrtools, needed Kicad) rather than one of the Python specific versions. CMake @@ -87,7 +89,7 @@ MinGW linker. Build and Install the wxWidgets Library --------------------------------------- The wxWidgets library is the base that KiCad is built upon. Version 2.9.4 -or later of wxWidgets should be used on Windows. You may be able to build +or later of wxWidgets *should be* used on Windows. You may be able to build KiCad with older versions of wxWidgets but it is not recommended. wxWidgets can be downloaded from http://http://www.wxwidgets.org/downloads/ @@ -107,16 +109,10 @@ install the wxWidgets library into MinGW then enter the following commands: If you want to install wxWidgets in MinGW then enter the following commands: #mkdir Release #cd Release -#../configure --prefix=/mingw --with-opengl +#../configure --prefix=/mingw --enable-monolithic=no --disable-shared --with-opengl #make && make install -#move /mingw/lib/wxmsw*.dll /mingw/bin -The last command is critical so that the libraries are in the MinGW PATH -and can be found at run time. If you want to build a full debugging version -of wxWidgets, add --enable-debug to the configure command. If you are going -to use the GNU debugger, you may also want to build the debugging libraries -with the extra GDB debugging information by adding --enable-debug_gdb to the -configure command. +wxWidgets will be statically linked to Kicad, which avoid issus with wxWidgets dlls Download the KiCad Source Code ------------------------------ @@ -229,5 +225,5 @@ To build the HTML developer documentation, run the following commands: #cd /build/debug #make doxygen-docs -The documentation will be created in the /Documenation/html +The documentation will be created in the /Documentation/html directory. diff --git a/Documentation/compiling/mac-osx.txt b/Documentation/compiling/mac-osx.txt index 1663cf2b6f..c94d1e6666 100644 --- a/Documentation/compiling/mac-osx.txt +++ b/Documentation/compiling/mac-osx.txt @@ -9,6 +9,7 @@ Snow Leopard Requirements * XCode Tools (http://developer.apple.com/tools/xcode) + * bzr (bazaar) * CMake (http://www.cmake.org) * wxWidgets 2.9 (http://www.wxwidgets.org/downloads) * Doxygen (http://www.doxygen.nl) @@ -19,7 +20,7 @@ Building wxWidgets 2.9 Universal ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To check if your tools and libraries are installed check with file for architectures. -user@macosx$ file /Developer/SDKs/MacOSX10.5.sdk/usr/lib/libSystem.dylib +user@macosx$ file /Developer/SDKs/MacOSX10.5.sdk/usr/lib/libSystem.dylib /Developer/SDKs/MacOSX10.5.sdk/usr/lib/libSystem.dylib: Mach-O universal binary with 4 architectures /Developer/SDKs/MacOSX10.5.sdk/usr/lib/libSystem.dylib (for architecture ppc7400): Mach-O dynamically linked shared library stub ppc @@ -37,7 +38,7 @@ At time of writing (2009-01-16) this is on line 18381 into this: OSX_UNIV_OPTS="-arch ppc -arch i386 -arch x86_64" Building a universal monolib wxWidgets 2.9 with the following parameters: -./configure --enable-unicode=yes --enable-shared=no --enable-monolithic --with-opengl --with-expat=builtin --enable-universal_binary --enable-aui --enable-debug --with-osx_cocoa --with-macosx-sdk=/Developer/SDKs/MacOSX10.5.sdk/ --prefix=/opt/wxwidgets/ +./configure --enable-unicode=yes --enable-shared=no --enable-monolithic --with-opengl --with-expat=builtin --enable-universal_binary --enable-aui --enable-debug --with-osx_cocoa --with-macosx-sdk=/Developer/SDKs/MacOSX10.5.sdk/ --prefix=/opt/wxwidgets/ Should be subsituded with the revision from SVN @@ -91,7 +92,7 @@ It depends on which CMake version you use: //This fixes also BOOST macro errors CMAKE_CXX_FLAGS:STRING=-D__ASSERTMACROS__ -//Build architectures for OSX +//Build architectures for OSX CMAKE_OSX_ARCHITECTURES:STRING=x86_64 -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.5.sdk/ -mmacosx-version-min=10.5 //The product will be built against the headers and libraries located diff --git a/Documentation/releases/2010-mar-14.html b/Documentation/releases/2010-mar-14.html deleted file mode 100644 index 1e3b810b32..0000000000 --- a/Documentation/releases/2010-mar-14.html +++ /dev/null @@ -1,530 +0,0 @@ - - - - - -KiCad 2010-xx-xx Release - - - - -

Common

-
-
    -
  • -

    -Actions can now be undo and redo -

    -
  • -
  • -

    -Menus and tooltips more clear -

    -
  • -
  • -

    -File history now in Open Recent submenu -

    -
  • -
  • -

    -Many new hotkeys added -

    -
  • -
  • -

    -Plot and print dialog rewritten -

    -
  • -
  • -

    -Remember last dialog position and tab -

    -
  • -
  • -

    -Better font shapes -

    -
  • -
  • -

    -Generation of bill of materials -

    -
  • -
  • -

    -Plot SVG output -

    -
  • -
-
-

KiCad

-
-
    -
  • -

    -Issue fixed when opening a project in a directory with a lot of subdirectories -

    -
  • -
  • -

    -If project is noname.pro no error will be displayed -

    -
  • -
-
-

EESchema

-
-
    -
  • -

    -New pin properties dialog -

    -
  • -
-
-

PCBNew

-
-
    -
  • -

    -Advanced layer setup -

    -
  • -
  • -

    -New panel for layer management -

    -
  • -
  • -

    -Support for net classes -

    -
  • -
  • -

    -Incorrect DRC error fixed, DRC min via and min track check -

    -
  • -
  • -

    -Handle local mask clearance and local net clearance -

    -
  • -
  • -

    -Handle zones in connectivity calculations -

    -
  • -
-
-

Core

-
-
    -
  • -

    -Many many bugfixes and cleanups -

    -
  • -
  • -

    -All comments translated to English -

    -
  • -
  • -

    -Moved to wxAUI and dialogs created with wxFormBuilder -

    -
  • -
  • -

    -Full support for Mac OS X with wxWidgets 2.9 -

    -
  • -
-
- - - diff --git a/Documentation/releases/2010-mar-14.txt b/Documentation/releases/2010-mar-14.txt deleted file mode 100644 index f3763b50ba..0000000000 --- a/Documentation/releases/2010-mar-14.txt +++ /dev/null @@ -1,40 +0,0 @@ -KiCad 2010-xx-xx Release -======================== - -== Common - * Actions can now be undo and redo - * Menus and tooltips more clear - * File history now in Open Recent submenu - * Many new hotkeys added - * Plot and print dialog rewritten - * Remember last dialog position and tab - * Better font shapes - * Generation of bill of materials - * Plot SVG output - -== KiCad - * Issue fixed when opening a project in a directory with a lot of subdirectories. - * If project is noname.pro no `error` will be displayed - -== EESchema - * New pin properties dialog - -== PCBNew - * Plot DXF output - * Advanced layer setup - * New panel for layer management - * Support for net classes - * Incorrect DRC error fixed, DRC min via and min track check - * Handle local mask clearance and local net clearance - * Handle zones in connectivity calculations - -== Core - * Many many bugfixes and cleanups - * All comments translated to English - * Moved to wxAUI and dialogs created with wxFormBuilder - * Full support for Mac OS X with wxWidgets 2.9 - -/////////////////////////////////////// -This is a asciidoc formatted file, it can be converted -to PDF,(XHTML) and others. See asciidoc homepage. -/////////////////////////////////////// diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 1e5a24dcdf..f834c2a66f 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -76,6 +76,9 @@ set(COMMON_SRCS msgpanel.cpp netlist_keywords.cpp newstroke_font.cpp + page_layout_default_description.cpp + page_layout_reader_keywords.cpp + page_layout_reader.cpp projet_config.cpp ptree.cpp reporter.cpp @@ -191,6 +194,15 @@ make_lexer( FP_LIB_TABLE_T ) +# auto-generate page layout reader s-expression page_layout_reader_lexer.h +# and title_block_reader_keywords.cpp. +make_lexer( + ${CMAKE_CURRENT_SOURCE_DIR}/page_layout_reader.keywords + ${PROJECT_SOURCE_DIR}/include/page_layout_reader_lexer.h + ${CMAKE_CURRENT_SOURCE_DIR}/page_layout_reader_keywords.cpp + TB_READER_T + ) + # The dsntest may not build properly using MS Visual Studio. if(NOT MSVC) # This one gets made only when testing. diff --git a/common/hotkeys_basic.cpp b/common/hotkeys_basic.cpp index dc5c9ffba8..025168e920 100644 --- a/common/hotkeys_basic.cpp +++ b/common/hotkeys_basic.cpp @@ -519,6 +519,7 @@ int EDA_BASE_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, if( file ) { fputs( TO_UTF8( msg ), file ); + fclose( file ); } else { diff --git a/common/page_layout_default_description.cpp b/common/page_layout_default_description.cpp new file mode 100644 index 0000000000..04e94a84f9 --- /dev/null +++ b/common/page_layout_default_description.cpp @@ -0,0 +1,72 @@ +/** + * @file page_layout_default_description.cpp + */ + +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 1992-2013 Jean-Pierre Charras . + * Copyright (C) 1992-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 + */ + +#include + +// height of the band reference grid 2.0 mm +// worksheet frame reference text size 1.3 mm +// default text size 1.5 mm +// default line width 0.15 mm +// frame ref pitch 50 mm + +extern const wxString defaultPageLayout; + +// Default page layout (sizes are in mm) +const wxString defaultPageLayout( wxT( "( page_layout\n" +"(setup (textsize 1.5 1.5) (linewidth 0.15) (textlinewidth 0.15) )" +"(rect (comment rect around the title block) (linewidth 0.15) (start 110 34) (end 2 2) )\n" +"(rect (start 0 0 ltcorner) (end 0 0 rbcorner) (repeat 2) (incrx 2) (incry 2) )\n" +"(line (start 50 2 ltcorner) (end 50 0 ltcorner) (repeat 30) (incrx 50) )\n" +"(tbtext \"1\" (pos 25 1 ltcorner) (font (size 1.3 1.3))(repeat 100) (incrx 50) )\n" +"(line (start 50 2 lbcorner) (end 50 0 lbcorner) (repeat 30) (incrx 50) )\n" +"(tbtext \"1\" (pos 25 1 lbcorner) (font (size 1.3 1.3)) (repeat 100) (incrx 50) )\n" +"(line (start 0 50 ltcorner) (end 2 50 ltcorner) (repeat 30) (incry 50) )\n" +"(tbtext \"A\" (pos 1 25 ltcorner) (font (size 1.3 1.3)) (justify center)(repeat 100) (incry 50) )\n" +"(line (start 0 50 rtcorner) (end 2 50 rtcorner) (repeat 30) (incry 50) )\n" +"(tbtext \"A\" (pos 1 25 rtcorner) (font (size 1.3 1.3)) (justify center) (repeat 100) (incry 50) )\n" +"(tbtext \"Date: %D\" (pos 87 6.9) )\n" +"(line (start 110 5.5) end 2 5.5) )\n" +"(tbtext \"%K\" (pos 108 4.1) (comment Kicad version ) )\n" +"(line (start 110 8.5) end 2 8.5) )\n" +"(tbtext \"Rev: %R\" (pos 24 6.9)(font bold italic)(justify left) )\n" +"(tbtext \"Size: %Z\" (comment Paper format name)(pos 105 6.9) )\n" +"(tbtext \"Id: %S/%N\" (comment Sheet id)(pos 24 4.1) )\n" +"(line (start 110 12.5) end 2 12.5) )\n" +"(tbtext \"Title: %T\" (pos 108 10.7)(font bold (size 2 2)) )\n" +"(tbtext \"File: %F\" (pos 108 14.3) )\n" +"(line (start 110 18.5) end 2 18.5) )\n" +"(tbtext \"Sheet: %P\" (pos 108 17) )\n" +"(tbtext \"%Y\" (comment Company name) (pos 108 20)(font bold) )\n" +"(tbtext \"%C0\" (comment Comment 0) (pos 108 23) )\n" +"(tbtext \"%C1\" (comment Comment 0) (pos 108 26) )\n" +"(tbtext \"%C2\" (comment Comment 0) (pos 108 29) )\n" +"(tbtext \"%C3\" (comment Comment 0) (pos 108 32) )\n" +"(line (start 90 8.5) end 90 5.5) )\n" +"(line (start 26 8.5) end 26 2) )\n" +")\n") ); diff --git a/common/page_layout_reader.cpp b/common/page_layout_reader.cpp new file mode 100644 index 0000000000..140d9e8df1 --- /dev/null +++ b/common/page_layout_reader.cpp @@ -0,0 +1,461 @@ +/** + * @file page_layout_reader.cpp + * @brief read an S expression of description of graphic items and texts + * to build a title block and page layout + */ + +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 1992-2013 Jean-Pierre Charras . + * Copyright (C) 1992-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 + */ + +#include +#include +#include +#include +#include +#include + +// defaultPageLayout is the default page layout description +// using the S expr. +// see page_layout_default_shape.cpp +extern const wxString defaultPageLayout; + +using namespace TB_READER_T; + +/** + * Class PAGE_LAYOUT_READER_PARSER + * holds data and functions pertinent to parsing a S-expression file + * for a WORKSHEET_LAYOUT. + */ +class PAGE_LAYOUT_READER_PARSER : public PAGE_LAYOUT_READER_LEXER +{ + DSIZE m_defaultTextSize; // Default text size, when not defined inside a tbtext + double m_defaultLineWidth; + double m_defaulTextLineWidth; + +public: + PAGE_LAYOUT_READER_PARSER( const char* aLine, const wxString& aSource ); + void Parse( WORKSHEET_LAYOUT* aLayout ) + throw( PARSE_ERROR, IO_ERROR ); + +private: + + /** + * Function parseInt + * parses an integer and constrains it between two values. + * @param aMin is the smallest return value. + * @param aMax is the largest return value. + * @return int - the parsed integer. + */ + int parseInt( int aMin, int aMax ); + + /** + * Function parseDouble + * parses a double + * @return double - the parsed double. + */ + double parseDouble(); + + void parseSetup() throw( IO_ERROR, PARSE_ERROR ); + void parseGraphic( WORKSHEET_DATAITEM * aItem ) throw( IO_ERROR, PARSE_ERROR ); + void parseText( WORKSHEET_DATAITEM_TEXT * aItem ) throw( IO_ERROR, PARSE_ERROR ); + void parseCoordinate( POINT_COORD& aCoord) throw( IO_ERROR, PARSE_ERROR ); +}; + +// PCB_PLOT_PARAMS_PARSER + +PAGE_LAYOUT_READER_PARSER::PAGE_LAYOUT_READER_PARSER( const char* aLine, const wxString& aSource ) : + PAGE_LAYOUT_READER_LEXER( aLine, aSource ) +{ + m_defaultTextSize.x = m_defaultTextSize.y = TB_DEFAULT_TEXTSIZE; + m_defaultLineWidth = 0.0; + m_defaulTextLineWidth = 0.0; +} + + +void PAGE_LAYOUT_READER_PARSER::Parse( WORKSHEET_LAYOUT* aLayout ) + throw( PARSE_ERROR, IO_ERROR ) +{ + T token; + WORKSHEET_DATAITEM * item; + + LOCALE_IO toggle; + + while( ( token = NextTok() ) != T_RIGHT ) + { + if( token == T_EOF) + break; + + if( token == T_LEFT ) + token = NextTok(); + + if( token == T_page_layout ) + continue; + + switch( token ) + { + case T_setup: // Defines default values for graphic items + parseSetup(); + break; + + case T_line: + item = new WORKSHEET_DATAITEM( WORKSHEET_DATAITEM::WS_SEGMENT ); + parseGraphic( item ); + aLayout->Append( item ); + break; + + case T_rect: + item = new WORKSHEET_DATAITEM( WORKSHEET_DATAITEM::WS_RECT ); + parseGraphic( item ); + aLayout->Append( item ); + break; + + case T_tbtext: + NeedSYMBOLorNUMBER(); + item = new WORKSHEET_DATAITEM_TEXT( FromUTF8() ); + parseText( (WORKSHEET_DATAITEM_TEXT*) item ); + aLayout->Append( item ); + break; + + default: + Unexpected( CurText() ); + break; + } + } +} + +void PAGE_LAYOUT_READER_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR ) +{ + T token; + while( ( token = NextTok() ) != T_RIGHT ) + { + if( token == T_EOF) + break; + + switch( token ) + { + case T_LEFT: + break; + + case T_linewidth: + m_defaultLineWidth = parseDouble(); + NeedRIGHT(); + break; + + case T_textsize: + m_defaultTextSize.x = parseDouble(); + m_defaultTextSize.y = parseDouble(); + NeedRIGHT(); + break; + + case T_textlinewidth: + m_defaulTextLineWidth = parseDouble(); + NeedRIGHT(); + break; + + default: + Unexpected( CurText() ); + break; + } + } +} + +void PAGE_LAYOUT_READER_PARSER::parseGraphic( WORKSHEET_DATAITEM * aItem ) + throw( IO_ERROR, PARSE_ERROR ) +{ + T token; + + aItem->m_LineWidth = m_defaultLineWidth; + + while( ( token = NextTok() ) != T_RIGHT ) + { + if( token == T_EOF) + break; + + if( token == T_LEFT ) + token = NextTok(); + + switch( token ) + { + case T_comment: // Comment, search the closing ')' + while( ( token = NextTok() ) != T_RIGHT && token != T_EOF ); + break; + + case T_start: + parseCoordinate( aItem->m_Pos ); + break; + + case T_end: + parseCoordinate( aItem->m_End ); + break; + + case T_repeat: + aItem->m_RepeatCount = parseInt( -1, 100 ); + NeedRIGHT(); + break; + + case T_incrx: + aItem->m_IncrementVector.x = parseDouble(); + NeedRIGHT(); + break; + + case T_incry: + aItem->m_IncrementVector.y = parseDouble(); + NeedRIGHT(); + break; + + case T_linewidth: + aItem->m_LineWidth = parseDouble(); + NeedRIGHT(); + break; + + default: + Unexpected( CurText() ); + break; + } + } +} + + +void PAGE_LAYOUT_READER_PARSER::parseText( WORKSHEET_DATAITEM_TEXT* aItem ) + throw( IO_ERROR, PARSE_ERROR ) +{ + T token; + + aItem->m_TextSize = m_defaultTextSize; + aItem->m_LineWidth = m_defaulTextLineWidth; + + while( ( token = NextTok() ) != T_RIGHT ) + { + if( token == T_EOF) + break; + + if( token == T_LEFT ) + token = NextTok(); + + switch( token ) + { + case T_comment: // Comment, search the closing ')' + while( ( token = NextTok() ) != T_RIGHT && token != T_EOF ); + break; + + case T_pos: + parseCoordinate( aItem->m_Pos ); + break; + + case T_repeat: + aItem->m_RepeatCount = parseInt( -1, 100 ); + NeedRIGHT(); + break; + + case T_incrx: + aItem->m_IncrementVector.x = parseDouble(); + NeedRIGHT(); + break; + + case T_incry: + aItem->m_IncrementVector.y = parseDouble(); + NeedRIGHT(); + break; + + case T_incrlabel: + aItem->m_IncrementLabel = parseInt(INT_MIN, INT_MAX); + NeedRIGHT(); + break; + + case T_maxlen: + aItem->m_BoundingBoxSize.x = parseDouble(); + NeedRIGHT(); + break; + + case T_maxheight: + aItem->m_BoundingBoxSize.y = parseDouble(); + NeedRIGHT(); + break; + + case T_font: + while( ( token = NextTok() ) != T_RIGHT ) + { + if( token == T_EOF) + break; + + switch( token ) + { + case T_LEFT: + break; + + case T_bold: + aItem->m_Flags |= USE_BOLD; + break; + + case T_italic: + aItem->m_Flags |= USE_ITALIC; + break; + + case T_size: + aItem->m_TextSize.x = parseDouble(); + aItem->m_TextSize.y = parseDouble(); + NeedRIGHT(); + break; + + case T_linewidth: + aItem->m_LineWidth = parseDouble(); + NeedRIGHT(); + break; + + default: + Unexpected( CurText() ); + break; + } + } + break; + + case T_justify: + while( ( token = NextTok() ) != T_RIGHT ) + { + if( token == T_EOF) + break; + + switch( token ) + { + case T_center: + aItem->m_Hjustify = GR_TEXT_HJUSTIFY_CENTER; + aItem->m_Vjustify = GR_TEXT_VJUSTIFY_CENTER; + break; + + case T_left: + aItem->m_Hjustify = GR_TEXT_HJUSTIFY_LEFT; + break; + + case T_right: + aItem->m_Hjustify = GR_TEXT_HJUSTIFY_RIGHT; + break; + + case T_top: + aItem->m_Vjustify = GR_TEXT_VJUSTIFY_TOP; + break; + + case T_bottom: + aItem->m_Vjustify = GR_TEXT_VJUSTIFY_BOTTOM; + break; + + default: + Unexpected( CurText() ); + break; + } + } + break; + + case T_rotate: + aItem->m_Orient = parseDouble(); + NeedRIGHT(); + break; + + default: + Unexpected( CurText() ); + break; + } + } +} + +// parse an expression like " 25 1 ltcorner)" +void PAGE_LAYOUT_READER_PARSER::parseCoordinate( POINT_COORD& aCoord) + throw( IO_ERROR, PARSE_ERROR ) +{ + T token; + + aCoord.m_Pos.x = parseDouble(); + aCoord.m_Pos.y = parseDouble(); + + while( ( token = NextTok() ) != T_RIGHT ) + { + switch( token ) + { + case T_ltcorner: + aCoord.m_Anchor = LT_CORNER; // left top corner + break; + + case T_lbcorner: + aCoord.m_Anchor = LB_CORNER; // left bottom corner + break; + + case T_rbcorner: + aCoord.m_Anchor = RB_CORNER; // right bottom corner + break; + + case T_rtcorner: + aCoord.m_Anchor = RT_CORNER; // right top corner + break; + + default: + Unexpected( CurText() ); + break; + } + } +} + +int PAGE_LAYOUT_READER_PARSER::parseInt( int aMin, int aMax ) +{ + T token = NextTok(); + + if( token != T_NUMBER ) + Expecting( T_NUMBER ); + + int val = atoi( CurText() ); + + if( val < aMin ) + val = aMin; + else if( val > aMax ) + val = aMax; + + return val; +} + + +double PAGE_LAYOUT_READER_PARSER::parseDouble() +{ + T token = NextTok(); + + if( token != T_NUMBER ) + Expecting( T_NUMBER ); + + double val = strtod( CurText(), NULL ); + + return val; +} + + +void WORKSHEET_LAYOUT::SetDefaultLayout() +{ + PAGE_LAYOUT_READER_PARSER lp_parser( defaultPageLayout, "default page" ); + + try + { + lp_parser.Parse( this ); + } + catch( IO_ERROR ioe ) + { + wxLogMessage( ioe.errorText ); + } +} diff --git a/common/page_layout_reader.keywords b/common/page_layout_reader.keywords new file mode 100644 index 0000000000..83e312dfb9 --- /dev/null +++ b/common/page_layout_reader.keywords @@ -0,0 +1,35 @@ +page_layout +setup +linewidth +textlinewidth +textsize +comment +line +rect +polygon +tbtext +ltcorner +lbcorner +rbcorner +rtcorner +name +pos +start +end +maxlen +maxheight +font +bold +italic +size +justify +left +center +right +top +bottom +rotate +repeat +incrx +incry +incrlabel diff --git a/common/title_block_shapes.cpp b/common/title_block_shapes.cpp index b00f95c49a..f9419894b9 100644 --- a/common/title_block_shapes.cpp +++ b/common/title_block_shapes.cpp @@ -1,5 +1,5 @@ /** - * @file title_block_shapes.cpp + * @file title_block_shape.cpp * @brief description of graphic items and texts to build a title block */ @@ -39,265 +39,157 @@ #include #include -#define GRID_REF_W Mm2mils( 1.8 ) // height of the band reference grid -#define TEXTSIZE Mm2mils( 1.5 ) // worksheet text size -#define FRMREF_TXTSIZE Mm2mils( 1.3 ) // worksheet frame reference text size -#define VARIABLE_BLOCK_START_POSITION (TEXTSIZE * 10) - -// The coordinates below are relative to the bottom right corner of page and -// will be subtracted from this origin. -#define BLOCK_OX Mm2mils( 106 ) -#define BLOCK_KICAD_VERSION_X BLOCK_OX - TEXTSIZE -#define BLOCK_KICAD_VERSION_Y TEXTSIZE -#define BLOCK_REV_X Mm2mils( 22 ) -#define BLOCK_REV_Y (TEXTSIZE * 3) -#define BLOCK_DATE_X BLOCK_OX - (TEXTSIZE * 15) -#define BLOCK_DATE_Y (TEXTSIZE * 3) -#define BLOCK_ID_SHEET_X Mm2mils( 22 ) -#define BLOCK_ID_SHEET_Y TEXTSIZE -#define BLOCK_SIZE_SHEET_X BLOCK_OX - TEXTSIZE -#define BLOCK_SIZE_SHEET_Y (TEXTSIZE * 3) -#define BLOCK_TITLE_X BLOCK_OX - TEXTSIZE -#define BLOCK_TITLE_Y (TEXTSIZE * 5) -#define BLOCK_FULLSHEETNAME_X BLOCK_OX - TEXTSIZE -#define BLOCK_FULLSHEETNAME_Y (TEXTSIZE * 7) -#define BLOCK_FILENAME_X BLOCK_OX - TEXTSIZE -#define BLOCK_FILENAME_Y (TEXTSIZE * 9) -#define BLOCK_COMMENT_X BLOCK_OX - TEXTSIZE -#define BLOCK_COMPANY_Y (TEXTSIZE * 11) -#define BLOCK_COMMENT1_Y (TEXTSIZE * 13) -#define BLOCK_COMMENT2_Y (TEXTSIZE * 15) -#define BLOCK_COMMENT3_Y (TEXTSIZE * 17) -#define BLOCK_COMMENT4_Y (TEXTSIZE * 19) +extern void SetDataList( WORKSHEET_LAYOUT& aDataList ); -// Text attributes set in m_Flags (ORed bits) - #define USE_BOLD 1 // has meaning for texts - #define USE_THICK_LINE 1 // equivalent to bold for lines - #define USE_ITALIC 2 // has meaning for texts - #define USE_TEXT_COLOR 4 - #define SET_UPPER_LIMIT 8 // Flag used to calculate variable position items - -// Work sheet structure type definitions. -enum TypeKi_WorkSheetData { - WS_TEXT, - WS_SEGMENT, - WS_UPPER_SEGMENT, - WS_LEFT_SEGMENT -}; - - -// superior horizontal segment: should be after comments -// to know the exact position -Ki_WorkSheetData WS_MostUpperLine = +WORKSHEET_DATAITEM_TEXT::WORKSHEET_DATAITEM_TEXT( const wxChar* aTextBase ) : + WORKSHEET_DATAITEM( WS_TEXT ) { - WS_UPPER_SEGMENT, - NULL, - BLOCK_OX, TEXTSIZE * 16, - 0, TEXTSIZE * 16, - NULL -}; + m_TextBase = aTextBase; + m_IncrementLabel = 1; + m_Hjustify = GR_TEXT_HJUSTIFY_LEFT; + m_Vjustify = GR_TEXT_VJUSTIFY_CENTER; + m_Orient = 0.0; + m_TextSize.x = m_TextSize.y = TB_DEFAULT_TEXTSIZE; +} -// Left vertical segment: should be after comments -// to know the exact position -Ki_WorkSheetData WS_MostLeftLine = +void WORKSHEET_DATAITEM_TEXT::TransfertSetupToGraphicText( WS_DRAW_ITEM_TEXT* aGText ) { - WS_LEFT_SEGMENT, - &WS_MostUpperLine, - BLOCK_OX, TEXTSIZE * 16, - BLOCK_OX, 0, - NULL -}; + aGText->SetHorizJustify( m_Hjustify ) ; + aGText->SetVertJustify( m_Vjustify ); + aGText->SetOrientation( m_Orient * 10 ); // graphic text orient unit = 0.1 degree +} -// horizontal segment between filename and comments -Ki_WorkSheetData WS_SeparatorLine = +void WORKSHEET_DATAITEM_TEXT::IncrementLabel( int aIncr ) { - WS_SEGMENT, - &WS_MostLeftLine, - BLOCK_OX, VARIABLE_BLOCK_START_POSITION, - 0, VARIABLE_BLOCK_START_POSITION, - NULL -}; + wxChar lbchar = m_TextBase[0]; + if( lbchar >= '0' && lbchar <= '9' ) + // A number is expected: + m_FullText.Printf( wxT("%d"), aIncr + lbchar - '0' ); + else + m_FullText.Printf( wxT("%c"), aIncr + lbchar ); +} -Ki_WorkSheetData WS_Date = +void WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize() { - WS_TEXT, - &WS_SeparatorLine, - BLOCK_DATE_X, BLOCK_DATE_Y, - 0, 0, - wxT( "Date: %D" ) -}; + m_ConstrainedTextSize = m_TextSize; -Ki_WorkSheetData WS_Licence = + if( m_BoundingBoxSize.x ) + { + bool italic = (m_Flags & USE_ITALIC) != 0; + int linewidth = 0; + int lenMsg = ReturnGraphicTextWidth( m_FullText, m_TextSize.x, italic, linewidth ); + if( lenMsg > m_BoundingBoxSize.x ) + m_ConstrainedTextSize.x = m_TextSize.x * m_BoundingBoxSize.x / lenMsg; + } + + if( m_BoundingBoxSize.y ) + { + if( m_ConstrainedTextSize.y > m_BoundingBoxSize.y ) + m_ConstrainedTextSize.y = m_BoundingBoxSize.y; + } +} + +const DPOINT WORKSHEET_DATAITEM::GetStartPos( int ii ) const { - WS_TEXT, - &WS_Date, - BLOCK_KICAD_VERSION_X,BLOCK_KICAD_VERSION_Y, - 0, - 0, - wxT("%K") // Kicad version -}; + DPOINT pos; + pos.x = m_Pos.m_Pos.x + ( m_IncrementVector.x * ii ); + pos.y = m_Pos.m_Pos.y + ( m_IncrementVector.y * ii ); -Ki_WorkSheetData WS_Revision = + switch( m_Pos.m_Anchor ) + { + case RB_CORNER: // right bottom corner + pos = m_RB_Corner - pos; + break; + + case RT_CORNER: // right top corner + pos.x = m_RB_Corner.x - pos.x; + pos.y = m_LT_Corner.y + pos.y; + break; + + case LB_CORNER: // left bottom corner + pos.x = m_LT_Corner.x + pos.x; + pos.y = m_RB_Corner.y - pos.y; + break; + + case LT_CORNER: // left top corner + pos = m_LT_Corner + pos; + break; + } + + return pos; +} + +const wxPoint WORKSHEET_DATAITEM::GetStartPosUi( int ii ) const { - WS_TEXT, - &WS_Licence, - BLOCK_REV_X, BLOCK_REV_Y, - 0, 0, - wxT( "Rev: %R" ), - USE_BOLD -}; + DPOINT pos = GetStartPos( ii ); + pos = pos * m_WSunits2Iu; + return wxPoint( int(pos.x), int(pos.y) ); +} -Ki_WorkSheetData WS_SizeSheet = +const DPOINT WORKSHEET_DATAITEM::GetEndPos( int ii ) const { - WS_TEXT, - &WS_Revision, - BLOCK_SIZE_SHEET_X,BLOCK_SIZE_SHEET_Y, - 0, 0, - wxT( "Size: %Z" ) // Paper format name -}; + DPOINT pos; + pos.x = m_End.m_Pos.x + ( m_IncrementVector.x * ii ); + pos.y = m_End.m_Pos.y + ( m_IncrementVector.y * ii ); + switch( m_End.m_Anchor ) + { + case RB_CORNER: // right bottom corner + pos = m_RB_Corner - pos; + break; -Ki_WorkSheetData WS_IdentSheet = + case RT_CORNER: // right top corner + pos.x = m_RB_Corner.x - pos.x; + pos.y = m_LT_Corner.y + pos.y; + break; + + case LB_CORNER: // left bottom corner + pos.x = m_LT_Corner.x + pos.x; + pos.y = m_RB_Corner.y - pos.y; + break; + + case LT_CORNER: // left top corner + pos = m_LT_Corner + pos; + break; + } + + return pos; +} + +const wxPoint WORKSHEET_DATAITEM::GetEndPosUi( int ii ) const { - WS_TEXT, - &WS_SizeSheet, - BLOCK_ID_SHEET_X,BLOCK_ID_SHEET_Y, - 0, 0, - wxT( "Id: %S/%N" ) -}; + DPOINT pos = GetEndPos( ii ); + pos = pos * m_WSunits2Iu; + return wxPoint( int(pos.x), int(pos.y) ); +} -Ki_WorkSheetData WS_Title = + +bool WORKSHEET_DATAITEM::IsInsidePage( int ii ) const { - WS_TEXT, - &WS_IdentSheet, - BLOCK_TITLE_X, BLOCK_TITLE_Y, - 0, 0, - wxT( "Title: %T" ), - USE_BOLD -}; + DPOINT pos = GetStartPos( ii ); -Ki_WorkSheetData WS_SheetFilename = -{ - WS_TEXT, - &WS_Title, - BLOCK_FILENAME_X, BLOCK_FILENAME_Y, - 0, 0, - wxT( "File: %F" ) -}; + if( m_RB_Corner.x < pos.x || m_LT_Corner.x > pos.x ) + return false; -Ki_WorkSheetData WS_FullSheetName = -{ - WS_TEXT, - &WS_SheetFilename, - BLOCK_FULLSHEETNAME_X,BLOCK_FULLSHEETNAME_Y, - 0, - 0, - wxT( "Sheet: %P" ) // Full sheet name (sheet path) -}; + if( m_RB_Corner.y < pos.y || m_LT_Corner.y > pos.y ) + return false; -Ki_WorkSheetData WS_Company = -{ - WS_TEXT, - &WS_FullSheetName, - BLOCK_COMMENT_X,BLOCK_COMPANY_Y, - 0, 0, - wxT("%Y"), // Company name - USE_BOLD | SET_UPPER_LIMIT | USE_TEXT_COLOR -}; + pos = GetEndPos( ii ); -Ki_WorkSheetData WS_Comment1 = -{ - WS_TEXT, - &WS_Company, - BLOCK_COMMENT_X,BLOCK_COMMENT1_Y, - 0, 0, - wxT("%C1"), // Comment 1 - SET_UPPER_LIMIT | USE_TEXT_COLOR -}; + if( m_RB_Corner.x < pos.x || m_LT_Corner.x > pos.x ) + return false; -Ki_WorkSheetData WS_Comment2 = -{ - WS_TEXT, - &WS_Comment1, - BLOCK_COMMENT_X,BLOCK_COMMENT2_Y, - 0, 0, - wxT("%C2"), // Comment 2 - SET_UPPER_LIMIT | USE_TEXT_COLOR -}; + if( m_RB_Corner.y < pos.y || m_LT_Corner.y > pos.y ) + return false; -Ki_WorkSheetData WS_Comment3 = -{ - WS_TEXT, - &WS_Comment2, - BLOCK_COMMENT_X,BLOCK_COMMENT3_Y, - 0, 0, - wxT("%C3"), // Comment 3 - SET_UPPER_LIMIT | USE_TEXT_COLOR -}; + return true; +} -Ki_WorkSheetData WS_Comment4 = -{ - WS_TEXT, - &WS_Comment3, - BLOCK_COMMENT_X, BLOCK_COMMENT4_Y, - 0, 0, - wxT("%C4"), // Comment 4 - SET_UPPER_LIMIT | USE_TEXT_COLOR -}; +double WORKSHEET_DATAITEM::m_WSunits2Iu = 1.0; +DPOINT WORKSHEET_DATAITEM::m_RB_Corner; +DPOINT WORKSHEET_DATAITEM::m_LT_Corner; - -// horizontal segment above COMPANY NAME -Ki_WorkSheetData WS_Segm3 = -{ - WS_SEGMENT, - &WS_Comment4, - BLOCK_OX, TEXTSIZE * 6, - 0, TEXTSIZE * 6, - NULL -}; - - -// vertical segment of the left REV and SHEET -Ki_WorkSheetData WS_Segm4 = -{ - WS_SEGMENT, - &WS_Segm3, - BLOCK_REV_X + TEXTSIZE,TEXTSIZE * 4, - BLOCK_REV_X + TEXTSIZE, 0, - NULL -}; - - -Ki_WorkSheetData WS_Segm5 = -{ - WS_SEGMENT, - &WS_Segm4, - BLOCK_OX, TEXTSIZE * 2, - 0, TEXTSIZE * 2, - NULL -}; - - -Ki_WorkSheetData WS_Segm6 = -{ - WS_SEGMENT, - &WS_Segm5, - BLOCK_OX, TEXTSIZE * 4, - 0, TEXTSIZE * 4, - NULL -}; - - -Ki_WorkSheetData WS_Segm7 = -{ - WS_SEGMENT, - &WS_Segm6, - BLOCK_OX - (TEXTSIZE * 11),TEXTSIZE * 4, - BLOCK_OX - (TEXTSIZE * 11),TEXTSIZE * 2, - NULL -}; - -#include +WORKSHEET_LAYOUT dataList; // The layout shape void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( const wxString& aPaperFormat, @@ -306,178 +198,126 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( const TITLE_BLOCK& aTitleBlock, EDA_COLOR_T aLineColor, EDA_COLOR_T aTextColor ) { - wxSize textsize( TEXTSIZE * m_milsToIu, TEXTSIZE * m_milsToIu ); - wxSize size_ref( FRMREF_TXTSIZE * m_milsToIu, - FRMREF_TXTSIZE * m_milsToIu ); - wxString msg; + #define milsTomm (25.4/1000) m_titleBlock = &aTitleBlock, m_paperFormat = &aPaperFormat, m_fileName = &aFileName, m_sheetFullName = &aSheetPathHumanReadable; + // Build the basic layout shape, if the layout list is empty + if( dataList.GetCount() == 0 ) + dataList.SetDefaultLayout(); + + WORKSHEET_DATAITEM::m_WSunits2Iu = m_milsToIu / milsTomm; // Left top corner position - wxPoint lt_corner; + DPOINT lt_corner; lt_corner.x = m_LTmargin.x; lt_corner.y = m_LTmargin.y; + WORKSHEET_DATAITEM::m_LT_Corner = lt_corner * milsTomm; // Right bottom corner position - wxPoint rb_corner; + DPOINT rb_corner; rb_corner.x = m_pageSize.x - m_RBmargin.x; rb_corner.y = m_pageSize.y - m_RBmargin.y; - - // Draw the border. - int ii, jj, ipas, gxpas, gypas; - - wxPoint pos = lt_corner; - wxPoint end = rb_corner; - for( ii = 0; ii < 2; ii++ ) - { - Append( new WS_DRAW_ITEM_RECT( - wxPoint( pos.x * m_milsToIu, pos.y * m_milsToIu ), - wxPoint( end.x * m_milsToIu, end.y * m_milsToIu ), - m_penSize, aLineColor ) ); - - pos.x += GRID_REF_W; - pos.y += GRID_REF_W; - end.x -= GRID_REF_W; - end.y -= GRID_REF_W; - } - - ipas = ( rb_corner.x - lt_corner.x ) / PAS_REF; - gxpas = ( rb_corner.x - lt_corner.x ) / ipas; - - for( ii = lt_corner.x + gxpas, jj = 1; ipas > 0; ii += gxpas, jj++, ipas-- ) - { - msg.Printf( wxT( "%d" ), jj ); - - if( ii < rb_corner.x - PAS_REF / 2 ) - { - Append( new WS_DRAW_ITEM_LINE( - wxPoint( ii * m_milsToIu, lt_corner.y * m_milsToIu ), - wxPoint( ii * m_milsToIu, ( lt_corner.y + GRID_REF_W ) * m_milsToIu ), - m_penSize, aLineColor ) ); - } - - Append( new WS_DRAW_ITEM_TEXT( msg, - wxPoint( ( ii - gxpas / 2 ) * m_milsToIu, - ( lt_corner.y + GRID_REF_W / 2 ) * m_milsToIu ), - size_ref, m_penSize, aLineColor ) ); - - if( ii < rb_corner.x - PAS_REF / 2 ) - { - Append( new WS_DRAW_ITEM_LINE( - wxPoint( ii * m_milsToIu, rb_corner.y * m_milsToIu ), - wxPoint( ii * m_milsToIu, (rb_corner.y - GRID_REF_W ) * m_milsToIu ), - m_penSize, aLineColor ) ); - } - - Append( new WS_DRAW_ITEM_TEXT( msg, - wxPoint( ( ii - gxpas / 2 ) * m_milsToIu, - ( rb_corner.y - GRID_REF_W / 2) * m_milsToIu ), - size_ref, m_penSize, aLineColor ) ); - } - - ipas = ( rb_corner.y - lt_corner.y ) / PAS_REF; - gypas = ( rb_corner.y - lt_corner.y ) / ipas; - - for( ii = lt_corner.y + gypas, jj = 0; ipas > 0; ii += gypas, jj++, ipas-- ) - { - if( jj < 26 ) - msg.Printf( wxT( "%c" ), jj + 'A' ); - else // I hope 52 identifiers are enough... - msg.Printf( wxT( "%c" ), 'a' + jj - 26 ); - - if( ii < rb_corner.y - PAS_REF / 2 ) - { - Append( new WS_DRAW_ITEM_LINE( - wxPoint( lt_corner.x * m_milsToIu, ii * m_milsToIu ), - wxPoint( ( lt_corner.x + GRID_REF_W ) * m_milsToIu, ii * m_milsToIu ), - m_penSize, aLineColor ) ); - } - - Append( new WS_DRAW_ITEM_TEXT( msg, - wxPoint( ( lt_corner.x + GRID_REF_W / 2 ) * m_milsToIu, - ( ii - gypas / 2 ) * m_milsToIu ), - size_ref, m_penSize, aLineColor ) ); - - if( ii < rb_corner.y - PAS_REF / 2 ) - { - Append( new WS_DRAW_ITEM_LINE( - wxPoint( rb_corner.x * m_milsToIu, ii * m_milsToIu ), - wxPoint( ( rb_corner.x - GRID_REF_W ) * m_milsToIu, ii * m_milsToIu ), - m_penSize, aLineColor ) ); - } - - Append( new WS_DRAW_ITEM_TEXT( msg, - wxPoint( ( rb_corner.x - GRID_REF_W / 2 ) * m_milsToIu, - ( ii - gxpas / 2 ) * m_milsToIu ), - size_ref, m_penSize, aLineColor ) ); - } - - int upperLimit = VARIABLE_BLOCK_START_POSITION; - rb_corner.x -= GRID_REF_W; - rb_corner.y -= GRID_REF_W; + WORKSHEET_DATAITEM::m_RB_Corner = rb_corner * milsTomm; WS_DRAW_ITEM_TEXT* gtext; - Ki_WorkSheetData* WsItem; int pensize; bool bold; bool italic = false; EDA_COLOR_T color; - for( WsItem = &WS_Segm7; WsItem != NULL; WsItem = WsItem->Pnext ) + for( unsigned ii = 0; ; ii++ ) { - pos.x = (rb_corner.x - WsItem->m_Posx) * m_milsToIu; - pos.y = (rb_corner.y - WsItem->m_Posy) * m_milsToIu; + WORKSHEET_DATAITEM* wsItem = dataList.GetItem( ii ); - msg.Empty(); + if( wsItem == NULL ) + break; - if( WsItem->m_Type == WS_TEXT && WsItem->m_TextBase ) - msg = BuildFullText( WsItem->m_TextBase ); - - switch( WsItem->m_Type ) + switch( wsItem->m_Type ) { - case WS_TEXT: - if( msg.IsEmpty() ) + case WORKSHEET_DATAITEM::WS_TEXT: + { + WORKSHEET_DATAITEM_TEXT * wsText = (WORKSHEET_DATAITEM_TEXT*)wsItem; + wsText->m_FullText = BuildFullText( wsText->m_TextBase ); + if( wsText->m_FullText.IsEmpty() ) break; + bold = false; - pensize = m_penSize; + pensize = wsText->GetPenSizeUi(); + + if( pensize == 0 ) + pensize = m_penSize; + color = aLineColor; - if( WsItem->m_Flags & USE_TEXT_COLOR ) + + if( wsText->m_Flags & USE_TEXT_COLOR ) color = aTextColor; - if( WsItem->m_Flags & USE_BOLD ) + wsText->SetConstrainedTextSize(); + wxSize textsize; + + textsize.x = KiROUND( wsText->m_ConstrainedTextSize.x + * WORKSHEET_DATAITEM::m_WSunits2Iu ); + textsize.y = KiROUND( wsText->m_ConstrainedTextSize.y + * WORKSHEET_DATAITEM::m_WSunits2Iu ); + + if( wsText->m_Flags & USE_BOLD ) { bold = true; pensize = GetPenSizeForBold( std::min( textsize.x, textsize.y ) ); } - Append( gtext = new WS_DRAW_ITEM_TEXT( msg, pos, textsize, - pensize, color, italic, bold ) ); - gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - if( WsItem->m_Flags & SET_UPPER_LIMIT ) - upperLimit = std::max( upperLimit, WsItem->m_Posy + TEXTSIZE ); + for( int jj = 0; jj < wsText->m_RepeatCount; ) + { + if( ! wsText->IsInsidePage( jj ) ) + break; + Append( gtext = new WS_DRAW_ITEM_TEXT( wsText->m_FullText, + wsText->GetStartPosUi( jj ), + textsize, + pensize, color, italic, bold ) ); + wsText->TransfertSetupToGraphicText( gtext ); + + jj++; + if( wsText->m_RepeatCount > 1 ) // Try to increment label + wsText->IncrementLabel( jj ); + } + } break; - case WS_UPPER_SEGMENT: + case WORKSHEET_DATAITEM::WS_SEGMENT: + pensize = wsItem->GetPenSizeUi(); - if( upperLimit == 0 ) - break; + if( pensize == 0 ) + pensize = m_penSize; - case WS_LEFT_SEGMENT: - WS_MostUpperLine.m_Posy = upperLimit; - WS_MostUpperLine.m_Endy = upperLimit; - WS_MostLeftLine.m_Posy = upperLimit; - pos.y = (rb_corner.y - WsItem->m_Posy) * m_milsToIu; + for( int jj = 0; jj < wsItem->m_RepeatCount; jj++ ) + { + if( ! wsItem->IsInsidePage( jj ) ) + break; + Append( new WS_DRAW_ITEM_LINE( wsItem->GetStartPosUi( jj ), + wsItem->GetEndPosUi( jj ), + pensize, aLineColor ) ); + } + break; - case WS_SEGMENT: - end.x = rb_corner.x - WsItem->m_Endx; - end.y = rb_corner.y - WsItem->m_Endy; - Append( new WS_DRAW_ITEM_LINE( pos, - wxPoint( end.x * m_milsToIu, end.y * m_milsToIu ), - m_penSize, aLineColor ) ); + case WORKSHEET_DATAITEM::WS_RECT: + pensize = wsItem->GetPenSizeUi(); + + if( pensize == 0 ) + pensize = m_penSize; + + for( int jj = 0; jj < wsItem->m_RepeatCount; jj++ ) + { + if( ! wsItem->IsInsidePage( jj ) ) + break; + + Append( new WS_DRAW_ITEM_RECT( wsItem->GetStartPosUi( jj ), + wsItem->GetEndPosUi( jj ), + pensize, aLineColor ) ); + } break; } } diff --git a/common/title_block_shapes_gost.cpp b/common/title_block_shapes_gost.cpp index e5ccad4ba9..86887d9597 100644 --- a/common/title_block_shapes_gost.cpp +++ b/common/title_block_shapes_gost.cpp @@ -1,5 +1,5 @@ /** - * @file title_block_shapes_gost.cpp + * @file title_block_shape_gost.h * @brief description of graphic items and texts to build a title block * using GOST standard */ @@ -43,6 +43,17 @@ #define TEXTSIZE 100 // worksheet text size +struct Ki_WorkSheetData +{ +public: + int m_Type; + Ki_WorkSheetData* Pnext; + int m_Posx, m_Posy; + int m_Endx, m_Endy; + const wxChar* m_TextBase; + int m_Flags; +}; + // Work sheet structure type definitions. enum TypeKi_WorkSheetData { WS_OSN, diff --git a/common/worksheet.cpp b/common/worksheet.cpp index a20c7dd877..f3fc9b5463 100644 --- a/common/worksheet.cpp +++ b/common/worksheet.cpp @@ -293,20 +293,17 @@ wxString WS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase ) format = aTextbase[++ii]; switch( format ) { + case '0': case '1': - msg += m_titleBlock->GetComment1(); - break; - case '2': - msg += m_titleBlock->GetComment2(); - break; - case '3': - msg += m_titleBlock->GetComment3(); - break; - case '4': - msg += m_titleBlock->GetComment4(); + case '5': + case '6': + case '7': + case '8': + case '9': + msg += m_titleBlock->GetComment( format - '0'); break; default: @@ -326,43 +323,42 @@ void TITLE_BLOCK::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aCont throw( IO_ERROR ) { // Don't write the title block information if there is nothing to write. - if( !m_title.IsEmpty() || !m_date.IsEmpty() || !m_revision.IsEmpty() - || !m_company.IsEmpty() || !m_comment1.IsEmpty() || !m_comment2.IsEmpty() - || !m_comment3.IsEmpty() || !m_comment4.IsEmpty() ) + bool isempty = true; + for( unsigned idx = 0; idx < m_tbTexts.GetCount(); idx++ ) + { + if( ! m_tbTexts[idx].IsEmpty() ) + { + isempty = false; + break; + } + } + + if( !isempty ) { aFormatter->Print( aNestLevel, "(title_block\n" ); - if( !m_title.IsEmpty() ) + if( !GetTitle().IsEmpty() ) aFormatter->Print( aNestLevel+1, "(title %s)\n", - aFormatter->Quotew( m_title ).c_str() ); + aFormatter->Quotew( GetTitle() ).c_str() ); - if( !m_date.IsEmpty() ) + if( !GetDate().IsEmpty() ) aFormatter->Print( aNestLevel+1, "(date %s)\n", - aFormatter->Quotew( m_date ).c_str() ); + aFormatter->Quotew( GetDate() ).c_str() ); - if( !m_revision.IsEmpty() ) + if( !GetRevision().IsEmpty() ) aFormatter->Print( aNestLevel+1, "(rev %s)\n", - aFormatter->Quotew( m_revision ).c_str() ); + aFormatter->Quotew( GetRevision() ).c_str() ); - if( !m_company.IsEmpty() ) + if( !GetCompany().IsEmpty() ) aFormatter->Print( aNestLevel+1, "(company %s)\n", - aFormatter->Quotew( m_company ).c_str() ); + aFormatter->Quotew( GetCompany() ).c_str() ); - if( !m_comment1.IsEmpty() ) - aFormatter->Print( aNestLevel+1, "(comment 1 %s)\n", - aFormatter->Quotew( m_comment1 ).c_str() ); - - if( !m_comment2.IsEmpty() ) - aFormatter->Print( aNestLevel+1, "(comment 2 %s)\n", - aFormatter->Quotew( m_comment2 ).c_str() ); - - if( !m_comment3.IsEmpty() ) - aFormatter->Print( aNestLevel+1, "(comment 3 %s)\n", - aFormatter->Quotew( m_comment3 ).c_str() ); - - if( !m_comment4.IsEmpty() ) - aFormatter->Print( aNestLevel+1, "(comment 4 %s)\n", - aFormatter->Quotew( m_comment4 ).c_str() ); + for( int ii = 0; ii < 3; ii++ ) + { + if( !GetComment(ii).IsEmpty() ) + aFormatter->Print( aNestLevel+1, "(comment %d %s)\n", ii+1, + aFormatter->Quotew( GetComment(1) ).c_str() ); + } aFormatter->Print( aNestLevel, ")\n\n" ); } diff --git a/include/class_title_block.h b/include/class_title_block.h index efbe13599c..785be8aab4 100644 --- a/include/class_title_block.h +++ b/include/class_title_block.h @@ -39,49 +39,94 @@ struct IO_ERROR; */ class TITLE_BLOCK { + // Texts are stored in wxArraystring. + // textsIdx gives the index of known texts in + // this array + enum textsIdx + { + titleIdx = 0, + dateIdx, + revisionIdx, + companyIdx, + m_commentIdx + }; + public: - // TITLE_BLOCK(); + + TITLE_BLOCK() {}; virtual ~TITLE_BLOCK() {}; // a virtual dtor seems needed to build // python lib without warning - void SetTitle( const wxString& aTitle ) { m_title = aTitle; } - const wxString& GetTitle() const { return m_title; } + void SetTitle( const wxString& aTitle ) + { + setTbText( titleIdx, aTitle ); + } + + const wxString& GetTitle() const + { + return getTbText( titleIdx );; + } /** * Function SetDate * sets the date field, and defaults to the current time and date. */ - void SetDate( const wxString& aDate ) { m_date = aDate; } - const wxString& GetDate() const { return m_date; } + void SetDate( const wxString& aDate ) + { + setTbText( dateIdx, aDate ); + } - void SetRevision( const wxString& aRevision ) { m_revision = aRevision; } - const wxString& GetRevision() const { return m_revision; } + const wxString& GetDate() const + { + return getTbText( dateIdx ); + } - void SetCompany( const wxString& aCompany ) { m_company = aCompany; } - const wxString& GetCompany() const { return m_company; } + void SetRevision( const wxString& aRevision ) + { + setTbText( revisionIdx, aRevision ); + } - void SetComment1( const wxString& aComment ) { m_comment1 = aComment; } - const wxString& GetComment1() const { return m_comment1; } + const wxString& GetRevision() const + { + return getTbText( revisionIdx ); + } - void SetComment2( const wxString& aComment ) { m_comment2 = aComment; } - const wxString& GetComment2() const { return m_comment2; } + void SetCompany( const wxString& aCompany ) + { + setTbText( companyIdx, aCompany ); + } - void SetComment3( const wxString& aComment ) { m_comment3 = aComment; } - const wxString& GetComment3() const { return m_comment3; } + const wxString& GetCompany() const + { + return getTbText( companyIdx ); + } + + void SetComment( int aIdx, const wxString& aComment ) + { + aIdx += m_commentIdx; + return setTbText( aIdx, aComment ); + } + + const wxString& GetComment( int aIdx ) const + { + aIdx += m_commentIdx; + return getTbText( aIdx ); + } + + // Only for old code compatibility. Will be removed later + void SetComment1( const wxString& aComment ) { SetComment( 0, aComment ); } + void SetComment2( const wxString& aComment ) { SetComment( 1, aComment ); } + void SetComment3( const wxString& aComment ) { SetComment( 2, aComment ); } + void SetComment4( const wxString& aComment ) { SetComment( 3, aComment ); } + const wxString& GetComment1( ) const { return GetComment( 0 ); } + const wxString& GetComment2( ) const { return GetComment( 1 ); } + const wxString& GetComment3( ) const { return GetComment( 2 ); } + const wxString& GetComment4( ) const { return GetComment( 3 ); } - void SetComment4( const wxString& aComment ) { m_comment4 = aComment; } - const wxString& GetComment4() const { return m_comment4; } void Clear() { - m_title.clear(); - m_date.clear(); - m_revision.clear(); - m_company.clear(); - m_comment1.clear(); - m_comment2.clear(); - m_comment3.clear(); - m_comment4.clear(); + m_tbTexts.Clear(); } /** @@ -97,14 +142,24 @@ public: throw( IO_ERROR ); private: - wxString m_title; - wxString m_date; - wxString m_revision; - wxString m_company; - wxString m_comment1; - wxString m_comment2; - wxString m_comment3; - wxString m_comment4; + wxArrayString m_tbTexts; + + void setTbText( int aIdx, const wxString& aText ) + { + if( (int)m_tbTexts.GetCount() <= aIdx ) + m_tbTexts.Add( wxEmptyString, aIdx + 1 - m_tbTexts.GetCount() ); + m_tbTexts[aIdx] = aText; + } + + const wxString& getTbText( int aIdx ) const + { + static const wxString m_emptytext; + + if( (int)m_tbTexts.GetCount() > aIdx ) + return m_tbTexts[aIdx]; + else + return m_emptytext; + } }; #endif // TITLE_BLOCK_H_ diff --git a/include/vector2d.h b/include/vector2d.h index 3968984df1..b2662b0505 100644 --- a/include/vector2d.h +++ b/include/vector2d.h @@ -27,7 +27,7 @@ #define VECTOR2D_H_ #include -#include +#include // For wxPoint definition /// Forward declaration for template friends diff --git a/include/worksheet.h b/include/worksheet.h index 6df596d889..0928963554 100644 --- a/include/worksheet.h +++ b/include/worksheet.h @@ -7,24 +7,15 @@ #ifndef WORKSHEET_H_ #define WORKSHEET_H_ -// Forwadr declarations: +#include // EDA_COLOR_T definition + +// Forward declarations: class EDA_DRAW_PANEL; class TITLE_BLOCK; class PAGE_INFO; #define PAS_REF 2000 // Pitch (in mils) of reference locations in worksheet -struct Ki_WorkSheetData -{ -public: - int m_Type; - Ki_WorkSheetData* Pnext; - int m_Posx, m_Posy; - int m_Endx, m_Endy; - const wxChar* m_TextBase; - int m_Flags; -}; - /** * Function DrawPageLayout is a core function to draw the page layout with * the frame and the basic inscriptions. diff --git a/include/worksheet_shape_builder.h b/include/worksheet_shape_builder.h index c0d27da722..740a2887db 100644 --- a/include/worksheet_shape_builder.h +++ b/include/worksheet_shape_builder.h @@ -7,6 +7,156 @@ #ifndef WORKSHEET_SHAPE_BUILDER_H #define WORKSHEET_SHAPE_BUILDER_H +#include +#include + +class WS_DRAW_ITEM_TEXT; // Forward declaration + +#define TB_DEFAULT_TEXTSIZE 1.5 // default worksheet text size in mm + +// Text attributes set in m_Flags (ORed bits) + #define USE_BOLD 1 // has meaning for texts + #define USE_THICK_LINE 1 // equivalent to bold for lines + #define USE_ITALIC 2 // has meaning for texts + #define USE_TEXT_COLOR 4 + #define SET_UPPER_LIMIT 8 // Flag used to calculate variable position items + +// A coordinate is relative to a page corner. +// Any of the 4 corners can be a reference. +// The default is the right bottom corner +enum corner_anchor +{ + RB_CORNER, // right bottom corner + RT_CORNER, // right top corner + LB_CORNER, // left bottom corner + LT_CORNER, // left top corner +}; + +// a coordinate point +// The position is always relative to the corner anchor +// Note the coordinate is from the anchor point +// to the opposite corner. +class POINT_COORD +{ +public: + DPOINT m_Pos; + int m_Anchor; +public: + POINT_COORD() { m_Anchor = RB_CORNER; } + POINT_COORD( DPOINT aPos, enum corner_anchor aAnchor = RB_CORNER ) + { + m_Pos = aPos; + m_Anchor = aAnchor; + } +}; + + +// Work sheet structure type definitions. +class WORKSHEET_DATAITEM +{ +public: + enum WS_ItemType { + WS_TEXT, + WS_SEGMENT, + WS_RECT + }; + WS_ItemType m_Type; + POINT_COORD m_Pos; + POINT_COORD m_End; + double m_LineWidth; + int m_Flags; + int m_RepeatCount; // repeat count for duplicate items + DPOINT m_IncrementVector; // For duplicate items: move vector + // for position increment + int m_IncrementLabel; + + static double m_WSunits2Iu; // conversion factor between + // ws units (mils) and draw/plot units + static DPOINT m_RB_Corner; // cordinates of the right bottom corner + // (ws units) + static DPOINT m_LT_Corner; // cordinates of the left top corner + // (ws units) + +public: + WORKSHEET_DATAITEM( WS_ItemType aType ) + { + m_Type = aType; + m_Flags = 0; + m_RepeatCount = 1; + m_IncrementLabel = 0; + m_LineWidth = 0.0; + } + + void SetStart( double aPosx, double aPosy, enum corner_anchor aAnchor = RB_CORNER ) + { + m_Pos.m_Pos.x = aPosx; + m_Pos.m_Pos.y = aPosy; + m_Pos.m_Anchor = aAnchor; + } + + void SetEnd( double aPosx, double aPosy, enum corner_anchor aAnchor = RB_CORNER ) + { + m_End.m_Pos.x = aPosx; + m_End.m_Pos.y = aPosy; + m_End.m_Anchor = aAnchor; + } + + const wxPoint GetStartPosUi( int ii = 0 ) const; + const wxPoint GetEndPosUi( int ii = 0 ) const; + const DPOINT GetStartPos( int ii = 0 ) const; + const DPOINT GetEndPos( int ii = 0 ) const; + bool IsInsidePage( int ii ) const; + int GetPenSizeUi() {return KiROUND( m_LineWidth * m_WSunits2Iu ); } +}; + +class WORKSHEET_DATAITEM_TEXT : public WORKSHEET_DATAITEM +{ +public: + wxString m_TextBase; // The basic text, with format symbols + wxString m_FullText; // The expanded text, shown on screen + int m_IncrementLabel; + double m_Orient; // Orientation in degrees + enum EDA_TEXT_HJUSTIFY_T m_Hjustify; + enum EDA_TEXT_VJUSTIFY_T m_Vjustify; + DSIZE m_TextSize; + DSIZE m_BoundingBoxSize; // When not null, this is the max + // size of the full text. + // the text size will be modified + // to keep the full text insite this + // bound. + DSIZE m_ConstrainedTextSize;// Actual text size, if constrained by + // the m_BoundingBoxSize constraint + +public: + WORKSHEET_DATAITEM_TEXT( const wxChar* aTextBase ); + + /** + * transfert the text justification and orientation + * to aGText + */ + void TransfertSetupToGraphicText( WS_DRAW_ITEM_TEXT* aGText ); + + /** + * Try to build text wihich is an increment of m_TextBase + * has meaning only if m_TextBase is a basic text (one char) + * If the basic char is a digit, build a number + * If the basic char is a letter, use the letter with ascii code + * aIncr + (basic char ascc code) + * @param aIncr = the increment value + * return the incremented label in m_FullText + */ + void IncrementLabel( int aIncr ); + + /** + * Calculates m_ConstrainedTextSize from m_TextSize + * to keep the X size and the full Y size of the text + * smaller than m_BoundingBoxSize + * if m_BoundingBoxSize.x or m_BoundingBoxSize.y > 0 + * if m_BoundingBoxSize.x or m_BoundingBoxSize.y == 0 + * the corresponding text size is not constrained + */ + void SetConstrainedTextSize(); +}; /* * Helper classes to handle basic graphic items used to raw/plot @@ -22,9 +172,11 @@ public: enum WS_DRAW_TYPE { wsg_line, wsg_rect, wsg_poly, wsg_text }; + protected: WS_DRAW_TYPE m_type; // wsg_line, wsg_rect, wsg_poly, wsg_text EDA_COLOR_T m_color; + protected: WS_DRAW_ITEM_BASE( WS_DRAW_TYPE aType, EDA_COLOR_T aColor ) { @@ -133,7 +285,8 @@ class WS_DRAW_ITEM_LIST wxSize m_pageSize; // the page size in mils double m_milsToIu; // the scalar to convert pages units ( mils) // to draw/plot units. - int m_penSize; // The line width for drawings. + int m_penSize; // The default line width for drawings. + // used when an item has a pen size = 0 int m_sheetNumber; // the value of the sheet number, for basic inscriptions int m_sheetCount; // the value of the number of sheets, in schematic // for basic inscriptions, in schematic @@ -298,4 +451,52 @@ public: }; +/** + * WORKSHEET_LAYOUT handles the grpahic items list to draw/plot + * the title block and other items (page references ... + */ +class WORKSHEET_LAYOUT +{ + std::vector m_list; + +public: + WORKSHEET_LAYOUT() {}; + ~WORKSHEET_LAYOUT() {ClearList(); } + + void ClearList() + { + for( unsigned ii = 0; ii < m_list.size(); ii++ ) + delete m_list[ii]; + } + + /** + * Add an item to the list of items + */ + void Append( WORKSHEET_DATAITEM* aItem ) + { + m_list.push_back( aItem ); + } + + /** + * @return the item from its index aIdx, or NULL if does not exist + */ + WORKSHEET_DATAITEM* GetItem( unsigned aIdx ) const + { + if( aIdx < m_list.size() ) + return m_list[aIdx]; + else + return NULL; + } + + /** + * @return the item count + */ + unsigned GetCount() const { return m_list.size(); } + + /** + * Fills the list with the default layout shape + */ + void SetDefaultLayout(); +}; + #endif // WORKSHEET_SHAPE_BUILDER_H diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 7fec74299a..181da820b7 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -64,37 +64,12 @@ static const wxString traceFootprintLibrary( wxT( "KicadFootprintLib" ) ); // Helper function to print a float number without using scientific notation // and no trailing 0 +// We want to avoid scientific notation in S-expr files (not easy to read) +// for floating numbers. +// So we cannot always just use the %g or the %f format to print a fp number +// this helper function uses the %f format when needed, or %g when %f is +// not well working and then removes trailing 0 -#if 0 -// Does not work for aValue < 0.0001 and > 0. -// Will need to support exponents in DSNLEXER if we get exponents > 16, i.e. the "precision". -std::string double2str( double aValue ) -{ - char buf[50]; - int len; - - if( aValue != 0.0 && fabs( aValue ) <= 0.0001 ) - { - len = sprintf( buf, "%.10f", aValue ); - - while( --len > 0 && buf[len] == '0' ) - buf[len] = '\0'; - - if( buf[len] == '.' ) - buf[len--] = '\0'; - - ++len; - } - else - { - len = sprintf( buf, "%.10g", mm ); - } - - return std::string( buf, len ); -} - -#else -// this one handles 0.00001 ok, and 1.222222222222222 ok, previous did not. std::string double2str( double aValue ) { char buf[50]; @@ -102,6 +77,8 @@ std::string double2str( double aValue ) if( aValue != 0.0 && fabs( aValue ) <= 0.0001 ) { + // For these small values, %f works fine, + // and %g gives an exponent len = sprintf( buf, "%.16f", aValue ); while( --len > 0 && buf[len] == '0' ) @@ -114,12 +91,13 @@ std::string double2str( double aValue ) } else { + // For these values, %g works fine, and sometimes %f + // gives a bad value (try aValue = 1.222222222222, with %.16f format!) len = sprintf( buf, "%.16g", aValue ); } return std::string( buf, len );; } -#endif /** From 1ec49864222dec4443e8470b46807bb1cae897a7 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 5 Jun 2013 15:21:14 +0200 Subject: [PATCH 02/50] Add info and comments about page layout description using S expressions --- common/page_layout_default_description.cpp | 83 +++++++++++++++++++++- 1 file changed, 80 insertions(+), 3 deletions(-) diff --git a/common/page_layout_default_description.cpp b/common/page_layout_default_description.cpp index 04e94a84f9..5d3b7f7ca0 100644 --- a/common/page_layout_default_description.cpp +++ b/common/page_layout_default_description.cpp @@ -29,16 +29,93 @@ #include +/* keyword used in page layout description are (see page_layout_reader.keywords) + * page_layout + * setup + * linewidth + * textlinewidth + * textsize + * comment + * line + * rect + * polygon + * tbtext + * ltcorner + * lbcorner + * rbcorner + * rtcorner + * name + * pos + * start + * end + * maxlen + * maxheight + * font + * bold + * italic + * size + * justify + * left + * center + * right + * top + * bottom + * rotate + * repeat + * incrx + * incry + * incrlabel + */ +/* + * Items use coordinates. + * A coordinate is defined relative to a page corner + * A coordinate is the X pos, the Y pos, and the corner which is the coordinate origin + * the default is the bottom right corner + * example: (start 10 0 ltcorner) or (start 20 10) + * The direction depends on the corner: a positive coordinate define a point + * from the corner origin, to the opposite corner. + * + * Items are defined by a name, coordinates in mm and some attributes, + * and can be repeated. + * for instance (repeat 2) (incrx 2) (incry 2) repeat the item 2 times, + * and coordinates are incremented by 2 on X direction, and 2 on Y direction + * Comments are allowed. they are inside (), and start by the keyword comment + * example: + * (comment rect around the title block) + * + * Lines and rect are defined by 2 coordinates start and end, and attributes. + * Attributes are linewidth and repeat parameters. + * example: + * (line (start 50 2 ltcorner) (end 50 0 ltcorner) (repeat 30) (incrx 50) ) + * (rect (comment rect around the title block) (linewidth 0.15) (start 110 34) (end 2 2) ) + * + * Texts are defined by the text (between quotes), the position, and attributes + * example + * "(tbtext \"1\" (pos 25 1 lbcorner) (font (size 1.3 1.3)) (repeat 100) (incrx 50) )" + * the text can be rotated by (rotation ) with value = rot angle in degrees + * (font (size 1.3 1.3) bold italic) defines a specific size, + * with bold and italic options + * (justify ) controls the text justification (the default is left) + * justif keyword is center, left, right, top and bottom + * (justify center top) is a text centered on X axis and top aligned on vertical axis + * The text size can be constrained: + * (maxlen ) and (maxheight ) force the actual text x and/or y size to be + * reduced to limit the text height to the maxheight value, + * and the full text x size to the maxlen value. + * If the actual text size is smaller than limits, its size is not modified. + * + */ + // height of the band reference grid 2.0 mm // worksheet frame reference text size 1.3 mm // default text size 1.5 mm // default line width 0.15 mm // frame ref pitch 50 mm -extern const wxString defaultPageLayout; +extern const wxString defaultPageLayout; // Default page layout (sizes are in mm) -const wxString defaultPageLayout( wxT( "( page_layout\n" +const wxString defaultPageLayout( wxT( "( page_layout\n" "(setup (textsize 1.5 1.5) (linewidth 0.15) (textlinewidth 0.15) )" "(rect (comment rect around the title block) (linewidth 0.15) (start 110 34) (end 2 2) )\n" "(rect (start 0 0 ltcorner) (end 0 0 rbcorner) (repeat 2) (incrx 2) (incry 2) )\n" @@ -69,4 +146,4 @@ const wxString defaultPageLayout( wxT( "( page_layout\n" "(tbtext \"%C3\" (comment Comment 0) (pos 108 32) )\n" "(line (start 90 8.5) end 90 5.5) )\n" "(line (start 26 8.5) end 26 2) )\n" -")\n") ); +")\n" ) ); From 0f1f0f92f1969c70451f8a8a4ecbf85cd70de3d4 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Wed, 5 Jun 2013 09:24:03 -0500 Subject: [PATCH 03/50] downloads-by-cmake now configurable, fix wx2.8 compiler errors --- CMakeLists.txt | 16 ++++++++++++---- common/page_layout_default_description.cpp | 9 ++++++--- common/page_layout_reader.cpp | 6 +----- include/worksheet.h | 5 +++++ pcbnew/CMakeLists.txt | 2 +- .../dialog_set_grid.cpp} | 18 ++++++++---------- pcbnew/dialogs/dialog_set_grid_base.cpp | 3 ++- ...g_set_grid.fbp => dialog_set_grid_base.fbp} | 2 +- pcbnew/dialogs/dialog_set_grid_base.h | 2 +- 9 files changed, 37 insertions(+), 26 deletions(-) rename pcbnew/{set_grid.cpp => dialogs/dialog_set_grid.cpp} (92%) rename pcbnew/dialogs/{dialog_set_grid.fbp => dialog_set_grid_base.fbp} (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 06c4de74c6..e3eebbbc7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,6 +74,13 @@ else() message("Build testing (unstable) version of KiCad") endif() +# All CMake downloads go here. Suggested is up in the source tree, not in the build dir where they +# would have to be downloaded over and over again. The default is to choose a directory that is +# hidden on linux (starts with a '.') because there is a way to exclude this directory when grepping +# the source tree. +set( DOWNLOAD_DIR ${PROJECT_SOURCE_DIR}/.downloads-by-cmake + CACHE PATH "Location of KiCad downloads, suggested is a dir common to all builds, i.e. global." ) + #================================================ # Set flags for GCC. @@ -149,6 +156,11 @@ if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS_DEBUG "${KICAD_GCC_DEBUG_BUILD_FLAGS} -Wall -g3 -ggdb3 -DDEBUG") endif() + # quiet GCC 4.8.1 while in boost + if( GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8 ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs" ) + endif() + endif(CMAKE_COMPILER_IS_GNUCXX) if(wxUSE_UNICODE) @@ -239,10 +251,6 @@ include(Functions) include( ExternalProject ) -# All CMake downloads go here, up in the source tree, not in the build dir where they -# would have to be downloaded over and over again. -set( DOWNLOAD_DIR ${PROJECT_SOURCE_DIR}/downloads-by-cmake ) - #================================================ # Find libraries that are needed to build KiCad. #================================================ diff --git a/common/page_layout_default_description.cpp b/common/page_layout_default_description.cpp index 5d3b7f7ca0..a0c8dac8d5 100644 --- a/common/page_layout_default_description.cpp +++ b/common/page_layout_default_description.cpp @@ -106,16 +106,18 @@ * */ +#include // defaultPageLayout + + // height of the band reference grid 2.0 mm // worksheet frame reference text size 1.3 mm // default text size 1.5 mm // default line width 0.15 mm // frame ref pitch 50 mm -extern const wxString defaultPageLayout; // Default page layout (sizes are in mm) -const wxString defaultPageLayout( wxT( "( page_layout\n" +const char defaultPageLayout[] = "( page_layout\n" "(setup (textsize 1.5 1.5) (linewidth 0.15) (textlinewidth 0.15) )" "(rect (comment rect around the title block) (linewidth 0.15) (start 110 34) (end 2 2) )\n" "(rect (start 0 0 ltcorner) (end 0 0 rbcorner) (repeat 2) (incrx 2) (incry 2) )\n" @@ -146,4 +148,5 @@ const wxString defaultPageLayout( wxT( "( page_layout\n" "(tbtext \"%C3\" (comment Comment 0) (pos 108 32) )\n" "(line (start 90 8.5) end 90 5.5) )\n" "(line (start 26 8.5) end 26 2) )\n" -")\n" ) ); +")\n" +; diff --git a/common/page_layout_reader.cpp b/common/page_layout_reader.cpp index 140d9e8df1..19f56dcdb4 100644 --- a/common/page_layout_reader.cpp +++ b/common/page_layout_reader.cpp @@ -36,10 +36,6 @@ #include #include -// defaultPageLayout is the default page layout description -// using the S expr. -// see page_layout_default_shape.cpp -extern const wxString defaultPageLayout; using namespace TB_READER_T; @@ -448,7 +444,7 @@ double PAGE_LAYOUT_READER_PARSER::parseDouble() void WORKSHEET_LAYOUT::SetDefaultLayout() { - PAGE_LAYOUT_READER_PARSER lp_parser( defaultPageLayout, "default page" ); + PAGE_LAYOUT_READER_PARSER lp_parser( defaultPageLayout, wxT( "default page" ) ); try { diff --git a/include/worksheet.h b/include/worksheet.h index 0928963554..d58203d77b 100644 --- a/include/worksheet.h +++ b/include/worksheet.h @@ -47,4 +47,9 @@ void DrawPageLayout( wxDC* aDC, EDA_DRAW_PANEL * aCanvas, int aPenWidth, double aScalar, EDA_COLOR_T aLineColor, EDA_COLOR_T aTextColor ); +// defaultPageLayout is the default page layout description +// using the S expr. +// see page_layout_default_shape.cpp +extern const char defaultPageLayout[]; + #endif // WORKSHEET_H_ diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 273c87db21..06f0aa71fd 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -97,6 +97,7 @@ set(PCBNEW_DIALOGS dialogs/dialog_mask_clearance_base.cpp dialogs/dialog_SVG_print.cpp dialogs/dialog_SVG_print_base.cpp + dialogs/dialog_set_grid.cpp dialogs/dialog_set_grid_base.cpp footprint_wizard.cpp footprint_wizard_frame.cpp @@ -192,7 +193,6 @@ set(PCBNEW_CLASS_SRCS print_board_functions.cpp printout_controler.cpp ratsnest.cpp - set_grid.cpp specctra.cpp specctra_export.cpp specctra_import.cpp diff --git a/pcbnew/set_grid.cpp b/pcbnew/dialogs/dialog_set_grid.cpp similarity index 92% rename from pcbnew/set_grid.cpp rename to pcbnew/dialogs/dialog_set_grid.cpp index 0f42682c73..5b2e288dbc 100644 --- a/pcbnew/set_grid.cpp +++ b/pcbnew/dialogs/dialog_set_grid.cpp @@ -1,5 +1,5 @@ /** - * @file set_grid.cpp + * @file dialog_set_grid.cpp * @brief Manage user grid. */ /* @@ -40,7 +40,7 @@ class DIALOG_SET_GRID : public DIALOG_SET_GRID_BASE { public: DIALOG_SET_GRID( wxWindow* parent, const wxPoint& pos ); - ~DIALOG_SET_GRID() { } + void SetGridSize( const wxRealPoint& grid ); wxRealPoint GetGridSize(); void SetGridUnits( int units ); @@ -56,6 +56,7 @@ private: void OnOkClick( wxCommandEvent& event ); }; + void PCB_BASE_FRAME::InstallGridFrame( const wxPoint& pos ) { DIALOG_SET_GRID dlg( this, pos ); @@ -90,8 +91,6 @@ void PCB_BASE_FRAME::InstallGridFrame( const wxPoint& pos ) DIALOG_SET_GRID::DIALOG_SET_GRID( wxWindow* parent, const wxPoint& pos ) : DIALOG_SET_GRID_BASE( parent ) { - SetFocus(); - m_TextPosXUnits->SetLabel( GetUnitsLabel( g_UserUnit ) ); m_TextPosYUnits->SetLabel( GetUnitsLabel( g_UserUnit ) ); @@ -105,9 +104,10 @@ void DIALOG_SET_GRID::SetGridSize( const wxRealPoint& grid ) { wxString msg; - msg.Printf( wxT( "%.6f" ), grid.x ); + msg.Printf( wxT( "%.10g" ), grid.x ); m_OptGridSizeX->SetValue( msg ); - msg.Printf( wxT( "%.6f" ), grid.y ); + + msg.Printf( wxT( "%.10g" ), grid.y ); m_OptGridSizeY->SetValue( msg ); } @@ -158,6 +158,7 @@ void DIALOG_SET_GRID::SetGridOrigin( const wxPoint& grid ) PutValueInLocalUnits( *m_GridOriginYCtrl, grid.y ); } + void DIALOG_SET_GRID::SetGridForFastSwitching( wxArrayString aGrids, int aGrid1, int aGrid2 ) { m_comboBoxGrid1->Append( aGrids ); @@ -167,6 +168,7 @@ void DIALOG_SET_GRID::SetGridForFastSwitching( wxArrayString aGrids, int aGrid1, m_comboBoxGrid2->SetSelection( aGrid2 ); } + void DIALOG_SET_GRID::GetGridForFastSwitching( int& aGrid1, int& aGrid2 ) { aGrid1 = m_comboBoxGrid1->GetSelection(); @@ -180,17 +182,13 @@ void DIALOG_SET_GRID::OnResetGridOrgClick( wxCommandEvent& event ) } -/*****************************************************************/ void DIALOG_SET_GRID::OnCancelClick( wxCommandEvent& event ) -/*****************************************************************/ { EndModal( wxID_CANCEL ); } -/*************************************************************************/ void DIALOG_SET_GRID::OnOkClick( wxCommandEvent& event ) -/*************************************************************************/ { EndModal( wxID_OK ); } diff --git a/pcbnew/dialogs/dialog_set_grid_base.cpp b/pcbnew/dialogs/dialog_set_grid_base.cpp index 2c46afe7db..306566344d 100644 --- a/pcbnew/dialogs/dialog_set_grid_base.cpp +++ b/pcbnew/dialogs/dialog_set_grid_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 8 2012) +// C++ code generated with wxFormBuilder (version Apr 30 2013) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -30,6 +30,7 @@ DIALOG_SET_GRID_BASE::DIALOG_SET_GRID_BASE( wxWindow* parent, wxWindowID id, con wxFlexGridSizer* fgSizer31; fgSizer31 = new wxFlexGridSizer( 2, 2, 0, 0 ); + fgSizer31->AddGrowableCol( 1 ); fgSizer31->SetFlexibleDirection( wxBOTH ); fgSizer31->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); diff --git a/pcbnew/dialogs/dialog_set_grid.fbp b/pcbnew/dialogs/dialog_set_grid_base.fbp similarity index 99% rename from pcbnew/dialogs/dialog_set_grid.fbp rename to pcbnew/dialogs/dialog_set_grid_base.fbp index b386c40703..f409d50996 100644 --- a/pcbnew/dialogs/dialog_set_grid.fbp +++ b/pcbnew/dialogs/dialog_set_grid_base.fbp @@ -209,7 +209,7 @@ 2 wxBOTH - + 1 0 diff --git a/pcbnew/dialogs/dialog_set_grid_base.h b/pcbnew/dialogs/dialog_set_grid_base.h index 9bb3e86b55..3f8fbd7aaa 100644 --- a/pcbnew/dialogs/dialog_set_grid_base.h +++ b/pcbnew/dialogs/dialog_set_grid_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 8 2012) +// C++ code generated with wxFormBuilder (version Apr 30 2013) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! From 66f5b3d3ccbd986d19d48d78d169269377f11073 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 5 Jun 2013 17:32:24 +0200 Subject: [PATCH 04/50] Fix a minor issue in page layout default descr. --- common/page_layout_default_description.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/common/page_layout_default_description.cpp b/common/page_layout_default_description.cpp index a0c8dac8d5..2b7623b971 100644 --- a/common/page_layout_default_description.cpp +++ b/common/page_layout_default_description.cpp @@ -131,21 +131,21 @@ const char defaultPageLayout[] = "( page_layout\n" "(tbtext \"A\" (pos 1 25 rtcorner) (font (size 1.3 1.3)) (justify center) (repeat 100) (incry 50) )\n" "(tbtext \"Date: %D\" (pos 87 6.9) )\n" "(line (start 110 5.5) end 2 5.5) )\n" -"(tbtext \"%K\" (pos 108 4.1) (comment Kicad version ) )\n" +"(tbtext \"%K\" (pos 109 4.1) (comment Kicad version ) )\n" "(line (start 110 8.5) end 2 8.5) )\n" "(tbtext \"Rev: %R\" (pos 24 6.9)(font bold italic)(justify left) )\n" -"(tbtext \"Size: %Z\" (comment Paper format name)(pos 105 6.9) )\n" +"(tbtext \"Size: %Z\" (comment Paper format name)(pos 109 6.9) )\n" "(tbtext \"Id: %S/%N\" (comment Sheet id)(pos 24 4.1) )\n" "(line (start 110 12.5) end 2 12.5) )\n" -"(tbtext \"Title: %T\" (pos 108 10.7)(font bold (size 2 2)) )\n" -"(tbtext \"File: %F\" (pos 108 14.3) )\n" +"(tbtext \"Title: %T\" (pos 109 10.7)(font bold (size 2 2)) )\n" +"(tbtext \"File: %F\" (pos 109 14.3) )\n" "(line (start 110 18.5) end 2 18.5) )\n" -"(tbtext \"Sheet: %P\" (pos 108 17) )\n" -"(tbtext \"%Y\" (comment Company name) (pos 108 20)(font bold) )\n" -"(tbtext \"%C0\" (comment Comment 0) (pos 108 23) )\n" -"(tbtext \"%C1\" (comment Comment 0) (pos 108 26) )\n" -"(tbtext \"%C2\" (comment Comment 0) (pos 108 29) )\n" -"(tbtext \"%C3\" (comment Comment 0) (pos 108 32) )\n" +"(tbtext \"Sheet: %P\" (pos 109 17) )\n" +"(tbtext \"%Y\" (comment Company name) (pos 109 20)(font bold) )\n" +"(tbtext \"%C0\" (comment Comment 0) (pos 109 23) )\n" +"(tbtext \"%C1\" (comment Comment 0) (pos 109 26) )\n" +"(tbtext \"%C2\" (comment Comment 0) (pos 109 29) )\n" +"(tbtext \"%C3\" (comment Comment 0) (pos 109 32) )\n" "(line (start 90 8.5) end 90 5.5) )\n" "(line (start 26 8.5) end 26 2) )\n" ")\n" From 142306e238de24456e084641b7c7bc96eb537813 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Wed, 5 Jun 2013 14:23:55 -0500 Subject: [PATCH 05/50] fix libeditframe.cpp, which in release build would not show multipart text in listbox. dialog uses DIALOG_SHIM. --- .../dialog_edit_component_in_schematic.cpp | 101 ++++++++++++++--- .../dialog_edit_component_in_schematic.h | 105 ------------------ ...dialog_edit_component_in_schematic_fbp.cpp | 4 +- ...dialog_edit_component_in_schematic_fbp.fbp | 2 +- .../dialog_edit_component_in_schematic_fbp.h | 7 +- eeschema/libeditframe.cpp | 6 +- 6 files changed, 96 insertions(+), 129 deletions(-) delete mode 100644 eeschema/dialogs/dialog_edit_component_in_schematic.h diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index 9141746a2d..926d2d6080 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -40,12 +40,95 @@ #include #include #include +#include -#include + +/** + * class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC + * is hand coded and implements DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP which + * is maintained by wxFormBuilder. Do not auto-generate this class or file, + * it is hand coded. + */ +class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP +{ +public: + /** Constructor */ + DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow* parent ); + + /** + * Function InitBuffers + * sets up to edit the given component. + * @param aComponent The component to edit. + */ + void InitBuffers( SCH_COMPONENT* aComponent ); + +private: + + friend class SCH_EDIT_FRAME; + + SCH_EDIT_FRAME* m_Parent; + SCH_COMPONENT* m_Cmp; + LIB_COMPONENT* m_LibEntry; + bool m_skipCopyFromPanel; + + static int s_SelectedRow; + + /// a copy of the edited component's SCH_FIELDs + SCH_FIELDS m_FieldsBuf; + + void setSelectedFieldNdx( int aFieldNdx ); + + int getSelectedFieldNdx(); + + /** + * Function copySelectedFieldToPanel + * sets the values displayed on the panel according to + * the currently selected field row + */ + void copySelectedFieldToPanel(); + + + /** + * Function copyPanelToSelectedField + * copies the values displayed on the panel fields to the currently + * selected field + * @return bool - true if all fields are OK, else false if the user has put + * bad data into a field, and this value can be used to deny a row change. + */ + bool copyPanelToSelectedField(); + + void copyOptionsToPanel(); + + void copyPanelToOptions(); + + void setRowItem( int aFieldNdx, const SCH_FIELD& aField ); + + // event handlers + void OnListItemDeselected( wxListEvent& event ); + void OnListItemSelected( wxListEvent& event ); + void OnCancelButtonClick( wxCommandEvent& event ); + void OnOKButtonClick( wxCommandEvent& event ); + void SetInitCmp( wxCommandEvent& event ); + void addFieldButtonHandler( wxCommandEvent& event ); + void deleteFieldButtonHandler( wxCommandEvent& event ); + void moveUpButtonHandler( wxCommandEvent& event ); + + SCH_FIELD* findField( const wxString& aFieldName ); + + /** + * Function updateDisplay + * update the listbox showing fields, according to the fields texts + * must be called after a text change in fields, if this change is not an edition + */ + void updateDisplay( ) + { + for( unsigned ii = FIELD1; iiInitBuffers( aComponent ); - wxSize sizeNow = dlg->GetSize(); - - // this relies on wxDefaultSize being -1,-1, be careful here. - if( sizeNow.GetWidth() < DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize.GetWidth() - || sizeNow.GetHeight() < DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize.GetHeight() ) - { - dlg->SetSize( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize ); - } - // make sure the chipnameTextCtrl is wide enough to hold any unusually long chip names: EnsureTextCtrlWidth( dlg->chipnameTextCtrl ); dlg->ShowModal(); - // Some of the field values are long and are not always fully visible because the - // window comes up too narrow. Remember user's manual window resizing efforts here - // so it comes up wide enough next time. - DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_LastSize = dlg->GetSize(); - m_canvas->MoveCursorToCrossHair(); m_canvas->SetIgnoreMouseEvents( false ); dlg->Destroy(); diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.h b/eeschema/dialogs/dialog_edit_component_in_schematic.h deleted file mode 100644 index 4711ed5b24..0000000000 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.h +++ /dev/null @@ -1,105 +0,0 @@ - -#ifndef __dialog_edit_component_in_schematic__ -#define __dialog_edit_component_in_schematic__ - - -#include -#include - -#include - - -class SCH_EDIT_FRAME; - - -/** - * class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC - * is hand coded and implements DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP which - * is maintained by wxFormBuilder. Do not auto-generate this class or file, - * it is hand coded. - */ -class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP -{ - friend class SCH_EDIT_FRAME; - - SCH_EDIT_FRAME* m_Parent; - SCH_COMPONENT* m_Cmp; - LIB_COMPONENT* m_LibEntry; - bool m_skipCopyFromPanel; - - static int s_SelectedRow; - - /// The size of the dialog window last time it was displayed; - static wxSize s_LastSize; - - /// a copy of the edited component's SCH_FIELDs - SCH_FIELDS m_FieldsBuf; - - void setSelectedFieldNdx( int aFieldNdx ); - - int getSelectedFieldNdx(); - - /** - * Function copySelectedFieldToPanel - * sets the values displayed on the panel according to - * the currently selected field row - */ - void copySelectedFieldToPanel(); - - - /** - * Function copyPanelToSelectedField - * copies the values displayed on the panel fields to the currently - * selected field - * @return bool - true if all fields are OK, else false if the user has put - * bad data into a field, and this value can be used to deny a row change. - */ - bool copyPanelToSelectedField(); - - void copyOptionsToPanel(); - - void copyPanelToOptions(); - - void setRowItem( int aFieldNdx, const SCH_FIELD& aField ); - - // event handlers - void OnListItemDeselected( wxListEvent& event ); - void OnListItemSelected( wxListEvent& event ); - void OnCancelButtonClick( wxCommandEvent& event ); - void OnOKButtonClick( wxCommandEvent& event ); - void SetInitCmp( wxCommandEvent& event ); - void addFieldButtonHandler( wxCommandEvent& event ); - void deleteFieldButtonHandler( wxCommandEvent& event ); - void moveUpButtonHandler( wxCommandEvent& event ); - - SCH_FIELD* findField( const wxString& aFieldName ); - - -protected: - - -public: - /** Constructor */ - DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow* parent ); - - /** - * Function InitBuffers - * sets up to edit the given component. - * @param aComponent The component to edit. - */ - void InitBuffers( SCH_COMPONENT* aComponent ); - -private: - /** - * Function updateDisplay - * update the listbox showing fields, according to the fields texts - * must be called after a text change in fields, if this change is not an edition - */ - void updateDisplay( ) - { - for( unsigned ii = FIELD1; iiSetSizeHints( wxDefaultSize, wxDefaultSize ); diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp index e4f7ca803d..aee5e6aa94 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp @@ -44,7 +44,7 @@ 700,496 wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU - ; + DIALOG_SHIM; dialog_shim.h Component Properties diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.h b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.h index 17b5e38ec6..895d108864 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 Oct 8 2012) +// C++ code generated with wxFormBuilder (version Apr 30 2013) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -11,6 +11,9 @@ #include #include #include +class DIALOG_SHIM; + +#include "dialog_shim.h" #include #include #include @@ -33,7 +36,7 @@ /////////////////////////////////////////////////////////////////////////////// /// Class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP /////////////////////////////////////////////////////////////////////////////// -class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public wxDialog +class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public DIALOG_SHIM { private: diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index 4e03d0fa27..24eef58c2c 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -468,9 +468,9 @@ void LIB_EDIT_FRAME::UpdatePartSelectList() { for( int i = 0; i < m_component->GetPartCount(); i++ ) { - wxString msg = LIB_COMPONENT::ReturnSubReference( i+1, false ); - msg.Printf( _( "Part %s" ), GetChars( msg ) ); - m_partSelectBox->Append( msg ); + wxString sub = LIB_COMPONENT::ReturnSubReference( i+1, false ); + wxString part = wxString::Format( _( "Part %s" ), GetChars( sub ) ); + m_partSelectBox->Append( part ); } } From 7f18b883ababc71450727d44bb6ddc0825c32205 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Thu, 6 Jun 2013 11:37:48 -0400 Subject: [PATCH 06/50] CvPcb filtering and other minor improvements. * Change filtering from single selection to logically and each filter type. * Remove clear filtering button and logic. * Filter buttons now behave as true toggle buttons. * Improve list control pane focus following when using arrow keys to change list pane. * Remove unused parameters from list box constructors. * Make tab key behave like right arrow key when moving focus to next list pane. * Make list pane focus wrap around to next or previous control. * Simplify component list filtering code. * Improve status bar updating. * Tell Bazaar to ignore .downloads-by-cmake instead of downloads-by-cmake. --- .bzrignore | 2 +- cvpcb/class_components_listbox.cpp | 129 ++++++----- cvpcb/class_footprints_listbox.cpp | 338 ++++++++--------------------- cvpcb/class_library_listbox.cpp | 131 +++++------ cvpcb/cvframe.cpp | 329 +++++++++++++++------------- cvpcb/cvpcb_mainframe.h | 9 +- cvpcb/cvstruct.h | 114 +++++++--- cvpcb/listboxes.cpp | 87 -------- cvpcb/tool_cvpcb.cpp | 20 +- pcbnew/netlist_reader.cpp | 18 ++ pcbnew/netlist_reader.h | 8 + 11 files changed, 519 insertions(+), 666 deletions(-) diff --git a/.bzrignore b/.bzrignore index 3e97e8ac23..de20aa512d 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1,5 +1,5 @@ include/boost -downloads-by-cmake +.downloads-by-cmake common/netlist_keywords.* common/netlist_lexer.h common/pcb_plot_params_lexer.h diff --git a/cvpcb/class_components_listbox.cpp b/cvpcb/class_components_listbox.cpp index 5f5db62d0a..1cc6a46ba9 100644 --- a/cvpcb/class_components_listbox.cpp +++ b/cvpcb/class_components_listbox.cpp @@ -1,6 +1,29 @@ -/*************************************************************************/ -/* listboxes.cpp: class for displaying footprint list and component list */ -/*************************************************************************/ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 1992-2012 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 class_components_listbox.h + */ #include #include @@ -8,15 +31,11 @@ #include #include #include +#include -/**************************************************/ -/* ListBox handling the schematic components list */ -/**************************************************/ - COMPONENTS_LISTBOX::COMPONENTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id, - const wxPoint& loc, const wxSize& size, - int nbitems, wxString choice[] ) : + const wxPoint& loc, const wxSize& size ) : ITEMS_LISTBOX_BASE( parent, id, loc, size, LISTB_STYLE & ~wxLC_SINGLE_SEL ) { } @@ -27,12 +46,10 @@ COMPONENTS_LISTBOX::~COMPONENTS_LISTBOX() } -/* Build the events table for the schematic components list box - */ - BEGIN_EVENT_TABLE( COMPONENTS_LISTBOX, ITEMS_LISTBOX_BASE ) EVT_SIZE( ITEMS_LISTBOX_BASE::OnSize ) EVT_CHAR( COMPONENTS_LISTBOX::OnChar ) + EVT_LIST_ITEM_SELECTED( ID_CVPCB_COMPONENT_LIST, COMPONENTS_LISTBOX::OnSelectComponent ) END_EVENT_TABLE() @@ -53,6 +70,7 @@ void COMPONENTS_LISTBOX::SetString( unsigned linecount, const wxString& text ) { if( linecount >= m_ComponentList.Count() ) linecount = m_ComponentList.Count() - 1; + if( linecount >= 0 ) m_ComponentList[linecount] = text; } @@ -65,19 +83,12 @@ void COMPONENTS_LISTBOX::AppendLine( const wxString& text ) } -/* - * Overlaid function: MUST be provided in wxLC_VIRTUAL mode - * because real data are not handled by ITEMS_LISTBOX_BASE - */ wxString COMPONENTS_LISTBOX::OnGetItemText( long item, long column ) const { return m_ComponentList.Item( item ); } -/* - * Enable or disable an item - */ void COMPONENTS_LISTBOX::SetSelection( unsigned index, bool State ) { if( (int) index >= GetCount() ) @@ -87,6 +98,7 @@ void COMPONENTS_LISTBOX::SetSelection( unsigned index, bool State ) { Select( index, State ); EnsureVisible( index ); + #ifdef __WXMAC__ Update(); #endif @@ -94,73 +106,74 @@ void COMPONENTS_LISTBOX::SetSelection( unsigned index, bool State ) } -/** - * Function OnChar - * called on a key pressed - * Call default handler for some special keys, - * and for "ascii" keys, select the first component - * that the name starts by the letter. - * This is the defaut behaviour of a listbox, but because we use - * virtual lists, the listbox does not know anything to what is displayed, - * we must handle this behaviour here. - * Furthermore the reference of components is not at the beginning of - * displayed lines (the first word is the line number) - */ void COMPONENTS_LISTBOX::OnChar( wxKeyEvent& event ) { int key = event.GetKeyCode(); + switch( key ) { - case WXK_HOME: - case WXK_END: - case WXK_UP: - case WXK_DOWN: - case WXK_PAGEUP: - case WXK_PAGEDOWN: - event.Skip(); - return; + case WXK_TAB: + case WXK_RIGHT: + case WXK_NUMPAD_RIGHT: + GetParent()->m_FootprintList->SetFocus(); + return; - case WXK_LEFT: - case WXK_NUMPAD_LEFT: - GetParent()->m_LibraryList->SetFocus(); - return; + case WXK_LEFT: + case WXK_NUMPAD_LEFT: + GetParent()->m_LibraryList->SetFocus(); + return; - case WXK_RIGHT: - case WXK_NUMPAD_RIGHT: - GetParent()->m_FootprintList->SetFocus(); - return; + case WXK_HOME: + case WXK_END: + case WXK_UP: + case WXK_DOWN: + case WXK_PAGEUP: + case WXK_PAGEDOWN: + event.Skip(); + return; - default: - break; + + default: + break; } // Search for an item name starting by the key code: - key = toupper(key); + key = toupper( key ); + for( unsigned ii = 0; ii < m_ComponentList.GetCount(); ii++ ) { - wxString text = m_ComponentList.Item(ii); - /* search for the start char of the footprint name. - * we must skip the line number - */ - text.Trim(false); // Remove leading spaces in line + wxString text = m_ComponentList.Item( ii ); + + // Search for the start char of the footprint name. Skip the line number. + text.Trim( false ); // Remove leading spaces in line unsigned jj = 0; + for( ; jj < text.Len(); jj++ ) { // skip line number if( text[jj] == ' ' ) break; } + for( ; jj < text.Len(); jj++ ) { // skip blanks if( text[jj] != ' ' ) break; } - int start_char = toupper(text[jj]); - if ( key == start_char ) + + int start_char = toupper( text[jj] ); + + if( key == start_char ) { Focus( ii ); SetSelection( ii, true ); // Ensure visible break; } } - +} + + +void COMPONENTS_LISTBOX::OnSelectComponent( wxListEvent& event ) +{ + SetFocus(); + GetParent()->OnSelectComponent( event ); } diff --git a/cvpcb/class_footprints_listbox.cpp b/cvpcb/class_footprints_listbox.cpp index 9ec56b0075..8d7ab4e930 100644 --- a/cvpcb/class_footprints_listbox.cpp +++ b/cvpcb/class_footprints_listbox.cpp @@ -36,21 +36,14 @@ #include #include #include +#include -/***************************************/ -/* ListBox handling the footprint list */ -/***************************************/ - FOOTPRINTS_LISTBOX::FOOTPRINTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id, const wxPoint& loc, - const wxSize& size, - int nbitems, wxString choice[] ) : + const wxSize& size ) : ITEMS_LISTBOX_BASE( parent, id, loc, size ) { - m_UseFootprintFullList = true; - m_ActiveFootprintList = NULL; - SetActiveFootprintList( true ); } @@ -59,24 +52,19 @@ FOOTPRINTS_LISTBOX::~FOOTPRINTS_LISTBOX() } -/* - * Return number of items - */ int FOOTPRINTS_LISTBOX::GetCount() { - return m_ActiveFootprintList->Count(); + return m_footprintList.Count(); } -/* - * Change an item text - */ void FOOTPRINTS_LISTBOX::SetString( unsigned linecount, const wxString& text ) { - if( linecount >= m_ActiveFootprintList->Count() ) - linecount = m_ActiveFootprintList->Count() - 1; + if( linecount >= m_footprintList.Count() ) + linecount = m_footprintList.Count() - 1; + if( linecount >= 0 ) - (*m_ActiveFootprintList)[linecount] = text; + m_footprintList[linecount] = text; } @@ -87,7 +75,7 @@ wxString FOOTPRINTS_LISTBOX::GetSelectedFootprint() if( ii >= 0 ) { - wxString msg = (*m_ActiveFootprintList)[ii]; + wxString msg = m_footprintList[ii]; msg.Trim( true ); msg.Trim( false ); footprintName = msg.AfterFirst( wxChar( ' ' ) ); @@ -99,24 +87,20 @@ wxString FOOTPRINTS_LISTBOX::GetSelectedFootprint() void FOOTPRINTS_LISTBOX::AppendLine( const wxString& text ) { - m_ActiveFootprintList->Add( text ); - SetItemCount( m_ActiveFootprintList->Count() ); + m_footprintList.Add( text ); + SetItemCount( m_footprintList.Count() ); } -/* - * Overlaid function: MUST be provided in wxLC_VIRTUAL mode - * because real data is not handled by ITEMS_LISTBOX_BASE - */ wxString FOOTPRINTS_LISTBOX::OnGetItemText( long item, long column ) const { - return m_ActiveFootprintList->Item( item ); + if( item < 0 || item >= (long)m_footprintList.GetCount() ) + return wxEmptyString; + + return m_footprintList.Item( item ); } -/* - * Enable or disable an item - */ void FOOTPRINTS_LISTBOX::SetSelection( unsigned index, bool State ) { if( (int) index >= GetCount() ) @@ -127,7 +111,9 @@ void FOOTPRINTS_LISTBOX::SetSelection( unsigned index, bool State ) #ifndef __WXMAC__ Select( index, State ); #endif + EnsureVisible( index ); + #ifdef __WXMAC__ Refresh(); #endif @@ -135,216 +121,79 @@ void FOOTPRINTS_LISTBOX::SetSelection( unsigned index, bool State ) } -void FOOTPRINTS_LISTBOX::SetFootprintFullList( FOOTPRINT_LIST& list ) +void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& aLibName, + COMPONENT* aComponent, int aFilterType ) { - wxString msg; - int oldSelection = GetSelection(); + wxArrayString newList; + wxString msg; + wxString oldSelection; - m_FullFootprintList.Clear(); + if( GetSelection() >= 0 && GetSelection() < (int)m_footprintList.GetCount() ) + oldSelection = m_footprintList[ GetSelection() ]; - for( unsigned ii = 0; ii < list.GetCount(); ii++ ) + for( unsigned ii = 0; ii < aList.GetCount(); ii++ ) { - FOOTPRINT_INFO & footprint = list.GetItem(ii); - msg.Printf( wxT( "%3zu %s" ), m_FullFootprintList.GetCount() + 1, - GetChars(footprint.m_Module) ); - m_FullFootprintList.Add( msg ); + if( aFilterType == UNFILTERED ) + { + msg.Printf( wxT( "%3zu %s" ), newList.GetCount() + 1, + GetChars( aList.GetItem( ii ).m_Module ) ); + newList.Add( msg ); + continue; + } + + if( (aFilterType & BY_LIBRARY) && !aLibName.IsEmpty() + && (aList.GetItem( ii ).m_libName != aLibName) ) + continue; + + if( (aFilterType & BY_COMPONENT) && (aComponent != NULL) + && !aComponent->MatchesFootprintFilters( aList.GetItem( ii ).m_Module ) ) + continue; + + if( (aFilterType & BY_PIN_COUNT) && (aComponent!= NULL) + && (aComponent->GetNetCount() != aList.GetItem( ii ).m_padCount) ) + continue; + + msg.Printf( wxT( "%3zu %s" ), newList.GetCount() + 1, + aList.GetItem( ii ).m_Module.GetData() ); + newList.Add( msg ); } - SetActiveFootprintList( true ); + if( newList == m_footprintList ) + return; - if( GetCount() == 0 || oldSelection < 0 || oldSelection >= GetCount() ) - SetSelection( 0, true ); + m_footprintList = newList; + + int selection = m_footprintList.Index( oldSelection ); + + if( selection == wxNOT_FOUND ) + selection = 0; + + DeleteAllItems(); + SetItemCount( m_footprintList.GetCount() ); + SetSelection( selection, true ); Refresh(); } -void FOOTPRINTS_LISTBOX::SetFootprintFilteredList( COMPONENT* aComponent, - FOOTPRINT_LIST& list ) -{ - wxString msg; - unsigned jj; - int OldSelection = GetSelection(); - bool hasItem = false; - - m_FilteredFootprintList.Clear(); - - for( unsigned ii = 0; ii < list.GetCount(); ii++ ) - { - FOOTPRINT_INFO& footprint = list.GetItem(ii); - // Search for matching footprints - // The search is case insensitive - wxString module = footprint.m_Module.Upper(); - wxString candidate; - - for( jj = 0; jj < aComponent->GetFootprintFilters().GetCount(); jj++ ) - { - candidate = aComponent->GetFootprintFilters()[jj].Upper(); - - if( !module.Matches( candidate ) ) - continue; - - msg.Printf( wxT( "%3zu %s" ), m_FilteredFootprintList.GetCount() + 1, - footprint.m_Module.GetData() ); - m_FilteredFootprintList.Add( msg ); - hasItem = true; - } - } - - if( hasItem ) - SetActiveFootprintList( false ); - else - SetActiveFootprintList( true ); - - if( ( GetCount() == 0 ) || ( OldSelection >= GetCount() ) ) - SetSelection( 0, true ); - - Refresh(); -} - - -void FOOTPRINTS_LISTBOX::SetFootprintFilteredByPinCount( COMPONENT* aComponent, - FOOTPRINT_LIST& list ) -{ - wxString msg; - int oldSelection = GetSelection(); - bool hasItem = false; - - m_FilteredFootprintList.Clear(); - - for( unsigned ii = 0; ii < list.GetCount(); ii++ ) - { - FOOTPRINT_INFO& footprint = list.GetItem(ii); - - if( aComponent->GetNetCount() == footprint.m_padCount ) - { - msg.Printf( wxT( "%3zu %s" ), m_FilteredFootprintList.GetCount() + 1, - footprint.m_Module.GetData() ); - m_FilteredFootprintList.Add( msg ); - hasItem = true; - } - } - - if( hasItem ) - SetActiveFootprintList( false ); - else - SetActiveFootprintList( true ); - - if( ( GetCount() == 0 ) || ( oldSelection >= GetCount() ) ) - SetSelection( 0, true ); - - Refresh(); -} - -void FOOTPRINTS_LISTBOX::SetFootprintFilteredByLibraryList( FOOTPRINT_LIST& list, - wxString SelectedLibrary ) { - wxString msg; - int oldSelection = GetSelection(); - bool hasItem = false; - - wxFileName filename = SelectedLibrary; - filename.SetExt( LegacyFootprintLibPathExtension ); - wxString FullLibraryName = wxGetApp().FindLibraryPath( filename ); - - m_FilteredFootprintList.Clear(); - - for( unsigned ii = 0; ii < list.GetCount(); ii++ ) - { - FOOTPRINT_INFO& footprint = list.GetItem(ii); - wxString LibName = footprint.m_libPath; - if( LibName.Matches( FullLibraryName ) ) - { - msg.Printf( wxT( "%3d %s" ), m_FilteredFootprintList.GetCount() + 1, - footprint.m_Module.GetData() ); - m_FilteredFootprintList.Add( msg ); - hasItem = true; - } - } - - if( hasItem ) - SetActiveFootprintList( false ); - else - SetActiveFootprintList( true ); - - if( ( GetCount() == 0 ) || ( oldSelection >= GetCount() ) ) - SetSelection( 0, true ); - - Refresh(); -} - -/** Set the footprint list. We can have 2 footprint list: - * The full footprint list - * The filtered footprint list (if the current selected component has a - * filter for footprints) - * @param FullList true = full footprint list, false = filtered footprint list - * @param Redraw = true to redraw the window - */ -void FOOTPRINTS_LISTBOX::SetActiveFootprintList( bool FullList, bool Redraw ) -{ - bool old_selection = m_UseFootprintFullList; - -#ifdef __WINDOWS__ - - /* Workaround for a curious bug in wxWidgets: - * if we switch from a long list of footprints to a short list (a - * filtered footprint list), and if the selected item is near the end - * of the long list, the new list is not displayed from the top of - * the list box - */ - if( m_ActiveFootprintList ) - { - bool new_selection; - - if( FullList ) - new_selection = true; - else - new_selection = false; - - if( new_selection != old_selection ) - SetSelection( 0, true ); - } -#endif - if( FullList ) - { - m_UseFootprintFullList = true; - m_ActiveFootprintList = &m_FullFootprintList; - SetItemCount( m_FullFootprintList.GetCount() ); - } - else - { - m_UseFootprintFullList = false; - m_ActiveFootprintList = &m_FilteredFootprintList; - SetItemCount( m_FilteredFootprintList.GetCount() ); - } - - if( Redraw ) - { - if( !m_UseFootprintFullList || ( m_UseFootprintFullList != old_selection ) ) - { - Refresh(); - } - } - - GetParent()->DisplayStatus(); -} - - -/**************************************/ -/* Event table for the footprint list */ -/**************************************/ - BEGIN_EVENT_TABLE( FOOTPRINTS_LISTBOX, ITEMS_LISTBOX_BASE ) EVT_SIZE( ITEMS_LISTBOX_BASE::OnSize ) EVT_CHAR( FOOTPRINTS_LISTBOX::OnChar ) + EVT_LIST_ITEM_SELECTED( ID_CVPCB_FOOTPRINT_LIST, FOOTPRINTS_LISTBOX::OnLeftClick ) + EVT_LIST_ITEM_ACTIVATED( ID_CVPCB_FOOTPRINT_LIST, FOOTPRINTS_LISTBOX::OnLeftDClick ) END_EVENT_TABLE() void FOOTPRINTS_LISTBOX::OnLeftClick( wxListEvent& event ) { + if( m_footprintList.IsEmpty() ) + return; + FOOTPRINT_INFO* Module; - wxString footprintName = GetSelectedFootprint(); + wxString footprintName = GetSelectedFootprint(); Module = GetParent()->m_footprints.GetModuleInfo( footprintName ); - wxASSERT(Module); + wxASSERT( Module ); + if( GetParent()->m_DisplayFootprintFrame ) { // Refresh current selected footprint view: @@ -354,11 +203,10 @@ void FOOTPRINTS_LISTBOX::OnLeftClick( wxListEvent& event ) if( Module ) { wxString msg; - msg = Module->m_Doc; + msg = _( "Description: " ) + Module->m_Doc; GetParent()->SetStatusText( msg, 0 ); - msg = wxT( "KeyW: " ); - msg += Module->m_KeyWord; + msg = _( "Key words: " ) + Module->m_KeyWord; GetParent()->SetStatusText( msg, 1 ); } } @@ -378,37 +226,39 @@ void FOOTPRINTS_LISTBOX::OnChar( wxKeyEvent& event ) switch( key ) { - case WXK_LEFT: - case WXK_NUMPAD_LEFT: - GetParent()->m_ListCmp->SetFocus(); - return; + case WXK_TAB: + case WXK_RIGHT: + case WXK_NUMPAD_RIGHT: + GetParent()->m_LibraryList->SetFocus(); + return; - case WXK_HOME: - case WXK_END: - case WXK_UP: - case WXK_DOWN: - case WXK_PAGEUP: - case WXK_PAGEDOWN: - case WXK_RIGHT: - case WXK_NUMPAD_RIGHT: - event.Skip(); - return; + case WXK_LEFT: + case WXK_NUMPAD_LEFT: + GetParent()->m_ListCmp->SetFocus(); + return; - default: - break; + case WXK_HOME: + case WXK_END: + case WXK_UP: + case WXK_DOWN: + case WXK_PAGEUP: + case WXK_PAGEDOWN: + event.Skip(); + return; + + default: + break; } // Search for an item name starting by the key code: - key = toupper(key); + key = toupper( key ); - for( unsigned ii = 0; ii < m_ActiveFootprintList->GetCount(); ii++ ) + for( unsigned ii = 0; ii < m_footprintList.GetCount(); ii++ ) { - wxString text = m_ActiveFootprintList->Item(ii); + wxString text = m_footprintList.Item( ii ); - /* search for the start char of the footprint name. - * we must skip the line number - */ - text.Trim(false); // Remove leading spaces in line + // Search for the start char of the footprint name. Skip the line number. + text.Trim( false ); // Remove leading spaces in line unsigned jj = 0; for( ; jj < text.Len(); jj++ ) diff --git a/cvpcb/class_library_listbox.cpp b/cvpcb/class_library_listbox.cpp index bab3f69da9..d9dc45e19a 100644 --- a/cvpcb/class_library_listbox.cpp +++ b/cvpcb/class_library_listbox.cpp @@ -33,19 +33,17 @@ #include #include #include +#include /***************************************/ /* ListBox handling the library list */ /***************************************/ -LIBRARY_LISTBOX::LIBRARY_LISTBOX( CVPCB_MAINFRAME* parent, - wxWindowID id, const wxPoint& loc, - const wxSize& size, - int nbitems, wxString choice[] ) : +LIBRARY_LISTBOX::LIBRARY_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id, + const wxPoint& loc, const wxSize& size ) : ITEMS_LISTBOX_BASE( parent, id, loc, size ) { - //ListLibraries(); } @@ -54,24 +52,19 @@ LIBRARY_LISTBOX::~LIBRARY_LISTBOX() } -/* - * Return number of items - */ int LIBRARY_LISTBOX::GetCount() { - return m_LibraryList.Count(); + return m_libraryList.Count(); } -/* - * Change an item text - */ void LIBRARY_LISTBOX::SetString( unsigned linecount, const wxString& text ) { - if( linecount >= m_LibraryList.Count() ) - linecount = m_LibraryList.Count() - 1; + if( linecount >= m_libraryList.Count() ) + linecount = m_libraryList.Count() - 1; + if( linecount >= 0 ) - m_LibraryList[linecount] = text; + m_libraryList[linecount] = text; } @@ -82,7 +75,7 @@ wxString LIBRARY_LISTBOX::GetSelectedLibrary() if( ii >= 0 ) { - libraryName = m_LibraryList[ii]; + libraryName = m_libraryList[ii]; } return libraryName; @@ -91,23 +84,17 @@ wxString LIBRARY_LISTBOX::GetSelectedLibrary() void LIBRARY_LISTBOX::AppendLine( const wxString& text ) { - m_LibraryList.Add( text ); - SetItemCount( m_LibraryList.Count() ); + m_libraryList.Add( text ); + SetItemCount( m_libraryList.Count() ); } -/* - * Overlaid function: MUST be provided in wxLC_VIRTUAL mode - * because real data is not handled by ITEMS_LISTBOX_BASE - */ wxString LIBRARY_LISTBOX::OnGetItemText( long item, long column ) const { - return m_LibraryList.Item( item ); + return m_libraryList.Item( item ); } -/* - * Enable or disable an item - */ + void LIBRARY_LISTBOX::SetSelection( unsigned index, bool State ) { if( (int) index >= GetCount() ) @@ -126,83 +113,69 @@ void LIBRARY_LISTBOX::SetSelection( unsigned index, bool State ) } -void LIBRARY_LISTBOX::SetLibraryList( wxArrayString list ) +void LIBRARY_LISTBOX::SetLibraryList( const wxArrayString& aList ) { - wxString msg; - int oldSelection = GetSelection(); + int oldSelection = GetSelection(); - m_LibraryList.Clear(); + m_libraryList = aList; - for( unsigned ii = 0; ii < list.GetCount(); ii++ ) - { - msg = list.Item(ii); - m_LibraryList.Add( msg ); - } - - SetItemCount(list.GetCount()); + SetItemCount( m_libraryList.GetCount() ); if( GetCount() == 0 || oldSelection < 0 || oldSelection >= GetCount() ) SetSelection( 0, true ); + Refresh(); } -/**************************************/ -/* Event table for the library list */ -/**************************************/ - BEGIN_EVENT_TABLE( LIBRARY_LISTBOX, ITEMS_LISTBOX_BASE ) EVT_SIZE( ITEMS_LISTBOX_BASE::OnSize ) EVT_CHAR( LIBRARY_LISTBOX::OnChar ) + EVT_LIST_ITEM_SELECTED( ID_CVPCB_LIBRARY_LIST, LIBRARY_LISTBOX::OnSelectLibrary ) END_EVENT_TABLE() -/** - * Function OnChar - * called on a key pressed - * Call default handler for some special keys, - * and for "ascii" keys, select the first footprint - * that the name starts by the letter. - * This is the defaut behaviour of a listbox, but because we use - * virtual lists, the listbox does not know anything to what is displayed, - * we must handle this behaviour here. - * Furthermore the footprint name is not at the beginning of - * displayed lines (the first word is the line number) - */ void LIBRARY_LISTBOX::OnChar( wxKeyEvent& event ) { int key = event.GetKeyCode(); + switch( key ) { - case WXK_RIGHT: - case WXK_NUMPAD_RIGHT: - GetParent()->m_ListCmp->SetFocus(); - return; + case WXK_TAB: + case WXK_RIGHT: + case WXK_NUMPAD_RIGHT: + GetParent()->m_ListCmp->SetFocus(); + return; - case WXK_HOME: - case WXK_END: - case WXK_UP: - case WXK_DOWN: - case WXK_PAGEUP: - case WXK_PAGEDOWN: - case WXK_LEFT: - case WXK_NUMPAD_LEFT: - event.Skip(); - return; + case WXK_LEFT: + case WXK_NUMPAD_LEFT: + GetParent()->m_FootprintList->SetFocus(); + return; - default: - break; + case WXK_HOME: + case WXK_END: + case WXK_UP: + case WXK_DOWN: + case WXK_PAGEUP: + case WXK_PAGEDOWN: + event.Skip(); + return; + + default: + break; } + // Search for an item name starting by the key code: key = toupper(key); - for( unsigned ii = 0; ii < m_LibraryList.GetCount(); ii++ ) + + for( unsigned ii = 0; ii < m_libraryList.GetCount(); ii++ ) { - wxString text = m_LibraryList.Item(ii); - /* search for the start char of the footprint name. - * we must skip the line number - */ - text.Trim(false); // Remove leading spaces in line + wxString text = m_libraryList.Item( ii ); + + // Search for the start char of the footprint name. Skip the line number. + text.Trim( false ); // Remove leading spaces in line unsigned jj = 0; + for( ; jj < text.Len(); jj++ ) { // skip line number @@ -217,6 +190,7 @@ void LIBRARY_LISTBOX::OnChar( wxKeyEvent& event ) } int start_char = toupper( text[jj] ); + if( key == start_char ) { Focus( ii ); @@ -225,3 +199,10 @@ void LIBRARY_LISTBOX::OnChar( wxKeyEvent& event ) } } } + + +void LIBRARY_LISTBOX::OnSelectLibrary( wxListEvent& event ) +{ + SetFocus(); + GetParent()->OnSelectComponent( event ); +} diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index cac9ad702b..795d2c55b6 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -87,20 +87,12 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME ) CVPCB_MAINFRAME::OnSelectFilteringFootprint ) EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, CVPCB_MAINFRAME::OnSelectFilteringFootprint ) - EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, - CVPCB_MAINFRAME::OnSelectFilteringFootprint ) // Frame events EVT_CHAR( CVPCB_MAINFRAME::OnChar ) EVT_CLOSE( CVPCB_MAINFRAME::OnCloseWindow ) EVT_SIZE( CVPCB_MAINFRAME::OnSize ) - // List item events - EVT_LIST_ITEM_SELECTED( ID_CVPCB_FOOTPRINT_LIST, CVPCB_MAINFRAME::OnLeftClick ) - EVT_LIST_ITEM_ACTIVATED( ID_CVPCB_FOOTPRINT_LIST, CVPCB_MAINFRAME::OnLeftDClick ) - EVT_LIST_ITEM_SELECTED( ID_CVPCB_COMPONENT_LIST, CVPCB_MAINFRAME::OnSelectComponent ) - EVT_LIST_ITEM_SELECTED( ID_CVPCB_LIBRARY_LIST, CVPCB_MAINFRAME::OnSelectComponent ) - EVT_UPDATE_UI( ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, CVPCB_MAINFRAME::OnUpdateKeepOpenOnSave ) END_EVENT_TABLE() @@ -111,14 +103,13 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) : EDA_BASE_FRAME( NULL, CVPCB_FRAME_TYPE, title, wxDefaultPosition, wxDefaultSize, style, CVPCB_MAINFRAME_NAME ) { - m_FrameName = CVPCB_MAINFRAME_NAME; - - m_ListCmp = NULL; - m_FootprintList = NULL; - m_LibraryList = NULL; + m_FrameName = CVPCB_MAINFRAME_NAME; + m_ListCmp = NULL; + m_FootprintList = NULL; + m_LibraryList = NULL; m_DisplayFootprintFrame = NULL; - m_mainToolBar = NULL; - m_modified = false; + m_mainToolBar = NULL; + m_modified = false; m_isEESchemaNetlist = false; m_KeepCvpcbOpen = false; m_undefinedComponentCnt = 0; @@ -200,22 +191,6 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) : CVPCB_MAINFRAME::~CVPCB_MAINFRAME() { - wxConfig* config = wxGetApp().GetSettings(); - - if( config ) - { - int state = 0; - if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) ) - { - state = 1; - } - else if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST ) ) - { - state = 2; - } - config->Write( wxT( FILTERFOOTPRINTKEY ), state ); - } - m_auimgr.UnInit(); } @@ -242,6 +217,19 @@ void CVPCB_MAINFRAME::SaveSettings() EDA_BASE_FRAME::SaveSettings(); cfg->Write( KeepCvpcbOpenEntry, m_KeepCvpcbOpen ); cfg->Write( FootprintDocFileEntry, m_DocModulesFileName ); + + int state = 0; + + if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) ) + state |= FOOTPRINTS_LISTBOX::BY_COMPONENT; + + if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST ) ) + state |= FOOTPRINTS_LISTBOX::BY_PIN_COUNT; + + if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST ) ) + state |= FOOTPRINTS_LISTBOX::BY_LIBRARY; + + cfg->Write( wxT( FILTERFOOTPRINTKEY ), state ); } @@ -508,91 +496,46 @@ void CVPCB_MAINFRAME::DisplayDocFile( wxCommandEvent& event ) } -void CVPCB_MAINFRAME::OnLeftClick( wxListEvent& event ) -{ - m_FootprintList->OnLeftClick( event ); -} - - -void CVPCB_MAINFRAME::OnLeftDClick( wxListEvent& event ) -{ - m_FootprintList->OnLeftDClick( event ); -} - - -/* Called when clicking on a component in component list window - * * Updates the filtered footprint list, if the filtered list option is selected - * * Updates the current selected footprint in footprint list - * * Updates the footprint shown in footprint display window (if opened) - */ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event ) { if( m_skipComponentSelect ) return; - #define REDRAW_LIST true - #define SELECT_FULL_LIST true - int selection = -1; - wxString SelectedLibrary; + wxString libraryName; + COMPONENT* component = NULL; + int filter = FOOTPRINTS_LISTBOX::UNFILTERED; - if( !m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) - && !m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST ) - && !m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST ) - ) - m_FootprintList->SetActiveFootprintList( SELECT_FULL_LIST, REDRAW_LIST ); + if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) ) + filter |= FOOTPRINTS_LISTBOX::BY_COMPONENT; - else - { - selection = m_ListCmp->GetSelection(); + if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST ) ) + filter |= FOOTPRINTS_LISTBOX::BY_PIN_COUNT; - if( selection < 0 ) - m_FootprintList->SetActiveFootprintList( SELECT_FULL_LIST, REDRAW_LIST ); + if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST ) ) + filter |= FOOTPRINTS_LISTBOX::BY_LIBRARY; - else - { - if( m_netlist.GetComponent( selection ) == NULL ) - m_FootprintList->SetActiveFootprintList( SELECT_FULL_LIST, REDRAW_LIST ); - else - { - if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST ) ) - { - m_FootprintList->SetFootprintFilteredByPinCount( m_netlist.GetComponent( selection ), - m_footprints ); - } - else - if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST ) ) - { - SelectedLibrary=m_LibraryList->GetSelectedLibrary(); - m_FootprintList->SetFootprintFilteredByLibraryList( m_footprints, SelectedLibrary ); - } - else - { - m_FootprintList->SetFootprintFilteredList( m_netlist.GetComponent( selection ), - m_footprints ); - } - } - } - } + component = GetSelectedComponent(); + libraryName = m_LibraryList->GetSelectedLibrary(); + m_FootprintList->SetFootprints( m_footprints, libraryName, component, filter ); - selection = m_ListCmp->GetSelection(); - - if( selection < 0 ) + if( component == NULL ) return; // Preview of the already assigned footprint. - // Find the footprint that was already choosen for this component and select it, - // but only if the selection is made from the component list. - // If the selection is made from the footprint list, do not change the current selected footprint. + // Find the footprint that was already chosen for this component and select it, + // but only if the selection is made from the component list. If the selection is + // made from the footprint list, do not change the current selected footprint. - if( FindFocus() == m_ListCmp ) + if( FindFocus() == m_ListCmp ) { - wxString module = m_netlist.GetComponent( selection )->GetFootprintName(); + wxString module = component->GetFootprintName(); bool found = false; + for( int ii = 0; ii < m_FootprintList->GetCount(); ii++ ) { wxString footprintName; - wxString msg = (*m_FootprintList->m_ActiveFootprintList)[ii]; + wxString msg = m_FootprintList->OnGetItemText( ii, 0 ); msg.Trim( true ); msg.Trim( false ); footprintName = msg.AfterFirst( wxChar( ' ' ) ); @@ -604,11 +547,14 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event ) break; } } - if( ! found ) + + if( !found ) { int ii = m_FootprintList->GetSelection(); + if ( ii >= 0 ) m_FootprintList->SetSelection( ii, false ); + if( m_DisplayFootprintFrame ) { CreateScreenCmp(); @@ -623,36 +569,6 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event ) void CVPCB_MAINFRAME::OnSelectFilteringFootprint( wxCommandEvent& event ) { - switch( event.GetId() ) - { - case ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST: - m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, false ); - m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, false ); - m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, false ); - break; - - case ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST: - m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, false ); - m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST, false ); - m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, false ); - break; - - case ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST: - m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, false ); - m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST, false ); - m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, false ); - break; - - case ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST: - m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, false ); - m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, false ); - m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST, false ); - break; - - default: - break; - } - wxListEvent l_event; OnSelectComponent( l_event ); @@ -667,35 +583,70 @@ void CVPCB_MAINFRAME::OnUpdateKeepOpenOnSave( wxUpdateUIEvent& event ) void CVPCB_MAINFRAME::DisplayStatus() { - wxString msg; + wxString msg; + COMPONENT* component; - msg.Printf( _( "Components: %d (free: %d)" ), (int) m_netlist.GetCount(), + msg.Printf( _( "Components: %d, unassigned: %d" ), (int) m_netlist.GetCount(), m_undefinedComponentCnt ); SetStatusText( msg, 0 ); - SetStatusText( wxEmptyString, 1 ); + msg.Empty(); + + component = GetSelectedComponent(); + + if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) && component ) + { + for( unsigned ii = 0; ii < component->GetFootprintFilters().GetCount(); ii++ ) + { + if( msg.IsEmpty() ) + msg += component->GetFootprintFilters()[ii]; + else + msg += wxT( ", " ) + component->GetFootprintFilters()[ii]; + } + + msg = _( "Filter list: " ) + msg; + } + + SetStatusText( msg, 1 ); + + msg.Empty(); if( m_FootprintList ) { - if( m_FootprintList->m_UseFootprintFullList ) - msg.Printf( _( "Footprints (All): %d" ), - (int) m_FootprintList->m_ActiveFootprintList->GetCount() ); - else - msg.Printf( _( "Footprints (filtered): %d" ), - (int) m_FootprintList->m_ActiveFootprintList->GetCount() ); - } - else - { - msg.Empty(); - } + if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) ) + msg = _( "key words" ); - SetStatusText( msg, 2 ); + if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST ) ) + { + if( !msg.IsEmpty() ) + msg += wxT( ", " ); + + msg += _( "pin count" ); + } + + if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST ) ) + { + if( !msg.IsEmpty() ) + msg += wxT( ", " ); + + msg += _( "library" ); + } + + if( msg.IsEmpty() ) + msg = _( "No filtering" ); + else + msg = _( "Filtered by " ) + msg; + + msg << wxT( ": " ) << m_FootprintList->GetCount(); + + SetStatusText( msg, 2 ); + } } bool CVPCB_MAINFRAME::LoadFootprintFiles() { - /* Check if there are footprint libraries in project file */ + // Check if there are footprint libraries in project file. if( m_ModuleLibNames.GetCount() == 0 ) { wxMessageBox( _( "No PCB footprint libraries are listed in the current project file." ), @@ -705,10 +656,10 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles() m_footprints.ReadFootprintFiles( m_ModuleLibNames ); - /* Display error messages, if any */ + // Display error messages, if any. if( !m_footprints.m_filesNotFound.IsEmpty() || !m_footprints.m_filesInvalid.IsEmpty() ) { - HTML_MESSAGE_BOX dialog( this, _("Load Error") ); + HTML_MESSAGE_BOX dialog( this, _( "Load Error" ) ); if( !m_footprints.m_filesNotFound.IsEmpty() ) { @@ -717,7 +668,7 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles() dialog.ListSet( m_footprints.m_filesNotFound ); } - /* Display if there are invalid files */ + // Display if there are invalid files. if( !m_footprints.m_filesInvalid.IsEmpty() ) { dialog.MessageSet( _( "Some files are invalid!" ) ); @@ -815,7 +766,6 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist() return 1; } - // We also remove footprint name if it is "$noname" because this is a dummy name, // not the actual name of the footprint. for( unsigned ii = 0; ii < m_netlist.GetCount(); ii++ ) @@ -831,7 +781,7 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist() } -/* File header. */ +// File header. static char HeaderLinkFile[] = { "Cmp-Mod V01" }; @@ -900,3 +850,86 @@ void CVPCB_MAINFRAME::CreateScreenCmp() m_DisplayFootprintFrame->InitDisplay(); } + + +void CVPCB_MAINFRAME::BuildFOOTPRINTS_LISTBOX() +{ + wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); + + if( m_FootprintList == NULL ) + { + m_FootprintList = new FOOTPRINTS_LISTBOX( this, ID_CVPCB_FOOTPRINT_LIST, + wxDefaultPosition, wxDefaultSize ); + m_FootprintList->SetFont( wxFont( guiFont.GetPointSize(), + wxFONTFAMILY_MODERN, + wxFONTSTYLE_NORMAL, + wxFONTWEIGHT_NORMAL ) ); + } + + m_FootprintList->SetFootprints( m_footprints, wxEmptyString, NULL, + FOOTPRINTS_LISTBOX::UNFILTERED ); + DisplayStatus(); +} + + +void CVPCB_MAINFRAME::BuildCmpListBox() +{ + wxString msg; + COMPONENT* component; + wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); + + if( m_ListCmp == NULL ) + { + m_ListCmp = new COMPONENTS_LISTBOX( this, ID_CVPCB_COMPONENT_LIST, + wxDefaultPosition, wxDefaultSize ); + m_ListCmp->SetFont( wxFont( guiFont.GetPointSize(), + wxFONTFAMILY_MODERN, + wxFONTSTYLE_NORMAL, + wxFONTWEIGHT_NORMAL ) ); + } + + m_ListCmp->m_ComponentList.Clear(); + + for( unsigned i = 0; i < m_netlist.GetCount(); i++ ) + { + component = m_netlist.GetComponent( i ); + + msg.Printf( CMP_FORMAT, m_ListCmp->GetCount() + 1, + GetChars( component->GetReference() ), + GetChars( component->GetValue() ), + GetChars( component->GetFootprintName() ) ); + m_ListCmp->m_ComponentList.Add( msg ); + } + + m_ListCmp->SetItemCount( m_ListCmp->m_ComponentList.Count() ); + m_ListCmp->SetSelection( 0, true ); +} + + +void CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX() +{ + wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); + + if( m_LibraryList == NULL ) + { + m_LibraryList = new LIBRARY_LISTBOX( this, ID_CVPCB_LIBRARY_LIST, + wxDefaultPosition, wxDefaultSize ); + m_LibraryList->SetFont( wxFont( guiFont.GetPointSize(), + wxFONTFAMILY_MODERN, + wxFONTSTYLE_NORMAL, + wxFONTWEIGHT_NORMAL ) ); + } + + m_LibraryList->SetLibraryList( m_ModuleLibNames ); +} + + +COMPONENT* CVPCB_MAINFRAME::GetSelectedComponent() +{ + int selection = m_ListCmp->GetSelection(); + + if( selection >= 0 && selection < (int) m_netlist.GetCount() ) + return m_netlist.GetComponent( selection ); + + return NULL; +} diff --git a/cvpcb/cvpcb_mainframe.h b/cvpcb/cvpcb_mainframe.h index c72a3beb96..b963d5a2e9 100644 --- a/cvpcb/cvpcb_mainframe.h +++ b/cvpcb/cvpcb_mainframe.h @@ -45,6 +45,7 @@ class FOOTPRINTS_LISTBOX; class COMPONENTS_LISTBOX; class LIBRARY_LISTBOX; class DISPLAY_FOOTPRINTS_FRAME; +class COMPONENT; /** @@ -52,8 +53,9 @@ class DISPLAY_FOOTPRINTS_FRAME; */ class CVPCB_MAINFRAME : public EDA_BASE_FRAME { -public: + wxArrayString m_footprintListEntries; +public: bool m_KeepCvpcbOpen; FOOTPRINTS_LISTBOX* m_FootprintList; LIBRARY_LISTBOX* m_LibraryList; @@ -81,9 +83,6 @@ public: CVPCB_MAINFRAME( const wxString& title, long style = KICAD_DEFAULT_DRAWFRAME_STYLE ); ~CVPCB_MAINFRAME(); - void OnLeftClick( wxListEvent& event ); - void OnLeftDClick( wxListEvent& event ); - /** * Function OnSelectComponent * Called when clicking on a component in component list window @@ -275,6 +274,8 @@ public: */ void SendMessageToEESCHEMA(); + COMPONENT* GetSelectedComponent(); + DECLARE_EVENT_TABLE() }; diff --git a/cvpcb/cvstruct.h b/cvpcb/cvstruct.h index 2335b75c0c..a2d2eb7701 100644 --- a/cvpcb/cvstruct.h +++ b/cvpcb/cvstruct.h @@ -29,6 +29,7 @@ #define CVSTRUCT_H #include + #include /* Forward declarations of all top-level window classes. */ @@ -45,58 +46,64 @@ class ITEMS_LISTBOX_BASE : public wxListView public: ITEMS_LISTBOX_BASE( CVPCB_MAINFRAME* aParent, wxWindowID aId, const wxPoint& aLocation, const wxSize& aSize, - long aStyle = wxLC_SINGLE_SEL); + long aStyle = wxLC_SINGLE_SEL ); ~ITEMS_LISTBOX_BASE(); - int GetSelection(); - void OnSize( wxSizeEvent& event ); + int GetSelection(); + void OnSize( wxSizeEvent& event ); virtual CVPCB_MAINFRAME* GetParent(); }; + /******************************************/ /* ListBox showing the list of footprints */ /******************************************/ - class FOOTPRINTS_LISTBOX : public ITEMS_LISTBOX_BASE { private: - wxArrayString m_FullFootprintList; - wxArrayString m_FilteredFootprintList; -public: - wxArrayString* m_ActiveFootprintList; - bool m_UseFootprintFullList; + wxArrayString m_footprintList; public: + enum FP_FILTER_T + { + UNFILTERED = 0, + BY_COMPONENT = 0x0001, + BY_PIN_COUNT = 0x0002, + BY_LIBRARY = 0x0004, + }; + FOOTPRINTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id, - const wxPoint& loc, const wxSize& size, - int nbitems, wxString choice[] ); + const wxPoint& loc, const wxSize& size ); ~FOOTPRINTS_LISTBOX(); int GetCount(); void SetSelection( unsigned index, bool State = true ); void SetString( unsigned linecount, const wxString& text ); void AppendLine( const wxString& text ); - void SetFootprintFullList( FOOTPRINT_LIST& list ); - void SetFootprintFilteredList( COMPONENT* aComponent, - FOOTPRINT_LIST& aList ); - void SetFootprintFilteredByPinCount( COMPONENT* aComponent, - FOOTPRINT_LIST& aList ); - void SetFootprintFilteredByLibraryList( FOOTPRINT_LIST& list, - wxString SelectedLibrary ); /** - * Set the footprint list. We can have 2 footprint list: - * The full footprint list - * The filtered footprint list (if the current selected component has a - * filter for footprints) - * @param FullList true = full footprint list, false = filtered footprint list - * @param Redraw = true to redraw the window + * Function SetFootprints + * populates the wxListCtrl with the footprints from \a aList that meet the filter + * criteria defined by \a aFilterType. + * + * @param aList is a #FOOTPRINT_LIST item containing the footprints. + * @param aLibName is wxString containing the name of the selected library. Can be + * wxEmptyString. + * @param aComponent is the #COMPONENT used by the filtering criteria. Can be NULL. + * @param aFilterType defines the criteria to filter \a aList. */ - void SetActiveFootprintList( bool FullList, bool Redraw = false ); + void SetFootprints( FOOTPRINT_LIST& aList, const wxString& aLibName, + COMPONENT* aComponent, int aFilterType ); wxString GetSelectedFootprint(); + + /** + * Function OnGetItemText + * this overloaded function MUST be provided for the wxLC_VIRTUAL mode + * because real data is not handled by ITEMS_LISTBOX_BASE + */ wxString OnGetItemText( long item, long column ) const; // Events functions: @@ -107,43 +114,54 @@ public: DECLARE_EVENT_TABLE() }; + /******************************************/ /* ListBox showing the list of library */ /******************************************/ - class LIBRARY_LISTBOX : public ITEMS_LISTBOX_BASE { -//private: - -public: - wxArrayString m_LibraryList; + wxArrayString m_libraryList; public: LIBRARY_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id, - const wxPoint& loc, const wxSize& size, - int nbitems, wxString choice[] ); + const wxPoint& loc, const wxSize& size ); ~LIBRARY_LISTBOX(); int GetCount(); void SetSelection( unsigned index, bool State = true ); void SetString( unsigned linecount, const wxString& text ); void AppendLine( const wxString& text ); - void SetLibraryList( wxArrayString list ); + void SetLibraryList( const wxArrayString& aList ); wxString GetSelectedLibrary(); wxString OnGetItemText( long item, long column ) const; // Events functions: void OnLeftClick( wxListEvent& event ); + + void OnSelectLibrary( wxListEvent& event ); + + /** + * Function OnChar + * called on a key pressed + * Call default handler for some special keys, + * and for "ascii" keys, select the first footprint + * that the name starts by the letter. + * This is the defaut behaviour of a listbox, but because we use + * virtual lists, the listbox does not know anything to what is displayed, + * we must handle this behaviour here. + * Furthermore the footprint name is not at the beginning of + * displayed lines (the first word is the line number) + */ void OnChar( wxKeyEvent& event ); DECLARE_EVENT_TABLE() }; + /****************************************************/ /* ListBox showing the list of schematic components */ /****************************************************/ - class COMPONENTS_LISTBOX : public ITEMS_LISTBOX_BASE { public: @@ -153,21 +171,45 @@ public: public: COMPONENTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id, - const wxPoint& loc, const wxSize& size, - int nbitems, wxString choice[] ); + const wxPoint& loc, const wxSize& size ); ~COMPONENTS_LISTBOX(); void Clear(); int GetCount(); + + /** + * Function OnGetItemText + * this overloaded function MUST be provided for the wxLC_VIRTUAL mode + * because real data is not handled by ITEMS_LISTBOX_BASE + */ wxString OnGetItemText( long item, long column ) const; + + /* + * Enable or disable an item + */ void SetSelection( unsigned index, bool State = true ); void SetString( unsigned linecount, const wxString& text ); void AppendLine( const wxString& text ); // Events functions: + + /** + * Function OnChar + * called on a key pressed + * Call default handler for some special keys, + * and for "ascii" keys, select the first component + * that the name starts by the letter. + * This is the default behavior of a listbox, but because we use + * virtual lists, the listbox does not know anything to what is displayed, + * we must handle this behavior here. + * Furthermore the reference of components is not at the beginning of + * displayed lines (the first word is the line number) + */ void OnChar( wxKeyEvent& event ); + void OnSelectComponent( wxListEvent& event ); + DECLARE_EVENT_TABLE() }; diff --git a/cvpcb/listboxes.cpp b/cvpcb/listboxes.cpp index 803ba01156..d36d921625 100644 --- a/cvpcb/listboxes.cpp +++ b/cvpcb/listboxes.cpp @@ -83,90 +83,3 @@ CVPCB_MAINFRAME* ITEMS_LISTBOX_BASE::GetParent() { return (CVPCB_MAINFRAME*) wxListView::GetParent(); } - - -/* - * Create or update the schematic components list. - */ -void CVPCB_MAINFRAME::BuildCmpListBox() -{ - COMPONENT* component; - wxString msg; - wxSize size( 10, 10 ); - wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); - - if( m_ListCmp == NULL ) - { - m_ListCmp = new COMPONENTS_LISTBOX( this, ID_CVPCB_COMPONENT_LIST, - wxDefaultPosition, size, - 0, NULL ); - m_ListCmp->SetFont( wxFont( guiFont.GetPointSize(), - wxFONTFAMILY_MODERN, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_NORMAL ) ); - } - - m_ListCmp->m_ComponentList.Clear(); - - for( unsigned i = 0; i < m_netlist.GetCount(); i++ ) - { - component = m_netlist.GetComponent( i ); - - msg.Printf( CMP_FORMAT, m_ListCmp->GetCount() + 1, - GetChars( component->GetReference() ), - GetChars( component->GetValue() ), - GetChars( component->GetFootprintName() ) ); - m_ListCmp->m_ComponentList.Add( msg ); - } - - m_ListCmp->SetItemCount( m_ListCmp->m_ComponentList.Count() ); - m_ListCmp->SetSelection( 0, true ); -} - - -/* - * Create or update the footprint list. - */ -void CVPCB_MAINFRAME::BuildFOOTPRINTS_LISTBOX() -{ - wxString msg; - wxSize size( 10, 10 ); - wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); - - if( m_FootprintList == NULL ) - { - m_FootprintList = new FOOTPRINTS_LISTBOX( this, ID_CVPCB_FOOTPRINT_LIST, - wxDefaultPosition, size, - 0, NULL ); - m_FootprintList->SetFont( wxFont( guiFont.GetPointSize(), - wxFONTFAMILY_MODERN, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_NORMAL ) ); - } - - m_FootprintList->SetFootprintFullList( m_footprints ); - DisplayStatus(); -} - -/* - * Create or update the library list. - */ -void CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX() -{ - wxString msg; - wxSize size( 10, 10 ); - wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); - - if( m_LibraryList == NULL ) - { - m_LibraryList = new LIBRARY_LISTBOX( this, ID_CVPCB_LIBRARY_LIST, - wxDefaultPosition, size, - 0 , NULL ); - m_LibraryList->SetFont( wxFont( guiFont.GetPointSize(), - wxFONTFAMILY_MODERN, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_NORMAL ) ); - } - - m_LibraryList->SetLibraryList( m_ModuleLibNames ); -} diff --git a/cvpcb/tool_cvpcb.cpp b/cvpcb/tool_cvpcb.cpp index 796351f165..700e344c0e 100644 --- a/cvpcb/tool_cvpcb.cpp +++ b/cvpcb/tool_cvpcb.cpp @@ -94,36 +94,30 @@ void CVPCB_MAINFRAME::ReCreateHToolbar() KiBitmap( module_filtered_list_xpm ), wxNullBitmap, true, NULL, - _( "Display the filtered footprint list for the current component" ), + _( "Filter the footprint list for the current component key words" ), wxEmptyString ); m_mainToolBar->AddTool( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST, KiBitmap( module_pin_filtered_list_xpm ), wxNullBitmap, true, NULL, - _( "Display the filtered footprint list by pin count for the current component" ), + _( "Filter the footprint list by pin count for the current component" ), wxEmptyString ); m_mainToolBar->AddTool( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, KiBitmap( module_library_list_xpm ), wxNullBitmap, true, NULL, - _( "Display the footprint list from selected library" ), - wxEmptyString ); - - m_mainToolBar->AddTool( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, - KiBitmap( module_full_list_xpm ), - wxNullBitmap, true, NULL, - _( "Display the full footprint list (without filtering)" ), + _( "Filter the footprint list by the selected library" ), wxEmptyString ); if( config ) { wxString key = wxT( FILTERFOOTPRINTKEY ); int opt = config->Read( key, (long) 1 ); - m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, opt == 3 ); - m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST, opt == 2 ); - m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, opt == 1 ); - m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, opt == 0 ); + + m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, opt & 4 ); + m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST, opt & 2 ); + m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, opt & 1 ); } // after adding the buttons to the toolbar, must call Realize() to reflect the changes diff --git a/pcbnew/netlist_reader.cpp b/pcbnew/netlist_reader.cpp index a62b086382..9f1888d798 100644 --- a/pcbnew/netlist_reader.cpp +++ b/pcbnew/netlist_reader.cpp @@ -92,6 +92,24 @@ const COMPONENT_NET& COMPONENT::GetNet( const wxString& aPinName ) } +bool COMPONENT::MatchesFootprintFilters( const wxString& aFootprintName ) const +{ + if( m_footprintFilters.GetCount() == 0 ) + return true; + + // The matching is case insensitive + wxString name = aFootprintName.Upper(); + + for( unsigned ii = 0; ii < m_footprintFilters.GetCount(); ii++ ) + { + if( name.Matches( m_footprintFilters[ii].Upper() ) ) + return true; + } + + return false; +} + + #if defined(DEBUG) void COMPONENT::Show( int aNestLevel, REPORTER& aReporter ) { diff --git a/pcbnew/netlist_reader.h b/pcbnew/netlist_reader.h index 72c6101a37..f1cbfa6632 100644 --- a/pcbnew/netlist_reader.h +++ b/pcbnew/netlist_reader.h @@ -197,6 +197,14 @@ public: const wxArrayString& GetFootprintFilters() const { return m_footprintFilters; } + /** + * Function MatchesFootprintFilters + * + * @return true if \a aFootprintName matches any of the footprint filters or no footprint + * filters are defined. + */ + bool MatchesFootprintFilters( const wxString& aFootprintName ) const; + MODULE* GetModule( bool aRelease = false ) { return ( aRelease ) ? m_footprint.release() : m_footprint.get(); From 7432d4de29dbeb5f019b0846d71a54acb0a37c1d Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 6 Jun 2013 20:03:29 +0200 Subject: [PATCH 07/50] Page layout: add comments, and fix a very minor issue. Eeschema, dialog netlist: fix a bug when removing a plugin panel, when is is not the last. dialog netlist:Add a predefined command string for python scripts, when creating a new netlist plugin entry. --- common/page_layout_default_description.cpp | 25 +++++++++- common/title_block_shapes.cpp | 12 ++--- eeschema/dialogs/dialog_netlist.cpp | 55 ++++++++++++---------- include/worksheet_shape_builder.h | 10 ++++ 4 files changed, 68 insertions(+), 34 deletions(-) diff --git a/common/page_layout_default_description.cpp b/common/page_layout_default_description.cpp index 2b7623b971..8b9b93633e 100644 --- a/common/page_layout_default_description.cpp +++ b/common/page_layout_default_description.cpp @@ -104,6 +104,27 @@ * and the full text x size to the maxlen value. * If the actual text size is smaller than limits, its size is not modified. * + * Texts can include a format symbol, a la printf. + * At run time these format symbols will be replaced by their actual value. + * + * format symbols are: + * + * %% = replaced by % + * %K = Kicad version + * %Z = paper format name (A4, USLetter ...) + * %Y = company name + * %D = date + * %R = revision + * %S = sheet number + * %N = number of sheets + * %Cx = comment (x = 0 to 9 to identify the comment) + * %F = filename + * %P = sheet path (sheet full name) + * %T = title + * + * example: + * (tbtext \"Size: %Z\" ...) displays "Size A4" or Size USLetter" + * */ #include // defaultPageLayout @@ -133,11 +154,11 @@ const char defaultPageLayout[] = "( page_layout\n" "(line (start 110 5.5) end 2 5.5) )\n" "(tbtext \"%K\" (pos 109 4.1) (comment Kicad version ) )\n" "(line (start 110 8.5) end 2 8.5) )\n" -"(tbtext \"Rev: %R\" (pos 24 6.9)(font bold italic)(justify left) )\n" +"(tbtext \"Rev: %R\" (pos 24 6.9)(font bold)(justify left) )\n" "(tbtext \"Size: %Z\" (comment Paper format name)(pos 109 6.9) )\n" "(tbtext \"Id: %S/%N\" (comment Sheet id)(pos 24 4.1) )\n" "(line (start 110 12.5) end 2 12.5) )\n" -"(tbtext \"Title: %T\" (pos 109 10.7)(font bold (size 2 2)) )\n" +"(tbtext \"Title: %T\" (pos 109 10.7)(font bold italic (size 2 2)) )\n" "(tbtext \"File: %F\" (pos 109 14.3) )\n" "(line (start 110 18.5) end 2 18.5) )\n" "(tbtext \"Sheet: %P\" (pos 109 17) )\n" diff --git a/common/title_block_shapes.cpp b/common/title_block_shapes.cpp index f9419894b9..6a3ac779f7 100644 --- a/common/title_block_shapes.cpp +++ b/common/title_block_shapes.cpp @@ -225,8 +225,6 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( WS_DRAW_ITEM_TEXT* gtext; int pensize; - bool bold; - bool italic = false; EDA_COLOR_T color; for( unsigned ii = 0; ; ii++ ) @@ -245,7 +243,6 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( if( wsText->m_FullText.IsEmpty() ) break; - bold = false; pensize = wsText->GetPenSizeUi(); if( pensize == 0 ) @@ -264,11 +261,8 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( textsize.y = KiROUND( wsText->m_ConstrainedTextSize.y * WORKSHEET_DATAITEM::m_WSunits2Iu ); - if( wsText->m_Flags & USE_BOLD ) - { - bold = true; + if( wsText->IsBold()) pensize = GetPenSizeForBold( std::min( textsize.x, textsize.y ) ); - } for( int jj = 0; jj < wsText->m_RepeatCount; ) { @@ -277,7 +271,9 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( Append( gtext = new WS_DRAW_ITEM_TEXT( wsText->m_FullText, wsText->GetStartPosUi( jj ), textsize, - pensize, color, italic, bold ) ); + pensize, color, + wsText->IsItalic(), + wsText->IsBold() ) ); wsText->TransfertSetupToGraphicText( gtext ); jj++; diff --git a/eeschema/dialogs/dialog_netlist.cpp b/eeschema/dialogs/dialog_netlist.cpp index e745c5be53..45d0d46ac6 100644 --- a/eeschema/dialogs/dialog_netlist.cpp +++ b/eeschema/dialogs/dialog_netlist.cpp @@ -1,8 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2012 Jean-Pierre Charras, jp.charras@wanadoo.fr - * Copyright (C) 2011 Wayne Stambaugh + * Copyright (C) 2013 Jean-Pierre Charras, jp.charras@wanadoo.fr + * Copyright (C) 2013 Wayne Stambaugh * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or @@ -656,7 +656,8 @@ void NETLIST_DIALOG::WriteCurrentNetlistSetup( void ) m_config->Write( NETLIST_USE_DEFAULT_NETNAME, GetUseDefaultNetlistName() ); - // Update the new titles + // Update existing custom pages + int jj = 0; for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ ) { NETLIST_PAGE_DIALOG* currPage = m_PanelNetType[ii + PANELCUSTOMBASE]; @@ -664,29 +665,32 @@ void NETLIST_DIALOG::WriteCurrentNetlistSetup( void ) if( currPage == NULL ) break; - msg = wxT( "Custom" ); - msg << ii + 1; + wxString title = currPage->m_TitleStringCtrl->GetValue(); - if( currPage->m_TitleStringCtrl ) - { - wxString title = currPage->m_TitleStringCtrl->GetValue(); - currPage->SetPageNetFmtName( title ); + if( title.IsEmpty() ) + continue; - if( msg != title ) // Title has changed, Update config - { - msg = CUSTOM_NETLIST_TITLE; - msg << ii + 1; - m_config->Write( msg, title ); - } - } + msg = CUSTOM_NETLIST_TITLE; + msg << jj + 1; + m_config->Write( msg, title ); - if( currPage->m_CommandStringCtrl ) - { - Command = currPage->m_CommandStringCtrl->GetValue(); - msg = CUSTOM_NETLIST_COMMAND; - msg << ii + 1; - m_config->Write( msg, Command ); - } + Command = currPage->m_CommandStringCtrl->GetValue(); + msg = CUSTOM_NETLIST_COMMAND; + msg << jj + 1; + m_config->Write( msg, Command ); + jj++; + } + + // Ensure all other pages are void + for(; jj < CUSTOMPANEL_COUNTMAX; jj++ ) + { + msg = CUSTOM_NETLIST_TITLE; + msg << jj + 1; + m_config->Write( msg, wxEmptyString ); + + msg = CUSTOM_NETLIST_COMMAND; + msg << jj + 1; + m_config->Write( msg, wxEmptyString ); } } @@ -807,8 +811,9 @@ void NETLIST_DIALOG_ADD_PLUGIN::OnBrowsePlugins( wxCommandEvent& event ) if( FullFileName.IsEmpty() ) return; - // Creates a default command line, suitable for external tool xslproc: + // Creates a default command line, suitable for external tool xslproc or python // try to build a default command line depending on plugin extension + // "xsl" or "exe" or "py" wxString cmdLine; wxFileName fn( FullFileName ); wxString ext = fn.GetExt(); @@ -817,6 +822,8 @@ void NETLIST_DIALOG_ADD_PLUGIN::OnBrowsePlugins( wxCommandEvent& event ) cmdLine.Printf(wxT("xsltproc -o \"%%O\" \"%s\" \"%%I\""), GetChars(FullFileName) ); else if( ext == wxT("exe" ) || ext.IsEmpty() ) cmdLine.Printf(wxT("\"%s\" > \"%%O\" < \"%%I\""), GetChars(FullFileName) ); + else if( ext == wxT("py" ) || ext.IsEmpty() ) + cmdLine.Printf(wxT("python \"%s\" \"%%I\" \"%%O\""), GetChars(FullFileName) ); else cmdLine.Printf(wxT("\"%s\""), GetChars(FullFileName) ); diff --git a/include/worksheet_shape_builder.h b/include/worksheet_shape_builder.h index 740a2887db..661c6cdd83 100644 --- a/include/worksheet_shape_builder.h +++ b/include/worksheet_shape_builder.h @@ -156,6 +156,16 @@ public: * the corresponding text size is not constrained */ void SetConstrainedTextSize(); + + /** + * @return true is a bold font should be selected + */ + bool IsBold() { return (m_Flags & USE_BOLD) != 0; } + + /** + * @return true is an italic font should be selected + */ + bool IsItalic() { return (m_Flags & USE_ITALIC) != 0; } }; /* From c8c05cb4ee18c84f92b4999e54c43715daa1cbdd Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 7 Jun 2013 11:49:36 +0200 Subject: [PATCH 08/50] page layout: if the environment variable KICAD_WKSFILE points a S expr page layout descr, this descr is used instead of internal descr. Mainly for testing purposes. Eeschema, dialog edit component: minor enhancement (the last selected notebook page is remembered during a session) --- common/page_layout_default_description.cpp | 4 +- common/page_layout_reader.cpp | 62 +++++++++++++++++++ common/title_block_shapes.cpp | 35 ++++++++--- .../dialogs/dialog_edit_component_in_lib.cpp | 37 ++++++++--- .../dialogs/dialog_edit_component_in_lib.h | 33 ++++++++-- .../dialog_edit_component_in_lib_base.cpp | 9 ++- .../dialog_edit_component_in_lib_base.fbp | 4 +- .../dialog_edit_component_in_lib_base.h | 4 +- include/worksheet.h | 4 -- include/worksheet_shape_builder.h | 7 +++ template/pagelayout.kicad_wks | 34 ++++++++++ 11 files changed, 201 insertions(+), 32 deletions(-) create mode 100644 template/pagelayout.kicad_wks diff --git a/common/page_layout_default_description.cpp b/common/page_layout_default_description.cpp index 8b9b93633e..ba112fa865 100644 --- a/common/page_layout_default_description.cpp +++ b/common/page_layout_default_description.cpp @@ -27,8 +27,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include - /* keyword used in page layout description are (see page_layout_reader.keywords) * page_layout * setup @@ -136,6 +134,8 @@ // default line width 0.15 mm // frame ref pitch 50 mm +// export defaultPageLayout: +extern const char defaultPageLayout[]; // Default page layout (sizes are in mm) const char defaultPageLayout[] = "( page_layout\n" diff --git a/common/page_layout_reader.cpp b/common/page_layout_reader.cpp index 19f56dcdb4..9ed36e724c 100644 --- a/common/page_layout_reader.cpp +++ b/common/page_layout_reader.cpp @@ -441,9 +441,14 @@ double PAGE_LAYOUT_READER_PARSER::parseDouble() return val; } +// defaultPageLayout is the default page layout description +// using the S expr. +// see page_layout_default_shape.cpp +extern const char defaultPageLayout[]; void WORKSHEET_LAYOUT::SetDefaultLayout() { + ClearList(); PAGE_LAYOUT_READER_PARSER lp_parser( defaultPageLayout, wxT( "default page" ) ); try @@ -455,3 +460,60 @@ void WORKSHEET_LAYOUT::SetDefaultLayout() wxLogMessage( ioe.errorText ); } } + +#include + +// SetLayout() try to load a custom layout file, +// currently defined by the environment variable KICAD_WKSFILE +// (a *.kicad_wks file). +// if does not exists, loads the default page layout. +void WORKSHEET_LAYOUT::SetLayout() +{ + wxString fullFileName; + wxGetEnv( wxT( "KICAD_WKSFILE" ), &fullFileName ); + + if( fullFileName.IsEmpty() || !wxFileExists( fullFileName ) ) + { + #ifdef DEBUG + if( !wxFileExists( fullFileName ) ) + { + wxLogMessage( wxT("Page layout file <%s> not found"), + fullFileName.GetData() ); + } + #endif + SetDefaultLayout(); + return; + } + + wxFile wksFile( fullFileName ); + + if( ! wksFile.IsOpened() ) + { + SetDefaultLayout(); + return; + } + + int filelen = wksFile.Length(); + char * buffer = new char[filelen+10]; + + if( wksFile.Read( buffer, filelen ) != filelen ) + wxLogMessage( _("The file <%s> was not fully read"), + fullFileName.GetData() ); + else + { + buffer[filelen]=0; + ClearList(); + PAGE_LAYOUT_READER_PARSER lp_parser( buffer, fullFileName ); + + try + { + lp_parser.Parse( this ); + } + catch( IO_ERROR ioe ) + { + wxLogMessage( ioe.errorText ); + } + } + + delete[] buffer; +} diff --git a/common/title_block_shapes.cpp b/common/title_block_shapes.cpp index 6a3ac779f7..33ea5ee12f 100644 --- a/common/title_block_shapes.cpp +++ b/common/title_block_shapes.cpp @@ -3,11 +3,6 @@ * @brief description of graphic items and texts to build a title block */ -/* - * This file creates a lot of structures which define the shape of a title block - * and frame references - */ - /* * This program source code file is part of KiCad, a free EDA CAD application. * @@ -33,14 +28,38 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + +/* + * the class WORKSHEET_DATAITEM (and WORKSHEET_DATAITEM_TEXT) defines + * a basic shape of a page layout ( frame references and title block ) + * Basic shapes are line, rect and texts + * the WORKSHEET_DATAITEM coordinates units is the mm, and are relative to + * one of 4 page corners. + * + * These items cannot be drawn or plot "as this". they should be converted + * to a "draw list" (WS_DRAW_ITEM_BASE and derived items) + + * The list of these items is stored in a WORKSHEET_LAYOUT instance. + * + * When building the draw list: + * the WORKSHEET_LAYOUT is used to create a WS_DRAW_ITEM_LIST + * coordinates are converted to draw/plot coordinates. + * texts are expanded if they contain format symbols. + * Items with m_RepeatCount > 1 are created m_RepeatCount times + * + * the WORKSHEET_LAYOUT is created only once. + * the WS_DRAW_ITEM_LIST is created each time the page layout is plot/drawn + * + * the WORKSHEET_LAYOUT instance is created from a S expression which + * describes the page layout (can be the default page layout or a custom file). + */ + #include #include #include #include #include -extern void SetDataList( WORKSHEET_LAYOUT& aDataList ); - WORKSHEET_DATAITEM_TEXT::WORKSHEET_DATAITEM_TEXT( const wxChar* aTextBase ) : WORKSHEET_DATAITEM( WS_TEXT ) @@ -207,7 +226,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( // Build the basic layout shape, if the layout list is empty if( dataList.GetCount() == 0 ) - dataList.SetDefaultLayout(); + dataList.SetLayout(); WORKSHEET_DATAITEM::m_WSunits2Iu = m_milsToIu / milsTomm; diff --git a/eeschema/dialogs/dialog_edit_component_in_lib.cpp b/eeschema/dialogs/dialog_edit_component_in_lib.cpp index 42a2d55034..72b4c4c69a 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_lib.cpp @@ -1,8 +1,29 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: dialog_edit_component_in_lib.cpp -// Author: jean-pierre Charras -// Licence: GPL -///////////////////////////////////////////////////////////////////////////// +/** + * @file dialog_edit_component_in_lib.cpp + */ + +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * 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 + */ #include #include @@ -11,12 +32,12 @@ #include #include -#include #include #include #include +int DIALOG_EDIT_COMPONENT_IN_LIBRARY::m_lastOpenedPage = 0; DIALOG_EDIT_COMPONENT_IN_LIBRARY::DIALOG_EDIT_COMPONENT_IN_LIBRARY( LIB_EDIT_FRAME* aParent ): DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( aParent ) @@ -33,6 +54,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY::DIALOG_EDIT_COMPONENT_IN_LIBRARY( LIB_EDIT_FRA DIALOG_EDIT_COMPONENT_IN_LIBRARY::~DIALOG_EDIT_COMPONENT_IN_LIBRARY() { + m_lastOpenedPage = m_NoteBook->GetSelection( ); } /* Initialize state of check boxes and texts @@ -86,6 +108,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg() m_ButtonDeleteOneFootprintFilter->Enable( false ); } + m_NoteBook->SetSelection( m_lastOpenedPage ); + m_stdSizerButtonOK->SetDefault(); } @@ -156,7 +180,6 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel() void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) { - /* Update the doc, keyword and doc filename strings */ int index; LIB_ALIAS* alias; diff --git a/eeschema/dialogs/dialog_edit_component_in_lib.h b/eeschema/dialogs/dialog_edit_component_in_lib.h index 547050f618..c343cf1cc2 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib.h +++ b/eeschema/dialogs/dialog_edit_component_in_lib.h @@ -1,8 +1,29 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: dialog_edit_component_in_lib.h -// Author: jean-pierre Charras -// Licence: GPL -///////////////////////////////////////////////////////////////////////////// +/** + * @file dialog_edit_component_in_lib.h + */ + +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * 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 + */ #ifndef _DIALOG_EDIT_COMPONENT_IN_LIB_H_ @@ -13,6 +34,8 @@ class DIALOG_EDIT_COMPONENT_IN_LIBRARY: public DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE { + static int m_lastOpenedPage; // To remember the last notebook selection + public: LIB_EDIT_FRAME* m_Parent; bool m_RecreateToolbar; diff --git a/eeschema/dialogs/dialog_edit_component_in_lib_base.cpp b/eeschema/dialogs/dialog_edit_component_in_lib_base.cpp index 231ac05511..6f9b889844 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib_base.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_lib_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 10 2012) +// C++ code generated with wxFormBuilder (version Oct 8 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -109,7 +109,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_PanelBasic->SetSizer( bSizerBasicPanel ); m_PanelBasic->Layout(); bSizerBasicPanel->Fit( m_PanelBasic ); - m_NoteBook->AddPage( m_PanelBasic, _("Options"), false ); + m_NoteBook->AddPage( m_PanelBasic, _("Options"), true ); m_PanelDoc = new wxPanel( m_NoteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); wxBoxSizer* m_PanelDocBoxSizer; m_PanelDocBoxSizer = new wxBoxSizer( wxVERTICAL ); @@ -121,6 +121,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_PanelDocBoxSizer->Add( m_staticTextDescription, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); m_DocCtrl = new wxTextCtrl( m_PanelDoc, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_DocCtrl->SetMaxLength( 0 ); m_PanelDocBoxSizer->Add( m_DocCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_staticTextKeywords = new wxStaticText( m_PanelDoc, wxID_ANY, _("Keywords:"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -130,6 +131,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_PanelDocBoxSizer->Add( m_staticTextKeywords, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); m_KeywordsCtrl = new wxTextCtrl( m_PanelDoc, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_KeywordsCtrl->SetMaxLength( 0 ); m_PanelDocBoxSizer->Add( m_KeywordsCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_staticTextDocFileName = new wxStaticText( m_PanelDoc, wxID_ANY, _("DocFileName:"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -139,6 +141,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_PanelDocBoxSizer->Add( m_staticTextDocFileName, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); m_DocfileCtrl = new wxTextCtrl( m_PanelDoc, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 400,-1 ), 0 ); + m_DocfileCtrl->SetMaxLength( 0 ); m_PanelDocBoxSizer->Add( m_DocfileCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); wxBoxSizer* bSizerPaneldocbutts; @@ -157,7 +160,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_PanelDoc->SetSizer( m_PanelDocBoxSizer ); m_PanelDoc->Layout(); m_PanelDocBoxSizer->Fit( m_PanelDoc ); - m_NoteBook->AddPage( m_PanelDoc, _("Description"), true ); + m_NoteBook->AddPage( m_PanelDoc, _("Description"), false ); m_PanelAlias = new wxPanel( m_NoteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); wxBoxSizer* bSizerMainPanelAlias; bSizerMainPanelAlias = new wxBoxSizer( wxHORIZONTAL ); diff --git a/eeschema/dialogs/dialog_edit_component_in_lib_base.fbp b/eeschema/dialogs/dialog_edit_component_in_lib_base.fbp index 2fda7f816d..4db20d476f 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib_base.fbp +++ b/eeschema/dialogs/dialog_edit_component_in_lib_base.fbp @@ -185,7 +185,7 @@ Options - 0 + 1 1 1 @@ -1348,7 +1348,7 @@ Description - 1 + 0 1 1 diff --git a/eeschema/dialogs/dialog_edit_component_in_lib_base.h b/eeschema/dialogs/dialog_edit_component_in_lib_base.h index 79b7c88a80..d07b912be2 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib_base.h +++ b/eeschema/dialogs/dialog_edit_component_in_lib_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 10 2012) +// C++ code generated with wxFormBuilder (version Oct 8 2012) // 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 diff --git a/include/worksheet.h b/include/worksheet.h index d58203d77b..7757d9282d 100644 --- a/include/worksheet.h +++ b/include/worksheet.h @@ -47,9 +47,5 @@ void DrawPageLayout( wxDC* aDC, EDA_DRAW_PANEL * aCanvas, int aPenWidth, double aScalar, EDA_COLOR_T aLineColor, EDA_COLOR_T aTextColor ); -// defaultPageLayout is the default page layout description -// using the S expr. -// see page_layout_default_shape.cpp -extern const char defaultPageLayout[]; #endif // WORKSHEET_H_ diff --git a/include/worksheet_shape_builder.h b/include/worksheet_shape_builder.h index 661c6cdd83..94d8d5fe10 100644 --- a/include/worksheet_shape_builder.h +++ b/include/worksheet_shape_builder.h @@ -507,6 +507,13 @@ public: * Fills the list with the default layout shape */ void SetDefaultLayout(); + + /** + * Fills the list with a custom layout, or + * the default layout, if no custom layout available + */ + void SetLayout(); + }; #endif // WORKSHEET_SHAPE_BUILDER_H diff --git a/template/pagelayout.kicad_wks b/template/pagelayout.kicad_wks new file mode 100644 index 0000000000..4a8d16b1ae --- /dev/null +++ b/template/pagelayout.kicad_wks @@ -0,0 +1,34 @@ +( page_layout + ( setup (textsize 1.5 1.5) (linewidth 0.15) (textlinewidth 0.15) ) + ( rect (comment rect around the title block) (linewidth 0.15) (start 110 34) (end 2 2) ) + ( rect (start 0 0 ltcorner) (end 0 0 rbcorner) (repeat 2) (incrx 2) (incry 2) ) + ( line (start 50 2 ltcorner) (end 50 0 ltcorner) (repeat 30) (incrx 50) ) + ( tbtext "1" (pos 25 1 ltcorner) (font (size 1.3 1.3))(repeat 100) (incrx 50) ) + ( line (start 50 2 lbcorner) (end 50 0 lbcorner) (repeat 30) (incrx 50) ) + ( tbtext "1" (pos 25 1 lbcorner) (font (size 1.3 1.3)) (repeat 100) (incrx 50) ) + ( line (start 0 50 ltcorner) (end 2 50 ltcorner) (repeat 30) (incry 50) ) + ( tbtext "A" (pos 1 25 ltcorner) (font (size 1.3 1.3)) + (justify center)(repeat 100) (incry 50) ) + ( line (start 0 50 rtcorner) (end 2 50 rtcorner) (repeat 30) (incry 50) ) + ( tbtext "A" (pos 1 25 rtcorner) (font (size 1.3 1.3)) + (justify center) (repeat 100) (incry 50) ) + ( tbtext "Date: %D" (pos 87 6.9) ) + ( line (start 110 5.5) end 2 5.5) ) + ( tbtext "%K" (pos 109 4.1) (comment Kicad version ) ) + ( line (start 110 8.5) end 2 8.5) ) + ( tbtext "Rev: %R" (pos 24 6.9)(font bold)(justify left) ) + ( tbtext "Size: %Z" (comment Paper format name)(pos 109 6.9) ) + ( tbtext "Id: %S/%N" (comment Sheet id)(pos 24 4.1) ) + ( line (start 110 12.5) end 2 12.5) ) + ( tbtext "Title: %T" (pos 109 10.7)(font bold (size 2 2)) ) + ( tbtext "File: %F" (pos 109 14.3) ) + ( line (start 110 18.5) end 2 18.5) ) + ( tbtext "Sheet: %P" (pos 109 17) ) + ( tbtext "%Y" (comment Company name) (pos 109 20)(font bold) ) + ( tbtext "%C0" (comment Comment 0) (pos 109 23) ) + ( tbtext "%C1" (comment Comment 0) (pos 109 26) ) + ( tbtext "%C2" (comment Comment 0) (pos 109 29) ) + ( tbtext "%C3" (comment Comment 0) (pos 109 32) ) + ( line (start 90 8.5) end 90 5.5) ) + ( line (start 26 8.5) end 26 2) ) +) From 9929919b59585179cb88512423fc6c7f2b76e862 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Fri, 7 Jun 2013 08:15:32 -0400 Subject: [PATCH 09/50] Fix CvPcb library filtering bug. (fixes lp:1188321) --- common/footprint_info.cpp | 23 +++++++++++++++++++++++ cvpcb/class_footprints_listbox.cpp | 2 +- include/footprint_info.h | 26 +++++++++++++++++++------- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/common/footprint_info.cpp b/common/footprint_info.cpp index cc5368a5af..810076be05 100644 --- a/common/footprint_info.cpp +++ b/common/footprint_info.cpp @@ -180,3 +180,26 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable ) return true; } + + +bool FOOTPRINT_INFO::InLibrary( const wxString& aLibrary ) const +{ + if( aLibrary.IsEmpty() ) + return false; + + if( aLibrary == m_libName || aLibrary == m_libPath ) + return true; + + wxFileName filename = aLibrary; + + if( filename.GetExt().IsEmpty() ) + filename.SetExt( LegacyFootprintLibPathExtension ); + + if( filename.GetFullPath() == m_libPath ) + return true; + + if( filename.GetPath().IsEmpty() ) + filename = wxGetApp().FindLibraryPath( filename.GetFullName() ); + + return filename.GetFullPath() == m_libPath; +} diff --git a/cvpcb/class_footprints_listbox.cpp b/cvpcb/class_footprints_listbox.cpp index 8d7ab4e930..3fb5874f30 100644 --- a/cvpcb/class_footprints_listbox.cpp +++ b/cvpcb/class_footprints_listbox.cpp @@ -142,7 +142,7 @@ void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& a } if( (aFilterType & BY_LIBRARY) && !aLibName.IsEmpty() - && (aList.GetItem( ii ).m_libName != aLibName) ) + && !aList.GetItem( ii ).InLibrary( aLibName ) ) continue; if( (aFilterType & BY_COMPONENT) && (aComponent != NULL) diff --git a/include/footprint_info.h b/include/footprint_info.h index 70678b24fa..ccdba621db 100644 --- a/include/footprint_info.h +++ b/include/footprint_info.h @@ -29,6 +29,7 @@ #ifndef FOOTPRINT_INFO_H_ #define FOOTPRINT_INFO_H_ + #include #include @@ -46,13 +47,13 @@ class FP_LIB_TABLE; class FOOTPRINT_INFO { public: - wxString m_libName; ///< Name of the library containing this module excluding path and ext. - wxString m_libPath; ///< The full library name and path associated the footprint. - 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 + wxString m_libName; ///< Name of the library containing this module excluding path and ext. + wxString m_libPath; ///< The full library name and path associated the footprint. + 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() { @@ -67,6 +68,17 @@ public: void SetLibraryPath( const wxString& aLibPath ) { m_libPath = aLibPath; } const wxString& GetLibraryPath() const { return m_libPath; } + + /** + * Function InLibrary + * tests if the #FOOTPRINT_INFO object was loaded from \a aLibrary. + * + * @param aLibrary is the file name or the fully qualified path and file name + * to test. + * @return true if the #FOOTPRINT_INFO object was loaded from \a aLibrary. Otherwise + * false. + */ + bool InLibrary( const wxString& aLibrary ) const; }; From ecbe947bc6ff1f54d16d5818985bac89311f35c6 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Fri, 7 Jun 2013 09:17:52 -0400 Subject: [PATCH 10/50] CvPcb pin count filtering improvement. (fixes lp:1188325) * Add option to MODULE::GetPadCount() to exclude non-plated through holes. --- common/footprint_info.cpp | 4 ++-- pcbnew/class_module.cpp | 19 +++++++++++++++++++ pcbnew/class_module.h | 12 +++++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/common/footprint_info.cpp b/common/footprint_info.cpp index 810076be05..a82f809d7a 100644 --- a/common/footprint_info.cpp +++ b/common/footprint_info.cpp @@ -99,7 +99,7 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames ) fpinfo->SetLibraryName( filename.GetName() ); fpinfo->SetLibraryPath( filename.GetFullPath() ); fpinfo->m_Module = fpnames[i]; - fpinfo->m_padCount = m->GetPadCount(); + fpinfo->m_padCount = m->GetPadCount( MODULE::DO_NOT_INCLUDE_NPTH ); fpinfo->m_KeyWord = m->GetKeywords(); fpinfo->m_Doc = m->GetDescription(); @@ -163,7 +163,7 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable ) fpinfo->SetLibraryName( libNickNames[ii] ); fpinfo->SetLibraryPath( path ); fpinfo->m_Module = fpnames[i]; - fpinfo->m_padCount = m->GetPadCount(); + fpinfo->m_padCount = m->GetPadCount( MODULE::DO_NOT_INCLUDE_NPTH ); fpinfo->m_KeyWord = m->GetKeywords(); fpinfo->m_Doc = m->GetDescription(); diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 64d03bb031..b0115bb119 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -603,6 +603,25 @@ D_PAD* MODULE::GetPad( const wxPoint& aPosition, LAYER_MSK aLayerMask ) } +unsigned MODULE::GetPadCount( INCLUDE_NPTH_T aIncludeNPTH ) const +{ + if( aIncludeNPTH ) + return m_Pads.GetCount(); + + unsigned cnt = 0; + + for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) + { + if( pad->GetAttribute() == PAD_HOLE_NOT_PLATED ) + continue; + + cnt++; + } + + return cnt; +} + + void MODULE::Add3DModel( S3D_MASTER* a3DModel ) { a3DModel->SetParent( this ); diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index 30f979b9b0..cc68cab05c 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -384,11 +384,21 @@ public: */ D_PAD* GetPad( const wxPoint& aPosition, LAYER_MSK aLayerMask = ALL_LAYERS ); + enum INCLUDE_NPTH_T + { + DO_NOT_INCLUDE_NPTH = false, + INCLUDE_NPTH = true + }; + /** * GetPadCount * returns the number of pads. + * + * @param aIncludeNPTH includes non-plated through holes when true. Does not include + * non-plated through holes when false. + * @return the number of pads according to \a aIncludeNPTH. */ - unsigned GetPadCount() const { return m_Pads.GetCount() ; } + unsigned GetPadCount( INCLUDE_NPTH_T aIncludeNPTH = INCLUDE_NPTH ) const; double GetArea() const { return m_Surface; } From ee6cd0883da5e7cbf44d86da0e06083eab069a1c Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 7 Jun 2013 18:37:44 +0200 Subject: [PATCH 11/50] Plot files : fix Bug #1188664 (full filename instead of short file name, and swapping between sheet path and file name) --- common/common_plot_functions.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/common_plot_functions.cpp b/common/common_plot_functions.cpp index f67f781fb2..50da2d814f 100644 --- a/common/common_plot_functions.cpp +++ b/common/common_plot_functions.cpp @@ -98,8 +98,12 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock, drawList.SetSheetNumber( aSheetNumber ); drawList.SetSheetCount( aNumberOfSheets ); - drawList.BuildWorkSheetGraphicList( aPageInfo.GetType(), aSheetDesc, - aFilename, aTitleBlock, plotColor, plotColor ); + // Print only a short filename, if aFilename is the full filename + + wxFileName fn( aFilename ); + + drawList.BuildWorkSheetGraphicList( aPageInfo.GetType(), fn.GetFullName(), + aSheetDesc, aTitleBlock, plotColor, plotColor ); // Draw item list for( WS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item; From 0c5d9fa20c446a3afd5955bdb4a65180d5254d20 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 7 Jun 2013 19:35:09 +0200 Subject: [PATCH 12/50] Fix compil issue on wxWidgets 2.8.12, created by my last commit. --- common/common_plot_functions.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/common_plot_functions.cpp b/common/common_plot_functions.cpp index 50da2d814f..e090dd2af2 100644 --- a/common/common_plot_functions.cpp +++ b/common/common_plot_functions.cpp @@ -35,6 +35,8 @@ #include #include #include "worksheet_shape_builder.h" +#include + wxString GetDefaultPlotExtension( PlotFormat aFormat ) From 515f5fbe5ea3217e341cd029a5ab8c184bea4ed1 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Fri, 7 Jun 2013 15:56:55 -0500 Subject: [PATCH 13/50] *) Introduce "invoke_a_dialog.h" to information hide between top frame and various DIALOG classes called from top frames. See comments in {eeschema,pcbnew}/invoke_a_dialog.h. *) Move some dialog classes into *.cpp files from *.h files. *) void SCH_EDIT_FRAME::OnErc( wxCommandEvent& event ) was opening the modeless ERC dialog more than once if icon was clicked more than once. *) Remove BOM stuff. --- eeschema/BOM_lister.h.notused | 188 -- eeschema/CMakeLists.txt | 2 +- eeschema/build_BOM.cpp.notused | 736 ------ eeschema/dialogs/annotate_dialog.h | 71 - ...nnotate_dialog.cpp => dialog_annotate.cpp} | 215 +- eeschema/dialogs/dialog_build_BOM.cpp | 591 ----- eeschema/dialogs/dialog_build_BOM.h | 94 - eeschema/dialogs/dialog_build_BOM_base.cpp | 157 -- eeschema/dialogs/dialog_build_BOM_base.fbp | 2060 ----------------- eeschema/dialogs/dialog_build_BOM_base.h | 83 - eeschema/dialogs/dialog_erc.cpp | 18 +- eeschema/dialogs/dialog_netlist.cpp | 1 - .../dialogs/dialog_print_using_printer.cpp | 38 +- eeschema/dialogs/dialog_print_using_printer.h | 34 - eeschema/invoke_a_dialog.h | 66 + eeschema/schframe.cpp | 25 +- include/id.h | 4 +- include/wxEeschemaStruct.h | 70 +- pcbnew/invoke_a_dialog.h | 69 + 19 files changed, 372 insertions(+), 4150 deletions(-) delete mode 100644 eeschema/BOM_lister.h.notused delete mode 100644 eeschema/build_BOM.cpp.notused delete mode 100644 eeschema/dialogs/annotate_dialog.h rename eeschema/dialogs/{annotate_dialog.cpp => dialog_annotate.cpp} (56%) delete mode 100644 eeschema/dialogs/dialog_build_BOM.cpp delete mode 100644 eeschema/dialogs/dialog_build_BOM.h delete mode 100644 eeschema/dialogs/dialog_build_BOM_base.cpp delete mode 100644 eeschema/dialogs/dialog_build_BOM_base.fbp delete mode 100644 eeschema/dialogs/dialog_build_BOM_base.h delete mode 100644 eeschema/dialogs/dialog_print_using_printer.h create mode 100644 eeschema/invoke_a_dialog.h create mode 100644 pcbnew/invoke_a_dialog.h diff --git a/eeschema/BOM_lister.h.notused b/eeschema/BOM_lister.h.notused deleted file mode 100644 index ba5dbbc024..0000000000 --- a/eeschema/BOM_lister.h.notused +++ /dev/null @@ -1,188 +0,0 @@ -/** - * @file BOM_lister.h - */ - -/* This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2012 Jean-Pierre Charras jp.charras at wanadoo.fr - * Copyright (C) 1992-2012 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 - */ - -#ifndef _BOM_LISTER_H_ -#define _BOM_LISTER_H_ - -#include - - -// A helper class to build item lists for BOM, -// and write lists on files -class BOM_LISTER -{ -private: - BOM_LABEL_LIST m_labelList; // a list of global and hierarchical labels - SCH_REFERENCE_LIST m_cmplist; // a flat list of components in the full hierarchy - FILE* m_outFile; // the output file for BOM generation - char m_separatorSymbol; // the separator used for csv files ( usually \t ; or , ) - bool m_outputFmtCsv; // true to create Csv files, false to create text lists - bool m_includeSubComponents; // true to list each part - // of a multiple part per package component - // false to list only once this kind of component - bool m_csvForm; // true to print less verbose component list - // false to print more verbose component list - bool m_groupReferences; // true to group in list by reference (when possible, - // i.e. when other fields have the same value - // false to list one reference per line - bool m_printLocation; // true to print component location in list by reference - std::vector m_fieldIDactive; // list of field IDs to print - -public: - BOM_LISTER() - { - m_outFile = NULL; - m_separatorSymbol = '\t'; - m_outputFmtCsv = false; - m_includeSubComponents = false; - m_csvForm = true; - m_printLocation = false; - m_groupReferences = false; - } - - // Accessors: - void SetGroupReferences( bool aGroupRef ) - { - m_groupReferences = aGroupRef; - } - - void SetPrintLocation( bool aPrintLoc ) - { - m_printLocation = aPrintLoc; - } - - void SetIncludeSubCmp( bool aIncludeSubCmp ) - { - m_includeSubComponents = aIncludeSubCmp; - } - - /** - * Function SetCvsFormOn - * prepare parameters to create a BOM list in comma separated value (cvs) - * @param aSeparator = the character used as "csv" separator - */ - void SetCvsFormOn( char aSeparator ) - { - m_csvForm = true; - m_separatorSymbol = aSeparator; - } - - /** - * Function SetCvsFormOff - * prepare parameters to create a BOM list in full text readable mode - * (not csv format) - */ - void SetCvsFormOff() - { - m_csvForm = false; - } - - void AddFieldIdToPrintList( int aFieldId ); - - void ClearFieldIdPrintList() { m_fieldIDactive.clear(); } - - /** - * Function CreateCsvBOMListByValues - * print the list of components, grouped by values: - * One line by value. The format is something like: - * value;quantity;references;other fields - * 18pF;2;"C404 C405";SM0402 - * 22nF/25V;4;"C128 C168 C228 C268";SM0402 - * @param aFile = the file to write to (will be closed) - */ - void CreateCsvBOMListByValues( FILE* aFile ); - - /** - * Function PrintGlobalAndHierarchicalLabelsList - * print the list of global and hierarchical labels by sheet or by name - * @param aSortBySheet = true to print by sheet name order - * false to print by label name order - * @param aFile = the file to write to (will be NOT closed) - */ - void PrintGlobalAndHierarchicalLabelsList( FILE* aFile, bool aSortBySheet ); - - /** - * Function PrintComponentsListByReferenceHumanReadable - * print a BOM list in human readable form - * @param aFile = the file to write to (will be NOT closed) - */ - bool PrintComponentsListByReferenceHumanReadable( FILE* aFile ); - - /** - * Function PrintComponentsListByReferenceCsvForm - * print the list of components ordered by references. Generate 2 formats: - * - full component list in csv form - * - "short" component list in csv form, grouped by common fields values - * (mainly component value) - * @param aFile = the file to write to (will be NOT closed) - */ - bool PrintComponentsListByReferenceCsvForm( FILE* aFile ); - - /** - * Function PrintComponentsListByValue - * print the list of components, sorted by value, one line per component - * not useable for csv format (use CreateCsvBOMListByValues instead) - * @param aFile = the file to write to (will be NOT closed) - */ - int PrintComponentsListByValue( FILE* aFile ); - -private: - - /** - * Helper function isFieldPrintable - * @return true if the field aFieldId should be printed. - * @param aFieldId = the field Id (FOOTPRIN, FIELD4 ...) - */ - bool isFieldPrintable( int aFieldId ); - - /** - * Helper function buildGlobalAndHierarchicalLabelsList - * Populate m_labelList with global and hierarchical labels - * and sheet pins labels - */ - void buildGlobalAndHierarchicalLabelsList(); - - /** - * Helper function returnFieldsString - * @return a string containing all selected fields texts, - * @param aComponent = the schematic component - * separated by the csv separator symbol - */ - const wxString returnFieldsString( SCH_COMPONENT* aComponent ); - - /** - * Helper function returnURLItemLocation - * @param aPathName = the full sheet name of item - * @param aPosition = a position (in internal units) to print - * @return a formated string to print the full location: - * /sheet name/( X Y position) - */ - const wxString returnURLItemLocation( const wxString& aPathName, - wxPoint aPosition ); -}; - -#endif // _BOM_LISTER_H_ diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 40738f9762..416b853cf3 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -12,7 +12,7 @@ include_directories( set(EESCHEMA_DLGS dialogs/dialog_color_config.cpp - dialogs/annotate_dialog.cpp + dialogs/dialog_annotate.cpp dialogs/dialog_annotate_base.cpp dialogs/dialog_lib_edit_text.cpp dialogs/dialog_lib_edit_text_base.cpp diff --git a/eeschema/build_BOM.cpp.notused b/eeschema/build_BOM.cpp.notused deleted file mode 100644 index c3df29d9bd..0000000000 --- a/eeschema/build_BOM.cpp.notused +++ /dev/null @@ -1,736 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2012 Wayne Stambaugh - * Copyright (C) 1992-2012 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 build_BOM.cpp - * @brief Code used to generate bill of materials. - */ - -#include // to use sort vector -#include - -#include -#include -#include -#include -#include -#include - -#include - -/* Creates the list of components, grouped by values: - * One line by value. The format is something like: - * value;quantity;references;other fields - * 18pF;2;"C404 C405";SM0402 - * 22nF/25V;4;"C128 C168 C228 C268";SM0402 - * param aFile = the file to write to (will be closed) - */ -void BOM_LISTER::CreateCsvBOMListByValues( FILE* aFile ) -{ - m_outFile = aFile; - - SCH_SHEET_LIST sheetList; - - sheetList.GetComponents( m_cmplist, false ); - - // sort component list by ref and remove sub components - m_cmplist.RemoveSubComponentsFromList(); - - // sort component list by value - m_cmplist.SortByValueOnly(); - - unsigned int index = 0; - - while( index < m_cmplist.GetCount() ) - { - SCH_COMPONENT* component = m_cmplist[index].GetComponent(); - wxString referenceListStr; - int qty = 1; - referenceListStr.append( m_cmplist[index].GetRef() ); - - for( unsigned int ii = index + 1; ii < m_cmplist.GetCount(); ) - { - if( *( m_cmplist[ii].GetComponent() ) == *component ) - { - referenceListStr.append( wxT( " " ) + m_cmplist[ii].GetRef() ); - m_cmplist.RemoveItem( ii ); - qty++; - } - else - ii++; // Increment index only when current item is not removed from the list - } - - // Write value, quantity and list of references - fprintf( m_outFile, "%s%c%d%c\"%s\"", - TO_UTF8( component->GetField( VALUE )->GetText() ), - m_separatorSymbol, qty, - m_separatorSymbol, TO_UTF8( referenceListStr ) ); - - for( int ii = FOOTPRINT; ii < component->GetFieldCount(); ii++ ) - { - if( isFieldPrintable( ii ) ) - fprintf( m_outFile, "%c%s", m_separatorSymbol, - TO_UTF8( component->GetField( ii )->GetText() ) ); - } - - fprintf( m_outFile, "\n" ); - index++; - } - - fclose( m_outFile ); - m_outFile = NULL; -} - - -bool BOM_LISTER::isFieldPrintable( int aFieldId ) -{ - for( unsigned ii = 0; ii < m_fieldIDactive.size(); ii++ ) - if( m_fieldIDactive[ii] == aFieldId ) - return true; - - - - - return false; -} - - -void BOM_LISTER::AddFieldIdToPrintList( int aFieldId ) -{ - for( unsigned ii = 0; ii < m_fieldIDactive.size(); ii++ ) - if( m_fieldIDactive[ii] == aFieldId ) - return; - - - - - m_fieldIDactive.push_back( aFieldId ); -} - - -/* compare function for sorting labels by value, then by sheet - */ -static bool SortLabelsByValue( const BOM_LABEL& obj1, const BOM_LABEL& obj2 ) -{ - int ii = obj1.GetText().CmpNoCase( obj2.GetText() ); - - if( ii == 0 ) - ii = obj1.GetSheetPath().Cmp( obj2.GetSheetPath() ); - - return ii < 0; -} - - -/* compare function for sorting labels by sheet, then by alphabetic order - */ -static bool SortLabelsBySheet( const BOM_LABEL& obj1, const BOM_LABEL& obj2 ) -{ - int ii = obj1.GetSheetPath().Cmp( obj2.GetSheetPath() ); - - if( ii == 0 ) - ii = obj1.GetText().CmpNoCase( obj2.GetText() ); - - return ii < 0; -} - - -// Creates the flat list of global, hierachycal labels and pin sheets -// and populate m_labelList -void BOM_LISTER::buildGlobalAndHierarchicalLabelsList() -{ - m_labelList.clear(); - - // Explore the flat sheet list - SCH_SHEET_LIST sheetList; - - for( SCH_SHEET_PATH* path = sheetList.GetFirst(); path; path = sheetList.GetNext() ) - { - SCH_ITEM* schItem = (SCH_ITEM*) path->LastDrawList(); - - for( ; schItem; schItem = schItem->Next() ) - { - switch( schItem->Type() ) - { - case SCH_HIERARCHICAL_LABEL_T: - case SCH_GLOBAL_LABEL_T: - m_labelList.push_back( BOM_LABEL( schItem->Type(), schItem, *path ) ); - break; - - case SCH_SHEET_T: - { - SCH_SHEET* sheet = (SCH_SHEET*) schItem; - - BOOST_FOREACH( SCH_SHEET_PIN & sheetPin, sheet->GetPins() ) { - m_labelList.push_back( BOM_LABEL( SCH_SHEET_PIN_T, - &sheetPin, *path ) ); - } - } - break; - - default: - break; - } - } - } -} - - -// Print the flat list of global, hierachycal labels and pin sheets -// contained by m_labelList -void BOM_LISTER::PrintGlobalAndHierarchicalLabelsList( FILE* aFile, bool aSortBySheet ) -{ - m_outFile = aFile; - - buildGlobalAndHierarchicalLabelsList(); - - wxString msg; - - if( aSortBySheet ) - { - sort( m_labelList.begin(), m_labelList.end(), SortLabelsBySheet ); - msg.Printf( _( - "\n#Global, Hierarchical Labels and PinSheets \ -( order = Sheet Number ) count = %d\n" ), - m_labelList.size() ); - } - else - { - sort( m_labelList.begin(), m_labelList.end(), SortLabelsByValue ); - msg.Printf( _( - "\n#Global, Hierarchical Labels and PinSheets ( \ -order = Alphab. ) count = %d\n\n" ), - m_labelList.size() ); - } - - fprintf( m_outFile, "%s", TO_UTF8( msg ) ); - - SCH_LABEL* label; - SCH_SHEET_PIN* pinsheet; - wxString sheetpath; - wxString labeltype; - - for( unsigned ii = 0; ii < m_labelList.size(); ii++ ) - { - switch( m_labelList[ii].GetType() ) - { - case SCH_HIERARCHICAL_LABEL_T: - case SCH_GLOBAL_LABEL_T: - label = (SCH_LABEL*) ( m_labelList[ii].GetLabel() ); - - if( m_labelList[ii].GetType() == SCH_HIERARCHICAL_LABEL_T ) - labeltype = wxT( "Hierarchical" ); - else - labeltype = wxT( "Global " ); - - sheetpath = m_labelList[ii].GetSheetPath().PathHumanReadable(); - msg.Printf( wxT( "> %-28.28s %s %s\n" ), - GetChars( label->GetText() ), - GetChars( labeltype ), - GetChars( returnURLItemLocation( sheetpath, label->GetPosition() ) ) ); - - fputs( TO_UTF8( msg ), m_outFile ); - break; - - case SCH_SHEET_PIN_T: - pinsheet = (SCH_SHEET_PIN*) m_labelList[ii].GetLabel(); - labeltype = FROM_UTF8( SheetLabelType[pinsheet->GetShape()] ); - - msg.Printf( _( "> %-28.28s PinSheet %-7.7s %s\n" ), - GetChars( pinsheet->GetText() ), - GetChars( labeltype ), - GetChars( returnURLItemLocation( m_labelList[ii].GetSheetPath(). - PathHumanReadable(), - pinsheet->GetPosition() ) ) ); - - fputs( TO_UTF8( msg ), m_outFile ); - break; - - default: - break; - } - } - - msg = _( "#End labels\n" ); - fputs( TO_UTF8( msg ), m_outFile ); -} - - -/* - * Helper function - * returns a string containing all selected fields texts, - * separated by the csv separator symbol (csv form) or a ; - */ -const wxString BOM_LISTER::returnFieldsString( SCH_COMPONENT* aComponent ) -{ - wxString outStr; - wxString tmpStr; - wxString text; - - for( int ii = FOOTPRINT; ii <= FIELD8; ii++ ) - { - if( !isFieldPrintable( ii ) ) - continue; - - if( aComponent->GetFieldCount() > ii ) - text = aComponent->GetField( ii )->GetText(); - else - text = wxEmptyString; - - if( m_csvForm ) - tmpStr.Printf( wxT( "%c%s" ), m_separatorSymbol, GetChars( text ) ); - else - tmpStr.Printf( wxT( "; %-12s" ), GetChars( text ) ); - - outStr += tmpStr; - } - - return outStr; -} - - -/* print the list of components ordered by references, - * full component list in human readable form - * param aFile = the file to write to (will be NOT closed) - */ - -/* full list in human readable form sample: - * #Cmp ( order = Reference )with sub-composants - * | C101 47pF Loc /(X=344,170 mm, Y=116,840 mm); C1 ; field1 ; - * | C102 47pF Loc /(X=364,490 mm, Y=116,840 mm); C1 ; ; - * | C103 47uF Loc /(X=66,040 mm, Y=231,140 mm); CP6 ; ; - */ - -bool BOM_LISTER::PrintComponentsListByReferenceHumanReadable( FILE* aFile ) -{ - m_outFile = aFile; - bool addDatasheet = isFieldPrintable( DATASHEET ); - - // Print component location if needed, but only when - // include sub component option is enabled, because for multiple - // parts per package there are more than one location per reference - bool printLocCmp = m_printLocation && m_includeSubComponents; - - wxString msg; - - if( m_cmplist.GetCount() == 0 ) // Build component list - { - SCH_SHEET_LIST sheetList; - sheetList.GetComponents( m_cmplist, false ); - - // sort component list - m_cmplist.SortByReferenceOnly(); - - if( !m_includeSubComponents ) - m_cmplist.RemoveSubComponentsFromList(); - } - else - m_cmplist.SortByReferenceOnly(); - - // Print comment line: - msg = _( "#Cmp ( order = Reference )" ); - - if( m_includeSubComponents ) - msg << _( " (with SubCmp)" ); - - fprintf( m_outFile, "%s\n", TO_UTF8( msg ) ); - - wxString subReference; // Unit ident, for mutiple parts per package - std::string CmpName; - - // Print list of items - for( unsigned ii = 0; ii < m_cmplist.GetCount(); ii++ ) - { - EDA_ITEM* item = m_cmplist[ii].GetComponent(); - - if( item == NULL ) - continue; - - if( item->Type() != SCH_COMPONENT_T ) - continue; - - SCH_COMPONENT* comp = (SCH_COMPONENT*) item; - - bool isMulti = false; - - LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( comp->GetLibName() ); - - if( entry ) - isMulti = entry->IsMulti(); - - CmpName = m_cmplist[ii].GetRefStr(); - - if( isMulti && m_includeSubComponents ) - { - subReference = LIB_COMPONENT::ReturnSubReference( m_cmplist[ii].GetUnit() ); - CmpName += TO_UTF8( subReference ); - } - - fprintf( m_outFile, "| %-10s %-12s", CmpName.c_str(), - TO_UTF8( comp->GetField( VALUE )->GetText() ) ); - - if( addDatasheet ) - fprintf( m_outFile, "%-20s", - TO_UTF8( comp->GetField( DATASHEET )->GetText() ) ); - - if( m_includeSubComponents ) - { - if( printLocCmp ) - { - msg = returnURLItemLocation( m_cmplist[ii].GetSheetPath().PathHumanReadable(), - comp->GetPosition() ); - fprintf( m_outFile, "%s", TO_UTF8( msg ) ); - } - } - - wxString tmpStr = returnFieldsString( comp ); - fprintf( m_outFile, "%s\n", TO_UTF8( tmpStr ) ); - } - - // Print the last line: - fputs( "#End Cmp\n", m_outFile ); - - return true; -} - - -/* print the list of components ordered by references. Generate 2 formats: - * - full component list in csv form - * - "short" component list in csv form, grouped by common fields values - * (mainly component value) - * param aFile = the file to write to (will be NOT closed) - */ - -/* full csv format sample: - * ref;value;sheet path(location);footprint;field1;field2 - * C101;47pF;Loc /(X=57,150 mm, Y=74,930 mm);Loc /(X=344,170 mm, Y=116,840 mm));C1;field1; - * C102;47pF;Loc /(X=344,170 mm, Y=116,840 mm);Loc /(X=364,490 mm, Y=116,840 mm));C1;; - * C103;47uF;Loc /(X=364,490 mm, Y=116,840 mm);Loc /(X=66,040 mm, Y=231,140 mm));CP6;; - * C104;47uF;Loc /(X=66,040 mm, Y=231,140 mm);Loc /(X=82,550 mm, Y=231,140 mm));CP6;; - */ -/* short csv format sample: - * ref;value;footprint;Champ1;Champ2 - * C101;47pF;C1;field1;;1 - * C102;47pF;C1;;;1 - * C103..C106;47uF;CP6;;;4 - */ - -bool BOM_LISTER::PrintComponentsListByReferenceCsvForm( FILE* aFile ) -{ - m_outFile = aFile; - bool addDatasheet = isFieldPrintable( DATASHEET ); - - // Set option group references, for components having same field values - // (same value, same footprint ...) - // obviously, this is possible only when print location - // and include Sub Components are not enabled. - bool groupRefs = m_groupReferences; - bool includeSubComponents = m_includeSubComponents && !groupRefs; - - // Print component location if needed, but only when - // include sub component option is enabled, because for multiple - // parts per package there are more than one location per reference - bool printLocCmp = m_printLocation && !groupRefs && m_includeSubComponents; - - wxString msg; - - if( m_cmplist.GetCount() == 0 ) // Build component list - { - SCH_SHEET_LIST sheetList; - sheetList.GetComponents( m_cmplist, false ); - - // sort component list - m_cmplist.SortByReferenceOnly(); - - if( !includeSubComponents ) - m_cmplist.RemoveSubComponentsFromList(); - } - else - m_cmplist.SortByReferenceOnly(); - - // Print comment line: - msg = wxT( "ref" ); - msg << (wxChar)m_separatorSymbol << wxT( "value" ); - - if( addDatasheet ) - msg << (wxChar)m_separatorSymbol << wxT( "datasheet" ); - - if( printLocCmp ) - msg << (wxChar)m_separatorSymbol << wxT( "sheet path(location)" ); - - if( isFieldPrintable( FOOTPRINT ) ) - msg << (wxChar)m_separatorSymbol << wxT( "footprint" ); - - for( int ii = FIELD1; ii <= FIELD8; ii++ ) - { - if( isFieldPrintable( ii ) ) - msg << (wxChar)m_separatorSymbol << _( "Field" ) << ii - FIELD1 + 1; - } - - if( groupRefs ) - msg << (wxChar)m_separatorSymbol << _( "Item count" ); - - fprintf( m_outFile, "%s\n", TO_UTF8( msg ) ); - - // Print BOM list - wxString strCur; - wxString strPred; - int amount = 0; // number of items, on the same line - wxString cmpName; - wxString cmpNameFirst; - wxString cmpNameLast; - - // Print list of items, by reference - for( unsigned ii = 0; ii < m_cmplist.GetCount(); ii++ ) - { - EDA_ITEM* item = m_cmplist[ii].GetComponent(); - - if( item == NULL ) - continue; - - if( item->Type() != SCH_COMPONENT_T ) - continue; - - SCH_COMPONENT* comp = (SCH_COMPONENT*) item; - - LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( comp->GetLibName() ); - - bool isMulti = false; - - if( entry ) - isMulti = entry->IsMulti(); - - cmpName = m_cmplist[ii].GetRef(); - - if( isMulti && includeSubComponents ) - // Add unit ident, for mutiple parts per package - cmpName += LIB_COMPONENT::ReturnSubReference( m_cmplist[ii].GetUnit() ); - - if( groupRefs ) - { - // Store value and datasheet (will be printed later) - strCur.Empty(); - strCur << (wxChar)m_separatorSymbol << comp->GetField( VALUE )->GetText(); - - if( addDatasheet ) - strCur << (wxChar)m_separatorSymbol << comp->GetField( DATASHEET )->GetText(); - } - else - { - // Print the current component reference, value and datasheet - msg = cmpName; - msg << (wxChar)m_separatorSymbol << comp->GetField( VALUE )->GetText(); - - if( addDatasheet ) - msg << (wxChar)m_separatorSymbol << comp->GetField( DATASHEET )->GetText(); - - fprintf( m_outFile, "%s", TO_UTF8( msg ) ); - } - - if( printLocCmp ) // Is allowed only for full list (not grouped) - { - msg = returnURLItemLocation( - m_cmplist[ii].GetSheetPath().PathHumanReadable(), - comp->GetPosition() ); - - fprintf( m_outFile, "%c%s", m_separatorSymbol, TO_UTF8( msg ) ); - } - - if( groupRefs ) - { - wxString tmpStr = returnFieldsString( comp ); - strCur += tmpStr; - - if( strPred.Len() == 0 ) - cmpNameFirst = cmpName; - else - { - // print a BOM line - msg.Empty(); - if( !strCur.IsSameAs( strPred ) ) - { - switch( amount ) - { - case 1: // One reference to print - // format C103;47uF;CP6;;;1 - msg << cmpNameFirst < - * | 10pF C16 Loc /controle/(X=68,580 mm, Y=83,820 mm); - */ -int BOM_LISTER::PrintComponentsListByValue( FILE* aFile ) -{ - m_outFile = aFile; - - if( m_cmplist.GetCount() == 0 ) // Build component list - { - SCH_SHEET_LIST sheetList; - sheetList.GetComponents( m_cmplist, false ); - - if( !m_includeSubComponents ) - { - // sort component list - m_cmplist.SortByReferenceOnly(); - m_cmplist.RemoveSubComponentsFromList(); - } - } - - m_cmplist.SortByValueOnly(); - - wxString msg; - - msg = _( "\n#Cmp ( order = Value )" ); - - if( m_includeSubComponents ) - msg << _( " (with SubCmp)" ); - - msg << wxT( "\n" ); - - fputs( TO_UTF8( msg ), m_outFile ); - - std::string cmpName; - for( unsigned ii = 0; ii < m_cmplist.GetCount(); ii++ ) - { - EDA_ITEM* schItem = m_cmplist[ii].GetComponent(); - - if( schItem == NULL ) - continue; - - if( schItem->Type() != SCH_COMPONENT_T ) - continue; - - SCH_COMPONENT* drawLibItem = (SCH_COMPONENT*) schItem; - - bool isMulti = false; - LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( drawLibItem->GetLibName() ); - - if( entry ) - isMulti = entry->IsMulti(); - - cmpName = m_cmplist[ii].GetRefStr(); - - if( isMulti && m_includeSubComponents ) - // Add unit ident, for mutiple parts per package - cmpName += TO_UTF8( LIB_COMPONENT::ReturnSubReference( m_cmplist[ii].GetUnit() ) ); - - fprintf( m_outFile, "| %-12s %-10s", - TO_UTF8( drawLibItem->GetField( VALUE )->GetText() ), - cmpName.c_str() ); - - // print the sheet path and location - if( m_includeSubComponents ) - { - msg = returnURLItemLocation( m_cmplist[ii].GetSheetPath().PathHumanReadable(), - drawLibItem->GetPosition() ); - fprintf( m_outFile, "%s", TO_UTF8( msg ) ); - } - - fprintf( m_outFile, "%s\n", TO_UTF8( returnFieldsString( drawLibItem ) ) ); - } - - msg = _( "#End Cmp\n" ); - fputs( TO_UTF8( msg ), m_outFile ); - return 0; -} - - -/* returnURLItemLocation - * return a formated string to print the full location: - * /( X Y position) - * param aPathName = the full sheet name of item - * param aPosition = a position (in internal units) to print - */ -const wxString BOM_LISTER::returnURLItemLocation( const wxString& aPathName, - wxPoint aPosition ) -{ - wxString text; - - text.Printf( wxT( "Loc %s(X=%s, Y=%s)" ), GetChars( aPathName ), - GetChars( ReturnStringFromValue( g_UserUnit, aPosition.x, true ) ), - GetChars( ReturnStringFromValue( g_UserUnit, aPosition.y, true ) ) ); - return text; -} diff --git a/eeschema/dialogs/annotate_dialog.h b/eeschema/dialogs/annotate_dialog.h deleted file mode 100644 index 4c0a8c50ec..0000000000 --- a/eeschema/dialogs/annotate_dialog.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 1992-2012 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 - */ - -#ifndef _ANNOTATE_DIALOG_H_ -#define _ANNOTATE_DIALOG_H_ - -#include - - -class SCH_EDIT_FRAME; -class wxConfig; - - -/*! - * DIALOG_ANNOTATE class declaration - */ - -class DIALOG_ANNOTATE: public DIALOG_ANNOTATE_BASE -{ -private: - SCH_EDIT_FRAME * m_Parent; - wxConfig* m_Config; - -public: - DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent ); - ~DIALOG_ANNOTATE(){}; - -private: - /// Initialises member variables - void InitValues(); - void OnCancelClick( wxCommandEvent& event ); - void OnClearAnnotationCmpClick( wxCommandEvent& event ); - void OnApplyClick( wxCommandEvent& event ); - - // User functions: - bool GetLevel( void ); - bool GetResetItems( void ); - int GetSortOrder( void ); - int GetAnnotateAlgo( void ); - bool GetAnnotateAutoCloseOpt() - { - return m_cbAutoCloseDlg->GetValue(); - } - bool GetAnnotateSilentMode() - { - return m_cbUseSilentMode->GetValue(); - } -}; - -#endif - // _ANNOTATE_DIALOG_H_ diff --git a/eeschema/dialogs/annotate_dialog.cpp b/eeschema/dialogs/dialog_annotate.cpp similarity index 56% rename from eeschema/dialogs/annotate_dialog.cpp rename to eeschema/dialogs/dialog_annotate.cpp index c463e11009..4015abbfe9 100644 --- a/eeschema/dialogs/annotate_dialog.cpp +++ b/eeschema/dialogs/dialog_annotate.cpp @@ -33,75 +33,132 @@ #include #include -#include +#include +#include + + +#define KEY_ANNOTATE_SORT_OPTION wxT( "AnnotateSortOption" ) +#define KEY_ANNOTATE_ALGO_OPTION wxT( "AnnotateAlgoOption" ) +#define KEY_ANNOTATE_AUTOCLOSE_OPTION wxT( "AnnotateAutoCloseOption" ) +#define KEY_ANNOTATE_USE_SILENTMODE wxT( "AnnotateSilentMode" ) + + +class wxConfig; + + +/** + * Class DIALOG_ANNOTATE + */ +class DIALOG_ANNOTATE: public DIALOG_ANNOTATE_BASE +{ +public: + DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent ); + + +private: + SCH_EDIT_FRAME* m_Parent; + wxConfig* m_Config; + + /// Initialises member variables + void InitValues(); + void OnCancelClick( wxCommandEvent& event ); + void OnClearAnnotationCmpClick( wxCommandEvent& event ); + void OnApplyClick( wxCommandEvent& event ); + + // User functions: + bool GetLevel(); + bool GetResetItems(); + + /** + * Function GetSortOrder + * @return 0 if annotation by X position, + * 1 if annotation by Y position, + * 2 if annotation by value + */ + int GetSortOrder(); + + /** + * Function GetAnnotateAlgo + * @return 0 if annotation using first not used Id value + * 1 if annotation using first not used Id value inside sheet num * 100 to sheet num * 100 + 99 + * 2 if annotation using first nhot used Id value inside sheet num * 1000 to sheet num * 1000 + 999 + */ + int GetAnnotateAlgo(); + + bool GetAnnotateAutoCloseOpt() + { + return m_cbAutoCloseDlg->GetValue(); + } + + bool GetAnnotateSilentMode() + { + return m_cbUseSilentMode->GetValue(); + } +}; -#define KEY_ANNOTATE_SORT_OPTION wxT("AnnotateSortOption") -#define KEY_ANNOTATE_ALGO_OPTION wxT("AnnotateAlgoOption") -#define KEY_ANNOTATE_AUTOCLOSE_OPTION wxT("AnnotateAutoCloseOption") -#define KEY_ANNOTATE_USE_SILENTMODE wxT("AnnotateSilentMode") DIALOG_ANNOTATE::DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent ) : DIALOG_ANNOTATE_BASE( parent ) { m_Parent = parent; + InitValues(); Layout(); - GetSizer()->SetSizeHints(this); + GetSizer()->SetSizeHints( this ); Centre(); } -/*********************************/ void DIALOG_ANNOTATE::InitValues() -/*********************************/ { m_Config = wxGetApp().GetSettings(); - SetFocus(); // needed to close dialog by escape key + if( m_Config ) { long option; - m_Config->Read(KEY_ANNOTATE_SORT_OPTION, &option, 0l); + + m_Config->Read( KEY_ANNOTATE_SORT_OPTION, &option, 0l ); switch( option ) { - default: - case 0: - m_rbSortBy_X_Position->SetValue(1); - break; + default: + case 0: + m_rbSortBy_X_Position->SetValue( 1 ); + break; - case 1: - m_rbSortBy_Y_Position->SetValue(1); - break; + case 1: + m_rbSortBy_Y_Position->SetValue( 1 ); + break; - case 2: - m_rbUseIncremental->SetValue(1); - break; - } - - m_Config->Read(KEY_ANNOTATE_ALGO_OPTION, &option, 0l); - switch( option ) - { - default: - case 0: - m_rbUseIncremental->SetValue(1); - break; - - case 1: - m_rbUseSheetNum->SetValue(1); - break; - - case 2: - m_rbStartSheetNumLarge->SetValue(1); - break; + case 2: + m_rbUseIncremental->SetValue( 1 ); + break; } - m_Config->Read(KEY_ANNOTATE_AUTOCLOSE_OPTION, &option, 0l); - if( option ) - m_cbAutoCloseDlg->SetValue(1); + m_Config->Read( KEY_ANNOTATE_ALGO_OPTION, &option, 0l ); + switch( option ) + { + default: + case 0: + m_rbUseIncremental->SetValue( 1 ); + break; - m_Config->Read(KEY_ANNOTATE_USE_SILENTMODE, &option, 0l); + case 1: + m_rbUseSheetNum->SetValue( 1 ); + break; + + case 2: + m_rbStartSheetNumLarge->SetValue( 1 ); + break; + } + + m_Config->Read( KEY_ANNOTATE_AUTOCLOSE_OPTION, &option, 0l ); if( option ) - m_cbUseSilentMode->SetValue(1); + m_cbAutoCloseDlg->SetValue( 1 ); + + m_Config->Read( KEY_ANNOTATE_USE_SILENTMODE, &option, 0l ); + if( option ) + m_cbUseSilentMode->SetValue( 1 ); } annotate_down_right_bitmap->SetBitmap( KiBitmap( annotate_down_right_xpm ) ); @@ -111,19 +168,17 @@ void DIALOG_ANNOTATE::InitValues() } -/*********************************************************/ void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event ) -/*********************************************************/ { - int response; - wxString message; + int response; + wxString message; if( m_Config ) { - m_Config->Write(KEY_ANNOTATE_SORT_OPTION, GetSortOrder()); - m_Config->Write(KEY_ANNOTATE_ALGO_OPTION, GetAnnotateAlgo()); - m_Config->Write(KEY_ANNOTATE_AUTOCLOSE_OPTION, GetAnnotateAutoCloseOpt()); - m_Config->Write(KEY_ANNOTATE_USE_SILENTMODE, GetAnnotateSilentMode()); + m_Config->Write( KEY_ANNOTATE_SORT_OPTION, GetSortOrder() ); + m_Config->Write( KEY_ANNOTATE_ALGO_OPTION, GetAnnotateAlgo() ); + m_Config->Write( KEY_ANNOTATE_AUTOCLOSE_OPTION, GetAnnotateAutoCloseOpt() ); + m_Config->Write( KEY_ANNOTATE_USE_SILENTMODE, GetAnnotateSilentMode() ); } // Display a message info in verbose mode, @@ -152,7 +207,7 @@ void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event ) { response = wxMessageBox( message, wxT( "" ), wxICON_EXCLAMATION | wxOK | wxCANCEL ); - if (response == wxCANCEL) + if( response == wxCANCEL ) return; } @@ -176,13 +231,11 @@ void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event ) } -/************************************************************************/ void DIALOG_ANNOTATE::OnClearAnnotationCmpClick( wxCommandEvent& event ) -/************************************************************************/ { - int response; + int response; + wxString message; - wxString message; if( GetLevel() ) message = _( "Clear the existing annotation for the entire schematic?" ); else @@ -191,19 +244,17 @@ void DIALOG_ANNOTATE::OnClearAnnotationCmpClick( wxCommandEvent& event ) message += _( "\n\nThis operation will clear the existing annotation and cannot be undone." ); response = wxMessageBox( message, wxT( "" ), wxICON_EXCLAMATION | wxOK | wxCANCEL ); - if (response == wxCANCEL) + if( response == wxCANCEL ) return; m_Parent->DeleteAnnotation( GetLevel() ? false : true ); m_Parent->GetCanvas()->Refresh(); - m_btnClear->Enable(false); + m_btnClear->Enable( false ); } -/************************************************************/ void DIALOG_ANNOTATE::OnCancelClick( wxCommandEvent& event ) -/************************************************************/ { if( IsModal() ) EndModal( wxID_CANCEL ); @@ -215,44 +266,46 @@ void DIALOG_ANNOTATE::OnCancelClick( wxCommandEvent& event ) } -/**************************************/ -bool DIALOG_ANNOTATE::GetLevel( void ) -/**************************************/ +bool DIALOG_ANNOTATE::GetLevel() { return m_rbEntireSchematic->GetValue(); } -/******************************************/ -bool DIALOG_ANNOTATE::GetResetItems( void ) -/******************************************/ + +bool DIALOG_ANNOTATE::GetResetItems() { return m_rbResetAnnotation->GetValue(); } -int DIALOG_ANNOTATE::GetSortOrder( void ) -/** - * @return 0 if annotation by X position, - * 1 if annotation by Y position, - * 2 if annotation by value - */ + +int DIALOG_ANNOTATE::GetSortOrder() { - if ( m_rbSortBy_X_Position->GetValue() ) + if( m_rbSortBy_X_Position->GetValue() ) return 0; - if ( m_rbSortBy_Y_Position->GetValue() ) + + if( m_rbSortBy_Y_Position->GetValue() ) return 1; + return 2; } -int DIALOG_ANNOTATE::GetAnnotateAlgo( void ) -/** - * @return 0 if annotation using first not used Id value - * 1 if annotation using first not used Id value inside sheet num * 100 to sheet num * 100 + 99 - * 2 if annotation using first nhot used Id value inside sheet num * 1000 to sheet num * 1000 + 999 - */ + +int DIALOG_ANNOTATE::GetAnnotateAlgo() { - if ( m_rbUseIncremental->GetValue() ) + if( m_rbUseIncremental->GetValue() ) return 0; - if ( m_rbUseSheetNum->GetValue() ) + + if( m_rbUseSheetNum->GetValue() ) return 1; + return 2; } + + +int InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller ) +{ + DIALOG_ANNOTATE dlg( aCaller ); + + return dlg.ShowModal(); +} + diff --git a/eeschema/dialogs/dialog_build_BOM.cpp b/eeschema/dialogs/dialog_build_BOM.cpp deleted file mode 100644 index 95c01afe22..0000000000 --- a/eeschema/dialogs/dialog_build_BOM.cpp +++ /dev/null @@ -1,591 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2011 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 dialog_build_BOM.cpp - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include - - -/* Local variables */ -static bool s_ListByRef = true; -static bool s_ListByValue = true; -static bool s_ListWithSubCmponents; -static bool s_ListHierarchicalPinByName; -static bool s_ListHierarchicalPinBySheet; -static bool s_BrowseCreatedList; -static int s_OutputFormOpt; -static int s_OutputSeparatorOpt; -static bool s_Add_Location = false; -static bool s_Add_FpField_state = true; -static bool s_Add_DatasheetField_state; -static bool s_Add_F1_state; -static bool s_Add_F2_state; -static bool s_Add_F3_state; -static bool s_Add_F4_state; -static bool s_Add_F5_state; -static bool s_Add_F6_state; -static bool s_Add_F7_state; -static bool s_Add_F8_state; -static bool s_Add_Alls_state; -static char s_ExportSeparatorSymbol; - - -static bool* s_AddFieldList[] = -{ - &s_Add_FpField_state, - &s_Add_F1_state, - &s_Add_F2_state, - &s_Add_F3_state, - &s_Add_F4_state, - &s_Add_F5_state, - &s_Add_F6_state, - &s_Add_F7_state, - &s_Add_F8_state, - &s_Add_Alls_state, - &s_Add_DatasheetField_state, - NULL -}; - - -const wxString OPTION_BOM_LIST_REF( wxT("BomListPerRef") ); -const wxString OPTION_BOM_LIST_VALUE( wxT("BomListPerValue") ); -const wxString OPTION_BOM_LIST_HPINS( wxT("BomListPerHPins") ); -const wxString OPTION_BOM_LIST_HPINS_BY_SHEET( wxT("BomListHPinsPerSheet") ); -const wxString OPTION_BOM_LIST_HPINS_BY_NAME_( wxT("BomListHPinsPerName") ); -const wxString OPTION_BOM_LIST_SUB_CMP( wxT("BomListSubCmps") ); - -const wxString OPTION_BOM_FORMAT( wxT("BomFormat") ); -const wxString OPTION_BOM_LAUNCH_BROWSER( wxT("BomLaunchBrowser") ); -const wxString OPTION_BOM_SEPARATOR( wxT("BomExportSeparator") ); -const wxString OPTION_BOM_ADD_FIELD ( wxT("BomAddField") ); -const wxString OPTION_BOM_ADD_LOCATION ( wxT("BomAddLocation") ); - -/* list of separators used in bom export to spreadsheet - * (selected by s_OutputSeparatorOpt, and s_OutputSeparatorOpt radiobox) - */ -static char s_ExportSeparator[] = ("\t;,."); - -/*! - * DIALOG_BUILD_BOM dialog type definition - */ - - -DIALOG_BUILD_BOM::DIALOG_BUILD_BOM( EDA_DRAW_FRAME* parent ) : - DIALOG_BUILD_BOM_BASE( parent ) -{ - m_config = wxGetApp().GetSettings(); - wxASSERT( m_config != NULL ); - - m_parent = parent; - - Init(); - - if( GetSizer() ) - { - GetSizer()->SetSizeHints( this ); - } - Centre(); -} - - -/*! - * Init Controls for DIALOG_BUILD_BOM - */ - -void DIALOG_BUILD_BOM::Init() -{ - SetFocus(); - - /* Get options */ - m_config->Read( OPTION_BOM_LIST_REF, &s_ListByRef ); - m_config->Read( OPTION_BOM_LIST_VALUE , &s_ListByValue ); - m_config->Read( OPTION_BOM_LIST_HPINS, &s_ListHierarchicalPinByName ); - m_config->Read( OPTION_BOM_LIST_HPINS_BY_SHEET, &s_ListWithSubCmponents ); - m_config->Read( OPTION_BOM_LIST_HPINS_BY_NAME_, &s_ListWithSubCmponents ); - m_config->Read( OPTION_BOM_LIST_SUB_CMP, &s_ListWithSubCmponents ); - m_config->Read( OPTION_BOM_LIST_HPINS_BY_SHEET, &s_ListHierarchicalPinBySheet ); - m_config->Read( OPTION_BOM_LIST_HPINS_BY_NAME_, &s_ListHierarchicalPinByName ); - s_OutputFormOpt = m_config->Read( OPTION_BOM_FORMAT, 0l ); - m_config->Read( OPTION_BOM_LAUNCH_BROWSER, &s_BrowseCreatedList ); - s_OutputSeparatorOpt = m_config->Read( OPTION_BOM_SEPARATOR, 0l ); - m_config->Read( OPTION_BOM_ADD_LOCATION, &s_Add_Location ); - - long addfields = m_config->Read( OPTION_BOM_ADD_FIELD, 0l ); - for( int ii = 0, bitmask = 1; s_AddFieldList[ii] != NULL; ii++ ) - { - if( (addfields & bitmask) ) - *s_AddFieldList[ii] = true; - else - *s_AddFieldList[ii] = false; - - bitmask <<= 1; - } - - // Set validators - m_ListCmpbyRefItems->SetValidator( wxGenericValidator( &s_ListByRef ) ); - m_ListSubCmpItems->SetValidator( wxGenericValidator( &s_ListWithSubCmponents ) ); - m_ListCmpbyValItems->SetValidator( wxGenericValidator( &s_ListByValue ) ); - m_GenListLabelsbyVal->SetValidator( wxGenericValidator( &s_ListHierarchicalPinByName ) ); - m_GenListLabelsbySheet->SetValidator( wxGenericValidator( &s_ListHierarchicalPinBySheet ) ); - m_OutputFormCtrl->SetValidator( wxGenericValidator( &s_OutputFormOpt ) ); - m_OutputSeparatorCtrl->SetValidator( wxGenericValidator( &s_OutputSeparatorOpt ) ); - m_GetListBrowser->SetValidator( wxGenericValidator( &s_BrowseCreatedList ) ); - - m_AddLocationField->SetValidator( wxGenericValidator( &s_Add_Location ) ); - m_AddFootprintField->SetValidator( wxGenericValidator( &s_Add_FpField_state ) ); - m_AddDatasheetField->SetValidator( wxGenericValidator( &s_Add_DatasheetField_state ) ); - m_AddField1->SetValidator( wxGenericValidator( &s_Add_F1_state ) ); - m_AddField2->SetValidator( wxGenericValidator( &s_Add_F2_state ) ); - m_AddField3->SetValidator( wxGenericValidator( &s_Add_F3_state ) ); - m_AddField4->SetValidator( wxGenericValidator( &s_Add_F4_state ) ); - m_AddField5->SetValidator( wxGenericValidator( &s_Add_F5_state ) ); - m_AddField6->SetValidator( wxGenericValidator( &s_Add_F6_state ) ); - m_AddField7->SetValidator( wxGenericValidator( &s_Add_F7_state ) ); - m_AddField8->SetValidator( wxGenericValidator( &s_Add_F8_state ) ); - m_AddAllFields->SetValidator( wxGenericValidator( &s_Add_Alls_state ) ); - - m_OutputFormCtrl->SetSelection( s_OutputFormOpt ); - m_OutputSeparatorCtrl->SetSelection( s_OutputSeparatorOpt ); - - // Enable/disable options: - wxCommandEvent dummy; - OnRadioboxSelectFormatSelected( dummy ); -} - - -/* - * Called on BOM format selection: - * Enable/disable options in dialog - */ -void DIALOG_BUILD_BOM::OnRadioboxSelectFormatSelected( wxCommandEvent& event ) -{ - switch( m_OutputFormCtrl->GetSelection() ) - { - case 0: // Human readable text full report - m_OutputSeparatorCtrl->Enable( false ); - m_ListCmpbyRefItems->Enable( true ); - m_ListCmpbyValItems->Enable( true ); - m_GenListLabelsbyVal->Enable( true ); - m_GenListLabelsbySheet->Enable( true ); - m_ListSubCmpItems->Enable( true ); - m_AddLocationField->Enable( true ); - break; - - case 1: // Csv format, full list by reference - m_OutputSeparatorCtrl->Enable( true ); - m_ListCmpbyRefItems->Enable( false ); - m_ListCmpbyValItems->Enable( false ); - m_GenListLabelsbyVal->Enable( false ); - m_GenListLabelsbySheet->Enable( false ); - m_ListSubCmpItems->Enable( true ); - m_AddLocationField->Enable( true ); - break; - - case 2: // Csv format, grouped list by reference - m_OutputSeparatorCtrl->Enable( true ); - m_ListCmpbyRefItems->Enable( false ); - m_ListCmpbyValItems->Enable( false ); - m_GenListLabelsbyVal->Enable( false ); - m_GenListLabelsbySheet->Enable( false ); - m_ListSubCmpItems->Enable( false ); - m_AddLocationField->Enable( false ); - break; - - case 3: // Csv format, short list by values - m_OutputSeparatorCtrl->Enable( true ); - m_ListCmpbyRefItems->Enable( false ); - m_ListCmpbyValItems->Enable( false ); - m_GenListLabelsbyVal->Enable( false ); - m_GenListLabelsbySheet->Enable( false ); - m_ListSubCmpItems->Enable( false ); - m_AddLocationField->Enable( false ); - break; - } -} - - -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK - */ - -void DIALOG_BUILD_BOM::OnOkClick( wxCommandEvent& event ) -{ - char ExportSeparatorSymbol = s_ExportSeparator[0]; - - if( m_OutputSeparatorCtrl->GetSelection() > 0 ) - ExportSeparatorSymbol = s_ExportSeparator[m_OutputSeparatorCtrl->GetSelection()]; - - int ExportFileType = m_OutputFormCtrl->GetSelection(); - - SavePreferences(); - - Create_BOM_Lists( ExportFileType, m_ListSubCmpItems->GetValue(), - ExportSeparatorSymbol, m_GetListBrowser->GetValue() ); -} - - -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL - */ - -void DIALOG_BUILD_BOM::OnCancelClick( wxCommandEvent& event ) -{ - EndModal( -1 ); -} - - -void DIALOG_BUILD_BOM::SavePreferences() -{ - // Determine current settings of "List items" and "Options" checkboxes - s_ListByRef = m_ListCmpbyRefItems->GetValue(); - s_ListWithSubCmponents = m_ListSubCmpItems->GetValue(); - s_ListByValue = m_ListCmpbyValItems->GetValue(); - s_ListHierarchicalPinByName = m_GenListLabelsbyVal->GetValue(); - s_ListHierarchicalPinBySheet = m_GenListLabelsbySheet->GetValue(); - s_BrowseCreatedList = m_GetListBrowser->GetValue(); - - // (saved in config ): - - // Determine current settings of both radiobutton groups - s_OutputFormOpt = m_OutputFormCtrl->GetSelection(); - s_OutputSeparatorOpt = m_OutputSeparatorCtrl->GetSelection(); - - if( s_OutputSeparatorOpt < 0 ) - s_OutputSeparatorOpt = 0; - - // Determine current settings of all "Fields to add" checkboxes - s_Add_Location = m_AddLocationField->GetValue(); - s_Add_FpField_state = m_AddFootprintField->GetValue(); - s_Add_DatasheetField_state = m_AddDatasheetField->GetValue(); - s_Add_F1_state = m_AddField1->GetValue(); - s_Add_F2_state = m_AddField2->GetValue(); - s_Add_F3_state = m_AddField3->GetValue(); - s_Add_F4_state = m_AddField4->GetValue(); - s_Add_F5_state = m_AddField5->GetValue(); - s_Add_F6_state = m_AddField6->GetValue(); - s_Add_F7_state = m_AddField7->GetValue(); - s_Add_F8_state = m_AddField8->GetValue(); - s_Add_Alls_state = m_AddAllFields->GetValue(); - - // Now save current settings of both radiobutton groups - m_config->Write( OPTION_BOM_LIST_REF, s_ListByRef ); - m_config->Write( OPTION_BOM_LIST_VALUE , s_ListByValue ); - m_config->Write( OPTION_BOM_LIST_HPINS, s_ListHierarchicalPinByName ); - m_config->Write( OPTION_BOM_LIST_HPINS_BY_SHEET, s_ListHierarchicalPinBySheet ); - m_config->Write( OPTION_BOM_LIST_HPINS_BY_NAME_, s_ListHierarchicalPinByName ); - m_config->Write( OPTION_BOM_LIST_SUB_CMP, s_ListWithSubCmponents ); - - m_config->Write( OPTION_BOM_FORMAT, (long) s_OutputFormOpt ); - m_config->Write( OPTION_BOM_SEPARATOR, (long) s_OutputSeparatorOpt ); - m_config->Write( OPTION_BOM_LAUNCH_BROWSER, (long) s_BrowseCreatedList ); - - // Now save current settings of all "Fields to add" checkboxes - m_config->Write( OPTION_BOM_ADD_LOCATION, s_Add_Location ); - - long addfields = 0; - for( int ii = 0, bitmask = 1; s_AddFieldList[ii] != NULL; ii++ ) - { - if( *s_AddFieldList[ii] ) - addfields |= bitmask; - - bitmask <<= 1; - } - - m_config->Write( OPTION_BOM_ADD_FIELD, addfields ); -} - - -void DIALOG_BUILD_BOM::Create_BOM_Lists( int aTypeFile, - bool aIncludeSubComponents, - char aExportSeparatorSymbol, - bool aRunBrowser ) -{ - wxString wildcard; - - static wxFileName fn; - - wxFileName current = g_RootSheet->GetScreen()->GetFileName(); - - s_ExportSeparatorSymbol = aExportSeparatorSymbol; - - if( !fn.HasName() || fn.GetName()==NAMELESS_PROJECT ) - { - fn.SetName( current.GetName() ); - } - // else use a previous run's name, because fn was set before and user - // is probably just iteratively refining the BOM. - - if( fn.GetPath().IsEmpty() ) - { - fn.SetPath( current.GetPath() ); - } - // else use a previous run's path, because fn was set before and user - // is probably just iteratively refining the BOM. - - wxString bomDesc = _( "Bill of Materials" ); // translate once, use twice. - - if( aTypeFile == 0 ) - { - fn.SetExt( wxT( "lst" ) ); - wildcard = bomDesc + wxT( " (*.lst)|*.lst" ); - } - else - { - fn.SetExt( wxT( "csv" ) ); - wildcard = bomDesc + wxT( " (*.csv)|*.csv" ); - } - - wxFileDialog dlg( this, bomDesc, fn.GetPath(), - fn.GetFullName(), wildcard, wxFD_SAVE ); - - if( dlg.ShowModal() == wxID_CANCEL ) - return; - - fn = dlg.GetPath(); // remember path+filename+ext for subsequent runs. - - m_listFileName = dlg.GetPath(); - - // Close dialog, then show the list (if so requested) - - switch( aTypeFile ) - { - case 0: // list - CreatePartsAndLabelsFullList( aIncludeSubComponents ); - break; - - case 1: // spreadsheet, Single Part per line - CreateSpreadSheetPartsFullList( aIncludeSubComponents, s_Add_Location, false ); - break; - - case 2: // spreadsheet, group Part with same fields per line - CreateSpreadSheetPartsFullList( aIncludeSubComponents, s_Add_Location, true ); - break; - - case 3: // spreadsheet, one value per line and no sub-component - CreateSpreadSheetPartsShortList(); - break; - } - - EndModal( 1 ); - - if( aRunBrowser ) - { - wxString editorname = wxGetApp().GetEditorName(); - wxString filename = m_listFileName; - AddDelimiterString( filename ); - ExecuteFile( this, editorname, filename ); - } -} - -/** Helper function IsFieldChecked - * return the state of the wxCheckbox corresponding to the - * field aFieldId (FOOTPRINT, DATASHEET and FIELD1 to FIELD8 - * if the option "All user fields" is checked, return always true - * for fileds ids >= FIELD1 - * @param aFieldId = the field id : FOOTPRINT to FIELD8 - */ -bool DIALOG_BUILD_BOM::IsFieldChecked(int aFieldId) -{ - if( m_AddAllFields->IsChecked() && (aFieldId>= FIELD1) ) - return true; - - switch ( aFieldId ) - { - case FIELD1: - return m_AddField1->IsChecked(); - case FIELD2: - return m_AddField2->IsChecked(); - case FIELD3: - return m_AddField3->IsChecked(); - case FIELD4: - return m_AddField4->IsChecked(); - case FIELD5: - return m_AddField5->IsChecked(); - case FIELD6: - return m_AddField6->IsChecked(); - case FIELD7: - return m_AddField7->IsChecked(); - case FIELD8: - return m_AddField8->IsChecked(); - case FOOTPRINT: - return m_AddFootprintField->IsChecked(); - case DATASHEET: - return m_AddDatasheetField->IsChecked(); - } - - return false; -} - - -/* Prints a list of components, in a form which can be imported by a spreadsheet. - * components having the same value and the same footprint - * are grouped on the same line - * Form is: - * value; number of components; list of references; ; ; ...; - * list is sorted by values - */ -void DIALOG_BUILD_BOM::CreateSpreadSheetPartsShortList( ) -{ - FILE* f; - - if( ( f = wxFopen( m_listFileName, wxT( "wt" ) ) ) == NULL ) - { - wxString msg; - msg.Printf( _( "Failed to open file <%s>" ), GetChars(m_listFileName) ); - DisplayError( this, msg ); - return; - } - - BOM_LISTER bom_lister; - bom_lister.SetCvsFormOn( s_ExportSeparatorSymbol ); - - // Set the list of fields to add to list - for( int ii = FOOTPRINT; ii <= FIELD8; ii++ ) - if( IsFieldChecked( ii ) ) - bom_lister.AddFieldIdToPrintList( ii ); - // Write the list of components grouped by values: - bom_lister.CreateCsvBOMListByValues( f ); -} - - -/* - * Print a list of components, in a form which can be imported by a spreadsheet - * form is: - * cmp ref; cmp val; fields; - * Components are sorted by reference - * param aIncludeSubComponents = true to print sub components - * param aPrintLocation = true to print components location - * (only possible when aIncludeSubComponents == true) - * param aGroupRefs = true to group components references, when other fieds - * have the same value - */ -void DIALOG_BUILD_BOM::CreateSpreadSheetPartsFullList( bool aIncludeSubComponents, - bool aPrintLocation, - bool aGroupRefs ) -{ - FILE* f; - wxString msg; - - if( ( f = wxFopen( m_listFileName, wxT( "wt" ) ) ) == NULL ) - { - msg.Printf( _( "Failed to open file <%s>" ), GetChars( m_listFileName ) ); - DisplayError( this, msg ); - return; - } - - BOM_LISTER bom_lister; - bom_lister.SetCvsFormOn( s_ExportSeparatorSymbol ); - - // Set group refs option (hight priority): - // Obvioulsy only useful when not including sub-components - bom_lister.SetGroupReferences( aGroupRefs ); - bom_lister.SetIncludeSubCmp( aIncludeSubComponents && !aGroupRefs ); - - // Set print location option: - // Obvioulsy only possible when including sub components - // and not grouping references - bom_lister.SetPrintLocation( aPrintLocation && !aGroupRefs && - aIncludeSubComponents ); - - // Set the list of fields to add to list - for( int ii = FOOTPRINT; ii <= FIELD8; ii++ ) - if( IsFieldChecked( ii ) ) - bom_lister.AddFieldIdToPrintList( ii ); - - // create the file - bom_lister.PrintComponentsListByReferenceCsvForm( f ); - - fclose( f ); -} - - -/* - * CreatePartsAndLabelsFullList() - * Main function to create the list of components and/or labels - * (global labels, hierarchical labels and pin sheets ) - */ -void DIALOG_BUILD_BOM::CreatePartsAndLabelsFullList( bool aIncludeSubComponents ) -{ - FILE* f; - wxString msg; - - if( ( f = wxFopen( m_listFileName, wxT( "wt" ) ) ) == NULL ) - { - msg.Printf( _( "Failed to open file <%s>" ), GetChars( m_listFileName ) ); - DisplayError( this, msg ); - return; - } - - BOM_LISTER bom_lister; - bom_lister.SetIncludeSubCmp( aIncludeSubComponents ); - bom_lister.SetCvsFormOff(); - bom_lister.SetPrintLocation( s_Add_Location ); - // Set the list of fields to add to list - for( int ii = FOOTPRINT; ii <= FIELD8; ii++ ) - if( IsFieldChecked( ii ) ) - bom_lister.AddFieldIdToPrintList( ii ); - - // creates the list file - wxString Title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion(); - - fprintf( f, "%s >> Creation date: %s\n", TO_UTF8( Title ), TO_UTF8( DateAndTime() ) ); - - if( m_ListCmpbyRefItems->GetValue() ) - bom_lister.PrintComponentsListByReferenceHumanReadable( f ); - - if( m_ListCmpbyValItems->GetValue() ) - bom_lister.PrintComponentsListByValue( f ); - - // Create list of global labels, hierachical labels and pins sheets - - if( m_GenListLabelsbySheet->GetValue() ) - bom_lister.PrintGlobalAndHierarchicalLabelsList( f, true ); - - if( m_GenListLabelsbyVal->GetValue() ) - bom_lister.PrintGlobalAndHierarchicalLabelsList( f, false ); - - msg = _( "\n#End List\n" ); - fprintf( f, "%s", TO_UTF8( msg ) ); - fclose( f ); -} diff --git a/eeschema/dialogs/dialog_build_BOM.h b/eeschema/dialogs/dialog_build_BOM.h deleted file mode 100644 index ea83e5980f..0000000000 --- a/eeschema/dialogs/dialog_build_BOM.h +++ /dev/null @@ -1,94 +0,0 @@ -/** - * @file dialog_build_BOM.h - */ - -/* This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 1992-2012 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 - */ - - -#ifndef _DIALOG_BUILD_BOM_H_ -#define _DIALOG_BUILD_BOM_H_ - -#include - - -class EDA_DRAW_FRAME; -class SCH_COMPONENT; -class wxConfig; - -class DIALOG_BUILD_BOM : public DIALOG_BUILD_BOM_BASE -{ -private: - EDA_DRAW_FRAME* m_parent; - wxConfig* m_config; - wxString m_listFileName; // The full filename of the file report. - -private: - void OnRadioboxSelectFormatSelected( wxCommandEvent& event ); - void OnOkClick( wxCommandEvent& event ); - void OnCancelClick( wxCommandEvent& event ); - - void SavePreferences(); - void Init(); - void Create_BOM_Lists( int aTypeFile, - bool aIncludeSubComponents, - char aExportSeparatorSymbol, - bool aRunBrowser ); - - void CreatePartsAndLabelsFullList( bool aIncludeSubComponents ); - - /** - * Function CreateSpreadSheetPartsFullList - * prints a list of components, in a form which can be imported by a - * spreadsheet. Form is: - * reference; cmp value; \; \; ...; - * Components are sorted by reference - * @param aIncludeSubComponents = true to print sub components - * @param aPrintLocation = true to print components location - * (only possible when aIncludeSubComponents == true) - * @param aGroupRefs = true to group components references, when other fieds - * have the same value - */ - void CreateSpreadSheetPartsFullList( bool aIncludeSubComponents, - bool aPrintLocation, - bool aGroupRefs ); - - /** - * Function CreateSpreadSheetPartsShortList - * prints a list of components, in a form which can be imported by a spreadsheet. - * components having the same value and the same footprint - * are grouped on the same line - * Form is: - * value; number of components; list of references; \; \; ...; - * list is sorted by values - */ - void CreateSpreadSheetPartsShortList(); - - bool IsFieldChecked( int aFieldId ); - -public: - DIALOG_BUILD_BOM( EDA_DRAW_FRAME* parent ); - - // ~DIALOG_BUILD_BOM() {}; -}; - -#endif // _DIALOG_BUILD_BOM_H_ diff --git a/eeschema/dialogs/dialog_build_BOM_base.cpp b/eeschema/dialogs/dialog_build_BOM_base.cpp deleted file mode 100644 index 4db0da25b3..0000000000 --- a/eeschema/dialogs/dialog_build_BOM_base.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 8 2012) -// http://www.wxformbuilder.org/ -// -// PLEASE DO "NOT" EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include "dialog_build_BOM_base.h" - -/////////////////////////////////////////////////////////////////////////// - -DIALOG_BUILD_BOM_BASE::DIALOG_BUILD_BOM_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) -{ - this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - - wxBoxSizer* bMainSizer; - bMainSizer = new wxBoxSizer( wxVERTICAL ); - - wxBoxSizer* bSizerUpper; - bSizerUpper = new wxBoxSizer( wxHORIZONTAL ); - - wxStaticBoxSizer* sbOptionsSizer; - sbOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options:") ), wxVERTICAL ); - - wxStaticBoxSizer* sbListOptionsSizer; - sbListOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("List items:") ), wxVERTICAL ); - - m_ListCmpbyRefItems = new wxCheckBox( this, wxID_ANY, _("Components by reference"), wxDefaultPosition, wxDefaultSize, 0 ); - sbListOptionsSizer->Add( m_ListCmpbyRefItems, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_ListSubCmpItems = new wxCheckBox( this, wxID_ANY, _("Sub components (i.e. U2A, U2B ...)"), wxDefaultPosition, wxDefaultSize, 0 ); - sbListOptionsSizer->Add( m_ListSubCmpItems, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_ListCmpbyValItems = new wxCheckBox( this, wxID_ANY, _("Components by value"), wxDefaultPosition, wxDefaultSize, 0 ); - sbListOptionsSizer->Add( m_ListCmpbyValItems, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_GenListLabelsbyVal = new wxCheckBox( this, wxID_ANY, _("Hierarchical pins by name"), wxDefaultPosition, wxDefaultSize, 0 ); - sbListOptionsSizer->Add( m_GenListLabelsbyVal, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_GenListLabelsbySheet = new wxCheckBox( this, wxID_ANY, _("Hierarchical pins by sheet"), wxDefaultPosition, wxDefaultSize, 0 ); - sbListOptionsSizer->Add( m_GenListLabelsbySheet, 0, wxALL, 5 ); - - - sbOptionsSizer->Add( sbListOptionsSizer, 0, wxEXPAND, 5 ); - - wxString m_OutputFormCtrlChoices[] = { _("List"), _("List for spreadsheet import (by ref)"), _("List for spreadsheet import (by grouped ref)"), _("List for spreadsheet import (by value)") }; - int m_OutputFormCtrlNChoices = sizeof( m_OutputFormCtrlChoices ) / sizeof( wxString ); - m_OutputFormCtrl = new wxRadioBox( this, ID_RADIOBOX_SELECT_FORMAT, _("Output format:"), wxDefaultPosition, wxDefaultSize, m_OutputFormCtrlNChoices, m_OutputFormCtrlChoices, 1, wxRA_SPECIFY_COLS ); - m_OutputFormCtrl->SetSelection( 1 ); - sbOptionsSizer->Add( m_OutputFormCtrl, 0, wxEXPAND|wxTOP, 5 ); - - wxString m_OutputSeparatorCtrlChoices[] = { _("Tab"), _(";"), _(",") }; - int m_OutputSeparatorCtrlNChoices = sizeof( m_OutputSeparatorCtrlChoices ) / sizeof( wxString ); - m_OutputSeparatorCtrl = new wxRadioBox( this, wxID_ANY, _("Field separator for spreadsheet import:"), wxDefaultPosition, wxDefaultSize, m_OutputSeparatorCtrlNChoices, m_OutputSeparatorCtrlChoices, 1, wxRA_SPECIFY_ROWS ); - m_OutputSeparatorCtrl->SetSelection( 0 ); - sbOptionsSizer->Add( m_OutputSeparatorCtrl, 0, wxEXPAND|wxTOP, 5 ); - - m_GetListBrowser = new wxCheckBox( this, wxID_ANY, _("Launch list browser"), wxDefaultPosition, wxDefaultSize, 0 ); - sbOptionsSizer->Add( m_GetListBrowser, 0, wxALL|wxEXPAND, 5 ); - - - bSizerUpper->Add( sbOptionsSizer, 3, wxALL|wxEXPAND, 5 ); - - wxBoxSizer* bRightSizer; - bRightSizer = new wxBoxSizer( wxVERTICAL ); - - wxStaticBoxSizer* sbAddToListSelectionSizer; - sbAddToListSelectionSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Add to list:") ), wxVERTICAL ); - - m_AddLocationField = new wxCheckBox( this, wxID_ANY, _("Component location"), wxDefaultPosition, wxDefaultSize, 0 ); - sbAddToListSelectionSizer->Add( m_AddLocationField, 0, wxALL, 5 ); - - wxStaticBoxSizer* sbFixedFieldsSizer; - sbFixedFieldsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("System Fields:") ), wxVERTICAL ); - - m_AddDatasheetField = new wxCheckBox( this, wxID_ANY, _("Datasheet"), wxDefaultPosition, wxDefaultSize, 0 ); - sbFixedFieldsSizer->Add( m_AddDatasheetField, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_AddFootprintField = new wxCheckBox( this, wxID_ANY, _("Footprint"), wxDefaultPosition, wxDefaultSize, 0 ); - sbFixedFieldsSizer->Add( m_AddFootprintField, 0, wxALL|wxEXPAND, 5 ); - - - sbAddToListSelectionSizer->Add( sbFixedFieldsSizer, 0, wxEXPAND, 5 ); - - wxStaticBoxSizer* sbUsersFiledsSizer; - sbUsersFiledsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Users fields:") ), wxVERTICAL ); - - m_AddField1 = new wxCheckBox( this, wxID_ANY, _("Field 1"), wxDefaultPosition, wxDefaultSize, 0 ); - sbUsersFiledsSizer->Add( m_AddField1, 0, wxEXPAND|wxALL, 5 ); - - m_AddField2 = new wxCheckBox( this, wxID_ANY, _("Field 2"), wxDefaultPosition, wxDefaultSize, 0 ); - sbUsersFiledsSizer->Add( m_AddField2, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_AddField3 = new wxCheckBox( this, wxID_ANY, _("Field 3"), wxDefaultPosition, wxDefaultSize, 0 ); - sbUsersFiledsSizer->Add( m_AddField3, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_AddField4 = new wxCheckBox( this, wxID_ANY, _("Field 4"), wxDefaultPosition, wxDefaultSize, 0 ); - sbUsersFiledsSizer->Add( m_AddField4, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_AddField5 = new wxCheckBox( this, wxID_ANY, _("Field 5"), wxDefaultPosition, wxDefaultSize, 0 ); - sbUsersFiledsSizer->Add( m_AddField5, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_AddField6 = new wxCheckBox( this, wxID_ANY, _("Field 6"), wxDefaultPosition, wxDefaultSize, 0 ); - sbUsersFiledsSizer->Add( m_AddField6, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_AddField7 = new wxCheckBox( this, wxID_ANY, _("Field 7"), wxDefaultPosition, wxDefaultSize, 0 ); - sbUsersFiledsSizer->Add( m_AddField7, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_AddField8 = new wxCheckBox( this, wxID_ANY, _("Field 8"), wxDefaultPosition, wxDefaultSize, 0 ); - sbUsersFiledsSizer->Add( m_AddField8, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - - sbAddToListSelectionSizer->Add( sbUsersFiledsSizer, 0, wxEXPAND|wxTOP, 5 ); - - m_AddAllFields = new wxCheckBox( this, wxID_ANY, _("All existing user fields"), wxDefaultPosition, wxDefaultSize, 0 ); - sbAddToListSelectionSizer->Add( m_AddAllFields, 0, wxALL, 5 ); - - - bRightSizer->Add( sbAddToListSelectionSizer, 1, wxEXPAND, 5 ); - - - bSizerUpper->Add( bRightSizer, 2, wxALL|wxEXPAND, 5 ); - - - bMainSizer->Add( bSizerUpper, 1, wxEXPAND, 5 ); - - m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bMainSizer->Add( m_staticline1, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 ); - - m_sdbSizer = new wxStdDialogButtonSizer(); - m_sdbSizerOK = new wxButton( this, wxID_OK ); - m_sdbSizer->AddButton( m_sdbSizerOK ); - m_sdbSizerCancel = new wxButton( this, wxID_CANCEL ); - m_sdbSizer->AddButton( m_sdbSizerCancel ); - m_sdbSizer->Realize(); - - bMainSizer->Add( m_sdbSizer, 0, wxALL|wxEXPAND, 5 ); - - - this->SetSizer( bMainSizer ); - this->Layout(); - bMainSizer->Fit( this ); - - // Connect Events - m_OutputFormCtrl->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnRadioboxSelectFormatSelected ), NULL, this ); - m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnCancelClick ), NULL, this ); - m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnOkClick ), NULL, this ); -} - -DIALOG_BUILD_BOM_BASE::~DIALOG_BUILD_BOM_BASE() -{ - // Disconnect Events - m_OutputFormCtrl->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnRadioboxSelectFormatSelected ), NULL, this ); - m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnCancelClick ), NULL, this ); - m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnOkClick ), NULL, this ); - -} diff --git a/eeschema/dialogs/dialog_build_BOM_base.fbp b/eeschema/dialogs/dialog_build_BOM_base.fbp deleted file mode 100644 index 2fa029deeb..0000000000 --- a/eeschema/dialogs/dialog_build_BOM_base.fbp +++ /dev/null @@ -1,2060 +0,0 @@ - - - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - dialog_build_BOM_base - 1000 - none - 1 - dialog_build_BOM_base - - . - - 1 - 1 - 1 - 1 - 0 - - 0 - wxAUI_MGR_DEFAULT - - - - 1 - 1 - impl_virtual - - - - 0 - wxID_ANY - - - DIALOG_BUILD_BOM_BASE - - -1,-1 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - DIALOG_SHIM; dialog_shim.h - List of Materials - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bMainSizer - wxVERTICAL - none - - 5 - wxEXPAND - 1 - - - bSizerUpper - wxHORIZONTAL - none - - 5 - wxALL|wxEXPAND - 3 - - wxID_ANY - Options: - - sbOptionsSizer - wxVERTICAL - none - - - 5 - wxEXPAND - 0 - - wxID_ANY - List items: - - sbListOptionsSizer - wxVERTICAL - none - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Components by reference - - 0 - - - 0 - - 1 - m_ListCmpbyRefItems - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Sub components (i.e. U2A, U2B ...) - - 0 - - - 0 - - 1 - m_ListSubCmpItems - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Components by value - - 0 - - - 0 - - 1 - m_ListCmpbyValItems - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Hierarchical pins by name - - 0 - - - 0 - - 1 - m_GenListLabelsbyVal - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Hierarchical pins by sheet - - 0 - - - 0 - - 1 - m_GenListLabelsbySheet - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxTOP - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "List" "List for spreadsheet import (by ref)" "List for spreadsheet import (by grouped ref)" "List for spreadsheet import (by value)" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - ID_RADIOBOX_SELECT_FORMAT - Output format: - 1 - - 0 - - - 0 - - 1 - m_OutputFormCtrl - 1 - - - protected - 1 - - Resizable - 1 - 1 - - wxRA_SPECIFY_COLS - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - OnRadioboxSelectFormatSelected - - - - - - - - - - 5 - wxEXPAND|wxTOP - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Tab" ";" "," - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Field separator for spreadsheet import: - 1 - - 0 - - - 0 - - 1 - m_OutputSeparatorCtrl - 1 - - - protected - 1 - - Resizable - 0 - 1 - - wxRA_SPECIFY_ROWS - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Launch list browser - - 0 - - - 0 - - 1 - m_GetListBrowser - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 2 - - - bRightSizer - wxVERTICAL - none - - 5 - wxEXPAND - 1 - - wxID_ANY - Add to list: - - sbAddToListSelectionSizer - wxVERTICAL - none - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Component location - - 0 - - - 0 - - 1 - m_AddLocationField - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 0 - - wxID_ANY - System Fields: - - sbFixedFieldsSizer - wxVERTICAL - none - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Datasheet - - 0 - - - 0 - - 1 - m_AddDatasheetField - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Footprint - - 0 - - - 0 - - 1 - m_AddFootprintField - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxTOP - 0 - - wxID_ANY - Users fields: - - sbUsersFiledsSizer - wxVERTICAL - none - - - 5 - wxEXPAND|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Field 1 - - 0 - - - 0 - - 1 - m_AddField1 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Field 2 - - 0 - - - 0 - - 1 - m_AddField2 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Field 3 - - 0 - - - 0 - - 1 - m_AddField3 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Field 4 - - 0 - - - 0 - - 1 - m_AddField4 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Field 5 - - 0 - - - 0 - - 1 - m_AddField5 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Field 6 - - 0 - - - 0 - - 1 - m_AddField6 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Field 7 - - 0 - - - 0 - - 1 - m_AddField7 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Field 8 - - 0 - - - 0 - - 1 - m_AddField8 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - All existing user fields - - 0 - - - 0 - - 1 - m_AddAllFields - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_staticline1 - 1 - - - protected - 1 - - Resizable - 1 - - wxLI_HORIZONTAL - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizer - protected - - OnCancelClick - - - - OnOkClick - - - - - - - - diff --git a/eeschema/dialogs/dialog_build_BOM_base.h b/eeschema/dialogs/dialog_build_BOM_base.h deleted file mode 100644 index f5d6bb7c66..0000000000 --- a/eeschema/dialogs/dialog_build_BOM_base.h +++ /dev/null @@ -1,83 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 8 2012) -// http://www.wxformbuilder.org/ -// -// PLEASE DO "NOT" EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#ifndef __DIALOG_BUILD_BOM_BASE_H__ -#define __DIALOG_BUILD_BOM_BASE_H__ - -#include -#include -#include -class DIALOG_SHIM; - -#include "dialog_shim.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_BUILD_BOM_BASE -/////////////////////////////////////////////////////////////////////////////// -class DIALOG_BUILD_BOM_BASE : public DIALOG_SHIM -{ - private: - - protected: - enum - { - ID_RADIOBOX_SELECT_FORMAT = 1000 - }; - - wxCheckBox* m_ListCmpbyRefItems; - wxCheckBox* m_ListSubCmpItems; - wxCheckBox* m_ListCmpbyValItems; - wxCheckBox* m_GenListLabelsbyVal; - wxCheckBox* m_GenListLabelsbySheet; - wxRadioBox* m_OutputFormCtrl; - wxRadioBox* m_OutputSeparatorCtrl; - wxCheckBox* m_GetListBrowser; - wxCheckBox* m_AddLocationField; - wxCheckBox* m_AddDatasheetField; - wxCheckBox* m_AddFootprintField; - wxCheckBox* m_AddField1; - wxCheckBox* m_AddField2; - wxCheckBox* m_AddField3; - wxCheckBox* m_AddField4; - wxCheckBox* m_AddField5; - wxCheckBox* m_AddField6; - wxCheckBox* m_AddField7; - wxCheckBox* m_AddField8; - wxCheckBox* m_AddAllFields; - wxStaticLine* m_staticline1; - wxStdDialogButtonSizer* m_sdbSizer; - wxButton* m_sdbSizerOK; - wxButton* m_sdbSizerCancel; - - // Virtual event handlers, overide them in your derived class - virtual void OnRadioboxSelectFormatSelected( wxCommandEvent& event ) { event.Skip(); } - virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } - virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } - - - public: - - DIALOG_BUILD_BOM_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("List of Materials"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - ~DIALOG_BUILD_BOM_BASE(); - -}; - -#endif //__DIALOG_BUILD_BOM_BASE_H__ diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 0b2306b0f5..e839564d72 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -45,6 +46,7 @@ #include #include #include +#include bool DIALOG_ERC::m_writeErcFile = false; @@ -57,7 +59,10 @@ END_EVENT_TABLE() DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) : - DIALOG_ERC_BASE( parent ) + DIALOG_ERC_BASE( + parent, + ID_DIALOG_ERC // parent looks for this ID explicitly + ) { m_parent = parent; Init(); @@ -564,3 +569,14 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) } } } + + +wxDialog* InvokeDialogERC( SCH_EDIT_FRAME* aCaller ) +{ + // This is a modeless dialog, so new it rather than instantiating on stack. + DIALOG_ERC* dlg = new DIALOG_ERC( aCaller ); + + dlg->Show( true ); + + return dlg; // wxDialog is information hiding about DIALOG_ERC. +} diff --git a/eeschema/dialogs/dialog_netlist.cpp b/eeschema/dialogs/dialog_netlist.cpp index 45d0d46ac6..8fbca46427 100644 --- a/eeschema/dialogs/dialog_netlist.cpp +++ b/eeschema/dialogs/dialog_netlist.cpp @@ -50,7 +50,6 @@ #include #include #include -#include #include #include diff --git a/eeschema/dialogs/dialog_print_using_printer.cpp b/eeschema/dialogs/dialog_print_using_printer.cpp index 18ebe89f73..2c28fadbcd 100644 --- a/eeschema/dialogs/dialog_print_using_printer.cpp +++ b/eeschema/dialogs/dialog_print_using_printer.cpp @@ -16,7 +16,35 @@ #include #include -#include +#include +#include + + + +/** + * Class DIALOG_PRINT_USING_PRINTER + * offers to print a schematic dialog. + * + * Derived from DIALOG_PRINT_USING_PRINTER_base created by wxFormBuilder + */ +class DIALOG_PRINT_USING_PRINTER : public DIALOG_PRINT_USING_PRINTER_BASE +{ +public: + DIALOG_PRINT_USING_PRINTER( SCH_EDIT_FRAME* aParent ); + + SCH_EDIT_FRAME* GetParent() const; + +private: + void OnCloseWindow( wxCloseEvent& event ); + void OnInitDialog( wxInitDialogEvent& event ); + void OnPageSetup( wxCommandEvent& event ); + void OnPrintPreview( wxCommandEvent& event ); + void OnPrintButtonClick( wxCommandEvent& event ); + void OnButtonCancelClick( wxCommandEvent& event ){ Close(); } + + void GetPrintOptions(); +}; + /** @@ -415,3 +443,11 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen ) aScreen->m_DrawOrg = old_org; aScreen->SetZoom( oldZoom ); } + + +int InvokeDialogPrintUsingPrinter( SCH_EDIT_FRAME* aCaller ) +{ + DIALOG_PRINT_USING_PRINTER dlg( aCaller ); + + return dlg.ShowModal(); +} diff --git a/eeschema/dialogs/dialog_print_using_printer.h b/eeschema/dialogs/dialog_print_using_printer.h deleted file mode 100644 index 5dfee48420..0000000000 --- a/eeschema/dialogs/dialog_print_using_printer.h +++ /dev/null @@ -1,34 +0,0 @@ - -#ifndef _DIALOG_PRINT_USING_PRINTER_H_ -#define _DIALOG_PRINT_USING_PRINTER_H_ - - -#include - - -/** - * Print schematic dialog. - * - * Class derived from DIALOG_PRINT_USING_PRINTER_base created by wxFormBuilder - */ -class DIALOG_PRINT_USING_PRINTER : public DIALOG_PRINT_USING_PRINTER_BASE -{ -public: - DIALOG_PRINT_USING_PRINTER( SCH_EDIT_FRAME* aParent ); - ~DIALOG_PRINT_USING_PRINTER() {}; - - SCH_EDIT_FRAME* GetParent() const; - -private: - void OnCloseWindow( wxCloseEvent& event ); - void OnInitDialog( wxInitDialogEvent& event ); - void OnPageSetup( wxCommandEvent& event ); - void OnPrintPreview( wxCommandEvent& event ); - void OnPrintButtonClick( wxCommandEvent& event ); - void OnButtonCancelClick( wxCommandEvent& event ){ Close(); } - - void GetPrintOptions(); -}; - - -#endif // _DIALOG_PRINT_USING_PRINTER_H_ diff --git a/eeschema/invoke_a_dialog.h b/eeschema/invoke_a_dialog.h new file mode 100644 index 0000000000..a8ccbff50a --- /dev/null +++ b/eeschema/invoke_a_dialog.h @@ -0,0 +1,66 @@ + +/* + * 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 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 header is an insolation layer between top most frames and any number of +// DIALOG classes which can be called from a frame window. +// It is a place to put invocation functions for [modal] dialogs, with benefits: +// +// 1) The information about each dialog class is not exposed to the frame. +// So therefore the DIALOG class can often be kept out of a header file entirely. +// +// 2) The information about the calling frame is not necessarily exposed to +// to the called dialog class, at least not in here. + +// The actual InvokeDialog() function is usually coded at the bottom of the +// DIALOG_.cpp file. + + +#ifndef INVOKE_A_DIALOG_H_ +#define INVOKE_A_DIALOG_H_ + + +class wxFrame; +class wxDialog; + +// Often this is not used in the prototypes, since wxFrame is good enough and would +// represent maximum information hiding. +class SCH_EDIT_FRAME; + + +/// Create and show DIALOG_ANNOTATE and return whatever +/// DIALOG_ANNOTATE::ShowModal() returns. +int InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller ); + +/// Create the modeless DIALOG_ERC and show it, return something to +/// destroy or close it. The dialog will have ID_DIALOG_ERC from id.h +wxDialog* InvokeDialogERC( SCH_EDIT_FRAME* aCaller ); + +/// Create and show DIALOG_PRINT_USING_PRINTER and return whatever +/// DIALOG_PRINT_USING_PRINTER::ShowModal() returns. +int InvokeDialogPrintUsingPrinter( SCH_EDIT_FRAME* aCaller ); + + + +#endif // INVOKE_A_DIALOG_H_ diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index d6f4a28c7f..f22cbcbb33 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -51,10 +51,7 @@ #include #include -#include -#include -#include -#include +#include #include #include @@ -200,6 +197,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* aParent, const wxString& aTitle, m_findReplaceData = new wxFindReplaceData( wxFR_DOWN ); m_undoItem = NULL; m_hasAutoSave = true; + SetForceHVLines( true ); SetDefaultLabelSize( DEFAULT_SIZE_TEXT ); @@ -244,8 +242,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* aParent, const wxString& aTitle, EDA_PANEINFO mesg; mesg.MessageToolbarPane(); - - if( m_mainToolBar ) m_auimgr.AddPane( m_mainToolBar, wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) ); @@ -602,19 +598,19 @@ void SCH_EDIT_FRAME::OnUpdateHiddenPins( wxUpdateUIEvent& aEvent ) void SCH_EDIT_FRAME::OnAnnotate( wxCommandEvent& event ) { - DIALOG_ANNOTATE* dlg = new DIALOG_ANNOTATE( this ); - - dlg->ShowModal(); - dlg->Destroy(); + InvokeDialogAnnotate( this ); } void SCH_EDIT_FRAME::OnErc( wxCommandEvent& event ) { - DIALOG_ERC* dlg = new DIALOG_ERC( this ); + // See if its already open... + wxWindow* erc = FindWindowById( ID_DIALOG_ERC, this ); - dlg->Show( true ); -// dlg->Destroy(); + if( erc ) + erc->Raise(); // bring it to the top if already open. + else + InvokeDialogERC( this ); } @@ -827,9 +823,8 @@ void SCH_EDIT_FRAME::SetLanguage( wxCommandEvent& event ) void SCH_EDIT_FRAME::OnPrint( wxCommandEvent& event ) { wxFileName fn; - DIALOG_PRINT_USING_PRINTER dlg( this ); - dlg.ShowModal(); + InvokeDialogPrintUsingPrinter( this ); fn = g_RootSheet->GetScreen()->GetFileName(); diff --git a/include/id.h b/include/id.h index 4d517474af..0c60acd429 100644 --- a/include/id.h +++ b/include/id.h @@ -241,11 +241,13 @@ enum main_id ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, ID_TB_OPTIONS_SHOW_PADS_SKETCH, - + // zoom commands for non center zooming ID_OFFCENTER_ZOOM_IN, ID_OFFCENTER_ZOOM_OUT, + ID_DIALOG_ERC, ///< eeschema ERC modeless dialog ID + ID_END_LIST }; diff --git a/include/wxEeschemaStruct.h b/include/wxEeschemaStruct.h index 7f8eca6ce9..a7dcc18b64 100644 --- a/include/wxEeschemaStruct.h +++ b/include/wxEeschemaStruct.h @@ -115,52 +115,52 @@ enum SCH_SEARCH_T { class SCH_EDIT_FRAME : public SCH_BASE_FRAME { private: - SCH_SHEET_PATH* m_CurrentSheet; ///< which sheet we are presently working on. - wxString m_DefaultSchematicFileName; - int m_TextFieldSize; - PARAM_CFG_ARRAY m_projectFileParams; - PARAM_CFG_ARRAY m_configSettings; - wxPageSetupDialogData m_pageSetupData; - wxFindReplaceData* m_findReplaceData; - wxPoint m_previewPosition; - wxSize m_previewSize; - wxPoint m_printDialogPosition; - wxSize m_printDialogSize; - bool m_printMonochrome; ///< Print monochrome instead of grey scale. - bool m_printSheetReference; - DIALOG_SCH_FIND* m_dlgFindReplace; - wxPoint m_findDialogPosition; - wxSize m_findDialogSize; - wxArrayString m_findStringHistoryList; - wxArrayString m_replaceStringHistoryList; - BLOCK_SELECTOR m_blockItems; ///< List of selected items. - SCH_ITEM* m_itemToRepeat; ///< Last item to insert by the repeat command. - int m_repeatLabelDelta; ///< Repeat label number increment step. - SCH_COLLECTOR m_collectedItems; ///< List of collected items. - SCH_FIND_COLLECTOR m_foundItems; ///< List of find/replace items. - SCH_ITEM* m_undoItem; ///< Copy of the current item being edited. - wxString m_simulatorCommand; ///< Command line used to call the circuit - ///< simulator (gnucap, spice, ...) - wxString m_netListerCommand; ///< Command line to call a custom net list - ///< generator. + SCH_SHEET_PATH* m_CurrentSheet; ///< which sheet we are presently working on. + wxString m_DefaultSchematicFileName; + int m_TextFieldSize; + PARAM_CFG_ARRAY m_projectFileParams; + PARAM_CFG_ARRAY m_configSettings; + wxPageSetupDialogData m_pageSetupData; + wxFindReplaceData* m_findReplaceData; + wxPoint m_previewPosition; + wxSize m_previewSize; + wxPoint m_printDialogPosition; + wxSize m_printDialogSize; + bool m_printMonochrome; ///< Print monochrome instead of grey scale. + bool m_printSheetReference; + DIALOG_SCH_FIND* m_dlgFindReplace; + wxPoint m_findDialogPosition; + wxSize m_findDialogSize; + wxArrayString m_findStringHistoryList; + wxArrayString m_replaceStringHistoryList; + BLOCK_SELECTOR m_blockItems; ///< List of selected items. + SCH_ITEM* m_itemToRepeat; ///< Last item to insert by the repeat command. + int m_repeatLabelDelta; ///< Repeat label number increment step. + SCH_COLLECTOR m_collectedItems; ///< List of collected items. + SCH_FIND_COLLECTOR m_foundItems; ///< List of find/replace items. + SCH_ITEM* m_undoItem; ///< Copy of the current item being edited. + wxString m_simulatorCommand; ///< Command line used to call the circuit + ///< simulator (gnucap, spice, ...) + wxString m_netListerCommand; ///< Command line to call a custom net list + ///< generator. - bool m_forceHVLines; ///< force H or V directions for wires, bus, line - int m_defaultLabelSize; ///< size of a new label + bool m_forceHVLines; ///< force H or V directions for wires, bus, line + int m_defaultLabelSize; ///< size of a new label /// An index to the last find item in the found items list #m_foundItems. - int m_foundItemIndex; + int m_foundItemIndex; /// Flag to indicate show hidden pins. - bool m_showAllPins; + bool m_showAllPins; /// The name of the format to use when generating a net list. - wxString m_netListFormat; + wxString m_netListFormat; /// Add X prefix to componen referencess when generating spice net lists. - bool m_addReferencPrefix; + bool m_addReferencPrefix; - wxString m_userLibraryPath; + wxString m_userLibraryPath; wxArrayString m_componentLibFiles; diff --git a/pcbnew/invoke_a_dialog.h b/pcbnew/invoke_a_dialog.h new file mode 100644 index 0000000000..c6736ae981 --- /dev/null +++ b/pcbnew/invoke_a_dialog.h @@ -0,0 +1,69 @@ + +/* + * 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 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 header is an insolation layer between top most frames and any number of +// DIALOG classes which can be called from a frame window. +// It is a place to put invocation functions for [modal] dialogs, with benefits: +// +// 1) The information about each dialog class is not exposed to the frame. +// So therefore the DIALOG class can often be kept out of a header file entirely. +// +// 2) The information about the calling frame is not necessarily exposed to +// to the called dialog class, at least not in here. + +// The actual InvokeDialog() function is usually coded at the bottom of the +// DIALOG_.cpp file. + + +#ifndef INVOKE_A_DIALOG_H_ +#define INVOKE_A_DIALOG_H_ + + +class wxFrame; +class wxDialog; + +// Often this is not used in the prototypes, since wxFrame is good enough and would +// represent maximum information hiding. +class PCB_EDIT_FRAME; + + +/* template: junk it after some are added: + +/// Create and show DIALOG_ANNOTATE and return whatever +/// DIALOG_ANNOTATE::ShowModal() returns. +int InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller ); + +/// Create the modeless DIALOG_ERC and show it, return something to +/// destroy or close it. The dialog will have ID_DIALOG_ERC from id.h +wxDialog* InvokeDialogERC( SCH_EDIT_FRAME* aCaller ); + +/// Create and show DIALOG_PRINT_USING_PRINTER and return whatever +/// DIALOG_PRINT_USING_PRINTER::ShowModal() returns. +int InvokeDialogPrintUsingPrinter( SCH_EDIT_FRAME* aCaller ); +*/ + + + +#endif // INVOKE_A_DIALOG_H_ From 98eb5e75e53f7bbff3b2cbf78d9301b72bc9d257 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Sat, 8 Jun 2013 12:06:26 -0400 Subject: [PATCH 14/50] CvPcb focus and status bar improvements. * Fixed status bar update bug that caused the selected footprint information to be overwritten. * Remove unnecessary SetFocus() calls in list control OnChar() handlers. --- cvpcb/class_components_listbox.cpp | 5 +- cvpcb/class_footprints_listbox.cpp | 25 ++------ cvpcb/class_library_listbox.cpp | 5 +- cvpcb/cvframe.cpp | 94 ++++++++++++++++++------------ cvpcb/cvpcb_mainframe.h | 13 ++++- 5 files changed, 77 insertions(+), 65 deletions(-) diff --git a/cvpcb/class_components_listbox.cpp b/cvpcb/class_components_listbox.cpp index 1cc6a46ba9..11a4a7c03f 100644 --- a/cvpcb/class_components_listbox.cpp +++ b/cvpcb/class_components_listbox.cpp @@ -115,12 +115,12 @@ void COMPONENTS_LISTBOX::OnChar( wxKeyEvent& event ) case WXK_TAB: case WXK_RIGHT: case WXK_NUMPAD_RIGHT: - GetParent()->m_FootprintList->SetFocus(); + GetParent()->ChangeFocus( true ); return; case WXK_LEFT: case WXK_NUMPAD_LEFT: - GetParent()->m_LibraryList->SetFocus(); + GetParent()->ChangeFocus( false ); return; case WXK_HOME: @@ -164,7 +164,6 @@ void COMPONENTS_LISTBOX::OnChar( wxKeyEvent& event ) if( key == start_char ) { - Focus( ii ); SetSelection( ii, true ); // Ensure visible break; } diff --git a/cvpcb/class_footprints_listbox.cpp b/cvpcb/class_footprints_listbox.cpp index 3fb5874f30..22e0c94477 100644 --- a/cvpcb/class_footprints_listbox.cpp +++ b/cvpcb/class_footprints_listbox.cpp @@ -188,27 +188,11 @@ void FOOTPRINTS_LISTBOX::OnLeftClick( wxListEvent& event ) if( m_footprintList.IsEmpty() ) return; - FOOTPRINT_INFO* Module; - wxString footprintName = GetSelectedFootprint(); - - Module = GetParent()->m_footprints.GetModuleInfo( footprintName ); - wxASSERT( Module ); - + // If the footprint view window is displayed, update the footprint. if( GetParent()->m_DisplayFootprintFrame ) - { - // Refresh current selected footprint view: GetParent()->CreateScreenCmp(); - } - if( Module ) - { - wxString msg; - msg = _( "Description: " ) + Module->m_Doc; - GetParent()->SetStatusText( msg, 0 ); - - msg = _( "Key words: " ) + Module->m_KeyWord; - GetParent()->SetStatusText( msg, 1 ); - } + GetParent()->DisplayStatus(); } @@ -229,12 +213,12 @@ void FOOTPRINTS_LISTBOX::OnChar( wxKeyEvent& event ) case WXK_TAB: case WXK_RIGHT: case WXK_NUMPAD_RIGHT: - GetParent()->m_LibraryList->SetFocus(); + GetParent()->ChangeFocus( true ); return; case WXK_LEFT: case WXK_NUMPAD_LEFT: - GetParent()->m_ListCmp->SetFocus(); + GetParent()->ChangeFocus( false ); return; case WXK_HOME: @@ -278,7 +262,6 @@ void FOOTPRINTS_LISTBOX::OnChar( wxKeyEvent& event ) if( key == start_char ) { - Focus( ii ); SetSelection( ii, true ); // Ensure visible break; } diff --git a/cvpcb/class_library_listbox.cpp b/cvpcb/class_library_listbox.cpp index d9dc45e19a..9c3e6cd0dd 100644 --- a/cvpcb/class_library_listbox.cpp +++ b/cvpcb/class_library_listbox.cpp @@ -144,12 +144,12 @@ void LIBRARY_LISTBOX::OnChar( wxKeyEvent& event ) case WXK_TAB: case WXK_RIGHT: case WXK_NUMPAD_RIGHT: - GetParent()->m_ListCmp->SetFocus(); + GetParent()->ChangeFocus( true ); return; case WXK_LEFT: case WXK_NUMPAD_LEFT: - GetParent()->m_FootprintList->SetFocus(); + GetParent()->ChangeFocus( false ); return; case WXK_HOME: @@ -193,7 +193,6 @@ void LIBRARY_LISTBOX::OnChar( wxKeyEvent& event ) if( key == start_char ) { - Focus( ii ); SetSelection( ii, true ); // Ensure visible break; } diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index 795d2c55b6..d25fde6d09 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -89,7 +89,6 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME ) CVPCB_MAINFRAME::OnSelectFilteringFootprint ) // Frame events - EVT_CHAR( CVPCB_MAINFRAME::OnChar ) EVT_CLOSE( CVPCB_MAINFRAME::OnCloseWindow ) EVT_SIZE( CVPCB_MAINFRAME::OnSize ) @@ -306,23 +305,27 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event ) } -void CVPCB_MAINFRAME::OnChar( wxKeyEvent& event ) +void CVPCB_MAINFRAME::ChangeFocus( bool aMoveRight ) { - switch( event.GetKeyCode() ) + wxWindow* hasFocus = wxWindow::FindFocus(); + + if( aMoveRight ) { - case WXK_LEFT: - case WXK_NUMPAD_LEFT: - m_ListCmp->SetFocus(); - break; - - case WXK_RIGHT: - case WXK_NUMPAD_RIGHT: - m_FootprintList->SetFocus(); - break; - - default: - event.Skip(); - break; + if( hasFocus == m_LibraryList ) + m_ListCmp->SetFocus(); + else if( hasFocus == m_ListCmp ) + m_FootprintList->SetFocus(); + else if( hasFocus == m_FootprintList ) + m_LibraryList->SetFocus(); + } + else + { + if( hasFocus == m_LibraryList ) + m_FootprintList->SetFocus(); + else if( hasFocus == m_ListCmp ) + m_LibraryList->SetFocus(); + else if( hasFocus == m_FootprintList ) + m_ListCmp->SetFocus(); } } @@ -523,10 +526,10 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event ) // Preview of the already assigned footprint. // Find the footprint that was already chosen for this component and select it, - // but only if the selection is made from the component list. If the selection is - // made from the footprint list, do not change the current selected footprint. - - if( FindFocus() == m_ListCmp ) + // but only if the selection is made from the component list or the library list. + // If the selection is made from the footprint list, do not change the current + // selected footprint. + if( FindFocus() == m_ListCmp || FindFocus() == m_LibraryList ) { wxString module = component->GetFootprintName(); @@ -586,28 +589,47 @@ void CVPCB_MAINFRAME::DisplayStatus() wxString msg; COMPONENT* component; - msg.Printf( _( "Components: %d, unassigned: %d" ), (int) m_netlist.GetCount(), - m_undefinedComponentCnt ); - SetStatusText( msg, 0 ); - - msg.Empty(); - - component = GetSelectedComponent(); - - if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) && component ) + if( wxWindow::FindFocus() == m_ListCmp || wxWindow::FindFocus() == m_LibraryList ) { - for( unsigned ii = 0; ii < component->GetFootprintFilters().GetCount(); ii++ ) + msg.Printf( _( "Components: %d, unassigned: %d" ), (int) m_netlist.GetCount(), + m_undefinedComponentCnt ); + SetStatusText( msg, 0 ); + + msg.Empty(); + + component = GetSelectedComponent(); + + if( component ) { - if( msg.IsEmpty() ) - msg += component->GetFootprintFilters()[ii]; - else - msg += wxT( ", " ) + component->GetFootprintFilters()[ii]; + for( unsigned ii = 0; ii < component->GetFootprintFilters().GetCount(); ii++ ) + { + if( msg.IsEmpty() ) + msg += component->GetFootprintFilters()[ii]; + else + msg += wxT( ", " ) + component->GetFootprintFilters()[ii]; + } + + msg = _( "Filter list: " ) + msg; } - msg = _( "Filter list: " ) + msg; + SetStatusText( msg, 1 ); + } + else + { + wxString footprintName = m_FootprintList->GetSelectedFootprint(); + FOOTPRINT_INFO* module = m_footprints.GetModuleInfo( footprintName ); + wxASSERT( module ); + + if( module ) + { + msg = _( "Description: " ) + module->m_Doc; + SetStatusText( msg, 0 ); + + msg = _( "Key words: " ) + module->m_KeyWord; + SetStatusText( msg, 1 ); + } } - SetStatusText( msg, 1 ); msg.Empty(); diff --git a/cvpcb/cvpcb_mainframe.h b/cvpcb/cvpcb_mainframe.h index b963d5a2e9..69fe7a03bc 100644 --- a/cvpcb/cvpcb_mainframe.h +++ b/cvpcb/cvpcb_mainframe.h @@ -95,10 +95,11 @@ public: void OnQuit( wxCommandEvent& event ); void OnCloseWindow( wxCloseEvent& Event ); void OnSize( wxSizeEvent& SizeEvent ); - void OnChar( wxKeyEvent& event ); void ReCreateHToolbar(); virtual void ReCreateMenuBar(); + void ChangeFocus( bool aMoveRight ); + /** * Function SetLanguage * is called on a language menu selection. @@ -223,7 +224,15 @@ public: /** * Function DisplayStatus - * displays info to the status line at bottom of the main frame. + * updates the information displayed on the status bar at bottom of the main frame. + * + * When the library or component list controls have the focus, the footprint assignment + * status of the components is displayed in the first status bar pane and the list of + * filters for the selected component is displayed in the second status bar pane. When + * the footprint list control has the focus, the description of the selected footprint is + * displayed in the first status bar pane and the key words for the selected footprint are + * displayed in the second status bar pane. The third status bar pane always displays the + * current footprint list filtering. */ void DisplayStatus(); From a287f89304af0ef4127a2def9738799cc0cf1184 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 8 Jun 2013 20:19:09 +0200 Subject: [PATCH 15/50] Custom page layout: add support for poly-polygons (useful for logos) --- common/page_layout_default_description.cpp | 91 ++++++---- common/page_layout_reader.cpp | 104 +++++++++++ common/page_layout_reader.keywords | 2 + common/title_block_shapes.cpp | 123 +++++++++++-- include/worksheet_shape_builder.h | 98 ++++++++++- template/pagelayout_logo.kicad_wks | 191 +++++++++++++++++++++ 6 files changed, 562 insertions(+), 47 deletions(-) create mode 100644 template/pagelayout_logo.kicad_wks diff --git a/common/page_layout_default_description.cpp b/common/page_layout_default_description.cpp index ba112fa865..26a1b7a842 100644 --- a/common/page_layout_default_description.cpp +++ b/common/page_layout_default_description.cpp @@ -46,6 +46,8 @@ * pos * start * end + * pts + * xy * maxlen * maxheight * font @@ -123,6 +125,29 @@ * example: * (tbtext \"Size: %Z\" ...) displays "Size A4" or Size USLetter" * + * Poly Polygons + * Set of filled polygons are supported. + * + * The main purpose is to allow logos, or complex shapes + * They support the repeat and rotation options + * They are defined by + * (polygon (position ..) + * the parameter linewidth defines the pen size used to draw/plot + * the polygon outlines (default = 0) + * example: + * (polygon (pos 134 18 rbcorner) (rotate 20) (linewidth 0.00254) + * + * and a list of corners like + * (pts (xy 20.574 8.382) (xy 19.9009 8.382) (xy 19.9009 6.26364) (xy 19.7485 5.98932) + * .... ) + * + * each sequence like + * (pts (xy 20.574 8.382) (xy 19.9009 8.382) (xy 19.9009 6.26364) (xy 19.7485 5.98932) + * .... ) + * defines a polygon. + * Each coordinate is relative to the polygon position. + * Therefore a "polygon" is in fact a set of polygons, of a poly polygon + * */ #include // defaultPageLayout @@ -135,39 +160,39 @@ // frame ref pitch 50 mm // export defaultPageLayout: -extern const char defaultPageLayout[]; +extern const char defaultPageLayout[]; // Default page layout (sizes are in mm) -const char defaultPageLayout[] = "( page_layout\n" -"(setup (textsize 1.5 1.5) (linewidth 0.15) (textlinewidth 0.15) )" -"(rect (comment rect around the title block) (linewidth 0.15) (start 110 34) (end 2 2) )\n" -"(rect (start 0 0 ltcorner) (end 0 0 rbcorner) (repeat 2) (incrx 2) (incry 2) )\n" -"(line (start 50 2 ltcorner) (end 50 0 ltcorner) (repeat 30) (incrx 50) )\n" -"(tbtext \"1\" (pos 25 1 ltcorner) (font (size 1.3 1.3))(repeat 100) (incrx 50) )\n" -"(line (start 50 2 lbcorner) (end 50 0 lbcorner) (repeat 30) (incrx 50) )\n" -"(tbtext \"1\" (pos 25 1 lbcorner) (font (size 1.3 1.3)) (repeat 100) (incrx 50) )\n" -"(line (start 0 50 ltcorner) (end 2 50 ltcorner) (repeat 30) (incry 50) )\n" -"(tbtext \"A\" (pos 1 25 ltcorner) (font (size 1.3 1.3)) (justify center)(repeat 100) (incry 50) )\n" -"(line (start 0 50 rtcorner) (end 2 50 rtcorner) (repeat 30) (incry 50) )\n" -"(tbtext \"A\" (pos 1 25 rtcorner) (font (size 1.3 1.3)) (justify center) (repeat 100) (incry 50) )\n" -"(tbtext \"Date: %D\" (pos 87 6.9) )\n" -"(line (start 110 5.5) end 2 5.5) )\n" -"(tbtext \"%K\" (pos 109 4.1) (comment Kicad version ) )\n" -"(line (start 110 8.5) end 2 8.5) )\n" -"(tbtext \"Rev: %R\" (pos 24 6.9)(font bold)(justify left) )\n" -"(tbtext \"Size: %Z\" (comment Paper format name)(pos 109 6.9) )\n" -"(tbtext \"Id: %S/%N\" (comment Sheet id)(pos 24 4.1) )\n" -"(line (start 110 12.5) end 2 12.5) )\n" -"(tbtext \"Title: %T\" (pos 109 10.7)(font bold italic (size 2 2)) )\n" -"(tbtext \"File: %F\" (pos 109 14.3) )\n" -"(line (start 110 18.5) end 2 18.5) )\n" -"(tbtext \"Sheet: %P\" (pos 109 17) )\n" -"(tbtext \"%Y\" (comment Company name) (pos 109 20)(font bold) )\n" -"(tbtext \"%C0\" (comment Comment 0) (pos 109 23) )\n" -"(tbtext \"%C1\" (comment Comment 0) (pos 109 26) )\n" -"(tbtext \"%C2\" (comment Comment 0) (pos 109 29) )\n" -"(tbtext \"%C3\" (comment Comment 0) (pos 109 32) )\n" -"(line (start 90 8.5) end 90 5.5) )\n" -"(line (start 26 8.5) end 26 2) )\n" -")\n" +const char defaultPageLayout[] = "( page_layout\n" + "(setup (textsize 1.5 1.5) (linewidth 0.15) (textlinewidth 0.15) )" + "(rect (comment rect around the title block) (linewidth 0.15) (start 110 34) (end 2 2) )\n" + "(rect (start 0 0 ltcorner) (end 0 0 rbcorner) (repeat 2) (incrx 2) (incry 2) )\n" + "(line (start 50 2 ltcorner) (end 50 0 ltcorner) (repeat 30) (incrx 50) )\n" + "(tbtext \"1\" (pos 25 1 ltcorner) (font (size 1.3 1.3))(repeat 100) (incrx 50) )\n" + "(line (start 50 2 lbcorner) (end 50 0 lbcorner) (repeat 30) (incrx 50) )\n" + "(tbtext \"1\" (pos 25 1 lbcorner) (font (size 1.3 1.3)) (repeat 100) (incrx 50) )\n" + "(line (start 0 50 ltcorner) (end 2 50 ltcorner) (repeat 30) (incry 50) )\n" + "(tbtext \"A\" (pos 1 25 ltcorner) (font (size 1.3 1.3)) (justify center)(repeat 100) (incry 50) )\n" + "(line (start 0 50 rtcorner) (end 2 50 rtcorner) (repeat 30) (incry 50) )\n" + "(tbtext \"A\" (pos 1 25 rtcorner) (font (size 1.3 1.3)) (justify center) (repeat 100) (incry 50) )\n" + "(tbtext \"Date: %D\" (pos 87 6.9) )\n" + "(line (start 110 5.5) end 2 5.5) )\n" + "(tbtext \"%K\" (pos 109 4.1) (comment Kicad version ) )\n" + "(line (start 110 8.5) end 2 8.5) )\n" + "(tbtext \"Rev: %R\" (pos 24 6.9)(font bold)(justify left) )\n" + "(tbtext \"Size: %Z\" (comment Paper format name)(pos 109 6.9) )\n" + "(tbtext \"Id: %S/%N\" (comment Sheet id)(pos 24 4.1) )\n" + "(line (start 110 12.5) end 2 12.5) )\n" + "(tbtext \"Title: %T\" (pos 109 10.7)(font bold italic (size 2 2)) )\n" + "(tbtext \"File: %F\" (pos 109 14.3) )\n" + "(line (start 110 18.5) end 2 18.5) )\n" + "(tbtext \"Sheet: %P\" (pos 109 17) )\n" + "(tbtext \"%Y\" (comment Company name) (pos 109 20)(font bold) )\n" + "(tbtext \"%C0\" (comment Comment 0) (pos 109 23) )\n" + "(tbtext \"%C1\" (comment Comment 0) (pos 109 26) )\n" + "(tbtext \"%C2\" (comment Comment 0) (pos 109 29) )\n" + "(tbtext \"%C3\" (comment Comment 0) (pos 109 32) )\n" + "(line (start 90 8.5) end 90 5.5) )\n" + "(line (start 26 8.5) end 26 2) )\n" + ")\n" ; diff --git a/common/page_layout_reader.cpp b/common/page_layout_reader.cpp index 9ed36e724c..f79f58eb20 100644 --- a/common/page_layout_reader.cpp +++ b/common/page_layout_reader.cpp @@ -76,6 +76,10 @@ private: void parseSetup() throw( IO_ERROR, PARSE_ERROR ); void parseGraphic( WORKSHEET_DATAITEM * aItem ) throw( IO_ERROR, PARSE_ERROR ); void parseText( WORKSHEET_DATAITEM_TEXT * aItem ) throw( IO_ERROR, PARSE_ERROR ); + void parsePolygon( WORKSHEET_DATAITEM_POLYPOLYGON * aItem ) + throw( IO_ERROR, PARSE_ERROR ); + void parsePolyOutline( WORKSHEET_DATAITEM_POLYPOLYGON * aItem ) + throw( IO_ERROR, PARSE_ERROR ); void parseCoordinate( POINT_COORD& aCoord) throw( IO_ERROR, PARSE_ERROR ); }; @@ -127,6 +131,12 @@ void PAGE_LAYOUT_READER_PARSER::Parse( WORKSHEET_LAYOUT* aLayout ) aLayout->Append( item ); break; + case T_polygon: + item = new WORKSHEET_DATAITEM_POLYPOLYGON(); + parsePolygon( (WORKSHEET_DATAITEM_POLYPOLYGON*) item ); + aLayout->Append( item ); + break; + case T_tbtext: NeedSYMBOLorNUMBER(); item = new WORKSHEET_DATAITEM_TEXT( FromUTF8() ); @@ -177,6 +187,100 @@ void PAGE_LAYOUT_READER_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR ) } } +void PAGE_LAYOUT_READER_PARSER::parsePolygon( WORKSHEET_DATAITEM_POLYPOLYGON * aItem ) + throw( IO_ERROR, PARSE_ERROR ) +{ + aItem->m_LineWidth = 0; + + T token; + + while( ( token = NextTok() ) != T_RIGHT ) + { + if( token == T_EOF) + break; + + if( token == T_LEFT ) + token = NextTok(); + + switch( token ) + { + case T_comment: // Comment, search the closing ')' + while( ( token = NextTok() ) != T_RIGHT && token != T_EOF ); + break; + + case T_pos: + parseCoordinate( aItem->m_Pos ); + break; + + case T_pts: + parsePolyOutline( aItem ); + aItem->CloseContour(); + break; + + case T_rotate: + aItem->m_Orient = parseDouble(); + NeedRIGHT(); + break; + + case T_repeat: + aItem->m_RepeatCount = parseInt( -1, 100 ); + NeedRIGHT(); + break; + + case T_incrx: + aItem->m_IncrementVector.x = parseDouble(); + NeedRIGHT(); + break; + + case T_incry: + aItem->m_IncrementVector.y = parseDouble(); + NeedRIGHT(); + break; + + case T_linewidth: + aItem->m_LineWidth = parseDouble(); + NeedRIGHT(); + break; + + default: + Unexpected( CurText() ); + break; + } + } + + aItem->SetBoundingBox(); +} + +void PAGE_LAYOUT_READER_PARSER::parsePolyOutline( WORKSHEET_DATAITEM_POLYPOLYGON * aItem ) + throw( IO_ERROR, PARSE_ERROR ) +{ + DPOINT corner; + T token; + + while( ( token = NextTok() ) != T_RIGHT ) + { + if( token == T_EOF) + break; + + if( token == T_LEFT ) + token = NextTok(); + + switch( token ) + { + case T_xy: + corner.x = parseDouble(); + corner.y = parseDouble(); + aItem->AppendCorner( corner ); + NeedRIGHT(); + break; + + default: + Unexpected( CurText() ); + break; + } + } +} + void PAGE_LAYOUT_READER_PARSER::parseGraphic( WORKSHEET_DATAITEM * aItem ) throw( IO_ERROR, PARSE_ERROR ) { diff --git a/common/page_layout_reader.keywords b/common/page_layout_reader.keywords index 83e312dfb9..cc7c9246a0 100644 --- a/common/page_layout_reader.keywords +++ b/common/page_layout_reader.keywords @@ -16,6 +16,8 @@ name pos start end +pts +xy maxlen maxheight font diff --git a/common/title_block_shapes.cpp b/common/title_block_shapes.cpp index 33ea5ee12f..949e844173 100644 --- a/common/title_block_shapes.cpp +++ b/common/title_block_shapes.cpp @@ -60,6 +60,80 @@ #include #include +WORKSHEET_DATAITEM_POLYPOLYGON::WORKSHEET_DATAITEM_POLYPOLYGON() : + WORKSHEET_DATAITEM( WS_POLYPOLYGON ) +{ + m_Orient = 0.0; +} + +const DPOINT WORKSHEET_DATAITEM_POLYPOLYGON::GetCornerPosition( unsigned aIdx, + int aRepeat ) const +{ + DPOINT pos = m_Corners[aIdx]; + + // Rotation: + RotatePoint( &pos.x, &pos.y, m_Orient * 10 ); + pos += GetStartPos( aRepeat ); + return pos; +} + +void WORKSHEET_DATAITEM_POLYPOLYGON::SetBoundingBox() +{ + if( m_Corners.size() == 0 ) + { + m_minCoord.x = m_maxCoord.x = 0.0; + m_minCoord.y = m_maxCoord.y = 0.0; + return; + } + + DPOINT pos; + pos = m_Corners[0]; + RotatePoint( &pos.x, &pos.y, m_Orient * 10 ); + m_minCoord = m_maxCoord = pos; + + for( unsigned ii = 1; ii < m_Corners.size(); ii++ ) + { + pos = m_Corners[ii]; + RotatePoint( &pos.x, &pos.y, m_Orient * 10 ); + + if( m_minCoord.x > pos.x ) + m_minCoord.x = pos.x; + + if( m_minCoord.y > pos.y ) + m_minCoord.y = pos.y; + + if( m_maxCoord.x < pos.x ) + m_maxCoord.x = pos.x; + + if( m_maxCoord.y < pos.y ) + m_maxCoord.y = pos.y; + } +} + +bool WORKSHEET_DATAITEM_POLYPOLYGON::IsInsidePage( int ii ) const +{ + DPOINT pos = GetStartPos( ii ); + pos += m_minCoord; // left top pos of bounding box + + if( m_LT_Corner.x > pos.x || m_LT_Corner.y > pos.y ) + return false; + + pos = GetStartPos( ii ); + pos += m_maxCoord; // rignt bottom pos of bounding box + + if( m_RB_Corner.x < pos.x || m_RB_Corner.y < pos.y ) + return false; + + return true; +} + +const wxPoint WORKSHEET_DATAITEM_POLYPOLYGON::GetCornerPositionUi( unsigned aIdx, + int aRepeat ) const +{ + DPOINT pos = GetCornerPosition( aIdx, aRepeat ); + pos = pos * m_WSunits2Iu; + return wxPoint( int(pos.x), int(pos.y) ); +} WORKSHEET_DATAITEM_TEXT::WORKSHEET_DATAITEM_TEXT( const wxChar* aTextBase ) : WORKSHEET_DATAITEM( WS_TEXT ) @@ -253,6 +327,8 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( if( wsItem == NULL ) break; + pensize = wsItem->GetPenSizeUi(); + switch( wsItem->m_Type ) { case WORKSHEET_DATAITEM::WS_TEXT: @@ -262,8 +338,6 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( if( wsText->m_FullText.IsEmpty() ) break; - pensize = wsText->GetPenSizeUi(); - if( pensize == 0 ) pensize = m_penSize; @@ -283,10 +357,11 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( if( wsText->IsBold()) pensize = GetPenSizeForBold( std::min( textsize.x, textsize.y ) ); - for( int jj = 0; jj < wsText->m_RepeatCount; ) + for( int jj = 0; jj < wsText->m_RepeatCount; jj++) { if( ! wsText->IsInsidePage( jj ) ) - break; + continue; + Append( gtext = new WS_DRAW_ITEM_TEXT( wsText->m_FullText, wsText->GetStartPosUi( jj ), textsize, @@ -295,23 +370,21 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( wsText->IsBold() ) ); wsText->TransfertSetupToGraphicText( gtext ); - jj++; - if( wsText->m_RepeatCount > 1 ) // Try to increment label - wsText->IncrementLabel( jj ); + // Increment label for the next text + if( wsText->m_RepeatCount > 1 ) + wsText->IncrementLabel( jj+1 ); } } break; case WORKSHEET_DATAITEM::WS_SEGMENT: - pensize = wsItem->GetPenSizeUi(); - if( pensize == 0 ) pensize = m_penSize; for( int jj = 0; jj < wsItem->m_RepeatCount; jj++ ) { if( ! wsItem->IsInsidePage( jj ) ) - break; + continue; Append( new WS_DRAW_ITEM_LINE( wsItem->GetStartPosUi( jj ), wsItem->GetEndPosUi( jj ), pensize, aLineColor ) ); @@ -319,8 +392,6 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( break; case WORKSHEET_DATAITEM::WS_RECT: - pensize = wsItem->GetPenSizeUi(); - if( pensize == 0 ) pensize = m_penSize; @@ -334,6 +405,34 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( pensize, aLineColor ) ); } break; + + case WORKSHEET_DATAITEM::WS_POLYPOLYGON: + { + WORKSHEET_DATAITEM_POLYPOLYGON * wspoly = + (WORKSHEET_DATAITEM_POLYPOLYGON*) wsItem; + for( int jj = 0; jj < wsItem->m_RepeatCount; jj++ ) + { + if( ! wsItem->IsInsidePage( jj ) ) + continue; + + for( int kk = 0; kk < wspoly->GetPolyCount(); kk++ ) + { + const bool fill = true; + WS_DRAW_ITEM_POLYGON* poly = new WS_DRAW_ITEM_POLYGON( fill, + pensize, aLineColor ); + Append( poly ); + + // Create polygon outline + unsigned ist = wspoly->GetPolyIndexStart( kk ); + unsigned iend = wspoly->GetPolyIndexEnd( kk ); + while( ist <= iend ) + poly->m_Corners.push_back( + wspoly->GetCornerPositionUi( ist++, jj ) ); + + } + } + } + break; } } } diff --git a/include/worksheet_shape_builder.h b/include/worksheet_shape_builder.h index 94d8d5fe10..09219c1b2a 100644 --- a/include/worksheet_shape_builder.h +++ b/include/worksheet_shape_builder.h @@ -52,13 +52,20 @@ public: // Work sheet structure type definitions. +// Basic items are: +// * segment and rect (defined by 2 points) +// * text (defined by a coordinate), the text and its justifications +// * poly polygon defined by a coordinate, and a set of list of corners +// ( because we use it for logos, there are more than one polygon +// in this description class WORKSHEET_DATAITEM { public: enum WS_ItemType { WS_TEXT, WS_SEGMENT, - WS_RECT + WS_RECT, + WS_POLYPOLYGON }; WS_ItemType m_Type; POINT_COORD m_Pos; @@ -87,6 +94,8 @@ public: m_LineWidth = 0.0; } + virtual ~WORKSHEET_DATAITEM() {} + void SetStart( double aPosx, double aPosy, enum corner_anchor aAnchor = RB_CORNER ) { m_Pos.m_Pos.x = aPosx; @@ -105,8 +114,92 @@ public: const wxPoint GetEndPosUi( int ii = 0 ) const; const DPOINT GetStartPos( int ii = 0 ) const; const DPOINT GetEndPos( int ii = 0 ) const; - bool IsInsidePage( int ii ) const; int GetPenSizeUi() {return KiROUND( m_LineWidth * m_WSunits2Iu ); } + + /** + * @return true if the item is inside the rectangle defined by the + * 4 corners, false otherwise. + */ + virtual bool IsInsidePage( int ii ) const; +}; + +class WORKSHEET_DATAITEM_POLYPOLYGON : public WORKSHEET_DATAITEM +{ +public: + double m_Orient; // Orientation in degrees + std::vector m_Corners; // corner list + +private: + std::vector m_polyIndexEnd; // index of the last point of each polygon + DPOINT m_minCoord; // min coord of corners, relative to m_Pos + DPOINT m_maxCoord; // max coord of corners, relative to m_Pos + +public: + WORKSHEET_DATAITEM_POLYPOLYGON( ); + + /** + * add a corner in corner list + * @param aCorner: the item to append + */ + void AppendCorner( const DPOINT& aCorner ) + { + m_Corners.push_back( aCorner ); + } + + /** + * Closes the current contour, by storing the index of the last corner + * of the current polygon in m_polyIndexEnd. + */ + void CloseContour() + { + m_polyIndexEnd.push_back( m_Corners.size() -1 ); + } + + /** + * @return the count of contours in the poly polygon + */ + int GetPolyCount() const { return (int) m_polyIndexEnd.size(); } + + /** + * @return the index of the first corner of the contour aCountour + * @param aContour = the index of the contour + */ + unsigned GetPolyIndexStart( unsigned aContour) const + { + if( aContour == 0 ) + return 0; + else + return m_polyIndexEnd[aContour-1] + 1; + } + + /** + * @return the index of the last corner of the contour aCountour + * @param aContour = the index of the contour + */ + unsigned GetPolyIndexEnd( unsigned aContour) const + { + return m_polyIndexEnd[aContour]; + } + + /** + * @return the coordinate (in mm) of the corner aIdx, + * for the repeated item aRepeat + */ + const DPOINT GetCornerPosition( unsigned aIdx, int aRepeat = 0 ) const; + + /** + * @return the coordinate (in draw/plot units) of the corner aIdx, + * for the repeated item aRepeat + */ + const wxPoint GetCornerPositionUi( unsigned aIdx, int aRepeat = 0 ) const; + + /** + * calculate the bounding box of the set polygons + */ + void SetBoundingBox(); + + + bool IsInsidePage( int ii ) const; }; class WORKSHEET_DATAITEM_TEXT : public WORKSHEET_DATAITEM @@ -233,6 +326,7 @@ class WS_DRAW_ITEM_POLYGON : public WS_DRAW_ITEM_BASE public: std::vector m_Corners; + public: WS_DRAW_ITEM_POLYGON( bool aFill, int aPenWidth, EDA_COLOR_T aColor ) : WS_DRAW_ITEM_BASE( wsg_poly, aColor ) diff --git a/template/pagelayout_logo.kicad_wks b/template/pagelayout_logo.kicad_wks new file mode 100644 index 0000000000..d60250570f --- /dev/null +++ b/template/pagelayout_logo.kicad_wks @@ -0,0 +1,191 @@ +( page_layout + ( setup (textsize 1.5 1.5) (linewidth 0.15) (textlinewidth 0.15) ) + ( rect (comment rect around the title block) (linewidth 0.15) (start 110 34) (end 2 2) ) + ( rect (start 0 0 ltcorner) (end 0 0 rbcorner) (repeat 2) (incrx 2) (incry 2) ) + ( line (start 50 2 ltcorner) (end 50 0 ltcorner) (repeat 30) (incrx 50) ) + ( tbtext "1" (pos 25 1 ltcorner) (font (size 1.3 1.3))(repeat 100) (incrx 50) ) + ( line (start 50 2 lbcorner) (end 50 0 lbcorner) (repeat 30) (incrx 50) ) + ( tbtext "1" (pos 25 1 lbcorner) (font (size 1.3 1.3)) (repeat 100) (incrx 50) ) + ( line (start 0 50 ltcorner) (end 2 50 ltcorner) (repeat 30) (incry 50) ) + ( tbtext "A" (pos 1 25 ltcorner) (font (size 1.3 1.3)) + (justify center)(repeat 100) (incry 50) ) + ( line (start 0 50 rtcorner) (end 2 50 rtcorner) (repeat 30) (incry 50) ) + ( tbtext "A" (pos 1 25 rtcorner) (font (size 1.3 1.3)) + (justify center) (repeat 100) (incry 50) ) + ( tbtext "Date: %D" (pos 87 6.9) ) + ( line (start 110 5.5) end 2 5.5) ) + ( tbtext "%K" (pos 109 4.1) (comment Kicad version ) ) + ( line (start 110 8.5) end 2 8.5) ) + ( tbtext "Rev: %R" (pos 24 6.9)(font bold)(justify left) ) + ( tbtext "Size: %Z" (comment Paper format name)(pos 109 6.9) ) + ( tbtext "Id: %S/%N" (comment Sheet id)(pos 24 4.1) ) + ( line (start 110 12.5) end 2 12.5) ) + ( tbtext "Title: %T" (pos 109 10.7)(font bold (size 2 2)) ) + ( tbtext "File: %F" (pos 109 14.3) ) + ( line (start 110 18.5) end 2 18.5) ) + ( tbtext "Sheet: %P" (pos 109 17) ) + ( tbtext "%Y" (comment Company name) (pos 109 20)(font bold) ) + ( tbtext "%C0" (comment Comment 0) (pos 109 23) ) + ( tbtext "%C1" (comment Comment 0) (pos 109 26) ) + ( tbtext "%C2" (comment Comment 0) (pos 109 29) ) + ( tbtext "%C3" (comment Comment 0) (pos 109 32) ) + ( line (start 90 8.5) end 90 5.5) ) + ( line (start 26 8.5) end 26 2) ) + + ( rect (comment rect around the logo) (linewidth 0.15) (start 157 34) (end 110 2) ) + (polygon (pos 134 18 rbcorner) (rotate 20) (linewidth 0.00254) + (pts (xy 20.574 8.382) (xy 19.9009 8.382) (xy 19.9009 6.26364) (xy 19.7485 5.98932) + (xy 19.71802 5.92328) (xy 19.69262 5.83946) (xy 19.66976 5.72262) (xy 19.65198 5.56006) + (xy 19.63674 5.33908) (xy 19.6215 5.04952) (xy 19.61134 4.67614) (xy 19.60372 4.20624) + (xy 19.5961 3.62712) (xy 19.58848 2.92862) (xy 19.5834 2.09296) (xy 19.57832 1.11252) + (xy 19.57578 0.27432) (xy 19.55038 -5.16636) (xy 18.15592 -5.16636) (xy 17.69364 -5.16382) + (xy 17.29232 -5.15874) (xy 16.98752 -5.15112) (xy 16.80464 -5.14096) (xy 16.764 -5.13334) + (xy 16.79194 -5.0419) (xy 16.8656 -4.85648) (xy 16.891 -4.79806) (xy 16.93672 -4.64312) + (xy 16.97228 -4.42468) (xy 16.99514 -4.11734) (xy 17.01038 -3.69824) (xy 17.01546 -3.14198) + (xy 17.018 -2.82702) (xy 17.01546 -2.25806) (xy 17.01292 -1.83896) (xy 17.0053 -1.5494) + (xy 16.99006 -1.36652) (xy 16.9672 -1.27508) (xy 16.93164 -1.25222) (xy 16.88592 -1.28016) + (xy 16.8656 -1.29794) (xy 16.47444 -1.5494) (xy 15.96644 -1.71704) (xy 15.3797 -1.7907) + (xy 15.2527 -1.79324) (xy 14.53134 -1.71958) (xy 13.89634 -1.50622) (xy 13.35278 -1.14808) + (xy 12.9032 -0.65024) (xy 12.5476 -0.0127) (xy 12.28598 0.762) (xy 12.22756 1.016) + (xy 12.1539 1.50368) (xy 12.11326 2.07264) (xy 12.10564 2.667) (xy 12.13104 3.23342) + (xy 12.18692 3.71348) (xy 12.2301 3.91668) (xy 12.49934 4.66344) (xy 12.88288 5.2959) + (xy 13.36802 5.8039) (xy 13.94968 6.17982) (xy 14.39164 6.35508) (xy 14.76248 6.41858) + (xy 15.21968 6.4262) (xy 15.69466 6.38302) (xy 16.11376 6.29158) (xy 16.20266 6.2611) + (xy 16.49984 6.1341) (xy 16.76146 5.99694) (xy 16.87576 5.92074) (xy 17.06118 5.7912) + (xy 17.15262 5.78104) (xy 17.1831 5.9055) (xy 17.18564 6.00964) (xy 17.18564 6.26364) + (xy 18.542 6.26364) (xy 19.9009 6.26364) (xy 19.9009 8.382) (xy 11.51636 8.382) + (xy 11.51636 6.26364) (xy 11.3665 6.03504) (xy 11.32586 5.9563) (xy 11.2903 5.84962) + (xy 11.26236 5.69468) (xy 11.24204 5.4737) (xy 11.22172 5.17144) (xy 11.20648 4.76504) + (xy 11.19124 4.2418) (xy 11.17854 3.57886) (xy 11.16838 3.00736) (xy 11.1506 2.16408) + (xy 11.13282 1.47066) (xy 11.10996 0.90932) (xy 11.07694 0.45974) (xy 11.03122 0.10414) + (xy 10.97026 -0.1778) (xy 10.89152 -0.40386) (xy 10.78738 -0.59436) (xy 10.6553 -0.76962) + (xy 10.49274 -0.94234) (xy 10.40892 -1.0287) (xy 9.93394 -1.38684) (xy 9.34212 -1.63576) + (xy 8.64616 -1.77546) (xy 7.85622 -1.80086) (xy 6.99262 -1.7145) (xy 6.31952 -1.57988) + (xy 5.92836 -1.48844) (xy 5.58038 -1.41478) (xy 5.31622 -1.36906) (xy 5.19938 -1.35636) + (xy 5.0419 -1.32588) (xy 4.99364 -1.27254) (xy 5.02666 -1.1557) (xy 5.10794 -0.92964) + (xy 5.22224 -0.635) (xy 5.35432 -0.31496) (xy 5.48132 -0.01524) (xy 5.588 0.22098) + (xy 5.65658 0.35052) (xy 5.6642 0.36068) (xy 5.76834 0.36322) (xy 5.98424 0.31496) + (xy 6.26872 0.22098) (xy 6.3119 0.2032) (xy 6.83768 0.04572) (xy 7.3406 -0.03048) + (xy 7.79018 -0.0254) (xy 8.14324 0.0635) (xy 8.2677 0.13462) (xy 8.49376 0.40132) + (xy 8.60044 0.68326) (xy 8.69188 1.05664) (xy 7.66826 1.10744) (xy 6.97738 1.16078) + (xy 6.41096 1.24968) (xy 5.92836 1.3843) (xy 5.49148 1.5748) (xy 5.24764 1.70942) + (xy 4.77012 2.08534) (xy 4.4196 2.54762) (xy 4.19608 3.0734) (xy 4.09448 3.63474) + (xy 4.11988 4.20878) (xy 4.26974 4.76758) (xy 4.54406 5.28828) (xy 4.9403 5.74294) + (xy 5.31876 6.02742) (xy 5.85978 6.2738) (xy 6.47954 6.40588) (xy 7.12724 6.42112) + (xy 7.74954 6.30936) (xy 7.75208 6.30936) (xy 8.06958 6.18744) (xy 8.37438 6.02742) + (xy 8.46582 5.96646) (xy 8.763 5.74802) (xy 8.7884 6.00456) (xy 8.8138 6.26364) + (xy 10.16508 6.26364) (xy 11.51636 6.26364) (xy 11.51636 8.382) (xy 4.13766 8.382) + (xy 4.13766 5.44068) (xy 4.10972 5.36702) (xy 4.0132 5.1816) (xy 3.86334 4.91744) + (xy 3.68046 4.6101) (xy 3.48742 4.29006) (xy 3.29946 3.99034) (xy 3.1369 3.74142) + (xy 3.10896 3.70078) (xy 2.9464 3.46456) (xy 2.65684 3.7211) (xy 2.20726 4.05892) + (xy 1.76276 4.26212) (xy 1.27254 4.34848) (xy 1.05664 4.3561) (xy 0.70104 4.34594) + (xy 0.43942 4.29768) (xy 0.19558 4.19862) (xy 0.05842 4.11988) (xy -0.38862 3.76682) + (xy -0.75946 3.28168) (xy -1.03378 2.7051) (xy -1.07188 2.58572) (xy -1.143 2.30378) + (xy -1.19126 1.98374) (xy -1.21666 1.58496) (xy -1.22936 1.0668) (xy -1.22936 0.889) + (xy -1.22428 0.381) (xy -1.21158 0) (xy -1.17856 -0.30226) (xy -1.12776 -0.56896) + (xy -1.04902 -0.84328) (xy -1.02108 -0.92964) (xy -0.75438 -1.53416) (xy -0.3937 -2.01676) + (xy 0.04318 -2.36474) (xy 0.54864 -2.57048) (xy 0.99822 -2.62636) (xy 1.54686 -2.55524) + (xy 2.05486 -2.35712) (xy 2.35712 -2.15138) (xy 2.5527 -1.98882) (xy 2.68986 -1.88468) + (xy 2.7305 -1.86436) (xy 2.794 -1.9304) (xy 2.92608 -2.10312) (xy 3.10388 -2.35458) + (xy 3.30962 -2.65176) (xy 3.51536 -2.96164) (xy 3.70586 -3.25374) (xy 3.85318 -3.4925) + (xy 3.94208 -3.64998) (xy 3.95732 -3.69316) (xy 3.86588 -3.74396) (xy 3.66268 -3.85064) + (xy 3.3782 -3.99288) (xy 3.22326 -4.06654) (xy 2.54508 -4.36118) (xy 1.92532 -4.5466) + (xy 1.31318 -4.64058) (xy 0.87122 -4.65836) (xy 0.02286 -4.59232) (xy -0.7493 -4.38912) + (xy -1.46558 -4.0386) (xy -2.15392 -3.5306) (xy -2.38252 -3.32232) (xy -2.9464 -2.70764) + (xy -3.37312 -2.04978) (xy -3.6957 -1.30302) (xy -3.82524 -0.87376) (xy -3.94208 -0.26924) + (xy -4.00304 0.43434) (xy -4.00812 1.17348) (xy -3.95986 1.88976) (xy -3.85572 2.52222) + (xy -3.82524 2.64922) (xy -3.51028 3.53314) (xy -3.07848 4.32562) (xy -2.53746 5.0165) + (xy -1.905 5.588) (xy -1.19126 6.02488) (xy -0.44958 6.30682) (xy 0.01016 6.39064) + (xy 0.57404 6.4262) (xy 1.17856 6.41604) (xy 1.76276 6.3627) (xy 2.26822 6.26364) + (xy 2.286 6.25856) (xy 2.72288 6.11124) (xy 3.23088 5.90296) (xy 3.73888 5.66166) + (xy 4.13766 5.44068) (xy 4.13766 8.382) (xy 0 8.382) (xy -4.74218 8.382) + (xy -4.74218 1.7653) (xy -4.74218 0.71882) (xy -4.74218 -0.55118) (xy -4.74218 -1.66116) + (xy -4.74218 -2.62382) (xy -4.74472 -3.44678) (xy -4.7498 -4.14528) (xy -4.75742 -4.7244) + (xy -4.77012 -5.19938) (xy -4.79044 -5.57784) (xy -4.81584 -5.87248) (xy -4.84886 -6.09346) + (xy -4.8895 -6.2484) (xy -4.94284 -6.35254) (xy -5.0038 -6.4135) (xy -5.07746 -6.44144) + (xy -5.16382 -6.44906) (xy -5.26542 -6.44398) (xy -5.37972 -6.4389) (xy -5.40512 -6.4389) + (xy -5.6515 -6.4516) (xy -5.79374 -6.51002) (xy -5.90042 -6.65734) (xy -5.969 -6.79958) + (xy -6.23062 -7.1755) (xy -6.57606 -7.4295) (xy -6.97738 -7.56158) (xy -7.40156 -7.57682) + (xy -7.81558 -7.47014) (xy -8.1915 -7.24662) (xy -8.49376 -6.90626) (xy -8.58774 -6.73354) + (xy -8.72998 -6.43636) (xy -14.05382 -6.43636) (xy -15.14602 -6.43636) (xy -16.08074 -6.43382) + (xy -16.87068 -6.43128) (xy -17.52854 -6.42874) (xy -18.06702 -6.42112) (xy -18.49628 -6.4135) + (xy -18.83156 -6.40334) (xy -19.08302 -6.39064) (xy -19.2659 -6.3754) (xy -19.38782 -6.35508) + (xy -19.46402 -6.33222) (xy -19.50974 -6.30428) (xy -19.50974 -6.30174) (xy -19.53514 -6.26618) + (xy -19.55546 -6.1976) (xy -19.57324 -6.08838) (xy -19.59102 -5.92582) (xy -19.60372 -5.69976) + (xy -19.61388 -5.40004) (xy -19.6215 -5.0165) (xy -19.62912 -4.53644) (xy -19.6342 -3.95224) + (xy -19.63928 -3.24866) (xy -19.64182 -2.41808) (xy -19.64182 -1.4478) (xy -19.64436 -0.32766) + (xy -19.64436 0.71882) (xy -19.64436 1.9685) (xy -19.64182 3.06324) (xy -19.64182 4.00812) + (xy -19.63928 4.81584) (xy -19.6342 5.49656) (xy -19.62912 6.06552) (xy -19.6215 6.52526) + (xy -19.61134 6.8961) (xy -19.60118 7.18058) (xy -19.58848 7.39394) (xy -19.5707 7.54634) + (xy -19.55292 7.64794) (xy -19.53006 7.71144) (xy -19.50974 7.73938) (xy -19.47418 7.76224) + (xy -19.4056 7.7851) (xy -19.29892 7.80288) (xy -19.1389 7.81812) (xy -18.91538 7.83082) + (xy -18.62074 7.84098) (xy -18.24228 7.85114) (xy -17.76984 7.85622) (xy -17.1958 7.86384) + (xy -16.50238 7.86638) (xy -15.68704 7.86892) (xy -14.732 7.87146) (xy -13.63218 7.87146) + (xy -12.37488 7.87146) (xy -12.192 7.874) (xy -10.91438 7.87146) (xy -9.79424 7.87146) + (xy -8.82142 7.86892) (xy -7.98576 7.86638) (xy -7.2771 7.86384) (xy -6.68782 7.85876) + (xy -6.20014 7.85114) (xy -5.81152 7.84352) (xy -5.50672 7.83336) (xy -5.27304 7.81812) + (xy -5.1054 7.80542) (xy -4.9911 7.78764) (xy -4.91998 7.76732) (xy -4.87934 7.74192) + (xy -4.8768 7.73938) (xy -4.8514 7.70128) (xy -4.83108 7.6327) (xy -4.8133 7.52348) + (xy -4.79552 7.36092) (xy -4.78282 7.1374) (xy -4.77266 6.83768) (xy -4.76504 6.45414) + (xy -4.75742 5.97408) (xy -4.75234 5.38734) (xy -4.74726 4.6863) (xy -4.74472 3.85318) + (xy -4.74472 2.88544) (xy -4.74218 1.7653) (xy -4.74218 8.382) (xy -20.574 8.382) + (xy -20.574 0) (xy -20.574 -8.382) (xy 0 -8.382) (xy 20.574 -8.382) + (xy 20.574 0) (xy 20.574 8.382) (xy 20.574 8.382)) + (pts (xy -9.4742 6.26364) (xy -11.25728 6.26364) (xy -13.04036 6.26364) (xy -13.04036 6.0071) + (xy -13.07846 5.76072) (xy -13.17752 5.48386) (xy -13.20038 5.4356) (xy -13.28674 5.29336) + (xy -13.45692 5.0419) (xy -13.68806 4.70662) (xy -13.96746 4.31292) (xy -14.27226 3.88112) + (xy -14.58976 3.4417) (xy -14.8971 3.02006) (xy -15.1765 2.63652) (xy -15.41526 2.31902) + (xy -15.58798 2.09296) (xy -15.67942 1.98882) (xy -15.7099 2.03454) (xy -15.73022 2.24282) + (xy -15.74038 2.61874) (xy -15.74292 3.15976) (xy -15.7353 3.76682) (xy -15.72514 4.37896) + (xy -15.71244 4.84886) (xy -15.69974 5.19684) (xy -15.67688 5.45084) (xy -15.64894 5.63372) + (xy -15.6083 5.76834) (xy -15.55496 5.88518) (xy -15.5194 5.94614) (xy -15.33144 6.26364) + (xy -16.96974 6.26364) (xy -18.61058 6.26364) (xy -18.45056 5.94868) (xy -18.415 5.87502) + (xy -18.38706 5.78612) (xy -18.36166 5.67182) (xy -18.34134 5.51688) (xy -18.3261 5.30606) + (xy -18.3134 5.02666) (xy -18.30324 4.66598) (xy -18.29816 4.20624) (xy -18.29308 3.63728) + (xy -18.29054 2.94386) (xy -18.29054 2.11328) (xy -18.29054 1.12776) (xy -18.288 0.889) + (xy -18.29054 -0.13208) (xy -18.29054 -0.99568) (xy -18.29308 -1.71958) (xy -18.29562 -2.31394) + (xy -18.30324 -2.79654) (xy -18.31086 -3.18008) (xy -18.32356 -3.47472) (xy -18.3388 -3.70078) + (xy -18.35658 -3.86588) (xy -18.37944 -3.9878) (xy -18.40738 -4.08178) (xy -18.4404 -4.15798) + (xy -18.45056 -4.17322) (xy -18.61058 -4.48818) (xy -17.01038 -4.48818) (xy -16.51 -4.48564) + (xy -16.07566 -4.48056) (xy -15.73022 -4.4704) (xy -15.49908 -4.4577) (xy -15.41018 -4.44246) + (xy -15.44574 -4.3434) (xy -15.53464 -4.16052) (xy -15.55496 -4.12496) (xy -15.61084 -3.9878) + (xy -15.65402 -3.7973) (xy -15.6845 -3.52806) (xy -15.70736 -3.15468) (xy -15.72514 -2.64922) + (xy -15.73276 -2.37236) (xy -15.75054 -1.70434) (xy -15.75816 -1.20396) (xy -15.748 -0.86106) + (xy -15.70228 -0.6731) (xy -15.61084 -0.63754) (xy -15.46098 -0.74422) (xy -15.24 -0.99314) + (xy -14.93266 -1.37668) (xy -14.5288 -1.8923) (xy -14.51102 -1.91516) (xy -14.04112 -2.51714) + (xy -13.67028 -3.00482) (xy -13.39088 -3.39344) (xy -13.18768 -3.70078) (xy -13.0556 -3.94208) + (xy -12.9794 -4.13004) (xy -12.95654 -4.28244) (xy -12.954 -4.29768) (xy -12.954 -4.48818) + (xy -11.23696 -4.48818) (xy -9.51992 -4.48818) (xy -10.07364 -3.91668) (xy -10.25398 -3.7211) + (xy -10.50544 -3.43154) (xy -10.81278 -3.06832) (xy -11.1633 -2.64922) (xy -11.54176 -2.19202) + (xy -11.93038 -1.71704) (xy -12.319 -1.23952) (xy -12.68476 -0.78232) (xy -13.02004 -0.36068) + (xy -13.30452 0.00254) (xy -13.5255 0.2921) (xy -13.66774 0.49022) (xy -13.716 0.57404) + (xy -13.66774 0.66294) (xy -13.53058 0.86868) (xy -13.31976 1.17348) (xy -13.04798 1.55702) + (xy -12.7254 2.00406) (xy -12.3698 2.49428) (xy -11.99388 3.00736) (xy -11.61034 3.5306) + (xy -11.23442 4.0386) (xy -10.87628 4.51866) (xy -10.55116 4.95046) (xy -10.27176 5.31622) + (xy -10.05332 5.59562) (xy -9.91108 5.76834) (xy -9.4742 6.26364) (xy -9.4742 6.26364)) + (pts (xy -5.75818 6.23316) (xy -5.83946 6.24332) (xy -6.06044 6.25094) (xy -6.39826 6.25856) + (xy -6.82498 6.26364) (xy -7.239 6.26364) (xy -7.71906 6.2611) (xy -8.13562 6.25856) + (xy -8.4582 6.25094) (xy -8.6614 6.24078) (xy -8.72236 6.23316) (xy -8.69188 6.14172) + (xy -8.61822 5.95376) (xy -8.59536 5.89534) (xy -8.5598 5.72262) (xy -8.52932 5.40512) + (xy -8.50392 4.9657) (xy -8.4836 4.42468) (xy -8.46836 3.81) (xy -8.4582 3.14198) + (xy -8.45566 2.44602) (xy -8.45566 1.74498) (xy -8.46074 1.06172) (xy -8.47344 0.42164) + (xy -8.49122 -0.15494) (xy -8.51408 -0.64262) (xy -8.54202 -1.01854) (xy -8.57504 -1.25984) + (xy -8.59028 -1.31572) (xy -8.7122 -1.61036) (xy -7.36346 -1.61036) (xy -6.01218 -1.61036) + (xy -6.01218 1.99136) (xy -6.01218 2.8956) (xy -6.00964 3.6449) (xy -6.00456 4.2545) + (xy -5.9944 4.74472) (xy -5.98424 5.12572) (xy -5.96646 5.41274) (xy -5.94614 5.6261) + (xy -5.92074 5.77596) (xy -5.89026 5.88264) (xy -5.88518 5.89534) (xy -5.8039 6.09854) + (xy -5.76072 6.22046) (xy -5.75818 6.23316) (xy -5.75818 6.23316)) + (pts (xy 8.636 3.4544) (xy 8.62838 3.80238) (xy 8.60298 4.0259) (xy 8.54964 4.17322) + (xy 8.45312 4.28752) (xy 8.4455 4.29514) (xy 8.08736 4.52628) (xy 7.66826 4.64058) + (xy 7.24408 4.62788) (xy 7.05866 4.572) (xy 6.77672 4.37388) (xy 6.5913 4.07924) + (xy 6.5405 3.74142) (xy 6.54558 3.70078) (xy 6.60146 3.45186) (xy 6.68782 3.25882) + (xy 6.70052 3.24104) (xy 6.96468 3.03784) (xy 7.35076 2.88798) (xy 7.81812 2.8067) + (xy 8.0645 2.794) (xy 8.636 2.794) (xy 8.636 3.4544) (xy 8.636 3.4544)) + (pts (xy 17.018 4.04876) (xy 16.7259 4.2291) (xy 16.34744 4.3942) (xy 15.94358 4.46024) + (xy 15.56766 4.4196) (xy 15.35938 4.3307) (xy 15.13332 4.15544) (xy 14.9733 3.93192) + (xy 14.86408 3.6322) (xy 14.80058 3.23342) (xy 14.77518 2.70764) (xy 14.77264 2.45364) + (xy 14.79296 1.77546) (xy 14.859 1.23952) (xy 14.97076 0.82296) (xy 15.1384 0.508) + (xy 15.33652 0.29718) (xy 15.66418 0.127) (xy 16.06042 0.08382) (xy 16.48714 0.17018) + (xy 16.68018 0.254) (xy 17.018 0.42672) (xy 17.018 2.23774) (xy 17.018 4.04876) + (xy 17.018 4.04876)) ) +) From 92ac2ac47e2b1b386f17829232c5f6b4ced7c46d Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 9 Jun 2013 18:36:54 +0200 Subject: [PATCH 16/50] Cvpcb: Bug fix: Select previous free component crashes Cvpcb when no previous free component found, and both Select next and previous free component where not working very well. --- HOW_TO_CONTRIBUTE.txt | 36 +++++++++++++++++++----------------- cvpcb/cvframe.cpp | 43 ++++++++++++++++--------------------------- 2 files changed, 35 insertions(+), 44 deletions(-) diff --git a/HOW_TO_CONTRIBUTE.txt b/HOW_TO_CONTRIBUTE.txt index 6175aa05d9..7cad15b06e 100644 --- a/HOW_TO_CONTRIBUTE.txt +++ b/HOW_TO_CONTRIBUTE.txt @@ -2,40 +2,42 @@ Contribute to KiCad (under Linux) -------------------- 1) make sure you have all the dependencies of KiCad: - sudo apt-get install debhelper dpatch libx11-dev - sudo apt-get install libglu1-mesa-dev libgl1-mesa-dev mesa-common-dev - sudo apt-get install libwxbase2.8-dev libwxgtk2.8-dev libboost-dev fakeroot - sudo apt-get install cmake bzr + sudo apt-get install debhelper dpatch libx11-dev + sudo apt-get install libglu1-mesa-dev libgl1-mesa-dev mesa-common-dev + sudo apt-get install libwxbase2.8-dev libwxgtk2.8-dev libboost-dev fakeroot + sudo apt-get install cmake bzr + sudo apt-get install cmake bzr bzrtools 2) initialize Bazaar: - bzr whoami "John Doe " + bzr whoami "John Doe " 3) get LATEST KiCad source tree and name it, for instance, "kicad_john": - cd ~/ - bzr branch lp:kicad kicad_john + cd ~/ + bzr branch lp:kicad kicad_john -4) create a copy of this folder and zip it away (just in case). +4) Read coding_style_policy.pdt, in /Documentation, + and other docs. 5) Modify/add source code. - cd kicad_john - gedit ....... + cd kicad_john + gedit ....... 6) Compile: - cd kicad_john - mkdir build; cd build - cmake ../ -DKICAD_TESTING_VERSION=ON -DCMAKE_BUILD_TYPE=Debug + cd kicad_john + mkdir build; cd build + cmake ../ -DKICAD_TESTING_VERSION=ON -DCMAKE_BUILD_TYPE=Debug to build a debug version or - cmake ../ -DKICAD_TESTING_VERSION=ON -DCMAKE_BUILD_TYPE=Release + cmake ../ -DKICAD_TESTING_VERSION=ON -DCMAKE_BUILD_TYPE=Release to build a release version - make -j 4 # this is for a 4 core machine + make 7) Repeat step 5 and 6 until satisfied. 8) Create a patch: - in kicad_john: + in kicad_john: if some files are added: bzr add [FILE...] - bzr diff > my_changes.patch + bzr diff > my_changes.patch 9) Send the patch file "my_changes.patch" to the KiCad developers mailing list. in the subject of the e-mail include the keyword "[PATCH]". diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index d25fde6d09..750e2d9924 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -332,60 +332,50 @@ void CVPCB_MAINFRAME::ChangeFocus( bool aMoveRight ) void CVPCB_MAINFRAME::ToFirstNA( wxCommandEvent& event ) { - int ii = 0; - int selection; - if( m_netlist.IsEmpty() ) return; - selection = m_ListCmp->GetSelection(); + long selection = m_ListCmp->GetFirstSelected(); if( selection < 0 ) - selection = 0; + selection = -1; // We will start to 0 for the first search , if no item selected - for( unsigned jj = 0; jj < m_netlist.GetCount(); jj++ ) + for( unsigned jj = selection+1; jj < m_netlist.GetCount(); jj++ ) { - if( m_netlist.GetComponent( jj )->GetFootprintName().IsEmpty() && ii > selection ) + if( m_netlist.GetComponent( jj )->GetFootprintName().IsEmpty() ) { - m_ListCmp->SetSelection( ii ); + m_ListCmp->SetSelection( wxNOT_FOUND, false ); // Remove all selections + m_ListCmp->SetSelection( jj ); SendMessageToEESCHEMA(); return; } - - ii++; } - - m_ListCmp->SetSelection( selection ); } void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event ) { - int ii; - int selection; - if( m_netlist.IsEmpty() ) return; - ii = m_ListCmp->GetCount() - 1; - selection = m_ListCmp->GetSelection(); + int selection = m_ListCmp->GetFirstSelected(); if( selection < 0 ) - selection = m_ListCmp->GetCount() - 1; + selection = m_ListCmp->GetCount(); + else + while( m_ListCmp->GetNextSelected( selection ) >= 0 ) + selection = m_ListCmp->GetNextSelected( selection ); - for( unsigned kk = m_netlist.GetCount() - 1; kk >= 0; kk-- ) + for( int kk = selection-1; kk >= 0; kk-- ) { - if( m_netlist.GetComponent( kk )->GetFootprintName().IsEmpty() && ii < selection ) + if( m_netlist.GetComponent( kk )->GetFootprintName().IsEmpty() ) { - m_ListCmp->SetSelection( ii ); + m_ListCmp->SetSelection( wxNOT_FOUND, false ); // Remove all selections + m_ListCmp->SetSelection( kk ); SendMessageToEESCHEMA(); return; } - - ii--; } - - m_ListCmp->SetSelection( selection ); } @@ -618,9 +608,8 @@ void CVPCB_MAINFRAME::DisplayStatus() { wxString footprintName = m_FootprintList->GetSelectedFootprint(); FOOTPRINT_INFO* module = m_footprints.GetModuleInfo( footprintName ); - wxASSERT( module ); - if( module ) + if( module ) // can be NULL if no netlist loaded { msg = _( "Description: " ) + module->m_Doc; SetStatusText( msg, 0 ); From b1489cbe40da35654d5673723a38c2f5309fb2f4 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 9 Jun 2013 18:50:57 +0200 Subject: [PATCH 17/50] Remove a useless message shown only in debug mode, about page layout file not found --- common/page_layout_reader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/page_layout_reader.cpp b/common/page_layout_reader.cpp index f79f58eb20..50981110ad 100644 --- a/common/page_layout_reader.cpp +++ b/common/page_layout_reader.cpp @@ -578,8 +578,8 @@ void WORKSHEET_LAYOUT::SetLayout() if( fullFileName.IsEmpty() || !wxFileExists( fullFileName ) ) { - #ifdef DEBUG - if( !wxFileExists( fullFileName ) ) + #if 0 + if( !fullFileName.IsEmpty() && !wxFileExists( fullFileName ) ) { wxLogMessage( wxT("Page layout file <%s> not found"), fullFileName.GetData() ); From 36aca68e403417ccc41ec811b09e05e94715f01d Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Sun, 9 Jun 2013 13:14:01 -0500 Subject: [PATCH 18/50] fix autopan non-response problem when dragging block to right or bottom --- common/drawpanel.cpp | 6 +++--- eeschema/schframe.cpp | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/common/drawpanel.cpp b/common/drawpanel.cpp index 47c2996935..5cde632226 100644 --- a/common/drawpanel.cpp +++ b/common/drawpanel.cpp @@ -830,11 +830,11 @@ void EDA_DRAW_PANEL::OnMouseLeaving( wxMouseEvent& event ) if( !m_enableAutoPan || !m_requestAutoPan || m_ignoreMouseEvents ) return; - // Auto pan if mouse is leave working area: + // Auto pan if mouse has left the client window wxSize size = GetClientSize(); - if( ( size.x < event.GetX() ) || ( size.y < event.GetY() ) - || ( event.GetX() <= 0) || ( event.GetY() <= 0 ) ) + if( size.x <= event.GetX() || event.GetX() < 0 || + size.y <= event.GetY() || event.GetY() < 0 ) { wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_POPUP_ZOOM_CENTER ); cmd.SetEventObject( this ); diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index f22cbcbb33..7f61b55171 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -604,11 +604,12 @@ void SCH_EDIT_FRAME::OnAnnotate( wxCommandEvent& event ) void SCH_EDIT_FRAME::OnErc( wxCommandEvent& event ) { - // See if its already open... + // See if it's already open... wxWindow* erc = FindWindowById( ID_DIALOG_ERC, this ); if( erc ) - erc->Raise(); // bring it to the top if already open. + // Bring it to the top if already open. Dual monitor users need this. + erc->Raise(); else InvokeDialogERC( this ); } From 00adc67d2a656094d0c298c8f041520658dd98f9 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Mon, 10 Jun 2013 07:24:01 -0500 Subject: [PATCH 19/50] Rename invoke_a_dialog.h. Code an alternate implementation for std::string BOARD_ITEM::FormatInternalUnits( int aValue ), for verification. --- eeschema/dialogs/dialog_annotate.cpp | 2 +- eeschema/dialogs/dialog_erc.cpp | 2 +- .../dialogs/dialog_print_using_printer.cpp | 2 +- ...{invoke_a_dialog.h => invoke_sch_dialog.h} | 0 eeschema/schframe.cpp | 2 +- pcbnew/class_board_item.cpp | 56 ++++++++++++++++++- ...{invoke_a_dialog.h => invoke_pcb_dialog.h} | 0 7 files changed, 59 insertions(+), 5 deletions(-) rename eeschema/{invoke_a_dialog.h => invoke_sch_dialog.h} (100%) rename pcbnew/{invoke_a_dialog.h => invoke_pcb_dialog.h} (100%) diff --git a/eeschema/dialogs/dialog_annotate.cpp b/eeschema/dialogs/dialog_annotate.cpp index 4015abbfe9..6c0c2eea71 100644 --- a/eeschema/dialogs/dialog_annotate.cpp +++ b/eeschema/dialogs/dialog_annotate.cpp @@ -33,7 +33,7 @@ #include #include -#include +#include #include diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index e839564d72..9b0b7e4d44 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include diff --git a/eeschema/dialogs/dialog_print_using_printer.cpp b/eeschema/dialogs/dialog_print_using_printer.cpp index 2c28fadbcd..cd6548c2ca 100644 --- a/eeschema/dialogs/dialog_print_using_printer.cpp +++ b/eeschema/dialogs/dialog_print_using_printer.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include diff --git a/eeschema/invoke_a_dialog.h b/eeschema/invoke_sch_dialog.h similarity index 100% rename from eeschema/invoke_a_dialog.h rename to eeschema/invoke_sch_dialog.h diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 7f61b55171..289f83e2ea 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -51,7 +51,7 @@ #include #include -#include +#include #include #include diff --git a/pcbnew/class_board_item.cpp b/pcbnew/class_board_item.cpp index dbb78a217d..0157c283e4 100644 --- a/pcbnew/class_board_item.cpp +++ b/pcbnew/class_board_item.cpp @@ -33,7 +33,7 @@ #include #include - +#include wxString BOARD_ITEM::ShowShape( STROKE_T aShape ) { @@ -88,6 +88,8 @@ wxString BOARD_ITEM::GetLayerName() const std::string BOARD_ITEM::FormatInternalUnits( int aValue ) { +#if 1 // !defined( USE_PCBNEW_NANOMETRES ) + char buf[50]; int len; double mm = aValue / IU_PER_MM; @@ -110,6 +112,58 @@ std::string BOARD_ITEM::FormatInternalUnits( int aValue ) } return std::string( buf, len ); + +#else + + // Assume aValue is in nanometers, and that we want the result in millimeters, + // and that int is 32 bit wide. Then perform an alternative algorithm. + // Can be used to verify that the above algorithm is correctly generating text. + // Convert aValue into an integer string, then insert a decimal point manually. + // Results are the same as above general purpose algorithm. + + wxASSERT( sizeof(int) == 4 ); + + if( aValue == 0 ) + return std::string( 1, '0' ); + else + { + char buf[50]; + int len = sprintf( buf, aValue > 0 ? "%06d" : "%07d", aValue ); + + std::string ret( buf, len ); + + std::string::iterator it = ret.end() - 1; // last byte + + // insert '.' at 6 positions from end, divides by 10e6 (a million), nm => mm + std::string::iterator decpoint = ret.end() - 6; + + // truncate trailing zeros, up to decimal point position + for( ; *it=='0' && it >= decpoint; --it ) + ret.erase( it ); // does not invalidate iterators it or decpoint + + if( it >= decpoint ) + { + ret.insert( decpoint, '.' ); + + // decpoint is invalidated here, after insert() + +#if 1 // want leading a zero when decimal point is in first position? + if( ret[0] == '.' ) + { + // insert leading zero ahead of decimal. + ret.insert( ret.begin(), '0' ); + } + else if( ret[0]=='-' && ret[1]=='.' ) + { + ret.insert( ret.begin() + 1, '0' ); + } +#endif + } + + return ret; + } + +#endif } diff --git a/pcbnew/invoke_a_dialog.h b/pcbnew/invoke_pcb_dialog.h similarity index 100% rename from pcbnew/invoke_a_dialog.h rename to pcbnew/invoke_pcb_dialog.h From 39993e27e4af31e0dc92c40b4a19556a15cba537 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 10 Jun 2013 15:23:58 +0200 Subject: [PATCH 20/50] Fix issue in auto panning while moving in EDA_DRAW_PANEL::OnMouseLeaving() --- HOW_TO_CONTRIBUTE.txt | 2 +- common/drawpanel.cpp | 26 ++++++++++++++++++-------- common/page_layout_reader.cpp | 2 +- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/HOW_TO_CONTRIBUTE.txt b/HOW_TO_CONTRIBUTE.txt index 7cad15b06e..746d3e3698 100644 --- a/HOW_TO_CONTRIBUTE.txt +++ b/HOW_TO_CONTRIBUTE.txt @@ -15,7 +15,7 @@ Contribute to KiCad (under Linux) cd ~/ bzr branch lp:kicad kicad_john -4) Read coding_style_policy.pdt, in /Documentation, +4) Read coding_style_policy.pdf, in /Documentation, and other docs. 5) Modify/add source code. diff --git a/common/drawpanel.cpp b/common/drawpanel.cpp index 5cde632226..9370503f91 100644 --- a/common/drawpanel.cpp +++ b/common/drawpanel.cpp @@ -830,16 +830,26 @@ void EDA_DRAW_PANEL::OnMouseLeaving( wxMouseEvent& event ) if( !m_enableAutoPan || !m_requestAutoPan || m_ignoreMouseEvents ) return; - // Auto pan if mouse has left the client window + // Auto pan when mouse has left the client window + // Ensure the cross_hair position is updated, + // because it will be used to center the screen. + // We use a position inside the client window wxSize size = GetClientSize(); + wxPoint cross_hair_pos = event.GetPosition(); + cross_hair_pos.x = std::min( cross_hair_pos.x, size.x ); + cross_hair_pos.y = std::min( cross_hair_pos.y, size.x ); + cross_hair_pos.x = std::max( cross_hair_pos.x, 0 ); + cross_hair_pos.y = std::max( cross_hair_pos.y, 0 ); - if( size.x <= event.GetX() || event.GetX() < 0 || - size.y <= event.GetY() || event.GetY() < 0 ) - { - wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_POPUP_ZOOM_CENTER ); - cmd.SetEventObject( this ); - GetEventHandler()->ProcessEvent( cmd ); - } + INSTALL_UNBUFFERED_DC( dc, this ); + cross_hair_pos.x = dc.DeviceToLogicalX( cross_hair_pos.x ); + cross_hair_pos.y = dc.DeviceToLogicalY( cross_hair_pos.y ); + + GetScreen()->SetCrossHairPosition( cross_hair_pos ); + + wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_POPUP_ZOOM_CENTER ); + cmd.SetEventObject( this ); + GetEventHandler()->ProcessEvent( cmd ); event.Skip(); } diff --git a/common/page_layout_reader.cpp b/common/page_layout_reader.cpp index 50981110ad..7cbd93f71b 100644 --- a/common/page_layout_reader.cpp +++ b/common/page_layout_reader.cpp @@ -579,7 +579,7 @@ void WORKSHEET_LAYOUT::SetLayout() if( fullFileName.IsEmpty() || !wxFileExists( fullFileName ) ) { #if 0 - if( !fullFileName.IsEmpty() && !wxFileExists( fullFileName ) ) + if( !fullFileName.IsEmpty() ) { wxLogMessage( wxT("Page layout file <%s> not found"), fullFileName.GetData() ); From 179ada1c70967a8eaa569fbfa4b1d77dd2d75910 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 11 Jun 2013 16:27:07 +0200 Subject: [PATCH 21/50] Eeschema: fix Bug #1189893 (ps plot file opened twice) --- eeschema/plot_schematic_PS.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/eeschema/plot_schematic_PS.cpp b/eeschema/plot_schematic_PS.cpp index 66d32ac79b..86b2982ca6 100644 --- a/eeschema/plot_schematic_PS.cpp +++ b/eeschema/plot_schematic_PS.cpp @@ -132,11 +132,6 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetPS( const wxString& aFileName, double aScale, bool aPlotFrameRef ) { - FILE* output_file = wxFopen( aFileName, wxT( "wt" ) ); - - if( output_file == NULL ) - return false; - PS_PLOTTER* plotter = new PS_PLOTTER(); plotter->SetPageSettings( aPageInfo ); plotter->SetDefaultLineWidth( GetDefaultLineThickness() ); From a3f2980d8089e2854a83a024a961ee995bb504ab Mon Sep 17 00:00:00 2001 From: Alexander Lunev Date: Wed, 12 Jun 2013 21:43:22 +0200 Subject: [PATCH 22/50] Fix pcad2kicad issue, from A. Lunev, and a minor code cleaning in component_references_lister.cpp. --- common/wildcards_and_files_ext.cpp | 2 +- eeschema/component_references_lister.cpp | 36 +++++--------- include/xnode.h | 10 ++-- .../pcad2kicad_common.cpp | 3 +- pcbnew/pcad2kicadpcb_plugin/pcb_text.cpp | 5 +- pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp | 48 ++++++++++--------- 6 files changed, 49 insertions(+), 55 deletions(-) diff --git a/common/wildcards_and_files_ext.cpp b/common/wildcards_and_files_ext.cpp index 9149ae229c..fe2c86e223 100644 --- a/common/wildcards_and_files_ext.cpp +++ b/common/wildcards_and_files_ext.cpp @@ -72,7 +72,7 @@ const wxString NetlistFileWildcard( _( "KiCad netlist files (*.net)|*.net" ) ); const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) ); const wxString LegacyPcbFileWildcard( _( "KiCad printed circuit board files (*.brd)|*.brd" ) ); const wxString EaglePcbFileWildcard( _( "Eagle ver. 6.x XML PCB files (*.brd)|*.brd" ) ); -const wxString PCadPcbFileWildcard( _( "P-Cad 2002/2004 ASCII PCB files (*.pcb)|*.pcb" ) ); +const wxString PCadPcbFileWildcard( _( "P-Cad 200x ASCII PCB files (*.pcb)|*.pcb" ) ); const wxString PcbFileWildcard( _( "KiCad s-expr printed circuit board files (*.kicad_pcb)|*.kicad_pcb" ) ); const wxString KiCadFootprintLibFileWildcard( _( "KiCad footprint s-expre library file (*.kicad_mod)|*.kicad_mod" ) ); const wxString KiCadFootprintLibPathWildcard( _( "KiCad footprint s-expre library path (*.pretty)|*.pretty" ) ); diff --git a/eeschema/component_references_lister.cpp b/eeschema/component_references_lister.cpp index 1b02e2573c..df0f97effe 100644 --- a/eeschema/component_references_lister.cpp +++ b/eeschema/component_references_lister.cpp @@ -713,14 +713,14 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList ) && ( componentFlatList[ii].m_Unit < 0x7FFFFFFF ) ) { msg.Printf( _( "Item not annotated: %s%s (unit %d)\n" ), - GetChars( componentFlatList[ii].GetRef() ), + GetChars( componentFlatList[ii].GetRef() ), GetChars( tmp ), componentFlatList[ii].m_Unit ); } else { msg.Printf( _( "Item not annotated: %s%s\n" ), - GetChars( componentFlatList[ii].GetRef() ), + GetChars( componentFlatList[ii].GetRef() ), GetChars( tmp ) ); } @@ -782,15 +782,15 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList ) if( ( componentFlatList[ii].m_Unit > 0 ) && ( componentFlatList[ii].m_Unit < 0x7FFFFFFF ) ) { - msg.Printf( _( "Multiple item %s%s (unit %d)\n" ), - GetChars( componentFlatList[ii].GetRef() ), + msg.Printf( _( "Multiple item %s%s (unit %d)\n" ), + GetChars( componentFlatList[ii].GetRef() ), GetChars( tmp ), componentFlatList[ii].m_Unit ); } else { msg.Printf( _( "Multiple item %s%s\n" ), - GetChars( componentFlatList[ii].GetRef() ), + GetChars( componentFlatList[ii].GetRef() ), GetChars( tmp ) ); } @@ -814,15 +814,15 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList ) if( ( componentFlatList[ii].m_Unit > 0 ) && ( componentFlatList[ii].m_Unit < 0x7FFFFFFF ) ) { - msg.Printf( _( "Multiple item %s%s (unit %d)\n" ), - GetChars( componentFlatList[ii].GetRef() ), + msg.Printf( _( "Multiple item %s%s (unit %d)\n" ), + GetChars( componentFlatList[ii].GetRef() ), GetChars( tmp ), componentFlatList[ii].m_Unit ); } else { msg.Printf( _( "Multiple item %s%s\n" ), - GetChars( componentFlatList[ii].GetRef() ), + GetChars( componentFlatList[ii].GetRef() ), GetChars( tmp ) ); } @@ -837,27 +837,17 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList ) if( componentFlatList[ii].CompareValue( componentFlatList[next] ) != 0 ) { -#if defined(KICAD_GOST) - msg.Printf( _( "Different values for %s%d.%d (%s) and %s%d.%d (%s)" ), + msg.Printf( _( "Different values for %s%d%s (%s) and %s%d%s (%s)" ), GetChars( componentFlatList[ii].GetRef() ), componentFlatList[ii].m_NumRef, - componentFlatList[ii].m_Unit, + GetChars( LIB_COMPONENT::ReturnSubReference( + componentFlatList[ii].m_Unit ) ), GetChars( componentFlatList[ii].m_Value->GetText() ), GetChars( componentFlatList[next].GetRef() ), componentFlatList[next].m_NumRef, - componentFlatList[next].m_Unit, - componentFlatList[next].m_Value->GetText().GetData() ); -#else - msg.Printf( _( "Different values for %s%d%c (%s) and %s%d%c (%s)" ), - GetChars( componentFlatList[ii].GetRef() ), - componentFlatList[ii].m_NumRef, - componentFlatList[ii].m_Unit + 'A' - 1, - GetChars( componentFlatList[ii].m_Value->GetText() ), - GetChars( componentFlatList[next].GetRef() ), - componentFlatList[next].m_NumRef, - componentFlatList[next].m_Unit + 'A' - 1, + GetChars( LIB_COMPONENT::ReturnSubReference( + componentFlatList[next].m_Unit ) ), GetChars( componentFlatList[next].m_Value->GetText() ) ); -#endif if( aMessageList ) aMessageList->Add( msg + wxT( "\n" )); diff --git a/include/xnode.h b/include/xnode.h index f5eb6f1e5b..692f2085d6 100644 --- a/include/xnode.h +++ b/include/xnode.h @@ -106,15 +106,19 @@ public: wxString GetAttribute( const wxString& attrName, const wxString& defaultVal ) const { - return GetPropVal(attrName, defaultVal); + return GetPropVal( attrName, defaultVal ); } bool GetAttribute( const wxString& attrName, wxString *value ) const { - return GetPropVal(attrName, value); + return GetPropVal( attrName, value ); } void AddAttribute( const wxString& attrName, const wxString& value ) { - AddProperty(attrName, value); + AddProperty( attrName, value ); + } + bool DeleteAttribute( const wxString& attrName ) + { + DeleteProperty( attrName ); } wxXmlProperty* GetAttributes() const { diff --git a/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.cpp b/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.cpp index d178888446..bf4861586e 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.cpp @@ -131,7 +131,8 @@ double StrToDoublePrecisionUnits( wxString aStr, char aAxe, wxString aActualConv { ls.ToDouble( &i ); #ifdef PCAD2KICAD_SCALE_SCH_TO_INCH_GRID - if( aActualConversion == wxT( "SCH" ) ) + if( aActualConversion == wxT( "SCH" ) + || aActualConversion == wxT( "SCHLIB" ) ) i = i * (0.0254 / 0.025); #endif i = Millimeter2iu( i ); diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_text.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_text.cpp index 297cbbb621..a760d0b01d 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_text.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_text.cpp @@ -76,10 +76,7 @@ void PCB_TEXT::Parse( XNODE* aNode, m_rotation = StrToInt1Units( str ); } - lNode = FindNode( aNode, wxT( "value" ) ); - - if( lNode ) - m_name.text = lNode->GetNodeContent(); + aNode->GetAttribute( wxT( "Name" ), &m_name.text ); str = FindNodeGetContent( aNode, wxT( "isFlipped" ) ); diff --git a/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp b/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp index 6bd2392968..d90dd48cb9 100644 --- a/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp @@ -39,9 +39,7 @@ void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc ) { int tok; XNODE* iNode = NULL, *cNode = NULL; - wxString str; - bool growing = false; - bool attr = false; + wxString str, propValue, content; wxCSConv conv( wxT( "windows-1251" ) ); FILE* fp = wxFopen( aFileName, wxT( "rt" ) ); @@ -56,21 +54,6 @@ void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc ) while( ( tok = lexer.NextTok() ) != DSN_EOF ) { - if( growing && ( tok == DSN_LEFT || tok == DSN_RIGHT ) ) - { - if( attr ) - { - cNode->AddAttribute( wxT( "Name" ), str.Trim( false ) ); - } - else if( str != wxEmptyString ) - { - cNode->AddChild( new XNODE( wxXML_TEXT_NODE, wxEmptyString, str ) ); - } - - growing = false; - attr = false; - } - if( tok == DSN_RIGHT ) { iNode = iNode->GetParent(); @@ -82,14 +65,33 @@ void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc ) cNode = new XNODE( wxXML_ELEMENT_NODE, wxString( lexer.CurText(), conv ) ); iNode->AddChild( cNode ); iNode = cNode; - growing = true; } - else + else if( cNode ) { - str += wxT( ' ' ); - str += wxString( lexer.CurText(), conv ); + str = wxString( lexer.CurText(), conv ); if( tok == DSN_STRING ) - attr = true; + { + // update attribute + if( iNode->GetAttribute( wxT( "Name" ), &propValue ) ) + { + iNode->DeleteAttribute( wxT( "Name" ) ); + iNode->AddAttribute( wxT( "Name" ), propValue + wxT( ' ' ) + str ); + } + else + iNode->AddAttribute( wxT( "Name" ), str ); + } + else if( str != wxEmptyString ) + { + // update node content + content = cNode->GetNodeContent() + wxT( ' ' ) + str; + + if( cNode->GetChildren() ) + cNode->GetChildren()->SetContent( content ); + else + cNode->AddChild( new wxXmlNode( wxXML_TEXT_NODE, + wxEmptyString, + content ) ); + } } } From 64f8e0b8e1f7a5fef54d0d22e75147701e50a202 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Thu, 13 Jun 2013 06:43:29 -0500 Subject: [PATCH 23/50] various --- CMakeModules/cmake_uninstall.cmake.in | 41 ++++++++++++++------------- common/drawframe.cpp | 14 ++++----- common/reporter.cpp | 2 +- include/reporter.h | 13 +++++---- include/xnode.h | 2 +- pcbnew/class_board_item.cpp | 10 +++---- 6 files changed, 43 insertions(+), 39 deletions(-) diff --git a/CMakeModules/cmake_uninstall.cmake.in b/CMakeModules/cmake_uninstall.cmake.in index df95fb9d82..1a2e75c7ae 100644 --- a/CMakeModules/cmake_uninstall.cmake.in +++ b/CMakeModules/cmake_uninstall.cmake.in @@ -1,21 +1,22 @@ -IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") - MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") -ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") +if( NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" ) + message( FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"" ) +endif() -FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) -STRING(REGEX REPLACE "\n" ";" files "${files}") -FOREACH(file ${files}) - MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") - IF(EXISTS "$ENV{DESTDIR}${file}") - EXEC_PROGRAM( - "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" - OUTPUT_VARIABLE rm_out - RETURN_VALUE rm_retval - ) - IF(NOT "${rm_retval}" STREQUAL 0) - MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") - ENDIF(NOT "${rm_retval}" STREQUAL 0) - ELSE(EXISTS "$ENV{DESTDIR}${file}") - MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") - ENDIF(EXISTS "$ENV{DESTDIR}${file}") -ENDFOREACH(file) +file( READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files ) +string( REGEX REPLACE "\n" ";" files "${files}" ) + +foreach( file ${files} ) + message( STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"" ) + if( EXISTS "$ENV{DESTDIR}${file}" ) + EXEC_PROGRAM( + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + if( NOT "${rm_retval}" STREQUAL 0 ) + message( FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"" ) + endif() + else() + message( STATUS "File \"$ENV{DESTDIR}${file}\" does not exist." ) + endif() +endforeach() diff --git a/common/drawframe.cpp b/common/drawframe.cpp index 361230ff1a..56ac99c931 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -698,13 +698,13 @@ bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, int aKey, const wxPoint& aPosi break; default: - { - wxString msg; - msg << wxT( "EDA_DRAW_FRAME::HandleBlockBegin() error: Unknown command " ) << - Block->GetCommand(); - DisplayError( this, msg ); - } - break; + { + wxString msg; + msg << wxT( "EDA_DRAW_FRAME::HandleBlockBegin() error: Unknown command " ) << + Block->GetCommand(); + DisplayError( this, msg ); + } + break; } Block->SetMessageBlock( this ); diff --git a/common/reporter.cpp b/common/reporter.cpp index 7eade576a9..19fd3a0dac 100644 --- a/common/reporter.cpp +++ b/common/reporter.cpp @@ -29,7 +29,7 @@ #include -REPORTER& REPORTER::Report( const char *aText ) +REPORTER& REPORTER::Report( const char* aText ) { Report( FROM_UTF8( aText ) ); return *this; diff --git a/include/reporter.h b/include/reporter.h index 933f0269dc..efda4c6368 100644 --- a/include/reporter.h +++ b/include/reporter.h @@ -39,11 +39,14 @@ class wxTextCtrl; /** * Class REPORTER - * is a pure virtual class used to derive REPORTOR objects from. + * is a pure virtual class used to derive REPORTER objects from. * - * The purpose of the REPORTER object is to hide an object that take a string as an input - * from other objects. This prevents objects such as wxWidgets UI control internals from - * being exposed to low level KiCad objects dervice from #BOARD_ITEM and #SCH_ITEM. + * The purpose of the REPORTER object is to offer a way for a procedural function + * to report multiple errors without having to: + *
    + *
  • a) know too much about the caller's UI, i.e. wx.
  • + *
  • b) stop after the first error
  • + *
*/ class REPORTER { @@ -56,7 +59,7 @@ public: */ virtual REPORTER& Report( const wxString& aText ) = 0; - REPORTER& Report( const char *aText ); + REPORTER& Report( const char* aText ); REPORTER& operator <<( const wxString& aText ) { return Report( aText ); } diff --git a/include/xnode.h b/include/xnode.h index 692f2085d6..cdd4d78917 100644 --- a/include/xnode.h +++ b/include/xnode.h @@ -118,7 +118,7 @@ public: } bool DeleteAttribute( const wxString& attrName ) { - DeleteProperty( attrName ); + return DeleteProperty( attrName ); } wxXmlProperty* GetAttributes() const { diff --git a/pcbnew/class_board_item.cpp b/pcbnew/class_board_item.cpp index 0157c283e4..dec5ab8afa 100644 --- a/pcbnew/class_board_item.cpp +++ b/pcbnew/class_board_item.cpp @@ -116,7 +116,7 @@ std::string BOARD_ITEM::FormatInternalUnits( int aValue ) #else // Assume aValue is in nanometers, and that we want the result in millimeters, - // and that int is 32 bit wide. Then perform an alternative algorithm. + // and that int is 32 bits wide. Then perform an alternative algorithm. // Can be used to verify that the above algorithm is correctly generating text. // Convert aValue into an integer string, then insert a decimal point manually. // Results are the same as above general purpose algorithm. @@ -128,13 +128,13 @@ std::string BOARD_ITEM::FormatInternalUnits( int aValue ) else { char buf[50]; - int len = sprintf( buf, aValue > 0 ? "%06d" : "%07d", aValue ); + int len = sprintf( buf, aValue > 0 ? "%06d" : "%07d", aValue ); // optionally pad w/leading zeros std::string ret( buf, len ); std::string::iterator it = ret.end() - 1; // last byte - // insert '.' at 6 positions from end, divides by 10e6 (a million), nm => mm + // insert '.' at 6 positions from end, dividing by 10e6 (a million), nm => mm std::string::iterator decpoint = ret.end() - 6; // truncate trailing zeros, up to decimal point position @@ -147,10 +147,10 @@ std::string BOARD_ITEM::FormatInternalUnits( int aValue ) // decpoint is invalidated here, after insert() -#if 1 // want leading a zero when decimal point is in first position? +#if 1 // want a leading zero when decimal point is in first position? if( ret[0] == '.' ) { - // insert leading zero ahead of decimal. + // insert leading zero ahead of decimal point. ret.insert( ret.begin(), '0' ); } else if( ret[0]=='-' && ret[1]=='.' ) From dea9dd2361bf82eb266030434eee1473ea0591fa Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Thu, 13 Jun 2013 11:09:35 -0500 Subject: [PATCH 24/50] better error reporting and parsing of bad legacy footprint libs --- eeschema/dialogs/dialog_annotate.cpp | 2 +- include/reporter.h | 4 +- kicad/dialogs/dialog_template_selector.h | 16 ++-- kicad/project_template.h | 2 +- pcbnew/legacy_plugin.cpp | 117 ++++++++++++++--------- pcbnew/legacy_plugin.h | 2 +- 6 files changed, 89 insertions(+), 54 deletions(-) diff --git a/eeschema/dialogs/dialog_annotate.cpp b/eeschema/dialogs/dialog_annotate.cpp index 6c0c2eea71..c37d8a1e38 100644 --- a/eeschema/dialogs/dialog_annotate.cpp +++ b/eeschema/dialogs/dialog_annotate.cpp @@ -1,5 +1,5 @@ /** - * @file annotate_dialog.cpp + * @file dialog_annotate.cpp * @brief Annotation dialog functions. */ diff --git a/include/reporter.h b/include/reporter.h index efda4c6368..5c88de6449 100644 --- a/include/reporter.h +++ b/include/reporter.h @@ -44,8 +44,8 @@ class wxTextCtrl; * The purpose of the REPORTER object is to offer a way for a procedural function * to report multiple errors without having to: *
    - *
  • a) know too much about the caller's UI, i.e. wx.
  • - *
  • b) stop after the first error
  • + *
  • know too much about the caller's UI, i.e. wx.
  • + *
  • stop after the first error
  • *
*/ class REPORTER diff --git a/kicad/dialogs/dialog_template_selector.h b/kicad/dialogs/dialog_template_selector.h index 41006aab25..f4ea0f3229 100644 --- a/kicad/dialogs/dialog_template_selector.h +++ b/kicad/dialogs/dialog_template_selector.h @@ -25,17 +25,18 @@ #ifndef PROJECT_TEMPLATE_SELECTOR_H #define PROJECT_TEMPLATE_SELECTOR_H -#include "dialogs/dialog_template_selector_base.h" +#include #include "project_template.h" + class TEMPLATE_WIDGET : public TEMPLATE_WIDGET_BASE { protected: - wxDialog* dialog; - wxWindow* parent; - wxPanel* panel; + wxDialog* dialog; + wxWindow* parent; + wxPanel* panel; + bool selected; - bool selected; PROJECT_TEMPLATE* templ; void OnKillFocus( wxFocusEvent& event ); @@ -56,6 +57,7 @@ public: bool IsSelected(); }; + class TEMPLATE_SELECTION_PANEL : public TEMPLATE_SELECTION_PANEL_BASE { protected: @@ -65,6 +67,7 @@ protected: public: /** * @param aParent The window creating the dialog + * @param aPath the path */ TEMPLATE_SELECTION_PANEL( wxWindow* aParent, const wxString& aPath ); ~TEMPLATE_SELECTION_PANEL(); @@ -72,6 +75,7 @@ public: const wxString& GetPath() { return m_templatesPath; } }; + class DIALOG_TEMPLATE_SELECTOR : public DIALOG_TEMPLATE_SELECTOR_BASE { protected: @@ -92,7 +96,7 @@ public: TEMPLATE_WIDGET* GetWidget(); void SetWidget( TEMPLATE_WIDGET* aWidget ); void onNotebookResize( wxSizeEvent& event ); - void OnPageChange( wxNotebookEvent& event ); + void OnPageChange( wxNotebookEvent& event ); }; #endif diff --git a/kicad/project_template.h b/kicad/project_template.h index 0014703ba9..98234755a9 100644 --- a/kicad/project_template.h +++ b/kicad/project_template.h @@ -59,7 +59,7 @@ ~~~~~~~~~~~~~~ /info.html - Contains html formatted information about the template which is used by the - user to determine if the template is what they are after. The tag + user to determine if the template is what they are after. The <title> tag determines the actual name of the template that is exposed to the user for template selection. Using html to format this document means that images can be in-lined without having to invent a new scheme. Only HTML supported by diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index dc7c46bb9a..ababcf2649 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -276,8 +276,9 @@ void LEGACY_PLUGIN::loadAllSections( bool doAppend ) if( TESTLINE( "$MODULE" ) ) { - MODULE* m = LoadMODULE(); - m_board->Add( m, ADD_APPEND ); + auto_ptr<MODULE> module( new MODULE( m_board ) ); + LoadMODULE( module.get() ); + m_board->Add( module.release(), ADD_APPEND ); } else if( TESTLINE( "$DRAWSEGMENT" ) ) @@ -918,9 +919,8 @@ void LEGACY_PLUGIN::loadSETUP() } -MODULE* LEGACY_PLUGIN::LoadMODULE() +void LEGACY_PLUGIN::LoadMODULE( MODULE* aModule ) { - auto_ptr<MODULE> module( new MODULE( m_board ) ); char* line; while( ( line = READLINE( m_reader ) ) != NULL ) @@ -929,14 +929,14 @@ MODULE* LEGACY_PLUGIN::LoadMODULE() // most frequently encountered ones at the top - if( TESTSUBSTR( "D" ) ) // read a drawing item, e.g. "DS" + if( TESTSUBSTR( "D" ) && strchr( "SCAP", line[1] ) ) // read a drawing item, e.g. "DS" { - loadMODULE_EDGE( module.get() ); + loadMODULE_EDGE( aModule ); } else if( TESTLINE( "$PAD" ) ) { - loadPAD( module.get() ); + loadPAD( aModule ); } // Read a footprint text description (ref, value, or drawing) @@ -951,17 +951,17 @@ MODULE* LEGACY_PLUGIN::LoadMODULE() switch( tnum ) { case TEXTE_MODULE::TEXT_is_REFERENCE: - textm = &module->Reference(); + textm = &aModule->Reference(); break; case TEXTE_MODULE::TEXT_is_VALUE: - textm = &module->Value(); + textm = &aModule->Value(); break; default: // text is a drawing - textm = new TEXTE_MODULE( module.get() ); - module->GraphicalItems().PushBack( textm ); + textm = new TEXTE_MODULE( aModule ); + aModule->GraphicalItems().PushBack( textm ); } loadMODULE_TEXT( textm ); @@ -986,29 +986,29 @@ MODULE* LEGACY_PLUGIN::LoadMODULE() // data is now a two character long string // Note: some old files do not have this field if( data && data[0] == 'F' ) - module->SetLocked( true ); + aModule->SetLocked( true ); if( data && data[1] == 'P' ) - module->SetIsPlaced( true ); + aModule->SetIsPlaced( true ); - module->SetPosition( wxPoint( pos_x, pos_y ) ); - module->SetLayer( layer ); - module->SetOrientation( orient ); - module->SetTimeStamp( timestamp ); - module->SetLastEditTime( edittime ); + aModule->SetPosition( wxPoint( pos_x, pos_y ) ); + aModule->SetLayer( layer ); + aModule->SetOrientation( orient ); + aModule->SetTimeStamp( timestamp ); + aModule->SetLastEditTime( edittime ); } else if( TESTLINE( "Li" ) ) // Library name of footprint { // There can be whitespace in the footprint name on some old libraries. // Grab everything after "Li" up to end of line: - module->SetLibRef( FROM_UTF8( StrPurge( line + SZ( "Li" ) ) ) ); + // aModule->SetLibRef( FROM_UTF8( StrPurge( line + SZ( "Li" ) ) ) ); } else if( TESTLINE( "Sc" ) ) // timestamp { time_t timestamp = hexParse( line + SZ( "Sc" ) ); - module->SetTimeStamp( timestamp ); + aModule->SetTimeStamp( timestamp ); } else if( TESTLINE( "Op" ) ) // (Op)tions for auto placement @@ -1020,7 +1020,7 @@ MODULE* LEGACY_PLUGIN::LoadMODULE() if( cntRot180 > 10 ) cntRot180 = 10; - module->SetPlacementCost180( cntRot180 ); + aModule->SetPlacementCost180( cntRot180 ); int cntRot90 = itmp1 & 0x0F; if( cntRot90 > 10 ) @@ -1030,7 +1030,7 @@ MODULE* LEGACY_PLUGIN::LoadMODULE() if( itmp1 > 10 ) itmp1 = 0; - module->SetPlacementCost90( (itmp1 << 4) | cntRot90 ); + aModule->SetPlacementCost90( (itmp1 << 4) | cntRot90 ); } else if( TESTLINE( "At" ) ) // (At)tributes of module @@ -1045,30 +1045,31 @@ MODULE* LEGACY_PLUGIN::LoadMODULE() if( strstr( data, "VIRTUAL" ) ) attrs |= MOD_VIRTUAL; - module->SetAttributes( attrs ); + aModule->SetAttributes( attrs ); } else if( TESTLINE( "AR" ) ) // Alternate Reference { // e.g. "AR /47BA2624/45525076" data = strtok( line + SZ( "AR" ), delims ); - module->SetPath( FROM_UTF8( data ) ); + if( data ) + aModule->SetPath( FROM_UTF8( data ) ); } else if( TESTLINE( "$SHAPE3D" ) ) { - load3D( module.get() ); + load3D( aModule ); } else if( TESTLINE( "Cd" ) ) { // e.g. "Cd Double rangee de contacts 2 x 4 pins\r\n" - module->SetDescription( FROM_UTF8( StrPurge( line + SZ( "Cd" ) ) ) ); + aModule->SetDescription( FROM_UTF8( StrPurge( line + SZ( "Cd" ) ) ) ); } else if( TESTLINE( "Kw" ) ) // Key words { - module->SetKeywords( FROM_UTF8( StrPurge( line + SZ( "Kw" ) ) ) ); + aModule->SetKeywords( FROM_UTF8( StrPurge( line + SZ( "Kw" ) ) ) ); } else if( TESTLINE( ".SolderPasteRatio" ) ) @@ -1082,54 +1083,58 @@ MODULE* LEGACY_PLUGIN::LoadMODULE() tmp = -0.50; if( tmp > 0.0 ) tmp = 0.0; - module->SetLocalSolderPasteMarginRatio( tmp ); + aModule->SetLocalSolderPasteMarginRatio( tmp ); } else if( TESTLINE( ".SolderPaste" ) ) { BIU tmp = biuParse( line + SZ( ".SolderPaste" ) ); - module->SetLocalSolderPasteMargin( tmp ); + aModule->SetLocalSolderPasteMargin( tmp ); } else if( TESTLINE( ".SolderMask" ) ) { BIU tmp = biuParse( line + SZ( ".SolderMask" ) ); - module->SetLocalSolderMaskMargin( tmp ); + aModule->SetLocalSolderMaskMargin( tmp ); } else if( TESTLINE( ".LocalClearance" ) ) { BIU tmp = biuParse( line + SZ( ".LocalClearance" ) ); - module->SetLocalClearance( tmp ); + aModule->SetLocalClearance( tmp ); } else if( TESTLINE( ".ZoneConnection" ) ) { int tmp = intParse( line + SZ( ".ZoneConnection" ) ); - module->SetZoneConnection( (ZoneConnection)tmp ); + aModule->SetZoneConnection( (ZoneConnection)tmp ); } else if( TESTLINE( ".ThermalWidth" ) ) { BIU tmp = biuParse( line + SZ( ".ThermalWidth" ) ); - module->SetThermalWidth( tmp ); + aModule->SetThermalWidth( tmp ); } else if( TESTLINE( ".ThermalGap" ) ) { BIU tmp = biuParse( line + SZ( ".ThermalGap" ) ); - module->SetThermalGap( tmp ); + aModule->SetThermalGap( tmp ); } else if( TESTLINE( "$EndMODULE" ) ) { - module->CalculateBoundingBox(); + aModule->CalculateBoundingBox(); - return module.release(); // preferred exit + return; // preferred exit } } - THROW_IO_ERROR( "Missing '$EndMODULE'" ); + wxString msg = wxString::Format( + wxT( "Missing '$EndMODULE' for MODULE '%s'" ), + GetChars( aModule->GetLibRef() ) ); + + THROW_IO_ERROR( msg ); } @@ -1175,8 +1180,12 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule ) case 'O': padshape = PAD_OVAL; break; case 'T': padshape = PAD_TRAPEZOID; break; default: - m_error.Printf( _( "Unknown padshape '%s' on line:%d" ), - FROM_UTF8( line ).GetData(), m_reader->LineNumber() ); + m_error.Printf( _( "Unknown padshape '%c=0x%02x' on line:%d of module:'%s'" ), + (unsigned char) padshape, + (unsigned char) padshape, + m_reader->LineNumber(), + GetChars( aModule->GetLibRef() ) + ); THROW_IO_ERROR( m_error ); } @@ -1372,8 +1381,12 @@ void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule ) case 'A': shape = S_ARC; break; case 'P': shape = S_POLYGON; break; default: - m_error.Printf( wxT( "Unknown EDGE_MODULE type '%s' line %d" ), - FROM_UTF8( line ).GetData(), m_reader->LineNumber() ); + m_error.Printf( wxT( "Unknown EDGE_MODULE type:'%c=0x%02x' on line:%d of module:'%s'" ), + (unsigned char) line[1], + (unsigned char) line[1], + m_reader->LineNumber(), + GetChars( aModule->GetLibRef() ) + ); THROW_IO_ERROR( m_error ); } @@ -4036,9 +4049,27 @@ void FPL_CACHE::LoadModules( LINE_READER* aReader ) // test first for the $MODULE, even before reading because of INDEX bug. if( TESTLINE( "$MODULE" ) ) { - MODULE* m = m_owner->LoadMODULE(); + auto_ptr<MODULE> module( new MODULE( m_owner->m_board ) ); - std::string footprintName = TO_UTF8( m->GetLibRef() ); + std::string footprintName = StrPurge( line + SZ( "$MODULE" ) ); + + // set the footprint name first thing, so exceptions can use name. + module->SetLibRef( FROM_UTF8( footprintName.c_str() ) ); + +#if 0 && defined( DEBUG ) + printf( "%s\n", footprintName.c_str() ); + if( footprintName == "QFN40" ) + { + int breakhere = 1; + (void) breakhere; + } +#endif + + m_owner->LoadMODULE( module.get() ); + + MODULE* m = module.release(); // exceptions after this are not expected. + + wxASSERT( footprintName == TO_UTF8( m->GetLibRef() ) ); /* diff --git a/pcbnew/legacy_plugin.h b/pcbnew/legacy_plugin.h index 82d0681e6c..cefba1ff14 100644 --- a/pcbnew/legacy_plugin.h +++ b/pcbnew/legacy_plugin.h @@ -106,7 +106,7 @@ public: void SetReader( LINE_READER* aReader ) { m_reader = aReader; } void SetFilePtr( FILE* aFile ) { m_fp = aFile; } - MODULE* LoadMODULE(); + void LoadMODULE( MODULE* aModule ); void SaveMODULE( const MODULE* aModule ) const; void SaveModule3D( const MODULE* aModule ) const; void SaveBOARD( const BOARD* aBoard ) const; From 2810f5a5fe627127fb17580768805fb36f97b8fe Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck <dick@softplc.com> Date: Thu, 13 Jun 2013 11:17:25 -0500 Subject: [PATCH 25/50] fix error message in legacy_plugin --- pcbnew/legacy_plugin.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index ababcf2649..5ee888f724 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -1165,7 +1165,9 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule ) // sscanf( PtLine, " %s %d %d %d %d %d", BufCar, &m_Size.x, &m_Size.y, &m_DeltaSize.x, &m_DeltaSize.y, &m_Orient ); while( isSpace( *data ) ) ++data; - int padshape = *data++; + + unsigned char padchar = (unsigned char) *data++; + int padshape; BIU size_x = biuParse( data, &data ); BIU size_y = biuParse( data, &data ); @@ -1173,7 +1175,7 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule ) BIU delta_y = biuParse( data, &data ); double orient = degParse( data ); - switch( padshape ) + switch( padchar ) { case 'C': padshape = PAD_CIRCLE; break; case 'R': padshape = PAD_RECT; break; @@ -1181,8 +1183,8 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule ) case 'T': padshape = PAD_TRAPEZOID; break; default: m_error.Printf( _( "Unknown padshape '%c=0x%02x' on line:%d of module:'%s'" ), - (unsigned char) padshape, - (unsigned char) padshape, + padchar, + padchar, m_reader->LineNumber(), GetChars( aModule->GetLibRef() ) ); From 26b7bdc35c5fd67b8a4f6f984f6dbb12c2628655 Mon Sep 17 00:00:00 2001 From: jean-pierre charras <jp.charras@wanadoo.fr> Date: Fri, 14 Jun 2013 16:59:52 +0200 Subject: [PATCH 26/50] Eeschema: add dialog and utilities to create BOMs from generic netlist --- CMakeModules/Html2C.cmake | 3 +- eeschema/CMakeLists.txt | 30 + eeschema/component_references_lister.cpp | 248 --- eeschema/dialogs/dialog_bom.cpp | 476 ++++++ eeschema/dialogs/dialog_bom_base.cpp | 117 ++ eeschema/dialogs/dialog_bom_base.fbp | 1520 +++++++++++++++++ eeschema/dialogs/dialog_bom_base.h | 103 ++ eeschema/dialogs/dialog_bom_cfg.keywords | 4 + eeschema/dialogs/dialog_bom_help.html | 210 +++ eeschema/invoke_sch_dialog.h | 9 +- eeschema/netlist.h | 43 - eeschema/schframe.cpp | 5 +- scripts/bom-in-python/README-bom.txt | 14 + .../{ky/bom_example5.py => bom-generation.py} | 40 +- .../{ky/bom_example1.py => bom_csv_by_ref.py} | 10 +- .../bom_example2.py => bom_csv_by_ref_v2.py} | 12 +- ...xample3.py => bom_csv_grouped_by_value.py} | 13 +- scripts/bom-in-python/bom_html_by_value.py | 119 ++ ...ample4.py => bom_html_grouped_by_value.py} | 25 +- .../ky.py => ky_generic_netlist_reader.py} | 0 scripts/bom-in-python/{ky => }/round_robin.py | 4 +- .../{ky => }/round_value_robin.py | 22 +- 22 files changed, 2667 insertions(+), 360 deletions(-) create mode 100644 eeschema/dialogs/dialog_bom.cpp create mode 100644 eeschema/dialogs/dialog_bom_base.cpp create mode 100644 eeschema/dialogs/dialog_bom_base.fbp create mode 100644 eeschema/dialogs/dialog_bom_base.h create mode 100644 eeschema/dialogs/dialog_bom_cfg.keywords create mode 100644 eeschema/dialogs/dialog_bom_help.html create mode 100644 scripts/bom-in-python/README-bom.txt rename scripts/bom-in-python/{ky/bom_example5.py => bom-generation.py} (89%) rename scripts/bom-in-python/{ky/bom_example1.py => bom_csv_by_ref.py} (82%) rename scripts/bom-in-python/{ky/bom_example2.py => bom_csv_by_ref_v2.py} (81%) rename scripts/bom-in-python/{ky/bom_example3.py => bom_csv_grouped_by_value.py} (83%) create mode 100644 scripts/bom-in-python/bom_html_by_value.py rename scripts/bom-in-python/{ky/bom_example4.py => bom_html_grouped_by_value.py} (89%) rename scripts/bom-in-python/{ky/ky.py => ky_generic_netlist_reader.py} (100%) rename scripts/bom-in-python/{ky => }/round_robin.py (87%) rename scripts/bom-in-python/{ky => }/round_value_robin.py (88%) diff --git a/CMakeModules/Html2C.cmake b/CMakeModules/Html2C.cmake index 2c44322d64..99919b31ce 100644 --- a/CMakeModules/Html2C.cmake +++ b/CMakeModules/Html2C.cmake @@ -8,5 +8,6 @@ file( STRINGS ${inputFile} lines ) file( WRITE ${outputFile} "// Do not edit this file, it is autogenerated by CMake from an HTML file\n" ) foreach( line ${lines} ) - file( APPEND ${outputFile} "\"" ${line} "\"\n" ) + STRING(REGEX REPLACE "\"" "\\\\\"" linem ${line}) + file( APPEND ${outputFile} "\"" ${linem} "\\n\"\n" ) endforeach( line ${lines} ) diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 416b853cf3..6c22e75182 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -14,6 +14,9 @@ set(EESCHEMA_DLGS dialogs/dialog_color_config.cpp dialogs/dialog_annotate.cpp dialogs/dialog_annotate_base.cpp + dialogs/dialog_bom.cpp + dialogs/dialog_bom_base.cpp + dialogs/dialog_bom_cfg_keywords.cpp dialogs/dialog_lib_edit_text.cpp dialogs/dialog_lib_edit_text_base.cpp dialogs/dialog_edit_component_in_lib.cpp @@ -203,6 +206,33 @@ make_lexer( template_fieldnames.h ) +make_lexer( + ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_bom_cfg.keywords + ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_bom_cfg_lexer.h + ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_bom_cfg_keywords.cpp + T_BOMCFG_T + + # Pass header file with dependency on *_lexer.h as extra_arg + /dialogs/dialog_bom_cfg.h + ) + +# Create a C++ compilable string initializer containing html text into a *.h file: +add_custom_command( + OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_bom_help_html.h + COMMAND ${CMAKE_COMMAND} + -DinputFile=${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_bom_help.html + -DoutputFile=${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_bom_help_html.h + -P ${CMAKE_MODULE_PATH}/Html2C.cmake + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_bom_help.html + COMMENT "creating ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_bom_help_html.h + from ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_bom_help.html" + ) + +set_source_files_properties( dialogs/dialog_bom.cpp + PROPERTIES + OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_bom_help_html.h + ) + add_executable(eeschema WIN32 MACOSX_BUNDLE ${EESCHEMA_SRCS} ${EESCHEMA_COMMON_SRCS} diff --git a/eeschema/component_references_lister.cpp b/eeschema/component_references_lister.cpp index df0f97effe..e352f785df 100644 --- a/eeschema/component_references_lister.cpp +++ b/eeschema/component_references_lister.cpp @@ -67,7 +67,6 @@ bool SCH_REFERENCE_LIST::sortByXPosition( const SCH_REFERENCE& item1, return ii < 0; } - bool SCH_REFERENCE_LIST::sortByYPosition( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 ) { @@ -106,252 +105,6 @@ bool SCH_REFERENCE_LIST::sortByRefAndValue( const SCH_REFERENCE& item1, return ii < 0; } -bool SCH_REFERENCE_LIST::sortByValueAndRef( const SCH_REFERENCE& item1, - const SCH_REFERENCE& item2 ) -{ - int ii = item1.CompareValue( item2 ); - - if( ii == 0 ) - ii = RefDesStringCompare( item1.GetRef(), item2.GetRef() ); - - if( ii == 0 ) - ii = item1.m_Unit - item2.m_Unit; - - if( ii == 0 ) - ii = item1.m_SheetNum - item2.m_SheetNum; - - if( ii == 0 ) - ii = item1.m_CmpPos.x - item2.m_CmpPos.x; - - if( ii == 0 ) - ii = item1.m_CmpPos.y - item2.m_CmpPos.y; - - if( ii == 0 ) - ii = item1.m_TimeStamp - item2.m_TimeStamp; - - return ii < 0; -} - -/* - * Helper function to calculate in a component value string - * the value, depending on multiplier symbol: - * pico - * nano - * micro (u) - * milli (m) - * kilo (k ou K) - * Mega - * Giga - * Tera - * - * with notations like 1K; 1.5K; 1,5K; 1k5 - * returns true if the string is a value, false if not - * (a value is a string starting by a number) - */ - -static bool engStrToDouble( wxString aStr, double* aDouble ) -{ - // A trick to take care of strings without a multiplier - aStr.Append( wxT( "R" ) ); - - // Regular expression for a value string, e.g., 47k2 -#if defined(KICAD_GOST) - static wxRegEx valueRegEx( wxT( "^([0-9]+)(мк|[pnumRkKMGT.,кнМГ])([0-9]*)(мк*|[pnumRkKMGTкнМГ]*)" ) ); -#else - static wxRegEx valueRegEx( wxT( "^([0-9]+)([pnumRkKMGT.,])([0-9]*)([pnumRkKMGT]*)" ) ); -#endif - - if( !valueRegEx.Matches( aStr ) ) - return false; - - wxString valueStr = wxString( valueRegEx.GetMatch( aStr, 1 ) - + wxT( "." ) - + valueRegEx.GetMatch( aStr, 3 ) ); - wxString multiplierString = valueRegEx.GetMatch( aStr, 2 ); -#if defined(KICAD_GOST) - if ( multiplierString == wxT( "мк" ) ) - multiplierString = wxT( "u" ); - else if ( multiplierString == wxT( "к" ) ) - multiplierString = wxT( "k" ); - else if ( multiplierString == wxT( "н" ) ) - multiplierString = wxT( "n" ); - else if ( multiplierString == wxT( "М" ) ) - multiplierString = wxT( "M" ); - else if ( multiplierString == wxT( "Г" ) ) - multiplierString = wxT( "G" ); -#endif - wxString post_multiplierString = valueRegEx.GetMatch( aStr, 4 ); -#if defined(KICAD_GOST) - if ( post_multiplierString == wxT( "мк" ) ) - multiplierString = wxT( "u" ); - else if ( post_multiplierString == wxT( "к" ) ) - multiplierString = wxT( "k" ); - else if ( post_multiplierString == wxT( "н" ) ) - multiplierString = wxT( "n" ); - else if ( post_multiplierString == wxT( "М" ) ) - multiplierString = wxT( "M" ); - else if ( post_multiplierString == wxT( "Г" ) ) - multiplierString = wxT( "G" ); -#endif - double multiplier; - - switch( (wxChar)multiplierString[0] ) - { - case 'p': - multiplier = 1e-12; - break; - case 'n': - multiplier = 1e-9; - break; - case 'u': - multiplier = 1e-6; - break; - case 'm': - multiplier = 1e-3; - break; - case 'k': - case 'K': - multiplier = 1e3; - break; - case 'M': - multiplier = 1e6; - break; - case 'G': - multiplier = 1e9; - break; - case 'T': - multiplier = 1e12; - break; - case 'R': - case '.': // floating point separator - case ',': // floating point separator (some languages) - default: - multiplier = 1; - break; - } - - switch( (wxChar)post_multiplierString[0] ) - { - case 'p': - multiplier = 1e-12; - break; - case 'n': - multiplier = 1e-9; - break; - case 'u': - multiplier = 1e-6; - break; - case 'm': - multiplier = 1e-3; - break; - case 'k': - case 'K': - multiplier = 1e3; - break; - case 'M': - multiplier = 1e6; - break; - case 'G': - multiplier = 1e9; - break; - case 'T': - multiplier = 1e12; - break; - case 'R': - default: - break; - } - - LOCALE_IO dummy; // set to C floating point standard - valueStr.ToDouble( aDouble ); - *aDouble *= multiplier; - - return true; -} - - -static bool splitRefStr( const wxString& aRef, wxString* aStr, int* aNumber ) -{ - static wxRegEx refRegEx( wxT( "^([a-zA-Z]+)([0-9]+)" ) ); - - if( !refRegEx.Matches( aRef ) ) - return false; - - *aStr = refRegEx.GetMatch( aRef, 1 ); - *aNumber = wxAtoi( refRegEx.GetMatch( aRef, 2 ) ); - return true; -} - -/* sort the list of references by value. - * Components are grouped by type and are sorted by value: - * The value of a component accept multiplier symbols (p, n, K ..) - * groups are made by first letter of reference - */ -bool SCH_REFERENCE_LIST::sortByValueOnly( const SCH_REFERENCE& item1, - const SCH_REFERENCE& item2 ) -{ - // First, group by type according to reference text part (R, C, etc.) - wxString text1 = item1.GetComponent()->GetField( REFERENCE )->GetText(); - wxString text2 = item2.GetComponent()->GetField( REFERENCE )->GetText(); - wxString refNameStr1, refNameStr2; - int refNumber1, refNumber2; - - if( !splitRefStr( text1, &refNameStr1, &refNumber1 ) ) - return false; - - if( !splitRefStr( text2, &refNameStr2, &refNumber2 ) ) - return false; - - int ii = refNameStr1.CmpNoCase( refNameStr2 ); - - if( ii != 0 ) - return ii < 0; - - // We can compare here 2 values relative to components of the same type - // assuming references are correctly chosen - text1 = item1.GetComponent()->GetField( VALUE )->GetText(); - text2 = item2.GetComponent()->GetField( VALUE )->GetText(); - - double value1, value2; - - // Try to convert value to double (4k7 -> 4700 etc.) - bool match1 = engStrToDouble( text1, &value1 ); - bool match2 = engStrToDouble( text2, &value2 ); - - // Values come before other strings - if( match1 && !match2 ) - return true; - - // Values come before other strings - if( !match1 && match2 ) - return false; - - if( match1 && match2 && (value1 != value2) ) - return value1 < value2; - - // Inside a group of components of same value, it could be good to group per footprints - text1 = item1.GetComponent()->GetField( FOOTPRINT )->GetText(); - text2 = item2.GetComponent()->GetField( FOOTPRINT )->GetText(); - ii = text1.CmpNoCase( text2 ); - - if( ii != 0 ) - return ii < 0; - - if( refNumber1 != refNumber2 ) - return refNumber1 < refNumber2; - - // Fall back to normal string compare - ii = text1.CmpNoCase( text2 ); - - if( ii == 0 ) - ii = RefDesStringCompare( item1.GetRef(), item2.GetRef() ); - - if( ii == 0 ) - ii = item1.m_Unit - item2.m_Unit; - - return ii < 0; -} - bool SCH_REFERENCE_LIST::sortByReferenceOnly( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 ) @@ -385,7 +138,6 @@ bool SCH_REFERENCE_LIST::sortByTimeStamp( const SCH_REFERENCE& item1, return ii < 0; } - int SCH_REFERENCE_LIST::FindUnit( size_t aIndex, int aUnit ) { int NumRef; diff --git a/eeschema/dialogs/dialog_bom.cpp b/eeschema/dialogs/dialog_bom.cpp new file mode 100644 index 0000000000..e98d474fb3 --- /dev/null +++ b/eeschema/dialogs/dialog_bom.cpp @@ -0,0 +1,476 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2013 Jean-Pierre Charras, jp.charras@wanadoo.fr + * 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 eeschema/dialogs/dialog_bom.cpp + * @brief Dialog box for creating bom and other documents from generic netlist. + */ + + +#include <fctsys.h> +#include <appl_wxstruct.h> +#include <confirm.h> +#include <gestfich.h> +#include <wxEeschemaStruct.h> + +#include <netlist.h> +#include <sch_sheet.h> +#include <invoke_sch_dialog.h> +#include <dialog_helpers.h> +#include <dialog_bom_base.h> +#include <../common/dialogs/dialog_display_info_HTML_base.h> + +#define BOM_PLUGINS_KEY wxT("bom_plugins") +#define BOM_PLUGIN_SELECTED_KEY wxT("bom_plugin_selected") + +const char * s_bomHelpInfo = +#include <dialog_bom_help_html.h> +; + +#include <dialog_bom_cfg_lexer.h> + +using namespace T_BOMCFG_T; + +/** + * Class BOM_CFG_READER_PARSER + * holds data and functions pertinent to parsing a S-expression file + * for a WORKSHEET_LAYOUT. + */ +class BOM_CFG_READER_PARSER : public DIALOG_BOM_CFG_LEXER +{ + wxArrayString* m_pluginsList; + +public: + BOM_CFG_READER_PARSER( wxArrayString* aPlugins, + const char* aData, const wxString& aSource ); + void Parse() throw( PARSE_ERROR, IO_ERROR ); + +private: + void parsePlugin() throw( IO_ERROR, PARSE_ERROR ); + +}; + +// PCB_PLOT_PARAMS_PARSER + +BOM_CFG_READER_PARSER::BOM_CFG_READER_PARSER( wxArrayString* aPlugins, + const char* aLine, + const wxString& aSource ) : + DIALOG_BOM_CFG_LEXER( aLine, aSource ) +{ + m_pluginsList = aPlugins; +} + + +void BOM_CFG_READER_PARSER::Parse() throw( PARSE_ERROR, IO_ERROR ) +{ + T token; + + while( ( token = NextTok() ) != T_RIGHT ) + { + if( token == T_EOF) + break; + + if( token == T_LEFT ) + token = NextTok(); + + if( token == T_plugins ) + continue; + + switch( token ) + { + case T_plugin: // Defines a new plugin + parsePlugin(); + break; + + default: +// Unexpected( CurText() ); + break; + } + } +} + +void BOM_CFG_READER_PARSER::parsePlugin() throw( IO_ERROR, PARSE_ERROR ) +{ + wxString title, command; + + NeedSYMBOLorNUMBER(); + title = FromUTF8(); + + T token; + while( ( token = NextTok() ) != T_RIGHT ) + { + if( token == T_EOF) + break; + + switch( token ) + { + case T_LEFT: + break; + + case T_cmd: + NeedSYMBOLorNUMBER(); + command = FromUTF8(); + NeedRIGHT(); + break; + + case T_opts: + while( ( token = NextTok() ) != T_RIGHT && token != T_EOF ); + break; + + default: + Unexpected( CurText() ); + break; + } + } + + if( ! title.IsEmpty() ) + { + m_pluginsList->Add( title ); + m_pluginsList->Add( command ); + } +} + +// The main dialog frame tu run scripts to build bom +class DIALOG_BOM : public DIALOG_BOM_BASE +{ +private: + SCH_EDIT_FRAME* m_parent; + // The list of scripts (or plugins): + // a script descr uses 2 lines: + // the first is the title + // the second is the command line + wxArrayString m_plugins; + wxConfig* m_config; // to store the "plugins" + +public: + // Constructor and destructor + DIALOG_BOM( SCH_EDIT_FRAME* parent ); + ~DIALOG_BOM(); + +private: + void OnPluginSelected( wxCommandEvent& event ); + void OnRunPlugin( wxCommandEvent& event ); + void OnCancelClick( wxCommandEvent& event ); + void OnHelp( wxCommandEvent& event ); + void OnAddPlugin( wxCommandEvent& event ); + void OnChoosePlugin( wxCommandEvent& event ); + void OnRemovePlugin( wxCommandEvent& event ); + void OnEditPlugin( wxCommandEvent& event ); + void OnCommandLineEdited( wxCommandEvent& event ); + void OnNameEdited( wxCommandEvent& event ); + + void pluginInit(); + void installPluginsList(); +}; + +// Create and show DIALOG_BOM. +int InvokeDialogCreateBOM( SCH_EDIT_FRAME* aCaller ) +{ + DIALOG_BOM dlg( aCaller ); + return dlg.ShowModal(); +} + +DIALOG_BOM::DIALOG_BOM( SCH_EDIT_FRAME* parent ) : + DIALOG_BOM_BASE( parent ) +{ + m_parent = parent; + m_config = wxGetApp().GetSettings(); + installPluginsList(); + + GetSizer()->SetSizeHints( this ); + Centre(); +} + +DIALOG_BOM::~DIALOG_BOM() +{ + wxString list; + + // Save the plugin descriptions in config. + // the config stores only one string. + // plugins are saved inside a S expr: + // ( plugins + // ( plugin "plugin name" (cmd "command line") ) + // .... + // ) + + STRING_FORMATTER writer; + list << wxT("(plugins"); + for( unsigned ii = 0; ii < m_plugins.GetCount(); ii += 2 ) + { + writer.Print( 1, "(plugin %s (cmd %s))", + writer.Quotew( m_plugins[ii] ).c_str(), + writer.Quotew( m_plugins[ii+1] ).c_str() ); + } + + list << writer.GetString(); + list << wxT(")"); + + m_config->Write( BOM_PLUGINS_KEY, list ); + + wxString active_plugin_name = m_lbPlugins->GetStringSelection( ); + m_config->Write( BOM_PLUGIN_SELECTED_KEY, active_plugin_name ); + +} + +/* Read the initialized plugins in config and fill the list + * of names + */ +void DIALOG_BOM::installPluginsList() +{ + wxString list, text, active_plugin_name; + m_config->Read( BOM_PLUGINS_KEY, &list ); + m_config->Read( BOM_PLUGIN_SELECTED_KEY, &active_plugin_name ); + + if( !list.IsEmpty() ) + { + BOM_CFG_READER_PARSER cfg_parser( &m_plugins, list.c_str(), wxT( "plugins" ) ); + try + { + cfg_parser.Parse(); + } + catch( IO_ERROR ioe ) + { +// wxLogMessage( ioe.errorText ); + } + } + + // Populate list box + for( unsigned ii = 0; ii < m_plugins.GetCount(); ii+=2 ) + { + m_lbPlugins->Append( m_plugins[ii] ); + + if( active_plugin_name == m_plugins[ii] ) + m_lbPlugins->SetSelection( ii/2 ); + } + + pluginInit(); +} + +void DIALOG_BOM::OnPluginSelected( wxCommandEvent& event ) +{ + pluginInit(); +} + +void DIALOG_BOM::pluginInit() +{ + int ii = m_lbPlugins->GetSelection(); + + if( ii < 0 ) + return; + + m_textCtrlName->SetValue( m_plugins[2 * ii] ); + m_textCtrlCommand->SetValue( m_plugins[(2 * ii)+1] ); +} + + +/** + * Function RunPlugin + * run the plugin command line + */ +void DIALOG_BOM::OnRunPlugin( wxCommandEvent& event ) +{ + wxFileName fn; + wxString fileWildcard; + wxString title = _( "Save Netlist File" ); + + // Calculate the xml netlist filename + fn = g_RootSheet->GetScreen()->GetFileName(); + + if( fn.GetPath().IsEmpty() ) + fn.SetPath( wxGetCwd() ); + + fn.ClearExt(); + wxString fullfilename = fn.GetFullPath(); + m_parent->ClearMsgPanel(); + + m_parent->SetNetListerCommand( m_textCtrlCommand->GetValue() ); + m_parent->CreateNetlist( -1, fullfilename, 0 ); +} + + +void DIALOG_BOM::OnCancelClick( wxCommandEvent& event ) +{ + EndModal( wxID_CANCEL ); +} + + +/** + * Function OnRemovePlugin + * Remove a plugin from the list + */ +void DIALOG_BOM::OnRemovePlugin( wxCommandEvent& event ) +{ + int ii = m_lbPlugins->GetSelection(); + + if( ii < 0 ) + return; + + m_lbPlugins->Delete( ii ); + + m_plugins.RemoveAt( 2*ii, 2 ); // Remove title and command line +} + +/** + * Function OnAddPlugin + * Add a new panel for a new netlist plugin + */ +void DIALOG_BOM::OnAddPlugin( wxCommandEvent& event ) +{ + // Creates a new plugin entry + wxString name = wxGetTextFromUser( _("Plugin") ); + + if( name.IsEmpty() ) + return; + + // Verify if it does not exists + for( unsigned ii = 0; ii < m_plugins.GetCount(); ii += 2 ) + { + if( name == m_plugins[ii] ) + { + wxMessageBox( _("This plugin already exists. Abort") ); + return; + } + } + + m_plugins.Add( name ); + m_plugins.Add( wxEmptyString ); + m_lbPlugins->Append( name ); + m_lbPlugins->SetSelection( m_lbPlugins->GetCount() - 1 ); +} + +/* + * Browse plugin files, and set m_CommandStringCtrl field + */ +void DIALOG_BOM::OnChoosePlugin( wxCommandEvent& event ) +{ + wxString FullFileName, Mask, Path; + + Mask = wxT( "*" ); + Path = wxGetApp().GetExecutablePath(); + FullFileName = EDA_FileSelector( _( "Plugin files:" ), + Path, + FullFileName, + wxEmptyString, + Mask, + this, + wxFD_OPEN, + true + ); + if( FullFileName.IsEmpty() ) + return; + + // Creates a default command line, + // suitable to run the external tool xslproc or python + // The default command line depending on plugin extension, currently + // "xsl" or "exe" or "py" + wxString cmdLine; + wxFileName fn( FullFileName ); + wxString ext = fn.GetExt(); + + if( ext == wxT("xsl" ) ) + cmdLine.Printf(wxT("xsltproc -o \"%%O\" \"%s\" \"%%I\""), GetChars(FullFileName) ); + else if( ext == wxT("exe" ) || ext.IsEmpty() ) + cmdLine.Printf(wxT("\"%s\" > \"%%O\" < \"%%I\""), GetChars(FullFileName) ); + else if( ext == wxT("py" ) || ext.IsEmpty() ) + cmdLine.Printf(wxT("python \"%s\" \"%%I\" \"%%O\""), GetChars(FullFileName) ); + else + cmdLine.Printf(wxT("\"%s\""), GetChars(FullFileName) ); + + m_textCtrlCommand->SetValue( cmdLine ); +} + +void DIALOG_BOM::OnEditPlugin( wxCommandEvent& event ) +{ + wxString pluginName, cmdline; + + // Try to find the plugin name. + // This is possible if the name ends by .py or .xsl + cmdline = m_textCtrlCommand->GetValue(); + int pos = -1; + + if( (pos = cmdline.Find( wxT(".py") )) != wxNOT_FOUND ) + pos += 2; + else if( (pos = cmdline.Find( wxT(".xsl") )) != wxNOT_FOUND ) + pos += 3; + + // the end of plugin name is at position pos. + if( pos > 0 ) + { + // Be sure this is the end of the name: the next char is " or space + int eos = cmdline[pos+1]; + + if( eos == ' '|| eos == '\"' ) + { + // search for the starting point of the name + int jj = pos-1; + while( jj >= 0 ) + if( cmdline[jj] != eos ) + jj--; + else + break; + + // extract the name + if( jj >= 0 ) + pluginName = cmdline.SubString( jj, pos ); + } + } + AddDelimiterString( pluginName ); + wxString editorname = wxGetApp().GetEditorName(); + + if( !editorname.IsEmpty() ) + ExecuteFile( this, editorname, pluginName ); + else + wxMessageBox( _("No text editor selected in KiCad. Please choose it") ); +} + +void DIALOG_BOM::OnHelp( wxCommandEvent& event ) +{ + DIALOG_DISPLAY_HTML_TEXT_BASE help_Dlg( this, wxID_ANY, + _("Bom generation Help"),wxDefaultPosition, wxSize( 750,550 ) ); + + wxString msg = FROM_UTF8(s_bomHelpInfo); + help_Dlg.m_htmlWindow->AppendToPage( msg ); + help_Dlg.ShowModal(); +} + +void DIALOG_BOM::OnCommandLineEdited( wxCommandEvent& event ) +{ + int ii = m_lbPlugins->GetSelection(); + + if( ii < 0 ) + return; + + m_plugins[(2 * ii)+1] = m_textCtrlCommand->GetValue(); +} + +void DIALOG_BOM::OnNameEdited( wxCommandEvent& event ) +{ + int ii = m_lbPlugins->GetSelection(); + + if( ii < 0 ) + return; + + m_plugins[2 * ii] = m_textCtrlName->GetValue(); + m_lbPlugins->SetString( ii, m_plugins[2 * ii] ); +} diff --git a/eeschema/dialogs/dialog_bom_base.cpp b/eeschema/dialogs/dialog_bom_base.cpp new file mode 100644 index 0000000000..f493248c94 --- /dev/null +++ b/eeschema/dialogs/dialog_bom_base.cpp @@ -0,0 +1,117 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 8 2012) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_bom_base.h" + +/////////////////////////////////////////////////////////////////////////// + +BEGIN_EVENT_TABLE( DIALOG_BOM_BASE, DIALOG_SHIM ) + EVT_LISTBOX( wxID_ANY, DIALOG_BOM_BASE::_wxFB_OnPluginSelected ) + EVT_TEXT( ID_CMDLINE, DIALOG_BOM_BASE::_wxFB_OnCommandLineEdited ) + EVT_TEXT( IN_NAMELINE, DIALOG_BOM_BASE::_wxFB_OnNameEdited ) + EVT_BUTTON( ID_CREATE_BOM, DIALOG_BOM_BASE::_wxFB_OnRunPlugin ) + EVT_BUTTON( wxID_CANCEL, DIALOG_BOM_BASE::_wxFB_OnCancelClick ) + EVT_BUTTON( ID_HELP, DIALOG_BOM_BASE::_wxFB_OnHelp ) + EVT_BUTTON( ID_ADD_PLUGIN, DIALOG_BOM_BASE::_wxFB_OnAddPlugin ) + EVT_BUTTON( wxID_BROWSE_PLUGINS, DIALOG_BOM_BASE::_wxFB_OnChoosePlugin ) + EVT_BUTTON( ID_REMOVEL_PLUGIN, DIALOG_BOM_BASE::_wxFB_OnRemovePlugin ) + EVT_BUTTON( wxID_ANY, DIALOG_BOM_BASE::_wxFB_OnEditPlugin ) +END_EVENT_TABLE() + +DIALOG_BOM_BASE::DIALOG_BOM_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bMainSizer; + bMainSizer = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bUpperSizer; + bUpperSizer = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* bLeftSizer; + bLeftSizer = new wxBoxSizer( wxVERTICAL ); + + m_staticTextPluginTitle = new wxStaticText( this, wxID_ANY, _("Plugins"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextPluginTitle->Wrap( -1 ); + bLeftSizer->Add( m_staticTextPluginTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_lbPlugins = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); + bLeftSizer->Add( m_lbPlugins, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_staticTextCmd = new wxStaticText( this, wxID_ANY, _("Command line:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextCmd->Wrap( -1 ); + bLeftSizer->Add( m_staticTextCmd, 0, wxRIGHT|wxLEFT, 5 ); + + m_textCtrlCommand = new wxTextCtrl( this, ID_CMDLINE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_textCtrlCommand->SetMaxLength( 0 ); + m_textCtrlCommand->SetMinSize( wxSize( 300,-1 ) ); + + bLeftSizer->Add( m_textCtrlCommand, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_staticTextName = new wxStaticText( this, wxID_ANY, _("Name:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextName->Wrap( -1 ); + bLeftSizer->Add( m_staticTextName, 0, wxRIGHT|wxLEFT, 5 ); + + m_textCtrlName = new wxTextCtrl( this, IN_NAMELINE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_textCtrlName->SetMaxLength( 0 ); + bLeftSizer->Add( m_textCtrlName, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + + bUpperSizer->Add( bLeftSizer, 1, wxEXPAND, 5 ); + + wxBoxSizer* bRightSizer; + bRightSizer = new wxBoxSizer( wxVERTICAL ); + + m_buttonNetlist = new wxButton( this, ID_CREATE_BOM, _("Generate"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonNetlist->SetDefault(); + bRightSizer->Add( m_buttonNetlist, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); + + m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); + bRightSizer->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); + + m_buttonHelp = new wxButton( this, ID_HELP, _("Help"), wxDefaultPosition, wxDefaultSize, 0 ); + bRightSizer->Add( m_buttonHelp, 0, wxALL|wxEXPAND, 5 ); + + m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bRightSizer->Add( m_staticline2, 0, wxEXPAND | wxALL, 5 ); + + m_buttonAddPlugin = new wxButton( this, ID_ADD_PLUGIN, _("Add Plugin"), wxDefaultPosition, wxDefaultSize, 0 ); + bRightSizer->Add( m_buttonAddPlugin, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); + + m_buttonBrowsePlugin = new wxButton( this, wxID_BROWSE_PLUGINS, _("Set Plugin"), wxDefaultPosition, wxDefaultSize, 0 ); + bRightSizer->Add( m_buttonBrowsePlugin, 0, wxALL|wxEXPAND, 5 ); + + m_buttonDelPlugin = new wxButton( this, ID_REMOVEL_PLUGIN, _("Remove Plugin"), wxDefaultPosition, wxDefaultSize, 0 ); + bRightSizer->Add( m_buttonDelPlugin, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); + + m_buttonEdit = new wxButton( this, wxID_ANY, _("Edit Plugin"), wxDefaultPosition, wxDefaultSize, 0 ); + bRightSizer->Add( m_buttonEdit, 0, wxALL|wxEXPAND, 5 ); + + + bUpperSizer->Add( bRightSizer, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + + bMainSizer->Add( bUpperSizer, 1, wxEXPAND, 5 ); + + m_staticTextDefaultFN = new wxStaticText( this, wxID_ANY, _("Output filename:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextDefaultFN->Wrap( -1 ); + bMainSizer->Add( m_staticTextDefaultFN, 0, wxRIGHT|wxLEFT, 5 ); + + m_textCtrlDefaultFileName = new wxTextCtrl( this, ID_FN, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); + m_textCtrlDefaultFileName->SetMaxLength( 0 ); + bMainSizer->Add( m_textCtrlDefaultFileName, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + + this->SetSizer( bMainSizer ); + this->Layout(); + + this->Centre( wxBOTH ); +} + +DIALOG_BOM_BASE::~DIALOG_BOM_BASE() +{ +} diff --git a/eeschema/dialogs/dialog_bom_base.fbp b/eeschema/dialogs/dialog_bom_base.fbp new file mode 100644 index 0000000000..6455cc8023 --- /dev/null +++ b/eeschema/dialogs/dialog_bom_base.fbp @@ -0,0 +1,1520 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<wxFormBuilder_Project> + <FileVersion major="1" minor="11" /> + <object class="Project" expanded="1"> + <property name="class_decoration"></property> + <property name="code_generation">C++</property> + <property name="disconnect_events">0</property> + <property name="disconnect_mode">source_name</property> + <property name="disconnect_php_events">0</property> + <property name="disconnect_python_events">0</property> + <property name="embedded_files_path">res</property> + <property name="encoding">UTF-8</property> + <property name="event_generation">table</property> + <property name="file">dialog_bom_base</property> + <property name="first_id">1000</property> + <property name="help_provider">none</property> + <property name="internationalize">1</property> + <property name="name">dialog_bom_base</property> + <property name="namespace"></property> + <property name="path">.</property> + <property name="precompiled_header"></property> + <property name="relative_path">1</property> + <property name="skip_php_events">1</property> + <property name="skip_python_events">1</property> + <property name="use_enum">1</property> + <property name="use_microsoft_bom">0</property> + <object class="Dialog" expanded="1"> + <property name="aui_managed">0</property> + <property name="aui_manager_style">wxAUI_MGR_DEFAULT</property> + <property name="bg"></property> + <property name="center">wxBOTH</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="enabled">1</property> + <property name="event_handler">impl_virtual</property> + <property name="extra_style"></property> + <property name="fg"></property> + <property name="font"></property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="maximum_size"></property> + <property name="minimum_size"></property> + <property name="name">DIALOG_BOM_BASE</property> + <property name="pos"></property> + <property name="size">404,334</property> + <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property> + <property name="subclass">DIALOG_SHIM; dialog_shim.h</property> + <property name="title">Bill of Material</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <event name="OnActivate"></event> + <event name="OnActivateApp"></event> + <event name="OnAuiFindManager"></event> + <event name="OnAuiPaneButton"></event> + <event name="OnAuiPaneClose"></event> + <event name="OnAuiPaneMaximize"></event> + <event name="OnAuiPaneRestore"></event> + <event name="OnAuiRender"></event> + <event name="OnChar"></event> + <event name="OnClose"></event> + <event name="OnEnterWindow"></event> + <event name="OnEraseBackground"></event> + <event name="OnHibernate"></event> + <event name="OnIconize"></event> + <event name="OnIdle"></event> + <event name="OnInitDialog"></event> + <event name="OnKeyDown"></event> + <event name="OnKeyUp"></event> + <event name="OnKillFocus"></event> + <event name="OnLeaveWindow"></event> + <event name="OnLeftDClick"></event> + <event name="OnLeftDown"></event> + <event name="OnLeftUp"></event> + <event name="OnMiddleDClick"></event> + <event name="OnMiddleDown"></event> + <event name="OnMiddleUp"></event> + <event name="OnMotion"></event> + <event name="OnMouseEvents"></event> + <event name="OnMouseWheel"></event> + <event name="OnPaint"></event> + <event name="OnRightDClick"></event> + <event name="OnRightDown"></event> + <event name="OnRightUp"></event> + <event name="OnSetFocus"></event> + <event name="OnSize"></event> + <event name="OnUpdateUI"></event> + <object class="wxBoxSizer" expanded="1"> + <property name="minimum_size"></property> + <property name="name">bMainSizer</property> + <property name="orient">wxVERTICAL</property> + <property name="permission">none</property> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxEXPAND</property> + <property name="proportion">1</property> + <object class="wxBoxSizer" expanded="1"> + <property name="minimum_size"></property> + <property name="name">bUpperSizer</property> + <property name="orient">wxHORIZONTAL</property> + <property name="permission">none</property> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxEXPAND</property> + <property name="proportion">1</property> + <object class="wxBoxSizer" expanded="1"> + <property name="minimum_size"></property> + <property name="name">bLeftSizer</property> + <property name="orient">wxVERTICAL</property> + <property name="permission">none</property> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxTOP|wxRIGHT|wxLEFT</property> + <property name="proportion">0</property> + <object class="wxStaticText" expanded="1"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="label">Plugins</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_staticTextPluginTitle</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass"></property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <property name="wrap">-1</property> + <event name="OnChar"></event> + <event name="OnEnterWindow"></event> + <event name="OnEraseBackground"></event> + <event name="OnKeyDown"></event> + <event name="OnKeyUp"></event> + <event name="OnKillFocus"></event> + <event name="OnLeaveWindow"></event> + <event name="OnLeftDClick"></event> + <event name="OnLeftDown"></event> + <event name="OnLeftUp"></event> + <event name="OnMiddleDClick"></event> + <event name="OnMiddleDown"></event> + <event name="OnMiddleUp"></event> + <event name="OnMotion"></event> + <event name="OnMouseEvents"></event> + <event name="OnMouseWheel"></event> + <event name="OnPaint"></event> + <event name="OnRightDClick"></event> + <event name="OnRightDown"></event> + <event name="OnRightUp"></event> + <event name="OnSetFocus"></event> + <event name="OnSize"></event> + <event name="OnUpdateUI"></event> + </object> + </object> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property> + <property name="proportion">1</property> + <object class="wxListBox" expanded="1"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="choices"></property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_lbPlugins</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass"></property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="validator_data_type"></property> + <property name="validator_style">wxFILTER_NONE</property> + <property name="validator_type">wxDefaultValidator</property> + <property name="validator_variable"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <event name="OnChar"></event> + <event name="OnEnterWindow"></event> + <event name="OnEraseBackground"></event> + <event name="OnKeyDown"></event> + <event name="OnKeyUp"></event> + <event name="OnKillFocus"></event> + <event name="OnLeaveWindow"></event> + <event name="OnLeftDClick"></event> + <event name="OnLeftDown"></event> + <event name="OnLeftUp"></event> + <event name="OnListBox">OnPluginSelected</event> + <event name="OnListBoxDClick"></event> + <event name="OnMiddleDClick"></event> + <event name="OnMiddleDown"></event> + <event name="OnMiddleUp"></event> + <event name="OnMotion"></event> + <event name="OnMouseEvents"></event> + <event name="OnMouseWheel"></event> + <event name="OnPaint"></event> + <event name="OnRightDClick"></event> + <event name="OnRightDown"></event> + <event name="OnRightUp"></event> + <event name="OnSetFocus"></event> + <event name="OnSize"></event> + <event name="OnUpdateUI"></event> + </object> + </object> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxRIGHT|wxLEFT</property> + <property name="proportion">0</property> + <object class="wxStaticText" expanded="1"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="label">Command line:</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_staticTextCmd</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass"></property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <property name="wrap">-1</property> + <event name="OnChar"></event> + <event name="OnEnterWindow"></event> + <event name="OnEraseBackground"></event> + <event name="OnKeyDown"></event> + <event name="OnKeyUp"></event> + <event name="OnKillFocus"></event> + <event name="OnLeaveWindow"></event> + <event name="OnLeftDClick"></event> + <event name="OnLeftDown"></event> + <event name="OnLeftUp"></event> + <event name="OnMiddleDClick"></event> + <event name="OnMiddleDown"></event> + <event name="OnMiddleUp"></event> + <event name="OnMotion"></event> + <event name="OnMouseEvents"></event> + <event name="OnMouseWheel"></event> + <event name="OnPaint"></event> + <event name="OnRightDClick"></event> + <event name="OnRightDown"></event> + <event name="OnRightUp"></event> + <event name="OnSetFocus"></event> + <event name="OnSize"></event> + <event name="OnUpdateUI"></event> + </object> + </object> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property> + <property name="proportion">0</property> + <object class="wxTextCtrl" expanded="1"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">ID_CMDLINE</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="maxlength">0</property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size">300,-1</property> + <property name="moveable">1</property> + <property name="name">m_textCtrlCommand</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass"></property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="validator_data_type"></property> + <property name="validator_style">wxFILTER_NONE</property> + <property name="validator_type">wxDefaultValidator</property> + <property name="validator_variable"></property> + <property name="value"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <event name="OnChar"></event> + <event name="OnEnterWindow"></event> + <event name="OnEraseBackground"></event> + <event name="OnKeyDown"></event> + <event name="OnKeyUp"></event> + <event name="OnKillFocus"></event> + <event name="OnLeaveWindow"></event> + <event name="OnLeftDClick"></event> + <event name="OnLeftDown"></event> + <event name="OnLeftUp"></event> + <event name="OnMiddleDClick"></event> + <event name="OnMiddleDown"></event> + <event name="OnMiddleUp"></event> + <event name="OnMotion"></event> + <event name="OnMouseEvents"></event> + <event name="OnMouseWheel"></event> + <event name="OnPaint"></event> + <event name="OnRightDClick"></event> + <event name="OnRightDown"></event> + <event name="OnRightUp"></event> + <event name="OnSetFocus"></event> + <event name="OnSize"></event> + <event name="OnText">OnCommandLineEdited</event> + <event name="OnTextEnter"></event> + <event name="OnTextMaxLen"></event> + <event name="OnTextURL"></event> + <event name="OnUpdateUI"></event> + </object> + </object> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxRIGHT|wxLEFT</property> + <property name="proportion">0</property> + <object class="wxStaticText" expanded="1"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="label">Name:</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_staticTextName</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass"></property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <property name="wrap">-1</property> + <event name="OnChar"></event> + <event name="OnEnterWindow"></event> + <event name="OnEraseBackground"></event> + <event name="OnKeyDown"></event> + <event name="OnKeyUp"></event> + <event name="OnKillFocus"></event> + <event name="OnLeaveWindow"></event> + <event name="OnLeftDClick"></event> + <event name="OnLeftDown"></event> + <event name="OnLeftUp"></event> + <event name="OnMiddleDClick"></event> + <event name="OnMiddleDown"></event> + <event name="OnMiddleUp"></event> + <event name="OnMotion"></event> + <event name="OnMouseEvents"></event> + <event name="OnMouseWheel"></event> + <event name="OnPaint"></event> + <event name="OnRightDClick"></event> + <event name="OnRightDown"></event> + <event name="OnRightUp"></event> + <event name="OnSetFocus"></event> + <event name="OnSize"></event> + <event name="OnUpdateUI"></event> + </object> + </object> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property> + <property name="proportion">0</property> + <object class="wxTextCtrl" expanded="1"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">IN_NAMELINE</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="maxlength">0</property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_textCtrlName</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass"></property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="validator_data_type"></property> + <property name="validator_style">wxFILTER_NONE</property> + <property name="validator_type">wxDefaultValidator</property> + <property name="validator_variable"></property> + <property name="value"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <event name="OnChar"></event> + <event name="OnEnterWindow"></event> + <event name="OnEraseBackground"></event> + <event name="OnKeyDown"></event> + <event name="OnKeyUp"></event> + <event name="OnKillFocus"></event> + <event name="OnLeaveWindow"></event> + <event name="OnLeftDClick"></event> + <event name="OnLeftDown"></event> + <event name="OnLeftUp"></event> + <event name="OnMiddleDClick"></event> + <event name="OnMiddleDown"></event> + <event name="OnMiddleUp"></event> + <event name="OnMotion"></event> + <event name="OnMouseEvents"></event> + <event name="OnMouseWheel"></event> + <event name="OnPaint"></event> + <event name="OnRightDClick"></event> + <event name="OnRightDown"></event> + <event name="OnRightUp"></event> + <event name="OnSetFocus"></event> + <event name="OnSize"></event> + <event name="OnText">OnNameEdited</event> + <event name="OnTextEnter"></event> + <event name="OnTextMaxLen"></event> + <event name="OnTextURL"></event> + <event name="OnUpdateUI"></event> + </object> + </object> + </object> + </object> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxALIGN_CENTER_VERTICAL</property> + <property name="proportion">0</property> + <object class="wxBoxSizer" expanded="1"> + <property name="minimum_size"></property> + <property name="name">bRightSizer</property> + <property name="orient">wxVERTICAL</property> + <property name="permission">none</property> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND</property> + <property name="proportion">0</property> + <object class="wxButton" expanded="1"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">ID_CREATE_BOM</property> + <property name="label">Generate</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_buttonNetlist</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass"></property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="validator_data_type"></property> + <property name="validator_style">wxFILTER_NONE</property> + <property name="validator_type">wxDefaultValidator</property> + <property name="validator_variable"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <event name="OnButtonClick">OnRunPlugin</event> + <event name="OnChar"></event> + <event name="OnEnterWindow"></event> + <event name="OnEraseBackground"></event> + <event name="OnKeyDown"></event> + <event name="OnKeyUp"></event> + <event name="OnKillFocus"></event> + <event name="OnLeaveWindow"></event> + <event name="OnLeftDClick"></event> + <event name="OnLeftDown"></event> + <event name="OnLeftUp"></event> + <event name="OnMiddleDClick"></event> + <event name="OnMiddleDown"></event> + <event name="OnMiddleUp"></event> + <event name="OnMotion"></event> + <event name="OnMouseEvents"></event> + <event name="OnMouseWheel"></event> + <event name="OnPaint"></event> + <event name="OnRightDClick"></event> + <event name="OnRightDown"></event> + <event name="OnRightUp"></event> + <event name="OnSetFocus"></event> + <event name="OnSize"></event> + <event name="OnUpdateUI"></event> + </object> + </object> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND</property> + <property name="proportion">0</property> + <object class="wxButton" expanded="1"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default">0</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_CANCEL</property> + <property name="label">Close</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_buttonCancel</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass"></property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="validator_data_type"></property> + <property name="validator_style">wxFILTER_NONE</property> + <property name="validator_type">wxDefaultValidator</property> + <property name="validator_variable"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <event name="OnButtonClick">OnCancelClick</event> + <event name="OnChar"></event> + <event name="OnEnterWindow"></event> + <event name="OnEraseBackground"></event> + <event name="OnKeyDown"></event> + <event name="OnKeyUp"></event> + <event name="OnKillFocus"></event> + <event name="OnLeaveWindow"></event> + <event name="OnLeftDClick"></event> + <event name="OnLeftDown"></event> + <event name="OnLeftUp"></event> + <event name="OnMiddleDClick"></event> + <event name="OnMiddleDown"></event> + <event name="OnMiddleUp"></event> + <event name="OnMotion"></event> + <event name="OnMouseEvents"></event> + <event name="OnMouseWheel"></event> + <event name="OnPaint"></event> + <event name="OnRightDClick"></event> + <event name="OnRightDown"></event> + <event name="OnRightUp"></event> + <event name="OnSetFocus"></event> + <event name="OnSize"></event> + <event name="OnUpdateUI"></event> + </object> + </object> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxALL|wxEXPAND</property> + <property name="proportion">0</property> + <object class="wxButton" expanded="1"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default">0</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">ID_HELP</property> + <property name="label">Help</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_buttonHelp</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass"></property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="validator_data_type"></property> + <property name="validator_style">wxFILTER_NONE</property> + <property name="validator_type">wxDefaultValidator</property> + <property name="validator_variable"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <event name="OnButtonClick">OnHelp</event> + <event name="OnChar"></event> + <event name="OnEnterWindow"></event> + <event name="OnEraseBackground"></event> + <event name="OnKeyDown"></event> + <event name="OnKeyUp"></event> + <event name="OnKillFocus"></event> + <event name="OnLeaveWindow"></event> + <event name="OnLeftDClick"></event> + <event name="OnLeftDown"></event> + <event name="OnLeftUp"></event> + <event name="OnMiddleDClick"></event> + <event name="OnMiddleDown"></event> + <event name="OnMiddleUp"></event> + <event name="OnMotion"></event> + <event name="OnMouseEvents"></event> + <event name="OnMouseWheel"></event> + <event name="OnPaint"></event> + <event name="OnRightDClick"></event> + <event name="OnRightDown"></event> + <event name="OnRightUp"></event> + <event name="OnSetFocus"></event> + <event name="OnSize"></event> + <event name="OnUpdateUI"></event> + </object> + </object> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxEXPAND | wxALL</property> + <property name="proportion">0</property> + <object class="wxStaticLine" expanded="1"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_staticline2</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style">wxLI_HORIZONTAL</property> + <property name="subclass"></property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <event name="OnChar"></event> + <event name="OnEnterWindow"></event> + <event name="OnEraseBackground"></event> + <event name="OnKeyDown"></event> + <event name="OnKeyUp"></event> + <event name="OnKillFocus"></event> + <event name="OnLeaveWindow"></event> + <event name="OnLeftDClick"></event> + <event name="OnLeftDown"></event> + <event name="OnLeftUp"></event> + <event name="OnMiddleDClick"></event> + <event name="OnMiddleDown"></event> + <event name="OnMiddleUp"></event> + <event name="OnMotion"></event> + <event name="OnMouseEvents"></event> + <event name="OnMouseWheel"></event> + <event name="OnPaint"></event> + <event name="OnRightDClick"></event> + <event name="OnRightDown"></event> + <event name="OnRightUp"></event> + <event name="OnSetFocus"></event> + <event name="OnSize"></event> + <event name="OnUpdateUI"></event> + </object> + </object> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND</property> + <property name="proportion">0</property> + <object class="wxButton" expanded="1"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default">0</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">ID_ADD_PLUGIN</property> + <property name="label">Add Plugin</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_buttonAddPlugin</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass"></property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="validator_data_type"></property> + <property name="validator_style">wxFILTER_NONE</property> + <property name="validator_type">wxDefaultValidator</property> + <property name="validator_variable"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <event name="OnButtonClick">OnAddPlugin</event> + <event name="OnChar"></event> + <event name="OnEnterWindow"></event> + <event name="OnEraseBackground"></event> + <event name="OnKeyDown"></event> + <event name="OnKeyUp"></event> + <event name="OnKillFocus"></event> + <event name="OnLeaveWindow"></event> + <event name="OnLeftDClick"></event> + <event name="OnLeftDown"></event> + <event name="OnLeftUp"></event> + <event name="OnMiddleDClick"></event> + <event name="OnMiddleDown"></event> + <event name="OnMiddleUp"></event> + <event name="OnMotion"></event> + <event name="OnMouseEvents"></event> + <event name="OnMouseWheel"></event> + <event name="OnPaint"></event> + <event name="OnRightDClick"></event> + <event name="OnRightDown"></event> + <event name="OnRightUp"></event> + <event name="OnSetFocus"></event> + <event name="OnSize"></event> + <event name="OnUpdateUI"></event> + </object> + </object> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxALL|wxEXPAND</property> + <property name="proportion">0</property> + <object class="wxButton" expanded="1"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default">0</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_BROWSE_PLUGINS</property> + <property name="label">Set Plugin</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_buttonBrowsePlugin</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass"></property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="validator_data_type"></property> + <property name="validator_style">wxFILTER_NONE</property> + <property name="validator_type">wxDefaultValidator</property> + <property name="validator_variable"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <event name="OnButtonClick">OnChoosePlugin</event> + <event name="OnChar"></event> + <event name="OnEnterWindow"></event> + <event name="OnEraseBackground"></event> + <event name="OnKeyDown"></event> + <event name="OnKeyUp"></event> + <event name="OnKillFocus"></event> + <event name="OnLeaveWindow"></event> + <event name="OnLeftDClick"></event> + <event name="OnLeftDown"></event> + <event name="OnLeftUp"></event> + <event name="OnMiddleDClick"></event> + <event name="OnMiddleDown"></event> + <event name="OnMiddleUp"></event> + <event name="OnMotion"></event> + <event name="OnMouseEvents"></event> + <event name="OnMouseWheel"></event> + <event name="OnPaint"></event> + <event name="OnRightDClick"></event> + <event name="OnRightDown"></event> + <event name="OnRightUp"></event> + <event name="OnSetFocus"></event> + <event name="OnSize"></event> + <event name="OnUpdateUI"></event> + </object> + </object> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND</property> + <property name="proportion">0</property> + <object class="wxButton" expanded="1"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default">0</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">ID_REMOVEL_PLUGIN</property> + <property name="label">Remove Plugin</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_buttonDelPlugin</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass"></property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="validator_data_type"></property> + <property name="validator_style">wxFILTER_NONE</property> + <property name="validator_type">wxDefaultValidator</property> + <property name="validator_variable"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <event name="OnButtonClick">OnRemovePlugin</event> + <event name="OnChar"></event> + <event name="OnEnterWindow"></event> + <event name="OnEraseBackground"></event> + <event name="OnKeyDown"></event> + <event name="OnKeyUp"></event> + <event name="OnKillFocus"></event> + <event name="OnLeaveWindow"></event> + <event name="OnLeftDClick"></event> + <event name="OnLeftDown"></event> + <event name="OnLeftUp"></event> + <event name="OnMiddleDClick"></event> + <event name="OnMiddleDown"></event> + <event name="OnMiddleUp"></event> + <event name="OnMotion"></event> + <event name="OnMouseEvents"></event> + <event name="OnMouseWheel"></event> + <event name="OnPaint"></event> + <event name="OnRightDClick"></event> + <event name="OnRightDown"></event> + <event name="OnRightUp"></event> + <event name="OnSetFocus"></event> + <event name="OnSize"></event> + <event name="OnUpdateUI"></event> + </object> + </object> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxALL|wxEXPAND</property> + <property name="proportion">0</property> + <object class="wxButton" expanded="1"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default">0</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="label">Edit Plugin</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_buttonEdit</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass"></property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="validator_data_type"></property> + <property name="validator_style">wxFILTER_NONE</property> + <property name="validator_type">wxDefaultValidator</property> + <property name="validator_variable"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <event name="OnButtonClick">OnEditPlugin</event> + <event name="OnChar"></event> + <event name="OnEnterWindow"></event> + <event name="OnEraseBackground"></event> + <event name="OnKeyDown"></event> + <event name="OnKeyUp"></event> + <event name="OnKillFocus"></event> + <event name="OnLeaveWindow"></event> + <event name="OnLeftDClick"></event> + <event name="OnLeftDown"></event> + <event name="OnLeftUp"></event> + <event name="OnMiddleDClick"></event> + <event name="OnMiddleDown"></event> + <event name="OnMiddleUp"></event> + <event name="OnMotion"></event> + <event name="OnMouseEvents"></event> + <event name="OnMouseWheel"></event> + <event name="OnPaint"></event> + <event name="OnRightDClick"></event> + <event name="OnRightDown"></event> + <event name="OnRightUp"></event> + <event name="OnSetFocus"></event> + <event name="OnSize"></event> + <event name="OnUpdateUI"></event> + </object> + </object> + </object> + </object> + </object> + </object> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxRIGHT|wxLEFT</property> + <property name="proportion">0</property> + <object class="wxStaticText" expanded="1"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="label">Output filename:</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_staticTextDefaultFN</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass"></property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <property name="wrap">-1</property> + <event name="OnChar"></event> + <event name="OnEnterWindow"></event> + <event name="OnEraseBackground"></event> + <event name="OnKeyDown"></event> + <event name="OnKeyUp"></event> + <event name="OnKillFocus"></event> + <event name="OnLeaveWindow"></event> + <event name="OnLeftDClick"></event> + <event name="OnLeftDown"></event> + <event name="OnLeftUp"></event> + <event name="OnMiddleDClick"></event> + <event name="OnMiddleDown"></event> + <event name="OnMiddleUp"></event> + <event name="OnMotion"></event> + <event name="OnMouseEvents"></event> + <event name="OnMouseWheel"></event> + <event name="OnPaint"></event> + <event name="OnRightDClick"></event> + <event name="OnRightDown"></event> + <event name="OnRightUp"></event> + <event name="OnSetFocus"></event> + <event name="OnSize"></event> + <event name="OnUpdateUI"></event> + </object> + </object> + <object class="sizeritem" expanded="1"> + <property name="border">5</property> + <property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property> + <property name="proportion">0</property> + <object class="wxTextCtrl" expanded="1"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">ID_FN</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="maxlength">0</property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_textCtrlDefaultFileName</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style">wxTE_READONLY</property> + <property name="subclass"></property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="validator_data_type"></property> + <property name="validator_style">wxFILTER_NONE</property> + <property name="validator_type">wxDefaultValidator</property> + <property name="validator_variable"></property> + <property name="value"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <event name="OnChar"></event> + <event name="OnEnterWindow"></event> + <event name="OnEraseBackground"></event> + <event name="OnKeyDown"></event> + <event name="OnKeyUp"></event> + <event name="OnKillFocus"></event> + <event name="OnLeaveWindow"></event> + <event name="OnLeftDClick"></event> + <event name="OnLeftDown"></event> + <event name="OnLeftUp"></event> + <event name="OnMiddleDClick"></event> + <event name="OnMiddleDown"></event> + <event name="OnMiddleUp"></event> + <event name="OnMotion"></event> + <event name="OnMouseEvents"></event> + <event name="OnMouseWheel"></event> + <event name="OnPaint"></event> + <event name="OnRightDClick"></event> + <event name="OnRightDown"></event> + <event name="OnRightUp"></event> + <event name="OnSetFocus"></event> + <event name="OnSize"></event> + <event name="OnText"></event> + <event name="OnTextEnter"></event> + <event name="OnTextMaxLen"></event> + <event name="OnTextURL"></event> + <event name="OnUpdateUI"></event> + </object> + </object> + </object> + </object> + </object> +</wxFormBuilder_Project> diff --git a/eeschema/dialogs/dialog_bom_base.h b/eeschema/dialogs/dialog_bom_base.h new file mode 100644 index 0000000000..ffd95a27c9 --- /dev/null +++ b/eeschema/dialogs/dialog_bom_base.h @@ -0,0 +1,103 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 8 2012) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __DIALOG_BOM_BASE_H__ +#define __DIALOG_BOM_BASE_H__ + +#include <wx/artprov.h> +#include <wx/xrc/xmlres.h> +#include <wx/intl.h> +class DIALOG_SHIM; + +#include "dialog_shim.h" +#include <wx/string.h> +#include <wx/stattext.h> +#include <wx/gdicmn.h> +#include <wx/font.h> +#include <wx/colour.h> +#include <wx/settings.h> +#include <wx/listbox.h> +#include <wx/textctrl.h> +#include <wx/sizer.h> +#include <wx/button.h> +#include <wx/statline.h> +#include <wx/dialog.h> + +/////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_BOM_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_BOM_BASE : public DIALOG_SHIM +{ + DECLARE_EVENT_TABLE() + private: + + // Private event handlers + void _wxFB_OnPluginSelected( wxCommandEvent& event ){ OnPluginSelected( event ); } + void _wxFB_OnCommandLineEdited( wxCommandEvent& event ){ OnCommandLineEdited( event ); } + void _wxFB_OnNameEdited( wxCommandEvent& event ){ OnNameEdited( event ); } + void _wxFB_OnRunPlugin( wxCommandEvent& event ){ OnRunPlugin( event ); } + void _wxFB_OnCancelClick( wxCommandEvent& event ){ OnCancelClick( event ); } + void _wxFB_OnHelp( wxCommandEvent& event ){ OnHelp( event ); } + void _wxFB_OnAddPlugin( wxCommandEvent& event ){ OnAddPlugin( event ); } + void _wxFB_OnChoosePlugin( wxCommandEvent& event ){ OnChoosePlugin( event ); } + void _wxFB_OnRemovePlugin( wxCommandEvent& event ){ OnRemovePlugin( event ); } + void _wxFB_OnEditPlugin( wxCommandEvent& event ){ OnEditPlugin( event ); } + + + protected: + enum + { + ID_CMDLINE = 1000, + IN_NAMELINE, + ID_CREATE_BOM, + ID_HELP, + ID_ADD_PLUGIN, + wxID_BROWSE_PLUGINS, + ID_REMOVEL_PLUGIN, + ID_FN + }; + + wxStaticText* m_staticTextPluginTitle; + wxListBox* m_lbPlugins; + wxStaticText* m_staticTextCmd; + wxTextCtrl* m_textCtrlCommand; + wxStaticText* m_staticTextName; + wxTextCtrl* m_textCtrlName; + wxButton* m_buttonNetlist; + wxButton* m_buttonCancel; + wxButton* m_buttonHelp; + wxStaticLine* m_staticline2; + wxButton* m_buttonAddPlugin; + wxButton* m_buttonBrowsePlugin; + wxButton* m_buttonDelPlugin; + wxButton* m_buttonEdit; + wxStaticText* m_staticTextDefaultFN; + wxTextCtrl* m_textCtrlDefaultFileName; + + // Virtual event handlers, overide them in your derived class + virtual void OnPluginSelected( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCommandLineEdited( wxCommandEvent& event ) { event.Skip(); } + virtual void OnNameEdited( wxCommandEvent& event ) { event.Skip(); } + virtual void OnRunPlugin( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnHelp( wxCommandEvent& event ) { event.Skip(); } + virtual void OnAddPlugin( wxCommandEvent& event ) { event.Skip(); } + virtual void OnChoosePlugin( wxCommandEvent& event ) { event.Skip(); } + virtual void OnRemovePlugin( wxCommandEvent& event ) { event.Skip(); } + virtual void OnEditPlugin( wxCommandEvent& event ) { event.Skip(); } + + + public: + + DIALOG_BOM_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Bill of Material"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 404,334 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_BOM_BASE(); + +}; + +#endif //__DIALOG_BOM_BASE_H__ diff --git a/eeschema/dialogs/dialog_bom_cfg.keywords b/eeschema/dialogs/dialog_bom_cfg.keywords new file mode 100644 index 0000000000..8790280ce4 --- /dev/null +++ b/eeschema/dialogs/dialog_bom_cfg.keywords @@ -0,0 +1,4 @@ +plugins +plugin +cmd +opts diff --git a/eeschema/dialogs/dialog_bom_help.html b/eeschema/dialogs/dialog_bom_help.html new file mode 100644 index 0000000000..4ba5c5bac1 --- /dev/null +++ b/eeschema/dialogs/dialog_bom_help.html @@ -0,0 +1,210 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252"> + <TITLE>kicad help + + + + + + +

+1 - Full +documentation:

+

+The +Eeschema +documentation, chapter 14 +describes this intermediate netlist and gives examples
See also +
https://answers.launchpad.net/kicad/+faq/2265

+

+2 - The +intermediate Netlist File

+

+BOM files (and +netlist files) can be created from an Intermediate netlist file +created by Eeschema.

+

+This file uses XML +syntax and is called the intermediate netlist. The intermediate +netlist includes a large amount of data about your board and because +of this, it can be used with post-processing to create a BOM or other +reports.

+

+Depending on the +output (BOM or netlist), different subsets of the complete +Intermediate Netlist file will be used in the post-processing.

+

+3 - Conversion to +a new format

+

+By applying a +post-processing filter to the Intermediate netlist file you can +generate foreign netlist files as well as BOM files. Because this +conversion is a text to text transformation.

+

+this post-processing +filter can be written using Python, XSLT, or any other tool capable +of taking XML as input.

+

+XSLT +itself is a XML language very suitable for XML transformations. There +is a free program called xsltproc +that +you can download and install. The +xsltproc +program can be used to read the Intermediate XML netlist input file, +apply a +style-sheet to transform the input, and save the results in an output +file. Use of xsltproc requires a style-sheet file using XSLT +conventions. The full conversion process is handled +by +Eeschema, after it is configured once to run xsltproc in a specific +way.

+

+4 - +Initialization of the dialog window

+

+You should add a new +pluging (a script) in plugin list by clicking on the Add Plugin +button.

+

+4.1 - Plugin +Configuration Parameters

+

+The Eeschema plug-in +configuration dialog requires the following information:

+
    +
  • + The title: for + instance, the name of the netlist format.

    +
  • + The command line to + launch the converter (usually a script).

    +
+

+Once you click on +the generate button the following will happen:

+
    +
  1. + Eeschema creates an + intermediate netlist file *.xml, for instance test.xml.

    +
  2. + Eeschema runs the + script from the command line to create the final output file.

    +
+

+4.2 - Generate +netlist files with the command line

+

+Assuming we are +using the program xsltproc.exe +to +apply the sheet style to the intermediate file, xsltproc.exe +is +executed with the following command.

+

+xsltproc.exe -o < +output filename > < style-sheet filename > < input XML +file to convert >

+

+On +Windows the command line is the +following.
f:/kicad/bin/xsltproc.exe +-o “%O” f:/kicad/bin/plugins/myconverter.xsl “%I”

+

+On +Linux the command becomes as +following.
xsltproc +-o “%O” /usr/local/kicad/bin/plugins/myconverter .xsl +“%I”

+

+Where +myconverter.xsl +is +the style-sheet that you are applying. Do not forget the double +quotes +around +the file names, this allows them to have spaces after the +substitution by Eeschema.

+

+The command line +format accepts parameters for filenames:

+

+The supported +formatting parameters are.

+
    +
  • + %B => base + filename and path of selected output file, minus path and extension.

    +
  • + %I => complete + filename and path of the temporary input file (the intermediate net + file).

    +
  • + %O => complete + filename and path of the user chosen output file.

    +
+

+%I will be replaced +by the actual intermediate file name
%O +will be replaced by the actual output file name.

+

+4.3 - Command +line format: example for xsltproc

+

+The +command line format for xsltproc is the following:
< path of +
xsltproc > xsltproc +< xsltproc parameters >

+

+On +Windows:
f:/kicad/bin/xsltproc.exe -o “%O” +f:/kicad/bin/plugins/netlist_form_pads-pcb.xsl “%I”

+

+On +Linux:
xsltproc +-o “%O” +/usr/local/kicad/bin/plugins/netlist_form_pads-pcb.xsl “%I”

+

+The +above examples assume +xsltproc +is installed on your PC under Windows and all files located in +kicad/bin.

+

+4.4 - Command +line format: example for +python scripts

+

+The command line +format for python is something like:
python +< +script file name > < input filename > < +output filename >

+

+On +Windows:
python.exe f:/kicad/python/my_python_script.py +“%I” “%O”

+

+On Linux:
python +/usr/local/kicad/python/my_python_script.py%I” +“%O”

+

+Assuming python is +installed on your PC.

+

+
+

+ + \ No newline at end of file diff --git a/eeschema/invoke_sch_dialog.h b/eeschema/invoke_sch_dialog.h index a8ccbff50a..a1f6ffcc95 100644 --- a/eeschema/invoke_sch_dialog.h +++ b/eeschema/invoke_sch_dialog.h @@ -37,8 +37,8 @@ // DIALOG_.cpp file. -#ifndef INVOKE_A_DIALOG_H_ -#define INVOKE_A_DIALOG_H_ +#ifndef INVOKE_SCH_DIALOG_H_ +#define INVOKE_SCH_DIALOG_H_ class wxFrame; @@ -61,6 +61,9 @@ wxDialog* InvokeDialogERC( SCH_EDIT_FRAME* aCaller ); /// DIALOG_PRINT_USING_PRINTER::ShowModal() returns. int InvokeDialogPrintUsingPrinter( SCH_EDIT_FRAME* aCaller ); +/// Create and show DIALOG_BOM and return whatever +/// DIALOG_BOM::ShowModal() returns. +int InvokeDialogCreateBOM( SCH_EDIT_FRAME* aCaller ); -#endif // INVOKE_A_DIALOG_H_ +#endif // INVOKE_SCH_DIALOG_H_ diff --git a/eeschema/netlist.h b/eeschema/netlist.h index 55189e5df4..2a3c439366 100644 --- a/eeschema/netlist.h +++ b/eeschema/netlist.h @@ -374,26 +374,6 @@ public: sort( componentFlatList.begin(), componentFlatList.end(), sortByRefAndValue ); } - /** - * Function SortByValueAndRef - * sorts the list of references by value. - *

- * Components are sorted in the following order: - *

    - *
  • Value of component.
  • - *
  • Numeric value of reference designator.
  • - *
  • Unit number when component has multiple parts.
  • - *
  • Sheet number.
  • - *
  • X coordinate position.
  • - *
  • Y coordinate position.
  • - *
- *

- */ - void SortByValueAndRef() - { - sort( componentFlatList.begin(), componentFlatList.end(), sortByValueAndRef ); - } - /** * Function SortByReferenceOnly * sorts the list of references by reference. @@ -410,25 +390,6 @@ public: sort( componentFlatList.begin(), componentFlatList.end(), sortByReferenceOnly ); } - /** - * Function SortByValueOnly - * sort the list of references by value. - *

- * Components are grouped by type and are sorted in the following order: - *

    - *
  • Value of component.
  • - *
  • Numeric value of reference designator.
  • - *
  • Unit number when component has multiple parts.
  • - *
- *

- * groups are made by the first letter of reference - * or the 2 first letters when existing - */ - void SortByValueOnly() - { - sort( componentFlatList.begin(), componentFlatList.end(), sortByValueOnly ); - } - /** * Function GetUnit * searches the sorted list of components for a another component with the same @@ -474,16 +435,12 @@ private: static bool sortByRefAndValue( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 ); - static bool sortByValueAndRef( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 ); - static bool sortByXPosition( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 ); static bool sortByYPosition( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 ); static bool sortByTimeStamp( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 ); - static bool sortByValueOnly( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 ); - static bool sortByReferenceOnly( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 ); /** diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 289f83e2ea..49fa8390e5 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -632,10 +632,7 @@ void SCH_EDIT_FRAME::OnCreateNetlist( wxCommandEvent& event ) void SCH_EDIT_FRAME::OnCreateBillOfMaterials( wxCommandEvent& ) { - wxMessageDialog dlg( this, - wxT( "https://answers.launchpad.net/kicad/+faq/2265" ), - _( "BOM Howto" ) ); - dlg.ShowModal(); + InvokeDialogCreateBOM( this ); } diff --git a/scripts/bom-in-python/README-bom.txt b/scripts/bom-in-python/README-bom.txt new file mode 100644 index 0000000000..e5be840892 --- /dev/null +++ b/scripts/bom-in-python/README-bom.txt @@ -0,0 +1,14 @@ +bom_?.py are some python scripts which read a generic xml netlist from eeschema, +and create a bom. + +All examples use ky_generic_netlist_reader.py, which is a python utility to read +and parse this generic xml netlist and create the corresponding data +used to build the bom. + +You can modify them to build the bom you want. + +to use them, you should install python, and run: +python bom_example?.py + +See Eeschema doc, chapter 14 for info about the generic xml netlist format, +and how to run a script from Eeschema to create a customized netlist or BOM. diff --git a/scripts/bom-in-python/ky/bom_example5.py b/scripts/bom-in-python/bom-generation.py similarity index 89% rename from scripts/bom-in-python/ky/bom_example5.py rename to scripts/bom-in-python/bom-generation.py index 7f6cd3be69..8746575348 100644 --- a/scripts/bom-in-python/ky/bom_example5.py +++ b/scripts/bom-in-python/bom-generation.py @@ -5,7 +5,7 @@ # # Import the KiCad python helper module and the csv formatter -import ky +import ky_generic_netlist_reader import sys # Start with a basic html template @@ -30,13 +30,13 @@ html = """ """ def myEqu(self, other): - """myEqu is a more advanced equivalence function for components which is + """myEqu is a more advanced equivalence function for components which is used by component grouping. Normal operation is to group components based on their Value, Library source, and Library part. - - In this example of a more advanced equivalency operator we also compare the + + In this example of a more advanced equivalency operator we also compare the custom fields Voltage, Tolerance and Manufacturer as well as the assigned - footprint. If these fields are not used in some parts they will simply be + footprint. If these fields are not used in some parts they will simply be ignored (they will match as both will be empty strings). """ @@ -54,18 +54,18 @@ def myEqu(self, other): elif self.getField("Manufacturer") != other.getField("Manufacturer"): result = False elif self.getField("Voltage") != other.getField("Voltage"): - result = False - + result = False + return result # Override the component equivalence operator - it is important to do this # before loading the netlist, otherwise all components will have the original # equivalency operator. -ky.component.__equ__ = myEqu - +ky_generic_netlist_reader.component.__equ__ = myEqu + # Generate an instance of a generic netlist, and load the netlist tree from # video.tmp. If the file doesn't exist, execution will stop -net = ky.netlist(sys.argv[1]) +net = ky_generic_netlist_reader.netlist(sys.argv[1]) # Open a file to write too, if the file cannot be opened output to stdout # instead @@ -82,31 +82,33 @@ html = html.replace('', net.getTool()) html = html.replace('', "Component Count:" + \ str(len(net.components))) -row = "Ref" + "Qnty" +row = "Ref" + "Qnty" row += "Value" + "Part" + "Datasheet" row += "Description" + "Vendor" - + html = html.replace('', row + "") -# Get all of the components in groups of matching parts + values (see ky.py) +# Get all of the components in groups of matching parts + values +# (see ky_generic_netlist_reader.py) grouped = net.groupComponents() # Output all of the component information for group in grouped: refs = "" - # Add the reference of every component in the group and keep a reference + # Add the reference of every component in the group and keep a reference # to the component so that the other data can be filled in once per group for component in group: refs += component.getRef() + ", " c = component - row = "" + refs +"" + str(len(group)) - row += "" + c.getValue() + "" + c.getLib() + "/" - row += c.getPart() + "" + c.getDatasheet() + "" - row += c.getDescription() + "" + c.getField("Vendor") + row = "\n " + row += "" + refs +"" + str(len(group)) + row += "" + c.getValue() + "" + c.getLib() + "/" + row += c.getPart() + "" + c.getDatasheet() + "" + row += c.getDescription() + "" + c.getField("Vendor") row += "" - + html = html.replace('', row + "") # Print the formatted html to output file diff --git a/scripts/bom-in-python/ky/bom_example1.py b/scripts/bom-in-python/bom_csv_by_ref.py similarity index 82% rename from scripts/bom-in-python/ky/bom_example1.py rename to scripts/bom-in-python/bom_csv_by_ref.py index 354c6b5686..ccc874fd16 100644 --- a/scripts/bom-in-python/ky/bom_example1.py +++ b/scripts/bom-in-python/bom_csv_by_ref.py @@ -5,13 +5,13 @@ # # Import the KiCad python helper module and the csv formatter -import ky +import ky_generic_netlist_reader import csv import sys # Generate an instance of a generic netlist, and load the netlist tree from # the command line option. If the file doesn't exist, execution will stop -net = ky.netlist(sys.argv[1]) +net = ky_generic_netlist_reader.netlist(sys.argv[1]) # Open a file to write to, if the file cannot be opened output to stdout # instead @@ -23,16 +23,16 @@ except IOError: # Create a new csv writer object to use as the output formatter, although we # are created a tab delimited list instead! -out = csv.writer(f, delimiter='\t', quoting=csv.QUOTE_NONE) +out = csv.writer(f, lineterminator='\n', delimiter='\t', quoting=csv.QUOTE_NONE) # Output a field delimited header line out.writerow(['Source:', net.getSource()]) out.writerow(['Date:', net.getDate()]) out.writerow(['Tool:', net.getTool()]) -out.writerow(['Component Count:', len(net.components)]) +out.writerow(['Component Count:', len(net.components)]) out.writerow(['Ref', 'Value', 'Part', 'Documentation', 'Description', 'Vendor']) # Output all of the component information for c in net.components: - out.writerow([c.getRef(), c.getValue(), c.getLib() + "/" + c.getPart(), + out.writerow([c.getRef(), c.getValue(), c.getLib() + "/" + c.getPart(), c.getDatasheet(), c.getDescription(), c.getField("Vendor")]) diff --git a/scripts/bom-in-python/ky/bom_example2.py b/scripts/bom-in-python/bom_csv_by_ref_v2.py similarity index 81% rename from scripts/bom-in-python/ky/bom_example2.py rename to scripts/bom-in-python/bom_csv_by_ref_v2.py index 58b1c05453..38e6f0c75f 100644 --- a/scripts/bom-in-python/ky/bom_example2.py +++ b/scripts/bom-in-python/bom_csv_by_ref_v2.py @@ -5,16 +5,16 @@ # # Import the KiCad python helper module -import ky +import ky_generic_netlist_reader import csv import sys - + # Generate an instance of a generic netlist, and load the netlist tree from # the command line option. If the file doesn't exist, execution will stop -net = ky.netlist(sys.argv[1]) +net = ky_generic_netlist_reader.netlist(sys.argv[1]) # Open a file to write to, if the file cannot be opened output to stdout -# instead +# instead try: f = open(sys.argv[2], 'w') except IOError: @@ -22,13 +22,13 @@ except IOError: f = stdout # Create a new csv writer object to use as the output formatter -out = csv.writer(f, delimiter=',', quotechar="\"", quoting=csv.QUOTE_ALL) +out = csv.writer(f, lineterminator='\n', delimiter=',', quotechar="\"", quoting=csv.QUOTE_ALL) # Output a field delimited header line out.writerow(['Source:', net.getSource()]) out.writerow(['Date:', net.getDate()]) out.writerow(['Tool:', net.getTool()]) -out.writerow(['Component Count:', len(net.components)]) +out.writerow(['Component Count:', len(net.components)]) out.writerow(['Ref', 'Value', 'Footprint', 'Datasheet', 'Manufacturer', 'Vendor']) # Output all of the component information (One component per row) diff --git a/scripts/bom-in-python/ky/bom_example3.py b/scripts/bom-in-python/bom_csv_grouped_by_value.py similarity index 83% rename from scripts/bom-in-python/ky/bom_example3.py rename to scripts/bom-in-python/bom_csv_grouped_by_value.py index dcbbf15b32..81d3acecf6 100644 --- a/scripts/bom-in-python/ky/bom_example3.py +++ b/scripts/bom-in-python/bom_csv_grouped_by_value.py @@ -5,13 +5,13 @@ # # Import the KiCad python helper module and the csv formatter -import ky +import ky_generic_netlist_reader import csv import sys # Generate an instance of a generic netlist, and load the netlist tree from # the command line option. If the file doesn't exist, execution will stop -net = ky.netlist(sys.argv[1]) +net = ky_generic_netlist_reader.netlist(sys.argv[1]) # Open a file to write to, if the file cannot be opened output to stdout # instead @@ -22,23 +22,24 @@ except IOError: f = stdout # Create a new csv writer object to use as the output formatter -out = csv.writer(f, delimiter=',', quotechar='\"', quoting=csv.QUOTE_ALL) +out = csv.writer(f, lineterminator='\n', delimiter=',', quotechar='\"', quoting=csv.QUOTE_ALL) # Output a set of rows for a header providing general information out.writerow(['Source:', net.getSource()]) out.writerow(['Date:', net.getDate()]) out.writerow(['Tool:', net.getTool()]) -out.writerow(['Component Count:', len(net.components)]) +out.writerow(['Component Count:', len(net.components)]) out.writerow(['Ref', 'Qnty', 'Value', 'Part', 'Datasheet', 'Description', 'Vendor']) -# Get all of the components in groups of matching parts + values (see ky.py) +# Get all of the components in groups of matching parts + values +# (see ky_generic_netlist_reader.py) grouped = net.groupComponents() # Output all of the component information for group in grouped: refs = "" - # Add the reference of every component in the group and keep a reference + # Add the reference of every component in the group and keep a reference # to the component so that the other data can be filled in once per group for component in group: refs += component.getRef() + ", " diff --git a/scripts/bom-in-python/bom_html_by_value.py b/scripts/bom-in-python/bom_html_by_value.py new file mode 100644 index 0000000000..4c7fa5f2a5 --- /dev/null +++ b/scripts/bom-in-python/bom_html_by_value.py @@ -0,0 +1,119 @@ +# +# Example python script to generate a BOM from a KiCad generic netlist +# +# Example: Sorted and Grouped HTML BOM with more advanced grouping +# + +# Import the KiCad python helper module and the csv formatter +import ky_generic_netlist_reader +import sys + +# Start with a basic html template +html = """ + + + + + KiCad BOM Example 5 + + +

+

+

+

+ + +
+ + + """ + +def myEqu(self, other): + """myEqu is a more advanced equivalence function for components which is + used by component grouping. Normal operation is to group components based + on their Value, Library source, and Library part. + + In this example of a more advanced equivalency operator we also compare the + custom fields Voltage, Tolerance and Manufacturer as well as the assigned + footprint. If these fields are not used in some parts they will simply be + ignored (they will match as both will be empty strings). + + """ + result = True + if self.getValue() != other.getValue(): + result = False + elif self.getLib() != other.getLib(): + result = False + elif self.getPart() != other.getPart(): + result = False + elif self.getFootprint() != other.getFootprint(): + result = False + elif self.getField("Tolerance") != other.getField("Tolerance"): + result = False + elif self.getField("Manufacturer") != other.getField("Manufacturer"): + result = False + elif self.getField("Voltage") != other.getField("Voltage"): + result = False + + return result + +# Override the component equivalence operator - it is important to do this +# before loading the netlist, otherwise all components will have the original +# equivalency operator. +ky_generic_netlist_reader.component.__equ__ = myEqu + +# Generate an instance of a generic netlist, and load the netlist tree from +# video.xml. If the file doesn't exist, execution will stop +net = ky_generic_netlist_reader.netlist(sys.argv[1]) + +# Open a file to write too, if the file cannot be opened output to stdout +# instead +try: + f = open(sys.argv[2], 'w') +except IOError: + print >> sys.stderr, __file__, ":", e + f = stdout + +# Output a set of rows for a header providing general information +html = html.replace('', net.getSource()) +html = html.replace('', net.getDate()) +html = html.replace('', net.getTool()) +html = html.replace('', "Component Count:" + \ + str(len(net.components))) + +row = "Ref" + "Qnty" +row += "Value" + "Part" +row += "Description" +#row += "Datasheet" +row += "PartNumber" + "Vendor" + +html = html.replace('', row + "") + +# Get all of the components in groups of matching parts + values +# (see ky_generic_netlist_reader.py) +grouped = net.groupComponents() + +# Output all of the component information +for group in grouped: + refs = "" + + # Add the reference of every component in the group and keep a reference + # to the component so that the other data can be filled in once per group + for component in group: + refs += component.getRef() + ", " + c = component + + row = "" + refs +"" + str(len(group)) + row += "" + c.getValue() + "" + row += c.getLib() + "/" + c.getPart() + "" + #row += c.getDatasheet() + "" + row += c.getDescription() + "" + row += c.getField("PartNumber") + "" + row += c.getField("Vendor") + row += "" + + html = html.replace('', row + "") + +# Print the formatted html to output file +print >> f, html diff --git a/scripts/bom-in-python/ky/bom_example4.py b/scripts/bom-in-python/bom_html_grouped_by_value.py similarity index 89% rename from scripts/bom-in-python/ky/bom_example4.py rename to scripts/bom-in-python/bom_html_grouped_by_value.py index 201c041e39..d1cb8912f7 100644 --- a/scripts/bom-in-python/ky/bom_example4.py +++ b/scripts/bom-in-python/bom_html_grouped_by_value.py @@ -5,7 +5,7 @@ # # Import the KiCad python helper module and the csv formatter -import ky +import ky_generic_netlist_reader import sys # Start with a basic html template @@ -27,10 +27,10 @@ html = """ """ - + # Generate an instance of a generic netlist, and load the netlist tree from # the command line option. If the file doesn't exist, execution will stop -net = ky.netlist(sys.argv[1]) +net = ky_generic_netlist_reader.netlist(sys.argv[1]) # Open a file to write to, if the file cannot be opened output to stdout # instead @@ -47,31 +47,32 @@ html = html.replace('', net.getTool()) html = html.replace('', "Component Count:" + \ str(len(net.components))) -row = "Ref" + "Qnty" +row = "Ref" + "Qnty" row += "Value" + "Part" + "Datasheet" row += "Description" + "Vendor" - + html = html.replace('', row + "") -# Get all of the components in groups of matching parts + values (see ky.py) +# Get all of the components in groups of matching parts + values +# (see ky_generic_netlist_reader.py) grouped = net.groupComponents() # Output all of the component information for group in grouped: refs = "" - # Add the reference of every component in the group and keep a reference + # Add the reference of every component in the group and keep a reference # to the component so that the other data can be filled in once per group for component in group: refs += component.getRef() + ", " c = component - row = "" + refs +"" + str(len(group)) - row += "" + c.getValue() + "" + c.getLib() + "/" - row += c.getPart() + "" + c.getDatasheet() + "" - row += c.getDescription() + "" + c.getField("Vendor") + row = "" + refs +"" + str(len(group)) + row += "" + c.getValue() + "" + c.getLib() + "/" + row += c.getPart() + "" + c.getDatasheet() + "" + row += c.getDescription() + "" + c.getField("Vendor") row += "" - + html = html.replace('', row + "") # Print the formatted html to the file diff --git a/scripts/bom-in-python/ky/ky.py b/scripts/bom-in-python/ky_generic_netlist_reader.py similarity index 100% rename from scripts/bom-in-python/ky/ky.py rename to scripts/bom-in-python/ky_generic_netlist_reader.py diff --git a/scripts/bom-in-python/ky/round_robin.py b/scripts/bom-in-python/round_robin.py similarity index 87% rename from scripts/bom-in-python/ky/round_robin.py rename to scripts/bom-in-python/round_robin.py index 870797a1a5..6aff7ef1a9 100644 --- a/scripts/bom-in-python/ky/round_robin.py +++ b/scripts/bom-in-python/round_robin.py @@ -5,12 +5,12 @@ # # Import the KiCad python helper module and the csv formatter -import ky +import ky_generic_netlist_reader import sys # Generate an instance of a generic netlist, and load the netlist tree from # the command line option. If the file doesn't exist, execution will stop -net = ky.netlist(sys.argv[1]) +net = ky_generic_netlist_reader.netlist(sys.argv[1]) # Open a file to write to, if the file cannot be opened output to stdout # instead diff --git a/scripts/bom-in-python/ky/round_value_robin.py b/scripts/bom-in-python/round_value_robin.py similarity index 88% rename from scripts/bom-in-python/ky/round_value_robin.py rename to scripts/bom-in-python/round_value_robin.py index 725f1d64b6..c7834420a7 100644 --- a/scripts/bom-in-python/ky/round_value_robin.py +++ b/scripts/bom-in-python/round_value_robin.py @@ -5,7 +5,7 @@ # # Import the KiCad python helper module and the csv formatter -import ky +import ky_generic_netlist_reader import sys def checkvalue(self): @@ -21,7 +21,7 @@ def checkvalue(self): newval = dec[0] + "." + dec[1] self.setValue(newval) v = self.getValue() - + if len(r) == 2 and r[1].isdigit(): # This is a resistor - make values consistent # If the value is a pure value, add R to the end of the value @@ -34,8 +34,8 @@ def checkvalue(self): i = i / 1000 v = str(i) + "K" else: - v = str(i) + "R" - + v = str(i) + "R" + self.setValue(v) else: # Get the multiplier character @@ -45,17 +45,17 @@ def checkvalue(self): if (len(v) == 2): newval = v[0] + multiplier + v[1] self.setValue(newval) - v = self.getValue() - - + v = self.getValue() + + # Give components a new method for checking the values (this could easily be a # Company Part Number generator method instead) -ky.component.checkvalue = checkvalue - +ky_generic_netlist_reader.component.checkvalue = checkvalue + # Generate an instance of a generic netlist, and load the netlist tree from # the command line option. If the file doesn't exist, execution will stop -net = ky.netlist(sys.argv[1]) +net = ky_generic_netlist_reader.netlist(sys.argv[1]) # Open a file to write to, if the file cannot be opened output to stdout # instead @@ -67,5 +67,5 @@ except IOError: for c in net.components: c.checkvalue() - + print >> f, net.formatXML() From 60eb4b006dcd9c2e169cc7af2bdf985811aece31 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Sat, 15 Jun 2013 12:55:51 -0400 Subject: [PATCH 27/50] Pcbnew netlist read performance improvements. * Do not search for footprint when no footprint is defined for a component in the netlist. --- pcbnew/netlist.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pcbnew/netlist.cpp b/pcbnew/netlist.cpp index bf9d60567d..5b40506808 100644 --- a/pcbnew/netlist.cpp +++ b/pcbnew/netlist.cpp @@ -185,6 +185,18 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter ) { component = aNetlist.GetComponent( ii ); + if( component->GetFootprintName().IsEmpty() ) + { + 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() ) @@ -278,6 +290,18 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter ) { component = aNetlist.GetComponent( ii ); + if( component->GetFootprintName().IsEmpty() ) + { + 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() ) From 4536e27426c8705c618f085de1b180881d193c82 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 17 Jun 2013 21:01:47 +0200 Subject: [PATCH 28/50] Eeschema: Fix wx28 compatibility issue. --- eeschema/dialogs/dialog_bom.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/eeschema/dialogs/dialog_bom.cpp b/eeschema/dialogs/dialog_bom.cpp index 59c4184400..cb01c70d2f 100644 --- a/eeschema/dialogs/dialog_bom.cpp +++ b/eeschema/dialogs/dialog_bom.cpp @@ -204,8 +204,6 @@ DIALOG_BOM::DIALOG_BOM( SCH_EDIT_FRAME* parent ) : DIALOG_BOM::~DIALOG_BOM() { - wxString list; - // Save the plugin descriptions in config. // the config stores only one string. // plugins are saved inside a S expr: @@ -215,16 +213,16 @@ DIALOG_BOM::~DIALOG_BOM() // ) STRING_FORMATTER writer; - list << wxT("(plugins"); + writer.Print( 0, "(plugins" ); for( unsigned ii = 0; ii < m_plugins.GetCount(); ii += 2 ) { writer.Print( 1, "(plugin %s (cmd %s))", writer.Quotew( m_plugins[ii] ).c_str(), writer.Quotew( m_plugins[ii+1] ).c_str() ); } + writer.Print( 0, ")" ); - list << writer.GetString(); - list << wxT(")"); + wxString list( FROM_UTF8( writer.GetString().c_str() ) ); m_config->Write( BOM_PLUGINS_KEY, list ); @@ -238,13 +236,14 @@ DIALOG_BOM::~DIALOG_BOM() */ void DIALOG_BOM::installPluginsList() { - wxString list, text, active_plugin_name; + wxString list, active_plugin_name; m_config->Read( BOM_PLUGINS_KEY, &list ); m_config->Read( BOM_PLUGIN_SELECTED_KEY, &active_plugin_name ); if( !list.IsEmpty() ) { - BOM_CFG_READER_PARSER cfg_parser( &m_plugins, list.c_str(), wxT( "plugins" ) ); + BOM_CFG_READER_PARSER cfg_parser( &m_plugins, TO_UTF8( list ), + wxT( "plugins" ) ); try { cfg_parser.Parse(); From 3b423cb12dd3fd917efe5cdb18fb30774aed1a66 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 18 Jun 2013 19:27:47 +0200 Subject: [PATCH 29/50] Pcbnew fix Bug #1192203 (I hope ...) Bitmap2component: add export for .kicad_mod new footprint file format, and export polygon descr for page layout description (.kicad_wks file) --- bitmap2component/bitmap2cmp_gui.cpp | 146 +- bitmap2component/bitmap2cmp_gui_base.cpp | 55 +- bitmap2component/bitmap2cmp_gui_base.fbp | 2469 +++++++++++++--------- bitmap2component/bitmap2cmp_gui_base.h | 21 +- bitmap2component/bitmap2component.cpp | 151 +- pcbnew/class_zone.cpp | 5 +- 6 files changed, 1819 insertions(+), 1028 deletions(-) diff --git a/bitmap2component/bitmap2cmp_gui.cpp b/bitmap2component/bitmap2cmp_gui.cpp index 9c7335e712..70bf62d408 100644 --- a/bitmap2component/bitmap2cmp_gui.cpp +++ b/bitmap2component/bitmap2cmp_gui.cpp @@ -46,6 +46,7 @@ #define KEYWORD_FRAME_SIZEY wxT( "Bmconverter_Size_y" ) #define KEYWORD_LAST_INPUT_FILE wxT( "Last_input" ) #define KEYWORD_LAST_OUTPUT_FILE wxT( "Last_output" ) +#define KEYWORD_LAST_FORMAT wxT( "Last_format" ) #define KEYWORD_BINARY_THRESHOLD wxT( "Threshold" ) #define KEYWORD_BW_NEGATIVE wxT( "Negative_choice" ) @@ -79,8 +80,32 @@ private: void OnPaint( wxPaintEvent& event ); void OnLoadFile( wxCommandEvent& event ); bool LoadFile( wxString& aFullFileName ); - void OnExportEeschema( wxCommandEvent& event ); - void OnExportPcbnew( wxCommandEvent& event ); + void OnExport( wxCommandEvent& event ); + + /** + * Generate a schematic library which comtains one component: + * the logo + */ + void OnExportEeschema(); + + /** + * Depending on the option: + * Legacy format: generate a module library which comtains one component + * New kicad_mod format: generate a module in S expr format + */ + void OnExportPcbnew( bool aLegacyFormat ); + + /** + * Generate a postscript file + */ + void OnExportPostScript(); + + /** + * Generate a file suitable to be copied into a page layout + * description file (.kicad_wks file + */ + void OnExportLogo(); + void Binarize( double aThreshold ); // aThreshold = 0.0 (black level) to 1.0 (white level) void OnOptionsSelection( wxCommandEvent& event ); void OnThresholdChange( wxScrollEvent& event ); @@ -104,6 +129,9 @@ BM2CMP_FRAME::BM2CMP_FRAME() : BM2CMP_FRAME_BASE( NULL ) if( m_Config->Read( KEYWORD_BW_NEGATIVE, &tmp ) ) m_rbOptions->SetSelection( tmp ? 1 : 0 ); + m_Config->Read( KEYWORD_LAST_FORMAT, &tmp ); + m_radioBoxFormat->SetSelection( tmp ); + // Give an icon wxIcon icon; @@ -114,8 +142,7 @@ BM2CMP_FRAME::BM2CMP_FRAME() : BM2CMP_FRAME_BASE( NULL ) SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); - m_buttonExportEeschema->Enable( false ); - m_buttonExportPcbnew->Enable( false ); + m_buttonExport->Enable( false ); if ( m_FramePos == wxDefaultPosition ) Centre(); @@ -138,6 +165,7 @@ BM2CMP_FRAME::~BM2CMP_FRAME() m_Config->Write( KEYWORD_LAST_OUTPUT_FILE, m_ConvertedFileName ); m_Config->Write( KEYWORD_BINARY_THRESHOLD, m_sliderThreshold->GetValue() ); m_Config->Write( KEYWORD_BW_NEGATIVE, m_rbOptions->GetSelection() ); + m_Config->Write( KEYWORD_LAST_FORMAT, m_radioBoxFormat->GetSelection() ); delete m_Config; @@ -198,8 +226,7 @@ void BM2CMP_FRAME::OnLoadFile( wxCommandEvent& event ) if( ! LoadFile( fullFilename ) ) return; - m_buttonExportEeschema->Enable( true ); - m_buttonExportPcbnew->Enable( true ); + m_buttonExport->Enable( true ); SetStatusText( fullFilename ); Refresh(); } @@ -300,8 +327,103 @@ void BM2CMP_FRAME::OnThresholdChange( wxScrollEvent& event ) Refresh(); } +void BM2CMP_FRAME::OnExport( wxCommandEvent& event ) +{ + int sel = m_radioBoxFormat->GetSelection(); -void BM2CMP_FRAME::OnExportEeschema( wxCommandEvent& event ) + switch( sel ) + { + case 0: + OnExportEeschema(); + break; + + case 1: + OnExportPcbnew( true ); + break; + + case 2: + OnExportPcbnew( false ); + break; + + case 3: + OnExportPostScript(); + break; + + case 4: + OnExportLogo(); + break; + } +} + +void BM2CMP_FRAME::OnExportLogo() +{ + wxFileName fn(m_ConvertedFileName); + wxString path = fn.GetPath(); + + if( path.IsEmpty() || !wxDirExists(path) ) + path = ::wxGetCwd(); + + wxString msg = _( "Logo file (*.kicad_wks)|*.kicad_wks" ); + wxFileDialog FileDlg( this, _( "Create a logo file" ), path, wxEmptyString, + msg, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + int diag = FileDlg.ShowModal(); + + if( diag != wxID_OK ) + return; + + m_ConvertedFileName = FileDlg.GetPath(); + + FILE* outfile; + outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) ); + + if( outfile == NULL ) + { + wxString msg; + msg.Printf( _( "File %s could not be created" ), m_ConvertedFileName.c_str() ); + wxMessageBox( msg ); + return; + } + + ExportFile( outfile, 4 ); + fclose( outfile ); +} + +void BM2CMP_FRAME::OnExportPostScript() +{ + wxFileName fn(m_ConvertedFileName); + wxString path = fn.GetPath(); + + if( path.IsEmpty() || !wxDirExists(path) ) + path = ::wxGetCwd(); + + wxString msg = _( "Postscript file (*.ps)|*.ps" ); + wxFileDialog FileDlg( this, _( "Create a Postscript file" ), path, wxEmptyString, + msg, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + int diag = FileDlg.ShowModal(); + + if( diag != wxID_OK ) + return; + + m_ConvertedFileName = FileDlg.GetPath(); + + FILE* outfile; + outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) ); + + if( outfile == NULL ) + { + wxString msg; + msg.Printf( _( "File %s could not be created" ), m_ConvertedFileName.c_str() ); + wxMessageBox( msg ); + return; + } + + ExportFile( outfile, 3 ); + fclose( outfile ); +} + +void BM2CMP_FRAME::OnExportEeschema() { wxFileName fn(m_ConvertedFileName); wxString path = fn.GetPath(); @@ -331,12 +453,12 @@ void BM2CMP_FRAME::OnExportEeschema( wxCommandEvent& event ) return; } - ExportFile( outfile, 1 ); + ExportFile( outfile, 2 ); fclose( outfile ); } -void BM2CMP_FRAME::OnExportPcbnew( wxCommandEvent& event ) +void BM2CMP_FRAME::OnExportPcbnew( bool aLegacyFormat ) { wxFileName fn(m_ConvertedFileName); wxString path = fn.GetPath(); @@ -344,7 +466,9 @@ void BM2CMP_FRAME::OnExportPcbnew( wxCommandEvent& event ) if( path.IsEmpty() || !wxDirExists(path) ) path = ::wxGetCwd(); - wxString msg = _( "Footprint file (*.mod;*.emp)|*.mod;*.emp" ); + wxString msg = aLegacyFormat ? + _( "Footprint file (*.emp)|*.emp" ) : + _( "Footprint file (*.kicad_mod)|*.kicad_mod" ); wxFileDialog FileDlg( this, _( "Create a footprint file for PcbNew" ), path, wxEmptyString, msg, @@ -368,7 +492,7 @@ void BM2CMP_FRAME::OnExportPcbnew( wxCommandEvent& event ) return; } - ExportFile( outfile, 0 ); + ExportFile( outfile, aLegacyFormat ? 0 : 1 ); fclose( outfile ); } diff --git a/bitmap2component/bitmap2cmp_gui_base.cpp b/bitmap2component/bitmap2cmp_gui_base.cpp index 079a3ef482..92315a9545 100644 --- a/bitmap2component/bitmap2cmp_gui_base.cpp +++ b/bitmap2component/bitmap2cmp_gui_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Sep 8 2010) +// C++ code generated with wxFormBuilder (version Oct 8 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -47,77 +47,82 @@ BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxS m_staticTextSizeX = new wxStaticText( m_panelRight, wxID_ANY, _("Size X:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextSizeX->Wrap( -1 ); - fgSizerInfo->Add( m_staticTextSizeX, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizerInfo->Add( m_staticTextSizeX, 0, wxALIGN_RIGHT|wxALL|wxALIGN_CENTER_VERTICAL, 5 ); m_SizeXValue = new wxStaticText( m_panelRight, wxID_ANY, _("0000"), wxDefaultPosition, wxDefaultSize, 0 ); m_SizeXValue->Wrap( -1 ); - fgSizerInfo->Add( m_SizeXValue, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizerInfo->Add( m_SizeXValue, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); m_SizeXunits = new wxStaticText( m_panelRight, wxID_ANY, _("pixels"), wxDefaultPosition, wxDefaultSize, 0 ); m_SizeXunits->Wrap( -1 ); - fgSizerInfo->Add( m_SizeXunits, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizerInfo->Add( m_SizeXunits, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); m_staticTextSizeY = new wxStaticText( m_panelRight, wxID_ANY, _("Size Y:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextSizeY->Wrap( -1 ); - fgSizerInfo->Add( m_staticTextSizeY, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizerInfo->Add( m_staticTextSizeY, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); m_SizeYValue = new wxStaticText( m_panelRight, wxID_ANY, _("0000"), wxDefaultPosition, wxDefaultSize, 0 ); m_SizeYValue->Wrap( -1 ); - fgSizerInfo->Add( m_SizeYValue, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizerInfo->Add( m_SizeYValue, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); m_SizeYunits = new wxStaticText( m_panelRight, wxID_ANY, _("pixels"), wxDefaultPosition, wxDefaultSize, 0 ); m_SizeYunits->Wrap( -1 ); - fgSizerInfo->Add( m_SizeYunits, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizerInfo->Add( m_SizeYunits, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); m_staticTextBPP = new wxStaticText( m_panelRight, wxID_ANY, _("BPP:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextBPP->Wrap( -1 ); - fgSizerInfo->Add( m_staticTextBPP, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizerInfo->Add( m_staticTextBPP, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); m_BPPValue = new wxStaticText( m_panelRight, wxID_ANY, _("0000"), wxDefaultPosition, wxDefaultSize, 0 ); m_BPPValue->Wrap( -1 ); - fgSizerInfo->Add( m_BPPValue, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizerInfo->Add( m_BPPValue, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); m_BPPunits = new wxStaticText( m_panelRight, wxID_ANY, _("bits"), wxDefaultPosition, wxDefaultSize, 0 ); m_BPPunits->Wrap( -1 ); - fgSizerInfo->Add( m_BPPunits, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + fgSizerInfo->Add( m_BPPunits, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + sbSizerInfo->Add( fgSizerInfo, 0, wxEXPAND|wxBOTTOM, 5 ); - brightSizer->Add( sbSizerInfo, 0, wxEXPAND|wxALL, 5 ); + + brightSizer->Add( sbSizerInfo, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_buttonLoad = new wxButton( m_panelRight, wxID_ANY, _("Load Bitmap"), wxDefaultPosition, wxDefaultSize, 0 ); - brightSizer->Add( m_buttonLoad, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 ); + brightSizer->Add( m_buttonLoad, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - m_buttonExportEeschema = new wxButton( m_panelRight, wxID_ANY, _("Export to Eeschema"), wxDefaultPosition, wxDefaultSize, 0 ); - m_buttonExportEeschema->SetToolTip( _("Create a library file for Eeschema\nThis library contains only one component: logo") ); + m_buttonExport = new wxButton( m_panelRight, wxID_ANY, _("Export"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonExport->SetToolTip( _("Create a library file for Eeschema\nThis library contains only one component: logo") ); - brightSizer->Add( m_buttonExportEeschema, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 ); + brightSizer->Add( m_buttonExport, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - m_buttonExportPcbnew = new wxButton( m_panelRight, wxID_ANY, _("Export to Pcbnew"), wxDefaultPosition, wxDefaultSize, 0 ); - m_buttonExportPcbnew->SetToolTip( _("Create a footprint file for PcbNew\nThis footprint contains only one footprint: logo") ); - - brightSizer->Add( m_buttonExportPcbnew, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 ); + wxString m_radioBoxFormatChoices[] = { _("Eeschema"), _("Pcbnew old fmt (.emp)"), _("Pcbnew kicad_mod"), _("Postscript"), _("Logo for title block") }; + int m_radioBoxFormatNChoices = sizeof( m_radioBoxFormatChoices ) / sizeof( wxString ); + m_radioBoxFormat = new wxRadioBox( m_panelRight, wxID_ANY, _("Format"), wxDefaultPosition, wxDefaultSize, m_radioBoxFormatNChoices, m_radioBoxFormatChoices, 1, wxRA_SPECIFY_COLS ); + m_radioBoxFormat->SetSelection( 4 ); + brightSizer->Add( m_radioBoxFormat, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); wxString m_rbOptionsChoices[] = { _("Normal"), _("Negative") }; int m_rbOptionsNChoices = sizeof( m_rbOptionsChoices ) / sizeof( wxString ); m_rbOptions = new wxRadioBox( m_panelRight, wxID_ANY, _("Options"), wxDefaultPosition, wxDefaultSize, m_rbOptionsNChoices, m_rbOptionsChoices, 1, wxRA_SPECIFY_COLS ); m_rbOptions->SetSelection( 0 ); - brightSizer->Add( m_rbOptions, 0, wxALL|wxEXPAND, 5 ); + brightSizer->Add( m_rbOptions, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_ThresholdText = new wxStaticText( m_panelRight, wxID_ANY, _("Threshold Value:"), wxDefaultPosition, wxDefaultSize, 0 ); m_ThresholdText->Wrap( -1 ); - brightSizer->Add( m_ThresholdText, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + brightSizer->Add( m_ThresholdText, 0, wxRIGHT|wxLEFT, 5 ); - m_sliderThreshold = new wxSlider( m_panelRight, wxID_ANY, 25, 0, 50, wxDefaultPosition, wxDefaultSize, wxSL_AUTOTICKS|wxSL_HORIZONTAL|wxSL_TOP ); + m_sliderThreshold = new wxSlider( m_panelRight, wxID_ANY, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS ); m_sliderThreshold->SetToolTip( _("Adjust the level to convert the greyscale picture to a black and white picture.") ); brightSizer->Add( m_sliderThreshold, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_panelRight->SetSizer( brightSizer ); m_panelRight->Layout(); brightSizer->Fit( m_panelRight ); bMainSizer->Add( m_panelRight, 0, wxEXPAND, 0 ); + this->SetSizer( bMainSizer ); this->Layout(); m_statusBar = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY ); @@ -127,8 +132,7 @@ BM2CMP_FRAME_BASE::BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxS m_GreyscalePicturePanel->Connect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaint ), NULL, this ); m_BNPicturePanel->Connect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaint ), NULL, this ); m_buttonLoad->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnLoadFile ), NULL, this ); - m_buttonExportEeschema->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExportEeschema ), NULL, this ); - m_buttonExportPcbnew->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExportPcbnew ), NULL, this ); + m_buttonExport->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExport ), NULL, this ); m_rbOptions->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnOptionsSelection ), NULL, this ); m_sliderThreshold->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( BM2CMP_FRAME_BASE::OnThresholdChange ), NULL, this ); } @@ -140,8 +144,7 @@ BM2CMP_FRAME_BASE::~BM2CMP_FRAME_BASE() m_GreyscalePicturePanel->Disconnect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaint ), NULL, this ); m_BNPicturePanel->Disconnect( wxEVT_PAINT, wxPaintEventHandler( BM2CMP_FRAME_BASE::OnPaint ), NULL, this ); m_buttonLoad->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnLoadFile ), NULL, this ); - m_buttonExportEeschema->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExportEeschema ), NULL, this ); - m_buttonExportPcbnew->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExportPcbnew ), NULL, this ); + m_buttonExport->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnExport ), NULL, this ); m_rbOptions->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( BM2CMP_FRAME_BASE::OnOptionsSelection ), NULL, this ); m_sliderThreshold->Disconnect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( BM2CMP_FRAME_BASE::OnThresholdChange ), NULL, this ); diff --git a/bitmap2component/bitmap2cmp_gui_base.fbp b/bitmap2component/bitmap2cmp_gui_base.fbp index d8f45dc4d0..d848aa0d8c 100644 --- a/bitmap2component/bitmap2cmp_gui_base.fbp +++ b/bitmap2component/bitmap2cmp_gui_base.fbp @@ -2,11 +2,13 @@ - + C++ 1 source_name + 0 0 + res UTF-8 connect bitmap2cmp_gui_base @@ -14,73 +16,78 @@ none 1 bitmap2cmp_gui - + . - + 1 + 1 1 0 0 - - - + 0 + wxAUI_MGR_DEFAULT + + + 1 1 impl_virtual - - - + + + 0 wxID_ANY - - + + BM2CMP_FRAME_BASE - - 500,419 + + 527,470 wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER - + Bitmap to Component Converter - - - wxFILTER_NONE - wxDefaultValidator - - - + + + wxTAB_TRAVERSAL 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + bMainSizer wxHORIZONTAL none @@ -89,219 +96,327 @@ wxEXPAND 1 - - - + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY - - + + 0 + + + 0 + + 1 m_notebook1 + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 1 + + Resizable + 1 + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + Original Picture 1 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY + + 0 -1,-1 + + 0 400,300 + 1 m_InitialPicturePanel + 1 + + protected - + 1 + + Resizable 5 5 - - - - - wxFILTER_NONE - wxDefaultValidator - - - + 1 + + + 0 + + + wxHSCROLL|wxVSCROLL - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + OnPaint - - - - - - + + + + + + - + Greyscale Picture 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY + + 0 -1,-1 + + 0 400,300 + 1 m_GreyscalePicturePanel + 1 + + protected - + 1 + + Resizable 5 5 - - - - - wxFILTER_NONE - wxDefaultValidator - - - + 1 + + + 0 + + + wxHSCROLL|wxVSCROLL - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + OnPaint - - - - - - + + + + + + - + Black&&White Picture 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY - - + + 0 + + + 0 + + 1 m_BNPicturePanel + 1 + + protected - + 1 + + Resizable 5 5 - - - - - wxFILTER_NONE - wxDefaultValidator - - - + 1 + + + 0 + + + wxHSCROLL|wxVSCROLL - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + OnPaint - - - - - - + + + + + + @@ -311,69 +426,96 @@ wxEXPAND 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY - - + + 0 + + + 0 + + 1 m_panelRight + 1 + + protected - - - - - - wxFILTER_NONE - wxDefaultValidator - - - + 1 + + Resizable + 1 + + + 0 + + + wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - + brightSizer wxVERTICAL none 5 - wxEXPAND|wxALL + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 wxID_ANY Bitmap Info: - + sbSizerInfo wxVERTICAL none - + 5 wxEXPAND|wxBOTTOM @@ -381,10 +523,10 @@ 3 wxBOTH - - + + 0 - + fgSizerInfo wxFLEX_GROWMODE_SPECIFIED none @@ -392,506 +534,749 @@ 0 5 - wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT + wxALIGN_RIGHT|wxALL|wxALIGN_CENTER_VERTICAL 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY Size X: - - + + 0 + + + 0 + + 1 m_staticTextSizeX + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - + 1 + + Resizable + 1 + + + + 0 + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + 5 - wxBOTTOM|wxRIGHT|wxLEFT + wxALL|wxALIGN_CENTER_VERTICAL 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY 0000 - - + + 0 + + + 0 + + 1 m_SizeXValue + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - + 1 + + Resizable + 1 + + + + 0 + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + 5 - wxBOTTOM|wxRIGHT|wxLEFT + wxALL|wxALIGN_CENTER_VERTICAL 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY pixels - - + + 0 + + + 0 + + 1 m_SizeXunits + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - + 1 + + Resizable + 1 + + + + 0 + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + 5 - wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT + wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY Size Y: - - + + 0 + + + 0 + + 1 m_staticTextSizeY + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - + 1 + + Resizable + 1 + + + + 0 + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + 5 - wxBOTTOM|wxRIGHT|wxLEFT + wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY 0000 - - + + 0 + + + 0 + + 1 m_SizeYValue + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - + 1 + + Resizable + 1 + + + + 0 + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + 5 - wxBOTTOM|wxRIGHT|wxLEFT + wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY pixels - - + + 0 + + + 0 + + 1 m_SizeYunits + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - + 1 + + Resizable + 1 + + + + 0 + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + 5 - wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT + wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY BPP: - - + + 0 + + + 0 + + 1 m_staticTextBPP + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - + 1 + + Resizable + 1 + + + + 0 + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + 5 - wxBOTTOM|wxRIGHT|wxLEFT + wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY 0000 - - + + 0 + + + 0 + + 1 m_BPPValue + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - + 1 + + Resizable + 1 + + + + 0 + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + 5 - wxBOTTOM|wxRIGHT|wxLEFT + wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY bits - - + + 0 + + + 0 + + 1 m_BPPunits + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - + 1 + + Resizable + 1 + + + + 0 + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -900,288 +1285,441 @@ 5 - wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL + wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 0 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY Load Bitmap - - + + 0 + + + 0 + + 1 m_buttonLoad + 1 + + protected - - - - - - + 1 + + Resizable + 1 + + + + 0 + + wxFILTER_NONE wxDefaultValidator - - - - + + + + OnLoadFile - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + 5 - wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL + wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 0 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY - Export to Eeschema - - - m_buttonExportEeschema + Export + + 0 + + + 0 + + 1 + m_buttonExport + 1 + + protected - - - - + 1 + + Resizable + 1 + + + + 0 Create a library file for Eeschema This library contains only one component: logo - + wxFILTER_NONE wxDefaultValidator - - - - - OnExportEeschema - - - - - - - - - - - - - - - - - - - - - - - + + + + + OnExport + + + + + + + + + + + + + + + + + + + + + + + 5 - wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL - 0 - - - - 1 - 0 - 1 - - - 0 - wxID_ANY - Export to Pcbnew - - - m_buttonExportPcbnew - protected - - - - - Create a footprint file for PcbNew This footprint contains only one footprint: logo - - wxFILTER_NONE - wxDefaultValidator - - - - - OnExportPcbnew - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND + wxBOTTOM|wxRIGHT|wxLEFT 0 - - "Normal" "Negative" - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Eeschema" "Pcbnew old fmt (.emp)" "Pcbnew kicad_mod" "Postscript" "Logo for title block" + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 + 0 + wxID_ANY + Format + 1 + + 0 + + + 0 + + 1 + m_radioBoxFormat + 1 + + + protected + 1 + + Resizable + 4 + 1 + + wxRA_SPECIFY_COLS + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Normal" "Negative" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 0 wxID_ANY Options 1 - - + + 0 + + + 0 + + 1 m_rbOptions + 1 + + protected - + 1 + + Resizable 0 - + 1 + wxRA_SPECIFY_COLS - - - + + 0 + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + OnOptionsSelection - - - - - - + + + + + + 5 - wxTOP|wxRIGHT|wxLEFT + wxRIGHT|wxLEFT 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY Threshold Value: - - + + 0 + + + 0 + + 1 m_ThresholdText + 1 + + protected - - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - + 1 + + Resizable + 1 + + + + 0 + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -1189,76 +1727,107 @@ wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY - 50 - + 100 + + 0 + 0 - + + 0 + + 1 m_sliderThreshold + 1 + + protected - - - wxSL_AUTOTICKS|wxSL_HORIZONTAL|wxSL_TOP - + 1 + + Resizable + 1 + + wxSL_HORIZONTAL|wxSL_LABELS + + 0 Adjust the level to convert the greyscale picture to a black and white picture. - + wxFILTER_NONE wxDefaultValidator - - 25 - - - - - - - - - - - - + + 50 + + + + + + + + + + + + OnThresholdChange - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1266,54 +1835,50 @@ - - + + 1 1 - + 1 - + 0 wxID_ANY - - + + m_statusBar protected - - + + wxST_SIZEGRIP - - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bitmap2component/bitmap2cmp_gui_base.h b/bitmap2component/bitmap2cmp_gui_base.h index e826f55b8e..301a63398b 100644 --- a/bitmap2component/bitmap2cmp_gui_base.h +++ b/bitmap2component/bitmap2cmp_gui_base.h @@ -1,15 +1,16 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Sep 8 2010) +// C++ code generated with wxFormBuilder (version Oct 8 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __bitmap2cmp_gui_base__ -#define __bitmap2cmp_gui_base__ +#ifndef __BITMAP2CMP_GUI_BASE_H__ +#define __BITMAP2CMP_GUI_BASE_H__ +#include +#include #include - #include #include #include @@ -56,8 +57,8 @@ class BM2CMP_FRAME_BASE : public wxFrame wxStaticText* m_BPPValue; wxStaticText* m_BPPunits; wxButton* m_buttonLoad; - wxButton* m_buttonExportEeschema; - wxButton* m_buttonExportPcbnew; + wxButton* m_buttonExport; + wxRadioBox* m_radioBoxFormat; wxRadioBox* m_rbOptions; wxStaticText* m_ThresholdText; wxSlider* m_sliderThreshold; @@ -66,17 +67,17 @@ class BM2CMP_FRAME_BASE : public wxFrame // Virtual event handlers, overide them in your derived class virtual void OnPaint( wxPaintEvent& event ) { event.Skip(); } virtual void OnLoadFile( wxCommandEvent& event ) { event.Skip(); } - virtual void OnExportEeschema( wxCommandEvent& event ) { event.Skip(); } - virtual void OnExportPcbnew( wxCommandEvent& event ) { event.Skip(); } + virtual void OnExport( wxCommandEvent& event ) { event.Skip(); } virtual void OnOptionsSelection( wxCommandEvent& event ) { event.Skip(); } virtual void OnThresholdChange( wxScrollEvent& event ) { event.Skip(); } public: - BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Bitmap to Component Converter"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,419 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL ); + BM2CMP_FRAME_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Bitmap to Component Converter"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 527,470 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL ); + ~BM2CMP_FRAME_BASE(); }; -#endif //__bitmap2cmp_gui_base__ +#endif //__BITMAP2CMP_GUI_BASE_H__ diff --git a/bitmap2component/bitmap2component.cpp b/bitmap2component/bitmap2component.cpp index e2c2bacbbc..245cfc3447 100644 --- a/bitmap2component/bitmap2component.cpp +++ b/bitmap2component/bitmap2component.cpp @@ -1,8 +1,8 @@ /* * This program source code file is part of KICAD, a free EDA CAD application. * - * Copyright (C) 1992-2010 jean-pierre.charras - * Copyright (C) 1992-2010 Kicad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-2013 jean-pierre.charras + * Copyright (C) 1992-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 @@ -22,8 +22,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include +#include // std::max -// For some unknown reasons, polygon.hpp shoul be included first +// For some unknown reasons, polygon.hpp should be included first #include #include @@ -38,13 +39,6 @@ #include -#ifndef max - #define max( a, b ) ( ( (a) > (b) ) ? (a) : (b) ) -#endif -#ifndef min - #define min( a, b ) ( ( (a) < (b) ) ? (a) : (b) ) -#endif - // Define some types used here from boost::polygon namespace bpl = boost::polygon; // bpl = boost polygon library using namespace bpl::operators; // +, -, =, ... @@ -58,9 +52,12 @@ typedef bpl::point_data KPolyPoint; // define a corner o enum output_format { POSTSCRIPT_FMT = 1, - PCBNEW_FMT, - EESCHEMA_FMT + PCBNEW_LEGACY_EMP, + PCBNEW_KICAD_MOD, + EESCHEMA_FMT, + KICAD_LOGO }; + /* free a potrace bitmap */ static void bm_free( potrace_bitmap_t* bm ) { @@ -172,22 +169,37 @@ int bitmap2component( potrace_bitmap_t* aPotrace_bitmap, FILE* aOutfile, int aFo switch( aFormat ) { - case 2: + case 4: + info.m_Format = KICAD_LOGO; + info.m_ScaleX = 1e3 * 25.4 / 300; // the conversion scale from PPI to micro + info.m_ScaleY = info.m_ScaleX; // Y axis is top to bottom + info.CreateOutputFile(); + break; + + case 3: info.m_Format = POSTSCRIPT_FMT; - info.m_ScaleX = info.m_ScaleY = 1.0; // the conversion scale + info.m_ScaleX = 1.0; // the conversion scale + info.m_ScaleY = info.m_ScaleX; // output vector data, e.g. as a rudimentary EPS file (mainly for tests) info.CreateOutputFile(); break; - case 1: + case 2: info.m_Format = EESCHEMA_FMT; - info.m_ScaleX = 1000.0 / 300; // the conversion scale + info.m_ScaleX = 1000.0 / 300; // the conversion scale from PPI to UI info.m_ScaleY = -info.m_ScaleX; // Y axis is bottom to Top for components in libs info.CreateOutputFile(); break; + case 1: + info.m_Format = PCBNEW_KICAD_MOD; + info.m_ScaleX = 1e6 * 25.4 / 300; // the conversion scale from PPI to UI + info.m_ScaleY = info.m_ScaleX; // Y axis is top to bottom in modedit + info.CreateOutputFile(); + break; + case 0: - info.m_Format = PCBNEW_FMT; + info.m_Format = PCBNEW_LEGACY_EMP; info.m_ScaleX = 10000.0 / 300; // the conversion scale info.m_ScaleY = info.m_ScaleX; // Y axis is top to bottom in modedit info.CreateOutputFile(); @@ -221,7 +233,7 @@ void BITMAPCONV_INFO::OuputFileHeader() fprintf( m_Outfile, "gsave\n" ); break; - case PCBNEW_FMT: + case PCBNEW_LEGACY_EMP: #define FIELD_LAYER 21 fieldSize = 600; // fields text size = 60 mils Ypos += fieldSize / 2; @@ -240,6 +252,22 @@ void BITMAPCONV_INFO::OuputFileHeader() -Ypos, fieldSize, fieldSize, fieldSize / 5, FIELD_LAYER, m_CmpName ); break; + case PCBNEW_KICAD_MOD: + // fields text size = 1.5 mm + // fields text thickness = 1.5 / 5 = 0.3mm + fprintf( m_Outfile, "(module %s (layer F.Cu)\n (at 0 0)\n", + m_CmpName ); + fprintf( m_Outfile, " (fp_text reference \"G***\" (at 0 0) (layer F.SilkS) hide\n" + " (effects (font (thickness 0.3)))\n )\n" ); + fprintf( m_Outfile, " (fp_text value \"%s\" (at 0.75 0) (layer F.SilkS) hide\n" + " (effects (font (thickness 0.3)))\n )\n", + m_CmpName ); + break; + + case KICAD_LOGO: + fprintf( m_Outfile, "(polygon (pos 0 0 rbcorner) (rotate 0) (linewidth 0.01)\n" ); + break; + case EESCHEMA_FMT: fprintf( m_Outfile, "EESchema-LIBRARY Version 2.3\n" ); fprintf( m_Outfile, "#\n# %s\n", m_CmpName ); @@ -267,11 +295,19 @@ void BITMAPCONV_INFO::OuputFileEnd() fprintf( m_Outfile, "%%EOF\n" ); break; - case PCBNEW_FMT: + case PCBNEW_LEGACY_EMP: fprintf( m_Outfile, "$EndMODULE %s\n", m_CmpName ); fprintf( m_Outfile, "$EndLIBRARY\n" ); break; + case PCBNEW_KICAD_MOD: + fprintf( m_Outfile, ")\n" ); + break; + + case KICAD_LOGO: + fprintf( m_Outfile, ")\n" ); + break; + case EESCHEMA_FMT: fprintf( m_Outfile, "ENDDRAW\n" ); fprintf( m_Outfile, "ENDDEF\n" ); @@ -282,11 +318,11 @@ void BITMAPCONV_INFO::OuputFileEnd() /** * Function OuputOnePolygon * write one polygon to output file. - * Polygon coordinates are expected scaled by the polugon extraction function + * Polygon coordinates are expected scaled by the polygon extraction function */ void BITMAPCONV_INFO::OuputOnePolygon( KPolygon & aPolygon ) { - unsigned ii; + unsigned ii, jj; KPolyPoint currpoint; int offsetX = (int)( m_PixmapWidth / 2 * m_ScaleX ); @@ -297,19 +333,27 @@ void BITMAPCONV_INFO::OuputOnePolygon( KPolygon & aPolygon ) switch( m_Format ) { case POSTSCRIPT_FMT: - fprintf( m_Outfile, "%d %d moveto\n", - startpoint.x(), startpoint.y() ); + offsetY = (int)( m_PixmapHeight * m_ScaleY ); + fprintf( m_Outfile, "newpath\n%d %d moveto\n", + startpoint.x(), offsetY - startpoint.y() ); + jj = 0; for( ii = 1; ii < aPolygon.size(); ii++ ) { currpoint = *(aPolygon.begin() + ii); - fprintf( m_Outfile, "%d %d lineto\n", - currpoint.x(), currpoint.y() ); + fprintf( m_Outfile, " %d %d lineto", + currpoint.x(), offsetY - currpoint.y() ); + + if( jj++ > 6 ) + { + jj = 0; + fprintf( m_Outfile, ("\n") ); + } } - fprintf( m_Outfile, "0 setgray fill\n" ); + fprintf( m_Outfile, "\nclosepath fill\n" ); break; - case PCBNEW_FMT: + case PCBNEW_LEGACY_EMP: { LAYER_NUM layer = SILKSCREEN_N_FRONT; int width = 1; @@ -330,6 +374,54 @@ void BITMAPCONV_INFO::OuputOnePolygon( KPolygon & aPolygon ) } break; + case PCBNEW_KICAD_MOD: + { + double width = 0.1; + fprintf( m_Outfile, " (fp_poly (pts" ); + + jj = 0; + for( ii = 0; ii < aPolygon.size(); ii++ ) + { + currpoint = *( aPolygon.begin() + ii ); + fprintf( m_Outfile, " (xy %f %f)", + (currpoint.x() - offsetX) / 1e6, + (currpoint.y() - offsetY) / 1e6 ); + + if( jj++ > 6 ) + { + jj = 0; + fprintf( m_Outfile, ("\n ") ); + } + } + // Close polygon + fprintf( m_Outfile, " (xy %f %f) )", + (startpoint.x() - offsetX) / 1e6, (startpoint.y() - offsetY) / 1e6 ); + fprintf( m_Outfile, "(layer F.SilkS) (width %f)\n )\n", width ); + } + break; + + case KICAD_LOGO: + fprintf( m_Outfile, " (pts" ); + // Internal units = micron, file unit = mm + jj = 0; + for( ii = 0; ii < aPolygon.size(); ii++ ) + { + currpoint = *( aPolygon.begin() + ii ); + fprintf( m_Outfile, " (xy %.3f %.3f)", + (currpoint.x() - offsetX) / 1e3, + (currpoint.y() - offsetY) / 1e3 ); + + if( jj++ > 4 ) + { + jj = 0; + fprintf( m_Outfile, ("\n ") ); + } + } + // Close polygon + fprintf( m_Outfile, " (xy %.3f %.3f) )\n", + (startpoint.x() - offsetX) / 1e3, (startpoint.y() - offsetY) / 1e3 ); + break; + case EESCHEMA_FMT: fprintf( m_Outfile, "P %d 0 0 1", (int) aPolygon.size() + 1 ); for( ii = 0; ii < aPolygon.size(); ii++ ) @@ -363,6 +455,9 @@ void BITMAPCONV_INFO::CreateOutputFile() KPolygonSet polyset_holes; potrace_dpoint_t( *c )[3]; + + setlocale( LC_NUMERIC, "C" ); // Switch the locale to standard C + OuputFileHeader(); bool main_outline = true; @@ -451,6 +546,8 @@ void BITMAPCONV_INFO::CreateOutputFile() } OuputFileEnd(); + + setlocale( LC_NUMERIC, "" ); // revert to the current locale } diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 4618255a91..085d7e9b61 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -954,8 +954,9 @@ wxString ZONE_CONTAINER::GetSelectMenuText() const } } - text.Printf( _( "Zone Outline %s on %s" ), GetChars( text ), + wxString msg; + msg.Printf( _( "Zone Outline %s on %s" ), GetChars( text ), GetChars( GetLayerName() ) ); - return text; + return msg; } From 781cc00aca615a1bf566227b424a101a8dd3a9fe Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 19 Jun 2013 18:11:12 +0200 Subject: [PATCH 30/50] Pcbnew: netlist dialog: add silent mode option, and tool tip to the 2 options (dry run and silent mode) dialog_display_info_HTML_base: derived now from dialog_shim. --- common/build_version.cpp | 4 +- .../dialogs/dialog_display_info_HTML_base.cpp | 6 +- .../dialogs/dialog_display_info_HTML_base.fbp | 322 ++-- .../dialogs/dialog_display_info_HTML_base.h | 21 +- common/html_messagebox.cpp | 2 +- eeschema/dialogs/dialog_bom.cpp | 6 +- pcbnew/dialogs/dialog_netlist.cpp | 12 +- pcbnew/dialogs/dialog_netlist.h | 8 +- pcbnew/dialogs/dialog_netlist_fbp.cpp | 91 +- pcbnew/dialogs/dialog_netlist_fbp.fbp | 1410 +++++++++-------- pcbnew/dialogs/dialog_netlist_fbp.h | 10 +- 11 files changed, 1065 insertions(+), 827 deletions(-) diff --git a/common/build_version.cpp b/common/build_version.cpp index ba57a1fbfe..52867e07c6 100644 --- a/common/build_version.cpp +++ b/common/build_version.cpp @@ -7,9 +7,9 @@ #ifndef KICAD_BUILD_VERSION #if defined KICAD_GOST -# define KICAD_BUILD_VERSION "(2013-mar-13 GOST)" +# define KICAD_BUILD_VERSION "(2013-jun-18 GOST)" #else -# define KICAD_BUILD_VERSION "(2013-mar-13)" +# define KICAD_BUILD_VERSION "(2013-jun-18)" #endif #endif diff --git a/common/dialogs/dialog_display_info_HTML_base.cpp b/common/dialogs/dialog_display_info_HTML_base.cpp index 4d6a90aac1..346b78692f 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 Apr 16 2008) +// C++ code generated with wxFormBuilder (version Oct 8 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -9,7 +9,7 @@ /////////////////////////////////////////////////////////////////////////// -DIALOG_DISPLAY_HTML_TEXT_BASE::DIALOG_DISPLAY_HTML_TEXT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +DIALOG_DISPLAY_HTML_TEXT_BASE::DIALOG_DISPLAY_HTML_TEXT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) { this->SetSizeHints( wxSize( 400,120 ), wxDefaultSize ); @@ -23,6 +23,7 @@ DIALOG_DISPLAY_HTML_TEXT_BASE::DIALOG_DISPLAY_HTML_TEXT_BASE( wxWindow* parent, m_buttonClose->SetDefault(); bMainSizer->Add( m_buttonClose, 0, wxALIGN_RIGHT|wxRIGHT|wxLEFT, 5 ); + this->SetSizer( bMainSizer ); this->Layout(); @@ -36,4 +37,5 @@ DIALOG_DISPLAY_HTML_TEXT_BASE::~DIALOG_DISPLAY_HTML_TEXT_BASE() // Disconnect Events m_htmlWindow->Disconnect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_DISPLAY_HTML_TEXT_BASE::OnHTMLLinkClicked ), NULL, this ); m_buttonClose->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DISPLAY_HTML_TEXT_BASE::OnCloseButtonClick ), NULL, this ); + } diff --git a/common/dialogs/dialog_display_info_HTML_base.fbp b/common/dialogs/dialog_display_info_HTML_base.fbp index be5a1cf4ba..8b7ed6f157 100644 --- a/common/dialogs/dialog_display_info_HTML_base.fbp +++ b/common/dialogs/dialog_display_info_HTML_base.fbp @@ -2,9 +2,13 @@ - + C++ 1 + source_name + 0 + 0 + res UTF-8 connect dialog_display_info_HTML_base @@ -12,64 +16,76 @@ none 1 dialog_display_info_HTML - + . - + 1 + 1 + 1 0 0 - - - + 0 + wxAUI_MGR_DEFAULT + + + + 1 1 - - - + impl_virtual + + + 0 wxID_ANY - + 400,120 DIALOG_DISPLAY_HTML_TEXT_BASE - + 431,120 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + DIALOG_SHIM; dialog_shim.h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -1,-1 bMainSizer @@ -80,51 +96,83 @@ wxEXPAND 1 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_ANY - + + 0 + + + 0 -1,-1 + 1 m_htmlWindow + 1 + + public - - + 1 + + Resizable + 1 + wxHW_SCROLLBAR_AUTO - - - - + + 0 + + + wxSUNKEN_BORDER - - - - - + + + + + OnHTMLLinkClicked - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -132,51 +180,87 @@ wxALIGN_RIGHT|wxRIGHT|wxLEFT 0 - - + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 1 + 0 + Dock + 0 + Left 1 - - + + 1 + + 0 0 wxID_CANCEL Close - - + + 0 + + + 0 + + 1 m_buttonClose + 1 + + protected - - + 1 + + Resizable + 1 + wxBU_EXACTFIT - - - - - + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + OnCloseButtonClick - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/common/dialogs/dialog_display_info_HTML_base.h b/common/dialogs/dialog_display_info_HTML_base.h index cc98541a02..a184872866 100644 --- a/common/dialogs/dialog_display_info_HTML_base.h +++ b/common/dialogs/dialog_display_info_HTML_base.h @@ -1,15 +1,19 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 16 2008) +// C++ code generated with wxFormBuilder (version Oct 8 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __dialog_display_info_HTML_base__ -#define __dialog_display_info_HTML_base__ +#ifndef __DIALOG_DISPLAY_INFO_HTML_BASE_H__ +#define __DIALOG_DISPLAY_INFO_HTML_BASE_H__ +#include +#include #include +class DIALOG_SHIM; +#include "dialog_shim.h" #include #include #include @@ -26,7 +30,7 @@ /////////////////////////////////////////////////////////////////////////////// /// Class DIALOG_DISPLAY_HTML_TEXT_BASE /////////////////////////////////////////////////////////////////////////////// -class DIALOG_DISPLAY_HTML_TEXT_BASE : public wxDialog +class DIALOG_DISPLAY_HTML_TEXT_BASE : public DIALOG_SHIM { private: @@ -34,15 +38,16 @@ class DIALOG_DISPLAY_HTML_TEXT_BASE : public wxDialog wxButton* m_buttonClose; // Virtual event handlers, overide them in your derived class - virtual void OnHTMLLinkClicked( wxHtmlLinkEvent& event ){ event.Skip(); } - virtual void OnCloseButtonClick( wxCommandEvent& event ){ event.Skip(); } + virtual void OnHTMLLinkClicked( wxHtmlLinkEvent& event ) { event.Skip(); } + virtual void OnCloseButtonClick( wxCommandEvent& event ) { event.Skip(); } 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( 431,120 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_DISPLAY_HTML_TEXT_BASE(); }; -#endif //__dialog_display_info_HTML_base__ +#endif //__DIALOG_DISPLAY_INFO_HTML_BASE_H__ diff --git a/common/html_messagebox.cpp b/common/html_messagebox.cpp index 6d4b0567cd..c86879eae2 100644 --- a/common/html_messagebox.cpp +++ b/common/html_messagebox.cpp @@ -6,8 +6,8 @@ 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 ) { - SetFocus(); ListClear(); + Center(); } void HTML_MESSAGE_BOX::OnCloseButtonClick( wxCommandEvent& event ) diff --git a/eeschema/dialogs/dialog_bom.cpp b/eeschema/dialogs/dialog_bom.cpp index cb01c70d2f..105a71fc06 100644 --- a/eeschema/dialogs/dialog_bom.cpp +++ b/eeschema/dialogs/dialog_bom.cpp @@ -39,7 +39,7 @@ #include #include #include -#include <../common/dialogs/dialog_display_info_HTML_base.h> +#include #define BOM_PLUGINS_KEY wxT("bom_plugins") #define BOM_PLUGIN_SELECTED_KEY wxT("bom_plugin_selected") @@ -459,8 +459,8 @@ void DIALOG_BOM::OnEditPlugin( wxCommandEvent& event ) void DIALOG_BOM::OnHelp( wxCommandEvent& event ) { - DIALOG_DISPLAY_HTML_TEXT_BASE help_Dlg( this, wxID_ANY, - _("Bom generation Help"),wxDefaultPosition, wxSize( 750,550 ) ); + HTML_MESSAGE_BOX help_Dlg( this, _("Bom Generation Help"), + wxDefaultPosition, wxSize( 750,550 ) ); wxString msg = FROM_UTF8(s_bomHelpInfo); help_Dlg.m_htmlWindow->AppendToPage( msg ); diff --git a/pcbnew/dialogs/dialog_netlist.cpp b/pcbnew/dialogs/dialog_netlist.cpp index 1acc9dd585..6284cf2cdf 100644 --- a/pcbnew/dialogs/dialog_netlist.cpp +++ b/pcbnew/dialogs/dialog_netlist.cpp @@ -6,7 +6,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-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 @@ -45,6 +45,7 @@ #include +#define NETLIST_SILENTMODE_KEY wxT("SilentMode") void PCB_EDIT_FRAME::InstallNetlistFrame( wxDC* DC ) { @@ -92,12 +93,19 @@ DIALOG_NETLIST::DIALOG_NETLIST( PCB_EDIT_FRAME* aParent, wxDC * aDC, { m_parent = aParent; m_dc = aDC; + m_config = wxGetApp().GetSettings(); + m_silentMode = m_config->Read( NETLIST_SILENTMODE_KEY, 0l ); m_NetlistFilenameCtrl->SetValue( aNetlistFullFilename ); m_cmpNameSourceOpt->SetSelection( m_parent->GetUseCmpFileForFpNames() ? 1 : 0 ); + m_checkBoxSilentMode->SetValue( m_silentMode ); GetSizer()->SetSizeHints( this ); } +DIALOG_NETLIST::~DIALOG_NETLIST() +{ + m_config->Write( NETLIST_SILENTMODE_KEY, (long) m_silentMode ); +} void DIALOG_NETLIST::OnOpenNetlistClick( wxCommandEvent& event ) { @@ -142,7 +150,7 @@ void DIALOG_NETLIST::OnReadNetlistFileClick( wxCommandEvent& event ) } // Give the user a chance to bail out when making changes from a netlist. - if( !m_checkDryRun->GetValue() + if( !m_checkDryRun->GetValue() && !m_silentMode && !m_parent->GetBoard()->IsEmpty() && !IsOK( NULL, _( "The changes made by reading the netlist cannot be undone. Are you " "sure you want to read the netlist?" ) ) ) diff --git a/pcbnew/dialogs/dialog_netlist.h b/pcbnew/dialogs/dialog_netlist.h index 332403c57f..800926c8ce 100644 --- a/pcbnew/dialogs/dialog_netlist.h +++ b/pcbnew/dialogs/dialog_netlist.h @@ -40,10 +40,12 @@ class DIALOG_NETLIST : public DIALOG_NETLIST_FBP private: PCB_EDIT_FRAME* m_parent; wxDC* m_dc; + bool m_silentMode; + wxConfig* m_config; public: DIALOG_NETLIST( PCB_EDIT_FRAME* aParent, wxDC* aDC, const wxString & aNetlistFullFilename ); - ~DIALOG_NETLIST() {}; + ~DIALOG_NETLIST(); // return true if the user choice is to use the .cmp file // created by CvPcb to know footprint names associated to components @@ -90,6 +92,10 @@ private: void OnCompileRatsnestClick( wxCommandEvent& event ); void OnCancelClick( wxCommandEvent& event ); void OnSaveMessagesToFile( wxCommandEvent& aEvent ); + void OnClickSilentMode( wxCommandEvent& event ) + { + m_silentMode = m_checkBoxSilentMode->GetValue(); + } void OnUpdateUISaveMessagesToFile( wxUpdateUIEvent& aEvent ); void OnUpdateUIValidNetlistFile( wxUpdateUIEvent& aEvent ); diff --git a/pcbnew/dialogs/dialog_netlist_fbp.cpp b/pcbnew/dialogs/dialog_netlist_fbp.cpp index 040213f413..0d3466cabe 100644 --- a/pcbnew/dialogs/dialog_netlist_fbp.cpp +++ b/pcbnew/dialogs/dialog_netlist_fbp.cpp @@ -19,8 +19,14 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w wxBoxSizer* bUpperSizer; bUpperSizer = new wxBoxSizer( wxHORIZONTAL ); - wxBoxSizer* bLeftSizer; - bLeftSizer = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bleftSizer; + bleftSizer = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bnetlistOptSizer; + bnetlistOptSizer = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* bmodulesOptSizer; + bmodulesOptSizer = new wxBoxSizer( wxVERTICAL ); wxString m_Select_By_TimestampChoices[] = { _("Reference"), _("Timestamp") }; int m_Select_By_TimestampNChoices = sizeof( m_Select_By_TimestampChoices ) / sizeof( wxString ); @@ -28,7 +34,7 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w m_Select_By_Timestamp->SetSelection( 0 ); m_Select_By_Timestamp->SetToolTip( _("Select how footprints are recognized:\nby their reference (U1, R3...) (normal setting)\nor their time stamp (special setting after a full schematic reannotation)") ); - bLeftSizer->Add( m_Select_By_Timestamp, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + bmodulesOptSizer->Add( m_Select_By_Timestamp, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); wxString m_cmpNameSourceOptChoices[] = { _("From netlist"), _("From separate .cmp file") }; int m_cmpNameSourceOptNChoices = sizeof( m_cmpNameSourceOptChoices ) / sizeof( wxString ); @@ -36,7 +42,7 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w m_cmpNameSourceOpt->SetSelection( 0 ); m_cmpNameSourceOpt->SetToolTip( _("Source of footprints names for component:\n- the netlist (if you have filled the footprint field of each component in schematic)\n- the .cmp file created by CvPcb") ); - bLeftSizer->Add( m_cmpNameSourceOpt, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + bmodulesOptSizer->Add( m_cmpNameSourceOpt, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); wxString m_ChangeExistingFootprintCtrlChoices[] = { _("Keep"), _("Change") }; int m_ChangeExistingFootprintCtrlNChoices = sizeof( m_ChangeExistingFootprintCtrlChoices ) / sizeof( wxString ); @@ -44,13 +50,13 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w m_ChangeExistingFootprintCtrl->SetSelection( 0 ); m_ChangeExistingFootprintCtrl->SetToolTip( _("Keep or change an existing footprint when the netlist gives a different footprint") ); - bLeftSizer->Add( m_ChangeExistingFootprintCtrl, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + bmodulesOptSizer->Add( m_ChangeExistingFootprintCtrl, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - bUpperSizer->Add( bLeftSizer, 1, wxEXPAND, 5 ); + bnetlistOptSizer->Add( bmodulesOptSizer, 1, wxEXPAND, 5 ); - wxBoxSizer* bMiddleSizer; - bMiddleSizer = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bTracksSizer; + bTracksSizer = new wxBoxSizer( wxVERTICAL ); wxString m_DeleteBadTracksChoices[] = { _("Keep"), _("Delete") }; int m_DeleteBadTracksNChoices = sizeof( m_DeleteBadTracksChoices ) / sizeof( wxString ); @@ -58,7 +64,7 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w m_DeleteBadTracks->SetSelection( 0 ); m_DeleteBadTracks->SetToolTip( _("Keep or delete bad tracks after a netlist change") ); - bMiddleSizer->Add( m_DeleteBadTracks, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + bTracksSizer->Add( m_DeleteBadTracks, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); wxString m_RemoveExtraFootprintsCtrlChoices[] = { _("Keep"), _("Delete") }; int m_RemoveExtraFootprintsCtrlNChoices = sizeof( m_RemoveExtraFootprintsCtrlChoices ) / sizeof( wxString ); @@ -66,15 +72,37 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w m_RemoveExtraFootprintsCtrl->SetSelection( 0 ); m_RemoveExtraFootprintsCtrl->SetToolTip( _("Remove footprints found on the Board but not in netlist\nNote: only not locked footprints will be removed") ); - bMiddleSizer->Add( m_RemoveExtraFootprintsCtrl, 0, wxALL|wxEXPAND, 5 ); + bTracksSizer->Add( m_RemoveExtraFootprintsCtrl, 0, wxALL|wxEXPAND, 5 ); - bUpperSizer->Add( bMiddleSizer, 1, wxEXPAND, 5 ); + bnetlistOptSizer->Add( bTracksSizer, 1, wxEXPAND, 5 ); + + + bleftSizer->Add( bnetlistOptSizer, 1, wxEXPAND, 5 ); + + wxBoxSizer* bCenterSizer; + bCenterSizer = new wxBoxSizer( wxVERTICAL ); + + m_checkDryRun = new wxCheckBox( this, wxID_ANY, _("Dry run. Only report changes in message panel"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkDryRun->SetToolTip( _("Dry Run:\nThe netlist is read, but no change is actually made on board.\nChanges are only reported in message panel, for info") ); + + bCenterSizer->Add( m_checkDryRun, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_checkBoxSilentMode = new wxCheckBox( this, wxID_ANY, _("Silent mode"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkBoxSilentMode->SetToolTip( _("Silent mode:\nDo not show the warning message before reading the netlist") ); + + bCenterSizer->Add( m_checkBoxSilentMode, 0, wxRIGHT|wxLEFT, 5 ); + + + bleftSizer->Add( bCenterSizer, 0, wxALL|wxEXPAND, 5 ); + + + bUpperSizer->Add( bleftSizer, 1, wxEXPAND, 5 ); wxBoxSizer* bRightSizerButtons; bRightSizerButtons = new wxBoxSizer( wxVERTICAL ); - m_buttonBrowse = new wxButton( this, ID_OPEN_NELIST, _("Open Netlist File"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonBrowse = new wxButton( this, ID_OPEN_NELIST, _("Browse Netlist Files"), wxDefaultPosition, wxDefaultSize, 0 ); bRightSizerButtons->Add( m_buttonBrowse, 0, wxEXPAND|wxALL, 5 ); m_buttonRead = new wxButton( this, ID_READ_NETLIST_FILE, _("Read Current Netlist"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -83,6 +111,9 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w bRightSizerButtons->Add( m_buttonRead, 0, wxEXPAND|wxALL, 5 ); + m_buttonClose = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); + bRightSizerButtons->Add( m_buttonClose, 0, wxALL|wxEXPAND, 5 ); + m_buttonFPTest = new wxButton( this, ID_TEST_NETLIST, _("Test Footprints"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonFPTest->SetToolTip( _("Read the current neltist file and list missing and extra footprints") ); @@ -96,33 +127,21 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w m_buttonSaveMessages = new wxButton( this, wxID_ANY, _("Save Messages to File"), wxDefaultPosition, wxDefaultSize, 0 ); bRightSizerButtons->Add( m_buttonSaveMessages, 0, wxALL|wxEXPAND, 5 ); - m_buttonClose = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); - bRightSizerButtons->Add( m_buttonClose, 0, wxALL|wxEXPAND, 5 ); + + bUpperSizer->Add( bRightSizerButtons, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 ); - bUpperSizer->Add( bRightSizerButtons, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxTOP, 5 ); - - - bMainSizer->Add( bUpperSizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 ); - - wxBoxSizer* bCenterSizer; - bCenterSizer = new wxBoxSizer( wxVERTICAL ); - - m_checkDryRun = new wxCheckBox( this, wxID_ANY, _("Only report changes in message panel"), wxDefaultPosition, wxDefaultSize, 0 ); - bCenterSizer->Add( m_checkDryRun, 0, wxALL, 5 ); - - - bMainSizer->Add( bCenterSizer, 0, wxALL|wxEXPAND, 5 ); - - m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bMainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); + bMainSizer->Add( bUpperSizer, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); wxBoxSizer* bLowerSizer; bLowerSizer = new wxBoxSizer( wxVERTICAL ); + m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bLowerSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); + m_staticTextNetfilename = new wxStaticText( this, wxID_ANY, _("Netlist File:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextNetfilename->Wrap( -1 ); - bLowerSizer->Add( m_staticTextNetfilename, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + bLowerSizer->Add( m_staticTextNetfilename, 0, wxRIGHT|wxLEFT, 5 ); m_NetlistFilenameCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_NetlistFilenameCtrl->SetMaxLength( 0 ); @@ -130,11 +149,11 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w m_staticText1 = new wxStaticText( this, wxID_ANY, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText1->Wrap( -1 ); - bLowerSizer->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + bLowerSizer->Add( m_staticText1, 0, wxRIGHT|wxLEFT, 5 ); m_MessageWindow = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CHARWRAP|wxTE_MULTILINE|wxTE_READONLY|wxTE_WORDWRAP ); m_MessageWindow->SetMaxLength( 0 ); - m_MessageWindow->SetMinSize( wxSize( -1,150 ) ); + m_MessageWindow->SetMinSize( wxSize( 300,150 ) ); bLowerSizer->Add( m_MessageWindow, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); @@ -147,30 +166,32 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w bMainSizer->Fit( this ); // Connect Events + m_checkBoxSilentMode->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnClickSilentMode ), NULL, this ); m_buttonBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnOpenNetlistClick ), NULL, this ); m_buttonRead->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnReadNetlistFileClick ), NULL, this ); m_buttonRead->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_NETLIST_FBP::OnUpdateUIValidNetlistFile ), NULL, this ); + m_buttonClose->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnCancelClick ), NULL, this ); m_buttonFPTest->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnTestFootprintsClick ), NULL, this ); m_buttonFPTest->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_NETLIST_FBP::OnUpdateUIValidNetlistFile ), NULL, this ); m_buttonRebild->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnCompileRatsnestClick ), NULL, this ); m_buttonRebild->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_NETLIST_FBP::OnUpdateUIValidNetlistFile ), NULL, this ); m_buttonSaveMessages->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnSaveMessagesToFile ), NULL, this ); m_buttonSaveMessages->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_NETLIST_FBP::OnUpdateUISaveMessagesToFile ), NULL, this ); - m_buttonClose->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnCancelClick ), NULL, this ); } DIALOG_NETLIST_FBP::~DIALOG_NETLIST_FBP() { // Disconnect Events + m_checkBoxSilentMode->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnClickSilentMode ), NULL, this ); m_buttonBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnOpenNetlistClick ), NULL, this ); m_buttonRead->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnReadNetlistFileClick ), NULL, this ); m_buttonRead->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_NETLIST_FBP::OnUpdateUIValidNetlistFile ), NULL, this ); + m_buttonClose->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnCancelClick ), NULL, this ); m_buttonFPTest->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnTestFootprintsClick ), NULL, this ); m_buttonFPTest->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_NETLIST_FBP::OnUpdateUIValidNetlistFile ), NULL, this ); m_buttonRebild->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnCompileRatsnestClick ), NULL, this ); m_buttonRebild->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_NETLIST_FBP::OnUpdateUIValidNetlistFile ), NULL, this ); m_buttonSaveMessages->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnSaveMessagesToFile ), NULL, this ); m_buttonSaveMessages->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_NETLIST_FBP::OnUpdateUISaveMessagesToFile ), NULL, this ); - m_buttonClose->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_NETLIST_FBP::OnCancelClick ), NULL, this ); } diff --git a/pcbnew/dialogs/dialog_netlist_fbp.fbp b/pcbnew/dialogs/dialog_netlist_fbp.fbp index 2d51da36b1..be1ecef1b8 100644 --- a/pcbnew/dialogs/dialog_netlist_fbp.fbp +++ b/pcbnew/dialogs/dialog_netlist_fbp.fbp @@ -93,7 +93,7 @@ none 5 - wxEXPAND|wxLEFT|wxRIGHT|wxTOP + wxEXPAND|wxRIGHT|wxLEFT 0 @@ -106,475 +106,684 @@ 1 - bLeftSizer + bleftSizer wxVERTICAL none 5 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Reference" "Timestamp" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Module Selection - 1 - - 0 - - - 0 + wxEXPAND + 1 + - 1 - m_Select_By_Timestamp - 1 - - - protected - 1 - - Resizable - 0 - 1 - - wxRA_SPECIFY_COLS - - 0 - Select how footprints are recognized: by their reference (U1, R3...) (normal setting) or their time stamp (special setting after a full schematic reannotation) - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "From netlist" "From separate .cmp file" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Module Name Source - 1 - - 0 - - - 0 - - 1 - m_cmpNameSourceOpt - 1 - - - protected - 1 - - Resizable - 0 - 1 - - wxRA_SPECIFY_COLS - - 0 - Source of footprints names for component: - the netlist (if you have filled the footprint field of each component in schematic) - the .cmp file created by CvPcb - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Keep" "Change" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Exchange Module - 1 - - 0 - - - 0 - - 1 - m_ChangeExistingFootprintCtrl - 1 - - - protected - 1 - - Resizable - 0 - 1 - - wxRA_SPECIFY_COLS - - 0 - Keep or change an existing footprint when the netlist gives a different footprint - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 1 - - - bMiddleSizer - wxVERTICAL - none - - 5 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Keep" "Delete" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Unconnected Tracks - 1 - - 0 - - - 0 - - 1 - m_DeleteBadTracks - 1 - - - protected - 1 - - Resizable - 0 - 1 - - wxRA_SPECIFY_COLS - - 0 - Keep or delete bad tracks after a netlist change - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - + bnetlistOptSizer + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + + bmodulesOptSizer + wxVERTICAL + none + + 5 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Reference" "Timestamp" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Module Selection + 1 + + 0 + + + 0 + + 1 + m_Select_By_Timestamp + 1 + + + protected + 1 + + Resizable + 0 + 1 + + wxRA_SPECIFY_COLS + + 0 + Select how footprints are recognized: by their reference (U1, R3...) (normal setting) or their time stamp (special setting after a full schematic reannotation) + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "From netlist" "From separate .cmp file" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Module Name Source + 1 + + 0 + + + 0 + + 1 + m_cmpNameSourceOpt + 1 + + + protected + 1 + + Resizable + 0 + 1 + + wxRA_SPECIFY_COLS + + 0 + Source of footprints names for component: - the netlist (if you have filled the footprint field of each component in schematic) - the .cmp file created by CvPcb + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Keep" "Change" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Exchange Module + 1 + + 0 + + + 0 + + 1 + m_ChangeExistingFootprintCtrl + 1 + + + protected + 1 + + Resizable + 0 + 1 + + wxRA_SPECIFY_COLS + + 0 + Keep or change an existing footprint when the netlist gives a different footprint + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + bTracksSizer + wxVERTICAL + none + + 5 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Keep" "Delete" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Unconnected Tracks + 1 + + 0 + + + 0 + + 1 + m_DeleteBadTracks + 1 + + + protected + 1 + + Resizable + 0 + 1 + + wxRA_SPECIFY_COLS + + 0 + Keep or delete bad tracks after a netlist change + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Keep" "Delete" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Extra Footprints + 1 + + 0 + + + 0 + + 1 + m_RemoveExtraFootprintsCtrl + 1 + + + protected + 1 + + Resizable + 0 + 1 + + wxRA_SPECIFY_COLS + + 0 + Remove footprints found on the Board but not in netlist Note: only not locked footprints will be removed + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxALL|wxEXPAND 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Keep" "Delete" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Extra Footprints - 1 - - 0 - - - 0 + - 1 - m_RemoveExtraFootprintsCtrl - 1 - - - protected - 1 - - Resizable - 0 - 1 - - wxRA_SPECIFY_COLS - - 0 - Remove footprints found on the Board but not in netlist Note: only not locked footprints will be removed - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - + bCenterSizer + wxVERTICAL + none + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Dry run. Only report changes in message panel + + 0 + + + 0 + + 1 + m_checkDryRun + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Dry Run: The netlist is read, but no change is actually made on board. Changes are only reported in message panel, for info + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Silent mode + + 0 + + + 0 + + 1 + m_checkBoxSilentMode + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Silent mode: Do not show the warning message before reading the netlist + + wxFILTER_NONE + wxDefaultValidator + + + + + + OnClickSilentMode + + + + + + + + + + + + + + + + + + + + + + + + 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxTOP + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT 0 @@ -614,7 +823,7 @@ 0 0 ID_OPEN_NELIST - Open Netlist File + Browse Netlist Files 0 @@ -757,6 +966,94 @@ OnUpdateUIValidNetlistFile + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_CANCEL + Close + + 0 + + + 0 + + 1 + m_buttonClose + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnCancelClick + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxEXPAND|wxALL @@ -1021,112 +1318,24 @@ OnUpdateUISaveMessagesToFile - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_CANCEL - Close - - 0 - - - 0 - - 1 - m_buttonClose - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnCancelClick - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 + wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT + 1 - bCenterSizer + bLowerSizer wxVERTICAL none 5 - wxALL + wxEXPAND | wxALL 0 - + 1 1 1 @@ -1140,7 +1349,6 @@ 1 0 - 0 1 1 @@ -1155,7 +1363,6 @@ 0 0 wxID_ANY - Only report changes in message panel 0 @@ -1163,7 +1370,7 @@ 0 1 - m_checkDryRun + m_staticline1 1 @@ -1173,19 +1380,14 @@ Resizable 1 - + wxLI_HORIZONTAL 0 - - wxFILTER_NONE - wxDefaultValidator - - @@ -1210,101 +1412,9 @@ - - - - 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_staticline1 - 1 - - - protected - 1 - - Resizable - 1 - - wxLI_HORIZONTAL - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT - 1 - - - bLowerSizer - wxVERTICAL - none 5 - wxTOP|wxRIGHT|wxLEFT + wxRIGHT|wxLEFT 0 1 @@ -1478,7 +1588,7 @@ 5 - wxTOP|wxRIGHT|wxLEFT + wxRIGHT|wxLEFT 0 1 @@ -1597,7 +1707,7 @@ 0 0 - -1,150 + 300,150 1 m_MessageWindow 1 diff --git a/pcbnew/dialogs/dialog_netlist_fbp.h b/pcbnew/dialogs/dialog_netlist_fbp.h index 39cb064223..36492e80ca 100644 --- a/pcbnew/dialogs/dialog_netlist_fbp.h +++ b/pcbnew/dialogs/dialog_netlist_fbp.h @@ -21,8 +21,8 @@ class DIALOG_SHIM; #include #include #include -#include #include +#include #include #include #include @@ -51,13 +51,14 @@ class DIALOG_NETLIST_FBP : public DIALOG_SHIM wxRadioBox* m_ChangeExistingFootprintCtrl; wxRadioBox* m_DeleteBadTracks; wxRadioBox* m_RemoveExtraFootprintsCtrl; + wxCheckBox* m_checkDryRun; + wxCheckBox* m_checkBoxSilentMode; wxButton* m_buttonBrowse; wxButton* m_buttonRead; + wxButton* m_buttonClose; wxButton* m_buttonFPTest; wxButton* m_buttonRebild; wxButton* m_buttonSaveMessages; - wxButton* m_buttonClose; - wxCheckBox* m_checkDryRun; wxStaticLine* m_staticline1; wxStaticText* m_staticTextNetfilename; wxTextCtrl* m_NetlistFilenameCtrl; @@ -65,14 +66,15 @@ class DIALOG_NETLIST_FBP : public DIALOG_SHIM wxTextCtrl* m_MessageWindow; // Virtual event handlers, overide them in your derived class + virtual void OnClickSilentMode( wxCommandEvent& event ) { event.Skip(); } virtual void OnOpenNetlistClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnReadNetlistFileClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnUpdateUIValidNetlistFile( wxUpdateUIEvent& event ) { event.Skip(); } + virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnTestFootprintsClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnCompileRatsnestClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnSaveMessagesToFile( wxCommandEvent& event ) { event.Skip(); } virtual void OnUpdateUISaveMessagesToFile( wxUpdateUIEvent& event ) { event.Skip(); } - virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } public: From 2b25beb074470cdd3d1d655729ccecfbac304f74 Mon Sep 17 00:00:00 2001 From: Alexander Lunev Date: Thu, 20 Jun 2013 15:53:23 -0500 Subject: [PATCH 31/50] Fix an issue with setting the Reference and Value of a module. The bug was revealed on re-opening the saved version of a file imported by pcad2kicadpcb. --- pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp index 3e7c54a934..45c8853590 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp @@ -540,7 +540,7 @@ void PCB_MODULE::AddToBoard() TEXTE_MODULE* val_text = &module->Value(); val_text->SetText( m_value.text ); - val_text->SetType( TEXTE_MODULE::TEXT_is_REFERENCE ); + val_text->SetType( TEXTE_MODULE::TEXT_is_VALUE ); val_text->SetPos0( wxPoint( m_value.correctedPositionX, m_value.correctedPositionY ) ); val_text->SetSize( wxSize( KiROUND( m_value.textHeight / 2 ), From 1f9ee2e45e607137daf7bcdd87f1bb26e9894aa3 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Sun, 23 Jun 2013 14:18:33 -0500 Subject: [PATCH 32/50] Support for 'initial single line comments' in the pretty footprint format. This is limited to round tripping the lines of commented text in the loading and saving to disk through PCBIO::Format() and PCBIO::Parse(). No editing of the comments is given. --- common/dsnlexer.cpp | 36 +++++++++++++++++++++++++++++++----- include/dsnlexer.h | 23 ++++++++++++++++++----- pcbnew/class_module.cpp | 9 ++++++--- pcbnew/class_module.h | 27 +++++++++++++++++++++++++++ pcbnew/kicad_plugin.cpp | 8 ++++++++ pcbnew/pcb_parser.cpp | 19 +++++++++++++------ pcbnew/pcb_parser.h | 30 +++++++++++++++++++----------- 7 files changed, 122 insertions(+), 30 deletions(-) diff --git a/common/dsnlexer.cpp b/common/dsnlexer.cpp index d9ed3e719b..769e278797 100644 --- a/common/dsnlexer.cpp +++ b/common/dsnlexer.cpp @@ -50,7 +50,7 @@ static int compare( const void* a1, const void* a2 ) //------------------------------------------------------------------ -void DSNLEXER::init() +inline void DSNLEXER::init() { curTok = DSN_NONE; prevTok = DSN_NONE; @@ -502,10 +502,16 @@ L_read: { if( commentsAreTokens ) { - // save the entire line, including new line as the current token. - // the '#' character may not be at offset zero. - curText = start; // entire line is the token - cur = start; // ensure a good curOffset below + // Grab the entire current line [excluding end of line char(s)] as the + // current token. The '#' character may not be at offset zero. + + while( limit[-1] == '\n' || limit[-1] == '\r' ) + --limit; + + curText.clear(); + curText.append( start, limit ); + + cur = start; // ensure a good curOffset below curTok = DSN_COMMENT; head = limit; // do a readLine() on next call in here. goto exit; @@ -739,3 +745,23 @@ exit: // single point of exit, no returns elsewhere please. return curTok; } + +wxArrayString* DSNLEXER::ReadCommentLines() throw( IO_ERROR ) +{ + wxArrayString* ret = 0; + bool cmt_setting = SetCommentsAreTokens( true ); + int tok = NextTok(); + + if( tok == DSN_COMMENT ) + { + ret = new wxArrayString(); + + do + ret->Add( FromUTF8() ); + while( ( tok = NextTok() ) == DSN_COMMENT ); + } + + SetCommentsAreTokens( cmt_setting ); + + return ret; +} diff --git a/include/dsnlexer.h b/include/dsnlexer.h index 35da414b6a..32721226fb 100644 --- a/include/dsnlexer.h +++ b/include/dsnlexer.h @@ -101,12 +101,12 @@ protected: bool commentsAreTokens; ///< true if should return comments as tokens - int prevTok; ///< curTok from previous NextTok() call. - int curOffset; ///< offset within current line of the current token + int prevTok; ///< curTok from previous NextTok() call. + int curOffset; ///< offset within current line of the current token - int curTok; ///< the current token obtained on last NextTok() - std::string curText; ///< the text of the current token - std::string lowercase; ///< a scratch buf holding token in lowercase + int curTok; ///< the current token obtained on last NextTok() + std::string curText; ///< the text of the current token + std::string lowercase; ///< a scratch buf holding token in lowercase const KEYWORD* keywords; unsigned keywordCount; @@ -368,6 +368,19 @@ public: return old; } + /** + * Function ReadCommentLines + * checks the next sequence of tokens and reads them into a wxArrayString + * if they are comments. Reading continues until a non-comment token is + * encountered, and such last read token remains as CurTok() and as CurText(). + * No push back or "un get" mechanism is used for this support. Upon return + * you simply avoid calling NextTok() for the next token, but rather CurTok(). + * + * @return wxArrayString* - heap allocated block of comments, or NULL if none; + * caller owns the allocation and must delete if not NULL. + */ + wxArrayString* ReadCommentLines() throw( IO_ERROR ); + /** * Function IsSymbol * tests a token to see if it is a symbol. This means it cannot be a diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index b0115bb119..07284f83f8 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -53,7 +53,8 @@ MODULE::MODULE( BOARD* parent ) : - BOARD_ITEM( (BOARD_ITEM*) parent, PCB_MODULE_T ) + BOARD_ITEM( (BOARD_ITEM*) parent, PCB_MODULE_T ), + m_initial_comments( 0 ) { m_Attributs = MOD_DEFAULT; m_Layer = LAYER_N_FRONT; @@ -82,7 +83,8 @@ MODULE::MODULE( BOARD* parent ) : MODULE::MODULE( const MODULE& aModule ) : - BOARD_ITEM( aModule ) + BOARD_ITEM( aModule ), + m_initial_comments( 0 ) { m_Pos = aModule.m_Pos; m_LibRef = aModule.m_LibRef; @@ -171,6 +173,7 @@ MODULE::~MODULE() { delete m_Reference; delete m_Value; + delete m_initial_comments; } @@ -185,7 +188,7 @@ void MODULE::DrawAncre( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, if( GetBoard()->IsElementVisible( ANCHOR_VISIBLE ) ) { - GRDrawAnchor( panel->GetClipBox(), DC, m_Pos.x, m_Pos.y, + GRDrawAnchor( panel->GetClipBox(), DC, m_Pos.x, m_Pos.y, dim_ancre, g_ColorsSettings.GetItemColor( ANCHOR_VISIBLE ) ); } diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index cc68cab05c..e78f214bc4 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -473,6 +473,30 @@ public: */ static const wxChar* ReturnStringLibNameInvalidChars( bool aUserReadable ); + /** + * Function SetInitialComments + * takes ownership of caller's heap allocated aInitialComments block. The comments + * are single line strings already containing the s-expression comments with + * optional leading whitespace and then a '#' character followed by optional + * single line text (text with no line endings, not even one). + * This block of single line comments will be output upfront of any generated + * s-expression text in the PCBIO::Format() function. + *

+ * Note that a block of single line comments constitutes a multiline block of + * single line comments. That is, the block is made of consecutive single line + * comments. + * @param aInitialComments is a heap allocated wxArrayString or NULL, which the caller + * gives up ownership of over to this MODULE. + */ + void SetInitialComments( wxArrayString* aInitialComments ) + { + delete m_initial_comments; + m_initial_comments = aInitialComments; + } + + /// Return the initial comments block or NULL if none, without transfer of ownership. + const wxArrayString* GetInitialComments() { return m_initial_comments; } + #if defined(DEBUG) virtual void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override #endif @@ -512,6 +536,9 @@ private: int m_LocalSolderPasteMargin; ///< Solder paste margin absolute value double m_LocalSolderPasteMarginRatio; ///< Solder mask margin ratio ///< value of pad size + + wxArrayString* m_initial_comments; ///< leading s-expression comments in the module, + ///< lazily allocated only if needed for speed }; #endif // MODULE_H_ diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 181da820b7..33cd1a0bdf 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -881,6 +881,14 @@ void PCB_IO::format( PCB_TARGET* aTarget, int aNestLevel ) const void PCB_IO::format( MODULE* aModule, int aNestLevel ) const throw( IO_ERROR ) { + const wxArrayString* initial_comments = aModule->GetInitialComments(); + + if( initial_comments ) + { + for( unsigned i=0; iGetCount(); ++i ) + m_out->Print( aNestLevel, "%s\n", TO_UTF8( (*initial_comments)[i] ) ); + } + m_out->Print( aNestLevel, "(module %s", m_out->Quotew( aModule->GetLibRef() ).c_str() ); if( aModule->IsLocked() ) diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index efcb0f49ad..6de537f87e 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -328,11 +328,16 @@ S3D_MASTER* PCB_PARSER::parse3DModel() throw( PARSE_ERROR ) BOARD_ITEM* PCB_PARSER::Parse() throw( IO_ERROR, PARSE_ERROR ) { - T token; - BOARD_ITEM* item; - LOCALE_IO toggle; // toggles on, then off, the C locale. + T token; + BOARD_ITEM* item; + LOCALE_IO toggle; - token = NextTok(); + // MODULEs can be prefixed with an initial block of single line comments and these + // are kept for Format() so they round trip in s-expression form. BOARDs might + // eventually do the same, but currently do not. + std::auto_ptr initial_comments( ReadCommentLines() ); + + token = CurTok(); if( token != T_LEFT ) Expecting( T_LEFT ); @@ -347,7 +352,7 @@ BOARD_ITEM* PCB_PARSER::Parse() throw( IO_ERROR, PARSE_ERROR ) break; case T_module: - item = (BOARD_ITEM*) parseMODULE(); + item = (BOARD_ITEM*) parseMODULE( initial_comments.release() ); break; default: @@ -1514,7 +1519,7 @@ DIMENSION* PCB_PARSER::parseDIMENSION() throw( IO_ERROR, PARSE_ERROR ) } -MODULE* PCB_PARSER::parseMODULE() throw( IO_ERROR, PARSE_ERROR ) +MODULE* PCB_PARSER::parseMODULE( wxArrayString* aInitialComments ) throw( IO_ERROR, PARSE_ERROR ) { wxCHECK_MSG( CurTok() == T_module, NULL, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as MODULE." ) ); @@ -1524,6 +1529,8 @@ MODULE* PCB_PARSER::parseMODULE() throw( IO_ERROR, PARSE_ERROR ) auto_ptr< MODULE > module( new MODULE( m_board ) ); + module->SetInitialComments( aInitialComments ); + NeedSYMBOLorNUMBER(); module->SetLibRef( FromUTF8() ); diff --git a/pcbnew/pcb_parser.h b/pcbnew/pcb_parser.h index 92574af4e4..e679a356f3 100644 --- a/pcbnew/pcb_parser.h +++ b/pcbnew/pcb_parser.h @@ -82,18 +82,26 @@ class PCB_PARSER : public PCB_LEXER void parseSetup() throw( IO_ERROR, PARSE_ERROR ); void parseNETINFO_ITEM() throw( IO_ERROR, PARSE_ERROR ); void parseNETCLASS() throw( IO_ERROR, PARSE_ERROR ); - DRAWSEGMENT* parseDRAWSEGMENT() throw( IO_ERROR, PARSE_ERROR ); - TEXTE_PCB* parseTEXTE_PCB() throw( IO_ERROR, PARSE_ERROR ); - DIMENSION* parseDIMENSION() throw( IO_ERROR, PARSE_ERROR ); - MODULE* parseMODULE() throw( IO_ERROR, PARSE_ERROR ); - TEXTE_MODULE* parseTEXTE_MODULE() throw( IO_ERROR, PARSE_ERROR ); - EDGE_MODULE* parseEDGE_MODULE() throw( IO_ERROR, PARSE_ERROR ); - D_PAD* parseD_PAD() throw( IO_ERROR, PARSE_ERROR ); - TRACK* parseTRACK() throw( IO_ERROR, PARSE_ERROR ); - SEGVIA* parseSEGVIA() throw( IO_ERROR, PARSE_ERROR ); + + DRAWSEGMENT* parseDRAWSEGMENT() throw( IO_ERROR, PARSE_ERROR ); + TEXTE_PCB* parseTEXTE_PCB() throw( IO_ERROR, PARSE_ERROR ); + DIMENSION* parseDIMENSION() throw( IO_ERROR, PARSE_ERROR ); + + /** + * Function parseModule + * @param aInitialComments may be a pointer to a heap allocated initial comment block + * or NULL. If not NULL, then caller has given ownership of a wxArrayString to + * this function and care must be taken to delete it even on exception. + */ + MODULE* parseMODULE( wxArrayString* aInitialComments = 0 ) throw( IO_ERROR, PARSE_ERROR ); + TEXTE_MODULE* parseTEXTE_MODULE() throw( IO_ERROR, PARSE_ERROR ); + EDGE_MODULE* parseEDGE_MODULE() throw( IO_ERROR, PARSE_ERROR ); + D_PAD* parseD_PAD() throw( IO_ERROR, PARSE_ERROR ); + TRACK* parseTRACK() throw( IO_ERROR, PARSE_ERROR ); + SEGVIA* parseSEGVIA() throw( IO_ERROR, PARSE_ERROR ); ZONE_CONTAINER* parseZONE_CONTAINER() throw( IO_ERROR, PARSE_ERROR ); - PCB_TARGET* parsePCB_TARGET() throw( IO_ERROR, PARSE_ERROR ); - BOARD* parseBOARD() throw( IO_ERROR, PARSE_ERROR ); + PCB_TARGET* parsePCB_TARGET() throw( IO_ERROR, PARSE_ERROR ); + BOARD* parseBOARD() throw( IO_ERROR, PARSE_ERROR ); /** From 9d86345ea5c032b2574003f395ebbcdf42abf02f Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Sun, 23 Jun 2013 17:41:35 -0500 Subject: [PATCH 33/50] fix copy constructor with new MODULE::m_initial_comments member handling --- pcbnew/class_module.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 07284f83f8..f5b29906a6 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -83,8 +83,7 @@ MODULE::MODULE( BOARD* parent ) : MODULE::MODULE( const MODULE& aModule ) : - BOARD_ITEM( aModule ), - m_initial_comments( 0 ) + BOARD_ITEM( aModule ) { m_Pos = aModule.m_Pos; m_LibRef = aModule.m_LibRef; @@ -166,6 +165,9 @@ MODULE::MODULE( const MODULE& aModule ) : // Ensure auxiliary data is up to date CalculateBoundingBox(); + + m_initial_comments = aModule.m_initial_comments ? + new wxArrayString( *aModule.m_initial_comments ) : 0; } From 4fad477d1a70ce27522c732779b847df8988b0dd Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Mon, 24 Jun 2013 00:30:22 -0500 Subject: [PATCH 34/50] add CTL_OMIT_INITIAL_COMMENTS and CTL_FOR_BOARD PCB_IO::Format()ing flags --- pcbnew/kicad_plugin.cpp | 25 +++++++++++++++++-------- pcbnew/kicad_plugin.h | 9 ++++++--- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 33cd1a0bdf..825a3383da 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -331,7 +331,9 @@ void PCB_IO::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProper { LOCALE_IO toggle; // toggles on, then off, the C locale. - m_board = aBoard; + init( aProperties ); + + m_board = aBoard; // after init() FILE_OUTPUTFORMATTER formatter( aFileName ); @@ -881,12 +883,17 @@ void PCB_IO::format( PCB_TARGET* aTarget, int aNestLevel ) const void PCB_IO::format( MODULE* aModule, int aNestLevel ) const throw( IO_ERROR ) { - const wxArrayString* initial_comments = aModule->GetInitialComments(); - - if( initial_comments ) + if( !( m_ctl & CTL_OMIT_INITIAL_COMMENTS ) ) { - for( unsigned i=0; iGetCount(); ++i ) - m_out->Print( aNestLevel, "%s\n", TO_UTF8( (*initial_comments)[i] ) ); + const wxArrayString* initial_comments = aModule->GetInitialComments(); + + if( initial_comments ) + { + for( unsigned i=0; iGetCount(); ++i ) + m_out->Print( aNestLevel, "%s\n", TO_UTF8( (*initial_comments)[i] ) ); + + m_out->Print( 0, "\n" ); // improve readability? + } } m_out->Print( aNestLevel, "(module %s", m_out->Quotew( aModule->GetLibRef() ).c_str() ); @@ -1073,7 +1080,7 @@ void PCB_IO::formatLayers( LAYER_MSK aLayerMask, int aNestLevel ) const { if( aLayerMask & GetLayerMask( layer ) ) { - if( m_board && !(m_ctl & CTL_STD_LAYER_NAMES) ) + if( m_board && !( m_ctl & CTL_STD_LAYER_NAMES ) ) layerName = m_board->GetLayerName( layer ); else // I am being called from FootprintSave() @@ -1558,7 +1565,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const PCB_IO::PCB_IO() : m_cache( 0 ), - m_ctl( 0 ), + m_ctl( CTL_FOR_BOARD ), // expecting to OUTPUTFORMAT into BOARD files. m_parser( new PCB_PARSER() ) { init( 0 ); @@ -1587,6 +1594,8 @@ BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* { FILE_LINE_READER reader( aFileName ); + init( aProperties ); + m_parser->SetLineReader( &reader ); m_parser->SetBoard( aAppendToMe ); diff --git a/pcbnew/kicad_plugin.h b/pcbnew/kicad_plugin.h index aa2b297ad4..3e4fbae982 100644 --- a/pcbnew/kicad_plugin.h +++ b/pcbnew/kicad_plugin.h @@ -37,12 +37,11 @@ class PCB_PARSER; /// Current s-expression file format version. 2 was the last legacy format version. #define SEXPR_BOARD_FILE_VERSION 3 -/// Use English Standard layer names -#define CTL_STD_LAYER_NAMES (1 << 0) +#define CTL_STD_LAYER_NAMES (1 << 0) ///< Use English Standard layer names #define CTL_OMIT_NETS (1 << 1) - #define CTL_OMIT_TSTAMPS (1 << 2) +#define CTL_OMIT_INITIAL_COMMENTS (1 << 3) ///< omit MODULE initial comments // common combinations of the above: @@ -52,6 +51,10 @@ class PCB_PARSER; /// 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) +/// The zero arg constructor when PCB_IO is used for PLUGIN::Load() and PLUGIN::Save()ing +/// a BOARD file underneath IO_MGR. +#define CTL_FOR_BOARD (CTL_OMIT_INITIAL_COMMENTS) + /** * Class PCB_IO * is a PLUGIN derivation for saving and loading Pcbnew s-expression formatted files. From e513380a85190f075ab49e29230bb604aa06bd86 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Tue, 25 Jun 2013 10:56:12 -0500 Subject: [PATCH 35/50] Add script to make a footprint library table from the KiCad Bazaar library repository, either in s-expr or CSV format. Add also the generation of such tables as of today. --- pcbnew/class_module.h | 2 +- scripts/make_global_table.sh | 68 ++++++++++++++++++++++++++++++++ template/fp_global_table | 76 ++++++++++++++++++++++++++++++++++++ template/fp_global_table.csv | 75 +++++++++++++++++++++++++++++++++++ 4 files changed, 220 insertions(+), 1 deletion(-) create mode 100755 scripts/make_global_table.sh create mode 100644 template/fp_global_table create mode 100644 template/fp_global_table.csv diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index e78f214bc4..9730bd7caf 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -495,7 +495,7 @@ public: } /// Return the initial comments block or NULL if none, without transfer of ownership. - const wxArrayString* GetInitialComments() { return m_initial_comments; } + const wxArrayString* GetInitialComments() const { return m_initial_comments; } #if defined(DEBUG) virtual void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override diff --git a/scripts/make_global_table.sh b/scripts/make_global_table.sh new file mode 100755 index 0000000000..d82c1f4368 --- /dev/null +++ b/scripts/make_global_table.sh @@ -0,0 +1,68 @@ +#!/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/template/fp_global_table b/template/fp_global_table new file mode 100644 index 0000000000..263c1c9c7f --- /dev/null +++ b/template/fp_global_table @@ -0,0 +1,76 @@ +# FP LIB TABLE: made from KiCad's Bazaar 'library' repository on 2013-06-25 +(fp_lib_table + (lib (name Allegro_ACS754_ACS755_ACS756_HallCurrentSensor_RevA)(type Legacy)(uri ${KISYSMOD}/Allegro_ACS754_ACS755_ACS756_HallCurrentSensor_RevA.mod)(options "")(descr "")) + (lib (name capacitors)(type Legacy)(uri ${KISYSMOD}/capacitors.mod)(options "")(descr "")) + (lib (name Capacitors_SMD_RevA)(type Legacy)(uri ${KISYSMOD}/Capacitors_SMD_RevA.mod)(options "")(descr "")) + (lib (name connect)(type Legacy)(uri ${KISYSMOD}/connect.mod)(options "")(descr "")) + (lib (name connectors_molex_serial_53047-A123)(type Legacy)(uri ${KISYSMOD}/connectors_molex_serial_53047-A123.mod)(options "")(descr "")) + (lib (name Crystals_RevB_20Apr2013)(type Legacy)(uri ${KISYSMOD}/Crystals_RevB_20Apr2013.mod)(options "")(descr "")) + (lib (name DCDC-ACDC-Converter_RevC_20Jul2012)(type Legacy)(uri ${KISYSMOD}/DCDC-ACDC-Converter_RevC_20Jul2012.mod)(options "")(descr "")) + (lib (name Dioden_SMD_RevA_31May2013)(type Legacy)(uri ${KISYSMOD}/Dioden_SMD_RevA_31May2013.mod)(options "")(descr "")) + (lib (name Dioden_ThroughHole_RevC)(type Legacy)(uri ${KISYSMOD}/Dioden_ThroughHole_RevC.mod)(options "")(descr "")) + (lib (name dip_sockets)(type Legacy)(uri ${KISYSMOD}/dip_sockets.mod)(options "")(descr "")) + (lib (name discret)(type Legacy)(uri ${KISYSMOD}/discret.mod)(options "")(descr "")) + (lib (name display)(type Legacy)(uri ${KISYSMOD}/display.mod)(options "")(descr "")) + (lib (name divers)(type Legacy)(uri ${KISYSMOD}/divers.mod)(options "")(descr "")) + (lib (name Elko_ThroughHole_RevB-3_30Dec2011)(type Legacy)(uri ${KISYSMOD}/Elko_ThroughHole_RevB-3_30Dec2011.mod)(options "")(descr "")) + (lib (name EuroBoardoutline_RevC)(type Legacy)(uri ${KISYSMOD}/EuroBoardoutline_RevC.mod)(options "")(descr "")) + (lib (name Fiducials_RevC_04Aug2012)(type Legacy)(uri ${KISYSMOD}/Fiducials_RevC_04Aug2012.mod)(options "")(descr "")) + (lib (name Footprint-Symbols_RevD_28Aug2012)(type Legacy)(uri ${KISYSMOD}/Footprint-Symbols_RevD_28Aug2012.mod)(options "")(descr "")) + (lib (name FuseholderAndFuses_RevD_28Aug2012)(type Legacy)(uri ${KISYSMOD}/FuseholderAndFuses_RevD_28Aug2012.mod)(options "")(descr "")) + (lib (name Heatsinks_RevC)(type Legacy)(uri ${KISYSMOD}/Heatsinks_RevC.mod)(options "")(descr "")) + (lib (name inductors)(type Legacy)(uri ${KISYSMOD}/inductors.mod)(options "")(descr "")) + (lib (name IR-directFET_Packages_RevB)(type Legacy)(uri ${KISYSMOD}/IR-directFET_Packages_RevB.mod)(options "")(descr "")) + (lib (name iut)(type Legacy)(uri ${KISYSMOD}/iut.mod)(options "")(descr "")) + (lib (name Label_RevA_21Mar2011)(type Legacy)(uri ${KISYSMOD}/Label_RevA_21Mar2011.mod)(options "")(descr "")) + (lib (name led)(type Legacy)(uri ${KISYSMOD}/led.mod)(options "")(descr "")) + (lib (name libcms)(type Legacy)(uri ${KISYSMOD}/libcms.mod)(options "")(descr "")) + (lib (name Measurement_Point_RevA)(type Legacy)(uri ${KISYSMOD}/Measurement_Point_RevA.mod)(options "")(descr "")) + (lib (name Measurement-Scala_RevA)(type Legacy)(uri ${KISYSMOD}/Measurement-Scala_RevA.mod)(options "")(descr "")) + (lib (name Mechanical_Socket-Plug_DIN41612-Stuff_RevA)(type Legacy)(uri ${KISYSMOD}/Mechanical_Socket-Plug_DIN41612-Stuff_RevA.mod)(options "")(descr "")) + (lib (name MiniUniversalMate-N-LokSockets_13Aug2012)(type Legacy)(uri ${KISYSMOD}/MiniUniversalMate-N-LokSockets_13Aug2012.mod)(options "")(descr "")) + (lib (name MountingHole_RevA)(type Legacy)(uri ${KISYSMOD}/MountingHole_RevA.mod)(options "")(descr "")) + (lib (name muonde)(type Legacy)(uri ${KISYSMOD}/muonde.mod)(options "")(descr "")) + (lib (name Neosid_Air-Coil_SML_HAMxx31A_HDMxx31A_RevA_25Apr2012)(type Legacy)(uri ${KISYSMOD}/Neosid_Air-Coil_SML_HAMxx31A_HDMxx31A_RevA_25Apr2012.mod)(options "")(descr "")) + (lib (name Neosid_Filter_HF-Coil_25Apr2012)(type Legacy)(uri ${KISYSMOD}/Neosid_Filter_HF-Coil_25Apr2012.mod)(options "")(descr "")) + (lib (name Neosid_Inductor_21Apr2012)(type Legacy)(uri ${KISYSMOD}/Neosid_Inductor_21Apr2012.mod)(options "")(descr "")) + (lib (name NF-Transformer_ETAL_RevA_28Aug2012)(type Legacy)(uri ${KISYSMOD}/NF-Transformer_ETAL_RevA_28Aug2012.mod)(options "")(descr "")) + (lib (name Oddities_RevA_10Mar2011)(type Legacy)(uri ${KISYSMOD}/Oddities_RevA_10Mar2011.mod)(options "")(descr "")) + (lib (name Opto-Devices_RevC_03Oct2012)(type Legacy)(uri ${KISYSMOD}/Opto-Devices_RevC_03Oct2012.mod)(options "")(descr "")) + (lib (name Oscillator-Modul_RevA)(type Legacy)(uri ${KISYSMOD}/Oscillator-Modul_RevA.mod)(options "")(descr "")) + (lib (name Pentawatt_RevB_30Apr2011)(type Legacy)(uri ${KISYSMOD}/Pentawatt_RevB_30Apr2011.mod)(options "")(descr "")) + (lib (name pga_sockets)(type Legacy)(uri ${KISYSMOD}/pga_sockets.mod)(options "")(descr "")) + (lib (name pin_array)(type Legacy)(uri ${KISYSMOD}/pin_array.mod)(options "")(descr "")) + (lib (name Potentiometer_RevB_02Aug2010)(type Legacy)(uri ${KISYSMOD}/Potentiometer_RevB_02Aug2010.mod)(options "")(descr "")) + (lib (name powerint)(type Legacy)(uri ${KISYSMOD}/powerint.mod)(options "")(descr "")) + (lib (name Printtrafo_CHK_RevA_04Aug2010)(type Legacy)(uri ${KISYSMOD}/Printtrafo_CHK_RevA_04Aug2010.mod)(options "")(descr "")) + (lib (name Relay_ThroughHole_RevB)(type Legacy)(uri ${KISYSMOD}/Relay_ThroughHole_RevB.mod)(options "")(descr "")) + (lib (name Resistor_SMD_RevA)(type Legacy)(uri ${KISYSMOD}/Resistor_SMD_RevA.mod)(options "")(descr "")) + (lib (name Resistor_ThroughHole_RevB_22Apr2011)(type Legacy)(uri ${KISYSMOD}/Resistor_ThroughHole_RevB_22Apr2011.mod)(options "")(descr "")) + (lib (name Resistor_Universal-Experimental_RevA)(type Legacy)(uri ${KISYSMOD}/Resistor_Universal-Experimental_RevA.mod)(options "")(descr "")) + (lib (name SI570_SI571_Oscillator_RevA_11Jun2012)(type Legacy)(uri ${KISYSMOD}/SI570_SI571_Oscillator_RevA_11Jun2012.mod)(options "")(descr "")) + (lib (name SIP9_Housing_14Jun2013)(type Legacy)(uri ${KISYSMOD}/SIP9_Housing_14Jun2013.mod)(options "")(descr "")) + (lib (name smd_capacitors)(type Legacy)(uri ${KISYSMOD}/smd_capacitors.mod)(options "")(descr "")) + (lib (name smd_crystal&oscillator)(type Legacy)(uri ${KISYSMOD}/smd_crystal&oscillator.mod)(options "")(descr "")) + (lib (name smd_resistors)(type Legacy)(uri ${KISYSMOD}/smd_resistors.mod)(options "")(descr "")) + (lib (name smd_soic_packages)(type Legacy)(uri ${KISYSMOD}/smd_soic_packages.mod)(options "")(descr "")) + (lib (name smd_ssop_packages)(type Legacy)(uri ${KISYSMOD}/smd_ssop_packages.mod)(options "")(descr "")) + (lib (name smd_transistors)(type Legacy)(uri ${KISYSMOD}/smd_transistors.mod)(options "")(descr "")) + (lib (name Socket_MOLEX-KK-System)(type Legacy)(uri ${KISYSMOD}/Socket_MOLEX-KK-System.mod)(options "")(descr "")) + (lib (name sockets)(type Legacy)(uri ${KISYSMOD}/sockets.mod)(options "")(descr "")) + (lib (name Socket_WAGO734_RevA)(type Legacy)(uri ${KISYSMOD}/Socket_WAGO734_RevA.mod)(options "")(descr "")) + (lib (name SOT126_SOT32_Housings_RevA_22Oct2012)(type Legacy)(uri ${KISYSMOD}/SOT126_SOT32_Housings_RevA_22Oct2012.mod)(options "")(descr "")) + (lib (name SOT23_SOT143_SOT143R_TSOT6_MK06A_SC70-6_Housing_26Jul2012)(type Legacy)(uri ${KISYSMOD}/SOT23_SOT143_SOT143R_TSOT6_MK06A_SC70-6_Housing_26Jul2012.mod)(options "")(descr "")) + (lib (name SOT89-3_SOT89-5_Housing_RevA_02Sep2012)(type Legacy)(uri ${KISYSMOD}/SOT89-3_SOT89-5_Housing_RevA_02Sep2012.mod)(options "")(descr "")) + (lib (name TerminalBlock_WAGO236-RM5mm_RevA2-cache)(type Legacy)(uri ${KISYSMOD}/TerminalBlock_WAGO236-RM5mm_RevA2-cache.mod)(options "")(descr "")) + (lib (name TO-50_Housings_RevA_21Apr2013)(type Legacy)(uri ${KISYSMOD}/TO-50_Housings_RevA_21Apr2013.mod)(options "")(descr "")) + (lib (name TO-78_Housing_RevA_04Jun2013)(type Legacy)(uri ${KISYSMOD}/TO-78_Housing_RevA_04Jun2013.mod)(options "")(descr "")) + (lib (name TO-92_Housings_06Jun2013)(type Legacy)(uri ${KISYSMOD}/TO-92_Housings_06Jun2013.mod)(options "")(descr "")) + (lib (name TransformerSMPS_ThroughHole_RevA)(type Legacy)(uri ${KISYSMOD}/TransformerSMPS_ThroughHole_RevA.mod)(options "")(descr "")) + (lib (name Transistor_TO-220_RevB_03Sep2012)(type Legacy)(uri ${KISYSMOD}/Transistor_TO-220_RevB_03Sep2012.mod)(options "")(descr "")) + (lib (name Transistor_TO-247_RevC)(type Legacy)(uri ${KISYSMOD}/Transistor_TO-247_RevC.mod)(options "")(descr "")) + (lib (name valves)(type Legacy)(uri ${KISYSMOD}/valves.mod)(options "")(descr "")) + (lib (name VML0806_Housing_Rohm_RevA_26Oct2012)(type Legacy)(uri ${KISYSMOD}/VML0806_Housing_Rohm_RevA_26Oct2012.mod)(options "")(descr "")) + (lib (name WireConnections-Bridges_RevA)(type Legacy)(uri ${KISYSMOD}/WireConnections-Bridges_RevA.mod)(options "")(descr "")) + (lib (name WirePads_RevA_15Jun2010)(type Legacy)(uri ${KISYSMOD}/WirePads_RevA_15Jun2010.mod)(options "")(descr "")) +) diff --git a/template/fp_global_table.csv b/template/fp_global_table.csv new file mode 100644 index 0000000000..be9eb4eb25 --- /dev/null +++ b/template/fp_global_table.csv @@ -0,0 +1,75 @@ +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&oscillator,Legacy,${KISYSMOD}/smd_crystal&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,"","" From b66d6e2d8c5a7b56d2955dad2e969e2be24e4a7d Mon Sep 17 00:00:00 2001 From: Alexander Lunev Date: Tue, 25 Jun 2013 11:05:51 -0500 Subject: [PATCH 36/50] pcad2kicadpcb: check for file format --- pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp b/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp index d90dd48cb9..49e966384b 100644 --- a/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/s_expr_loader.cpp @@ -34,9 +34,11 @@ namespace PCAD2KICAD { static KEYWORD empty_keywords[1] = {}; +static const char ACCEL_ASCII_KEYWORD[] = "ACCEL_ASCII"; void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc ) { + char line[sizeof( ACCEL_ASCII_KEYWORD )]; int tok; XNODE* iNode = NULL, *cNode = NULL; wxString str, propValue, content; @@ -47,6 +49,14 @@ void LoadInputFile( wxString aFileName, wxXmlDocument* aXmlDoc ) if( !fp ) THROW_IO_ERROR( wxT( "Unable to open file: " ) + aFileName ); + // check file format + if( !fgets( line, sizeof( line ), fp ) + || strcmp( line, ACCEL_ASCII_KEYWORD ) ) + THROW_IO_ERROR( "Unknown file type" ); + + // rewind the file + fseek( fp, 0, SEEK_SET ); + // lexer now owns fp, will close on exception or return DSNLEXER lexer( empty_keywords, 0, fp, aFileName ); From 10352b1df5087de21a0b548e20755803c60c755a Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 27 Jun 2013 21:12:01 +0200 Subject: [PATCH 37/50] Minor fixes. Gerbview: fix a collision name for GetLayout method. --- common/page_layout_default_description.cpp | 18 +++--- eeschema/dialogs/dialog_lib_edit_pin_base.cpp | 15 +++-- eeschema/dialogs/dialog_lib_edit_pin_base.fbp | 6 +- eeschema/dialogs/dialog_lib_edit_pin_base.h | 6 +- eeschema/lib_pin.cpp | 3 +- gerbview/class_GERBER.cpp | 6 +- gerbview/class_gbr_layout.h | 1 - gerbview/class_gbr_screen.cpp | 9 +-- gerbview/draw_gerber_screen.cpp | 12 ++-- gerbview/excellon_read_drill_file.cpp | 4 +- gerbview/gerbview_frame.cpp | 56 +++++++++---------- gerbview/gerbview_frame.h | 20 +++---- gerbview/initpcb.cpp | 12 ++-- gerbview/onleftclick.cpp | 4 -- gerbview/pcbplot.cpp | 5 -- gerbview/rs274d.cpp | 36 ++++++++++-- pcbnew/class_pad.h | 5 +- pcbnew/class_pad_draw_functions.cpp | 20 +++---- pcbnew/printout_controler.cpp | 2 +- template/pagelayout.kicad_wks | 18 +++--- template/pagelayout_logo.kicad_wks | 24 ++++---- 21 files changed, 151 insertions(+), 131 deletions(-) diff --git a/common/page_layout_default_description.cpp b/common/page_layout_default_description.cpp index 26a1b7a842..faced42fea 100644 --- a/common/page_layout_default_description.cpp +++ b/common/page_layout_default_description.cpp @@ -165,7 +165,7 @@ extern const char defaultPageLayout[]; // Default page layout (sizes are in mm) const char defaultPageLayout[] = "( page_layout\n" "(setup (textsize 1.5 1.5) (linewidth 0.15) (textlinewidth 0.15) )" - "(rect (comment rect around the title block) (linewidth 0.15) (start 110 34) (end 2 2) )\n" + "(rect (comment \"rect around the title block\") (linewidth 0.15) (start 110 34) (end 2 2) )\n" "(rect (start 0 0 ltcorner) (end 0 0 rbcorner) (repeat 2) (incrx 2) (incry 2) )\n" "(line (start 50 2 ltcorner) (end 50 0 ltcorner) (repeat 30) (incrx 50) )\n" "(tbtext \"1\" (pos 25 1 ltcorner) (font (size 1.3 1.3))(repeat 100) (incrx 50) )\n" @@ -177,21 +177,21 @@ const char defaultPageLayout[] = "( page_layout\n" "(tbtext \"A\" (pos 1 25 rtcorner) (font (size 1.3 1.3)) (justify center) (repeat 100) (incry 50) )\n" "(tbtext \"Date: %D\" (pos 87 6.9) )\n" "(line (start 110 5.5) end 2 5.5) )\n" - "(tbtext \"%K\" (pos 109 4.1) (comment Kicad version ) )\n" + "(tbtext \"%K\" (pos 109 4.1) (comment \"Kicad version\" ) )\n" "(line (start 110 8.5) end 2 8.5) )\n" "(tbtext \"Rev: %R\" (pos 24 6.9)(font bold)(justify left) )\n" - "(tbtext \"Size: %Z\" (comment Paper format name)(pos 109 6.9) )\n" - "(tbtext \"Id: %S/%N\" (comment Sheet id)(pos 24 4.1) )\n" + "(tbtext \"Size: %Z\" (comment \"Paper format name\")(pos 109 6.9) )\n" + "(tbtext \"Id: %S/%N\" (comment \"Sheet id\")(pos 24 4.1) )\n" "(line (start 110 12.5) end 2 12.5) )\n" "(tbtext \"Title: %T\" (pos 109 10.7)(font bold italic (size 2 2)) )\n" "(tbtext \"File: %F\" (pos 109 14.3) )\n" "(line (start 110 18.5) end 2 18.5) )\n" "(tbtext \"Sheet: %P\" (pos 109 17) )\n" - "(tbtext \"%Y\" (comment Company name) (pos 109 20)(font bold) )\n" - "(tbtext \"%C0\" (comment Comment 0) (pos 109 23) )\n" - "(tbtext \"%C1\" (comment Comment 0) (pos 109 26) )\n" - "(tbtext \"%C2\" (comment Comment 0) (pos 109 29) )\n" - "(tbtext \"%C3\" (comment Comment 0) (pos 109 32) )\n" + "(tbtext \"%Y\" (comment \"Company name\") (pos 109 20)(font bold) )\n" + "(tbtext \"%C0\" (comment \"Comment 0\") (pos 109 23) )\n" + "(tbtext \"%C1\" (comment \"Comment 1\") (pos 109 26) )\n" + "(tbtext \"%C2\" (comment \"Comment 2\") (pos 109 29) )\n" + "(tbtext \"%C3\" (comment \"Comment 3\") (pos 109 32) )\n" "(line (start 90 8.5) end 90 5.5) )\n" "(line (start 26 8.5) end 26 2) )\n" ")\n" diff --git a/eeschema/dialogs/dialog_lib_edit_pin_base.cpp b/eeschema/dialogs/dialog_lib_edit_pin_base.cpp index 42149d5a3b..e1990a9407 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_base.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_base.cpp @@ -1,10 +1,12 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 11 2012) +// C++ code generated with wxFormBuilder (version Oct 8 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// +#include "wx/bmpcbox.h" + #include "dialog_lib_edit_pin_base.h" /////////////////////////////////////////////////////////////////////////// @@ -33,6 +35,7 @@ DIALOG_LIB_EDIT_PIN_BASE::DIALOG_LIB_EDIT_PIN_BASE( wxWindow* parent, wxWindowID fgSizerPins->Add( m_staticTextPinName, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_textPinName = new wxTextCtrl( this, ID_M_TEXTPINNAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_textPinName->SetMaxLength( 0 ); fgSizerPins->Add( m_textPinName, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM, 3 ); m_staticTextPadName = new wxStaticText( this, ID_M_STATICTEXTPADNAME, _("Pin n&umber:"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -42,13 +45,14 @@ DIALOG_LIB_EDIT_PIN_BASE::DIALOG_LIB_EDIT_PIN_BASE( wxWindow* parent, wxWindowID fgSizerPins->Add( m_staticTextPadName, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_textPadName = new wxTextCtrl( this, ID_M_TEXTPADNAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_textPadName->SetMaxLength( 0 ); fgSizerPins->Add( m_textPadName, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM, 3 ); m_staticTextOrient = new wxStaticText( this, wxID_ANY, _("&Orientation:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextOrient->Wrap( -1 ); fgSizerPins->Add( m_staticTextOrient, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - m_choiceOrientation = new wxBitmapComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); + m_choiceOrientation = new wxBitmapComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ); fgSizerPins->Add( m_choiceOrientation, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); m_staticTextEType = new wxStaticText( this, wxID_ANY, _("&Electrical type:"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -57,14 +61,14 @@ DIALOG_LIB_EDIT_PIN_BASE::DIALOG_LIB_EDIT_PIN_BASE( wxWindow* parent, wxWindowID fgSizerPins->Add( m_staticTextEType, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - m_choiceElectricalType = new wxBitmapComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); + m_choiceElectricalType = new wxBitmapComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ); fgSizerPins->Add( m_choiceElectricalType, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); m_staticTextGstyle = new wxStaticText( this, wxID_ANY, _("Graphic &Style:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextGstyle->Wrap( -1 ); fgSizerPins->Add( m_staticTextGstyle, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); - m_choiceStyle = new wxBitmapComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); + m_choiceStyle = new wxBitmapComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ); fgSizerPins->Add( m_choiceStyle, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); @@ -115,6 +119,7 @@ DIALOG_LIB_EDIT_PIN_BASE::DIALOG_LIB_EDIT_PIN_BASE( wxWindow* parent, wxWindowID fgSizerTextsSizes->Add( m_staticTextNameSize, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_textPinNameTextSize = new wxTextCtrl( this, ID_M_TEXTPINNAMETEXTSIZE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_textPinNameTextSize->SetMaxLength( 0 ); fgSizerTextsSizes->Add( m_textPinNameTextSize, 1, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM, 3 ); m_staticNameTextSizeUnits = new wxStaticText( this, ID_M_STATICNAMETEXTSIZEUNITS, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -126,6 +131,7 @@ DIALOG_LIB_EDIT_PIN_BASE::DIALOG_LIB_EDIT_PIN_BASE( wxWindow* parent, wxWindowID fgSizerTextsSizes->Add( m_staticTextPadNameSize, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 ); m_textPadNameTextSize = new wxTextCtrl( this, ID_M_TEXTPADNAMETEXTSIZE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_textPadNameTextSize->SetMaxLength( 0 ); fgSizerTextsSizes->Add( m_textPadNameTextSize, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxEXPAND, 3 ); m_staticNumberTextSizeUnits = new wxStaticText( this, ID_M_STATICNUMBERTEXTSIZEUNITS, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -137,6 +143,7 @@ DIALOG_LIB_EDIT_PIN_BASE::DIALOG_LIB_EDIT_PIN_BASE( wxWindow* parent, wxWindowID fgSizerTextsSizes->Add( m_staticTextPinLen, 0, wxALL, 5 ); m_textLength = new wxTextCtrl( this, ID_M_TEXTLENGTH, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_textLength->SetMaxLength( 0 ); fgSizerTextsSizes->Add( m_textLength, 0, wxTOP|wxBOTTOM|wxEXPAND, 5 ); m_staticLengthUnits = new wxStaticText( this, ID_M_STATICLENGTHUNITS, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); diff --git a/eeschema/dialogs/dialog_lib_edit_pin_base.fbp b/eeschema/dialogs/dialog_lib_edit_pin_base.fbp index 58a8dd5367..268c5d0722 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_base.fbp +++ b/eeschema/dialogs/dialog_lib_edit_pin_base.fbp @@ -607,7 +607,7 @@ -1 1 - + wxCB_READONLY wxBitmapComboBox; wx/bmpcbox.h 0 @@ -781,7 +781,7 @@ -1 1 - + wxCB_READONLY wxBitmapComboBox; wx/bmpcbox.h 0 @@ -955,7 +955,7 @@ -1 1 - + wxCB_READONLY wxBitmapComboBox; wx/bmpcbox.h 0 diff --git a/eeschema/dialogs/dialog_lib_edit_pin_base.h b/eeschema/dialogs/dialog_lib_edit_pin_base.h index a48e0a5faa..191b055471 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_base.h +++ b/eeschema/dialogs/dialog_lib_edit_pin_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 11 2012) +// C++ code generated with wxFormBuilder (version Oct 8 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -11,7 +11,9 @@ #include #include #include -#include "wx/bmpcbox.h" +class DIALOG_SHIM; +class wxBitmapComboBox; + #include "dialog_shim.h" #include #include diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index f5b982fe2e..374717b83b 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -311,7 +311,8 @@ void LIB_PIN::SetOrientation( int orientation ) for( size_t i = 0; i < pinList.size(); i++ ) { - if( ( pinList[i]->m_Flags & IS_LINKED ) == 0 || pinList[i]->m_orientation == orientation ) + if( ( pinList[i]->m_Flags & IS_LINKED ) == 0 || + pinList[i]->m_orientation == orientation ) continue; pinList[i]->m_orientation = orientation; diff --git a/gerbview/class_GERBER.cpp b/gerbview/class_GERBER.cpp index c4178640e3..9d7b7302ea 100644 --- a/gerbview/class_GERBER.cpp +++ b/gerbview/class_GERBER.cpp @@ -6,8 +6,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2010 - * Copyright (C) 1992-2010 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-2013 Jean-Pierre Charras jp.charras at wanadoo.fr + * Copyright (C) 1992-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 @@ -308,7 +308,7 @@ void GERBER_IMAGE::StepAndRepeatItem( const GERBER_DRAW_ITEM& aItem ) move_vector.y = scaletoIU( jj * GetLayerParams().m_StepForRepeat.y, GetLayerParams().m_StepForRepeatMetric ); dupItem->MoveXY( move_vector ); - m_Parent->GetLayout()->m_Drawings.Append( dupItem ); + m_Parent->GetGerberLayout()->m_Drawings.Append( dupItem ); } } } diff --git a/gerbview/class_gbr_layout.h b/gerbview/class_gbr_layout.h index ea16415dff..c192fff890 100644 --- a/gerbview/class_gbr_layout.h +++ b/gerbview/class_gbr_layout.h @@ -9,7 +9,6 @@ #include -// #include #include #include // PAGE_INFO #include diff --git a/gerbview/class_gbr_screen.cpp b/gerbview/class_gbr_screen.cpp index 1deff7c3cf..aaf96275ff 100644 --- a/gerbview/class_gbr_screen.cpp +++ b/gerbview/class_gbr_screen.cpp @@ -7,13 +7,7 @@ #include #include #include - -#include -#include -#include - -#include - +#include #define DMIL_GRID( x ) wxRealPoint( x * IU_PER_DECIMILS,\ x * IU_PER_DECIMILS ) @@ -23,7 +17,6 @@ /** Default GerbView zoom values. - Limited to 19 values to keep a decent size to menus. Roughly a 1.5 progression. */ static const double gbrZoomList[] = diff --git a/gerbview/draw_gerber_screen.cpp b/gerbview/draw_gerber_screen.cpp index a05940b672..24b03fbd83 100644 --- a/gerbview/draw_gerber_screen.cpp +++ b/gerbview/draw_gerber_screen.cpp @@ -1,9 +1,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2011 Wayne Stambaugh - * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2013 Jean-Pierre Charras, jpierre.charras at wanadoo + * 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 @@ -59,7 +59,7 @@ void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LAYER_MSK aPrintMasklayer, m_canvas->SetPrintMirrored( aPrintMirrorMode ); // XXX -1 as drawmode? - GetLayout()->Draw( m_canvas, aDC, UNSPECIFIED_DRAWMODE, wxPoint( 0, 0 ) ); + GetGerberLayout()->Draw( m_canvas, aDC, UNSPECIFIED_DRAWMODE, wxPoint( 0, 0 ) ); m_canvas->SetPrintMirrored( false ); @@ -73,7 +73,7 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) { GBR_SCREEN* screen = (GBR_SCREEN*) GetScreen(); - if( !GetLayout() ) + if( !GetGerberLayout() ) return; wxBusyCursor dummy; @@ -96,7 +96,7 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) } // Draw according to the current setting. This needs to be GR_COPY or GR_OR. - GetLayout()->Draw( m_canvas, DC, drawMode, wxPoint( 0, 0 ) ); + GetGerberLayout()->Draw( m_canvas, DC, drawMode, wxPoint( 0, 0 ) ); // Draw the "background" now, i.e. grid and axis after gerber layers // because most of time the actual background is erased by successive drawings of each gerber diff --git a/gerbview/excellon_read_drill_file.cpp b/gerbview/excellon_read_drill_file.cpp index 2057432fae..e06f59f07b 100644 --- a/gerbview/excellon_read_drill_file.cpp +++ b/gerbview/excellon_read_drill_file.cpp @@ -487,8 +487,8 @@ bool EXCELLON_IMAGE::Execute_Drill_Command( char*& text ) ReportMessage( msg ); return false; } - gbritem = new GERBER_DRAW_ITEM( GetParent()->GetLayout(), this ); - GetParent()->GetLayout()->m_Drawings.Append( gbritem ); + gbritem = new GERBER_DRAW_ITEM( GetParent()->GetGerberLayout(), this ); + GetParent()->GetGerberLayout()->m_Drawings.Append( gbritem ); if( m_SlotOn ) // Oval hole { fillLineGBRITEM( gbritem, diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 550931d7f4..40580a1c84 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -70,7 +70,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* aParent, const wxString& aTitle, aStyle, GERBVIEW_FRAME_NAME ) { m_colorsSettings = &g_ColorsSettings; - m_Layout = NULL; + m_gerberLayout = NULL; m_FrameName = GERBVIEW_FRAME_NAME; m_show_layer_manager_tools = true; @@ -95,7 +95,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* aParent, const wxString& aTitle, SetVisibleLayers( FULL_LAYERS ); // All 32 layers visible. - SetScreen( new GBR_SCREEN( GetLayout()->GetPageSettings().GetSizeIU() ) ); + SetScreen( new GBR_SCREEN( GetGerberLayout()->GetPageSettings().GetSizeIU() ) ); // Create the PCB_LAYER_WIDGET *after* SetLayout(): wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); @@ -112,10 +112,10 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* aParent, const wxString& aTitle, LoadSettings(); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); - if( m_LastGridSizeId < ID_POPUP_GRID_LEVEL_1000 ) - m_LastGridSizeId = m_LastGridSizeId; - if( m_LastGridSizeId > ID_POPUP_GRID_LEVEL_0_0_1MM ) - m_LastGridSizeId = ID_POPUP_GRID_LEVEL_0_0_1MM; + if( m_LastGridSizeId < 0 ) + m_LastGridSizeId = 0; + if( m_LastGridSizeId > ID_POPUP_GRID_LEVEL_0_0_1MM-ID_POPUP_GRID_LEVEL_1000 ) + m_LastGridSizeId = ID_POPUP_GRID_LEVEL_0_0_1MM-ID_POPUP_GRID_LEVEL_1000; GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); ReCreateMenuBar(); @@ -184,13 +184,13 @@ void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event ) double GERBVIEW_FRAME::BestZoom() { - GERBER_DRAW_ITEM* item = GetLayout()->m_Drawings; + GERBER_DRAW_ITEM* item = GetGerberLayout()->m_Drawings; // gives a minimal value to zoom, if no item in list if( item == NULL ) return ZOOM_FACTOR( 350.0 ); - EDA_RECT bbox = GetLayout()->ComputeBoundingBox(); + EDA_RECT bbox = GetGerberLayout()->ComputeBoundingBox(); wxSize size = m_canvas->GetClientSize(); @@ -552,7 +552,7 @@ LAYER_MSK GERBVIEW_FRAME::GetVisibleLayers() const */ void GERBVIEW_FRAME::SetVisibleLayers( LAYER_MSK aLayerMask ) { - GetLayout()->SetVisibleLayers( aLayerMask ); + GetGerberLayout()->SetVisibleLayers( aLayerMask ); } @@ -567,7 +567,7 @@ bool GERBVIEW_FRAME::IsLayerVisible( LAYER_NUM aLayer ) const if( ! m_DisplayOptions.m_IsPrinting ) return m_LayersManager->IsLayerVisible( aLayer ); else - return GetLayout()->IsLayerVisible( aLayer ); + return GetGerberLayout()->IsLayerVisible( aLayer ); } @@ -693,8 +693,8 @@ void GERBVIEW_FRAME::setActiveLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) { - wxASSERT( m_Layout ); - m_Layout->SetPageSettings( aPageSettings ); + wxASSERT( m_gerberLayout ); + m_gerberLayout->SetPageSettings( aPageSettings ); if( GetScreen() ) GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() ); @@ -703,47 +703,47 @@ void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) const PAGE_INFO& GERBVIEW_FRAME::GetPageSettings() const { - wxASSERT( m_Layout ); - return m_Layout->GetPageSettings(); + wxASSERT( m_gerberLayout ); + return m_gerberLayout->GetPageSettings(); } const wxSize GERBVIEW_FRAME::GetPageSizeIU() const { - wxASSERT( m_Layout ); + wxASSERT( m_gerberLayout ); // this function is only needed because EDA_DRAW_FRAME is not compiled // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route // into an application specific source file. - return m_Layout->GetPageSettings().GetSizeIU(); + return m_gerberLayout->GetPageSettings().GetSizeIU(); } const TITLE_BLOCK& GERBVIEW_FRAME::GetTitleBlock() const { - wxASSERT( m_Layout ); - return m_Layout->GetTitleBlock(); + wxASSERT( m_gerberLayout ); + return m_gerberLayout->GetTitleBlock(); } void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { - wxASSERT( m_Layout ); - m_Layout->SetTitleBlock( aTitleBlock ); + wxASSERT( m_gerberLayout ); + m_gerberLayout->SetTitleBlock( aTitleBlock ); } const wxPoint& GERBVIEW_FRAME::GetOriginAxisPosition() const { - wxASSERT( m_Layout ); - return m_Layout->GetOriginAxisPosition(); + wxASSERT( m_gerberLayout ); + return m_gerberLayout->GetOriginAxisPosition(); } void GERBVIEW_FRAME::SetOriginAxisPosition( const wxPoint& aPosition ) { - wxASSERT( m_Layout ); - m_Layout->SetOriginAxisPosition( aPosition ); + wxASSERT( m_gerberLayout ); + m_gerberLayout->SetOriginAxisPosition( aPosition ); } @@ -768,13 +768,13 @@ void GERBVIEW_FRAME::SetCurItem( GERBER_DRAW_ITEM* aItem, bool aDisplayInfo ) /* - * Function GetLayoutBoundingBox + * Function GetGerberLayoutBoundingBox * returns the bounding box containing all gerber items. */ -EDA_RECT GERBVIEW_FRAME::GetLayoutBoundingBox() +EDA_RECT GERBVIEW_FRAME::GetGerberLayoutBoundingBox() { - GetLayout()->ComputeBoundingBox(); - return GetLayout()->GetBoundingBox(); + GetGerberLayout()->ComputeBoundingBox(); + return GetGerberLayout()->GetBoundingBox(); } /* diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index ba1f079c9d..d12e00d840 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -82,26 +82,26 @@ public: class GERBVIEW_FRAME : public EDA_DRAW_FRAME // PCB_BASE_FRAME { - GBR_LAYOUT* m_Layout; + GBR_LAYOUT* m_gerberLayout; public: GBR_DISPLAY_OPTIONS m_DisplayOptions; /** * Function SetLayout - * sets the m_Layout member in such as way as to ensure deleting any previous + * sets the m_gerberLayout member in such as way as to ensure deleting any previous * GBR_LAYOUT. * @param aLayout The GBR_LAYOUT to put into the frame. */ void SetLayout( GBR_LAYOUT* aLayout ) { - delete m_Layout; - m_Layout = aLayout; + delete m_gerberLayout; + m_gerberLayout = aLayout; } - GBR_LAYOUT* GetLayout() const + GBR_LAYOUT* GetGerberLayout() const { - wxASSERT( m_Layout ); - return m_Layout; + wxASSERT( m_gerberLayout ); + return m_gerberLayout; } /** @@ -110,17 +110,17 @@ public: */ GERBER_DRAW_ITEM* GetItemsList() { - GERBER_DRAW_ITEM* item = GetLayout()->m_Drawings; + GERBER_DRAW_ITEM* item = GetGerberLayout()->m_Drawings; return (GERBER_DRAW_ITEM*) item; } /** - * Function GetLayoutBoundingBox + * Function GetGerberLayoutBoundingBox * calculates the bounding box containing all gerber items. * @return EDA_RECT - the items bounding box */ - EDA_RECT GetLayoutBoundingBox(); + EDA_RECT GetGerberLayoutBoundingBox(); void SetPageSettings( const PAGE_INFO& aPageSettings ); // overload const PAGE_INFO& GetPageSettings() const; // overload diff --git a/gerbview/initpcb.cpp b/gerbview/initpcb.cpp index 0efef5b750..1ae5090a3c 100644 --- a/gerbview/initpcb.cpp +++ b/gerbview/initpcb.cpp @@ -1,8 +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) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr + * 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 @@ -41,7 +41,7 @@ bool GERBVIEW_FRAME::Clear_Pcb( bool query ) { LAYER_NUM layer; - if( GetLayout() == NULL ) + if( GetGerberLayout() == NULL ) return false; if( query && GetScreen()->IsModify() ) @@ -50,7 +50,7 @@ bool GERBVIEW_FRAME::Clear_Pcb( bool query ) return false; } - GetLayout()->m_Drawings.DeleteAll(); + GetGerberLayout()->m_Drawings.DeleteAll(); for( layer = FIRST_LAYER; layer < NB_GERBER_LAYERS; ++layer ) { @@ -61,7 +61,7 @@ bool GERBVIEW_FRAME::Clear_Pcb( bool query ) } } - GetLayout()->SetBoundingBox( EDA_RECT() ); + GetGerberLayout()->SetBoundingBox( EDA_RECT() ); SetScreen( new GBR_SCREEN( GetPageSettings().GetSizeIU() ) ); @@ -84,7 +84,7 @@ void GERBVIEW_FRAME::Erase_Current_Layer( bool query ) SetCurItem( NULL ); - GERBER_DRAW_ITEM* item = GetLayout()->m_Drawings; + GERBER_DRAW_ITEM* item = GetGerberLayout()->m_Drawings; GERBER_DRAW_ITEM * next; for( ; item; item = next ) diff --git a/gerbview/onleftclick.cpp b/gerbview/onleftclick.cpp index 14f818220e..dc73fbac08 100644 --- a/gerbview/onleftclick.cpp +++ b/gerbview/onleftclick.cpp @@ -5,12 +5,8 @@ #include #include #include -//#include "gestfich.h" -//#include "appl_wxstruct.h" #include -//#include "pcbplot.h" -//#include "kicad_device_context.h" #include #include #include diff --git a/gerbview/pcbplot.cpp b/gerbview/pcbplot.cpp index b2f089e096..e13b1de974 100644 --- a/gerbview/pcbplot.cpp +++ b/gerbview/pcbplot.cpp @@ -8,11 +8,6 @@ #include #include - -/**************************************************************/ -/* void PCB_BASE_FRAME::ToPlotter(wxCommandEvent& event) */ -/***************************************************************/ - /** TODO */ void GERBVIEW_FRAME::ToPlotter(wxCommandEvent& event) { diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp index f36e634829..838f1a9b39 100644 --- a/gerbview/rs274d.cpp +++ b/gerbview/rs274d.cpp @@ -1,6 +1,30 @@ -/********************/ -/**** rs274d.cpp ****/ -/********************/ +/** + * @file rs274d.cpp + * @brief functions to read the rs274d commands from a rs274d/rs274x file + */ + +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * 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 + */ #include #include @@ -511,9 +535,9 @@ bool GERBER_IMAGE::Execute_G_Command( char*& text, int G_command ) break; case GC_TURN_OFF_POLY_FILL: - if( m_Exposure && m_Parent->GetLayout()->m_Drawings ) // End of polygon + if( m_Exposure && m_Parent->GetGerberLayout()->m_Drawings ) // End of polygon { - GERBER_DRAW_ITEM * gbritem = m_Parent->GetLayout()->m_Drawings.GetLast(); + GERBER_DRAW_ITEM * gbritem = m_Parent->GetGerberLayout()->m_Drawings.GetLast(); StepAndRepeatItem( *gbritem ); } m_Exposure = false; @@ -542,7 +566,7 @@ bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande ) APERTURE_T aperture = APT_CIRCLE; GERBER_DRAW_ITEM* gbritem; - GBR_LAYOUT* layout = m_Parent->GetLayout(); + GBR_LAYOUT* layout = m_Parent->GetGerberLayout(); LAYER_NUM activeLayer = m_Parent->getActiveLayer(); diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index db1ba22ae5..5999c07d5b 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -345,9 +345,12 @@ public: * position. * @param aSegEnd = the ending point of the equivalent segment, relative to the shape position * @param aRotation = full rotation of the segment + * @param aRotation = full rotation of the segment + * @param aMargin = a margin around the shape (for instance mask margin) * @return the width of the segment */ - int BuildSegmentFromOvalShape( wxPoint& aSegStart, wxPoint& aSegEnd, double aRotation ) const; + int BuildSegmentFromOvalShape( wxPoint& aSegStart, wxPoint& aSegEnd, + double aRotation, const wxSize& aMargin ) const; void ReturnStringPadName( wxString& text ) const; // Return pad name as string in a buffer diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index 1619e599be..7d95403c03 100644 --- a/pcbnew/class_pad_draw_functions.cpp +++ b/pcbnew/class_pad_draw_functions.cpp @@ -340,8 +340,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) GRCircle( aClipBox, aDC, shape_pos.x, shape_pos.y, halfsize.x + aDrawInfo.m_PadClearance, - 0, - aDrawInfo.m_Color ); + 0, aDrawInfo.m_Color ); } break; @@ -349,7 +348,8 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) case PAD_OVAL: { wxPoint segStart, segEnd; - seg_width = BuildSegmentFromOvalShape(segStart, segEnd, angle); + seg_width = BuildSegmentFromOvalShape(segStart, segEnd, angle, + aDrawInfo.m_Mask_margin); segStart += shape_pos; segEnd += shape_pos; @@ -596,27 +596,27 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) * aRotation is the asked rotation of the segment (usually m_Orient) */ int D_PAD::BuildSegmentFromOvalShape(wxPoint& aSegStart, wxPoint& aSegEnd, - double aRotation) const + double aRotation, const wxSize& aMargin) const { int width; if( m_Size.y < m_Size.x ) // Build an horizontal equiv segment { int delta = ( m_Size.x - m_Size.y ) / 2; - aSegStart.x = -delta; + aSegStart.x = -delta - aMargin.x; aSegStart.y = 0; - aSegEnd.x = delta; + aSegEnd.x = delta + aMargin.x; aSegEnd.y = 0; - width = m_Size.y; + width = m_Size.y + ( aMargin.y * 2 ); } else // Vertical oval: build a vertical equiv segment { int delta = ( m_Size.y -m_Size.x ) / 2; aSegStart.x = 0; - aSegStart.y = -delta; + aSegStart.y = -delta - aMargin.y; aSegEnd.x = 0; - aSegEnd.y = delta; - width = m_Size.x; + aSegEnd.y = delta + aMargin.y; + width = m_Size.x + ( aMargin.x * 2 ); } if( aRotation ) diff --git a/pcbnew/printout_controler.cpp b/pcbnew/printout_controler.cpp index 1361e6785d..4376d40ef5 100644 --- a/pcbnew/printout_controler.cpp +++ b/pcbnew/printout_controler.cpp @@ -168,7 +168,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() boardBoundingBox = brd->ComputeBoundingBox(); wxString titleblockFilename = brd->GetFileName(); #elif defined (GERBVIEW) - boardBoundingBox = ((GERBVIEW_FRAME*) m_Parent)->GetLayoutBoundingBox(); + boardBoundingBox = ((GERBVIEW_FRAME*) m_Parent)->GetGerberLayoutBoundingBox(); wxString titleblockFilename; // TODO see if we uses the gerber file name #else #error BOARD_PRINTOUT_CONTROLLER::DrawPage() works only for PCBNEW or GERBVIEW diff --git a/template/pagelayout.kicad_wks b/template/pagelayout.kicad_wks index 4a8d16b1ae..60c19735eb 100644 --- a/template/pagelayout.kicad_wks +++ b/template/pagelayout.kicad_wks @@ -1,6 +1,6 @@ ( page_layout ( setup (textsize 1.5 1.5) (linewidth 0.15) (textlinewidth 0.15) ) - ( rect (comment rect around the title block) (linewidth 0.15) (start 110 34) (end 2 2) ) + ( rect (comment "rect around the title block") (linewidth 0.15) (start 110 34) (end 2 2) ) ( rect (start 0 0 ltcorner) (end 0 0 rbcorner) (repeat 2) (incrx 2) (incry 2) ) ( line (start 50 2 ltcorner) (end 50 0 ltcorner) (repeat 30) (incrx 50) ) ( tbtext "1" (pos 25 1 ltcorner) (font (size 1.3 1.3))(repeat 100) (incrx 50) ) @@ -14,21 +14,21 @@ (justify center) (repeat 100) (incry 50) ) ( tbtext "Date: %D" (pos 87 6.9) ) ( line (start 110 5.5) end 2 5.5) ) - ( tbtext "%K" (pos 109 4.1) (comment Kicad version ) ) + ( tbtext "%K" (pos 109 4.1) (comment "Kicad version" ) ) ( line (start 110 8.5) end 2 8.5) ) ( tbtext "Rev: %R" (pos 24 6.9)(font bold)(justify left) ) - ( tbtext "Size: %Z" (comment Paper format name)(pos 109 6.9) ) - ( tbtext "Id: %S/%N" (comment Sheet id)(pos 24 4.1) ) + ( tbtext "Size: %Z" (comment "Paper format name")(pos 109 6.9) ) + ( tbtext "Id: %S/%N" (comment "Sheet id")(pos 24 4.1) ) ( line (start 110 12.5) end 2 12.5) ) ( tbtext "Title: %T" (pos 109 10.7)(font bold (size 2 2)) ) ( tbtext "File: %F" (pos 109 14.3) ) ( line (start 110 18.5) end 2 18.5) ) ( tbtext "Sheet: %P" (pos 109 17) ) - ( tbtext "%Y" (comment Company name) (pos 109 20)(font bold) ) - ( tbtext "%C0" (comment Comment 0) (pos 109 23) ) - ( tbtext "%C1" (comment Comment 0) (pos 109 26) ) - ( tbtext "%C2" (comment Comment 0) (pos 109 29) ) - ( tbtext "%C3" (comment Comment 0) (pos 109 32) ) + ( tbtext "%Y" (comment "Company name") (pos 109 20)(font bold) ) + ( tbtext "%C0" (comment "Comment 0") (pos 109 23) ) + ( tbtext "%C1" (comment "Comment 1") (pos 109 26) ) + ( tbtext "%C2" (comment "Comment 2") (pos 109 29) ) + ( tbtext "%C3" (comment "Comment 3") (pos 109 32) ) ( line (start 90 8.5) end 90 5.5) ) ( line (start 26 8.5) end 26 2) ) ) diff --git a/template/pagelayout_logo.kicad_wks b/template/pagelayout_logo.kicad_wks index d60250570f..dd710966ec 100644 --- a/template/pagelayout_logo.kicad_wks +++ b/template/pagelayout_logo.kicad_wks @@ -1,6 +1,6 @@ ( page_layout ( setup (textsize 1.5 1.5) (linewidth 0.15) (textlinewidth 0.15) ) - ( rect (comment rect around the title block) (linewidth 0.15) (start 110 34) (end 2 2) ) + ( rect (comment "rect around the title block") (linewidth 0.15) (start 110 34) (end 2 2) ) ( rect (start 0 0 ltcorner) (end 0 0 rbcorner) (repeat 2) (incrx 2) (incry 2) ) ( line (start 50 2 ltcorner) (end 50 0 ltcorner) (repeat 30) (incrx 50) ) ( tbtext "1" (pos 25 1 ltcorner) (font (size 1.3 1.3))(repeat 100) (incrx 50) ) @@ -14,25 +14,25 @@ (justify center) (repeat 100) (incry 50) ) ( tbtext "Date: %D" (pos 87 6.9) ) ( line (start 110 5.5) end 2 5.5) ) - ( tbtext "%K" (pos 109 4.1) (comment Kicad version ) ) + ( tbtext "%K" (pos 109 4.1) (comment "Kicad version" ) ) ( line (start 110 8.5) end 2 8.5) ) ( tbtext "Rev: %R" (pos 24 6.9)(font bold)(justify left) ) - ( tbtext "Size: %Z" (comment Paper format name)(pos 109 6.9) ) - ( tbtext "Id: %S/%N" (comment Sheet id)(pos 24 4.1) ) + ( tbtext "Size: %Z" (comment "Paper format name")(pos 109 6.9) ) + ( tbtext "Id: %S/%N" (comment "Sheet id")(pos 24 4.1) ) ( line (start 110 12.5) end 2 12.5) ) ( tbtext "Title: %T" (pos 109 10.7)(font bold (size 2 2)) ) ( tbtext "File: %F" (pos 109 14.3) ) ( line (start 110 18.5) end 2 18.5) ) ( tbtext "Sheet: %P" (pos 109 17) ) - ( tbtext "%Y" (comment Company name) (pos 109 20)(font bold) ) - ( tbtext "%C0" (comment Comment 0) (pos 109 23) ) - ( tbtext "%C1" (comment Comment 0) (pos 109 26) ) - ( tbtext "%C2" (comment Comment 0) (pos 109 29) ) - ( tbtext "%C3" (comment Comment 0) (pos 109 32) ) - ( line (start 90 8.5) end 90 5.5) ) - ( line (start 26 8.5) end 26 2) ) + ( tbtext "%Y" (comment "Company name") (pos 109 20)(font bold) ) + ( tbtext "%C0" (comment "Comment 0") (pos 109 23) ) + ( tbtext "%C1" (comment "Comment 1") (pos 109 26) ) + ( tbtext "%C2" (comment "Comment 2") (pos 109 29) ) + ( tbtext "%C3" (comment "Comment 3") (pos 109 32) ) + ( line (start 90 8.5) (end 90 5.5) ) + ( line (start 26 8.5) (end 26 2) ) - ( rect (comment rect around the logo) (linewidth 0.15) (start 157 34) (end 110 2) ) + ( rect (comment "rect around the logo") (linewidth 0.15) (start 157 34) (end 110 2) ) (polygon (pos 134 18 rbcorner) (rotate 20) (linewidth 0.00254) (pts (xy 20.574 8.382) (xy 19.9009 8.382) (xy 19.9009 6.26364) (xy 19.7485 5.98932) (xy 19.71802 5.92328) (xy 19.69262 5.83946) (xy 19.66976 5.72262) (xy 19.65198 5.56006) From ce94880a5227436e474a26753475a20381689f3d Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Thu, 27 Jun 2013 16:27:29 -0400 Subject: [PATCH 38/50] Pcbnew: fix bug reading legacy board format. (fixes lp:1195368) --- pcbnew/legacy_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index 5ee888f724..717f0f7445 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -1002,7 +1002,7 @@ void LEGACY_PLUGIN::LoadMODULE( MODULE* aModule ) { // There can be whitespace in the footprint name on some old libraries. // Grab everything after "Li" up to end of line: - // aModule->SetLibRef( FROM_UTF8( StrPurge( line + SZ( "Li" ) ) ) ); + aModule->SetLibRef( FROM_UTF8( StrPurge( line + SZ( "Li" ) ) ) ); } else if( TESTLINE( "Sc" ) ) // timestamp From cec229bf8329d74f17ba9c335010f3344c480daa Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Thu, 27 Jun 2013 15:33:28 -0500 Subject: [PATCH 39/50] WTF --- pcbnew/legacy_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index 717f0f7445..c780c85da0 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -1002,7 +1002,7 @@ void LEGACY_PLUGIN::LoadMODULE( MODULE* aModule ) { // There can be whitespace in the footprint name on some old libraries. // Grab everything after "Li" up to end of line: - aModule->SetLibRef( FROM_UTF8( StrPurge( line + SZ( "Li" ) ) ) ); + //aModule->SetLibRef( FROM_UTF8( StrPurge( line + SZ( "Li" ) ) ) ); } else if( TESTLINE( "Sc" ) ) // timestamp From 770d72c53888d5854ef2f2fdaea9add2238e87cb Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Thu, 27 Jun 2013 15:34:30 -0500 Subject: [PATCH 40/50] remove dialog_netlist.h --- eeschema/dialogs/dialog_netlist.cpp | 287 ++++++++++++++++++++-------- eeschema/dialogs/dialog_netlist.h | 205 -------------------- eeschema/invoke_sch_dialog.h | 10 + eeschema/netform.cpp | 1 - eeschema/netlist.h | 25 ++- eeschema/schframe.cpp | 12 +- 6 files changed, 245 insertions(+), 295 deletions(-) delete mode 100644 eeschema/dialogs/dialog_netlist.h diff --git a/eeschema/dialogs/dialog_netlist.cpp b/eeschema/dialogs/dialog_netlist.cpp index 8fbca46427..1e8519568b 100644 --- a/eeschema/dialogs/dialog_netlist.cpp +++ b/eeschema/dialogs/dialog_netlist.cpp @@ -49,12 +49,184 @@ #include #include #include -#include +#include #include #include +#include #include + + +#define CUSTOMPANEL_COUNTMAX 8 // Max number of netlist plugins + + +/* panel (notebook page) identifiers */ +enum panel_netlist_index { + PANELPCBNEW = 0, /* Handle Netlist format Pcbnew */ + PANELORCADPCB2, /* Handle Netlist format OracdPcb2 */ + PANELCADSTAR, /* Handle Netlist format CadStar */ + PANELSPICE, /* Handle Netlist format Pspice */ + PANELCUSTOMBASE /* First auxiliary panel (custom netlists). + * others use PANELCUSTOMBASE+1, PANELCUSTOMBASE+2.. */ +}; + + +/* wxPanels for creating the NoteBook pages for each netlist format: */ +class NETLIST_PAGE_DIALOG : public wxPanel +{ +public: + NETLIST_TYPE_ID m_IdNetType; + wxCheckBox* m_IsCurrentFormat; + wxCheckBox* m_AddSubPrefix; + wxTextCtrl* m_CommandStringCtrl; + wxTextCtrl* m_TitleStringCtrl; + wxButton* m_ButtonCancel; + wxBoxSizer* m_LeftBoxSizer; + wxBoxSizer* m_RightBoxSizer; + wxBoxSizer* m_RightOptionsBoxSizer; + wxBoxSizer* m_LowBoxSizer; + wxRadioBox* m_NetOption; +private: + wxString m_pageNetFmtName; + +public: + /** Constructor to create a setup page for one netlist format. + * Used in Netlist format Dialog box creation + * @param parent = wxNotebook * parent + * @param title = title (name) of the notebook page + * @param id_NetType = netlist type id + */ + NETLIST_PAGE_DIALOG( wxNotebook* parent, const wxString& title, + NETLIST_TYPE_ID id_NetType ); + ~NETLIST_PAGE_DIALOG() { }; + + /** + * function GetPageNetFmtName + * @return the name of the netlist format for this page + * This is usually the page label. + * For the pcbnew netlist, this is "LegacyPcbnew" + * when the "old" format is selected + * and "PcbnewAdvanced" when the advanced format (S expr fmt)is selected + */ + const wxString GetPageNetFmtName(); + + void SetPageNetFmtName( const wxString &aName ) { m_pageNetFmtName = aName; } +}; + + +/* Dialog frame for creating netlists */ +class NETLIST_DIALOG : public NETLIST_DIALOG_BASE +{ +public: + SCH_EDIT_FRAME* m_Parent; + wxString m_NetFmtName; + NETLIST_PAGE_DIALOG* m_PanelNetType[4 + CUSTOMPANEL_COUNTMAX]; + +private: + wxConfig* m_config; + +public: + + // Constructor and destructor + NETLIST_DIALOG( SCH_EDIT_FRAME* parent ); + ~NETLIST_DIALOG() { }; + +private: + void InstallCustomPages(); + NETLIST_PAGE_DIALOG* AddOneCustomPage( const wxString & aTitle, + const wxString & aCommandString, + NETLIST_TYPE_ID aNetTypeId ); + void InstallPageSpice(); + void GenNetlist( wxCommandEvent& event ); + void RunSimulator( wxCommandEvent& event ); + void NetlistUpdateOpt(); + void OnCancelClick( wxCommandEvent& event ); + void OnNetlistTypeSelection( wxNotebookEvent& event ); + void SelectDefaultNetlistType( wxCommandEvent& event ); + void EnableSubcircuitPrefix( wxCommandEvent& event ); + + /** + * Function OnAddPlugin + * Add a new panel for a new netlist plugin + */ + void OnAddPlugin( wxCommandEvent& event ); + + /** + * Function OnDelPlugin + * Remove a panel relative to a netlist plugin + */ + void OnDelPlugin( wxCommandEvent& event ); + + /** + * Function WriteCurrentNetlistSetup + * Write the current netlist options setup in the configuration + */ + void WriteCurrentNetlistSetup(); + + bool GetUseDefaultNetlistName() + { + return m_cbUseDefaultNetlistName->IsChecked(); + } + + /** + * Function ReturnUserNetlistTypeName + * to retrieve user netlist type names + * @param first_item = true: return first name of the list, false = return next + * @return a wxString : name of the type netlist or empty string + * this function must be called first with "first_item" = true + * and after with "first_item" = false to get all the other existing netlist names + */ + const wxString ReturnUserNetlistTypeName( bool first_item ); + + /** + * Function ReturnFilenamePrms + * returns the filename extension and the wildcard string for this curr + * or a void name if there is no default name + * @param aNetTypeId = the netlist type ( NET_TYPE_PCBNEW ... ) + * @param aExt = a reference to a wxString to return the default file ext. + * @param aWildCard = reference to a wxString to return the default wildcard. + * @return true for known netlist type, false for custom formats + */ + bool ReturnFilenamePrms( NETLIST_TYPE_ID aNetTypeId, + wxString * aExt, wxString * aWildCard ); + + DECLARE_EVENT_TABLE() +}; + + +class NETLIST_DIALOG_ADD_PLUGIN : public NETLIST_DIALOG_ADD_PLUGIN_BASE +{ +private: + NETLIST_DIALOG* m_Parent; + +public: + NETLIST_DIALOG_ADD_PLUGIN( NETLIST_DIALOG* parent ); + const wxString GetPluginTitle() + { + return m_textCtrlName->GetValue(); + } + const wxString GetPluginTCommandLine() + { + return m_textCtrlCommand->GetValue(); + } + +private: + + /** + * Function OnOKClick + * Validate info relative to a new netlist plugin + */ + void OnOKClick( wxCommandEvent& event ); + void OnCancelClick( wxCommandEvent& event ); + + /* + * Browse plugin files, and set m_CommandStringCtrl field + */ + void OnBrowsePlugins( wxCommandEvent& event ); +}; + + /* Event id for notebook page buttons: */ enum id_netlist { ID_CREATE_NETLIST = ID_END_EESCHEMA_ID_LIST + 1, @@ -86,14 +258,7 @@ BEGIN_EVENT_TABLE( NETLIST_DIALOG, NETLIST_DIALOG_BASE ) END_EVENT_TABLE() -/*******************************/ -/* Functions for these classes */ -/*******************************/ - -/* Contructor to create a setup page for one netlist format. - * Used in Netlist format Dialog box creation - */ NETLIST_PAGE_DIALOG::NETLIST_PAGE_DIALOG( wxNotebook* parent, const wxString& title, NETLIST_TYPE_ID id_NetType ) : @@ -163,6 +328,7 @@ NETLIST_PAGE_DIALOG::NETLIST_PAGE_DIALOG( wxNotebook* parent, } } + const wxString NETLIST_PAGE_DIALOG::GetPageNetFmtName() { // PCBNEW Format is a special type: @@ -223,14 +389,6 @@ NETLIST_DIALOG::NETLIST_DIALOG( SCH_EDIT_FRAME* parent ) : } -/** - * Function ReturnUserNetlistTypeName - * to retrieve user netlist type names - * @param first_item = true: return first name of the list, false = return next - * @return a wxString : name of the type netlist or empty string - * this function must be called first with "first_item" = true - * and after with "first_item" = false to get all the other existing netlist names - */ const wxString NETLIST_DIALOG::ReturnUserNetlistTypeName( bool first_item ) { static int index; @@ -249,6 +407,7 @@ const wxString NETLIST_DIALOG::ReturnUserNetlistTypeName( bool first_item ) return name; } + void NETLIST_DIALOG::InstallPageSpice() { wxButton* Button; @@ -282,8 +441,6 @@ void NETLIST_DIALOG::InstallPageSpice() } -/* create the pages for custom netlist format selection: - */ void NETLIST_DIALOG::InstallCustomPages() { int ii; @@ -308,6 +465,7 @@ void NETLIST_DIALOG::InstallCustomPages() } } + NETLIST_PAGE_DIALOG* NETLIST_DIALOG::AddOneCustomPage( const wxString & aTitle, const wxString & aCommandString, NETLIST_TYPE_ID aNetTypeId ) @@ -346,8 +504,6 @@ NETLIST_PAGE_DIALOG* NETLIST_DIALOG::AddOneCustomPage( const wxString & aTitle, } -/* Called when the check box "default format" is clicked - */ void NETLIST_DIALOG::SelectDefaultNetlistType( wxCommandEvent& event ) { int ii; @@ -366,10 +522,7 @@ void NETLIST_DIALOG::SelectDefaultNetlistType( wxCommandEvent& event ) currPage->m_IsCurrentFormat->SetValue( true ); } -/* Called when a netlist type is selected. - * Enable/disable relevant/irrelevant widgets, and display the default - * netlist name, for known types - */ + void NETLIST_DIALOG::OnNetlistTypeSelection( wxNotebookEvent& event ) { NETLIST_PAGE_DIALOG* currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); @@ -390,10 +543,7 @@ void NETLIST_DIALOG::OnNetlistTypeSelection( wxNotebookEvent& event ) m_textCtrlDefaultFileName->Clear(); } -/* Called when the check box m_AddSubPrefix - * "default format" is clicked - * ( Spice format only ) - */ + void NETLIST_DIALOG::EnableSubcircuitPrefix( wxCommandEvent& event ) { @@ -407,6 +557,7 @@ void NETLIST_DIALOG::EnableSubcircuitPrefix( wxCommandEvent& event ) m_Parent->SetAddReferencePrefix( currPage->m_AddSubPrefix->IsChecked() ); } + void NETLIST_DIALOG::NetlistUpdateOpt() { int ii; @@ -425,12 +576,6 @@ void NETLIST_DIALOG::NetlistUpdateOpt() } -/** - * Function GenNetlist - * Create the netlist file: - * calculate the filename with the suitable extensions - * and run the netlist creator - */ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event ) { wxFileName fn; @@ -445,7 +590,7 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event ) unsigned netlist_opt = 0; - /* Calculate the netlist filename */ + // Calculate the netlist filename fn = g_RootSheet->GetScreen()->GetFileName(); ReturnFilenamePrms( currPage->m_IdNetType, &fileExt, &fileWildcard ); @@ -478,18 +623,20 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event ) if( fn.GetPath().IsEmpty() ) fn.SetPath( wxGetCwd() ); - wxString fullfilename = fn.GetFullPath(); + wxString fullpath = fn.GetFullPath(); if( !GetUseDefaultNetlistName() || currPage->m_IdNetType >= NET_TYPE_CUSTOM1 ) { - wxFileDialog dlg( this, title, fn.GetPath(), - fullfilename, fileWildcard, - wxFD_SAVE ); + wxString fullname = fn.GetFullName(); + wxString path = fn.GetPath(); + + // fullname does not and should not include the path, per wx docs. + wxFileDialog dlg( this, title, path, fullname, fileWildcard, wxFD_SAVE ); if( dlg.ShowModal() == wxID_CANCEL ) return; - fullfilename = dlg.GetPath(); + fullpath = dlg.GetPath(); // directory + filename } m_Parent->ClearMsgPanel(); @@ -499,22 +646,14 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event ) else m_Parent->SetNetListerCommand( wxEmptyString ); - m_Parent->CreateNetlist( currPage->m_IdNetType, fullfilename, netlist_opt ); + m_Parent->CreateNetlist( currPage->m_IdNetType, fullpath, netlist_opt ); WriteCurrentNetlistSetup(); EndModal( wxID_OK ); } -/** - * Function ReturnFilenamePrms - * returns the filename extension and the wildcard string for this curr - * or a void name if there is no default name - * @param aNetTypeId = the netlist type ( NET_TYPE_PCBNEW ... ) - * @param aExt = a reference to a wxString to return the default file ext. - * @param aWildCard = reference to a wxString to return the default wildcard. - * @return true for known netlist type, false for custom formats - */ + bool NETLIST_DIALOG::ReturnFilenamePrms( NETLIST_TYPE_ID aNetTypeId, wxString * aExt, wxString * aWildCard ) { @@ -555,15 +694,7 @@ bool NETLIST_DIALOG::ReturnFilenamePrms( NETLIST_TYPE_ID aNetTypeId, return ret; } -/* Function CreateNetlist - * > test for some issues (missing or duplicate references and sheet names) - * > build netlist info - * > create the netlist file - * param aFormat = netlist format (NET_TYPE_PCBNEW ...) - * param aFullFileName = full netlist file name - * param aNetlistOptions = netlist options using OR'ed bits (see WriteNetListFile). - * return true if success. - */ + bool SCH_EDIT_FRAME::CreateNetlist( int aFormat, const wxString& aFullFileName, unsigned aNetlistOptions ) { @@ -592,7 +723,7 @@ Do you want to annotate schematic?" ) ) ) return false; } - /* Cleanup the entire hierarchy */ + // Cleanup the entire hierarchy SCH_SCREENS screens; screens.SchematicCleanUp(); @@ -621,7 +752,7 @@ void NETLIST_DIALOG::RunSimulator( wxCommandEvent& event ) ExecFile = tmp.BeforeFirst( ' ' ); CommandLine = tmp.AfterFirst( ' ' ); - /* Calculate the netlist filename */ + // Calculate the netlist filename fn = g_RootSheet->GetScreen()->GetFileName(); fn.SetExt( wxT( "cir" ) ); CommandLine += wxT( " \"" ) + fn.GetFullPath() + wxT( "\"" ); @@ -643,11 +774,7 @@ void NETLIST_DIALOG::RunSimulator( wxCommandEvent& event ) } -/** - * Function WriteCurrentNetlistSetup - * Write the current netlist options setup in the configuration - */ -void NETLIST_DIALOG::WriteCurrentNetlistSetup( void ) +void NETLIST_DIALOG::WriteCurrentNetlistSetup() { wxString msg, Command; @@ -694,10 +821,6 @@ void NETLIST_DIALOG::WriteCurrentNetlistSetup( void ) } -/** - * Function OnDelPlugin - * Remove a panel relative to a netlist plugin - */ void NETLIST_DIALOG::OnDelPlugin( wxCommandEvent& event ) { NETLIST_PAGE_DIALOG* currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); @@ -715,10 +838,7 @@ void NETLIST_DIALOG::OnDelPlugin( wxCommandEvent& event ) EndModal( NET_PLUGIN_CHANGE ); } -/** - * Function OnAddPlugin - * Add a new panel for a new netlist plugin - */ + void NETLIST_DIALOG::OnAddPlugin( wxCommandEvent& event ) { NETLIST_DIALOG_ADD_PLUGIN dlg( this ); @@ -763,10 +883,7 @@ NETLIST_DIALOG_ADD_PLUGIN::NETLIST_DIALOG_ADD_PLUGIN( NETLIST_DIALOG* parent ) : GetSizer()->SetSizeHints( this ); } -/** - * Function OnOKClick - * Validate info relative to a new netlist plugin - */ + void NETLIST_DIALOG_ADD_PLUGIN::OnOKClick( wxCommandEvent& event ) { if( m_textCtrlCommand->GetValue() == wxEmptyString ) @@ -784,14 +901,13 @@ void NETLIST_DIALOG_ADD_PLUGIN::OnOKClick( wxCommandEvent& event ) EndModal( wxID_OK ); } + void NETLIST_DIALOG_ADD_PLUGIN::OnCancelClick( wxCommandEvent& event ) { EndModal( wxID_CANCEL ); } -/* - * Browse plugin files, and set m_CommandStringCtrl field - */ + void NETLIST_DIALOG_ADD_PLUGIN::OnBrowsePlugins( wxCommandEvent& event ) { wxString FullFileName, Mask, Path; @@ -834,3 +950,12 @@ void NETLIST_DIALOG_ADD_PLUGIN::OnBrowsePlugins( wxCommandEvent& event ) if( title.IsEmpty() ) wxMessageBox( _( "Do not forget to choose a title for this netlist control page" ) ); } + + +int InvokeDialogNetList( SCH_EDIT_FRAME* aCaller ) +{ + NETLIST_DIALOG dlg( aCaller ); + + return dlg.ShowModal(); +} + diff --git a/eeschema/dialogs/dialog_netlist.h b/eeschema/dialogs/dialog_netlist.h deleted file mode 100644 index 33311e4750..0000000000 --- a/eeschema/dialogs/dialog_netlist.h +++ /dev/null @@ -1,205 +0,0 @@ -/** - * @file eeschema/dialogs/dialog_netlist.h - */ - -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2012 Jean-Pierre Charras, jp.charras@wanadoo.fr - * Copyright (C) 2011 Wayne Stambaugh - * Copyright (C) 1992-2012 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 - */ - -#ifndef _DIALOG_NETLIST_H_ -#define _DIALOG_NETLIST_H_ - -#include - -#define CUSTOMPANEL_COUNTMAX 8 // Max number of netlist plugins - -// Id to select netlist type -enum NETLIST_TYPE_ID { - NET_TYPE_UNINIT = 0, - NET_TYPE_PCBNEW, - NET_TYPE_ORCADPCB2, - NET_TYPE_CADSTAR, - NET_TYPE_SPICE, - NET_TYPE_CUSTOM1, /* NET_TYPE_CUSTOM1 - * is the first id for user netlist format - * NET_TYPE_CUSTOM1+CUSTOMPANEL_COUNTMAX-1 - * is the last id for user netlist format - */ - NET_TYPE_CUSTOM_MAX = NET_TYPE_CUSTOM1 + CUSTOMPANEL_COUNTMAX - 1 -}; - -/* panel (notebook page) identifiers */ -enum panel_netlist_index { - PANELPCBNEW = 0, /* Handle Netlist format Pcbnew */ - PANELORCADPCB2, /* Handle Netlist format OracdPcb2 */ - PANELCADSTAR, /* Handle Netlist format CadStar */ - PANELSPICE, /* Handle Netlist format Pspice */ - PANELCUSTOMBASE /* First auxiliary panel (custom netlists). - * others use PANELCUSTOMBASE+1, PANELCUSTOMBASE+2.. */ -}; - -// Values returned when the netlist dialog is dismissed -#define NET_PLUGIN_CHANGE 1 -// other values in use are wxID_OK and wxID_CANCEL - - - -/* wxPanels for creating the NoteBook pages for each netlist format: */ -class NETLIST_PAGE_DIALOG : public wxPanel -{ -public: - NETLIST_TYPE_ID m_IdNetType; - wxCheckBox* m_IsCurrentFormat; - wxCheckBox* m_AddSubPrefix; - wxTextCtrl* m_CommandStringCtrl; - wxTextCtrl* m_TitleStringCtrl; - wxButton* m_ButtonCancel; - wxBoxSizer* m_LeftBoxSizer; - wxBoxSizer* m_RightBoxSizer; - wxBoxSizer* m_RightOptionsBoxSizer; - wxBoxSizer* m_LowBoxSizer; - wxRadioBox* m_NetOption; -private: - wxString m_pageNetFmtName; - -public: - /** Constructor to create a setup page for one netlist format. - * Used in Netlist format Dialog box creation - * @param parent = wxNotebook * parent - * @param title = title (name) of the notebook page - * @param id_NetType = netlist type id - */ - NETLIST_PAGE_DIALOG( wxNotebook* parent, const wxString& title, - NETLIST_TYPE_ID id_NetType ); - ~NETLIST_PAGE_DIALOG() { }; - - /** - * function GetPageNetFmtName - * @return the name of the netlist format for this page - * This is usually the page label. - * For the pcbnew netlist, this is "LegacyPcbnew" - * when the "old" format is selected - * and "PcbnewAdvanced" when the advanced format (S expr fmt)is selected - */ - const wxString GetPageNetFmtName(); - - void SetPageNetFmtName( const wxString &aName ) { m_pageNetFmtName = aName; } -}; - - -// Options for Spice netlist generation (OR'ed bits -enum netlistOptions { - NET_USE_X_PREFIX = 2, // for Spice netlist : change "U" and "IC" reference prefix to "X" - NET_PCBNEW_USE_NEW_FORMAT = 1, // For Pcbnew use the new format (S expression and SWEET) -}; - -/* Dialog frame for creating netlists */ -class NETLIST_DIALOG : public NETLIST_DIALOG_BASE -{ -public: - SCH_EDIT_FRAME* m_Parent; - wxString m_NetFmtName; - NETLIST_PAGE_DIALOG* m_PanelNetType[4 + CUSTOMPANEL_COUNTMAX]; - -private: - wxConfig* m_config; - -public: - - // Constructor and destructor - NETLIST_DIALOG( SCH_EDIT_FRAME* parent ); - ~NETLIST_DIALOG() { }; - -private: - void InstallCustomPages(); - NETLIST_PAGE_DIALOG* AddOneCustomPage( const wxString & aTitle, - const wxString & aCommandString, - NETLIST_TYPE_ID aNetTypeId ); - void InstallPageSpice(); - void GenNetlist( wxCommandEvent& event ); - void RunSimulator( wxCommandEvent& event ); - void NetlistUpdateOpt(); - void OnCancelClick( wxCommandEvent& event ); - void OnNetlistTypeSelection( wxNotebookEvent& event ); - void SelectDefaultNetlistType( wxCommandEvent& event ); - void EnableSubcircuitPrefix( wxCommandEvent& event ); - void OnAddPlugin( wxCommandEvent& event ); - void OnDelPlugin( wxCommandEvent& event ); - - void WriteCurrentNetlistSetup( void ); - - bool GetUseDefaultNetlistName() - { - return m_cbUseDefaultNetlistName->IsChecked(); - } - - /** - * Function ReturnUserNetlistTypeName - * to retrieve user netlist type names - * @param first_item = true: return first name of the list, false = return next - * @return a wxString : name of the type netlist or empty string - * this function must be called first with "first_item" = true - * and after with "first_item" = false to get all the other existing netlist names - */ - const wxString ReturnUserNetlistTypeName( bool first_item ); - - /** - * Function ReturnFilenamePrms - * returns the filename extension and the wildcard string for this curr - * or a void name if there is no default name - * @param aNetTypeId = the netlist type ( NET_TYPE_PCBNEW ... ) - * @param aExt = a reference to a wxString to return the default file ext. - * @param aWildCard = reference to a wxString to return the default wildcard. - * @return true for known netlist type, false for custom formats - */ - bool ReturnFilenamePrms( NETLIST_TYPE_ID aNetTypeId, - wxString * aExt, wxString * aWildCard ); - - DECLARE_EVENT_TABLE() -}; - - -class NETLIST_DIALOG_ADD_PLUGIN : public NETLIST_DIALOG_ADD_PLUGIN_BASE -{ -private: - NETLIST_DIALOG* m_Parent; - -public: - NETLIST_DIALOG_ADD_PLUGIN( NETLIST_DIALOG* parent ); - const wxString GetPluginTitle() - { - return m_textCtrlName->GetValue(); - } - const wxString GetPluginTCommandLine() - { - return m_textCtrlCommand->GetValue(); - } - -private: - void OnOKClick( wxCommandEvent& event ); - void OnCancelClick( wxCommandEvent& event ); - void OnBrowsePlugins( wxCommandEvent& event ); -}; - -#endif /* _DIALOG_NETLIST_H_ */ diff --git a/eeschema/invoke_sch_dialog.h b/eeschema/invoke_sch_dialog.h index a1f6ffcc95..4cd27be957 100644 --- a/eeschema/invoke_sch_dialog.h +++ b/eeschema/invoke_sch_dialog.h @@ -65,5 +65,15 @@ int InvokeDialogPrintUsingPrinter( SCH_EDIT_FRAME* aCaller ); /// DIALOG_BOM::ShowModal() returns. int InvokeDialogCreateBOM( SCH_EDIT_FRAME* aCaller ); +/** + * Function InvokeDialogNetList + * creates and shows NETLIST_DIALOG and returns whatever + * NETLIST_DIALOG::ShowModal() returns. + * @param int - NET_PLUGIN_CHANGE means user added or deleted a plugin, + * wxID_OK, or wxID_CANCEL. +*/ +#define NET_PLUGIN_CHANGE 1 +int InvokeDialogNetList( SCH_EDIT_FRAME* aCaller ); + #endif // INVOKE_SCH_DIALOG_H_ diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index 1d5e1ae7b8..fbb16a245b 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -37,7 +37,6 @@ #include #include -#include #include #include #include diff --git a/eeschema/netlist.h b/eeschema/netlist.h index 2a3c439366..2dd7f977e7 100644 --- a/eeschema/netlist.h +++ b/eeschema/netlist.h @@ -39,6 +39,29 @@ #include +/// netlist types +enum NETLIST_TYPE_ID { + NET_TYPE_UNINIT = 0, + NET_TYPE_PCBNEW, + NET_TYPE_ORCADPCB2, + NET_TYPE_CADSTAR, + NET_TYPE_SPICE, + NET_TYPE_CUSTOM1, /* NET_TYPE_CUSTOM1 + * is the first id for user netlist format + * NET_TYPE_CUSTOM1+CUSTOMPANEL_COUNTMAX-1 + * is the last id for user netlist format + */ + //NET_TYPE_CUSTOM_MAX = NET_TYPE_CUSTOM1 + CUSTOMPANEL_COUNTMAX - 1 +}; + + +/// Options for Spice netlist generation (OR'ed bits +enum netlistOptions { + NET_USE_X_PREFIX = 2, // for Spice netlist : change "U" and "IC" reference prefix to "X" + NET_PCBNEW_USE_NEW_FORMAT = 1, // For Pcbnew use the new format (S expression and SWEET) +}; + + class SCH_COMPONENT; class SCH_REFERENC_LIST; @@ -46,7 +69,7 @@ class SCH_REFERENC_LIST; #define NETLIST_HEAD_STRING "EESchema Netlist Version 1.1" // Max pin number per component and footprint -#define MAXPIN 5000 +#define MAXPIN 5000 /** diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 49fa8390e5..45ed6a8d91 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -44,7 +44,6 @@ #include #include -#include #include #include #include @@ -617,16 +616,15 @@ void SCH_EDIT_FRAME::OnErc( wxCommandEvent& event ) void SCH_EDIT_FRAME::OnCreateNetlist( wxCommandEvent& event ) { - int i; + int result; do { - NETLIST_DIALOG* dlg = new NETLIST_DIALOG( this ); - i = dlg->ShowModal(); - dlg->Destroy(); - } while( i == NET_PLUGIN_CHANGE ); + result = InvokeDialogNetList( this ); - // If a plugin is removed or added, rebuild and reopen the new dialog + // If a plugin is removed or added, rebuild and reopen the new dialog + + } while( result == NET_PLUGIN_CHANGE ); } From 0a11144cad2b7320539eb17f309f88207456c01a Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Thu, 27 Jun 2013 16:34:01 -0500 Subject: [PATCH 41/50] fix legacy board file footprint name setting in MODULE --- pcbnew/legacy_plugin.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index c780c85da0..f45a4a78cb 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -277,6 +277,9 @@ void LEGACY_PLUGIN::loadAllSections( bool doAppend ) if( TESTLINE( "$MODULE" ) ) { auto_ptr module( new MODULE( m_board ) ); + + module->SetLibRef( FROM_UTF8( StrPurge( line + SZ( "$MODULE" ) ) ) ); + LoadMODULE( module.get() ); m_board->Add( module.release(), ADD_APPEND ); } @@ -998,12 +1001,14 @@ void LEGACY_PLUGIN::LoadMODULE( MODULE* aModule ) aModule->SetLastEditTime( edittime ); } + /* footprint name set earlier, immediately after MODULE construction else if( TESTLINE( "Li" ) ) // Library name of footprint { // There can be whitespace in the footprint name on some old libraries. // Grab everything after "Li" up to end of line: //aModule->SetLibRef( FROM_UTF8( StrPurge( line + SZ( "Li" ) ) ) ); } + */ else if( TESTLINE( "Sc" ) ) // timestamp { From 820153c7d4c8f8e69de82061ad55ce8f7273bb9c Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 28 Jun 2013 12:49:43 +0200 Subject: [PATCH 42/50] Gerbview: remove fully outdated code (about reading DCode files) and fix erroneous comments. --- gerbview/dcode.cpp | 128 --------------------------- gerbview/events_called_functions.cpp | 1 - gerbview/files.cpp | 31 ------- gerbview/gerbview.cpp | 3 +- gerbview/gerbview_frame.h | 57 +++--------- gerbview/gerbview_id.h | 1 - gerbview/menubar.cpp | 6 -- gerbview/readgerb.cpp | 10 ++- 8 files changed, 18 insertions(+), 219 deletions(-) diff --git a/gerbview/dcode.cpp b/gerbview/dcode.cpp index f8a43bb263..5e1dc793c3 100644 --- a/gerbview/dcode.cpp +++ b/gerbview/dcode.cpp @@ -154,134 +154,6 @@ int D_CODE::GetShapeDim( GERBER_DRAW_ITEM* aParent ) } -int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName ) -{ - int current_Dcode, ii; - char* ptcar; - int dimH, dimV, drill, dummy; - float fdimH, fdimV, fdrill; - char c_type_outil[256]; - char line[GERBER_BUFZ]; - wxString msg; - D_CODE* dcode; - FILE* dest; - LAYER_NUM layer = getActiveLayer(); - int type_outil; - - if( g_GERBER_List[layer] == NULL ) - g_GERBER_List[layer] = new GERBER_IMAGE( this, layer ); - - GERBER_IMAGE* gerber = g_GERBER_List[layer]; - - - /* Updating gerber scale: */ - double dcode_scale = IU_PER_MILS; // By uniting dCode = mil, - // internal unit = IU_PER_MILS - current_Dcode = 0; - - if( D_Code_FullFileName.IsEmpty() ) - return 0; - - dest = wxFopen( D_Code_FullFileName, wxT( "rt" ) ); - if( dest == 0 ) - { - msg.Printf( _( "File <%s> not found" ), GetChars( D_Code_FullFileName ) ); - DisplayError( this, msg, 10 ); - return -1; - } - - gerber->InitToolTable(); - - while( fgets( line, sizeof(line) - 1, dest ) != NULL ) - { - if( *line == ';' ) - continue; - - if( strlen( line ) < 10 ) - continue; /* Skip blank line. */ - - dcode = NULL; - current_Dcode = 0; - - /* Determine of the type of file from D_Code. */ - ptcar = line; - ii = 0; - - while( *ptcar ) - if( *(ptcar++) == ',' ) - ii++; - - if( ii >= 6 ) /* value in mils */ - { - sscanf( line, "%d,%d,%d,%d,%d,%d,%d", &ii, - &dimH, &dimV, &drill, &dummy, &dummy, &type_outil ); - - dimH = KiROUND( dimH * dcode_scale ); - dimV = KiROUND( dimV * dcode_scale ); - drill = KiROUND( drill * dcode_scale ); - - if( ii < 1 ) - ii = 1; - - current_Dcode = ii - 1 + FIRST_DCODE; - } - else /* Values in inches are converted to mils. */ - { - fdrill = 0; - current_Dcode = 0; - - sscanf( line, "%f,%f,%1s", &fdimV, &fdimH, c_type_outil ); - ptcar = line; - - while( *ptcar ) - { - if( *ptcar == 'D' ) - { - sscanf( ptcar + 1, "%d,%f", ¤t_Dcode, &fdrill ); - break; - } - else - { - ptcar++; - } - } - - dimH = KiROUND( fdimH * dcode_scale * 1000 ); - dimV = KiROUND( fdimV * dcode_scale * 1000 ); - drill = KiROUND( fdrill * dcode_scale * 1000 ); - - if( strchr( "CLROP", c_type_outil[0] ) ) - { - type_outil = (APERTURE_T) c_type_outil[0]; - } - else - { - fclose( dest ); - return -2; - } - } - - /* Update the list of d_codes if consistent. */ - if( current_Dcode < FIRST_DCODE ) - continue; - - if( current_Dcode >= TOOLS_MAX_COUNT ) - continue; - - dcode = gerber->GetDCODE( current_Dcode ); - dcode->m_Size.x = dimH; - dcode->m_Size.y = dimV; - dcode->m_Shape = (APERTURE_T) type_outil; - dcode->m_Drill.x = dcode->m_Drill.y = drill; - dcode->m_Defined = true; - } - - fclose( dest ); - - return 1; -} - - void GERBVIEW_FRAME::CopyDCodesSizeToItems() { static D_CODE dummy( 999 ); //Used if D_CODE not found in list diff --git a/gerbview/events_called_functions.cpp b/gerbview/events_called_functions.cpp index 828021cb2d..6efd44786d 100644 --- a/gerbview/events_called_functions.cpp +++ b/gerbview/events_called_functions.cpp @@ -29,7 +29,6 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME ) EVT_TOOL( wxID_FILE, GERBVIEW_FRAME::Files_io ) EVT_TOOL( ID_GERBVIEW_ERASE_ALL, GERBVIEW_FRAME::Files_io ) EVT_TOOL( ID_GERBVIEW_LOAD_DRILL_FILE, GERBVIEW_FRAME::Files_io ) - EVT_TOOL( ID_GERBVIEW_LOAD_DCODE_FILE, GERBVIEW_FRAME::Files_io ) EVT_TOOL( ID_NEW_BOARD, GERBVIEW_FRAME::Files_io ) EVT_TOOL( ID_GERBVIEW_SET_PAGE_BORDER, GERBVIEW_FRAME::Process_Special_Functions ) diff --git a/gerbview/files.cpp b/gerbview/files.cpp index 14cb8fc4df..a4e22938aa 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -90,11 +90,6 @@ void GERBVIEW_FRAME::Files_io( wxCommandEvent& event ) m_canvas->Refresh(); break; - case ID_GERBVIEW_LOAD_DCODE_FILE: - LoadDCodeFile( wxEmptyString ); - m_canvas->Refresh(); - break; - default: wxFAIL_MSG( wxT( "File_io: unexpected command id" ) ); break; @@ -290,29 +285,3 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) return true; } - - -bool GERBVIEW_FRAME::LoadDCodeFile( const wxString& aFullFileName ) -{ - wxString wildcard; - wxFileName fn = aFullFileName; - - if( !fn.IsOk() ) - { - wildcard = _( "Gerber DCODE files" ); - wildcard += wxT(" ") + AllFilesWildcard; - fn = m_lastFileName; - wxFileDialog dlg( this, _( "Load GERBER DCODE File" ), - fn.GetPath(), fn.GetFullName(), wildcard, - wxFD_OPEN | wxFD_FILE_MUST_EXIST ); - - if( dlg.ShowModal() == wxID_CANCEL ) - return false; - - fn = dlg.GetPath(); - } - - ReadDCodeDefinitionFile( fn.GetFullPath() ); - CopyDCodesSizeToItems(); - return true; -} diff --git a/gerbview/gerbview.cpp b/gerbview/gerbview.cpp index a79cf2038a..57d2b8462f 100644 --- a/gerbview/gerbview.cpp +++ b/gerbview/gerbview.cpp @@ -26,12 +26,11 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - #include +#include #include #include #include #include -//#include #include #include diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index d12e00d840..98cf6fe83d 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -379,14 +379,14 @@ public: /** * Function ReFillLayerWidget * changes out all the layers in m_Layers and may be called upon - * loading a new BOARD. + * loading new gerber files. */ void ReFillLayerWidget(); /** * Function setActiveLayer * will change the currently active layer to \a aLayer and also - * update the PCB_LAYER_WIDGET. + * update the GERBER_LAYER_WIDGET. */ void setActiveLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate = true ); @@ -412,7 +412,7 @@ public: /** * Function syncLayerWidget - * updates the currently "selected" layer within the PCB_LAYER_WIDGET. + * updates the currently "selected" layer within the GERBER_LAYER_WIDGET. * The currently active layer is defined by the return value of getActiveLayer(). *

* This function cannot be inline without including layer_widget.h in @@ -453,10 +453,11 @@ public: /** * Load applications settings specific to the Pcbnew. * - * This overrides the base class PCB_BASE_FRAME::LoadSettings() to + * This overrides the base class EDA_DRAW_FRAME::LoadSettings() to * handle settings specific common to the PCB layout application. It - * calls down to the base class to load settings common to all PCB type - * drawing frames. Please put your application settings for Pcbnew here + * calls down to the base class to load settings common to all + * EDA_DRAW_FRAME type drawing frames. + * Please put your application settings for Pcbnew here * to avoid having application settings loaded all over the place. */ virtual void LoadSettings(); @@ -464,10 +465,10 @@ public: /** * Save applications settings common to PCB draw frame objects. * - * This overrides the base class PCB_BASE_FRAME::SaveSettings() to - * save settings specific to the PCB layout application main window. It - * calls down to the base class to save settings common to all PCB type - * drawing frames. Please put your application settings for Pcbnew here + * This overrides the base class EDA_DRAW_FRAME::SaveSettings() to + * save settings specific to the gerbview application main window. It + * calls down to the base class to save settings common to all + * drawing frames. Please put your application settings for Gerbview here * to avoid having application settings saved all over the place. */ virtual void SaveSettings(); @@ -638,42 +639,6 @@ public: void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); - /** - * Read a DCode file (not used with RX274X files , just with RS274D old files). - * Note: there is no standard for DCode file. - * Just read a file format created by early versions of Pcbnew. - * @return false if file not read (cancellation) - * true if OK - * @ aparm aFullFileName = name of file to load. - * if empty, or if the file does not exist, a file dialog is opened - */ - bool LoadDCodeFile( const wxString& aFullFileName ); - - /** - * Function ReadDCodeDefinitionFile - * reads in a dcode file assuming ALSPCB file format with ';' indicating - * comments. - *

- * Format is like CSV but with optional ';' delineated comments:
- * tool, Horiz, Vert, drill, vitesse, acc. ,Type ; [DCODE (commentaire)]
- * ex: 1, 12, 12, 0, 0, 0, 3 ; D10 - *

- * Format:
- * Ver, Hor, Type, Tool [,Drill]
- * example: 0.012, 0.012, L , D10
- * - * Load all found dcodes into a table of D_CODE instantiations. - * @param D_Code_FullFileName The name of the file to read from. - * @return int -
- * -1 = file not found
- * -2 = parsing problem
- * 0 = the \a D_Code_FullFileName is empty, no reading - * is done but an empty GERBER is put into - * g_GERBER_List[]
- * 1 = read OK
- */ - int ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName ); - /** * Set Size Items (Lines, Flashes) from DCodes List */ diff --git a/gerbview/gerbview_id.h b/gerbview/gerbview_id.h index 3adc44b6ed..9304b8e2cb 100644 --- a/gerbview/gerbview_id.h +++ b/gerbview/gerbview_id.h @@ -17,7 +17,6 @@ enum gerbview_ids ID_GERBVIEW_SHOW_LIST_DCODES, ID_GERBVIEW_LOAD_DRILL_FILE, - ID_GERBVIEW_LOAD_DCODE_FILE, ID_GERBVIEW_ERASE_ALL, ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE, ID_GERBVIEW_SHOW_SOURCE, diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index 982de72de6..6ea327a46b 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -71,12 +71,6 @@ void GERBVIEW_FRAME::ReCreateMenuBar( void ) _( "Load excellon drill file" ), KiBitmap( gerbview_drill_file_xpm ) ); - // Dcodes - AddMenuItem( fileMenu, ID_GERBVIEW_LOAD_DCODE_FILE, - _( "Load &DCodes" ), - _( "Load D-Codes definition file" ), - KiBitmap( gerber_open_dcode_file_xpm ) ); - // Recent gerber files static wxMenu* openRecentGbrMenu; diff --git a/gerbview/readgerb.cpp b/gerbview/readgerb.cpp index 74a9cb9ea3..01ae04cb4f 100644 --- a/gerbview/readgerb.cpp +++ b/gerbview/readgerb.cpp @@ -162,13 +162,15 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName, dlg.ShowModal(); } - /* Init DCodes list and perhaps read a DCODES file, - * if the gerber file is only a RS274D file - * (i.e. without any aperture information) + /* if the gerber file is only a RS274D file + * (i.e. without any aperture information), wran the user: */ if( !gerber->m_Has_DCode ) { - return LoadDCodeFile( D_Code_FullFileName ); + msg = _("Warning: this file has no D-Code definition\n" + "It is perhaps an old RS274D file\n" + "Therefore the size of items is undefined"); + wxMessageBox( msg ); } return true; From a56d3235e3bf9219c61e06a18ed433b25e47403e Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Fri, 28 Jun 2013 12:29:39 -0400 Subject: [PATCH 43/50] Prevent GTK printing build error on Linux * Do not fail to build when wxWidgets is built with either --with-gnomeprint or --with-gtkprint are not configured. Only display warning. * Move warning code from include/common.h to common/common.cpp so it only shows the warning once instead of every source file that includes common.h --- common/common.cpp | 14 ++++++++++++++ include/common.h | 10 ---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/common/common.cpp b/common/common.cpp index aae5441be9..383eb80350 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -40,6 +40,20 @@ #include + +// Fail build if wxWidgets printing was not configured. +#if !wxUSE_PRINTING_ARCHITECTURE && !SWIG +# error "You must use '--enable-printarch' in your wx library configuration." +#endif + +// Show warning if wxWidgets Gnome or GTK printing was not configured. +#if defined( __WXGTK__ ) +# if !wxUSE_LIBGNOMEPRINT && !wxUSE_GTKPRINT && !SWIG +# warning "You must use '--with-gnomeprint' or '--with-gtkprint' in your wx library configuration for full print capabilities." +# endif +#endif + + /** * Global variables definitions. * diff --git a/include/common.h b/include/common.h index c116e85cfc..fe8f3d08cc 100644 --- a/include/common.h +++ b/include/common.h @@ -42,16 +42,6 @@ #include #include -#if !wxUSE_PRINTING_ARCHITECTURE && !SWIG -# error "You must use '--enable-printarch' in your wx library configuration." -#endif - -#if defined( __WXGTK__ ) -# if !wxUSE_LIBGNOMEPRINT && !wxUSE_GTKPRINT && !SWIG -# error "You must use '--with-gnomeprint' or '--with-gtkprint' in your wx library configuration." -# endif -#endif - class wxAboutDialogInfo; From 5c247857d3c9b6d2cb1f15705374fa0369b6e7e3 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 29 Jun 2013 11:52:22 +0200 Subject: [PATCH 44/50] Replace in EDA_TEXT::Draw the parameter EDA_DRAW_PANEL* aPanel by EDA_RECT* aClipBox, which is the actual parameter used by Draw. This change make more easy to use this function when a EDA_DRAW_PANEL canvas is not used to draw texts. Remove dead code in worksheet.cpp. --- common/drawtxt.cpp | 39 +++---- common/eda_text.cpp | 38 +++---- common/worksheet.cpp | 155 +++++++++++----------------- eeschema/lib_field.cpp | 5 +- eeschema/lib_pin.cpp | 23 +++-- eeschema/lib_text.cpp | 5 +- eeschema/sch_field.cpp | 7 +- eeschema/sch_sheet.cpp | 7 +- eeschema/sch_text.cpp | 22 ++-- gerbview/draw_gerber_screen.cpp | 2 +- include/drawtxt.h | 6 +- include/eda_text.h | 14 +-- include/worksheet.h | 14 ++- include/worksheet_shape_builder.h | 13 ++- include/wxstruct.h | 9 -- pcbnew/class_pad_draw_functions.cpp | 6 +- pcbnew/class_pcb_text.cpp | 3 +- pcbnew/class_text_mod.cpp | 9 +- pcbnew/class_track.cpp | 18 ++-- 19 files changed, 177 insertions(+), 218 deletions(-) diff --git a/common/drawtxt.cpp b/common/drawtxt.cpp index b7da2dc15f..5fe1d5f768 100644 --- a/common/drawtxt.cpp +++ b/common/drawtxt.cpp @@ -242,7 +242,7 @@ static void DrawGraphicTextPline( EDA_RECT* aClipBox, /** * Function DrawGraphicText * Draw a graphic text (like module texts) - * @param aPanel = the current m_canvas. NULL if draw within a 3D GL Canvas + * @param aClipBox = the clipping rect, or NULL if no clipping * @param aDC = the current Device Context. NULL if draw within a 3D GL Canvas * @param aPos = text position (according to h_justify, v_justify) * @param aColor (enum EDA_COLOR_T) = text color @@ -261,7 +261,7 @@ static void DrawGraphicTextPline( EDA_RECT* aClipBox, * @param aPlotter = a pointer to a PLOTTER instance, when this function is used to plot * the text. NULL to draw this text. */ -void DrawGraphicText( EDA_DRAW_PANEL* aPanel, +void DrawGraphicText( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aPos, EDA_COLOR_T aColor, @@ -284,9 +284,6 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, wxPoint current_char_pos; // Draw coordinates for the current char wxPoint overbar_pos; // Start point for the current overbar int overbar_italic_comp; // Italic compensation for overbar - EDA_RECT* clipBox; // Clip box used in basic draw functions - - clipBox = aPanel ? aPanel->GetClipBox() : NULL; #define BUF_SIZE 100 wxPoint coord[BUF_SIZE + 1]; // Buffer coordinate used to draw polylines (one char shape) bool sketch_mode = false; @@ -322,7 +319,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, dy = size_v; /* Do not draw the text if out of draw area! */ - if( aPanel ) + if( aClipBox ) { int xm, ym, ll, xc, yc; ll = std::abs( dx ); @@ -330,10 +327,10 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, xc = current_char_pos.x; yc = current_char_pos.y; - x0 = aPanel->GetClipBox()->GetX() - ll; - y0 = aPanel->GetClipBox()->GetY() - ll; - xm = aPanel->GetClipBox()->GetRight() + ll; - ym = aPanel->GetClipBox()->GetBottom() + ll; + x0 = aClipBox->GetX() - ll; + y0 = aClipBox->GetY() - ll; + xm = aClipBox->GetRight() + ll; + ym = aClipBox->GetBottom() + ll; if( xc < x0 ) return; @@ -407,7 +404,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, aCallback( current_char_pos.x, current_char_pos.y, end.x, end.y ); } else - GRLine( clipBox, aDC, + GRLine( aClipBox, aDC, current_char_pos.x, current_char_pos.y, end.x, end.y, aWidth, aColor ); return; @@ -461,7 +458,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, RotatePoint( &overbar_pos, aPos, aOrient ); coord[1] = overbar_pos; // Plot the overbar segment - DrawGraphicTextPline( clipBox, aDC, aColor, aWidth, + DrawGraphicTextPline( aClipBox, aDC, aColor, aWidth, sketch_mode, 2, coord, aCallback, aPlotter ); } @@ -508,7 +505,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, if( aWidth <= 1 ) aWidth = 0; - DrawGraphicTextPline( clipBox, aDC, aColor, aWidth, + DrawGraphicTextPline( aClipBox, aDC, aColor, aWidth, sketch_mode, point_count, coord, aCallback, aPlotter ); } @@ -554,13 +551,12 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, coord[1] = overbar_pos; // Plot the overbar segment - DrawGraphicTextPline( clipBox, aDC, aColor, aWidth, + DrawGraphicTextPline( aClipBox, aDC, aColor, aWidth, sketch_mode, 2, coord, aCallback, aPlotter ); } } -void DrawGraphicHaloText( EDA_DRAW_PANEL * aPanel, - wxDC * aDC, +void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC, const wxPoint &aPos, enum EDA_COLOR_T aBgColor, enum EDA_COLOR_T aColor1, @@ -570,24 +566,23 @@ void DrawGraphicHaloText( EDA_DRAW_PANEL * aPanel, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, - int aWidth, - bool aItalic, - bool aBold, + int aWidth, bool aItalic, bool aBold, void (*aCallback)( int x0, int y0, int xf, int yf ), PLOTTER * aPlotter ) { // Swap color if contrast would be better - if( ColorIsLight( aBgColor ) ) { + if( ColorIsLight( aBgColor ) ) + { EDA_COLOR_T c = aColor1; aColor1 = aColor2; aColor2 = c; } - DrawGraphicText( aPanel, aDC, aPos, aColor1, aText, aOrient, aSize, + DrawGraphicText( aClipBox, aDC, aPos, aColor1, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic, aBold, aCallback, aPlotter ); - DrawGraphicText( aPanel, aDC, aPos, aColor2, aText, aOrient, aSize, + DrawGraphicText( aClipBox, aDC, aPos, aColor2, aText, aOrient, aSize, aH_justify, aV_justify, aWidth / 4, aItalic, aBold, aCallback, aPlotter ); } diff --git a/common/eda_text.cpp b/common/eda_text.cpp index 59383b2dcb..2c90aa4891 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -35,10 +35,13 @@ // Conversion to application internal units defined at build time. #if defined( PCBNEW ) -#include + #include #elif defined( EESCHEMA ) -#include + #include #elif defined( GERBVIEW ) +#elif defined( PL_EDITOR ) + #include + #define FMT_IU Double2Str #else #error "Cannot resolve units formatting due to no definition of EESCHEMA or PCBNEW." #endif @@ -212,7 +215,7 @@ bool EDA_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy } -void EDA_TEXT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, +void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode, EDA_COLOR_T aAnchor_color ) { @@ -229,34 +232,23 @@ void EDA_TEXT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, for( unsigned i = 0; iCount(); i++ ) { wxString txt = list->Item( i ); - DrawOneLineOfText( aPanel, - aDC, - aOffset, - aColor, - aDrawMode, - aFillMode, + drawOneLineOfText( aClipBox, aDC, aOffset, aColor, + aDrawMode, aFillMode, i ? UNSPECIFIED_COLOR : aAnchor_color, - txt, - pos ); + txt, pos ); pos += offset; } delete (list); } else - DrawOneLineOfText( aPanel, - aDC, - aOffset, - aColor, - aDrawMode, - aFillMode, - aAnchor_color, - m_Text, - m_Pos ); + drawOneLineOfText( aClipBox, aDC, aOffset, aColor, + aDrawMode, aFillMode, + aAnchor_color, m_Text, m_Pos ); } -void EDA_TEXT::DrawOneLineOfText( EDA_DRAW_PANEL* aPanel, wxDC* aDC, +void EDA_TEXT::drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode, EDA_COLOR_T aAnchor_color, @@ -273,7 +265,7 @@ void EDA_TEXT::DrawOneLineOfText( EDA_DRAW_PANEL* aPanel, wxDC* aDC, // Draw text anchor, if requested if( aAnchor_color != UNSPECIFIED_COLOR ) { - GRDrawAnchor( aPanel->GetClipBox(), aDC, + GRDrawAnchor( aClipBox, aDC, aPos.x + aOffset.x, aPos.y + aOffset.y, DIM_ANCRE_TEXTE, aAnchor_color ); } @@ -286,7 +278,7 @@ void EDA_TEXT::DrawOneLineOfText( EDA_DRAW_PANEL* aPanel, wxDC* aDC, if( m_Mirror ) size.x = -size.x; - DrawGraphicText( aPanel, aDC, aOffset + aPos, aColor, aText, m_Orient, size, + DrawGraphicText( aClipBox, aDC, aOffset + aPos, aColor, aText, m_Orient, size, m_HJustify, m_VJustify, width, m_Italic, m_Bold ); } diff --git a/common/worksheet.cpp b/common/worksheet.cpp index f3fc9b5463..d3c242f1be 100644 --- a/common/worksheet.cpp +++ b/common/worksheet.cpp @@ -46,15 +46,68 @@ static const wxString productName = wxT( "KiCad E.D.A. " ); +/* Draws the item list crated by BuildWorkSheetGraphicList + * aClipBox = the clipping rect, or NULL if no clipping + * aDC = the current Device Context + */ +void WS_DRAW_ITEM_LIST::Draw( EDA_RECT* aClipBox, wxDC* aDC ) +{ + for( WS_DRAW_ITEM_BASE* item = GetFirst(); item; item = GetNext() ) + { + switch( item->GetType() ) + { + case WS_DRAW_ITEM_BASE::wsg_line: + { + WS_DRAW_ITEM_LINE* line = (WS_DRAW_ITEM_LINE*) item; + GRLine( aClipBox, aDC, + line->GetStart(), line->GetEnd(), + line->GetPenWidth(), line->GetColor() ); + } + break; -void DrawPageLayout( wxDC* aDC, EDA_DRAW_PANEL * aCanvas, + case WS_DRAW_ITEM_BASE::wsg_rect: + { + WS_DRAW_ITEM_RECT* rect = (WS_DRAW_ITEM_RECT*) item; + GRRect( aClipBox, aDC, + rect->GetStart().x, rect->GetStart().y, + rect->GetEnd().x, rect->GetEnd().y, + rect->GetPenWidth(), rect->GetColor() ); + } + break; + + case WS_DRAW_ITEM_BASE::wsg_text: + { + WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item; + DrawGraphicText( aClipBox, aDC, text->GetTextPosition(), + text->GetColor(), text->GetText(), + text->GetOrientation(), text->GetSize(), + text->GetHorizJustify(), text->GetVertJustify(), + text->GetPenWidth(), text->IsItalic(), text->IsBold() ); + } + break; + + case WS_DRAW_ITEM_BASE::wsg_poly: + { + WS_DRAW_ITEM_POLYGON* poly = (WS_DRAW_ITEM_POLYGON*) item; + GRPoly( aClipBox, aDC, + poly->m_Corners.size(), &poly->m_Corners[0], + poly->IsFilled() ? FILLED_SHAPE : NO_FILL, + poly->GetPenWidth(), + poly->GetColor(), poly->GetColor() ); + } + break; + } + } +} + +void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox, const PAGE_INFO& aPageInfo, const wxString &aFullSheetName, const wxString& aFileName, TITLE_BLOCK& aTitleBlock, int aSheetCount, int aSheetNumber, int aPenWidth, double aScalar, - EDA_COLOR_T aLineColor, EDA_COLOR_T aTextColor ) + EDA_COLOR_T aColor, EDA_COLOR_T aAltColor ) { GRSetDrawMode( aDC, GR_COPY ); WS_DRAW_ITEM_LIST drawList; @@ -72,56 +125,10 @@ void DrawPageLayout( wxDC* aDC, EDA_DRAW_PANEL * aCanvas, drawList.BuildWorkSheetGraphicList( aPageInfo.GetType(), aFullSheetName, aFileName, - aTitleBlock, aLineColor, aTextColor ); + aTitleBlock, aColor, aAltColor ); // Draw item list - for( WS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item; - item = drawList.GetNext() ) - { - switch( item->GetType() ) - { - case WS_DRAW_ITEM_BASE::wsg_line: - { - WS_DRAW_ITEM_LINE* line = (WS_DRAW_ITEM_LINE*) item; - GRLine( aCanvas ? aCanvas->GetClipBox() : NULL, aDC, - line->GetStart(), line->GetEnd(), - line->GetPenWidth(), line->GetColor() ); - } - break; - - case WS_DRAW_ITEM_BASE::wsg_rect: - { - WS_DRAW_ITEM_RECT* rect = (WS_DRAW_ITEM_RECT*) item; - GRRect( aCanvas ? aCanvas->GetClipBox() : NULL, aDC, - rect->GetStart().x, rect->GetStart().y, - rect->GetEnd().x, rect->GetEnd().y, - rect->GetPenWidth(), rect->GetColor() ); - } - break; - - case WS_DRAW_ITEM_BASE::wsg_text: - { - WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item; - DrawGraphicText( aCanvas, aDC, text->GetTextPosition(), - text->GetColor(), text->GetText(), - text->GetOrientation(), text->GetSize(), - text->GetHorizJustify(), text->GetVertJustify(), - text->GetPenWidth(), text->IsItalic(), text->IsBold() ); - } - break; - - case WS_DRAW_ITEM_BASE::wsg_poly: - { - WS_DRAW_ITEM_POLYGON* poly = (WS_DRAW_ITEM_POLYGON*) item; - GRPoly( aCanvas ? aCanvas->GetClipBox() : NULL, aDC, - poly->m_Corners.size(), &poly->m_Corners[0], - poly->IsFilled() ? FILLED_SHAPE : NO_FILL, - poly->GetPenWidth(), - poly->GetColor(), poly->GetColor() ); - } - break; - } - } + drawList.Draw( aClipBox, aDC ); } @@ -146,59 +153,13 @@ void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWi TITLE_BLOCK t_block = GetTitleBlock(); EDA_COLOR_T color = RED; - DrawPageLayout( aDC, m_canvas, pageInfo, + DrawPageLayout( aDC, m_canvas->GetClipBox(), pageInfo, aFilename, GetScreenDesc(), t_block, aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber, aLineWidth, aScalar, color, color ); } -const wxString EDA_DRAW_FRAME::GetXYSheetReferences( const wxPoint& aPosition ) const -{ - const PAGE_INFO& pageInfo = GetPageSettings(); - - int ii; - int xg, yg; - int ipas; - int gxpas, gypas; - int refx, refy; - wxString msg; - - // Upper left corner - refx = pageInfo.GetLeftMarginMils(); - refy = pageInfo.GetTopMarginMils(); - - // lower right corner - xg = pageInfo.GetSizeMils().x - pageInfo.GetRightMarginMils(); - yg = pageInfo.GetSizeMils().y - pageInfo.GetBottomMarginMils(); - - // Get the Y axis identifier (A symbol A ... Z) - if( aPosition.y < refy || aPosition.y > yg ) // Outside of Y limits - msg << wxT( "?" ); - else - { - ipas = ( yg - refy ) / PAS_REF; // ipas = Y count sections - gypas = ( yg - refy ) / ipas; // gypas = Y section size - ii = ( aPosition.y - refy ) / gypas; - msg.Printf( wxT( "%c" ), 'A' + ii ); - } - - // Get the X axis identifier (A number 1 ... n) - if( aPosition.x < refx || aPosition.x > xg ) // Outside of X limits - msg << wxT( "?" ); - else - { - ipas = ( xg - refx ) / PAS_REF; // ipas = X count sections - gxpas = ( xg - refx ) / ipas; // gxpas = X section size - - ii = ( aPosition.x - refx ) / gxpas; - msg << ii + 1; - } - - return msg; -} - - wxString EDA_DRAW_FRAME::GetScreenDesc() { // Virtual function, in basic function, returns diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 60a32cf419..2a3fbdb245 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -304,7 +304,8 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a text = m_Text; GRSetDrawMode( aDC, aDrawMode ); - DrawGraphicText( aPanel, aDC, text_pos, (EDA_COLOR_T) color, text, m_Orient, m_Size, + EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL; + DrawGraphicText( clipbox, aDC, text_pos, (EDA_COLOR_T) color, text, m_Orient, m_Size, m_HJustify, m_VJustify, linewidth, m_Italic, m_Bold ); /* Set to one (1) to draw bounding box around field text to validate @@ -315,7 +316,7 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a grBox.SetOrigin( aTransform.TransformCoordinate( bBox.GetOrigin() ) ); grBox.SetEnd( aTransform.TransformCoordinate( bBox.GetEnd() ) ); grBox.Move( aOffset ); - GRRect( aPanel->GetClipBox(), aDC, grBox, 0, LIGHTMAGENTA ); + GRRect( clipbox, aDC, grBox, 0, LIGHTMAGENTA ); #endif } diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 36122e433f..4494a3068a 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -1091,6 +1091,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, numLineWidth = Clamp_Text_PenSize( numLineWidth, m_numTextSize, false ); GRSetDrawMode( DC, DrawMode ); + EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; /* Get the num and name colors */ if( (Color < 0) && IsSelected() ) @@ -1139,7 +1140,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, if( orient == PIN_RIGHT ) { x = x1 + TextInside; - DrawGraphicText( panel, DC, wxPoint( x, y1 ), NameColor, + DrawGraphicText( clipbox, DC, wxPoint( x, y1 ), NameColor, m_name, TEXT_ORIENT_HORIZ, PinNameSize, @@ -1150,7 +1151,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, else // Orient == PIN_LEFT { x = x1 - TextInside; - DrawGraphicText( panel, DC, wxPoint( x, y1 ), NameColor, + DrawGraphicText( clipbox, DC, wxPoint( x, y1 ), NameColor, m_name, TEXT_ORIENT_HORIZ, PinNameSize, @@ -1162,7 +1163,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, if( DrawPinNum ) { - DrawGraphicText( panel, DC, + DrawGraphicText( clipbox, DC, wxPoint( (x1 + pin_pos.x) / 2, y1 - TXTMARGE ), NumColor, StringPinNum, @@ -1180,7 +1181,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, y = y1 + TextInside; if( DrawPinName ) - DrawGraphicText( panel, DC, wxPoint( x1, y ), NameColor, + DrawGraphicText( clipbox, DC, wxPoint( x1, y ), NameColor, m_name, TEXT_ORIENT_VERT, PinNameSize, GR_TEXT_HJUSTIFY_RIGHT, @@ -1188,7 +1189,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, false, false ); if( DrawPinNum ) - DrawGraphicText( panel, DC, + DrawGraphicText( clipbox, DC, wxPoint( x1 - TXTMARGE, (y1 + pin_pos.y) / 2 ), NumColor, StringPinNum, @@ -1202,7 +1203,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, y = y1 - TextInside; if( DrawPinName ) - DrawGraphicText( panel, DC, wxPoint( x1, y ), NameColor, + DrawGraphicText( clipbox, DC, wxPoint( x1, y ), NameColor, m_name, TEXT_ORIENT_VERT, PinNameSize, GR_TEXT_HJUSTIFY_LEFT, @@ -1210,7 +1211,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, false, false ); if( DrawPinNum ) - DrawGraphicText( panel, DC, + DrawGraphicText( clipbox, DC, wxPoint( x1 - TXTMARGE, (y1 + pin_pos.y) / 2 ), NumColor, StringPinNum, @@ -1229,7 +1230,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, if( DrawPinName ) { x = (x1 + pin_pos.x) / 2; - DrawGraphicText( panel, DC, wxPoint( x, y1 - TXTMARGE ), + DrawGraphicText( clipbox, DC, wxPoint( x, y1 - TXTMARGE ), NameColor, m_name, TEXT_ORIENT_HORIZ, PinNameSize, GR_TEXT_HJUSTIFY_CENTER, @@ -1239,7 +1240,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, if( DrawPinNum ) { x = (x1 + pin_pos.x) / 2; - DrawGraphicText( panel, DC, wxPoint( x, y1 + TXTMARGE ), + DrawGraphicText( clipbox, DC, wxPoint( x, y1 + TXTMARGE ), NumColor, StringPinNum, TEXT_ORIENT_HORIZ, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, @@ -1252,7 +1253,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, if( DrawPinName ) { y = (y1 + pin_pos.y) / 2; - DrawGraphicText( panel, DC, wxPoint( x1 - TXTMARGE, y ), + DrawGraphicText( clipbox, DC, wxPoint( x1 - TXTMARGE, y ), NameColor, m_name, TEXT_ORIENT_VERT, PinNameSize, GR_TEXT_HJUSTIFY_CENTER, @@ -1262,7 +1263,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, if( DrawPinNum ) { - DrawGraphicText( panel, DC, + DrawGraphicText( clipbox, DC, wxPoint( x1 + TXTMARGE, (y1 + pin_pos.y) / 2 ), NumColor, StringPinNum, TEXT_ORIENT_VERT, PinNumSize, diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 7964844b47..cdfd1eb644 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -399,7 +399,8 @@ void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aO // Calculate pos accordint to mirror/rotation. txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset; - DrawGraphicText( aPanel, aDC, txtpos, (EDA_COLOR_T) color, m_Text, orient, m_Size, + EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL; + DrawGraphicText( clipbox, aDC, txtpos, (EDA_COLOR_T) color, m_Text, orient, m_Size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GetPenSize(), m_Italic, m_Bold ); @@ -412,7 +413,7 @@ void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aO grBox.SetOrigin( aTransform.TransformCoordinate( bBox.GetOrigin() ) ); grBox.SetEnd( aTransform.TransformCoordinate( bBox.GetEnd() ) ); grBox.Move( aOffset ); - GRRect( aPanel->GetClipBox(), aDC, grBox, 0, LIGHTMAGENTA ); + GRRect( clipbox, aDC, grBox, 0, LIGHTMAGENTA ); #endif } diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index c2691c0780..e09712994e 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -194,7 +194,8 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, color = GetLayerColor( LAYER_FIELDS ); } - DrawGraphicText( panel, DC, textpos, color, GetFullyQualifiedText(), orient, m_Size, + EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; + DrawGraphicText( clipbox, DC, textpos, color, GetFullyQualifiedText(), orient, m_Size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, LineWidth, m_Italic, m_Bold ); @@ -214,9 +215,9 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, textpos = parentComponent->GetScreenCoord( textpos ); textpos += parentComponent->GetPosition(); const int len = 10; - GRLine( panel->GetClipBox(), DC, + GRLine( clipbox, DC, textpos.x - len, textpos.y, textpos.x + len, textpos.y, 0, BLUE ); - GRLine( panel->GetClipBox(), DC, + GRLine( clipbox, DC, textpos.x, textpos.y - len, textpos.x, textpos.y + len, 0, BLUE ); #endif } diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index a94e7150b2..d655bf9fb7 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -573,6 +573,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint pos_sheetname,pos_filename; wxPoint pos = m_pos + aOffset; int lineWidth = GetPenSize(); + EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL; if( aColor >= 0 ) color = aColor; @@ -581,7 +582,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GRSetDrawMode( aDC, aDrawMode ); - GRRect( aPanel->GetClipBox(), aDC, pos.x, pos.y, + GRRect( clipbox, aDC, pos.x, pos.y, pos.x + m_size.x, pos.y + m_size.y, lineWidth, color ); pos_sheetname = GetSheetNamePosition() + aOffset; @@ -599,7 +600,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, txtcolor = GetLayerColor( LAYER_SHEETNAME ); Text = wxT( "Sheet: " ) + m_name; - DrawGraphicText( aPanel, aDC, pos_sheetname, + DrawGraphicText( clipbox, aDC, pos_sheetname, (EDA_COLOR_T) txtcolor, Text, name_orientation, wxSize( m_sheetNameSize, m_sheetNameSize ), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, lineWidth, @@ -612,7 +613,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, txtcolor = GetLayerColor( LAYER_SHEETFILENAME ); Text = wxT( "File: " ) + m_fileName; - DrawGraphicText( aPanel, aDC, pos_filename, + DrawGraphicText( clipbox, aDC, pos_filename, (EDA_COLOR_T) txtcolor, Text, name_orientation, wxSize( m_fileNameSize, m_fileNameSize ), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, lineWidth, diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 3e0f1baa7e..77acb3d096 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -343,6 +343,7 @@ void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset, { EDA_COLOR_T color; int linewidth = ( m_Thickness == 0 ) ? GetDefaultLineThickness() : m_Thickness; + EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); @@ -355,7 +356,7 @@ void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset, wxPoint text_offset = aOffset + GetSchematicTextOffset(); EXCHG( linewidth, m_Thickness ); // Set the minimum width - EDA_TEXT::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR ); + EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR ); EXCHG( linewidth, m_Thickness ); // set initial value if( m_isDangling ) @@ -365,7 +366,7 @@ void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset, #if 0 { EDA_RECT BoundaryBox = GetBoundingBox(); - GRRect( panel->GetClipBox(), DC, BoundaryBox, 0, BROWN ); + GRRect( clipbox, DC, BoundaryBox, 0, BROWN ); } #endif } @@ -1285,11 +1286,12 @@ void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel, int linewidth = (m_Thickness == 0) ? GetDefaultLineThickness() : m_Thickness; linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); EXCHG( linewidth, m_Thickness ); // Set the minimum width - EDA_TEXT::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR ); + EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; + EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR ); EXCHG( linewidth, m_Thickness ); // set initial value CreateGraphicShape( Poly, m_Pos + aOffset ); - GRPoly( panel->GetClipBox(), DC, Poly.size(), &Poly[0], 0, linewidth, color, color ); + GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color ); if( m_isDangling ) DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color ); @@ -1298,7 +1300,7 @@ void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel, #if 0 { EDA_RECT BoundaryBox = GetBoundingBox(); - GRRect( panel->GetClipBox(), DC, BoundaryBox, 0, BROWN ); + GRRect( clipbox, DC, BoundaryBox, 0, BROWN ); } #endif } @@ -1604,7 +1606,9 @@ void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel, { static std::vector Poly; EDA_COLOR_T color; - int linewidth = ( m_Thickness == 0 ) ? GetDefaultLineThickness() : m_Thickness; + int linewidth = m_Thickness == 0 ? + GetDefaultLineThickness() : m_Thickness; + EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); @@ -1617,11 +1621,11 @@ void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel, EXCHG( linewidth, m_Thickness ); // Set the minimum width wxPoint text_offset = offset + GetSchematicTextOffset(); - EDA_TEXT::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR ); + EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR ); EXCHG( linewidth, m_Thickness ); // set initial value CreateGraphicShape( Poly, m_Pos + offset ); - GRPoly( panel->GetClipBox(), DC, Poly.size(), &Poly[0], 0, linewidth, color, color ); + GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color ); if( m_isDangling ) DrawDanglingSymbol( panel, DC, m_Pos + offset, color ); @@ -1630,7 +1634,7 @@ void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel, #if 0 { EDA_RECT BoundaryBox = GetBoundingBox(); - GRRect( panel->GetClipBox(), DC, BoundaryBox, 0, BROWN ); + GRRect( clipbox, DC, BoundaryBox, 0, BROWN ); } #endif } diff --git a/gerbview/draw_gerber_screen.cpp b/gerbview/draw_gerber_screen.cpp index 24b03fbd83..b680f86902 100644 --- a/gerbview/draw_gerber_screen.cpp +++ b/gerbview/draw_gerber_screen.cpp @@ -407,7 +407,7 @@ void GERBVIEW_FRAME::DrawItemsDCodeID( wxDC* aDC, GR_DRAWMODE aDrawMode ) int color = GetVisibleElementColor( DCODES_VISIBLE ); - DrawGraphicText( m_canvas, aDC, pos, (EDA_COLOR_T) color, Line, + DrawGraphicText( m_canvas->GetClipBox(), aDC, pos, (EDA_COLOR_T) color, Line, orient, wxSize( width, width ), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, 0, false, false ); diff --git a/include/drawtxt.h b/include/drawtxt.h index 7df51db52b..b2d898e99a 100644 --- a/include/drawtxt.h +++ b/include/drawtxt.h @@ -70,7 +70,7 @@ int OverbarPositionY( int size_v ); /** * Function DrawGraphicText * Draw a graphic text (like module texts) - * @param aPanel = the current DrawPanel. NULL if draw within a 3D GL Canvas + * @param aClipBox = the clipping rect, or NULL if no clipping * @param aDC = the current Device Context. NULL if draw within a 3D GL Canvas * @param aPos = text position (according to h_justify, v_justify) * @param aColor (enum EDA_COLOR_T) = text color @@ -89,7 +89,7 @@ int OverbarPositionY( int size_v ); * @param aPlotter = a pointer to a PLOTTER instance, when this function is used to plot * the text. NULL to draw this text. */ -void DrawGraphicText( EDA_DRAW_PANEL * aPanel, +void DrawGraphicText( EDA_RECT* aClipBox, wxDC * aDC, const wxPoint &aPos, enum EDA_COLOR_T aColor, @@ -111,7 +111,7 @@ void DrawGraphicText( EDA_DRAW_PANEL * aPanel, * If aBgColor is a dark color text is drawn in aColor2 with aColor1 * border; otherwise colors are swapped. */ -void DrawGraphicHaloText( EDA_DRAW_PANEL * aPanel, +void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC, const wxPoint &aPos, enum EDA_COLOR_T aBgColor, diff --git a/include/eda_text.h b/include/eda_text.h index 6558db3a6c..301dda0637 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -1,8 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2013 Jean-Pierre Charras, jpe.charras at wanadoo.fr + * 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 @@ -183,7 +183,7 @@ public: /** * Function Draw - * @param aPanel = the current DrawPanel + * @param aClipBox = the clipping rect, or NULL if no clipping * @param aDC = the current Device Context * @param aOffset = draw offset (usually (0,0)) * @param aColor = text color @@ -191,7 +191,7 @@ public: * @param aDisplay_mode = LINE, FILLED or SKETCH * @param aAnchor_color = anchor color ( UNSPECIFIED = do not draw anchor ). */ - void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, + void Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aDisplay_mode = LINE, EDA_COLOR_T aAnchor_color = UNSPECIFIED_COLOR ); @@ -277,10 +277,10 @@ public: private: /** - * Function DrawOneLineOfText + * Function drawOneLineOfText * Draw a single text line. * Used to draw each line of this EDA_TEXT, that can be multiline - * @param aPanel = the current DrawPanel + * @param aClipBox = the clipping rect, or NULL if no clipping * @param aDC = the current Device Context * @param aOffset = draw offset (usually (0,0)) * @param aColor = text color @@ -290,7 +290,7 @@ private: * @param aText = the single line of text to draw. * @param aPos = the position of this line ). */ - void DrawOneLineOfText( EDA_DRAW_PANEL* aPanel, wxDC* aDC, + void drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode, EDA_COLOR_T aAnchor_color, wxString& aText, diff --git a/include/worksheet.h b/include/worksheet.h index 7757d9282d..4b16095c77 100644 --- a/include/worksheet.h +++ b/include/worksheet.h @@ -11,17 +11,15 @@ // Forward declarations: class EDA_DRAW_PANEL; +class EDA_RECT; class TITLE_BLOCK; class PAGE_INFO; -#define PAS_REF 2000 // Pitch (in mils) of reference locations in worksheet - /** * Function DrawPageLayout is a core function to draw the page layout with * the frame and the basic inscriptions. * @param aDC The device context. - * @param aCanvas The EDA_DRAW_PANEL to draw into, or NULL if the page - * layout is not drawn into the main panel. + * @param aClipBox = the clipping rect, or NULL if no clipping. * @param aPageInfo for margins and page size (in mils). * @param aFullSheetName The sheetpath (full sheet name), for basic inscriptions. * @param aFileName The file name, for basic inscriptions. @@ -30,22 +28,22 @@ class PAGE_INFO; * @param aSheetNumber The sheet number (for basic inscriptions). * @param aPenWidth the pen size The line width for drawing. * @param aScalar the scale factor to convert from mils to internal units. - * @param aLineColor The color for drawing. - * @param aTextColor The color for inscriptions. + * @param aColor The color for drawing. + * @param aAltColor The color for items which need to be "hightlighted". * * Parameters used in aPageInfo * - the size of the page layout. * - the LTmargin The left top margin of the page layout. * - the RBmargin The right bottom margin of the page layout. */ -void DrawPageLayout( wxDC* aDC, EDA_DRAW_PANEL * aCanvas, +void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox, const PAGE_INFO& aPageInfo, const wxString &aFullSheetName, const wxString& aFileName, TITLE_BLOCK& aTitleBlock, int aSheetCount, int aSheetNumber, int aPenWidth, double aScalar, - EDA_COLOR_T aLineColor, EDA_COLOR_T aTextColor ); + EDA_COLOR_T aColor, EDA_COLOR_T aAltColor ); #endif // WORKSHEET_H_ diff --git a/include/worksheet_shape_builder.h b/include/worksheet_shape_builder.h index 09219c1b2a..8b9c8ea3f0 100644 --- a/include/worksheet_shape_builder.h +++ b/include/worksheet_shape_builder.h @@ -504,6 +504,13 @@ public: return NULL; } + /** + * Draws the item list crated by BuildWorkSheetGraphicList + * @param aClipBox = the clipping rect, or NULL if no clipping + * @param aDC = the current Device Context + */ + void Draw( EDA_RECT* aClipBox, wxDC* aDC ); + /** * Function BuildWorkSheetGraphicList is a core function for * drawing or plotting the page layout with @@ -515,14 +522,14 @@ public: * @param aFileName The file name, for basic inscriptions. * @param aSheetPathHumanReadable The human readable sheet path. * @param aTitleBlock The sheet title block, for basic inscriptions. - * @param aLineColor The color for drawing and fixed text. - * @param aTextColor The color for user inscriptions. + * @param aColor The color for drawing. + * @param aAltColor The color for items which need to be "hightlighted". */ void BuildWorkSheetGraphicList( const wxString& aPaperFormat, const wxString& aFileName, const wxString& aSheetPathHumanReadable, const TITLE_BLOCK& aTitleBlock, - EDA_COLOR_T aLineColor, EDA_COLOR_T aTextColor ); + EDA_COLOR_T aColor, EDA_COLOR_T aAltColor ); /** * Function BuildFullText * returns the full text corresponding to the aTextbase, diff --git a/include/wxstruct.h b/include/wxstruct.h index 5d4c3a82d7..83c0e9c492 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -708,15 +708,6 @@ public: void DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth, double aScale, const wxString &aFilename ); - /** - * Function GetXYSheetReferences - * returns the X,Y sheet references where the point position is located - * @param aPosition = position to identify by YX ref - * @return a wxString containing the message locator like A3 or B6 - * (or ?? if out of page limits) - */ - const wxString GetXYSheetReferences( const wxPoint& aPosition ) const; - void DisplayToolMsg( const wxString& msg ); virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) = 0; virtual void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) = 0; diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index 7d95403c03..fca76caa09 100644 --- a/pcbnew/class_pad_draw_functions.cpp +++ b/pcbnew/class_pad_draw_functions.cpp @@ -539,6 +539,8 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) wxString buffer; int tsize; + EDA_RECT* clipBox = aDrawInfo.m_DrawPanel? + aDrawInfo.m_DrawPanel->GetClipBox() : NULL; if( aDrawInfo.m_Display_padnum ) { @@ -552,7 +554,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) { // tsize reserve room for marges and segments thickness tsize = ( tsize * 7 ) / 10; - DrawGraphicHaloText( aDrawInfo.m_DrawPanel, aDC, tpos, + DrawGraphicHaloText( clipBox, aDC, tpos, aDrawInfo.m_Color, BLACK, WHITE, buffer, t_angle, wxSize( tsize , tsize ), GR_TEXT_HJUSTIFY_CENTER, @@ -579,7 +581,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) // tsize reserve room for marges and segments thickness tsize = ( tsize * 7 ) / 10; - DrawGraphicHaloText( aDrawInfo.m_DrawPanel, aDC, tpos, + DrawGraphicHaloText( clipBox, aDC, tpos, aDrawInfo.m_Color, BLACK, WHITE, m_ShortNetname, t_angle, wxSize( tsize, tsize ), GR_TEXT_HJUSTIFY_CENTER, diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index fd20cf981e..344f776537 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -103,7 +103,8 @@ void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, if( brd->IsElementVisible( ANCHOR_VISIBLE ) ) anchor_color = brd->GetVisibleElementColor( ANCHOR_VISIBLE ); - EDA_TEXT::Draw( panel, DC, offset, color, + EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; + EDA_TEXT::Draw( clipbox, DC, offset, color, DrawMode, fillmode, anchor_color ); } diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index f75bb735ea..9e1d7050cf 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -233,7 +233,7 @@ EDA_RECT TEXTE_MODULE::GetBoundingBox() const void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, const wxPoint& offset ) { - MODULE* module = (MODULE*) m_Parent; + MODULE* module = (MODULE*) m_Parent; /* parent must *not* be NULL (a module text without a footprint parent has no sense) */ @@ -281,14 +281,14 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, width = -width; GRSetDrawMode( DC, draw_mode ); - wxPoint pos( m_Pos.x - offset.x, + wxPoint pos( m_Pos.x - offset.x, m_Pos.y - offset.y); // Draw the text anchor point if( brd->IsElementVisible( ANCHOR_VISIBLE ) ) { EDA_COLOR_T anchor_color = brd->GetVisibleElementColor(ANCHOR_VISIBLE); - GRDrawAnchor( panel->GetClipBox(), DC, pos.x, pos.y, + GRDrawAnchor( panel->GetClipBox(), DC, pos.x, pos.y, DIM_ANCRE_TEXTE, anchor_color ); } @@ -300,7 +300,8 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, if( m_Mirror ) size.x = -size.x; - DrawGraphicText( panel, DC, pos, color, m_Text, orient, + EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; + DrawGraphicText( clipbox, DC, pos, color, m_Text, orient, size, m_HJustify, m_VJustify, width, m_Italic, m_Bold ); } diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index ee37bb6d73..da404bda20 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -176,7 +176,7 @@ wxString SEGZONE::GetSelectMenuText() const nettxt = wxT( "???" ); } - text.Printf( _( "Zone (%08lX) [%s] on %s" ), + text.Printf( _( "Zone (%08lX) [%s] on %s" ), m_TimeStamp, GetChars( nettxt ), GetChars( GetLayerName() ) ); return text; @@ -738,10 +738,11 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, GRSetDrawMode( aDC, GR_COPY ); tsize = (tsize * 7) / 10; // small reduction to give a better look - DrawGraphicHaloText( panel, aDC, tpos, - color, BLACK, WHITE, net->GetShortNetname(), angle, + EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; + DrawGraphicHaloText( clipbox, aDC, tpos, + color, BLACK, WHITE, net->GetShortNetname(), angle, wxSize( tsize, tsize ), - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false, false ); } @@ -917,7 +918,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, m_Start.x + aOffset.x - bx, m_Start.y + aOffset.y - by, 0, color ); - // lines for the bottom layer + // lines for the bottom layer ax = 0; ay = radius; bx = 0; by = drill_radius; RotatePoint( &ax, &ay, layer_bottom * 3600.0 / brd->GetCopperLayerCount( ) ); RotatePoint( &bx, &by, layer_bottom * 3600.0 / brd->GetCopperLayerCount( ) ); @@ -952,10 +953,11 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, if( (aDrawMode & GR_XOR) == 0 ) GRSetDrawMode( aDC, GR_COPY ); - DrawGraphicHaloText( panel, aDC, m_Start, - color, WHITE, BLACK, net->GetShortNetname(), 0, + EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; + DrawGraphicHaloText( clipbox, aDC, m_Start, + color, WHITE, BLACK, net->GetShortNetname(), 0, wxSize( tsize, tsize ), - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false, false ); } } From ee8901d9dd11616602a30722a74989927a85db23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Thor=C3=A9n?= <1196277@bugs.launchpad.net> Date: Sun, 30 Jun 2013 19:40:33 +0200 Subject: [PATCH 45/50] All: Fix bug #1196277 (pcbnew does not save all parts of the title block to the kicad_pcb file) --- common/worksheet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/worksheet.cpp b/common/worksheet.cpp index d3c242f1be..88bf97c179 100644 --- a/common/worksheet.cpp +++ b/common/worksheet.cpp @@ -314,11 +314,11 @@ void TITLE_BLOCK::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aCont aFormatter->Print( aNestLevel+1, "(company %s)\n", aFormatter->Quotew( GetCompany() ).c_str() ); - for( int ii = 0; ii < 3; ii++ ) + for( int ii = 0; ii < 4; ii++ ) { if( !GetComment(ii).IsEmpty() ) aFormatter->Print( aNestLevel+1, "(comment %d %s)\n", ii+1, - aFormatter->Quotew( GetComment(1) ).c_str() ); + aFormatter->Quotew( GetComment(ii) ).c_str() ); } aFormatter->Print( aNestLevel, ")\n\n" ); From 44d31a18974f391f1cff352addaa04bbfe910fd9 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Sun, 30 Jun 2013 20:05:40 -0500 Subject: [PATCH 46/50] Speed up DSNLEXER::findToken() to such an extent that it resulted in an approximate 13% reduction in *.kicad_pcb file loading times. --- common/dsnlexer.cpp | 65 +++++++++++++++++---------- common/getrunningmicrosecs.cpp | 2 +- include/dsnlexer.h | 7 +-- include/hashtables.h | 81 ++++++++++++++++++++++++++-------- pcbnew/files.cpp | 14 +++++- 5 files changed, 122 insertions(+), 47 deletions(-) diff --git a/common/dsnlexer.cpp b/common/dsnlexer.cpp index 769e278797..27ee92a6c5 100644 --- a/common/dsnlexer.cpp +++ b/common/dsnlexer.cpp @@ -33,24 +33,13 @@ #include #include -//#include "fctsys.h" -//#include "pcbnew.h" //#define STANDALONE 1 // enable this for stand alone testing. -static int compare( const void* a1, const void* a2 ) -{ - const KEYWORD* k1 = (const KEYWORD*) a1; - const KEYWORD* k2 = (const KEYWORD*) a2; - - int ret = strcmp( k1->name, k2->name ); - return ret; -} - //------------------------------------------------------------------ -inline void DSNLEXER::init() +void DSNLEXER::init() { curTok = DSN_NONE; prevTok = DSN_NONE; @@ -61,6 +50,23 @@ inline void DSNLEXER::init() space_in_quoted_tokens = false; commentsAreTokens = false; + +#if 1 + if( keywordCount > 11 ) + { + // resize the hashtable bucket count + keyword_hash.reserve( keywordCount ); + } + + // fill the specialized "C string" hashtable from keywords[] + const KEYWORD* it = keywords; + const KEYWORD* end = it + keywordCount; + + for( ; it < end; ++it ) + { + keyword_hash[it->name] = it->token; + } +#endif } @@ -168,21 +174,21 @@ LINE_READER* DSNLEXER::PopReader() } +#if 0 +static int compare( const void* a1, const void* a2 ) +{ + const KEYWORD* k1 = (const KEYWORD*) a1; + const KEYWORD* k2 = (const KEYWORD*) a2; + + int ret = strcmp( k1->name, k2->name ); + return ret; +} + int DSNLEXER::findToken( const std::string& tok ) { - // convert to lower case once, this should be faster than using strcasecmp() - // for each test in compare(). - lowercase.clear(); - - for( std::string::const_iterator iter = tok.begin(); iter!=tok.end(); ++iter ) - lowercase += (char) tolower( *iter ); - KEYWORD search; - search.name = lowercase.c_str(); - - // a boost hashtable might be a few percent faster, depending on - // hashtable size and quality of the hash function. + search.name = tok.c_str(); const KEYWORD* findings = (const KEYWORD*) bsearch( &search, keywords, keywordCount, @@ -193,6 +199,19 @@ int DSNLEXER::findToken( const std::string& tok ) return -1; } +#else + +int DSNLEXER::findToken( const std::string& tok ) +{ + + KEYWORD_MAP::const_iterator it = keyword_hash.find( tok.c_str() ); + if( it == keyword_hash.end() ) + return -1; + + return it->second; +} +#endif + const char* DSNLEXER::Syntax( int aTok ) { diff --git a/common/getrunningmicrosecs.cpp b/common/getrunningmicrosecs.cpp index 06dae30fda..152a1d15d6 100644 --- a/common/getrunningmicrosecs.cpp +++ b/common/getrunningmicrosecs.cpp @@ -25,7 +25,7 @@ #include - +#include #if defined(_WIN32) diff --git a/include/dsnlexer.h b/include/dsnlexer.h index 32721226fb..4c01ed03df 100644 --- a/include/dsnlexer.h +++ b/include/dsnlexer.h @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -106,10 +107,10 @@ protected: int curTok; ///< the current token obtained on last NextTok() std::string curText; ///< the text of the current token - std::string lowercase; ///< a scratch buf holding token in lowercase - const KEYWORD* keywords; - unsigned keywordCount; + const KEYWORD* keywords; ///< table sorted by CMake for bsearch() + unsigned keywordCount; ///< count of keywords table + KEYWORD_MAP keyword_hash; ///< fast, specialized "C string" hashtable void init(); diff --git a/include/hashtables.h b/include/hashtables.h index 758a3ae33c..a0fbd778b7 100644 --- a/include/hashtables.h +++ b/include/hashtables.h @@ -59,29 +59,74 @@ typedef std::unordered_map< std::string, EDA_RECT > RECT_MAP; /// Map a std::string to a wxString, used in PLUGINs. typedef boost::unordered_map< std::string, wxString > PROPERTIES; -/// Map a std::string to an integer. Used in DSNLEXER. -typedef boost::unordered_map< std::string, int > KEYWORD_MAP; + +/// Equality test for "const char*" type used in very specialized KEYWORD_MAP below +struct iequal_to : std::binary_function< const char*, const char*, bool > +{ + bool operator()( const char* x, const char* y ) const + { + return !strcmp( x, y ); + } +}; + + +/// Very fast and efficient hash function for "const char*" type, used in specialized +/// KEYWORD_MAP below. +/// taken from: http://www.boost.org/doc/libs/1_53_0/libs/unordered/examples/fnv1.hpp +struct fnv_1a +{ + /* not used, std::string is too slow: + std::size_t operator()( std::string const& text ) const + { + std::size_t hash = 2166136261u; + + for( std::string::const_iterator it = text.begin(), end = text.end(); + it != end; ++it ) + { + hash ^= *it; + hash *= 16777619; + } + return hash; + } + */ + + std::size_t operator()( const char* it ) const + { + std::size_t hash = 2166136261u; + + for( ; *it; ++it ) + { + hash ^= *it; + hash *= 16777619; + } + return hash; + } +}; + + +/** + * Type KEYWORD_MAP + * is a hashtable made of a const char* and an int. Note that use of this + * type outside very specific circumstances is foolish since there is no storage + * provided for the actual C string itself. This type assumes use with type KEYWORD + * that is created by CMake and that table creates *constant* storage for C strings + * (and pointers to those C strings). Here we are only interested in the C strings + * themselves and only the pointers are duplicated within the hashtable. + * If the strings were not constant and fixed, this type would not work. + * Also note that normally a hashtable (i.e. unordered_map) using a const char* key + * would simply compare the 32 bit or 64 bit pointers themselves, rather than + * the C strings which they are known to point to in this context. + * I force the latter behavior by supplying both "hash" and "equality" overloads + * to the hashtable (unordered_map) template. + * @author Dick Hollenbeck + */ +typedef boost::unordered_map< const char*, int, fnv_1a, iequal_to > KEYWORD_MAP; + /// Map a std::string to an EDA_RECT. /// The key is the classname of the derived wxformbuilder dialog. typedef boost::unordered_map< std::string, EDA_RECT > RECT_MAP; - -#elif 0 // wx is inconsistent across platforms, will soon switch to boost - -// http://docs.wxwidgets.org/trunk/classwx_hash_map.html -#include - -/// Map a C string to a wxString, used in PLUGINs. -WX_DECLARE_HASH_MAP( char*, wxString, wxStringHash, wxStringEqual, PROPERTIES ); - -/// Map a C string to an integer. Used in DSNLEXER. -WX_DECLARE_HASH_MAP( char*, int, wxStringHash, wxStringEqual, KEYWORD_MAP ); - -/// Map a C string to an EDA_RECT. -/// The key is the classname of the derived wxformbuilder dialog. -WX_DECLARE_HASH_MAP( char*, EDA_RECT, wxStringHash, wxStringEqual, RECT_MAP ); - #endif #endif // HASHTABLES_H_ diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 9e16cfdfdc..16bf9a40ef 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -283,9 +283,19 @@ bool PCB_EDIT_FRAME::LoadOnePcbFile( const wxString& aFileName, bool aAppend, props["page_width"] = wxString::Format( wxT( "%d" ), GetPageSizeIU().x ); props["page_height"] = wxString::Format( wxT( "%d" ), GetPageSizeIU().y ); +#if 0 + // measure the time to load a BOARD. + unsigned startTime = GetRunningMicroSecs(); +#endif + // load or append either: loadedBoard = pi->Load( GetBoard()->GetFileName(), aAppend ? GetBoard() : NULL, &props ); +#if 0 + unsigned stopTime = GetRunningMicroSecs(); + printf( "PLUGIN::Load(): %u usecs\n", stopTime - startTime ); +#endif + // the Load plugin method makes a 'fresh' board, so we need to // set its own name GetBoard()->SetFileName( fileName.GetFullPath() ); @@ -296,8 +306,8 @@ bool PCB_EDIT_FRAME::LoadOnePcbFile( const wxString& aFileName, bool aAppend, loadedBoard->GetFileFormatVersionAtLoad() < LEGACY_BOARD_FILE_VERSION ) { DisplayInfoMessage( this, - _( "This file was created by an older version of Pcbnew.\ -\nIt will be stored in the new file format when you save this file again." ) ); + _( "This file was created by an older version of Pcbnew.\n" + "It will be stored in the new file format when you save this file again." ) ); } SetBoard( loadedBoard ); From caf5fc8d8d7899a6beec1fd52b5a6d6c98021f9e Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Mon, 1 Jul 2013 01:47:36 -0500 Subject: [PATCH 47/50] DSNLEXER::NextTok() organizes the specctraMode code better, into one if block mostly. This keeps it out of the KiCad mode path, making that leaner and less confusing about what is supported in KiCad mode. Within KiCad mode, treat quoted vs. non-quoted tokens as the two general categories, with non-quoted having sub-categories. Eliminate an unimplemented, unused function declaration in DSNLEXER. Improve the output formatting of THROW_PARSE_ERROR(). --- common/dsnlexer.cpp | 446 ++++++++++++++++++++++---------------------- include/dsnlexer.h | 18 +- include/richio.h | 2 +- pcbnew/files.cpp | 7 +- 4 files changed, 229 insertions(+), 244 deletions(-) diff --git a/common/dsnlexer.cpp b/common/dsnlexer.cpp index 27ee92a6c5..c44ca0ca09 100644 --- a/common/dsnlexer.cpp +++ b/common/dsnlexer.cpp @@ -196,19 +196,18 @@ int DSNLEXER::findToken( const std::string& tok ) if( findings ) return findings->token; else - return -1; + return DSN_SYMBOL; // not a keyword, some arbitrary symbol. } #else -int DSNLEXER::findToken( const std::string& tok ) +inline int DSNLEXER::findToken( const std::string& tok ) { - KEYWORD_MAP::const_iterator it = keyword_hash.find( tok.c_str() ); - if( it == keyword_hash.end() ) - return -1; + if( it != keyword_hash.end() ) + return it->second; - return it->second; + return DSN_SYMBOL; // not a keyword, some arbitrary symbol. } #endif @@ -300,25 +299,24 @@ bool DSNLEXER::IsSymbol( int aTok ) void DSNLEXER::Expecting( int aTok ) throw( IO_ERROR ) { - wxString errText; - errText.Printf( _("Expecting '%s'"), GetChars( GetTokenString( aTok ) ) ); + wxString errText = wxString::Format( + _("Expecting '%s'"), GetChars( GetTokenString( aTok ) ) ); THROW_PARSE_ERROR( errText, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); } void DSNLEXER::Expecting( const char* text ) throw( IO_ERROR ) { - wxString errText; - errText.Printf( _("Expecting '%s'"), - GetChars( wxString::FromUTF8( text ) ) ); + wxString errText = wxString::Format( + _("Expecting '%s'"), GetChars( wxString::FromUTF8( text ) ) ); THROW_PARSE_ERROR( errText, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); } void DSNLEXER::Unexpected( int aTok ) throw( IO_ERROR ) { - wxString errText; - errText.Printf( _("Unexpected '%s'"), GetChars( GetTokenString( aTok ) ) ); + wxString errText = wxString::Format( + _("Unexpected '%s'"), GetChars( GetTokenString( aTok ) ) ); THROW_PARSE_ERROR( errText, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); } @@ -333,9 +331,8 @@ void DSNLEXER::Duplicate( int aTok ) throw( IO_ERROR ) void DSNLEXER::Unexpected( const char* text ) throw( IO_ERROR ) { - wxString errText; - errText.Printf( _("Unexpected '%s'"), - GetChars( wxString::FromUTF8( text ) ) ); + wxString errText = wxString::Format( + _("Unexpected '%s'"), GetChars( wxString::FromUTF8( text ) ) ); THROW_PARSE_ERROR( errText, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); } @@ -433,11 +430,11 @@ inline bool isSep( char cc ) * at the first non-number character, even if it is not whitespace. * * @param cp is the start of the current token. - * @param limit is the end of the current line of text. - * @return const char* - if initial text was a number, then pointer to the text - * after this number, else NULL if initial text was not a number. + * @param limit is the end of the current token. + * + * @return bool - true if input token is a number, else false. */ -static const char* isNumber( const char* cp, const char* limit ) +static bool isNumber( const char* cp, const char* limit ) { // regex for a float: "^[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?" i.e. any number, // code traversal manually here: @@ -483,7 +480,7 @@ static const char* isNumber( const char* cp, const char* limit ) } } - return sawNumber ? cp : NULL; + return sawNumber; } @@ -494,73 +491,179 @@ int DSNLEXER::NextTok() throw( IO_ERROR ) prevTok = curTok; - if( curTok != DSN_EOF ) + if( curTok == DSN_EOF ) + goto exit; + + if( cur >= limit ) { - if( cur >= limit ) - { L_read: - // blank lines are returned as "\n" and will have a len of 1. - // EOF will have a len of 0 and so is detectable. - int len = readLine(); - if( len == 0 ) - { - cur = start; // after readLine(), since start can change, set cur offset to start - curTok = DSN_EOF; - goto exit; - } - - cur = start; // after readLine() since start can change. - - // skip leading whitespace - while( cur= limit ) - goto L_read; - - if( *cur == '(' ) - { - curText = *cur; - curTok = DSN_LEFT; - head = cur+1; + cur = start; // after readLine(), since start can change, set cur offset to start + curTok = DSN_EOF; goto exit; } - if( *cur == ')' ) + cur = start; // after readLine() since start can change. + + // skip leading whitespace + while( cur= limit ) + goto L_read; + + if( *cur == '(' ) + { + curText = *cur; + curTok = DSN_LEFT; + head = cur+1; + goto exit; + } + + if( *cur == ')' ) + { + curText = *cur; + curTok = DSN_RIGHT; + head = cur+1; + goto exit; + } + + // Non-specctraMode, understands and deciphers escaped \, \r, \n, and \". + // Strips off leading and trailing double quotes + if( !specctraMode ) + { + // a quoted string, will return DSN_STRING + if( *cur == stringDelimiter ) + { + // copy the token, character by character so we can remove doubled up quotes. + curText.clear(); + + ++cur; // skip over the leading delimiter, which is always " in non-specctraMode + + head = cur; + + while( head= limit ) + break; // throw exception at L_unterminated + + switch( *head++ ) + { + case '"': + case '\\': c = head[-1]; break; + case 'a': c = '\x07'; break; + case 'b': c = '\x08'; break; + case 'f': c = '\x0c'; break; + case 'n': c = '\n'; break; + case 'r': c = '\r'; break; + case 't': c = '\x09'; break; + case 'v': c = '\x0b'; break; + + case 'x': // 1 or 2 byte hex escape sequence + for( i=0; i<2; ++i ) + { + if( !isxdigit( head[i] ) ) + break; + tbuf[i] = head[i]; + } + tbuf[i] = '\0'; + if( i > 0 ) + c = (char) strtoul( tbuf, NULL, 16 ); + else + c = 'x'; // a goofed hex escape sequence, interpret as 'x' + head += i; + break; + + default: // 1-3 byte octal escape sequence + --head; + for( i=0; i<3; ++i ) + { + if( head[i] < '0' || head[i] > '7' ) + break; + tbuf[i] = head[i]; + } + tbuf[i] = '\0'; + if( i > 0 ) + c = (char) strtoul( tbuf, NULL, 8 ); + else + c = '\\'; // a goofed octal escape sequence, interpret as '\' + head += i; + break; + } + + curText += c; + } + + else if( *head == '"' ) // end of the non-specctraMode DSN_STRING + { + curTok = DSN_STRING; + ++head; // omit this trailing double quote + goto exit; + } + + else + curText += *head++; + + } // while + + // L_unterminated: + wxString errtxt( _( "Un-terminated delimited string" ) ); + THROW_PARSE_ERROR( errtxt, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); + } + } + + else // is specctraMode, tests in this block should not occur in KiCad mode. + { + /* get the dash out of a which is embedded for example + like: U2-14 or "U2"-"14" + This is detectable by a non-space immediately preceeding the dash. + */ + if( *cur == '-' && cur>start && !isSpace( cur[-1] ) ) + { + curText = '-'; + curTok = DSN_DASH; head = cur+1; goto exit; } @@ -594,166 +697,53 @@ L_read: goto exit; } - /* get the dash out of a which is embedded for example - like: U2-14 or "U2"-"14" - This is detectable by a non-space immediately preceeding the dash. - */ - if( *cur == '-' && cur>start && !isSpace( cur[-1] ) ) - { - curText = '-'; - curTok = DSN_DASH; - head = cur+1; - goto exit; - } - - if( ( head = isNumber( cur, limit ) ) != NULL && - // token can only be a number if trailing text is a separator or line end - ( head==limit || isSep( *head ) ) ) - { - curText.clear(); - curText.append( cur, head ); - curTok = DSN_NUMBER; - goto exit; - } - - // a quoted string, will return DSN_STRING + // specctraMode DSN_STRING if( *cur == stringDelimiter ) { - // Non-specctraMode, understands and deciphers escaped \, \r, \n, and \". - // Strips off leading and trailing double quotes - if( !specctraMode ) + ++cur; // skip over the leading delimiter: ",', or $ + + head = cur; + + while( head= limit ) { - // copy the token, character by character so we can remove doubled up quotes. - curText.clear(); - - ++cur; // skip over the leading delimiter, which is always " in non-specctraMode - - head = cur; - - while( head= limit ) - break; // throw exception at L_unterminated - - switch( *head++ ) - { - case '"': - case '\\': c = head[-1]; break; - case 'a': c = '\x07'; break; - case 'b': c = '\x08'; break; - case 'f': c = '\x0c'; break; - case 'n': c = '\n'; break; - case 'r': c = '\r'; break; - case 't': c = '\x09'; break; - case 'v': c = '\x0b'; break; - - case 'x': // 1 or 2 byte hex escape sequence - for( i=0; i<2; ++i ) - { - if( !isxdigit( head[i] ) ) - break; - tbuf[i] = head[i]; - } - tbuf[i] = '\0'; - if( i > 0 ) - c = (char) strtoul( tbuf, NULL, 16 ); - else - c = 'x'; // a goofed hex escape sequence, interpret as 'x' - head += i; - break; - - default: // 1-3 byte octal escape sequence - --head; - for( i=0; i<3; ++i ) - { - if( head[i] < '0' || head[i] > '7' ) - break; - tbuf[i] = head[i]; - } - tbuf[i] = '\0'; - if( i > 0 ) - c = (char) strtoul( tbuf, NULL, 8 ); - else - c = '\\'; // a goofed octal escape sequence, interpret as '\' - head += i; - break; - } - - curText += c; - } - - else if( *head == '"' ) // end of the non-specctraMode DSN_STRING - { - curTok = DSN_STRING; - ++head; // omit this trailing double quote - goto exit; - } - - else - curText += *head++; - - } // while - - // L_unterminated: wxString errtxt( _( "Un-terminated delimited string" ) ); THROW_PARSE_ERROR( errtxt, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); } - else // specctraMode DSN_STRING - { - ++cur; // skip over the leading delimiter: ",', or $ - - head = cur; - - while( head= limit ) - { - wxString errtxt( _( "Un-terminated delimited string" ) ); - THROW_PARSE_ERROR( errtxt, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); - } - - curText.clear(); - curText.append( cur, head ); - - ++head; // skip over the trailing delimiter - - curTok = DSN_STRING; - goto exit; - } - } - - // Maybe it is a token we will find in the token table. - // If not, then call it a DSN_SYMBOL. - { - head = cur+1; - while( headAdd( FromUTF8() ); + } while( ( tok = NextTok() ) == DSN_COMMENT ); } diff --git a/include/dsnlexer.h b/include/dsnlexer.h index 4c01ed03df..896a8bf2f4 100644 --- a/include/dsnlexer.h +++ b/include/dsnlexer.h @@ -134,19 +134,6 @@ protected: return 0; } - - /** - * Function readLineOrCmt - * reads a line from the LINE_READER and returns either: - *

    - *
  1. a positive line length (a +1 if empty line) - *
  2. zero of end of file. - *
  3. DSN_COMMENT if the line is a comment - *
- */ - int readLineOrCmt(); - - /** * Function findToken * takes a string and looks up the string in the list of expected @@ -154,7 +141,8 @@ protected: * * @param tok A string holding the token text to lookup, in an * unpredictable case: uppercase or lowercase - * @return int - DSN_T or -1 if argument string is not a recognized token. + * @return int - DSN_T matching the keyword text, or DSN_SYMBOL if argument + * string is not a recognized token. */ int findToken( const std::string& tok ); @@ -168,6 +156,8 @@ protected: return false; } + + #endif public: diff --git a/include/richio.h b/include/richio.h index 7fd0f6a265..72bd733298 100644 --- a/include/richio.h +++ b/include/richio.h @@ -45,7 +45,7 @@ #define IO_FORMAT _( "IO_ERROR: %s\nfrom %s : %s" ) -#define PARSE_FORMAT _( "PARSE_ERROR: %s in input/source \"%s\", line %d, offset %d\nfrom %s : %s" ) +#define PARSE_FORMAT _( "PARSE_ERROR: %s in input/source\n'%s'\nline %d\noffset %d\nfrom %s : %s" ) // references: // http://stackoverflow.com/questions/2670816/how-can-i-use-the-compile-time-constant-line-in-a-string diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 16bf9a40ef..bdd507fae0 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -50,6 +50,9 @@ #include #include // LEGACY_BOARD_FILE_VERSION +//#define USE_INSTRUMENTATION true +#define USE_INSTRUMENTATION false + static const wxString backupFileExtensionSuffix( wxT( "-bak" ) ); static const wxString autosaveFilePrefix( wxT( "_autosave-" ) ); @@ -283,7 +286,7 @@ bool PCB_EDIT_FRAME::LoadOnePcbFile( const wxString& aFileName, bool aAppend, props["page_width"] = wxString::Format( wxT( "%d" ), GetPageSizeIU().x ); props["page_height"] = wxString::Format( wxT( "%d" ), GetPageSizeIU().y ); -#if 0 +#if USE_INSTRUMENTATION // measure the time to load a BOARD. unsigned startTime = GetRunningMicroSecs(); #endif @@ -291,7 +294,7 @@ bool PCB_EDIT_FRAME::LoadOnePcbFile( const wxString& aFileName, bool aAppend, // load or append either: loadedBoard = pi->Load( GetBoard()->GetFileName(), aAppend ? GetBoard() : NULL, &props ); -#if 0 +#if USE_INSTRUMENTATION unsigned stopTime = GetRunningMicroSecs(); printf( "PLUGIN::Load(): %u usecs\n", stopTime - startTime ); #endif From 9d6ec5a26554dd1d4fd63f6460143721081f81f4 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Mon, 1 Jul 2013 09:37:03 -0500 Subject: [PATCH 48/50] dsnlexer.cpp's isNumber() was recently stupid-ized, un-stupid-ize it. --- common/dsnlexer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/dsnlexer.cpp b/common/dsnlexer.cpp index c44ca0ca09..42a9f2bb9c 100644 --- a/common/dsnlexer.cpp +++ b/common/dsnlexer.cpp @@ -480,7 +480,7 @@ static bool isNumber( const char* cp, const char* limit ) } } - return sawNumber; + return sawNumber && cp==limit; } From 26bd37e0862c3356de015c7e9b360f17f81ec454 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 3 Jul 2013 09:27:52 +0200 Subject: [PATCH 49/50] Eeschema: fix bug Bug #1197103 and an other very minor bug. --- eeschema/annotate.cpp | 24 +++++++++++++++++++++++- eeschema/eeschema.cpp | 6 ++++-- eeschema/sch_screen.cpp | 5 +++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp index 1e7225d69e..c59d48efde 100644 --- a/eeschema/annotate.cpp +++ b/eeschema/annotate.cpp @@ -3,6 +3,29 @@ * @brief Component annotation. */ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * 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 + */ + #include // to use sort vector #include @@ -13,7 +36,6 @@ #include #include -#include #include #include diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index da50b61fd2..0ba7209ce9 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -161,10 +161,12 @@ bool EDA_APP::OnInit() frame->Zoom_Automatique( true ); - /* Load file specified in the command line. */ + // Load file specified in the command line: if( fileReady ) { - wxSetWorkingDirectory( filename.GetPath() ); + if( !filename.GetPath().IsEmpty() ) + // wxSetWorkingDirectory does not like empty paths + wxSetWorkingDirectory( filename.GetPath() ); if( frame->LoadOneEEProject( filename.GetFullPath(), false ) ) frame->GetCanvas()->Refresh( true ); diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index d95b21c627..84326ea9e9 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -734,6 +734,11 @@ void SCH_SCREEN::ClearAnnotation( SCH_SHEET_PATH* aSheetPath ) SCH_COMPONENT* component = (SCH_COMPONENT*) item; component->ClearAnnotation( aSheetPath ); + + // Clear the modified component flag set by component->ClearAnnotation + // because we do not use it here and we should not leave this flag set, + // when an edition is finished: + component->ClearFlags(); } } } From 28d702f6a9b2b1c6b4c1e6dd39a1b2526a891bd3 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 5 Jul 2013 19:48:01 +0200 Subject: [PATCH 50/50] Eeschema: fix a *very subtle* bug noticeable only in complex hierachies, for multiple parts per package: sometimes, the modified flag was set for these components just when switching from a sheet to an other sheet. Pcbnew: fix Bug #1197414 (dragged track segments does not show clearance area) --- eeschema/sch_component.cpp | 5 +++++ eeschema/sch_component.h | 15 +++++++++++++++ eeschema/sch_sheet_path.cpp | 2 +- pcbnew/dragsegm.cpp | 1 + pcbnew/modules.cpp | 2 ++ pcbnew/move-drag_pads.cpp | 35 ++++++++++++++++++++--------------- pcbnew/move_or_drag_track.cpp | 4 ++-- pcbnew/onrightclick.cpp | 11 +++++++---- 8 files changed, 53 insertions(+), 22 deletions(-) diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 00ab0bb907..9d59c7d1d9 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -249,6 +249,11 @@ void SCH_COMPONENT::SetUnit( int aUnit ) } } +void SCH_COMPONENT::UpdateUnit( int aUnit ) +{ + m_unit = aUnit; +} + void SCH_COMPONENT::SetConvert( int aConvert ) { diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index adaae8a4fb..f315be39c9 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -130,8 +130,23 @@ public: int GetUnit() const { return m_unit; } + /** + * change the unit id to aUnit + * has maening only for multiple parts per package + * Also set the modified flag bit + * @param aUnit = the new unit Id + */ void SetUnit( int aUnit ); + /** + * change the unit id to aUnit + * has maening only for multiple parts per package + * Do not change the modified flag bit, and should be used when + * change is not due to an edition command + * @param aUnit = the new unit Id + */ + void UpdateUnit( int aUnit ); + int GetConvert() const { return m_convert; } void SetConvert( int aConvert ); diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index fe41d64ca4..71f777dc22 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -234,7 +234,7 @@ void SCH_SHEET_PATH::UpdateAllScreenReferences() { SCH_COMPONENT* component = (SCH_COMPONENT*) t; component->GetField( REFERENCE )->SetText( component->GetRef( this ) ); - component->SetUnit( component->GetUnitSelection( this ) ); + component->UpdateUnit( component->GetUnitSelection( this ) ); } t = t->Next(); diff --git a/pcbnew/dragsegm.cpp b/pcbnew/dragsegm.cpp index 0cde2b7614..0e0303f860 100644 --- a/pcbnew/dragsegm.cpp +++ b/pcbnew/dragsegm.cpp @@ -409,6 +409,7 @@ void UndrawAndMarkSegmentsToDrag( EDA_DRAW_PANEL* aCanvas, wxDC* aDC ) track->Draw( aCanvas, aDC, GR_XOR ); track->SetState( IN_EDIT, false ); + track->SetFlags( IS_DRAGGED ); if( g_DragSegmentList[ii].m_Flag & STARTPOINT ) track->SetFlags( STARTPOINT ); diff --git a/pcbnew/modules.cpp b/pcbnew/modules.cpp index 7d96639fe4..f19e944a9b 100644 --- a/pcbnew/modules.cpp +++ b/pcbnew/modules.cpp @@ -180,6 +180,7 @@ void Abort_MoveOrCopyModule( EDA_DRAW_PANEL* Panel, wxDC* DC ) pt_segm = g_DragSegmentList[ii].m_Track; pt_segm->Draw( Panel, DC, GR_XOR ); pt_segm->SetState( IN_EDIT, false ); + pt_segm->ClearFlags(); g_DragSegmentList[ii].RestoreInitialValues(); pt_segm->Draw( Panel, DC, GR_OR ); } @@ -405,6 +406,7 @@ void PCB_BASE_FRAME::PlaceModule( MODULE* aModule, wxDC* aDC, bool aDoNotRecreat { TRACK * track = g_DragSegmentList[ii].m_Track; track->SetState( IN_EDIT, false ); + track->ClearFlags(); if( aDC ) track->Draw( m_canvas, aDC, GR_OR ); diff --git a/pcbnew/move-drag_pads.cpp b/pcbnew/move-drag_pads.cpp index 7cc032af6a..b7dd439d7e 100644 --- a/pcbnew/move-drag_pads.cpp +++ b/pcbnew/move-drag_pads.cpp @@ -44,11 +44,12 @@ static void Abort_Move_Pad( EDA_DRAW_PANEL* Panel, wxDC* DC ) // Pad move in progress: restore origin of dragged tracks, if any. for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) { - TRACK* Track = g_DragSegmentList[ii].m_Track; - Track->Draw( Panel, DC, GR_XOR ); - Track->SetState( IN_EDIT, false ); + TRACK* track = g_DragSegmentList[ii].m_Track; + track->Draw( Panel, DC, GR_XOR ); + track->SetState( IN_EDIT, false ); + track->ClearFlags(); g_DragSegmentList[ii].RestoreInitialValues(); - Track->Draw( Panel, DC, GR_OR ); + track->Draw( Panel, DC, GR_OR ); } EraseDragList(); @@ -122,7 +123,7 @@ void PCB_BASE_FRAME::StartMovePad( D_PAD* aPad, wxDC* aDC, bool aDragConnectedTr void PCB_BASE_FRAME::PlacePad( D_PAD* aPad, wxDC* DC ) { int dX, dY; - TRACK* Track; + TRACK* track; if( aPad == NULL ) return; @@ -135,16 +136,16 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* aPad, wxDC* DC ) // Save dragged track segments in undo list for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) { - Track = g_DragSegmentList[ii].m_Track; + track = g_DragSegmentList[ii].m_Track; // Set the old state if( g_DragSegmentList[ii].m_Pad_Start ) - Track->SetStart( Pad_OldPos ); + track->SetStart( Pad_OldPos ); if( g_DragSegmentList[ii].m_Pad_End ) - Track->SetEnd( Pad_OldPos ); + track->SetEnd( Pad_OldPos ); - picker.SetItem( Track ); + picker.SetItem( track ); pickList.PushItem( picker ); } @@ -169,19 +170,23 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* aPad, wxDC* DC ) // Redraw dragged track segments for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) { - Track = g_DragSegmentList[ii].m_Track; + track = g_DragSegmentList[ii].m_Track; // Set the new state if( g_DragSegmentList[ii].m_Pad_Start ) - Track->SetStart( aPad->GetPosition() ); + track->SetStart( aPad->GetPosition() ); if( g_DragSegmentList[ii].m_Pad_End ) - Track->SetEnd( aPad->GetPosition() ); - - Track->SetState( IN_EDIT, false ); + track->SetEnd( aPad->GetPosition() ); if( DC ) - Track->Draw( m_canvas, DC, GR_OR ); + track->Draw( m_canvas, DC, GR_XOR ); + + track->SetState( IN_EDIT, false ); + track->ClearFlags(); + + if( DC ) + track->Draw( m_canvas, DC, GR_OR ); } // Compute local coordinates (i.e refer to module position and for module orient = 0) diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index 3e89a847b4..877edfcd03 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -107,7 +107,7 @@ static void Show_MoveNode( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPo { wxPoint moveVector; BASE_SCREEN* screen = aPanel->GetScreen(); - int track_fill_copy = DisplayOpt.DisplayPcbTrackFill; + int tmp = DisplayOpt.DisplayPcbTrackFill; GR_DRAWMODE draw_mode = GR_XOR | GR_HIGHLIGHT; DisplayOpt.DisplayPcbTrackFill = false; @@ -145,7 +145,7 @@ static void Show_MoveNode( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPo track->Draw( aPanel, aDC, draw_mode ); } - DisplayOpt.DisplayPcbTrackFill = track_fill_copy; + DisplayOpt.DisplayPcbTrackFill = tmp; // Display track length if( track ) diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index 183ffe5c0c..5df6ea1d61 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -1,9 +1,10 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr - * Copyright (C) 2007-2011 Wayne Stambaugh - * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 2007-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 @@ -467,7 +468,9 @@ void PCB_EDIT_FRAME::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu ) { if( Track->Type() == PCB_VIA_T ) { - AddMenuItem( PopMenu, ID_POPUP_PCB_MOVE_TRACK_NODE, _( "Drag Via" ), + msg = AddHotkeyName( _( "Drag Via" ), g_Board_Editor_Hokeys_Descr, + HK_DRAG_ITEM ); + AddMenuItem( PopMenu, ID_POPUP_PCB_MOVE_TRACK_NODE, msg, KiBitmap( move_xpm ) ); } else