From 544ca4c90d20258e4bb90a63a6180aafd2424523 Mon Sep 17 00:00:00 2001 From: charras Date: Wed, 15 Oct 2008 17:14:51 +0000 Subject: [PATCH] solved a very subtle bug in polygon_test_point_inside.cpp. Sometimes a point outside a polygon was seen inside the polygon --- pcbnew/class_zone.cpp | 20 +- pcbnew/class_zone.h | 59 +- pcbnew/dialog_copper_zones.cpp | 52 +- pcbnew/dialog_copper_zones.h | 3 +- pcbnew/dialog_copper_zones_frame.cpp | 38 +- pcbnew/dialog_copper_zones_frame.fbp | 951 +++++++++++++++----------- pcbnew/dialog_copper_zones_frame.h | 7 + pcbnew/zones.h | 1 + pcbnew/zones_by_polygon.cpp | 1 + polygon/polygon_test_point_inside.cpp | 17 +- 10 files changed, 683 insertions(+), 466 deletions(-) diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 34ad7a91c5..c7eca9a0b9 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -30,6 +30,7 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) : utility2 = 0; // flags used in polygon calculations m_Poly = new CPolyLine(); // Outlines m_ArcToSegmentsCount = 16; // Use 16 segment to convert a circle to a polygon + m_DrawOptions = 0; } @@ -137,8 +138,9 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const if( ret < 2 ) return false; - ret = fprintf( aFile, "ZOptions %d %d\n", m_GridFillValue, m_ArcToSegmentsCount ); - if( ret < 2 ) + ret = fprintf( aFile, "ZOptions %d %d %c\n", m_GridFillValue, m_ArcToSegmentsCount, + m_DrawOptions ? 'S' : 'F' ); + if( ret < 3 ) return false; @@ -266,20 +268,26 @@ int ZONE_CONTAINER::ReadDescr( FILE* aFile, int* aLineNum ) break; } } - /* Set hatch later, afer reading outlines corners data */ + /* Set hatch mode later, after reading outlines corners data */ } if( strnicmp( Line, "ZOptions", 8 ) == 0 ) // Options info found { int gridsize = 50; int arcsegmentcount = 16; + int drawopt = 'F'; text = Line + 8; - ret = sscanf( text, "%d %d", &gridsize, &arcsegmentcount ); - if( ret < 1 ) // Must find 1 or 2 args. + ret = sscanf( text, "%d %d %c", &gridsize, &arcsegmentcount, &drawopt ); + if( ret < 1 ) // Must find 1 or more args. return false; else m_GridFillValue = gridsize; + if ( arcsegmentcount >= 32 ) m_ArcToSegmentsCount = 32; + + if ( drawopt == 'S' ) // Sketch mode for filled areas in this zone selected + m_DrawOptions = 1; + } if( strnicmp( Line, "ZClearance", 10 ) == 0 ) // Clearence and pad options info found { @@ -436,7 +444,7 @@ void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel, { static int* CornersBuffer = NULL; static unsigned CornersBufferSize = 0; - bool sketch_mode = false; // true to show areas outlines only (test and debug purposes) + bool sketch_mode = m_DrawOptions; // false to show filled polys, true to show polygons outlines only (test and debug purposes) if( DC == NULL ) return; diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h index 08efd9a3c5..40c0fc231a 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -41,16 +41,19 @@ public: * In less simple cases (when m_Poly has holes) m_FilledPolysList is a polygon equivalent to m_Poly, without holes * In complex cases an ouline decribed by m_Poly can have many filled areas */ + int m_DrawOptions; /* used to pass some draw options (draw filled areas in sketch mode for instance ...) + * currently useful when testing filling zones algos + */ private: - int m_NetCode; // Net number for fast comparisons + int m_NetCode; // Net number for fast comparisons public: ZONE_CONTAINER( BOARD* parent ); ~ZONE_CONTAINER(); - bool Save( FILE* aFile ) const; - int ReadDescr( FILE* aFile, int* aLineNum = NULL ); + bool Save( FILE* aFile ) const; + int ReadDescr( FILE* aFile, int* aLineNum = NULL ); wxPoint& GetPosition() { @@ -69,9 +72,9 @@ public: * copy usefull data from the source. * flags and linked list pointers are NOT copied */ - void Copy( ZONE_CONTAINER* src ); + void Copy( ZONE_CONTAINER* src ); - void Display_Infos( WinEDA_DrawFrame* frame ); + void Display_Infos( WinEDA_DrawFrame* frame ); /** * Function Draw @@ -81,10 +84,10 @@ public: * @param offset = Draw offset (usually wxPoint(0,0)) * @param aDrawMode = GR_OR, GR_XOR, GR_COPY .. */ - void Draw( WinEDA_DrawPanel* panel, - wxDC* DC, - int aDrawMode, - const wxPoint& offset = ZeroOffset ); + void Draw( WinEDA_DrawPanel* panel, + wxDC* DC, + int aDrawMode, + const wxPoint& offset = ZeroOffset ); /** * Function DrawDrawFilledArea @@ -94,19 +97,19 @@ public: * @param offset = Draw offset (usually wxPoint(0,0)) * @param aDrawMode = GR_OR, GR_XOR, GR_COPY .. */ - void DrawFilledArea( WinEDA_DrawPanel* panel, - wxDC* DC, - int aDrawMode, - const wxPoint& offset = ZeroOffset ); + void DrawFilledArea( WinEDA_DrawPanel* panel, + wxDC* DC, + int aDrawMode, + const wxPoint& offset = ZeroOffset ); - EDA_Rect GetBoundingBox(); + EDA_Rect GetBoundingBox(); /** * Function Test_For_Copper_Island_And_Remove__Insulated_Islands * Remove insulated copper islands found in m_FilledPolysList. * @param aPcb = the board to analyse */ - void Test_For_Copper_Island_And_Remove_Insulated_Islands( BOARD* aPcb ); + void Test_For_Copper_Island_And_Remove_Insulated_Islands( BOARD* aPcb ); /** * Function DrawWhileCreateOutline @@ -117,7 +120,7 @@ public: * @param DC = current Device Context * @param draw_mode = draw mode: OR, XOR .. */ - void DrawWhileCreateOutline( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode = GR_OR ); + void DrawWhileCreateOutline( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode = GR_OR ); /** @@ -136,7 +139,7 @@ public: } - void SetNet( int anet_code ); + void SetNet( int anet_code ); /** * Function HitTest @@ -144,7 +147,7 @@ public: * @param refPos A wxPoint to test * @return bool - true if a hit, else false */ - bool HitTest( const wxPoint& refPos ); + bool HitTest( const wxPoint& refPos ); /** function BuildFilledPolysListData * Build m_FilledPolysList data from real outlines (m_Poly) @@ -155,7 +158,7 @@ public: * This function does not add holes for pads and tracks but calls * AddClearanceAreasPolygonsToPolysList() to do that for copper layers */ - int BuildFilledPolysListData( BOARD * aPcb ); + int BuildFilledPolysListData( BOARD* aPcb ); /** function AddClearanceAreasPolygonsToPolysList * Add non copper areas polygons (pads and tracks with clearence) @@ -167,7 +170,7 @@ public: * filled copper area polygon (without clearence areas * @param aPcb: the current board */ - void AddClearanceAreasPolygonsToPolysList( BOARD * aPcb ); + void AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ); /** * Function HitTestForCorner @@ -175,7 +178,7 @@ public: * @return -1 if none, corner index in .corner * @param refPos : A wxPoint to test */ - int HitTestForCorner( const wxPoint& refPos ); + int HitTestForCorner( const wxPoint& refPos ); /** * Function HitTestForEdge @@ -183,7 +186,7 @@ public: * @return -1 if none, or index of the starting corner in .corner * @param refPos : A wxPoint to test */ - int HitTestForEdge( const wxPoint& refPos ); + int HitTestForEdge( const wxPoint& refPos ); /** * Function HitTest (overlayed) @@ -191,7 +194,7 @@ public: * @param refArea : the given EDA_Rect * @return bool - true if a hit, else false */ - bool HitTest( EDA_Rect& refArea ); + bool HitTest( EDA_Rect& refArea ); /** * Function Fill_Zone() @@ -204,7 +207,7 @@ public: * @param verbose = true to show error messages * @return error level (0 = no error) */ - int Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose = TRUE ); + int Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose = TRUE ); /* Geometric transformations: */ @@ -213,14 +216,14 @@ public: * Move the outlines * @param offset = moving vector */ - void Move( const wxPoint& offset ); + void Move( const wxPoint& offset ); /** * Function MoveEdge * Move the outline Edge. m_CornerSelection is the start point of the outline edge * @param offset = moving vector */ - void MoveEdge( const wxPoint& offset ); + void MoveEdge( const wxPoint& offset ); /** * Function Rotate @@ -228,7 +231,7 @@ public: * @param centre = rot centre * @param angle = in 0.1 degree */ - void Rotate( const wxPoint& centre, int angle ); + void Rotate( const wxPoint& centre, int angle ); /** * Function Mirror @@ -236,7 +239,7 @@ public: * the layer is not changed * @param mirror_ref = vertical axis position */ - void Mirror( const wxPoint& mirror_ref ); + void Mirror( const wxPoint& mirror_ref ); /** * Function GetClass diff --git a/pcbnew/dialog_copper_zones.cpp b/pcbnew/dialog_copper_zones.cpp index 265c6128b2..ed5c65bf10 100644 --- a/pcbnew/dialog_copper_zones.cpp +++ b/pcbnew/dialog_copper_zones.cpp @@ -81,7 +81,7 @@ void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event ) int selection = 0; int grid_routing = g_GridRoutingSize; - + if( m_Zone_Container ) grid_routing = m_Zone_Container->m_GridFillValue; @@ -120,6 +120,12 @@ void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event ) } g_Zone_Hatching = m_Zone_Container->m_Poly->GetHatchStyle(); g_Zone_Arc_Approximation = m_Zone_Container->m_ArcToSegmentsCount; + + g_FilledAreasShowMode = m_Zone_Container->m_DrawOptions; + if ( g_FilledAreasShowMode == 1) + m_ShowFilledAreasInSketchOpt->SetValue(true); + + } else @@ -242,19 +248,21 @@ void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event ) } -/*************************************************************/ +/********************************************************************/ void dialog_copper_zone::OnButtonCancelClick( wxCommandEvent& event ) -/*************************************************************/ +/********************************************************************/ { EndModal( ZONE_ABORT ); } -/**********************************************************/ -bool dialog_copper_zone::AcceptOptions(bool aPromptForErrors) -/**********************************************************/ +/********************************************************************************************/ +bool dialog_copper_zone::AcceptOptions(bool aPromptForErrors, bool aUseExportableSetupOnly) +/********************************************************************************************/ /** Function dialog_copper_zone::AcceptOptions( * @return false if incorrect options, true if Ok. + * @param aPromptForErrors = true to prompt user on incorrectparams + * @param aUseExportableSetupOnly = true to use exportable parametres only (used to export this setup to other zones) */ { switch( m_FillOpt->GetSelection() ) @@ -315,7 +323,7 @@ bool dialog_copper_zone::AcceptOptions(bool aPromptForErrors) case 4: g_GridRoutingSize = 0; - wxMessageBox( wxT( + DisplayInfo( this, wxT( "You are using No grid for filling zones\nThis is currently in development and for tests only.\n Do not use for production")); break; } @@ -328,6 +336,12 @@ bool dialog_copper_zone::AcceptOptions(bool aPromptForErrors) else g_Zone_45_Only = TRUE; + g_FilledAreasShowMode = m_ShowFilledAreasInSketchOpt->IsChecked() ? 1 : 0; + + // If we use only exportable to others zones parameters, exit here: + if ( aUseExportableSetupOnly ) + return true; + /* Get the layer selection for this zone */ int ii = m_LayerSelectionCtrl->GetSelection(); if( ii < 0 && aPromptForErrors ) @@ -335,7 +349,10 @@ bool dialog_copper_zone::AcceptOptions(bool aPromptForErrors) DisplayError( this, _( "Error : you must choose a layer" ) ); return false; } + + g_CurrentZone_Layer = m_LayerId[ii]; + /* Get the net name selection for this zone */ ii = m_ListNetNameSelection->GetSelection(); @@ -432,4 +449,25 @@ void dialog_copper_zone::OnRemoveFillZoneButtonClick( wxCommandEvent& event ) m_Parent->DrawPanel->Refresh(); } +/******************************************************************************/ +void dialog_copper_zone::ExportSetupToOtherCopperZones( wxCommandEvent& event ) +/******************************************************************************/ +{ + if ( !AcceptOptions(true, true) ) + return; + + // Export to others zones: + BOARD * pcb = m_Parent->m_Pcb; + for( int ii = 0; ii < pcb->GetAreaCount(); ii++ ) + { + ZONE_CONTAINER* zone = pcb->GetArea(ii); + zone->m_Poly->SetHatch( g_Zone_Hatching ); + zone->m_PadOption = g_Zone_Pad_Options; + zone->m_ZoneClearance = g_DesignSettings.m_ZoneClearence; + zone->m_GridFillValue = g_GridRoutingSize; + zone->m_ArcToSegmentsCount = g_Zone_Arc_Approximation; + zone->m_DrawOptions = g_FilledAreasShowMode; + m_Parent->GetScreen()->SetModify();; + } +} diff --git a/pcbnew/dialog_copper_zones.h b/pcbnew/dialog_copper_zones.h index d86bd2b669..d85e7d8686 100644 --- a/pcbnew/dialog_copper_zones.h +++ b/pcbnew/dialog_copper_zones.h @@ -20,9 +20,10 @@ public: void OnInitDialog( wxInitDialogEvent& event ); void OnButtonOkClick( wxCommandEvent& event ); void OnButtonCancelClick( wxCommandEvent& event ); - bool AcceptOptions(bool aPromptForErrors); + bool AcceptOptions(bool aPromptForErrors, bool aUseExportableSetupOnly = false); void OnRemoveFillZoneButtonClick( wxCommandEvent& event ); void OnNetSortingOptionSelected( wxCommandEvent& event ); + void ExportSetupToOtherCopperZones( wxCommandEvent& event ); }; #endif // #ifndef DIALOG_COPPER_ZONES diff --git a/pcbnew/dialog_copper_zones_frame.cpp b/pcbnew/dialog_copper_zones_frame.cpp index bedffc1d5a..4593f84d83 100644 --- a/pcbnew/dialog_copper_zones_frame.cpp +++ b/pcbnew/dialog_copper_zones_frame.cpp @@ -11,9 +11,10 @@ BEGIN_EVENT_TABLE( dialog_copper_zone_frame, wxDialog ) EVT_INIT_DIALOG( dialog_copper_zone_frame::_wxFB_OnInitDialog ) + EVT_BUTTON( wxID_BUTTON_EXPORT, dialog_copper_zone_frame::_wxFB_ExportSetupToOtherCopperZones ) EVT_BUTTON( wxID_OK, dialog_copper_zone_frame::_wxFB_OnButtonOkClick ) EVT_BUTTON( wxID_CANCEL, dialog_copper_zone_frame::_wxFB_OnButtonCancelClick ) - EVT_BUTTON( wxID_ANY, dialog_copper_zone_frame::_wxFB_OnRemoveFillZoneButtonClick ) + EVT_BUTTON( wxID_BUTTON_UNFILL, dialog_copper_zone_frame::_wxFB_OnRemoveFillZoneButtonClick ) EVT_RADIOBOX( ID_NET_SORTING_OPTION, dialog_copper_zone_frame::_wxFB_OnNetSortingOptionSelected ) END_EVENT_TABLE() @@ -27,6 +28,9 @@ dialog_copper_zone_frame::dialog_copper_zone_frame( wxWindow* parent, wxWindowID wxBoxSizer* m_OptionsBoxSizer; m_OptionsBoxSizer = new wxBoxSizer( wxHORIZONTAL ); + wxStaticBoxSizer* m_ExportableSetupSizer; + m_ExportableSetupSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Zone Setup:") ), wxHORIZONTAL ); + wxBoxSizer* m_LeftBoxSizer; m_LeftBoxSizer = new wxBoxSizer( wxVERTICAL ); @@ -36,8 +40,8 @@ dialog_copper_zone_frame::dialog_copper_zone_frame( wxWindow* parent, wxWindowID wxString m_GridCtrlChoices[] = { _("0.00000"), _("0.00000"), _("0.00000"), _("0.00000"), _("No Grid (For tests only!)") }; int m_GridCtrlNChoices = sizeof( m_GridCtrlChoices ) / sizeof( wxString ); m_GridCtrl = new wxRadioBox( this, ID_RADIOBOX_GRID_SELECTION, _("Grid Size for Filling:"), wxDefaultPosition, wxDefaultSize, m_GridCtrlNChoices, m_GridCtrlChoices, 1, wxRA_SPECIFY_COLS ); - m_GridCtrl->SetSelection( 1 ); - m_FillOptionsBox->Add( m_GridCtrl, 0, wxALL, 5 ); + m_GridCtrl->SetSelection( 0 ); + m_FillOptionsBox->Add( m_GridCtrl, 0, wxALL|wxEXPAND, 5 ); m_ClearanceValueTitle = new wxStaticText( this, wxID_ANY, _("Zone clearance value (mm):"), wxDefaultPosition, wxDefaultSize, 0 ); m_ClearanceValueTitle->Wrap( -1 ); @@ -49,15 +53,24 @@ dialog_copper_zone_frame::dialog_copper_zone_frame( wxWindow* parent, wxWindowID wxString m_FillOptChoices[] = { _("Include Pads"), _("Thermal Relief"), _("Exclude Pads") }; int m_FillOptNChoices = sizeof( m_FillOptChoices ) / sizeof( wxString ); m_FillOpt = new wxRadioBox( this, wxID_ANY, _("Pad in Zone:"), wxDefaultPosition, wxDefaultSize, m_FillOptNChoices, m_FillOptChoices, 1, wxRA_SPECIFY_COLS ); - m_FillOpt->SetSelection( 1 ); + m_FillOpt->SetSelection( 2 ); m_FillOptionsBox->Add( m_FillOpt, 0, wxALL|wxEXPAND, 5 ); + m_ShowFilledAreasInSketchOpt = new wxCheckBox( this, wxID_ANY, _("Show filled areas in sketch mode"), wxDefaultPosition, wxDefaultSize, 0 ); + + m_ShowFilledAreasInSketchOpt->SetToolTip( _("If enabled, filled areas in is this zone will be displayed as non filled polygons.\nIf disabled, filled areas in is this zone will be displayed as \"solid\" areas (normal mode).") ); + + m_FillOptionsBox->Add( m_ShowFilledAreasInSketchOpt, 0, wxALL, 5 ); + m_LeftBoxSizer->Add( m_FillOptionsBox, 1, wxEXPAND, 5 ); - m_OptionsBoxSizer->Add( m_LeftBoxSizer, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); + m_ExportableSetupSizer->Add( m_LeftBoxSizer, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); - m_OptionsBoxSizer->Add( 5, 5, 0, wxEXPAND, 5 ); + m_ExportableSetupSizer->Add( 5, 5, 0, wxEXPAND, 5 ); + + wxBoxSizer* m_MiddleBox; + m_MiddleBox = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* m_MiddleBoxSizer; m_MiddleBoxSizer = new wxBoxSizer( wxVERTICAL ); @@ -92,7 +105,16 @@ dialog_copper_zone_frame::dialog_copper_zone_frame( wxWindow* parent, wxWindowID m_MiddleBoxSizer->Add( m_OutilinesBoxOpt, 1, wxEXPAND, 5 ); - m_OptionsBoxSizer->Add( m_MiddleBoxSizer, 0, 0, 5 ); + m_ExportSetupBuuton = new wxButton( this, wxID_BUTTON_EXPORT, _("Export to others zones"), wxDefaultPosition, wxDefaultSize, 0 ); + m_ExportSetupBuuton->SetToolTip( _("Export this zone setup to all others copper zones") ); + + m_MiddleBoxSizer->Add( m_ExportSetupBuuton, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + m_MiddleBox->Add( m_MiddleBoxSizer, 0, 0, 5 ); + + m_ExportableSetupSizer->Add( m_MiddleBox, 1, wxEXPAND, 5 ); + + m_OptionsBoxSizer->Add( m_ExportableSetupSizer, 1, wxEXPAND, 5 ); m_OptionsBoxSizer->Add( 0, 0, 0, wxEXPAND, 5 ); @@ -107,7 +129,7 @@ dialog_copper_zone_frame::dialog_copper_zone_frame( wxWindow* parent, wxWindowID m_ButtonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); m_RightBoxSizer->Add( m_ButtonCancel, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); - m_UnFillZoneButton = new wxButton( this, wxID_ANY, _("UnFill Zone"), wxDefaultPosition, wxDefaultSize, 0 ); + m_UnFillZoneButton = new wxButton( this, wxID_BUTTON_UNFILL, _("UnFill Zone"), wxDefaultPosition, wxDefaultSize, 0 ); m_RightBoxSizer->Add( m_UnFillZoneButton, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); diff --git a/pcbnew/dialog_copper_zones_frame.fbp b/pcbnew/dialog_copper_zones_frame.fbp index 91b3783983..751fdae8b9 100644 --- a/pcbnew/dialog_copper_zones_frame.fbp +++ b/pcbnew/dialog_copper_zones_frame.fbp @@ -86,444 +86,573 @@ none 5 - wxEXPAND|wxALIGN_CENTER_VERTICAL - 0 - + wxEXPAND + 1 + + wxID_ANY + Zone Setup: - m_LeftBoxSizer - wxVERTICAL + m_ExportableSetupSizer + wxHORIZONTAL none + 5 - wxEXPAND - 1 - - wxID_ANY - Zone Fill Options: + wxEXPAND|wxALIGN_CENTER_VERTICAL + 0 + - m_FillOptionsBox + m_LeftBoxSizer wxVERTICAL none - 5 - wxALL - 0 - - - "0.00000" "0.00000" "0.00000" "0.00000" "No Grid (For tests only!)" - - 1 - - - 0 - ID_RADIOBOX_GRID_SELECTION - Grid Size for Filling: - 1 - - - m_GridCtrl - protected - - 1 - - wxRA_SPECIFY_COLS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - - - 1 - - - 0 + wxEXPAND + 1 + wxID_ANY - Zone clearance value (mm): - + Zone Fill Options: - m_ClearanceValueTitle - protected - - - - - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - - - 1 - - - 0 - wxID_ANY - - 0 - - m_ZoneClearanceCtrl - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - - "Include Pads" "Thermal Relief" "Exclude Pads" - - 1 - - - 0 - wxID_ANY - Pad in Zone: - 1 - - - m_FillOpt - protected - - 1 - - wxRA_SPECIFY_COLS - - - - - - - - - - - - - - - - - - - - - - - - - - - - + m_FillOptionsBox + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + + "0.00000" "0.00000" "0.00000" "0.00000" "No Grid (For tests only!)" + + 1 + + + 0 + ID_RADIOBOX_GRID_SELECTION + Grid Size for Filling: + 1 + + + m_GridCtrl + protected + + 0 + + wxRA_SPECIFY_COLS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + + + 1 + + + 0 + wxID_ANY + Zone clearance value (mm): + + + m_ClearanceValueTitle + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + + + 1 + + + 0 + wxID_ANY + + 0 + + m_ZoneClearanceCtrl + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + "Include Pads" "Thermal Relief" "Exclude Pads" + + 1 + + + 0 + wxID_ANY + Pad in Zone: + 1 + + + m_FillOpt + protected + + 2 + + wxRA_SPECIFY_COLS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + 0 + + 1 + + + 0 + wxID_ANY + Show filled areas in sketch mode + + + m_ShowFilledAreasInSketchOpt + protected + + + + + If enabled, filled areas in is this zone will be displayed as non filled polygons. If disabled, filled areas in is this zone will be displayed as "solid" areas (normal mode). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - 5 - wxEXPAND - 0 - - 5 - protected - 5 - - - - 5 - - 0 - - - m_MiddleBoxSizer - wxVERTICAL - none + + 5 + wxEXPAND + 0 + + 5 + protected + 5 + + 5 wxEXPAND 1 - - wxID_ANY - Outlines Options: + - m_OutilinesBoxOpt + m_MiddleBox wxVERTICAL none - - - 5 - wxALL|wxEXPAND - 0 - - - "Any" "H , V and 45 deg" - - 1 - - - 0 - wxID_ANY - Zone edges orient: - 1 - - - m_OrientEdgesOpt - protected - - 0 - - wxRA_SPECIFY_COLS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 0 - - 5 - protected - 5 - - - - 5 - wxALL|wxEXPAND - 0 - - - "Line" "Hatched Outline" "Full Hatched" - - 1 - - - 0 - ID_RADIOBOX_OUTLINES_OPTION - Outlines Appearance - 1 - + - m_OutlineAppearanceCtrl - protected - - 0 - - wxRA_SPECIFY_COLS - - Choose how a zone outline is displayed - Single line - Short hatching - Full zone area hatched - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - - "16 segments / 360 deg" "32 segments / 360 deg" - - 1 - - - 0 - wxID_ARC_APPROX - Arcs Approximation: - 1 - - - m_ArcApproximationOpt - protected - - 1 - - wxRA_SPECIFY_COLS - - Number of segments to approximate a circle in filling calculations. 16 segment is faster to calculate and when redraw screen. 32 segment give a better quality - - - - - - - - - - - - - - - - - - - - - - - - - - - + m_MiddleBoxSizer + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + wxID_ANY + Outlines Options: + + m_OutilinesBoxOpt + wxVERTICAL + none + + + 5 + wxALL|wxEXPAND + 0 + + + "Any" "H , V and 45 deg" + + 1 + + + 0 + wxID_ANY + Zone edges orient: + 1 + + + m_OrientEdgesOpt + protected + + 0 + + wxRA_SPECIFY_COLS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + 0 + + 5 + protected + 5 + + + + 5 + wxALL|wxEXPAND + 0 + + + "Line" "Hatched Outline" "Full Hatched" + + 1 + + + 0 + ID_RADIOBOX_OUTLINES_OPTION + Outlines Appearance + 1 + + + m_OutlineAppearanceCtrl + protected + + 0 + + wxRA_SPECIFY_COLS + + Choose how a zone outline is displayed - Single line - Short hatching - Full zone area hatched + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + "16 segments / 360 deg" "32 segments / 360 deg" + + 1 + + + 0 + wxID_ARC_APPROX + Arcs Approximation: + 1 + + + m_ArcApproximationOpt + protected + + 1 + + wxRA_SPECIFY_COLS + + Number of segments to approximate a circle in filling calculations. 16 segment is faster to calculate and when redraw screen. 32 segment give a better quality + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL + 0 + + + + 0 + 1 + + + 0 + wxID_BUTTON_EXPORT + Export to others zones + + + m_ExportSetupBuuton + protected + + + + + Export this zone setup to all others copper zones + + + + ExportSetupToOtherCopperZones + + + + + + + + + + + + + + + + + + + + + + + + + @@ -665,7 +794,7 @@ 0 - wxID_ANY + wxID_BUTTON_UNFILL UnFill Zone diff --git a/pcbnew/dialog_copper_zones_frame.h b/pcbnew/dialog_copper_zones_frame.h index 7bcf737732..9ce3df5469 100644 --- a/pcbnew/dialog_copper_zones_frame.h +++ b/pcbnew/dialog_copper_zones_frame.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -36,6 +37,7 @@ class dialog_copper_zone_frame : public wxDialog // Private event handlers void _wxFB_OnInitDialog( wxInitDialogEvent& event ){ OnInitDialog( event ); } + void _wxFB_ExportSetupToOtherCopperZones( wxCommandEvent& event ){ ExportSetupToOtherCopperZones( event ); } void _wxFB_OnButtonOkClick( wxCommandEvent& event ){ OnButtonOkClick( event ); } void _wxFB_OnButtonCancelClick( wxCommandEvent& event ){ OnButtonCancelClick( event ); } void _wxFB_OnRemoveFillZoneButtonClick( wxCommandEvent& event ){ OnRemoveFillZoneButtonClick( event ); } @@ -48,6 +50,8 @@ class dialog_copper_zone_frame : public wxDialog ID_RADIOBOX_GRID_SELECTION = 1000, ID_RADIOBOX_OUTLINES_OPTION, wxID_ARC_APPROX, + wxID_BUTTON_EXPORT, + wxID_BUTTON_UNFILL, ID_NET_SORTING_OPTION, ID_TEXTCTRL_NETNAMES_FILTER, ID_NETNAME_SELECTION, @@ -58,11 +62,13 @@ class dialog_copper_zone_frame : public wxDialog wxStaticText* m_ClearanceValueTitle; wxTextCtrl* m_ZoneClearanceCtrl; wxRadioBox* m_FillOpt; + wxCheckBox* m_ShowFilledAreasInSketchOpt; wxRadioBox* m_OrientEdgesOpt; wxRadioBox* m_OutlineAppearanceCtrl; wxRadioBox* m_ArcApproximationOpt; + wxButton* m_ExportSetupBuuton; wxButton* m_OkButton; wxButton* m_ButtonCancel; @@ -78,6 +84,7 @@ class dialog_copper_zone_frame : public wxDialog // Virtual event handlers, overide them in your derived class virtual void OnInitDialog( wxInitDialogEvent& 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 OnRemoveFillZoneButtonClick( wxCommandEvent& event ){ event.Skip(); } diff --git a/pcbnew/zones.h b/pcbnew/zones.h index ff538a3172..13f65f40c1 100644 --- a/pcbnew/zones.h +++ b/pcbnew/zones.h @@ -36,6 +36,7 @@ eda_global int g_CurrentZone_Layer; // Layer used to create the eda_global int g_Zone_Hatching; // Option to show the zone area (outlines only, short hatches or full hatches eda_global int g_Zone_Arc_Approximation; // Option to select number of segments to approximate a circle // 16 or 32 segments +eda_global int g_FilledAreasShowMode; // Used to select draw options for filled areas in a zone (currently normal =0, sketch = 1) eda_global ZONE_CONTAINER::m_PadInZone g_Zone_Pad_Options #ifdef MAIN diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index e12cd9c218..65d8d8a6e7 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -794,6 +794,7 @@ void WinEDA_PcbFrame::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container zone_container->m_ZoneClearance = g_DesignSettings.m_ZoneClearence; zone_container->m_GridFillValue = g_GridRoutingSize; zone_container->m_ArcToSegmentsCount = g_Zone_Arc_Approximation; + zone_container->m_DrawOptions = g_FilledAreasShowMode; // Combine zones if possible : diff --git a/polygon/polygon_test_point_inside.cpp b/polygon/polygon_test_point_inside.cpp index 64f7754696..c5f4354261 100644 --- a/polygon/polygon_test_point_inside.cpp +++ b/polygon/polygon_test_point_inside.cpp @@ -317,11 +317,11 @@ bool TestPointInsidePolygon( std::vector aPolysList, double intersectx1, intersecty1, intersectx2, intersecty2; int ok; ok = FindLineSegmentIntersection( a, slope, - aPolysList[ics].x, aPolysList[ics].y, - aPolysList[ice].x, aPolysList[ice].y, - CPolyLine::STRAIGHT, - &intersectx1, &intersecty1, - &intersectx2, &intersecty2 ); + aPolysList[ics].x, aPolysList[ics].y, + aPolysList[ice].x, aPolysList[ice].y, + CPolyLine::STRAIGHT, + &intersectx1, &intersecty1, + &intersectx2, &intersecty2 ); /* FindLineSegmentIntersection() returns 0, 1 or 2 coordinates (ok = 0, 1, 2) * for straight line segments, only 0 or 1 are possible @@ -331,6 +331,13 @@ bool TestPointInsidePolygon( std::vector aPolysList, { xx = (int) intersectx1; yy = (int) intersecty1; + + /* if the intersection point is on the start point of the current segment, + * do not count it, + * because it was already counted, as ending point of the previous segment + */ + if( xx == aPolysList[ics].x && yy == aPolysList[ics].y ) + continue; #if OUTSIDE_IF_ON_SIDE if( xx == refx && yy == refy ) return false; // (x,y) is on a side, call it outside