From 4787918fac8efca3f229fda8c92f7d16d07f64bc Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 24 Jun 2014 20:04:16 +0200 Subject: [PATCH] Make dialog pns properties resizable. DXF import: add very basic polyline import. --- common/draw_panel.cpp | 2 +- pcbnew/dialogs/dialog_pns_settings_base.cpp | 11 +- pcbnew/dialogs/dialog_pns_settings_base.fbp | 143 +++++--------------- pcbnew/dialogs/dialog_pns_settings_base.h | 6 +- pcbnew/import_dxf/dxf2brd_items.cpp | 60 ++++++++ pcbnew/import_dxf/dxf2brd_items.h | 4 +- 6 files changed, 100 insertions(+), 126 deletions(-) diff --git a/common/draw_panel.cpp b/common/draw_panel.cpp index d977f17c4c..0367238bd6 100644 --- a/common/draw_panel.cpp +++ b/common/draw_panel.cpp @@ -128,7 +128,7 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id, if( cfg ) { - cfg->Read( ENBL_MIDDLE_BUTT_PAN_KEY, &m_enableMiddleButtonPan, false ); + cfg->Read( ENBL_MIDDLE_BUTT_PAN_KEY, &m_enableMiddleButtonPan, true ); cfg->Read( ENBL_ZOOM_NO_CENTER_KEY, &m_enableZoomNoCenter, false ); cfg->Read( MIDDLE_BUTT_PAN_LIMITED_KEY, &m_panScrollbarLimits, false ); cfg->Read( ENBL_AUTO_PAN_KEY, &m_enableAutoPan, true ); diff --git a/pcbnew/dialogs/dialog_pns_settings_base.cpp b/pcbnew/dialogs/dialog_pns_settings_base.cpp index 2642caf845..fb1214e740 100644 --- a/pcbnew/dialogs/dialog_pns_settings_base.cpp +++ b/pcbnew/dialogs/dialog_pns_settings_base.cpp @@ -11,7 +11,7 @@ DIALOG_PNS_SETTINGS_BASE::DIALOG_PNS_SETTINGS_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 ); + this->SetSizeHints( wxSize( 280,380 ), wxDefaultSize ); wxBoxSizer* bMainSizer; bMainSizer = new wxBoxSizer( wxVERTICAL ); @@ -91,8 +91,8 @@ DIALOG_PNS_SETTINGS_BASE::DIALOG_PNS_SETTINGS_BASE( wxWindow* parent, wxWindowID bOptions->Add( bEffort, 0, wxEXPAND, 5 ); - m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bOptions->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); + + bMainSizer->Add( bOptions, 1, wxEXPAND|wxALL, 5 ); m_stdButtons = new wxStdDialogButtonSizer(); m_stdButtonsOK = new wxButton( this, wxID_OK ); @@ -101,10 +101,7 @@ DIALOG_PNS_SETTINGS_BASE::DIALOG_PNS_SETTINGS_BASE( wxWindow* parent, wxWindowID m_stdButtons->AddButton( m_stdButtonsCancel ); m_stdButtons->Realize(); - bOptions->Add( m_stdButtons, 0, wxEXPAND, 5 ); - - - bMainSizer->Add( bOptions, 1, wxEXPAND|wxALL, 5 ); + bMainSizer->Add( m_stdButtons, 0, wxEXPAND|wxALL, 5 ); this->SetSizer( bMainSizer ); diff --git a/pcbnew/dialogs/dialog_pns_settings_base.fbp b/pcbnew/dialogs/dialog_pns_settings_base.fbp index d635feb8ee..7350038cd1 100644 --- a/pcbnew/dialogs/dialog_pns_settings_base.fbp +++ b/pcbnew/dialogs/dialog_pns_settings_base.fbp @@ -41,11 +41,11 @@ 0 wxID_ANY - + 280,380 DIALOG_PNS_SETTINGS_BASE - 277,404 - wxDEFAULT_DIALOG_STYLE + 298,410 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Interactive Router settings @@ -811,11 +811,11 @@ - + 5 wxEXPAND 0 - + bEffort wxHORIZONTAL @@ -1221,113 +1221,32 @@ - - 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 - wxEXPAND - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_stdButtons - protected - - OnCancelClick - - - - OnOkClick - - - - + + + + 5 + wxEXPAND|wxALL + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_stdButtons + protected + + OnCancelClick + + + + OnOkClick + + diff --git a/pcbnew/dialogs/dialog_pns_settings_base.h b/pcbnew/dialogs/dialog_pns_settings_base.h index 5ba9eb21e3..22f07b2bb4 100644 --- a/pcbnew/dialogs/dialog_pns_settings_base.h +++ b/pcbnew/dialogs/dialog_pns_settings_base.h @@ -24,9 +24,8 @@ class DIALOG_SHIM; #include #include #include -#include -#include #include +#include #include /////////////////////////////////////////////////////////////////////////// @@ -52,7 +51,6 @@ class DIALOG_PNS_SETTINGS_BASE : public DIALOG_SHIM wxSlider* m_effort; wxStaticText* m_lowLabel; wxStaticText* m_highLabel; - wxStaticLine* m_staticline1; wxStdDialogButtonSizer* m_stdButtons; wxButton* m_stdButtonsOK; wxButton* m_stdButtonsCancel; @@ -65,7 +63,7 @@ class DIALOG_PNS_SETTINGS_BASE : public DIALOG_SHIM public: - DIALOG_PNS_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Interactive Router settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 277,404 ), long style = wxDEFAULT_DIALOG_STYLE ); + DIALOG_PNS_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Interactive Router settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 298,410 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_PNS_SETTINGS_BASE(); }; diff --git a/pcbnew/import_dxf/dxf2brd_items.cpp b/pcbnew/import_dxf/dxf2brd_items.cpp index e143830ee3..3a31fd0297 100644 --- a/pcbnew/import_dxf/dxf2brd_items.cpp +++ b/pcbnew/import_dxf/dxf2brd_items.cpp @@ -134,6 +134,66 @@ void DXF2BRD_CONVERTER::addLine( const DRW_Line& data ) appendToBoard( segm ); } +void DXF2BRD_CONVERTER::addPolyline(const DRW_Polyline& data ) +{ + // Currently, Pcbnew does not know polylines, for boards. + // So we have to convert a polyline to a set of segments. + // Obviously, the z coordinate is ignored + + wxPoint startpoint; + for( unsigned ii = 0; ii < data.vertlist.size(); ii++ ) + { + DRW_Vertex* vertex = data.vertlist[ii]; + + if( ii == 0 ) + { + startpoint.x = mapX( vertex->basePoint.x ); + startpoint.y = mapY( vertex->basePoint.y ); + continue; + } + + DRAWSEGMENT* segm = new DRAWSEGMENT( m_brd ); + segm->SetLayer( m_brdLayer ); + segm->SetStart( startpoint ); + wxPoint endpoint( mapX( vertex->basePoint.x ), mapY( vertex->basePoint.y ) ); + segm->SetEnd( endpoint ); + segm->SetWidth( mapDim( data.thickness == 0 ? m_defaultThickness + : data.thickness ) ); + appendToBoard( segm ); + startpoint = endpoint; + } +} + +void DXF2BRD_CONVERTER::addLWPolyline(const DRW_LWPolyline& data ) +{ + // Currently, Pcbnew does not know polylines, for boards. + // So we have to convert a polyline to a set of segments. + // The import is a simplified import: the width of segment is + // (obviously contant and is the width of the DRW_LWPolyline. + // the variable width of each vertex (when exists) is not used. + wxPoint startpoint; + for( unsigned ii = 0; ii < data.vertlist.size(); ii++ ) + { + DRW_Vertex2D* vertex = data.vertlist[ii]; + + if( ii == 0 ) + { + startpoint.x = mapX( vertex->x ); + startpoint.y = mapY( vertex->y ); + continue; + } + + DRAWSEGMENT* segm = new DRAWSEGMENT( m_brd ); + segm->SetLayer( m_brdLayer ); + segm->SetStart( startpoint ); + wxPoint endpoint( mapX( vertex->x ), mapY( vertex->y ) ); + segm->SetEnd( endpoint ); + segm->SetWidth( mapDim( data.thickness == 0 ? m_defaultThickness + : data.thickness ) ); + appendToBoard( segm ); + startpoint = endpoint; + } +} /* * Import Circle entities. diff --git a/pcbnew/import_dxf/dxf2brd_items.h b/pcbnew/import_dxf/dxf2brd_items.h index 0dcd676571..ecc8b14e1b 100644 --- a/pcbnew/import_dxf/dxf2brd_items.h +++ b/pcbnew/import_dxf/dxf2brd_items.h @@ -123,9 +123,9 @@ private: virtual void addCircle(const DRW_Circle& data ); virtual void addArc(const DRW_Arc& data ); virtual void addEllipse(const DRW_Ellipse& data ){} - virtual void addLWPolyline(const DRW_LWPolyline& data ){} + virtual void addLWPolyline(const DRW_LWPolyline& data ); virtual void addText(const DRW_Text& data ); - virtual void addPolyline(const DRW_Polyline& data ){} + virtual void addPolyline(const DRW_Polyline& data ); virtual void addSpline(const DRW_Spline* data ){} virtual void addKnot(const DRW_Entity&) {} virtual void addInsert(const DRW_Insert& data ){}