Implement proper dangling end handling for block moves.
(Most of this is actually fixing the IsDanglingStateChanged() to correctly indicate that it *updates* the dangling state, not just tests it.)
This commit is contained in:
parent
b445b0fab2
commit
4030eec939
|
@ -254,6 +254,21 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
||||||
nextcmd = true;
|
nextcmd = true;
|
||||||
block->SetState( STATE_BLOCK_MOVE );
|
block->SetState( STATE_BLOCK_MOVE );
|
||||||
|
|
||||||
|
// Mark dangling pins at the edges of the block:
|
||||||
|
std::vector<DANGLING_END_ITEM> internalPoints;
|
||||||
|
|
||||||
|
for( unsigned i = 0; i < block->GetCount(); ++i )
|
||||||
|
{
|
||||||
|
auto item = static_cast<SCH_ITEM*>( block->GetItem( i ) );
|
||||||
|
item->GetEndPoints( internalPoints );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( unsigned i = 0; i < block->GetCount(); ++i )
|
||||||
|
{
|
||||||
|
auto item = static_cast<SCH_ITEM*>( block->GetItem( i ) );
|
||||||
|
item->UpdateDanglingState( internalPoints );
|
||||||
|
}
|
||||||
|
|
||||||
m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines );
|
m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines );
|
||||||
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
|
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,7 +278,7 @@ bool SCH_EDIT_FRAME::TestDanglingEnds()
|
||||||
|
|
||||||
for( SCH_ITEM* item = GetScreen()->GetDrawList().begin(); item; item = item->Next() )
|
for( SCH_ITEM* item = GetScreen()->GetDrawList().begin(); item; item = item->Next() )
|
||||||
{
|
{
|
||||||
if( item->IsDanglingStateChanged( endPoints ) )
|
if( item->UpdateDanglingState( endPoints ) )
|
||||||
{
|
{
|
||||||
GetCanvas()->GetView()->Update( item, KIGFX::REPAINT );
|
GetCanvas()->GetView()->Update( item, KIGFX::REPAINT );
|
||||||
hasStateChanged = true;
|
hasStateChanged = true;
|
||||||
|
|
|
@ -209,7 +209,7 @@ void SCH_BUS_ENTRY_BASE::Rotate( wxPoint aPosition )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SCH_BUS_WIRE_ENTRY::IsDanglingStateChanged( std::vector<DANGLING_END_ITEM>& aItemList )
|
bool SCH_BUS_WIRE_ENTRY::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList )
|
||||||
{
|
{
|
||||||
bool previousStateStart = m_isDanglingStart;
|
bool previousStateStart = m_isDanglingStart;
|
||||||
bool previousStateEnd = m_isDanglingEnd;
|
bool previousStateEnd = m_isDanglingEnd;
|
||||||
|
@ -275,7 +275,7 @@ bool SCH_BUS_WIRE_ENTRY::IsDanglingStateChanged( std::vector<DANGLING_END_ITEM>&
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SCH_BUS_BUS_ENTRY::IsDanglingStateChanged( std::vector<DANGLING_END_ITEM>& aItemList )
|
bool SCH_BUS_BUS_ENTRY::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList )
|
||||||
{
|
{
|
||||||
bool previousStateStart = m_isDanglingStart;
|
bool previousStateStart = m_isDanglingStart;
|
||||||
bool previousStateEnd = m_isDanglingEnd;
|
bool previousStateEnd = m_isDanglingEnd;
|
||||||
|
|
|
@ -159,7 +159,7 @@ public:
|
||||||
|
|
||||||
BITMAP_DEF GetMenuImage() const override;
|
BITMAP_DEF GetMenuImage() const override;
|
||||||
|
|
||||||
bool IsDanglingStateChanged( std::vector<DANGLING_END_ITEM>& aItemList ) override;
|
bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -192,7 +192,7 @@ public:
|
||||||
|
|
||||||
BITMAP_DEF GetMenuImage() const override;
|
BITMAP_DEF GetMenuImage() const override;
|
||||||
|
|
||||||
bool IsDanglingStateChanged( std::vector<DANGLING_END_ITEM>& aItemList ) override;
|
bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList ) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _SCH_BUS_ENTRY_H_
|
#endif // _SCH_BUS_ENTRY_H_
|
||||||
|
|
|
@ -1594,7 +1594,7 @@ void SCH_COMPONENT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SCH_COMPONENT::IsDanglingStateChanged( std::vector<DANGLING_END_ITEM>& aItemList )
|
bool SCH_COMPONENT::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList )
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
|
|
|
@ -573,7 +573,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return true if any pin's state has changed.
|
* @return true if any pin's state has changed.
|
||||||
*/
|
*/
|
||||||
bool IsDanglingStateChanged( std::vector<DANGLING_END_ITEM>& aItemList ) override;
|
bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList ) override;
|
||||||
|
|
||||||
wxPoint GetPinPhysicalPosition( const LIB_PIN* Pin ) const;
|
wxPoint GetPinPhysicalPosition( const LIB_PIN* Pin ) const;
|
||||||
|
|
||||||
|
|
|
@ -260,7 +260,7 @@ public:
|
||||||
* @param aItemList - List of items to test item against.
|
* @param aItemList - List of items to test item against.
|
||||||
* @return True if the dangling state has changed from it's current setting.
|
* @return True if the dangling state has changed from it's current setting.
|
||||||
*/
|
*/
|
||||||
virtual bool IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList ) { return false; }
|
virtual bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList ) { return false; }
|
||||||
|
|
||||||
virtual bool IsDangling() const { return false; }
|
virtual bool IsDangling() const { return false; }
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,8 @@ SCH_LINE::SCH_LINE( const SCH_LINE& aLine ) :
|
||||||
m_size = aLine.m_size;
|
m_size = aLine.m_size;
|
||||||
m_style = aLine.m_style;
|
m_style = aLine.m_style;
|
||||||
m_color = aLine.m_color;
|
m_color = aLine.m_color;
|
||||||
m_startIsDangling = m_endIsDangling = false;
|
m_startIsDangling = aLine.m_startIsDangling;
|
||||||
|
m_endIsDangling = aLine.m_endIsDangling;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -503,7 +504,7 @@ void SCH_LINE::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SCH_LINE::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList )
|
bool SCH_LINE::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList )
|
||||||
{
|
{
|
||||||
bool previousStartState = m_startIsDangling;
|
bool previousStartState = m_startIsDangling;
|
||||||
bool previousEndState = m_endIsDangling;
|
bool previousEndState = m_endIsDangling;
|
||||||
|
|
|
@ -156,7 +156,7 @@ public:
|
||||||
|
|
||||||
void GetEndPoints( std::vector<DANGLING_END_ITEM>& aItemList ) override;
|
void GetEndPoints( std::vector<DANGLING_END_ITEM>& aItemList ) override;
|
||||||
|
|
||||||
bool IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList ) override;
|
bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList ) override;
|
||||||
|
|
||||||
bool IsStartDangling() const { return m_startIsDangling; }
|
bool IsStartDangling() const { return m_startIsDangling; }
|
||||||
bool IsEndDangling() const { return m_endIsDangling; }
|
bool IsEndDangling() const { return m_endIsDangling; }
|
||||||
|
|
|
@ -509,7 +509,7 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer, bool isDangling, bool isMovin
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( ( isDangling || isMoving ) && aPin->IsPowerConnection() )
|
if( isDangling && aPin->IsPowerConnection() )
|
||||||
drawPinDanglingSymbol( m_gal, pos, color );
|
drawPinDanglingSymbol( m_gal, pos, color );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -631,7 +631,7 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer, bool isDangling, bool isMovin
|
||||||
pos + VECTOR2D( -1, 1 ) * TARGET_PIN_RADIUS );
|
pos + VECTOR2D( -1, 1 ) * TARGET_PIN_RADIUS );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ( isDangling || isMoving ) && ( aPin->IsVisible() || aPin->IsPowerConnection() ) )
|
if( isDangling && ( aPin->IsVisible() || aPin->IsPowerConnection() ) )
|
||||||
drawPinDanglingSymbol( m_gal, pos, color );
|
drawPinDanglingSymbol( m_gal, pos, color );
|
||||||
|
|
||||||
// Draw the labels
|
// Draw the labels
|
||||||
|
|
|
@ -918,7 +918,7 @@ bool SCH_SCREEN::TestDanglingEnds()
|
||||||
|
|
||||||
for( item = m_drawList.begin(); item; item = item->Next() )
|
for( item = m_drawList.begin(); item; item = item->Next() )
|
||||||
{
|
{
|
||||||
if( item->IsDanglingStateChanged( endPoints ) )
|
if( item->UpdateDanglingState( endPoints ) )
|
||||||
{
|
{
|
||||||
hasStateChanged = true;
|
hasStateChanged = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -806,12 +806,12 @@ void SCH_SHEET::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SCH_SHEET::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList )
|
bool SCH_SHEET::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList )
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
for( SCH_SHEET_PIN& pinsheet : GetPins() )
|
for( SCH_SHEET_PIN& pinsheet : GetPins() )
|
||||||
changed |= pinsheet.IsDanglingStateChanged( aItemList );
|
changed |= pinsheet.UpdateDanglingState( aItemList );
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -516,7 +516,7 @@ public:
|
||||||
|
|
||||||
void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) override;
|
void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) override;
|
||||||
|
|
||||||
bool IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList ) override;
|
bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList ) override;
|
||||||
|
|
||||||
bool IsSelectStateChanged( const wxRect& aRect ) override;
|
bool IsSelectStateChanged( const wxRect& aRect ) override;
|
||||||
|
|
||||||
|
|
|
@ -353,7 +353,7 @@ void SCH_TEXT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList )
|
bool SCH_TEXT::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList )
|
||||||
{
|
{
|
||||||
// Normal text labels cannot be tested for dangling ends.
|
// Normal text labels cannot be tested for dangling ends.
|
||||||
if( Type() == SCH_TEXT_T )
|
if( Type() == SCH_TEXT_T )
|
||||||
|
|
|
@ -172,7 +172,7 @@ public:
|
||||||
|
|
||||||
virtual void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
|
virtual void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
|
||||||
|
|
||||||
virtual bool IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList ) override;
|
virtual bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList ) override;
|
||||||
|
|
||||||
virtual bool IsDangling() const override { return m_isDangling; }
|
virtual bool IsDangling() const override { return m_isDangling; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue