Properties for SCH_LINE

Also rename an incongruous setter
This commit is contained in:
Jon Evans 2023-06-24 20:08:42 -04:00
parent 1c1849ec1a
commit bf2e9f8261
6 changed files with 42 additions and 6 deletions

View File

@ -1615,8 +1615,8 @@ void EDA_SHAPE::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance
}
ENUM_TO_WXANY( SHAPE_T )
ENUM_TO_WXANY( PLOT_DASH_TYPE )
IMPLEMENT_ENUM_TO_WXANY( SHAPE_T )
IMPLEMENT_ENUM_TO_WXANY( PLOT_DASH_TYPE )
static struct EDA_SHAPE_DESC

View File

@ -1853,5 +1853,7 @@ static struct SCH_LABEL_DESC
propMgr.InheritsAfter( TYPE_HASH( SCH_HIERLABEL ), TYPE_HASH( SCH_LABEL_BASE ) );
propMgr.InheritsAfter( TYPE_HASH( SCH_GLOBALLABEL ), TYPE_HASH( SCH_LABEL_BASE ) );
propMgr.InheritsAfter( TYPE_HASH( SCH_DIRECTIVE_LABEL ), TYPE_HASH( SCH_LABEL_BASE ) );
propMgr.Mask( TYPE_HASH( SCH_LABEL_BASE ), TYPE_HASH( EDA_TEXT ), _HKI( "Hyperlink" ) );
}
} _SCH_LABEL_DESC;

View File

@ -90,6 +90,17 @@ SCH_LINE::SCH_LINE( const SCH_LINE& aLine ) :
}
wxString SCH_LINE::GetFriendlyName() const
{
switch( GetLayer() )
{
case LAYER_WIRE: return _( "Wire" );
case LAYER_BUS: return _( "Bus" );
default: return _( "Graphic Line" );
}
}
wxString SCH_LINE::GetNetname( const SCH_SHEET_PATH& aSheet )
{
std::list<const SCH_LINE *> checkedLines;
@ -981,8 +992,24 @@ static struct SCH_LINE_DESC
{
SCH_LINE_DESC()
{
ENUM_MAP<PLOT_DASH_TYPE>::Instance()
.Map( PLOT_DASH_TYPE::DEFAULT, _HKI( "Default" ) )
.Map( PLOT_DASH_TYPE::SOLID, _HKI( "Solid" ) )
.Map( PLOT_DASH_TYPE::DASH, _HKI( "Dashed" ) )
.Map( PLOT_DASH_TYPE::DOT, _HKI( "Dotted" ) )
.Map( PLOT_DASH_TYPE::DASHDOT, _HKI( "Dash-Dot" ) )
.Map( PLOT_DASH_TYPE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
REGISTER_TYPE( SCH_LINE );
propMgr.InheritsAfter( TYPE_HASH( SCH_LINE ), TYPE_HASH( SCH_ITEM ) );
void ( SCH_LINE::*lineStyleSetter )( PLOT_DASH_TYPE ) = &SCH_LINE::SetLineStyle;
propMgr.AddProperty( new PROPERTY_ENUM<SCH_LINE, PLOT_DASH_TYPE>( _HKI( "Line Style" ),
lineStyleSetter, &SCH_LINE::GetLineStyle ) );
propMgr.AddProperty( new PROPERTY<SCH_LINE, int>( _HKI( "Line Width" ),
&SCH_LINE::SetLineWidth, &SCH_LINE::GetLineWidth ) );
}
} _SCH_LINE_DESC;

View File

@ -61,6 +61,8 @@ public:
return wxT( "SCH_LINE" );
}
wxString GetFriendlyName() const override;
/**
* @brief This function travel though all the connected wire segments
* to look for connected labels.
@ -172,6 +174,7 @@ public:
COLOR4D GetLineColor() const;
void SetLineWidth( const int aSize );
int GetLineWidth() const { return m_stroke.GetWidth(); }
virtual bool HasLineStroke() const override { return true; }
virtual STROKE_PARAMS GetStroke() const override { return m_stroke; }
@ -193,8 +196,6 @@ public:
|| ( style_a == PLOT_DASH_TYPE::SOLID && style_b == PLOT_DASH_TYPE::DEFAULT );
}
int GetLineSize() const { return m_stroke.GetWidth(); }
void ViewGetLayers( int aLayers[], int& aCount ) const override;
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;

View File

@ -1928,8 +1928,8 @@ void SCH_LEGACY_PLUGIN::saveLine( SCH_LINE* aLine )
// Write line style (width, type, color) only for non default values
if( aLine->IsGraphicLine() )
{
if( aLine->GetLineSize() != 0 )
m_out->Print( 0, " %s %d", T_WIDTH, schIUScale.IUToMils( aLine->GetLineSize() ) );
if( aLine->GetLineWidth() != 0 )
m_out->Print( 0, " %s %d", T_WIDTH, schIUScale.IUToMils( aLine->GetLineWidth() ) );
m_out->Print( 0, " %s %s", T_STYLE,
TO_UTF8( STROKE_PARAMS::GetLineStyleToken( aLine->GetLineStyle() ) ) );

View File

@ -28,6 +28,7 @@
#include <trigo.h>
#include <geometry/shape_poly_set.h>
#include <geometry/geometry_utils.h>
#include <properties/property.h>
#include <stroke_params.h>
class LINE_READER;
@ -378,4 +379,9 @@ protected:
bool m_annotationProxy; // A shape storing the position of an annotation
};
#ifndef SWIG
DECLARE_ENUM_TO_WXANY( SHAPE_T );
DECLARE_ENUM_TO_WXANY( PLOT_DASH_TYPE );
#endif
#endif // EDA_SHAPE_H