From bc230f7650f67da413ab407e9ac332887f3058d3 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 23 Dec 2014 14:01:59 +0100 Subject: [PATCH] Code cleaning: move class PAGE_INFO from common.h to class_page_info.h; Fix issue when using a page layout file in project folder: eeschema and Pcbnew did not use it, unless using an absolute path. Now, if the file path is nor absolute, it is seen as relative to the project (which is the expected behavior) fp lib wizard: when pcbnew id compiled with USE_GITHUB_PLUGIN=OFF, the github plugin option is no more accessible (and the web viewer no more used). --- CMakeLists.txt | 5 +- common/class_page_info.cpp | 1 + common/common.cpp | 13 ++ common/fp_lib_table.cpp | 6 + common/page_layout/title_block_shapes.cpp | 1 + common/worksheet_viewitem.cpp | 1 + cvpcb/CMakeLists.txt | 6 +- eeschema/eeschema_config.cpp | 11 +- gerbview/class_gbr_layout.cpp | 3 - gerbview/class_gbr_layout.h | 4 - gerbview/gerbview.h | 3 - gerbview/gerbview_frame.cpp | 14 +- gerbview/gerbview_frame.h | 2 + include/class_page_info.h | 242 +++++++++++++++++++++ include/class_sch_screen.h | 1 + include/common.h | 216 +----------------- include/plot_common.h | 2 +- include/worksheet.h | 2 +- include/worksheet_shape_builder.h | 1 + pagelayout_editor/class_pl_editor_layout.h | 4 +- pagelayout_editor/page_layout_writer.cpp | 2 +- pagelayout_editor/pl_editor_config.cpp | 1 - pcbnew/CMakeLists.txt | 8 +- pcbnew/dialogs/wizard_add_fplib.cpp | 8 + pcbnew/pcbnew_config.cpp | 13 +- pcbnew/router/router_preview_item.cpp | 103 ++++----- webviewer/webviewer.cpp | 4 +- 27 files changed, 384 insertions(+), 293 deletions(-) create mode 100644 include/class_page_info.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c7b062472..ebb0383832 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,8 +42,9 @@ option( KICAD_KEEPCASE # So this option disable use of wxWEBVIEW, if building wxWEBVIEW creates issues # see: # http://docs.wxwidgets.org/3.0/classwx_web_view.html -# No issues on Windows, needs webkitgtk-devel package installed on Linux. -# (I don't know the OSX status) +# * No issues on Windows. +# * needs webkitgtk-devel package installed on Linux, and wxWidgets rebuilt with this package. +# * Seems also OK on OSX. # However the default option is on # This option could be removed soon, if no serious issue happens on Linux or OSX option( KICAD_USE_WEBKIT diff --git a/common/class_page_info.cpp b/common/class_page_info.cpp index f5dbadf614..30a694a0e1 100644 --- a/common/class_page_info.cpp +++ b/common/class_page_info.cpp @@ -24,6 +24,7 @@ #include +#include #include diff --git a/common/common.cpp b/common/common.cpp index 475fc906b3..b2b2de4c99 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -346,6 +346,19 @@ wxString GetKicadConfigPath() } +#include +const wxString ExpandEnvVarSubstitutions( const wxString& aString ) +{ + // wxGetenv( wchar_t* ) is not re-entrant on linux. + // Put a lock on multithreaded use of wxGetenv( wchar_t* ), called from wxEpandEnvVars(), + static MUTEX getenv_mutex; + + MUTLOCK lock( getenv_mutex ); + + // We reserve the right to do this another way, by providing our own member + // function. + return wxExpandEnvVars( aString ); +} bool EnsureFileDirectoryExists( wxFileName* aTargetFullFileName, const wxString& aBaseFilename, diff --git a/common/fp_lib_table.cpp b/common/fp_lib_table.cpp index 420693da4d..fb7a8f6d67 100644 --- a/common/fp_lib_table.cpp +++ b/common/fp_lib_table.cpp @@ -639,6 +639,9 @@ const FP_LIB_TABLE::ROW* FP_LIB_TABLE::FindRow( const wxString& aNickname ) const wxString FP_LIB_TABLE::ExpandSubstitutions( const wxString& aString ) { +// Duplicate code: the same is now in common.cpp, due to the fact it is used +// in many other places than FP_LIB_TABLE +#if 0 static MUTEX getenv_mutex; MUTLOCK lock( getenv_mutex ); @@ -646,6 +649,9 @@ const wxString FP_LIB_TABLE::ExpandSubstitutions( const wxString& aString ) // We reserve the right to do this another way, by providing our own member // function. return wxExpandEnvVars( aString ); +#else + return ExpandEnvVarSubstitutions( aString ); +#endif } diff --git a/common/page_layout/title_block_shapes.cpp b/common/page_layout/title_block_shapes.cpp index 57ac270594..c7a838578a 100644 --- a/common/page_layout/title_block_shapes.cpp +++ b/common/page_layout/title_block_shapes.cpp @@ -56,6 +56,7 @@ #include #include +#include #include #include #include diff --git a/common/worksheet_viewitem.cpp b/common/worksheet_viewitem.cpp index fc3f9b300a..cf029912d9 100644 --- a/common/worksheet_viewitem.cpp +++ b/common/worksheet_viewitem.cpp @@ -33,6 +33,7 @@ #include #include #include +#include using namespace KIGFX; diff --git a/cvpcb/CMakeLists.txt b/cvpcb/CMakeLists.txt index c49051bccf..c067236b78 100644 --- a/cvpcb/CMakeLists.txt +++ b/cvpcb/CMakeLists.txt @@ -8,8 +8,8 @@ endif() add_definitions( -DCVPCB ) -if( KICAD_USE_WEBKIT ) - set( WEBVIEWERTOOL "webviewer" ) +if( KICAD_USE_WEBKITT AND BUILD_GITHUB_PLUGIN ) + set( WEBVIEWER_WXLIB "webviewer" ) add_definitions( -DKICAD_USE_WEBKIT ) endif() @@ -117,7 +117,7 @@ target_link_libraries( cvpcb_kiface pcbcommon pcad2kicadpcb common - ${WEBVIEWERTOOL} # before bitmaps, because it uses some bitmaps defined in bitmaps + ${WEBVIEWER_WXLIB} # before bitmaps, because it uses some bitmaps defined in bitmaps bitmaps polygon gal diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index a81b996953..45c492ca0c 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -478,8 +479,16 @@ bool SCH_EDIT_FRAME::LoadProjectFile() // BASE_SCREEN::m_PageLayoutDescrFileName, read in config project file // If empty, the default descr is loaded WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance(); + wxString pg_fullfilename = ExpandEnvVarSubstitutions( BASE_SCREEN::m_PageLayoutDescrFileName ); - pglayout.SetPageLayout( BASE_SCREEN::m_PageLayoutDescrFileName ); + if( !pg_fullfilename.IsEmpty() ) + { + // When the page layout filename is not absolute, therefore + // relative to the current project, make it absolute + pg_fullfilename = Prj().AbsolutePath( pg_fullfilename ); + } + + pglayout.SetPageLayout( pg_fullfilename ); return isRead; } diff --git a/gerbview/class_gbr_layout.cpp b/gerbview/class_gbr_layout.cpp index 19849cd6ac..427cab12ed 100644 --- a/gerbview/class_gbr_layout.cpp +++ b/gerbview/class_gbr_layout.cpp @@ -36,9 +36,6 @@ GBR_LAYOUT::GBR_LAYOUT() { - PAGE_INFO pageInfo( wxT( "GERBER" ) ); - SetPageSettings( pageInfo ); - m_printLayersMask.set(); } diff --git a/gerbview/class_gbr_layout.h b/gerbview/class_gbr_layout.h index 94c9b1e2f1..8388bf5b17 100644 --- a/gerbview/class_gbr_layout.h +++ b/gerbview/class_gbr_layout.h @@ -50,7 +50,6 @@ class GBR_LAYOUT { private: EDA_RECT m_BoundingBox; - PAGE_INFO m_paper; TITLE_BLOCK m_titles; wxPoint m_originAxisPosition; std::bitset m_printLayersMask; // When printing: the list of layers to print @@ -61,9 +60,6 @@ public: GBR_LAYOUT(); ~GBR_LAYOUT(); - const PAGE_INFO& GetPageSettings() const { return m_paper; } - void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; } - const wxPoint& GetAuxOrigin() const { return m_originAxisPosition; diff --git a/gerbview/gerbview.h b/gerbview/gerbview.h index b4a3c0a3d7..d54ec58f0c 100644 --- a/gerbview/gerbview.h +++ b/gerbview/gerbview.h @@ -32,9 +32,6 @@ #define CURSEUR_ON_GRILLE 0 #define CURSEUR_OFF_GRILLE 1 -class GERBVIEW_FRAME; -class GERBER_IMAGE; -class PAGE_INFO; /** * size of single line of a text from a gerber file. * warning: some files can have very long lines, so the buffer must be large. diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 7c83369140..d24595739d 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -70,6 +70,8 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ): { m_colorsSettings = &g_ColorsSettings; m_gerberLayout = NULL; + PAGE_INFO pageInfo( wxT( "GERBER" ) ); + SetPageSettings( pageInfo ); m_FrameName = GERBVIEW_FRAME_NAME; m_show_layer_manager_tools = true; @@ -94,7 +96,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ): SetVisibleLayers( -1 ); // All draw layers visible. - SetScreen( new GBR_SCREEN( GetGerberLayout()->GetPageSettings().GetSizeIU() ) ); + SetScreen( new GBR_SCREEN( GetPageSettings().GetSizeIU() ) ); // Create the PCB_LAYER_WIDGET *after* SetLayout(): wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); @@ -720,8 +722,7 @@ void GERBVIEW_FRAME::setActiveLayer( int aLayer, bool doLayerWidgetUpdate ) void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) { - wxASSERT( m_gerberLayout ); - m_gerberLayout->SetPageSettings( aPageSettings ); + m_paper = aPageSettings; if( GetScreen() ) GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() ); @@ -730,19 +731,16 @@ void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) const PAGE_INFO& GERBVIEW_FRAME::GetPageSettings() const { - wxASSERT( m_gerberLayout ); - return m_gerberLayout->GetPageSettings(); + return m_paper; } const wxSize GERBVIEW_FRAME::GetPageSizeIU() const { - 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_gerberLayout->GetPageSettings().GetSizeIU(); + return GetPageSettings().GetSizeIU(); } diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index 3cead41440..ca0747c3c2 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -37,6 +37,7 @@ #include #include #include +#include #define NO_AVAILABLE_LAYERS UNDEFINED_LAYER @@ -83,6 +84,7 @@ class GERBVIEW_FRAME : public EDA_DRAW_FRAME // PCB_BASE_FRAME { GBR_LAYOUT* m_gerberLayout; wxPoint m_grid_origin; + PAGE_INFO m_paper; // used only to show paper limits to screen public: GBR_DISPLAY_OPTIONS m_DisplayOptions; diff --git a/include/class_page_info.h b/include/class_page_info.h new file mode 100644 index 0000000000..87c60e6185 --- /dev/null +++ b/include/class_page_info.h @@ -0,0 +1,242 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2007-2013 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 2008-2013 Wayne Stambaugh + * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/** + * @file class_page_info.h + */ + +#ifndef CLASS_PAGE_INFO_H_ +#define CLASS_PAGE_INFO_H_ + +#include + +#include // for OUTPUTFORMATTER and IO_ERROR +#include // for IU_PER_MILS + + +/** + * Class PAGE_INFO + * describes the page size and margins of a paper page on which to + * eventually print or plot. Paper sizes are often described in inches. + * Here paper is described in 1/1000th of an inch (mils). For convenience + * there are some read only accessors for internal units (IU), which is a compile + * time calculation, not runtime. + * + * @author Dick Hollenbeck + */ +class PAGE_INFO +{ +public: + + PAGE_INFO( const wxString& aType = PAGE_INFO::A3, bool IsPortrait = false ); + + // paper size names which are part of the public API, pass to SetType() or + // above constructor. + + // these were once wxStrings, but it caused static construction sequence problems: + static const wxChar A4[]; + static const wxChar A3[]; + static const wxChar A2[]; + static const wxChar A1[]; + static const wxChar A0[]; + static const wxChar A[]; + static const wxChar B[]; + static const wxChar C[]; + static const wxChar D[]; + static const wxChar E[]; + static const wxChar GERBER[]; + static const wxChar USLetter[]; + static const wxChar USLegal[]; + static const wxChar USLedger[]; + static const wxChar Custom[]; ///< "User" defined page type + + + /** + * Function SetType + * sets the name of the page type and also the sizes and margins + * commonly associated with that type name. + * + * @param aStandardPageDescriptionName is a wxString constant giving one of: + * "A4" "A3" "A2" "A1" "A0" "A" "B" "C" "D" "E" "GERBER", "USLetter", "USLegal", + * "USLedger", or "User". If "User" then the width and height are custom, + * and will be set according to previous calls to + * static PAGE_INFO::SetUserWidthMils() and + * static PAGE_INFO::SetUserHeightMils(); + * @param IsPortrait Set to true to set page orientation to portrait mode. + * + * @return bool - true if @a aStandarePageDescription was a recognized type. + */ + bool SetType( const wxString& aStandardPageDescriptionName, bool IsPortrait = false ); + const wxString& GetType() const { return m_type; } + + /** + * Function IsDefault + * @return True if the object has the default page settings which are A3, landscape. + */ + bool IsDefault() const { return m_type == PAGE_INFO::A3 && !m_portrait; } + + /** + * Function IsCustom + * returns true if the type is Custom + */ + bool IsCustom() const; + + /** + * Function SetPortrait + * will rotate the paper page 90 degrees. This PAGE_INFO may either be in + * portrait or landscape mode. Use this function to change from one to the + * other mode. + * @param isPortrait if true and not already in portrait mode, will change + * this PAGE_INFO to portrait mode. Or if false and not already in landscape mode, + * will change this PAGE_INFO to landscape mode. + */ + void SetPortrait( bool isPortrait ); + bool IsPortrait() const { return m_portrait; } + + /** + * Function GetWxOrientation. + * @return ws' style printing orientation (wxPORTRAIT or wxLANDSCAPE). + */ +#if wxCHECK_VERSION( 2, 9, 0 ) + wxPrintOrientation GetWxOrientation() const { return IsPortrait() ? wxPORTRAIT : wxLANDSCAPE; } +#else + int GetWxOrientation() const { return IsPortrait() ? wxPORTRAIT : wxLANDSCAPE; } +#endif + + /** + * Function GetPaperId + * @return wxPaperSize - wxPrintData's style paper id associated with + * page type name. + */ + wxPaperSize GetPaperId() const { return m_paper_id; } + + void SetWidthMils( int aWidthInMils ); + int GetWidthMils() const { return m_size.x; } + + void SetHeightMils( int aHeightInMils ); + int GetHeightMils() const { return m_size.y; } + + const wxSize& GetSizeMils() const { return m_size; } + + // Accessors returning "Internal Units (IU)". IUs are mils in EESCHEMA, + // and either deci-mils or nanometers in PCBNew. +#if defined(PCBNEW) || defined(EESCHEMA) || defined(GERBVIEW) || defined(PL_EDITOR) + int GetWidthIU() const { return IU_PER_MILS * GetWidthMils(); } + int GetHeightIU() const { return IU_PER_MILS * GetHeightMils(); } + const wxSize GetSizeIU() const { return wxSize( GetWidthIU(), GetHeightIU() ); } +#endif + + /** + * Function SetCustomWidthMils + * sets the width of Custom page in mils, for any custom page + * constructed or made via SetType() after making this call. + */ + static void SetCustomWidthMils( int aWidthInMils ); + + /** + * Function SetCustomHeightMils + * sets the height of Custom page in mils, for any custom page + * constructed or made via SetType() after making this call. + */ + static void SetCustomHeightMils( int aHeightInMils ); + + /** + * Function GetCustomWidthMils. + * @return int - custom paper width in mils. + */ + static int GetCustomWidthMils() { return s_user_width; } + + /** + * Function GetCustomHeightMils. + * @return int - custom paper height in mils. + */ + static int GetCustomHeightMils() { return s_user_height; } + + /** + * Function GetStandardSizes + * returns the standard page types, such as "A4", "A3", etc. + static wxArrayString GetStandardSizes(); + */ + + /** + * Function Format + * outputs the page class to \a aFormatter in s-expression form. + * + * @param aFormatter The #OUTPUTFORMATTER object to write to. + * @param aNestLevel The indentation next level. + * @param aControlBits The control bit definition for object specific formatting. + * @throw IO_ERROR on write error. + */ + void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const + throw( IO_ERROR ); + +protected: + // only the class implementation(s) may use this constructor + PAGE_INFO( const wxSize& aSizeMils, const wxString& aName, wxPaperSize aPaperId ); + + +private: + + // standard pre-defined sizes + static const PAGE_INFO pageA4; + static const PAGE_INFO pageA3; + static const PAGE_INFO pageA2; + static const PAGE_INFO pageA1; + static const PAGE_INFO pageA0; + static const PAGE_INFO pageA; + static const PAGE_INFO pageB; + static const PAGE_INFO pageC; + static const PAGE_INFO pageD; + static const PAGE_INFO pageE; + static const PAGE_INFO pageGERBER; + + static const PAGE_INFO pageUSLetter; + static const PAGE_INFO pageUSLegal; + static const PAGE_INFO pageUSLedger; + + static const PAGE_INFO pageUser; + + // all dimensions here are in mils + + wxString m_type; ///< paper type: A4, A3, etc. + wxSize m_size; ///< mils + +/// Min and max page sizes for clamping. +#define MIN_PAGE_SIZE 4000 +#define MAX_PAGE_SIZE 48000 + + bool m_portrait; ///< true if portrait, false if landscape + + wxPaperSize m_paper_id; ///< wx' style paper id. + + static int s_user_height; + static int s_user_width; + + void updatePortrait(); + + void setMargins(); +}; + +#endif // CLASS_PAGE_INFO_H_ diff --git a/include/class_sch_screen.h b/include/class_sch_screen.h index ce6d7a45d0..20e2eddb0e 100644 --- a/include/class_sch_screen.h +++ b/include/class_sch_screen.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include <../eeschema/general.h> diff --git a/include/common.h b/include/common.h index af9bf1c297..beb726f8bb 100644 --- a/include/common.h +++ b/include/common.h @@ -170,213 +170,6 @@ enum EDA_UNITS_T { }; -// forward declarations: -class LibNameList; - - -/** - * Class PAGE_INFO - * describes the page size and margins of a paper page on which to - * eventually print or plot. Paper sizes are often described in inches. - * Here paper is described in 1/1000th of an inch (mils). For convenience - * there are some read only accessors for internal units (IU), which is a compile - * time calculation, not runtime. - * - * @author Dick Hollenbeck - */ -class PAGE_INFO -{ -public: - - PAGE_INFO( const wxString& aType = PAGE_INFO::A3, bool IsPortrait = false ); - - // paper size names which are part of the public API, pass to SetType() or - // above constructor. - - // these were once wxStrings, but it caused static construction sequence problems: - static const wxChar A4[]; - static const wxChar A3[]; - static const wxChar A2[]; - static const wxChar A1[]; - static const wxChar A0[]; - static const wxChar A[]; - static const wxChar B[]; - static const wxChar C[]; - static const wxChar D[]; - static const wxChar E[]; - static const wxChar GERBER[]; - static const wxChar USLetter[]; - static const wxChar USLegal[]; - static const wxChar USLedger[]; - static const wxChar Custom[]; ///< "User" defined page type - - - /** - * Function SetType - * sets the name of the page type and also the sizes and margins - * commonly associated with that type name. - * - * @param aStandardPageDescriptionName is a wxString constant giving one of: - * "A4" "A3" "A2" "A1" "A0" "A" "B" "C" "D" "E" "GERBER", "USLetter", "USLegal", - * "USLedger", or "User". If "User" then the width and height are custom, - * and will be set according to previous calls to - * static PAGE_INFO::SetUserWidthMils() and - * static PAGE_INFO::SetUserHeightMils(); - * @param IsPortrait Set to true to set page orientation to portrait mode. - * - * @return bool - true if @a aStandarePageDescription was a recognized type. - */ - bool SetType( const wxString& aStandardPageDescriptionName, bool IsPortrait = false ); - const wxString& GetType() const { return m_type; } - - /** - * Function IsDefault - * @return True if the object has the default page settings which are A3, landscape. - */ - bool IsDefault() const { return m_type == PAGE_INFO::A3 && !m_portrait; } - - /** - * Function IsCustom - * returns true if the type is Custom - */ - bool IsCustom() const; - - /** - * Function SetPortrait - * will rotate the paper page 90 degrees. This PAGE_INFO may either be in - * portrait or landscape mode. Use this function to change from one to the - * other mode. - * @param isPortrait if true and not already in portrait mode, will change - * this PAGE_INFO to portrait mode. Or if false and not already in landscape mode, - * will change this PAGE_INFO to landscape mode. - */ - void SetPortrait( bool isPortrait ); - bool IsPortrait() const { return m_portrait; } - - /** - * Function GetWxOrientation. - * @return ws' style printing orientation (wxPORTRAIT or wxLANDSCAPE). - */ -#if wxCHECK_VERSION( 2, 9, 0 ) - wxPrintOrientation GetWxOrientation() const { return IsPortrait() ? wxPORTRAIT : wxLANDSCAPE; } -#else - int GetWxOrientation() const { return IsPortrait() ? wxPORTRAIT : wxLANDSCAPE; } -#endif - - /** - * Function GetPaperId - * @return wxPaperSize - wxPrintData's style paper id associated with - * page type name. - */ - wxPaperSize GetPaperId() const { return m_paper_id; } - - void SetWidthMils( int aWidthInMils ); - int GetWidthMils() const { return m_size.x; } - - void SetHeightMils( int aHeightInMils ); - int GetHeightMils() const { return m_size.y; } - - const wxSize& GetSizeMils() const { return m_size; } - - // Accessors returning "Internal Units (IU)". IUs are mils in EESCHEMA, - // and either deci-mils or nanometers in PCBNew. -#if defined(PCBNEW) || defined(EESCHEMA) || defined(GERBVIEW) || defined(PL_EDITOR) - int GetWidthIU() const { return IU_PER_MILS * GetWidthMils(); } - int GetHeightIU() const { return IU_PER_MILS * GetHeightMils(); } - const wxSize GetSizeIU() const { return wxSize( GetWidthIU(), GetHeightIU() ); } -#endif - - /** - * Function SetCustomWidthMils - * sets the width of Custom page in mils, for any custom page - * constructed or made via SetType() after making this call. - */ - static void SetCustomWidthMils( int aWidthInMils ); - - /** - * Function SetCustomHeightMils - * sets the height of Custom page in mils, for any custom page - * constructed or made via SetType() after making this call. - */ - static void SetCustomHeightMils( int aHeightInMils ); - - /** - * Function GetCustomWidthMils. - * @return int - custom paper width in mils. - */ - static int GetCustomWidthMils() { return s_user_width; } - - /** - * Function GetCustomHeightMils. - * @return int - custom paper height in mils. - */ - static int GetCustomHeightMils() { return s_user_height; } - - /** - * Function GetStandardSizes - * returns the standard page types, such as "A4", "A3", etc. - static wxArrayString GetStandardSizes(); - */ - - /** - * Function Format - * outputs the page class to \a aFormatter in s-expression form. - * - * @param aFormatter The #OUTPUTFORMATTER object to write to. - * @param aNestLevel The indentation next level. - * @param aControlBits The control bit definition for object specific formatting. - * @throw IO_ERROR on write error. - */ - void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const - throw( IO_ERROR ); - -protected: - // only the class implementation(s) may use this constructor - PAGE_INFO( const wxSize& aSizeMils, const wxString& aName, wxPaperSize aPaperId ); - - -private: - - // standard pre-defined sizes - static const PAGE_INFO pageA4; - static const PAGE_INFO pageA3; - static const PAGE_INFO pageA2; - static const PAGE_INFO pageA1; - static const PAGE_INFO pageA0; - static const PAGE_INFO pageA; - static const PAGE_INFO pageB; - static const PAGE_INFO pageC; - static const PAGE_INFO pageD; - static const PAGE_INFO pageE; - static const PAGE_INFO pageGERBER; - - static const PAGE_INFO pageUSLetter; - static const PAGE_INFO pageUSLegal; - static const PAGE_INFO pageUSLedger; - - static const PAGE_INFO pageUser; - - // all dimensions here are in mils - - wxString m_type; ///< paper type: A4, A3, etc. - wxSize m_size; ///< mils - -/// Min and max page sizes for clamping. -#define MIN_PAGE_SIZE 4000 -#define MAX_PAGE_SIZE 48000 - - bool m_portrait; ///< true if portrait, false if landscape - - wxPaperSize m_paper_id; ///< wx' style paper id. - - static int s_user_height; - static int s_user_width; - - void updatePortrait(); - - void setMargins(); -}; - extern EDA_UNITS_T g_UserUnit; ///< display units /// Draw color for moving objects. @@ -646,6 +439,15 @@ wxConfigBase* GetNewConfig( const wxString& aProgName ); */ wxString GetKicadConfigPath(); +/** + * Function ExpandEnvVarSubstitutions + * replaces any environment variable references with their values + * @param aString = a string containing (perhaps) references to env var + * @return a string where env var are replaced by their value + */ +const wxString ExpandEnvVarSubstitutions( const wxString& aString ); + + #ifdef __WXMAC__ /** * OSX specific function GetOSXKicadUserDataDir diff --git a/include/plot_common.h b/include/plot_common.h index 333953da48..6ebf5f340c 100644 --- a/include/plot_common.h +++ b/include/plot_common.h @@ -35,7 +35,7 @@ #include #include #include -#include // PAGE_INFO +#include #include // FILL_T /** diff --git a/include/worksheet.h b/include/worksheet.h index 4b16095c77..d4bed64b1a 100644 --- a/include/worksheet.h +++ b/include/worksheet.h @@ -8,12 +8,12 @@ #define WORKSHEET_H_ #include // EDA_COLOR_T definition +#include // Forward declarations: class EDA_DRAW_PANEL; class EDA_RECT; class TITLE_BLOCK; -class PAGE_INFO; /** * Function DrawPageLayout is a core function to draw the page layout with diff --git a/include/worksheet_shape_builder.h b/include/worksheet_shape_builder.h index a349cad470..3dcdf529c5 100644 --- a/include/worksheet_shape_builder.h +++ b/include/worksheet_shape_builder.h @@ -38,6 +38,7 @@ class WORKSHEET_DATAITEM; // Forward declaration class TITLE_BLOCK; +class PAGE_INFO; #define TB_DEFAULT_TEXTSIZE 1.5 // default worksheet text size in mm diff --git a/pagelayout_editor/class_pl_editor_layout.h b/pagelayout_editor/class_pl_editor_layout.h index b28468c7a1..cbd26ca3d2 100644 --- a/pagelayout_editor/class_pl_editor_layout.h +++ b/pagelayout_editor/class_pl_editor_layout.h @@ -28,8 +28,8 @@ #ifndef CLASS_PL_EDITOR_LAYOUT_H #define CLASS_PL_EDITOR_LAYOUT_H -#include // PAGE_INFO -#include // PAGE_INFO +#include +#include #include class EDA_DRAW_PANEL; diff --git a/pagelayout_editor/page_layout_writer.cpp b/pagelayout_editor/page_layout_writer.cpp index dfc6321511..81d4f6b182 100644 --- a/pagelayout_editor/page_layout_writer.cpp +++ b/pagelayout_editor/page_layout_writer.cpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include using namespace TB_READER_T; diff --git a/pagelayout_editor/pl_editor_config.cpp b/pagelayout_editor/pl_editor_config.cpp index f136fa1691..ad15cc65ad 100644 --- a/pagelayout_editor/pl_editor_config.cpp +++ b/pagelayout_editor/pl_editor_config.cpp @@ -38,7 +38,6 @@ #include #include - #define GROUP wxT("/pl_editor") diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 478f2a5d44..eba8f15d57 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -370,8 +370,8 @@ if( UNIX AND NOT APPLE ) list( APPEND PCBNEW_EXTRA_LIBS rt ) endif() -if( KICAD_USE_WEBKIT ) - set( WEBVIEWERTOOL "webviewer" ) +if( KICAD_USE_WEBKIT AND BUILD_GITHUB_PLUGIN ) + set( WEBVIEWER_WXLIB "webviewer" ) add_definitions( -DKICAD_USE_WEBKIT ) endif() @@ -402,7 +402,7 @@ if( KICAD_SCRIPTING_MODULES ) idf3 ${GITHUB_PLUGIN_LIBRARIES} polygon - ${WEBVIEWERTOOL} + ${WEBVIEWER_WXLIB} bitmaps gal ${GLEW_LIBRARIES} @@ -569,7 +569,7 @@ target_link_libraries( pcbnew_kiface common pcad2kicadpcb polygon - ${WEBVIEWERTOOL} # before bitmaps, because it uses some bitmaps defined in bitmap + ${WEBVIEWER_WXLIB} # before bitmaps, because it uses some bitmaps defined in bitmap bitmaps gal lib_dxf diff --git a/pcbnew/dialogs/wizard_add_fplib.cpp b/pcbnew/dialogs/wizard_add_fplib.cpp index abea28e053..c9b74cabc7 100644 --- a/pcbnew/dialogs/wizard_add_fplib.cpp +++ b/pcbnew/dialogs/wizard_add_fplib.cpp @@ -72,6 +72,14 @@ WIZARD_FPLIB_TABLE::WIZARD_FPLIB_TABLE( wxWindow* aParent, wxArrayString& aEnvVa { initDlg( aEnvVariableList ); + // Allows github plugin selection only when the plugin is compiled: +#ifndef BUILD_GITHUB_PLUGIN + m_rbFpLibFormat->Enable( GITHUB_PLUGIN, false ); + + if( m_rbFpLibFormat->GetSelection() == GITHUB_PLUGIN ) + m_rbFpLibFormat->SetSelection( KICAD_PLUGIN ); +#endif + // Currently, I (JPC) do not know the best way to add/store // what is currently called env variables // So do not show tools to change them, diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 37e676260d..3fc02a3901 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -268,7 +269,17 @@ bool PCB_EDIT_FRAME::LoadProjectSettings() // BASE_SCREEN::m_PageLayoutDescrFileName, read in config project file // If empty, the default descr is loaded WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance(); - pglayout.SetPageLayout( BASE_SCREEN::m_PageLayoutDescrFileName ); + wxString pg_fullfilename = ExpandEnvVarSubstitutions( + BASE_SCREEN::m_PageLayoutDescrFileName ); + + if( !pg_fullfilename.IsEmpty() ) + { + // When the page layout filename is not absolute, therefore + // relative to the current project, make it absolute + pg_fullfilename = Prj().AbsolutePath( pg_fullfilename ); + } + + pglayout.SetPageLayout( pg_fullfilename ); return rc; } diff --git a/pcbnew/router/router_preview_item.cpp b/pcbnew/router/router_preview_item.cpp index 58715927bc..c51c91c18c 100644 --- a/pcbnew/router/router_preview_item.cpp +++ b/pcbnew/router/router_preview_item.cpp @@ -159,65 +159,70 @@ void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const switch( m_shape->Type() ) { - case SH_LINE_CHAIN: - { - const SHAPE_LINE_CHAIN* l = (const SHAPE_LINE_CHAIN*) m_shape; - drawLineChain( *l, aGal ); - break; - } + case SH_LINE_CHAIN: + { + const SHAPE_LINE_CHAIN* l = (const SHAPE_LINE_CHAIN*) m_shape; + drawLineChain( *l, aGal ); + break; + } - case SH_SEGMENT: + case SH_SEGMENT: + { + const SHAPE_SEGMENT* s = (const SHAPE_SEGMENT*) m_shape; + aGal->DrawLine( s->GetSeg().A, s->GetSeg().B ); + + if( m_clearance > 0 ) { - const SHAPE_SEGMENT* s = (const SHAPE_SEGMENT*) m_shape; + aGal->SetLayerDepth( ClearanceOverlayDepth ); + aGal->SetStrokeColor( COLOR4D( DARKDARKGRAY ) ); + aGal->SetLineWidth( m_width + 2 * m_clearance ); aGal->DrawLine( s->GetSeg().A, s->GetSeg().B ); - - if( m_clearance > 0 ) - { - aGal->SetLayerDepth( ClearanceOverlayDepth ); - aGal->SetStrokeColor( COLOR4D( DARKDARKGRAY ) ); - aGal->SetLineWidth( m_width + 2 * m_clearance ); - aGal->DrawLine( s->GetSeg().A, s->GetSeg().B ); - } - - break; } - case SH_CIRCLE: + break; + } + + case SH_CIRCLE: + { + const SHAPE_CIRCLE* c = (const SHAPE_CIRCLE*) m_shape; + aGal->DrawCircle( c->GetCenter(), c->GetRadius() ); + + if( m_clearance > 0 ) { - const SHAPE_CIRCLE* c = (const SHAPE_CIRCLE*) m_shape; - aGal->DrawCircle( c->GetCenter(), c->GetRadius() ); - - if( m_clearance > 0 ) - { - aGal->SetLayerDepth( ClearanceOverlayDepth ); - aGal->SetFillColor( COLOR4D( DARKDARKGRAY ) ); - aGal->SetIsStroke( false ); - aGal->DrawCircle( c->GetCenter(), c->GetRadius() + m_clearance ); - } - - break; + aGal->SetLayerDepth( ClearanceOverlayDepth ); + aGal->SetFillColor( COLOR4D( DARKDARKGRAY ) ); + aGal->SetIsStroke( false ); + aGal->DrawCircle( c->GetCenter(), c->GetRadius() + m_clearance ); } - case SH_RECT: + break; + } + + case SH_RECT: + { + const SHAPE_RECT* r = (const SHAPE_RECT*) m_shape; + aGal->DrawRectangle( r->GetPosition(), r->GetPosition() + r->GetSize() ); + + if( m_clearance > 0 ) { - const SHAPE_RECT* r = (const SHAPE_RECT*) m_shape; - aGal->DrawRectangle( r->GetPosition(), r->GetPosition() + r->GetSize() ); - - if( m_clearance > 0 ) - { - aGal->SetLayerDepth( ClearanceOverlayDepth ); - VECTOR2I p0( r->GetPosition() ), s( r->GetSize() ); - aGal->SetStrokeColor( COLOR4D( DARKDARKGRAY ) ); - aGal->SetIsStroke( true ); - aGal->SetLineWidth( 2 * m_clearance ); - aGal->DrawLine( p0, VECTOR2I( p0.x + s.x, p0.y ) ); - aGal->DrawLine( p0, VECTOR2I( p0.x, p0.y + s.y ) ); - aGal->DrawLine( p0 + s , VECTOR2I( p0.x + s.x, p0.y ) ); - aGal->DrawLine( p0 + s, VECTOR2I( p0.x, p0.y + s.y ) ); - } - - break; + aGal->SetLayerDepth( ClearanceOverlayDepth ); + VECTOR2I p0( r->GetPosition() ), s( r->GetSize() ); + aGal->SetStrokeColor( COLOR4D( DARKDARKGRAY ) ); + aGal->SetIsStroke( true ); + aGal->SetLineWidth( 2 * m_clearance ); + aGal->DrawLine( p0, VECTOR2I( p0.x + s.x, p0.y ) ); + aGal->DrawLine( p0, VECTOR2I( p0.x, p0.y + s.y ) ); + aGal->DrawLine( p0 + s , VECTOR2I( p0.x + s.x, p0.y ) ); + aGal->DrawLine( p0 + s, VECTOR2I( p0.x, p0.y + s.y ) ); } + + break; + } + + case SH_CONVEX: + case SH_POLYGON: + case SH_COMPOUND: + break; // Not yet in use } } } diff --git a/webviewer/webviewer.cpp b/webviewer/webviewer.cpp index c69855b72a..2968a6057f 100644 --- a/webviewer/webviewer.cpp +++ b/webviewer/webviewer.cpp @@ -42,7 +42,7 @@ #include "wx/wx.h" #if !wxUSE_WEBVIEW_WEBKIT && !wxUSE_WEBVIEW_IE -#error "A wxWebView backend is required by this sample" +#error "wxWidgets must be built with wxWebView support enabled. Please rebuild wxWidgets" #endif #include "wx/artprov.h" @@ -60,7 +60,7 @@ #if wxUSE_STC #include "wx/stc/stc.h" #else -#error "wxStyledTextControl is needed by the web viewer" +#error "wxWidgets must be built with wxStyledTextControl enabled. Please rebuild wxWidgets" #endif #include