From 3b56ea67324dc52c746b6ff231c8b0e9c17151b4 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 2 Aug 2012 15:23:53 +0200 Subject: [PATCH 1/2] Eeschema: fix crash when changing a label type to a global label during creation. Pcbnew: code cleaning in polygons --- eeschema/edit_label.cpp | 4 + eeschema/sch_sheet.cpp | 2 - pcbnew/class_board.h | 6 +- pcbnew/dialogs/dialog_copper_zones_base.cpp | 92 +++--- pcbnew/dialogs/dialog_copper_zones_base.fbp | 334 +++----------------- pcbnew/dialogs/dialog_copper_zones_base.h | 13 +- pcbnew/zones_test_and_combine_areas.cpp | 166 ++-------- polygon/PolyLine.cpp | 121 ++++++- 8 files changed, 236 insertions(+), 502 deletions(-) diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 75f9b259e7..fb23f6b922 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -230,6 +230,10 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent ) newtext->Draw( m_canvas, &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); m_canvas->CrossHairOn( &dc ); // redraw schematic cursor + // if the old item is the current schematic item, replace it by the new text: + if( screen->GetCurItem() == text ) + screen->SetCurItem( newtext ); + if( text->IsNew() ) { // if the previous text is new, no undo command to prepare here diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 061dc4f4d1..ab923065ab 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -950,8 +950,6 @@ void SCH_SHEET::renumberPins() void SCH_SHEET::GetEndPoints( std::vector & aItemList ) { - // Using BOOST_FOREACH here creates problems (bad pointer value to pinsheet). - // I do not know why. for( unsigned ii = 0; ii < GetPins().size(); ii++ ) { SCH_SHEET_PIN &pinsheet = GetPins()[ii]; diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index 6fa3768183..ecf5b49028 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -1115,11 +1115,9 @@ public: * area_to_test must be after area_ref in m_ZoneDescriptorList * @param area_ref = area reference * @param area_to_test = area to compare for intersection calculations - * @return : 0 if no intersection - * 1 if intersection - * 2 if arcs intersect + * @return : false if no intersection, true if intersection */ - int TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_to_test ); + bool TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_to_test ); /** * Function CombineAreas diff --git a/pcbnew/dialogs/dialog_copper_zones_base.cpp b/pcbnew/dialogs/dialog_copper_zones_base.cpp index 3c36d7b185..02e794730b 100644 --- a/pcbnew/dialogs/dialog_copper_zones_base.cpp +++ b/pcbnew/dialogs/dialog_copper_zones_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Mar 17 2012) +// C++ code generated with wxFormBuilder (version Apr 10 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -19,8 +19,8 @@ BEGIN_EVENT_TABLE( DIALOG_COPPER_ZONE_BASE, DIALOG_SHIM ) EVT_CHOICE( ID_CORNER_SMOOTHING, DIALOG_COPPER_ZONE_BASE::_wxFB_OnCornerSmoothingModeChoice ) EVT_CHOICE( ID_M_PADINZONEOPT, DIALOG_COPPER_ZONE_BASE::_wxFB_OnPadsInZoneClick ) EVT_BUTTON( wxID_BUTTON_EXPORT, DIALOG_COPPER_ZONE_BASE::_wxFB_ExportSetupToOtherCopperZones ) - EVT_BUTTON( wxID_OK, DIALOG_COPPER_ZONE_BASE::_wxFB_OnButtonOkClick ) EVT_BUTTON( wxID_CANCEL, DIALOG_COPPER_ZONE_BASE::_wxFB_OnButtonCancelClick ) + EVT_BUTTON( wxID_OK, DIALOG_COPPER_ZONE_BASE::_wxFB_OnButtonOkClick ) END_EVENT_TABLE() DIALOG_COPPER_ZONE_BASE::DIALOG_COPPER_ZONE_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) @@ -37,10 +37,10 @@ DIALOG_COPPER_ZONE_BASE::DIALOG_COPPER_ZONE_BASE( wxWindow* parent, wxWindowID i m_staticText17 = new wxStaticText( this, wxID_ANY, _("Layer:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText17->Wrap( -1 ); - m_layerSizer->Add( m_staticText17, 0, wxLEFT|wxRIGHT|wxTOP, 5 ); + m_layerSizer->Add( m_staticText17, 0, wxTOP|wxRIGHT, 5 ); - m_LayerSelectionCtrl = new wxListView( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_ALIGN_LEFT|wxLC_NO_HEADER|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_SMALL_ICON ); - m_layerSizer->Add( m_LayerSelectionCtrl, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_LayerSelectionCtrl = new wxListView( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_HEADER|wxLC_REPORT|wxLC_SINGLE_SEL ); + m_layerSizer->Add( m_LayerSelectionCtrl, 1, wxEXPAND|wxRIGHT, 5 ); m_OptionsBoxSizer->Add( m_layerSizer, 1, wxEXPAND, 5 ); @@ -53,7 +53,7 @@ DIALOG_COPPER_ZONE_BASE::DIALOG_COPPER_ZONE_BASE( wxWindow* parent, wxWindowID i bSizer7->Add( m_staticText2, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); m_ListNetNameSelection = new wxListBox( this, ID_NETNAME_SELECTION, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); - bSizer7->Add( m_ListNetNameSelection, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + bSizer7->Add( m_ListNetNameSelection, 1, wxEXPAND, 5 ); m_OptionsBoxSizer->Add( bSizer7, 1, wxEXPAND, 5 ); @@ -93,92 +93,92 @@ DIALOG_COPPER_ZONE_BASE::DIALOG_COPPER_ZONE_BASE( wxWindow* parent, wxWindowID i m_NetSortOptSizer->Add( m_buttonRunFilter, 0, wxALL|wxEXPAND, 5 ); - m_OptionsBoxSizer->Add( m_NetSortOptSizer, 0, wxALL, 5 ); + m_OptionsBoxSizer->Add( m_NetSortOptSizer, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - m_MainBoxSizer->Add( m_OptionsBoxSizer, 1, wxALL|wxEXPAND, 5 ); + m_MainBoxSizer->Add( m_OptionsBoxSizer, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); wxStaticBoxSizer* m_ExportableSetupSizer; m_ExportableSetupSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Settings") ), wxHORIZONTAL ); - wxBoxSizer* bSizer9; - bSizer9 = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bSizerSettings; + bSizerSettings = new wxBoxSizer( wxVERTICAL ); m_ClearanceValueTitle = new wxStaticText( this, wxID_ANY, _("Clearance"), wxDefaultPosition, wxDefaultSize, 0 ); m_ClearanceValueTitle->Wrap( -1 ); - bSizer9->Add( m_ClearanceValueTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + bSizerSettings->Add( m_ClearanceValueTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); m_ZoneClearanceCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - bSizer9->Add( m_ZoneClearanceCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + bSizerSettings->Add( m_ZoneClearanceCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_MinThicknessValueTitle = new wxStaticText( this, wxID_ANY, _("Minimum width"), wxDefaultPosition, wxDefaultSize, 0 ); m_MinThicknessValueTitle->Wrap( -1 ); m_MinThicknessValueTitle->SetToolTip( _("Minimun thickness of filled areas.") ); - bSizer9->Add( m_MinThicknessValueTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + bSizerSettings->Add( m_MinThicknessValueTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); m_ZoneMinThicknessCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - bSizer9->Add( m_ZoneMinThicknessCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + bSizerSettings->Add( m_ZoneMinThicknessCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_staticText151 = new wxStaticText( this, wxID_ANY, _("Corner smoothing:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText151->Wrap( -1 ); - bSizer9->Add( m_staticText151, 0, wxLEFT|wxRIGHT|wxTOP, 5 ); + bSizerSettings->Add( m_staticText151, 0, wxLEFT|wxRIGHT|wxTOP, 5 ); wxString m_cornerSmoothingChoiceChoices[] = { _("None"), _("Chamfer"), _("Fillet") }; int m_cornerSmoothingChoiceNChoices = sizeof( m_cornerSmoothingChoiceChoices ) / sizeof( wxString ); m_cornerSmoothingChoice = new wxChoice( this, ID_CORNER_SMOOTHING, wxDefaultPosition, wxDefaultSize, m_cornerSmoothingChoiceNChoices, m_cornerSmoothingChoiceChoices, 0 ); m_cornerSmoothingChoice->SetSelection( 0 ); - bSizer9->Add( m_cornerSmoothingChoice, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + bSizerSettings->Add( m_cornerSmoothingChoice, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); m_cornerSmoothingTitle = new wxStaticText( this, wxID_ANY, _("Chamfer distance (mm):"), wxDefaultPosition, wxDefaultSize, 0 ); m_cornerSmoothingTitle->Wrap( -1 ); - bSizer9->Add( m_cornerSmoothingTitle, 0, wxRIGHT|wxLEFT, 5 ); + bSizerSettings->Add( m_cornerSmoothingTitle, 0, wxRIGHT|wxLEFT, 5 ); m_cornerSmoothingCtrl = new wxTextCtrl( this, ID_M_CORNERSMOOTHINGCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - bSizer9->Add( m_cornerSmoothingCtrl, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + bSizerSettings->Add( m_cornerSmoothingCtrl, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); - m_ExportableSetupSizer->Add( bSizer9, 0, wxEXPAND, 5 ); + m_ExportableSetupSizer->Add( bSizerSettings, 0, wxEXPAND, 5 ); - wxBoxSizer* m_LeftBox; - m_LeftBox = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bSizerPadsConnection; + bSizerPadsConnection = new wxBoxSizer( wxVERTICAL ); m_staticText13 = new wxStaticText( this, wxID_ANY, _("Pad connection:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText13->Wrap( -1 ); - m_LeftBox->Add( m_staticText13, 0, wxLEFT|wxRIGHT|wxTOP, 5 ); + bSizerPadsConnection->Add( m_staticText13, 0, wxLEFT|wxRIGHT|wxTOP, 5 ); wxString m_PadInZoneOptChoices[] = { _("Solid"), _("Thermal relief"), _("THT thermal"), _("None") }; int m_PadInZoneOptNChoices = sizeof( m_PadInZoneOptChoices ) / sizeof( wxString ); m_PadInZoneOpt = new wxChoice( this, ID_M_PADINZONEOPT, wxDefaultPosition, wxDefaultSize, m_PadInZoneOptNChoices, m_PadInZoneOptChoices, 0 ); m_PadInZoneOpt->SetSelection( 0 ); - m_LeftBox->Add( m_PadInZoneOpt, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + bSizerPadsConnection->Add( m_PadInZoneOpt, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); wxStaticBoxSizer* m_ThermalShapesParamsSizer; m_ThermalShapesParamsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Thermal Reliefs") ), wxVERTICAL ); m_AntipadSizeText = new wxStaticText( this, wxID_ANY, _("Antipad clearance"), wxDefaultPosition, wxDefaultSize, 0 ); m_AntipadSizeText->Wrap( -1 ); - m_ThermalShapesParamsSizer->Add( m_AntipadSizeText, 0, wxLEFT|wxRIGHT|wxTOP, 5 ); + m_ThermalShapesParamsSizer->Add( m_AntipadSizeText, 0, wxTOP|wxRIGHT, 5 ); m_AntipadSizeValue = new wxTextCtrl( this, wxID_ANTIPAD_SIZE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_AntipadSizeValue->SetToolTip( _("Clearance between pads in the same net and filled areas.") ); - m_ThermalShapesParamsSizer->Add( m_AntipadSizeValue, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + m_ThermalShapesParamsSizer->Add( m_AntipadSizeValue, 0, wxEXPAND|wxBOTTOM, 5 ); m_CopperBridgeWidthText = new wxStaticText( this, wxID_ANY, _("Spoke width"), wxDefaultPosition, wxDefaultSize, 0 ); m_CopperBridgeWidthText->Wrap( -1 ); - m_ThermalShapesParamsSizer->Add( m_CopperBridgeWidthText, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + m_ThermalShapesParamsSizer->Add( m_CopperBridgeWidthText, 0, wxTOP|wxRIGHT, 5 ); m_CopperWidthValue = new wxTextCtrl( this, wxID_COPPER_BRIDGE_VALUE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_CopperWidthValue->SetToolTip( _("Width of copper in thermal reliefs.") ); - m_ThermalShapesParamsSizer->Add( m_CopperWidthValue, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + m_ThermalShapesParamsSizer->Add( m_CopperWidthValue, 0, wxEXPAND|wxBOTTOM, 5 ); - m_LeftBox->Add( m_ThermalShapesParamsSizer, 0, wxALL|wxEXPAND, 5 ); + bSizerPadsConnection->Add( m_ThermalShapesParamsSizer, 0, wxALL|wxEXPAND, 5 ); - m_ExportableSetupSizer->Add( m_LeftBox, 0, wxEXPAND, 5 ); + m_ExportableSetupSizer->Add( bSizerPadsConnection, 0, wxEXPAND, 5 ); wxBoxSizer* m_MiddleBox; m_MiddleBox = new wxBoxSizer( wxVERTICAL ); @@ -215,52 +215,54 @@ DIALOG_COPPER_ZONE_BASE::DIALOG_COPPER_ZONE_BASE( wxWindow* parent, wxWindowID i m_ExportableSetupSizer->Add( m_MiddleBox, 0, wxEXPAND, 5 ); - wxBoxSizer* bSizer81; - bSizer81 = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bSizerLowerRight; + bSizerLowerRight = new wxBoxSizer( wxVERTICAL ); m_staticText14 = new wxStaticText( this, wxID_ANY, _("Outline slope:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText14->Wrap( -1 ); - bSizer81->Add( m_staticText14, 0, wxLEFT|wxRIGHT|wxTOP, 5 ); + bSizerLowerRight->Add( m_staticText14, 0, wxLEFT|wxRIGHT|wxTOP, 5 ); wxString m_OrientEdgesOptChoices[] = { _("Arbitrary"), _("H, V, and 45 deg only") }; int m_OrientEdgesOptNChoices = sizeof( m_OrientEdgesOptChoices ) / sizeof( wxString ); m_OrientEdgesOpt = new wxChoice( this, ID_M_ORIENTEDGESOPT, wxDefaultPosition, wxDefaultSize, m_OrientEdgesOptNChoices, m_OrientEdgesOptChoices, 0 ); m_OrientEdgesOpt->SetSelection( 0 ); - bSizer81->Add( m_OrientEdgesOpt, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + bSizerLowerRight->Add( m_OrientEdgesOpt, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); m_staticText15 = new wxStaticText( this, wxID_ANY, _("Outline style:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText15->Wrap( -1 ); - bSizer81->Add( m_staticText15, 0, wxLEFT|wxRIGHT|wxTOP, 5 ); + bSizerLowerRight->Add( m_staticText15, 0, wxLEFT|wxRIGHT|wxTOP, 5 ); wxString m_OutlineAppearanceCtrlChoices[] = { _("Line"), _("Hatched"), _("Fully hatched") }; int m_OutlineAppearanceCtrlNChoices = sizeof( m_OutlineAppearanceCtrlChoices ) / sizeof( wxString ); m_OutlineAppearanceCtrl = new wxChoice( this, ID_M_OUTLINEAPPEARANCECTRL, wxDefaultPosition, wxDefaultSize, m_OutlineAppearanceCtrlNChoices, m_OutlineAppearanceCtrlChoices, 0 ); m_OutlineAppearanceCtrl->SetSelection( 0 ); - bSizer81->Add( m_OutlineAppearanceCtrl, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + bSizerLowerRight->Add( m_OutlineAppearanceCtrl, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); - m_ExportableSetupSizer->Add( bSizer81, 0, wxEXPAND, 5 ); + m_ExportableSetupSizer->Add( bSizerLowerRight, 0, wxEXPAND, 5 ); m_MainBoxSizer->Add( m_ExportableSetupSizer, 0, wxALL|wxEXPAND, 5 ); - wxBoxSizer* bSizer10; - bSizer10 = new wxBoxSizer( wxHORIZONTAL ); + wxBoxSizer* bSizerbottom; + bSizerbottom = new wxBoxSizer( wxHORIZONTAL ); m_ExportSetupButton = new wxButton( this, wxID_BUTTON_EXPORT, _("Export Settings to Other Zones"), wxDefaultPosition, wxDefaultSize, 0 ); m_ExportSetupButton->SetToolTip( _("Export this zone setup (excluding layer and net selection) to all other copper zones.") ); - bSizer10->Add( m_ExportSetupButton, 0, wxALL|wxEXPAND, 5 ); + bSizerbottom->Add( m_ExportSetupButton, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - m_OkButton = new wxButton( this, wxID_OK, _("Ok"), wxDefaultPosition, wxDefaultSize, 0 ); - m_OkButton->SetDefault(); - bSizer10->Add( m_OkButton, 0, wxALL|wxEXPAND, 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(); - m_ButtonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer10->Add( m_ButtonCancel, 0, wxALL|wxEXPAND, 5 ); + bSizerbottom->Add( m_sdbSizer, 1, wxEXPAND, 5 ); - m_MainBoxSizer->Add( bSizer10, 0, wxALIGN_RIGHT|wxALL, 5 ); + m_MainBoxSizer->Add( bSizerbottom, 0, wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); this->SetSizer( m_MainBoxSizer ); diff --git a/pcbnew/dialogs/dialog_copper_zones_base.fbp b/pcbnew/dialogs/dialog_copper_zones_base.fbp index 9d9ded4636..82fa8cbe9d 100644 --- a/pcbnew/dialogs/dialog_copper_zones_base.fbp +++ b/pcbnew/dialogs/dialog_copper_zones_base.fbp @@ -25,62 +25,28 @@ 1 0 - 1 - 1 - 1 - 1 - 0 - - - - + wxAUI_MGR_DEFAULT - - 1 - 0 - 1 1 - 0 - Dock - 0 - Left 1 impl_virtual - 1 - 0 0 ID_DIALOG_COPPER_ZONE_BASE - - 0 - - 0 - 1 DIALOG_COPPER_ZONE_BASE - 1 - - - 1 - Resizable - 1 567,500 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h - Zone Properties - 0 + Copper Zone Properties - - wxFILTER_NONE - wxDefaultValidator - @@ -127,7 +93,7 @@ protected 5 - wxALL|wxEXPAND + wxEXPAND|wxTOP|wxRIGHT|wxLEFT 1 @@ -145,7 +111,7 @@ none 5 - wxLEFT|wxRIGHT|wxTOP + wxTOP|wxRIGHT 0 1 @@ -197,10 +163,6 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -232,7 +194,7 @@ 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + wxEXPAND|wxRIGHT 1 1 @@ -279,7 +241,7 @@ Resizable 1 - wxLC_ALIGN_LEFT|wxLC_NO_HEADER|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_SMALL_ICON + wxLC_NO_HEADER|wxLC_REPORT|wxLC_SINGLE_SEL wxListView; 0 @@ -400,10 +362,6 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -435,7 +393,7 @@ 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + wxEXPAND 1 1 @@ -525,7 +483,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL 0 wxID_ANY @@ -589,10 +547,6 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -764,10 +718,6 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -942,10 +892,6 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -1176,7 +1122,7 @@ 0 - bSizer9 + bSizerSettings wxVERTICAL none @@ -1233,10 +1179,6 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -1411,10 +1353,6 @@ 0 Minimun thickness of filled areas. - - wxFILTER_NONE - wxDefaultValidator - @@ -1589,10 +1527,6 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -1764,10 +1698,6 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -1896,7 +1826,7 @@ 0 - m_LeftBox + bSizerPadsConnection wxVERTICAL none @@ -1953,10 +1883,6 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -2088,7 +2014,7 @@ 5 - wxLEFT|wxRIGHT|wxTOP + wxTOP|wxRIGHT 0 1 @@ -2140,10 +2066,6 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -2175,7 +2097,7 @@ 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT + wxEXPAND|wxBOTTOM 0 1 @@ -2266,7 +2188,7 @@ 5 - wxTOP|wxRIGHT|wxLEFT + wxTOP|wxRIGHT 0 1 @@ -2318,10 +2240,6 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -2353,7 +2271,7 @@ 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT + wxEXPAND|wxBOTTOM 0 1 @@ -2509,10 +2427,6 @@ 0 On each copper layer, zones are filled by priority order. So when a zone is inside an other zone: * If its priority is highter: its outlines are removed from the other layer. * If its priority is equal: a DRC error is set. - - wxFILTER_NONE - wxDefaultValidator - @@ -2598,10 +2512,6 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -2687,10 +2597,6 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -2862,10 +2768,6 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -2991,7 +2893,7 @@ 0 - bSizer81 + bSizerLowerRight wxVERTICAL none @@ -3048,10 +2950,6 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -3223,10 +3121,6 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -3350,16 +3244,16 @@ 5 - wxALIGN_RIGHT|wxALL + wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT 0 - bSizer10 + bSizerbottom wxHORIZONTAL none 5 - wxALL|wxEXPAND + wxEXPAND|wxRIGHT|wxLEFT 0 1 @@ -3445,180 +3339,30 @@ - + 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_OK - Ok - - 0 - - - 0 + wxEXPAND + 1 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 - 1 - m_OkButton - 1 - - + m_sdbSizer protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnButtonOkClick - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_CANCEL - Cancel - - 0 - - - 0 - - 1 - m_ButtonCancel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnButtonCancelClick - - - - - - - - - - - - - - - - - - - - - - - + + OnButtonCancelClick + + + + OnButtonOkClick + + diff --git a/pcbnew/dialogs/dialog_copper_zones_base.h b/pcbnew/dialogs/dialog_copper_zones_base.h index ec77cbeb36..904802b9cb 100644 --- a/pcbnew/dialogs/dialog_copper_zones_base.h +++ b/pcbnew/dialogs/dialog_copper_zones_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Mar 17 2012) +// C++ code generated with wxFormBuilder (version Apr 10 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -46,8 +46,8 @@ class DIALOG_COPPER_ZONE_BASE : public DIALOG_SHIM void _wxFB_OnCornerSmoothingModeChoice( wxCommandEvent& event ){ OnCornerSmoothingModeChoice( event ); } void _wxFB_OnPadsInZoneClick( wxCommandEvent& event ){ OnPadsInZoneClick( event ); } void _wxFB_ExportSetupToOtherCopperZones( wxCommandEvent& event ){ ExportSetupToOtherCopperZones( event ); } - void _wxFB_OnButtonOkClick( wxCommandEvent& event ){ OnButtonOkClick( event ); } void _wxFB_OnButtonCancelClick( wxCommandEvent& event ){ OnButtonCancelClick( event ); } + void _wxFB_OnButtonOkClick( wxCommandEvent& event ){ OnButtonOkClick( event ); } protected: @@ -108,8 +108,9 @@ class DIALOG_COPPER_ZONE_BASE : public DIALOG_SHIM wxStaticText* m_staticText15; wxChoice* m_OutlineAppearanceCtrl; wxButton* m_ExportSetupButton; - wxButton* m_OkButton; - wxButton* m_ButtonCancel; + wxStdDialogButtonSizer* m_sdbSizer; + wxButton* m_sdbSizerOK; + wxButton* m_sdbSizerCancel; // Virtual event handlers, overide them in your derived class virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } @@ -119,13 +120,13 @@ class DIALOG_COPPER_ZONE_BASE : public DIALOG_SHIM virtual void OnCornerSmoothingModeChoice( wxCommandEvent& event ) { event.Skip(); } virtual void OnPadsInZoneClick( wxCommandEvent& event ) { event.Skip(); } virtual void ExportSetupToOtherCopperZones( wxCommandEvent& event ) { event.Skip(); } - virtual void OnButtonOkClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnButtonCancelClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnButtonOkClick( wxCommandEvent& event ) { event.Skip(); } public: - DIALOG_COPPER_ZONE_BASE( wxWindow* parent, wxWindowID id = ID_DIALOG_COPPER_ZONE_BASE, const wxString& title = _("Zone Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 567,500 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_COPPER_ZONE_BASE( wxWindow* parent, wxWindowID id = ID_DIALOG_COPPER_ZONE_BASE, const wxString& title = _("Copper Zone Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 567,500 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_COPPER_ZONE_BASE(); }; diff --git a/pcbnew/zones_test_and_combine_areas.cpp b/pcbnew/zones_test_and_combine_areas.cpp index 63e7a1fe79..d6169a69ea 100644 --- a/pcbnew/zones_test_and_combine_areas.cpp +++ b/pcbnew/zones_test_and_combine_areas.cpp @@ -276,12 +276,12 @@ bool BOARD::CombineAllAreasInNet( PICKED_ITEMS_LIST* aDeletedList, int aNetCode, // check area2 against curr_area if( curr_area->utility || area2->utility || aUseUtility == false ) { - int ret = TestAreaIntersection( curr_area, area2 ); + bool ret = TestAreaIntersection( curr_area, area2 ); - if( ret == 1 ) + if( ret ) ret = CombineAreas( aDeletedList, curr_area, area2 ); - if( ret == 1 ) + if( ret ) { mod_ia1 = true; modified = true; @@ -306,8 +306,6 @@ bool BOARD::CombineAllAreasInNet( PICKED_ITEMS_LIST* aDeletedList, int aNetCode, */ bool BOARD::TestAreaIntersections( ZONE_CONTAINER* area_to_test ) { - CPolyLine* poly1 = area_to_test->m_Poly; - for( unsigned ia2 = 0; ia2 < m_ZoneDescriptorList.size(); ia2++ ) { ZONE_CONTAINER* area2 = m_ZoneDescriptorList[ia2]; @@ -330,95 +328,8 @@ bool BOARD::TestAreaIntersections( ZONE_CONTAINER* area_to_test ) if( area_to_test->GetIsKeepout() != area2->GetIsKeepout() ) continue; - CPolyLine* poly2 = area2->m_Poly; - - // test bounding rects - CRect b1 = poly1->GetCornerBounds(); - CRect b2 = poly2->GetCornerBounds(); - - if( b1.bottom > b2.top - || b1.top < b2.bottom - || b1.left > b2.right - || b1.right < b2.left ) - continue; - - // test for intersecting segments - for( int icont1 = 0; icont1GetContoursCount(); icont1++ ) - { - int is1 = poly1->GetContourStart( icont1 ); - int ie1 = poly1->GetContourEnd( icont1 ); - - for( int ic1 = is1; ic1<=ie1; ic1++ ) - { - int xi1 = poly1->GetX( ic1 ); - int yi1 = poly1->GetY( ic1 ); - int xf1, yf1; - - if( ic1 < ie1 ) - { - xf1 = poly1->GetX( ic1 + 1 ); - yf1 = poly1->GetY( ic1 + 1 ); - } - else - { - xf1 = poly1->GetX( is1 ); - yf1 = poly1->GetY( is1 ); - } - - for( int icont2 = 0; icont2 < poly2->GetContoursCount(); icont2++ ) - { - int is2 = poly2->GetContourStart( icont2 ); - int ie2 = poly2->GetContourEnd( icont2 ); - - for( int ic2 = is2; ic2<=ie2; ic2++ ) - { - int xi2 = poly2->GetX( ic2 ); - int yi2 = poly2->GetY( ic2 ); - int xf2, yf2; - - if( ic2 < ie2 ) - { - xf2 = poly2->GetX( ic2 + 1 ); - yf2 = poly2->GetY( ic2 + 1 ); - } - else - { - xf2 = poly2->GetX( is2 ); - yf2 = poly2->GetY( is2 ); - } - - int n_int = FindSegmentIntersections( xi1, yi1, xf1, yf1, - xi2, yi2, xf2, yf2 ); - if( n_int ) - return true; - } - } - } - } - - // If a contour is inside an other contour, no segments intersects, but the zones can - // be combined test a corner inside an outline (only one corner is enought) - for( int ic2 = 0; ic2 < poly2->GetNumCorners(); ic2++ ) - { - int x = poly2->GetX( ic2 ); - int y = poly2->GetY( ic2 ); - - if( poly1->TestPointInside( x, y ) ) - { - return true; - } - } - - for( int ic1 = 0; ic1 < poly1->GetNumCorners(); ic1++ ) - { - int x = poly1->GetX( ic1 ); - int y = poly1->GetY( ic1 ); - - if( poly2->TestPointInside( x, y ) ) - { - return true; - } - } + if( TestAreaIntersection( area_to_test, area2 ) ) + return true; } return false; @@ -431,14 +342,13 @@ bool BOARD::TestAreaIntersections( ZONE_CONTAINER* area_to_test ) * area_to_test must be after area_ref in m_ZoneDescriptorList * @param area_ref = area reference * @param area_to_test = area to compare for intersection calculations - * @return : 0 if no intersection - * 1 if intersection + * @return : false if no intersection, true if intersection */ -int BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_to_test ) +bool BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_to_test ) { // see if areas are on same layer if( area_ref->GetLayer() != area_to_test->GetLayer() ) - return 0; + return false; CPolyLine* poly1 = area_ref->m_Poly; CPolyLine* poly2 = area_to_test->m_Poly; @@ -449,11 +359,9 @@ int BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_ if( b1.bottom > b2.top || b1.top < b2.bottom || b1.left > b2.right || b1.right < b2.left ) - return 0; + return false; // now test for intersecting segments - bool bInt = false; - for( int icont1 = 0; icont1GetContoursCount(); icont1++ ) { int is1 = poly1->GetContourStart( icont1 ); @@ -498,48 +406,40 @@ int BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_ yf2 = poly2->GetY( is2 ); } - int n_int = FindSegmentIntersections( xi1, yi1, xf1, yf1, - xi2, yi2, xf2, yf2 ); - if( n_int ) - { - bInt = true; - break; - } + bool intersect = FindSegmentIntersections( xi1, yi1, xf1, yf1, + xi2, yi2, xf2, yf2 ); + if( intersect ) + return true; } } } } - if( !bInt ) + // If a contour is inside an other contour, no segments intersects, but the zones + // can be combined if a corner is inside an outline (only one corner is enought) + for( int ic2 = 0; ic2 < poly2->GetNumCorners(); ic2++ ) { - // If a contour is inside an other contour, no segments intersects, but the zones - // can be combined test a corner inside an outline (only one corner is enought) - for( int ic2 = 0; ic2 < poly2->GetNumCorners(); ic2++ ) + int x = poly2->GetX( ic2 ); + int y = poly2->GetY( ic2 ); + + if( poly1->TestPointInside( x, y ) ) { - int x = poly2->GetX( ic2 ); - int y = poly2->GetY( ic2 ); - - if( poly1->TestPointInside( x, y ) ) - { - return 1; - } + return 1; } - - for( int ic1 = 0; ic1 < poly1->GetNumCorners(); ic1++ ) - { - int x = poly1->GetX( ic1 ); - int y = poly1->GetY( ic1 ); - - if( poly2->TestPointInside( x, y ) ) - { - return 1; - } - } - - return 0; } - return 1; + for( int ic1 = 0; ic1 < poly1->GetNumCorners(); ic1++ ) + { + int x = poly1->GetX( ic1 ); + int y = poly1->GetY( ic1 ); + + if( poly2->TestPointInside( x, y ) ) + { + return 1; + } + } + + return 0; } diff --git a/polygon/PolyLine.cpp b/polygon/PolyLine.cpp index d79f3628ee..c23a5ad17f 100644 --- a/polygon/PolyLine.cpp +++ b/polygon/PolyLine.cpp @@ -453,7 +453,96 @@ void armBoolEng( Bool_Engine* aBooleng, bool aConvertHoles ) */ int CPolyLine::NormalizeAreaOutlines( std::vector* aNewPolygonList ) { +#if 1 return NormalizeWithKbool( aNewPolygonList ); +#else // Do NOT use this code: it does not yet work + unsigned corners_count = m_CornersList.size(); + + KI_POLYGON_SET polysholes; + KI_POLYGON_WITH_HOLES mainpoly; + std::vector cornerslist; + KI_POLYGON_WITH_HOLES_SET outlines; + KI_POLYGON poly_tmp; + + unsigned ic = 0; + // enter main outline + while( ic < corners_count ) + { + const CPolyPt& corner = m_CornersList[ic++]; + cornerslist.push_back( KI_POLY_POINT( corner.x, corner.y ) ); + + if( corner.end_contour ) + break; + } + + mainpoly.set( cornerslist.begin(), cornerslist.end() ); + outlines.push_back( mainpoly ); + outlines &= mainpoly; + + // Enter holes + while( ic < corners_count ) + { + cornerslist.clear(); + { + while( ic < corners_count ) + { + const CPolyPt& corner = m_CornersList[ic++]; + cornerslist.push_back( KI_POLY_POINT( corner.x, corner.y ) ); + + if( corner.end_contour ) + break; + } + + bpl::set_points( poly_tmp, cornerslist.begin(), cornerslist.end() ); + polysholes.push_back( poly_tmp ); + } + } + + outlines -= polysholes; + + // copy polygon with holes to destination + RemoveAllContours(); + + for( unsigned ii = 0; ii < outlines.size(); ii++ ) + { + CPolyLine* polyline = this; + if( ii > 0 ) + { + polyline = new CPolyLine; + polyline->SetLayer( GetLayer() ); + polyline->SetHatchStyle( GetHatchStyle() ); + polyline->SetHatchPitch( GetHatchPitch() ); + aNewPolygonList->push_back( polyline ); + } + + KI_POLYGON_WITH_HOLES& curr_poly = outlines[ii]; + KI_POLYGON_WITH_HOLES::iterator_type corner = curr_poly.begin(); + // enter main contour + while( corner != curr_poly.end() ) + { + polyline->AppendCorner( corner->x(), corner->y() ); + corner++; + } + polyline->CloseLastContour(); + + // add holes (set of polygons) + KI_POLYGON_WITH_HOLES::iterator_holes_type hole = curr_poly.begin_holes(); + while( hole != curr_poly.end_holes() ) + { + KI_POLYGON::iterator_type hole_corner = hole->begin(); + // create area with external contour: Recreate only area edges, NOT holes + while( hole_corner != hole->end() ) + { + polyline->AppendCorner( hole_corner->x(), hole_corner->y() ); + hole_corner++; + } + polyline->CloseLastContour(); + hole++; + } + } + + return outlines.size(); +#endif } @@ -1526,8 +1615,8 @@ void ConvertPolysListWithHolesToOnePolygon( const std::vector& aPolysL std::vector& aOnePolyList ) { unsigned corners_count = aPolysListWithHoles.size(); - int polycount = 0; + int polycount = 0; for( unsigned ii = 0; ii < corners_count; ii++ ) { const CPolyPt& corner = aPolysListWithHoles[ii]; @@ -1536,8 +1625,8 @@ void ConvertPolysListWithHolesToOnePolygon( const std::vector& aPolysL polycount++; } - // If polycount<= 1, there is no holes found. - if( polycount<= 1 ) + // If polycount<= 1, there is no holes found, and therefore just copy the polygon. + if( polycount <= 1 ) { aOnePolyList = aPolysListWithHoles; return; @@ -1587,23 +1676,21 @@ void ConvertPolysListWithHolesToOnePolygon( const std::vector& aPolysL // We should have only one polygon in list wxASSERT( mainpoly.size() != 1 ); + KI_POLYGON& poly_nohole = mainpoly[0]; + CPolyPt corner( 0, 0, false ); + + for( unsigned jj = 0; jj < poly_nohole.size(); jj++ ) { - KI_POLYGON& poly_nohole = mainpoly[0]; - CPolyPt corner( 0, 0, false ); - - for( unsigned jj = 0; jj < poly_nohole.size(); jj++ ) - { - KI_POLY_POINT point = *(poly_nohole.begin() + jj); - corner.x = point.x(); - corner.y = point.y(); - corner.end_contour = false; - aOnePolyList.push_back( corner ); - } - - corner.end_contour = true; - aOnePolyList.pop_back(); + KI_POLY_POINT point = *(poly_nohole.begin() + jj); + corner.x = point.x(); + corner.y = point.y(); + corner.end_contour = false; aOnePolyList.push_back( corner ); } + + corner.end_contour = true; + aOnePolyList.pop_back(); + aOnePolyList.push_back( corner ); } /** From 899d23d4fd1a0d13637d65eb8377601fb5b7835e Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 2 Aug 2012 19:32:42 +0200 Subject: [PATCH 2/2] Polygon code cleanup --- polygon/PolyLine.cpp | 109 ++++------------------------------------ polygon/PolyLine.h | 32 +++++++----- polygon/polygons_defs.h | 1 - 3 files changed, 30 insertions(+), 112 deletions(-) diff --git a/polygon/PolyLine.cpp b/polygon/PolyLine.cpp index c23a5ad17f..aee22e3cf0 100644 --- a/polygon/PolyLine.cpp +++ b/polygon/PolyLine.cpp @@ -24,7 +24,6 @@ CPolyLine::CPolyLine() m_hatchStyle = NO_HATCH; m_hatchPitch = 0; m_layer = 0; - m_width = 0; m_utility = 0; m_Kbool_Poly_Engine = NULL; } @@ -135,9 +134,7 @@ int CPolyLine::NormalizeWithKbool( std::vector* aExtraPolyList ) else if( aExtraPolyList ) // a new outside contour is found: create a new CPolyLine { polyline = new CPolyLine; - polyline->SetLayer( GetLayer() ); - polyline->SetHatchStyle( GetHatchStyle() ); - polyline->SetHatchPitch( GetHatchPitch() ); + polyline->ImportSettings( this ); aExtraPolyList->push_back( polyline ); // put it in array bool first = true; @@ -453,98 +450,19 @@ void armBoolEng( Bool_Engine* aBooleng, bool aConvertHoles ) */ int CPolyLine::NormalizeAreaOutlines( std::vector* aNewPolygonList ) { -#if 1 return NormalizeWithKbool( aNewPolygonList ); -#else // Do NOT use this code: it does not yet work - unsigned corners_count = m_CornersList.size(); - - KI_POLYGON_SET polysholes; - KI_POLYGON_WITH_HOLES mainpoly; - std::vector cornerslist; - KI_POLYGON_WITH_HOLES_SET outlines; - KI_POLYGON poly_tmp; - - unsigned ic = 0; - // enter main outline - while( ic < corners_count ) - { - const CPolyPt& corner = m_CornersList[ic++]; - cornerslist.push_back( KI_POLY_POINT( corner.x, corner.y ) ); - - if( corner.end_contour ) - break; - } - - mainpoly.set( cornerslist.begin(), cornerslist.end() ); - outlines.push_back( mainpoly ); - outlines &= mainpoly; - - // Enter holes - while( ic < corners_count ) - { - cornerslist.clear(); - { - while( ic < corners_count ) - { - const CPolyPt& corner = m_CornersList[ic++]; - cornerslist.push_back( KI_POLY_POINT( corner.x, corner.y ) ); - - if( corner.end_contour ) - break; - } - - bpl::set_points( poly_tmp, cornerslist.begin(), cornerslist.end() ); - polysholes.push_back( poly_tmp ); - } - } - - outlines -= polysholes; - - // copy polygon with holes to destination - RemoveAllContours(); - - for( unsigned ii = 0; ii < outlines.size(); ii++ ) - { - CPolyLine* polyline = this; - if( ii > 0 ) - { - polyline = new CPolyLine; - polyline->SetLayer( GetLayer() ); - polyline->SetHatchStyle( GetHatchStyle() ); - polyline->SetHatchPitch( GetHatchPitch() ); - aNewPolygonList->push_back( polyline ); - } - - KI_POLYGON_WITH_HOLES& curr_poly = outlines[ii]; - KI_POLYGON_WITH_HOLES::iterator_type corner = curr_poly.begin(); - // enter main contour - while( corner != curr_poly.end() ) - { - polyline->AppendCorner( corner->x(), corner->y() ); - corner++; - } - polyline->CloseLastContour(); - - // add holes (set of polygons) - KI_POLYGON_WITH_HOLES::iterator_holes_type hole = curr_poly.begin_holes(); - while( hole != curr_poly.end_holes() ) - { - KI_POLYGON::iterator_type hole_corner = hole->begin(); - // create area with external contour: Recreate only area edges, NOT holes - while( hole_corner != hole->end() ) - { - polyline->AppendCorner( hole_corner->x(), hole_corner->y() ); - hole_corner++; - } - polyline->CloseLastContour(); - hole++; - } - } - - return outlines.size(); -#endif } +/** + * Function ImportSettings + * Copy settings (layer, hatch styles) from aPoly + */ +void CPolyLine::ImportSettings( const CPolyLine * aPoly ) +{ + SetLayer( aPoly->GetLayer() ); + SetHatchStyle( aPoly->GetHatchStyle() ); + SetHatchPitch( aPoly->GetHatchPitch() ); +} /* initialize a contour * set layer, hatch style, and starting point @@ -931,11 +849,6 @@ int CPolyLine::GetEndContour( int ic ) CRect CPolyLine::GetBounds() { CRect r = GetCornerBounds(); - - r.left -= m_width / 2; - r.right += m_width / 2; - r.bottom -= m_width / 2; - r.top += m_width / 2; return r; } diff --git a/polygon/PolyLine.h b/polygon/PolyLine.h index 984062700c..b7e44b30fc 100644 --- a/polygon/PolyLine.h +++ b/polygon/PolyLine.h @@ -108,6 +108,13 @@ public: CPolyLine(); ~CPolyLine(); + /** + * Function ImportSettings + * Copy settings (layer, hatch styles) from aPoly + * @param aPoly is the CPolyLine to import settings + */ + void ImportSettings( const CPolyLine * aPoly ); + // functions for modifying the CPolyLine contours /* initialize a contour @@ -176,15 +183,15 @@ public: // access functions void SetLayer( int aLayer ) { m_layer = aLayer; } - int GetLayer() { return m_layer; } - int GetNumCorners(); - int GetNumSides(); - int GetClosed(); - int GetContoursCount(); - int GetContour( int ic ); - int GetContourStart( int icont ); - int GetContourEnd( int icont ); - int GetContourSize( int icont ); + int GetLayer() const { return m_layer; } + int GetNumCorners(); + int GetNumSides(); + int GetClosed(); + int GetContoursCount(); + int GetContour( int ic ); + int GetContourStart( int icont ); + int GetContourEnd( int icont ); + int GetContourSize( int icont ); int GetX( int ic ) const { return m_CornersList[ic].x; } int GetY( int ic ) const { return m_CornersList[ic].y; } @@ -193,13 +200,13 @@ public: int GetEndContour( int ic ); - int GetUtility( int ic ) { return m_CornersList[ic].m_utility; }; + int GetUtility( int ic ) const { return m_CornersList[ic].m_utility; }; void SetUtility( int ic, int utility ) { m_CornersList[ic].m_utility = utility; }; - int GetHatchPitch() { return m_hatchPitch; } + int GetHatchPitch() const { return m_hatchPitch; } static int GetDefaultHatchPitchMils() { return 20; } // default hatch pitch value in mils - enum HATCH_STYLE GetHatchStyle() { return m_hatchStyle; } + enum HATCH_STYLE GetHatchStyle() const { return m_hatchStyle; } void SetHatch( int aHatchStyle, int aHatchPitch, bool aRebuildHatch ) { SetHatchPitch( aHatchPitch ); @@ -286,7 +293,6 @@ public: private: int m_layer; // layer to draw on - int m_width; // lines width when drawing. Provided but not really used enum HATCH_STYLE m_hatchStyle; // hatch style, see enum above int m_hatchPitch; // for DIAGONAL_EDGE hatched outlines, basic distance between 2 hatch lines // and the len of eacvh segment diff --git a/polygon/polygons_defs.h b/polygon/polygons_defs.h index f9055c1cc6..94437bfff8 100644 --- a/polygon/polygons_defs.h +++ b/polygon/polygons_defs.h @@ -59,7 +59,6 @@ typedef bpl::polygon_with_holes_data KI_POLYGON_WITH_HOLES; * is always stored in a KI_POLYGON_WITH_HOLES_SET, because these operations * can create many separate polygons with holespolygons */ - typedef std::vector KI_POLYGON_WITH_HOLES_SET;