mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 00:21:25 +00:00
Fixup fill versions.
Older versions saved some non-symbol shapes with wrong fill mode. The property inspector also sets the wrong fill mode. Fixes https://gitlab.com/kicad/code/kicad/-/issues/19254
This commit is contained in:
parent
a7aea56a74
commit
f1cbcc83fe
common
eeschema
include
@ -2347,17 +2347,9 @@ static struct EDA_SHAPE_DESC
|
||||
shapeProps )
|
||||
.SetAvailableFunc( fillAvailable );
|
||||
|
||||
auto fillColor = new PROPERTY<EDA_SHAPE, COLOR4D>( _HKI( "Fill Color" ),
|
||||
&EDA_SHAPE::SetFillColor, &EDA_SHAPE::GetFillColor );
|
||||
fillColor->SetWriteableFunc(
|
||||
[=]( INSPECTABLE* aItem ) -> bool
|
||||
{
|
||||
if( EDA_SHAPE* edaShape = dynamic_cast<EDA_SHAPE*>( aItem ) )
|
||||
return edaShape->GetFillMode() == FILL_T::FILLED_WITH_COLOR;
|
||||
|
||||
return true;
|
||||
} );
|
||||
propMgr.AddProperty( fillColor, shapeProps )
|
||||
propMgr.AddProperty( new PROPERTY<EDA_SHAPE, COLOR4D>( _HKI( "Fill Color" ),
|
||||
&EDA_SHAPE::SetFillColor, &EDA_SHAPE::GetFillColor ),
|
||||
shapeProps )
|
||||
.SetAvailableFunc( fillAvailable )
|
||||
.SetIsHiddenFromRulesEditor();
|
||||
}
|
||||
|
@ -3790,6 +3790,16 @@ SCH_BUS_WIRE_ENTRY* SCH_IO_KICAD_SEXPR_PARSER::parseBusEntry()
|
||||
}
|
||||
|
||||
|
||||
void fixupSchFillMode( SCH_SHAPE* aShape )
|
||||
{
|
||||
if( aShape->GetFillMode() == FILL_T::FILLED_SHAPE )
|
||||
{
|
||||
aShape->SetFillColor( aShape->GetStroke().GetColor() );
|
||||
aShape->SetFillMode( FILL_T::FILLED_WITH_COLOR );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SCH_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseSchPolyLine()
|
||||
{
|
||||
T token;
|
||||
@ -3838,6 +3848,7 @@ SCH_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseSchPolyLine()
|
||||
parseFill( fill );
|
||||
polyline->SetFillMode( fill.m_FillType );
|
||||
polyline->SetFillColor( fill.m_Color );
|
||||
fixupSchFillMode( polyline.get() );
|
||||
break;
|
||||
|
||||
case T_uuid:
|
||||
@ -3970,6 +3981,7 @@ SCH_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseSchArc()
|
||||
parseFill( fill );
|
||||
arc->SetFillMode( fill.m_FillType );
|
||||
arc->SetFillColor( fill.m_Color );
|
||||
fixupSchFillMode( arc.get() );
|
||||
break;
|
||||
|
||||
case T_uuid:
|
||||
@ -4029,6 +4041,7 @@ SCH_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseSchCircle()
|
||||
parseFill( fill );
|
||||
circle->SetFillMode( fill.m_FillType );
|
||||
circle->SetFillColor( fill.m_Color );
|
||||
fixupSchFillMode( circle.get() );
|
||||
break;
|
||||
|
||||
case T_uuid:
|
||||
@ -4087,6 +4100,7 @@ SCH_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseSchRectangle()
|
||||
parseFill( fill );
|
||||
rectangle->SetFillMode( fill.m_FillType );
|
||||
rectangle->SetFillColor( fill.m_Color );
|
||||
fixupSchFillMode( rectangle.get() );
|
||||
break;
|
||||
|
||||
case T_uuid:
|
||||
@ -4203,6 +4217,7 @@ SCH_SHAPE* SCH_IO_KICAD_SEXPR_PARSER::parseSchBezier()
|
||||
parseFill( fill );
|
||||
bezier->SetFillMode( fill.m_FillType );
|
||||
bezier->SetFillColor( fill.m_Color );
|
||||
fixupSchFillMode( bezier.get() );
|
||||
break;
|
||||
|
||||
case T_uuid:
|
||||
@ -4501,6 +4516,7 @@ void SCH_IO_KICAD_SEXPR_PARSER::parseSchTextBoxContent( SCH_TEXTBOX* aTextBox )
|
||||
parseFill( fill );
|
||||
aTextBox->SetFillMode( fill.m_FillType );
|
||||
aTextBox->SetFillColor( fill.m_Color );
|
||||
fixupSchFillMode( aTextBox );
|
||||
break;
|
||||
|
||||
case T_margins:
|
||||
|
@ -66,6 +66,17 @@ void SCH_SHAPE::SetStroke( const STROKE_PARAMS& aStroke )
|
||||
}
|
||||
|
||||
|
||||
void SCH_SHAPE::SetFilled( bool aFilled )
|
||||
{
|
||||
if( !aFilled )
|
||||
m_fill = FILL_T::NO_FILL;
|
||||
else if( GetParentSymbol() )
|
||||
m_fill = FILL_T::FILLED_SHAPE;
|
||||
else
|
||||
m_fill = FILL_T::FILLED_WITH_COLOR;
|
||||
}
|
||||
|
||||
|
||||
void SCH_SHAPE::Move( const VECTOR2I& aOffset )
|
||||
{
|
||||
move( aOffset );
|
||||
@ -685,6 +696,20 @@ static struct SCH_SHAPE_DESC
|
||||
return false;
|
||||
};
|
||||
|
||||
auto isFillColorEditable =
|
||||
[]( INSPECTABLE* aItem ) -> bool
|
||||
{
|
||||
if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
|
||||
{
|
||||
if( shape->GetParentSymbol() )
|
||||
return shape->GetFillMode() == FILL_T::FILLED_WITH_COLOR;
|
||||
else
|
||||
return shape->IsFilled();
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
propMgr.OverrideAvailability( TYPE_HASH( SCH_SHAPE ), TYPE_HASH( SCH_ITEM ),
|
||||
_HKI( "Position X" ), isPolygon );
|
||||
propMgr.OverrideAvailability( TYPE_HASH( SCH_SHAPE ), TYPE_HASH( SCH_ITEM ),
|
||||
@ -693,6 +718,9 @@ static struct SCH_SHAPE_DESC
|
||||
propMgr.OverrideAvailability( TYPE_HASH( SCH_SHAPE ), TYPE_HASH( EDA_SHAPE ),
|
||||
_HKI( "Filled" ), isSchematicItem );
|
||||
|
||||
propMgr.OverrideWriteability( TYPE_HASH( SCH_SHAPE ), TYPE_HASH( EDA_SHAPE ),
|
||||
_HKI( "Fill Color" ), isFillColorEditable );
|
||||
|
||||
void ( SCH_SHAPE::*fillModeSetter )( FILL_T ) = &SCH_SHAPE::SetFillMode;
|
||||
FILL_T ( SCH_SHAPE::*fillModeGetter )() const = &SCH_SHAPE::GetFillMode;
|
||||
|
||||
|
@ -65,6 +65,8 @@ public:
|
||||
return m_stroke.GetLineStyle();
|
||||
}
|
||||
|
||||
void SetFilled( bool aFilled ) override;
|
||||
|
||||
const BOX2I GetBoundingBox() const override;
|
||||
|
||||
VECTOR2I GetPosition() const override { return getPosition(); }
|
||||
|
@ -105,7 +105,7 @@ public:
|
||||
return IsFilled();
|
||||
}
|
||||
|
||||
void SetFilled( bool aFlag )
|
||||
virtual void SetFilled( bool aFlag )
|
||||
{
|
||||
setFilled( aFlag );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user