From e23f2b7b7b0dc116a06e3b0064aa7adaf409b167 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 15 May 2014 08:32:24 +0200 Subject: [PATCH] DXF export: fix incorrect export of polygons having thick outline (like zones): Thick segments of outline were drawn like lines with no thickness. Fix ( workaround only) crash (Windows only) when a quasi modal frame (like footprint viewer) was called from a dialog (like the component properties dialog in schematic editor). Very minor other fixes. --- common/common_plotDXF_functions.cpp | 31 ++++++++++++++++++++++++----- common/eda_doc.cpp | 8 ++++---- common/kiway_player.cpp | 10 ++++++++-- common/msgpanel.cpp | 5 +++-- eeschema/getpart.cpp | 1 - include/eda_doc.h | 4 ++-- include/msgpanel.h | 4 +++- pcbnew/modedit.cpp | 8 +++++++- pcbnew/tools/common_actions.cpp | 8 ++++---- 9 files changed, 57 insertions(+), 22 deletions(-) diff --git a/common/common_plotDXF_functions.cpp b/common/common_plotDXF_functions.cpp index 0164ca628b..89aabe2f73 100644 --- a/common/common_plotDXF_functions.cpp +++ b/common/common_plotDXF_functions.cpp @@ -326,18 +326,39 @@ void DXF_PLOTTER::PlotPoly( const std::vector< wxPoint >& aCornerList, if( aCornerList.size() <= 1 ) return; - MoveTo( aCornerList[0] ); - for( unsigned ii = 1; ii < aCornerList.size(); ii++ ) - LineTo( aCornerList[ii] ); + // Plot outlines with lines (thickness = 0) to define the polygon + if( aWidth == 0 || aFill ) + { + MoveTo( aCornerList[0] ); + + for( unsigned ii = 1; ii < aCornerList.size(); ii++ ) + LineTo( aCornerList[ii] ); + } // Close polygon if 'fill' requested + unsigned last = aCornerList.size() - 1; + if( aFill ) { - unsigned ii = aCornerList.size() - 1; - if( aCornerList[ii] != aCornerList[0] ) + if( aCornerList[last] != aCornerList[0] ) LineTo( aCornerList[0] ); } + PenFinish(); + + // if the polygon outline has thickness, plot outlines with thick segments + if( aWidth > 0 ) + { + MoveTo( aCornerList[0] ); + + for( unsigned ii = 1; ii < aCornerList.size(); ii++ ) + ThickSegment( aCornerList[ii-1], aCornerList[ii], + aWidth, FILLED ); + + if( aCornerList[last] != aCornerList[0] ) + ThickSegment( aCornerList[last], aCornerList[0], + aWidth, FILLED ); + } } diff --git a/common/eda_doc.cpp b/common/eda_doc.cpp index 407b1c5ed3..717002e000 100644 --- a/common/eda_doc.cpp +++ b/common/eda_doc.cpp @@ -59,7 +59,7 @@ static const wxFileTypeInfo EDAfallbacks[] = }; -bool GetAssociatedDocument( wxFrame* aFrame, +bool GetAssociatedDocument( wxWindow* aParent, const wxString& aDocName, const wxPathList* aPaths) @@ -122,7 +122,7 @@ bool GetAssociatedDocument( wxFrame* aFrame, fullfilename, extension, mask, - aFrame, + aParent, wxFD_OPEN, true, wxPoint( -1, -1 ) ); @@ -133,7 +133,7 @@ bool GetAssociatedDocument( wxFrame* aFrame, if( !wxFileExists( fullfilename ) ) { msg.Printf( _( "Doc File '%s' not found" ), GetChars( aDocName ) ); - DisplayError( aFrame, msg ); + DisplayError( aParent, msg ); return false; } @@ -176,7 +176,7 @@ bool GetAssociatedDocument( wxFrame* aFrame, if( !success ) { msg.Printf( _( "Unknown MIME type for doc file <%s>" ), GetChars( fullfilename ) ); - DisplayError( aFrame, msg ); + DisplayError( aParent, msg ); } return success; diff --git a/common/kiway_player.cpp b/common/kiway_player.cpp index fda3962d2d..2351239e16 100644 --- a/common/kiway_player.cpp +++ b/common/kiway_player.cpp @@ -141,10 +141,16 @@ bool KIWAY_PLAYER::ShowModal( wxString* aResult, wxWindow* aResultantFocusWindow bool KIWAY_PLAYER::Destroy() { - // Needed on Windows to leave the modal parent on top with focus + // Reparent is needed on Windows to leave the modal parent on top with focus + // However it works only if the caller is a main frame, not a dialog. + // (application crashes if the new parent is a wxDialog #ifdef __WINDOWS__ if( m_modal_resultant_parent && GetParent() != m_modal_resultant_parent ) - Reparent( m_modal_resultant_parent ); + { + EDA_BASE_FRAME* parent = dynamic_cast(m_modal_resultant_parent); + if( parent ) + Reparent( m_modal_resultant_parent ); + } #endif return EDA_BASE_FRAME::Destroy(); diff --git a/common/msgpanel.cpp b/common/msgpanel.cpp index 9004f03d6b..5652db8148 100644 --- a/common/msgpanel.cpp +++ b/common/msgpanel.cpp @@ -37,8 +37,9 @@ END_EVENT_TABLE() EDA_MSG_PANEL::EDA_MSG_PANEL( wxWindow* aParent, int aId, - const wxPoint& aPosition, const wxSize& aSize ) : - wxPanel( aParent, aId, aPosition, aSize ) + const wxPoint& aPosition, const wxSize& aSize, + long style, const wxString &name ) : + wxPanel( aParent, aId, aPosition, aSize, style, name ) { SetFont( wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ) ); SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) ); diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index 8821cfb31e..cd4c15a90a 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -39,7 +39,6 @@ #include #include -#include #include #include #include diff --git a/include/eda_doc.h b/include/eda_doc.h index fd6e0f3df2..1935c528c4 100644 --- a/include/eda_doc.h +++ b/include/eda_doc.h @@ -19,13 +19,13 @@ int KeyWordOk( const wxString& aKeyList, const wxString& aDatabase ); /** * Function GetAssociatedDocument * open a document (file) with the suitable browser - * @param aFrame = main frame + * @param aParent = main frame * @param aDocName = filename of file to open (Full filename or short filename) * if \a aDocName begins with http: or ftp: or www. the default internet browser is launched * @param aPaths = a wxPathList to explore. * if NULL or aDocName is a full filename, aPath is not used. */ -bool GetAssociatedDocument( wxFrame* aFrame, +bool GetAssociatedDocument( wxWindow* aParent, const wxString& aDocName, const wxPathList* aPaths = NULL ); diff --git a/include/msgpanel.h b/include/msgpanel.h index 6ea6513ce2..dc5edd29eb 100644 --- a/include/msgpanel.h +++ b/include/msgpanel.h @@ -121,7 +121,9 @@ protected: wxSize computeTextSize( const wxString& text ) const; public: - EDA_MSG_PANEL( wxWindow* aParent, int aId, const wxPoint& aPosition, const wxSize& aSize ); + EDA_MSG_PANEL( wxWindow* aParent, int aId, + const wxPoint& aPosition, const wxSize& aSize, + long style=wxTAB_TRAVERSAL, const wxString &name=wxPanelNameStr); ~EDA_MSG_PANEL(); /** diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 81b74eebe7..7150c85bcf 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -367,7 +367,13 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) { // update module in the current board, // not just add it to the board with total disregard for the netlist... - PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, true ); + PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false ); + + if( pcbframe == NULL ) // happens when the board editor is not active (or closed) + { + wxMessageBox( _("No board currently edited" ) ); + break; + } BOARD* mainpcb = pcbframe->GetBoard(); MODULE* source_module = NULL; diff --git a/pcbnew/tools/common_actions.cpp b/pcbnew/tools/common_actions.cpp index 3ff65af56b..45e9ba17fc 100644 --- a/pcbnew/tools/common_actions.cpp +++ b/pcbnew/tools/common_actions.cpp @@ -208,11 +208,11 @@ TOOL_ACTION COMMON_ACTIONS::layerAlphaDec( "pcbnew.layerAlphaDec", // Grid control TOOL_ACTION COMMON_ACTIONS::gridFast1( "pcbnew.gridFast1", - AS_GLOBAL, MD_ALT + '1', + AS_GLOBAL, (int)MD_ALT + '1', "", "" ); TOOL_ACTION COMMON_ACTIONS::gridFast2( "pcbnew.gridFast2", - AS_GLOBAL, MD_ALT + '2', + AS_GLOBAL, (int)MD_ALT + '2', "", "" ); TOOL_ACTION COMMON_ACTIONS::gridNext( "pcbnew.gridNext", @@ -220,7 +220,7 @@ TOOL_ACTION COMMON_ACTIONS::gridNext( "pcbnew.gridNext", "", "" ); TOOL_ACTION COMMON_ACTIONS::gridPrev( "pcbnew.gridPrev", - AS_GLOBAL, MD_CTRL + '`', + AS_GLOBAL, (int)MD_CTRL + '`', "", "" ); @@ -248,7 +248,7 @@ TOOL_ACTION COMMON_ACTIONS::resetCoords( "pcbnew.resetCoords", "", "" ); TOOL_ACTION COMMON_ACTIONS::switchUnits( "pcbnew.switchUnits", - AS_GLOBAL, MD_CTRL + 'U', + AS_GLOBAL, (int)MD_CTRL + 'U', "", "" ); TOOL_ACTION COMMON_ACTIONS::showHelp( "pcbnew.showHelp",