Browse Source

Don't disable line styles on filled shapes.

It's too much trouble to figure out what the
user wants, and not always right even then.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19946

(cherry picked from commit 42acb62f6e)
9.0
Jeff Young 9 months ago
parent
commit
2a93af1348
  1. 60
      pcbnew/dialogs/dialog_shape_properties.cpp
  2. 2
      pcbnew/dialogs/dialog_shape_properties_base.cpp
  3. 1
      pcbnew/dialogs/dialog_shape_properties_base.fbp
  4. 1
      pcbnew/dialogs/dialog_shape_properties_base.h
  5. 73
      pcbnew/pcb_painter.cpp

60
pcbnew/dialogs/dialog_shape_properties.cpp

@ -710,8 +710,6 @@ private:
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
void onFilledCheckbox( wxCommandEvent& event ) override;
void onLayerSelection( wxCommandEvent& event ) override;
void onTechLayersChanged( wxCommandEvent& event ) override;
@ -875,13 +873,13 @@ DIALOG_SHAPE_PROPERTIES::DIALOG_SHAPE_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent,
case SHAPE_T::RECTANGLE:
// For all these functions, it's very important that the fields are added in the same order
// as the CTRL_IDX enums in the GEOM_SYNCER classes.
AddXYPointToSizer( *aParent, *m_gbsRectangleByCorners, 0, 0, _( "Start Point" ), false, m_boundCtrls);
AddXYPointToSizer( *aParent, *m_gbsRectangleByCorners, 0, 0, _( "Start Point" ), false, m_boundCtrls );
AddXYPointToSizer( *aParent, *m_gbsRectangleByCorners, 0, 3, _( "End Point" ), false, m_boundCtrls );
AddXYPointToSizer( *aParent, *m_gbsRectangleByCornerSize, 0, 0, _( "Start Point" ), false, m_boundCtrls);
AddXYPointToSizer( *aParent, *m_gbsRectangleByCornerSize, 0, 0, _( "Start Point" ), false, m_boundCtrls );
AddXYPointToSizer( *aParent, *m_gbsRectangleByCornerSize, 0, 3, _( "Size" ), true, m_boundCtrls );
AddXYPointToSizer( *aParent, *m_gbsRectangleByCenterSize, 0, 0, _( "Center" ), false, m_boundCtrls);
AddXYPointToSizer( *aParent, *m_gbsRectangleByCenterSize, 0, 0, _( "Center" ), false, m_boundCtrls );
AddXYPointToSizer( *aParent, *m_gbsRectangleByCenterSize, 0, 3, _( "Size" ), true, m_boundCtrls );
m_geomSync = std::make_unique<RECTANGLE_GEOM_SYNCER>( m_workingCopy, m_boundCtrls );
@ -893,8 +891,8 @@ DIALOG_SHAPE_PROPERTIES::DIALOG_SHAPE_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent,
case SHAPE_T::SEGMENT:
AddXYPointToSizer( *aParent, *m_gbsLineByEnds, 0, 0, _( "Start Point" ), false, m_boundCtrls);
AddXYPointToSizer( *aParent, *m_gbsLineByEnds, 0, 3, _( "End Point" ), false, m_boundCtrls);
AddXYPointToSizer( *aParent, *m_gbsLineByEnds, 0, 0, _( "Start Point" ), false, m_boundCtrls );
AddXYPointToSizer( *aParent, *m_gbsLineByEnds, 0, 3, _( "End Point" ), false, m_boundCtrls );
AddXYPointToSizer( *aParent, *m_gbsLineByLengthAngle, 0, 0, _( "Start Point" ), false, m_boundCtrls);
AddFieldToSizer( *aParent, *m_gbsLineByLengthAngle, 1, 3, _( "Length" ), ORIGIN_TRANSFORMS::NOT_A_COORD, false, m_boundCtrls );
@ -915,9 +913,9 @@ DIALOG_SHAPE_PROPERTIES::DIALOG_SHAPE_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent,
AddXYPointToSizer( *aParent, *m_gbsArcByCSA, 0, 3, _( "Start Point" ), false, m_boundCtrls);
AddFieldToSizer( *aParent, *m_gbsArcByCSA, 3, 0, _( "Start Angle" ), ORIGIN_TRANSFORMS::NOT_A_COORD, true, m_boundCtrls );
AddXYPointToSizer( *aParent, *m_gbsArcBySME, 0, 0, _( "Start Point" ), false, m_boundCtrls);
AddXYPointToSizer( *aParent, *m_gbsArcBySME, 0, 3, _( "Mid Point" ), false, m_boundCtrls);
AddXYPointToSizer( *aParent, *m_gbsArcBySME, 3, 0, _( "End Point" ), false, m_boundCtrls);
AddXYPointToSizer( *aParent, *m_gbsArcBySME, 0, 0, _( "Start Point" ), false, m_boundCtrls );
AddXYPointToSizer( *aParent, *m_gbsArcBySME, 0, 3, _( "Mid Point" ), false, m_boundCtrls );
AddXYPointToSizer( *aParent, *m_gbsArcBySME, 3, 0, _( "End Point" ), false, m_boundCtrls );
m_geomSync = std::make_unique<ARC_GEOM_SYNCER>( m_workingCopy, m_boundCtrls );
@ -929,8 +927,8 @@ DIALOG_SHAPE_PROPERTIES::DIALOG_SHAPE_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent,
AddXYPointToSizer( *aParent, *m_gbsCircleCenterRadius, 0, 0, _( "Center" ), false, m_boundCtrls);
AddFieldToSizer( *aParent, *m_gbsCircleCenterRadius, 3, 0, _( "Radius" ), ORIGIN_TRANSFORMS::NOT_A_COORD, false, m_boundCtrls );
AddXYPointToSizer( *aParent, *m_gbsCircleCenterPoint, 0, 0, _( "Center" ), false, m_boundCtrls);
AddXYPointToSizer( *aParent, *m_gbsCircleCenterPoint, 0, 3, _( "Point on Circle" ), false, m_boundCtrls);
AddXYPointToSizer( *aParent, *m_gbsCircleCenterPoint, 0, 0, _( "Center" ), false, m_boundCtrls );
AddXYPointToSizer( *aParent, *m_gbsCircleCenterPoint, 0, 3, _( "Point on Circle" ), false, m_boundCtrls );
m_geomSync = std::make_unique<CIRCLE_GEOM_SYNCER>( m_workingCopy, m_boundCtrls );
@ -939,10 +937,10 @@ DIALOG_SHAPE_PROPERTIES::DIALOG_SHAPE_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent,
break;
case SHAPE_T::BEZIER:
AddXYPointToSizer( *aParent, *m_gbsBezier, 0, 0, _( "Start Point" ), false, m_boundCtrls);
AddXYPointToSizer( *aParent, *m_gbsBezier, 0, 3, _( "End Point" ), false, m_boundCtrls);
AddXYPointToSizer( *aParent, *m_gbsBezier, 3, 0, _( "Control Point 1" ), false, m_boundCtrls);
AddXYPointToSizer( *aParent, *m_gbsBezier, 3, 3, _( "Control Point 2" ), false, m_boundCtrls);
AddXYPointToSizer( *aParent, *m_gbsBezier, 0, 0, _( "Start Point" ), false, m_boundCtrls );
AddXYPointToSizer( *aParent, *m_gbsBezier, 0, 3, _( "End Point" ), false, m_boundCtrls );
AddXYPointToSizer( *aParent, *m_gbsBezier, 3, 0, _( "Control Point 1" ), false, m_boundCtrls );
AddXYPointToSizer( *aParent, *m_gbsBezier, 3, 3, _( "Control Point 2" ), false, m_boundCtrls );
m_geomSync = std::make_unique<BEZIER_GEOM_SYNCER>( m_workingCopy, m_boundCtrls );
@ -960,20 +958,22 @@ DIALOG_SHAPE_PROPERTIES::DIALOG_SHAPE_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent,
}
// Remove any tabs not used (Hide() doesn't work on Windows)
for( int i = m_notebookShapeDefs->GetPageCount() - 1; i >= 0; --i )
for( int i = (int) m_notebookShapeDefs->GetPageCount() - 1; i >= 0; --i )
{
if( shownPages.count( i ) == 0 )
m_notebookShapeDefs->RemovePage( i );
}
// Used the last saved tab if any
if( s_lastTabForShape.count( m_item->GetShape() ) > 0 )
if( s_lastTabForShape.count( m_item->GetShape() ) > 0
&& s_lastTabForShape[m_item->GetShape()] < (int) m_notebookShapeDefs->GetPageCount() )
{
m_notebookShapeDefs->SetSelection( s_lastTabForShape[m_item->GetShape()] );
}
// Find the first control in the shown tab
wxWindow* tabPanel = m_notebookShapeDefs->GetCurrentPage();
for( size_t i = 0; i < m_boundCtrls.size(); ++i )
{
if( m_boundCtrls[i].m_Ctrl->IsDescendant( tabPanel ) )
@ -1064,30 +1064,6 @@ void DIALOG_SHAPE_PROPERTIES::onLayerSelection( wxCommandEvent& event )
}
void DIALOG_SHAPE_PROPERTIES::onFilledCheckbox( wxCommandEvent& event )
{
if( m_filledCtrl->GetValue() )
{
m_lineStyleCombo->SetSelection( 0 );
m_lineStyleLabel->Enable( false );
m_lineStyleCombo->Enable( false );
}
else
{
LINE_STYLE style = m_item->GetStroke().GetLineStyle();
if( style == LINE_STYLE::DEFAULT )
style = LINE_STYLE::SOLID;
if( (int) style < (int) lineTypeNames.size() )
m_lineStyleCombo->SetSelection( (int) style );
m_lineStyleLabel->Enable( true );
m_lineStyleCombo->Enable( true );
}
}
void DIALOG_SHAPE_PROPERTIES::onTechLayersChanged( wxCommandEvent& event )
{
enableTechLayers();

2
pcbnew/dialogs/dialog_shape_properties_base.cpp

@ -300,7 +300,6 @@ DIALOG_SHAPE_PROPERTIES_BASE::DIALOG_SHAPE_PROPERTIES_BASE( wxWindow* parent, wx
bMainSizer->Fit( this );
// Connect Events
m_filledCtrl->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SHAPE_PROPERTIES_BASE::onFilledCheckbox ), NULL, this );
m_LayerSelectionCtrl->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_SHAPE_PROPERTIES_BASE::onLayerSelection ), NULL, this );
m_hasSolderMask->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SHAPE_PROPERTIES_BASE::onTechLayersChanged ), NULL, this );
}
@ -308,7 +307,6 @@ DIALOG_SHAPE_PROPERTIES_BASE::DIALOG_SHAPE_PROPERTIES_BASE( wxWindow* parent, wx
DIALOG_SHAPE_PROPERTIES_BASE::~DIALOG_SHAPE_PROPERTIES_BASE()
{
// Disconnect Events
m_filledCtrl->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SHAPE_PROPERTIES_BASE::onFilledCheckbox ), NULL, this );
m_LayerSelectionCtrl->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_SHAPE_PROPERTIES_BASE::onLayerSelection ), NULL, this );
m_hasSolderMask->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SHAPE_PROPERTIES_BASE::onTechLayersChanged ), NULL, this );

1
pcbnew/dialogs/dialog_shape_properties_base.fbp

@ -1173,7 +1173,6 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnCheckBox">onFilledCheckbox</event>
</object>
</object>
<object class="gbsizeritem" expanded="false">

1
pcbnew/dialogs/dialog_shape_properties_base.h

@ -88,7 +88,6 @@ class DIALOG_SHAPE_PROPERTIES_BASE : public DIALOG_SHIM
wxButton* m_StandardButtonsSizerCancel;
// Virtual event handlers, override them in your derived class
virtual void onFilledCheckbox( wxCommandEvent& event ) { event.Skip(); }
virtual void onLayerSelection( wxCommandEvent& event ) { event.Skip(); }
virtual void onTechLayersChanged( wxCommandEvent& event ) { event.Skip(); }

73
pcbnew/pcb_painter.cpp

@ -1796,10 +1796,14 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
int thickness = getLineThickness( aShape->GetWidth() );
LINE_STYLE lineStyle = aShape->GetStroke().GetLineStyle();
if( lineStyle == LINE_STYLE::DEFAULT )
lineStyle = LINE_STYLE::SOLID;
if( IsSolderMaskLayer( aLayer )
&& aShape->HasSolderMask()
&& IsExternalCopperLayer( aShape->GetLayer() ) )
&& aShape->HasSolderMask()
&& IsExternalCopperLayer( aShape->GetLayer() ) )
{
lineStyle = LINE_STYLE::SOLID;
thickness += aShape->GetSolderMaskExpansion() * 2;
}
@ -1815,7 +1819,7 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
if( aShape->GetNetCode() <= NETINFO_LIST::UNCONNECTED )
return;
wxString netname = aShape->GetDisplayNetname();
const wxString& netname = aShape->GetDisplayNetname();
if( netname.IsEmpty() )
return;
@ -1836,6 +1840,10 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
{
color = m_pcbSettings.GetColor( aShape, aLayer );
thickness = thickness + m_lockedShadowMargin;
// Note: on LAYER_LOCKED_ITEM_SHADOW always draw shadow shapes as continuous lines
// otherwise the look is very strange and ugly
lineStyle = LINE_STYLE::SOLID;
}
if( outline_mode )
@ -1848,9 +1856,7 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
m_gal->SetFillColor( color );
m_gal->SetStrokeColor( color );
// Note: on LAYER_LOCKED_ITEM_SHADOW always draw shadow shapes as continuous lines
// otherwise the look is very strange and ugly
if( lineStyle <= LINE_STYLE::FIRST_TYPE || aLayer == LAYER_LOCKED_ITEM_SHADOW )
if( lineStyle == LINE_STYLE::SOLID || aShape->IsFilled() )
{
switch( aShape->GetShape() )
{
@ -1880,7 +1886,7 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
{
m_gal->DrawSegment( aShape->GetStart(), aShape->GetEnd(), thickness );
}
else
else if( lineStyle == LINE_STYLE::SOLID )
{
m_gal->SetIsFill( true );
m_gal->SetIsStroke( false );
@ -1916,7 +1922,7 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
m_gal->SetIsFill( true );
m_gal->SetIsStroke( false );
if( thickness > 0 )
if( lineStyle == LINE_STYLE::SOLID && thickness > 0 )
{
m_gal->DrawSegment( pts[0], pts[1], thickness );
m_gal->DrawSegment( pts[1], pts[2], thickness );
@ -1956,7 +1962,7 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
m_gal->DrawArcSegment( aShape->GetCenter(), aShape->GetRadius(), startAngle,
endAngle - startAngle, thickness, m_maxError );
}
else
else if( lineStyle == LINE_STYLE::SOLID )
{
m_gal->SetIsFill( true );
m_gal->SetIsStroke( false );
@ -1976,18 +1982,25 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
else
{
m_gal->SetIsFill( aShape->IsFilled() );
m_gal->SetIsStroke( thickness > 0 );
m_gal->SetIsStroke( lineStyle == LINE_STYLE::SOLID && thickness > 0 );
m_gal->SetLineWidth( thickness );
int radius = aShape->GetRadius();
if( thickness < 0 )
if( lineStyle == LINE_STYLE::SOLID && thickness > 0 )
{
radius += thickness / 2;
radius = std::max( radius, 0 );
m_gal->DrawCircle( aShape->GetStart(), radius );
}
else if( aShape->IsFilled() )
{
if( thickness < 0 )
{
radius += thickness / 2;
radius = std::max( radius, 0 );
}
m_gal->DrawCircle( aShape->GetStart(), radius );
m_gal->DrawCircle( aShape->GetStart(), radius );
}
}
break;
@ -2008,7 +2021,7 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
m_gal->SetIsFill( true );
m_gal->SetIsStroke( false );
if( thickness > 0 )
if( lineStyle == LINE_STYLE::SOLID && thickness > 0 )
{
for( int ii = 0; ii < shape.OutlineCount(); ++ii )
m_gal->DrawSegmentChain( shape.Outline( ii ), thickness );
@ -2016,25 +2029,24 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
if( aShape->IsFilled() )
{
// On Opengl, a not convex filled polygon is usually drawn by using triangles
// as primitives. CacheTriangulation() can create basic triangle primitives to
// draw the polygon solid shape on Opengl. GLU tessellation is much slower,
// so currently we are using our tessellation.
if( m_gal->IsOpenGlEngine() && !shape.IsTriangulationUpToDate() )
shape.CacheTriangulation( true, true );
if( thickness >= 0 )
{
m_gal->DrawPolygon( shape );
}
else
if( thickness < 0 )
{
SHAPE_POLY_SET deflated_shape = shape;
deflated_shape.Inflate( thickness / 2, CORNER_STRATEGY::ROUND_ALL_CORNERS,
m_maxError );
m_gal->DrawPolygon( deflated_shape );
}
else
{
// On Opengl, a not convex filled polygon is usually drawn by using
// triangles as primitives. CacheTriangulation() can create basic triangle
// primitives to draw the polygon solid shape on Opengl. GLU tessellation
// is much slower, so currently we are using our tessellation.
if( m_gal->IsOpenGlEngine() && !shape.IsTriangulationUpToDate() )
shape.CacheTriangulation( true, true );
m_gal->DrawPolygon( shape );
}
}
}
@ -2060,7 +2072,7 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
else
{
m_gal->SetIsFill( aShape->IsFilled() );
m_gal->SetIsStroke( thickness > 0 );
m_gal->SetIsStroke( lineStyle == LINE_STYLE::SOLID && thickness > 0 );
m_gal->SetLineWidth( thickness );
if( aShape->GetBezierPoints().size() > 2 )
@ -2082,7 +2094,8 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
break;
}
}
else
if( lineStyle != LINE_STYLE::SOLID )
{
if( !outline_mode )
{

Loading…
Cancel
Save