diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index 6bfdac599b..98f69fd113 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -2216,7 +2216,7 @@ void SCH_LEGACY_PLUGIN::saveLine( SCH_LINE* aLine ) m_out->Print( 0, "Wire %s %s", layer, width ); // Write line style (width, type, color) only for non default values - if( aLine->GetLayer() == LAYER_NOTES ) + if( aLine->IsGraphicLine() ) { if( aLine->GetPenSize() != aLine->GetDefaultWidth() ) m_out->Print( 0, " %s %d", T_WIDTH, aLine->GetLineSize() ); diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 75416a7e08..8591a7defa 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -270,7 +270,7 @@ COLOR4D SCH_LINE::GetLineColor() const int SCH_LINE::GetDefaultStyle() const { - if( m_Layer == LAYER_NOTES ) + if( IsGraphicLine() ) return PLOTDASHTYPE_DASH; return PLOTDASHTYPE_SOLID; @@ -520,7 +520,7 @@ SCH_LINE* SCH_LINE::MergeOverlap( SCH_LINE* aLine ) void SCH_LINE::GetEndPoints( std::vector & aItemList ) { - if( GetLayer() == LAYER_NOTES ) + if( IsGraphicLine() ) return; if( ( GetLayer() == LAYER_BUS ) || ( GetLayer() == LAYER_WIRE ) ) @@ -565,7 +565,7 @@ bool SCH_LINE::UpdateDanglingState( std::vector& aItemList ) break; } } - else if( GetLayer() == LAYER_BUS || GetLayer() == LAYER_NOTES ) + else if( GetLayer() == LAYER_BUS || IsGraphicLine() ) { // Lines on the notes layer and the bus layer cannot be tested for dangling ends. previousStartState = previousEndState = m_startIsDangling = m_endIsDangling = false; @@ -663,7 +663,7 @@ void SCH_LINE::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) { // Net list item not required for graphic lines. - if( (GetLayer() != LAYER_BUS) && (GetLayer() != LAYER_WIRE) ) + if( IsGraphicLine() ) return; NETLIST_OBJECT* item = new NETLIST_OBJECT(); @@ -813,3 +813,8 @@ void SCH_LINE::GetMsgPanelInfo( EDA_UNITS aUnits, MSG_PANEL_ITEMS& aList ) } } + +bool SCH_LINE::IsGraphicLine() const +{ + return ( GetLayer() == LAYER_NOTES ); +} \ No newline at end of file diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index c762afe991..190d11e53a 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -219,6 +219,13 @@ public: void Show( int nestLevel, std::ostream& os ) const override; #endif + /** + * Returns if the line is a graphic (non electrical line) + * + * Currently, anything on the internal NOTES layer is a graphic line + */ + bool IsGraphicLine() const; + private: bool doIsConnected( const wxPoint& aPosition ) const override; }; diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index c6a76a3b7f..b47638d29b 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -175,21 +175,30 @@ bool SCH_EDIT_TOOL::Init() } }; - auto propertiesCondition = [] ( const SELECTION& aSel ) { + auto propertiesCondition = []( const SELECTION& aSel ) { if( aSel.GetSize() != 1 ) return false; - switch( static_cast( aSel.Front() )->Type() ) + auto item = static_cast( aSel.Front() ); + switch( item->Type() ) { case SCH_MARKER_T: case SCH_JUNCTION_T: case SCH_NO_CONNECT_T: case SCH_BUS_WIRE_ENTRY_T: case SCH_BUS_BUS_ENTRY_T: - case SCH_LINE_T: case SCH_SHEET_PIN_T: case SCH_PIN_T: return false; + case SCH_LINE_T: + { + SCH_LINE* line = static_cast( item ); + + assert( line != nullptr ); + + // Only graphic lines support properties in the file format + return line->IsGraphicLine(); + } default: return true; } @@ -1282,10 +1291,10 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) case SCH_LINE_T: { - SCH_LINE* line = (SCH_LINE*) item; + SCH_LINE* line = static_cast( item ); // We purposely disallow editing everything except graphic lines - if( line->GetLayer() != LAYER_NOTES ) + if( !line->IsGraphicLine() ) break; DIALOG_EDIT_LINE_STYLE dlg( m_frame, line );