Fix "Properties" not appearing in right click menu for graphic line.

This commit is contained in:
Mark Roszko 2019-12-26 15:15:34 +00:00 committed by Jon Evans
parent d4dee3c5a0
commit d3edeaec50
4 changed files with 31 additions and 10 deletions

View File

@ -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() );

View File

@ -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 <DANGLING_END_ITEM>& 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<DANGLING_END_ITEM>& 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 );
}

View File

@ -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;
};

View File

@ -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<EDA_ITEM*>( aSel.Front() )->Type() )
auto item = static_cast<EDA_ITEM*>( 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<SCH_LINE*>( 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<SCH_LINE*>( 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 );