Allow polygon drawing on edge cuts and courtyard

Prevents line splitting behavior needed in v5 when drawing polygons on
courtyards. Also provide property dialog with some smarts to handle
special layers

Fixes https://gitlab.com/kicad/code/kicad/issues/6900
This commit is contained in:
Seth Hillbrand 2020-12-30 14:04:37 -08:00
parent 3eec5f32ef
commit 5a3e5781bf
5 changed files with 48 additions and 30 deletions

View File

@ -75,6 +75,8 @@ private:
} }
bool Validate() override; bool Validate() override;
void onLayer( wxCommandEvent& event ) override;
}; };
DIALOG_GRAPHIC_ITEM_PROPERTIES::DIALOG_GRAPHIC_ITEM_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, DIALOG_GRAPHIC_ITEM_PROPERTIES::DIALOG_GRAPHIC_ITEM_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent,
@ -188,12 +190,22 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow()
break; break;
case S_POLYGON: case S_POLYGON:
{
LSET graphicPolygonsLayers = LSET::AllLayersMask();
graphicPolygonsLayers.reset( Edge_Cuts ).reset( F_CrtYd ).reset( B_CrtYd );
SetTitle( _( "Polygon Properties" ) ); SetTitle( _( "Polygon Properties" ) );
m_sizerLeft->Show( false ); m_sizerLeft->Show( false );
m_filledCtrl->Show( true ); m_filledCtrl->Show( true );
break; m_filledCtrl->Enable( graphicPolygonsLayers.Contains( m_item->GetLayer() ) );
// Prevent courtyard/edge cuts from being filled
if( !graphicPolygonsLayers.Contains( m_item->GetLayer() ) )
m_filledCtrl->SetValue( false );
break;
}
case S_RECT: case S_RECT:
SetTitle( _( "Rectangle Properties" ) ); SetTitle( _( "Rectangle Properties" ) );
@ -360,6 +372,24 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow()
} }
void DIALOG_GRAPHIC_ITEM_PROPERTIES::onLayer( wxCommandEvent& event )
{
if( m_item->GetShape() == S_POLYGON )
{
LSET graphicPolygonsLayers = LSET::AllLayersMask();
graphicPolygonsLayers.reset( Edge_Cuts ).reset( F_CrtYd ).reset( B_CrtYd );
m_filledCtrl->Enable( graphicPolygonsLayers.Contains(
ToLAYER_ID( m_LayerSelectionCtrl->GetLayerSelection() ) ) );
// Prevent courtyard/edge cuts from being filled
if( !graphicPolygonsLayers.Contains(
ToLAYER_ID( m_LayerSelectionCtrl->GetLayerSelection() ) ) )
m_filledCtrl->SetValue( false );
}
}
bool DIALOG_GRAPHIC_ITEM_PROPERTIES::Validate() bool DIALOG_GRAPHIC_ITEM_PROPERTIES::Validate()
{ {
wxArrayString error_msgs; wxArrayString error_msgs;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018) // C++ code generated with wxFormBuilder (version 3.9.0 Dec 30 2020)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
@ -214,6 +214,7 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind
// Connect Events // Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnClose ) ); this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnClose ) );
this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnInitDlg ) ); this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnInitDlg ) );
m_LayerSelectionCtrl->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::onLayer ), NULL, this );
} }
DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::~DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE() DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::~DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE()
@ -221,5 +222,6 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::~DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE()
// Disconnect Events // Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnClose ) ); this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnClose ) );
this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnInitDlg ) ); this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnInitDlg ) );
m_LayerSelectionCtrl->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::onLayer ), NULL, this );
} }

View File

@ -14,6 +14,7 @@
<property name="file">dialog_graphic_item_properties_base</property> <property name="file">dialog_graphic_item_properties_base</property>
<property name="first_id">1000</property> <property name="first_id">1000</property>
<property name="help_provider">none</property> <property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property> <property name="indent_with_spaces"></property>
<property name="internationalize">1</property> <property name="internationalize">1</property>
<property name="name">DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE</property> <property name="name">DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE</property>
@ -25,6 +26,7 @@
<property name="skip_php_events">1</property> <property name="skip_php_events">1</property>
<property name="skip_python_events">1</property> <property name="skip_python_events">1</property>
<property name="ui_table">UI</property> <property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property> <property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property> <property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1"> <object class="Dialog" expanded="1">
@ -2507,6 +2509,7 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnCombobox">onLayer</event>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018) // C++ code generated with wxFormBuilder (version 3.9.0 Dec 30 2020)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
@ -82,9 +82,10 @@ class DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE : public DIALOG_SHIM
wxButton* m_StandardButtonsSizerOK; wxButton* m_StandardButtonsSizerOK;
wxButton* m_StandardButtonsSizerCancel; wxButton* m_StandardButtonsSizerCancel;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, override them in your derived class
virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } virtual void OnClose( wxCloseEvent& event ) { event.Skip(); }
virtual void OnInitDlg( wxInitDialogEvent& event ) { event.Skip(); } virtual void OnInitDlg( wxInitDialogEvent& event ) { event.Skip(); }
virtual void onLayer( wxCommandEvent& event ) { event.Skip(); }
public: public:

View File

@ -232,32 +232,14 @@ void ZONE_CREATE_HELPER::commitZone( std::unique_ptr<ZONE> aZone )
graphicPolygonsLayers.reset( Edge_Cuts ).reset( F_CrtYd ).reset( B_CrtYd ); graphicPolygonsLayers.reset( Edge_Cuts ).reset( F_CrtYd ).reset( B_CrtYd );
if( graphicPolygonsLayers.Contains( m_params.m_layer ) ) auto poly = m_tool.m_isFootprintEditor ? new FP_SHAPE( (FOOTPRINT*) parent )
{ : new PCB_SHAPE();
auto poly = m_tool.m_isFootprintEditor ? new FP_SHAPE( (FOOTPRINT *) parent ) poly->SetShape( S_POLYGON );
: new PCB_SHAPE(); poly->SetFilled( graphicPolygonsLayers.Contains( m_params.m_layer ) );
poly->SetShape( S_POLYGON ); poly->SetLayer( m_params.m_layer );
poly->SetFilled( m_params.m_layer != Edge_Cuts ); poly->SetPolyShape( *aZone->Outline() );
poly->SetLayer( m_params.m_layer ); bCommit.Add( poly );
poly->SetPolyShape ( *aZone->Outline() ); m_tool.GetManager()->RunAction( PCB_ACTIONS::selectItem, true, poly );
bCommit.Add( poly );
m_tool.GetManager()->RunAction( PCB_ACTIONS::selectItem, true, poly );
}
else
{
SHAPE_POLY_SET* outline = aZone->Outline();
for( auto seg = outline->CIterateSegments( 0 ); seg; seg++ )
{
auto* new_seg = m_tool.m_isFootprintEditor ? new FP_SHAPE( (FOOTPRINT *) parent )
: new PCB_SHAPE();
new_seg->SetShape( S_SEGMENT );
new_seg->SetLayer( m_params.m_layer );
new_seg->SetStart( wxPoint( seg.Get().A.x, seg.Get().A.y ) );
new_seg->SetEnd( wxPoint( seg.Get().B.x, seg.Get().B.y ) );
bCommit.Add( new_seg );
}
}
bCommit.Push( _( "Add a graphical polygon" ) ); bCommit.Push( _( "Add a graphical polygon" ) );