Constrain SHEET_PIN movement, and keep them attached when resizing SHEET.

Fixes: lp:1829314
* https://bugs.launchpad.net/kicad/+bug/1829314
This commit is contained in:
Jeff Young 2019-05-16 22:27:03 +01:00
parent 48fb78418c
commit 6630a7227d
4 changed files with 46 additions and 8 deletions

View File

@ -482,6 +482,24 @@ void EE_POINT_EDITOR::updateItem() const
sheet->SetPosition( (wxPoint) topLeft );
sheet->SetSize( wxSize( botRight.x - topLeft.x, botRight.y - topLeft.y ) );
// Keep sheet pins attached to edges:
for( SCH_SHEET_PIN& pin : sheet->GetPins() )
{
wxPoint pos = pin.GetPosition();
switch( pin.GetEdge() )
{
case SCH_SHEET_PIN::SHEET_LEFT_SIDE: pos.x = topLeft.x; break;
case SCH_SHEET_PIN::SHEET_RIGHT_SIDE: pos.x = topRight.x; break;
case SCH_SHEET_PIN::SHEET_TOP_SIDE: pos.y = topLeft.y; break;
case SCH_SHEET_PIN::SHEET_BOTTOM_SIDE: pos.y = botLeft.y; break;
case SCH_SHEET_PIN::SHEET_UNDEFINED_SIDE: break;
}
pin.SetPosition( pos );
}
break;
}

View File

@ -658,7 +658,7 @@ int SCH_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType )
item = m_frame->CreateNewText( LAYER_NOTES );
break;
case SCH_SHEET_PIN_T:
item = m_selectionTool->SelectPoint( cursorPos, EE_COLLECTOR::SheetsAndSheetLabels );
item = m_selectionTool->SelectPoint( cursorPos, EE_COLLECTOR::SheetsOnly );
if( item )
{
@ -667,6 +667,15 @@ int SCH_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType )
else
item = m_frame->CreateSheetPin( (SCH_SHEET*) item );
}
else
{
m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
m_statusPopup->SetTextColor( wxColour( 255, 0, 0 ) );
m_statusPopup->SetText( _( "Click over a sheet to create a sheet pin" ) );
m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
m_statusPopup->Popup();
m_statusPopup->Expire( 1500 );
}
break;
default:
wxFAIL_MSG( "doTwoClickPlace(): unknown type" );

View File

@ -26,7 +26,7 @@
#include <tools/ee_tool_base.h>
#include <sch_base_frame.h>
#include <status_popup.h>
class SCH_COMPONENT;
class SCH_BUS_WIRE_ENTRY;
@ -82,6 +82,9 @@ private:
///> Sets up handlers for various events.
void setTransitions() override;
private:
std::unique_ptr<STATUS_TEXT_POPUP> m_statusPopup;
};
#endif /* SCH_DRAWING_TOOLS_H */

View File

@ -399,16 +399,12 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
selection.ClearReferencePoint();
for( auto item : selection )
for( EDA_ITEM* item : selection )
item->ClearEditFlags();
if( unselect )
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
else
m_selectionTool->RemoveItemsFromSel( &dragAdditions, QUIET_MODE );
if( restore_state )
{
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
m_frame->RollbackSchematicFromUndo();
}
else
@ -416,6 +412,12 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
addJunctionsIfNeeded( selection );
m_frame->SchematicCleanUp();
m_frame->TestDanglingEnds();
if( unselect )
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
else
m_selectionTool->RemoveItemsFromSel( &dragAdditions, QUIET_MODE );
m_frame->OnModify();
}
@ -594,6 +596,12 @@ void SCH_MOVE_TOOL::moveItem( EDA_ITEM* aItem, VECTOR2I aDelta, bool isDrag )
static_cast<SCH_ITEM*>( aItem )->Move( transformedDelta );
break;
}
case SCH_SHEET_PIN_T:
{
SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) aItem;
pin->ConstrainOnEdge( pin->GetPosition() + (wxPoint) aDelta );
break;
}
default:
static_cast<SCH_ITEM*>( aItem )->Move( (wxPoint) aDelta );
break;