Browse Source

sch_view: update to handle items with children

revert-0c36e162
Mike Williams 6 months ago
parent
commit
5eee8f1c5f
  1. 34
      eeschema/sch_view.cpp
  2. 3
      eeschema/sch_view.h
  3. 7
      eeschema/tools/sch_move_tool.cpp
  4. 12
      eeschema/tools/sch_selection_tool.cpp
  5. 5
      eeschema/tools/sch_selection_tool.h

34
eeschema/sch_view.cpp

@ -57,6 +57,40 @@ SCH_VIEW::~SCH_VIEW()
}
void SCH_VIEW::Update( const KIGFX::VIEW_ITEM* aItem, int aUpdateFlags ) const
{
if( aItem->IsSCH_ITEM() )
{
// The equivalent function in PCB_VIEW doesn't need to do this, but
// that's only because RunOnChildren's constness is misleading in the PCB editor;
// it doesn't modify target item, but our uses of it modify its children.
SCH_ITEM* schItem = const_cast<SCH_ITEM*>( static_cast<const SCH_ITEM*>( aItem ) );
if( schItem->Type() == SCH_TABLECELL_T )
{
VIEW::Update( schItem->GetParent() );
}
else
{
schItem->RunOnChildren(
[this, aUpdateFlags]( SCH_ITEM* child )
{
VIEW::Update( child, aUpdateFlags );
},
RECURSE_MODE::NO_RECURSE );
}
}
VIEW::Update( aItem, aUpdateFlags );
}
void SCH_VIEW::Update( const KIGFX::VIEW_ITEM* aItem ) const
{
SCH_VIEW::Update( aItem, KIGFX::ALL );
}
void SCH_VIEW::Cleanup()
{
Clear();

3
eeschema/sch_view.h

@ -100,6 +100,9 @@ public:
SCH_VIEW( SCH_BASE_FRAME* aFrame );
~SCH_VIEW();
void Update( const KIGFX::VIEW_ITEM* aItem, int aUpdateFlags ) const override;
void Update( const KIGFX::VIEW_ITEM* aItem ) const override;
void Cleanup();
void DisplaySheet( const SCH_SCREEN* aScreen );

7
eeschema/tools/sch_move_tool.cpp

@ -645,6 +645,13 @@ bool SCH_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COMMIT* aComm
shape->UpdateHatching();
}
static_cast<SCH_ITEM*>( item )->RunOnChildren(
[&]( SCH_ITEM* schItem )
{
item->SetFlags( IS_MOVING );
},
RECURSE_MODE::RECURSE );
if( SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( item ) )
schItem->SetStoredPos( schItem->GetPosition() );
}

12
eeschema/tools/sch_selection_tool.cpp

@ -2422,6 +2422,15 @@ void SCH_SELECTION_TOOL::filterCollectorForHierarchy( SCH_COLLECTOR& aCollector,
}
int SCH_SELECTION_TOOL::updateSelection( const TOOL_EVENT& aEvent )
{
getView()->Update( &m_selection );
getView()->Update( &m_enteredGroupOverlay );
return 0;
}
void SCH_SELECTION_TOOL::InitializeSelectionState( SCH_TABLE* aTable )
{
for( SCH_TABLECELL* cell : aTable->GetCells() )
@ -3274,6 +3283,9 @@ void SCH_SELECTION_TOOL::setTransitions()
Go( &SCH_SELECTION_TOOL::SelectNext, SCH_ACTIONS::nextNetItem.MakeEvent() );
Go( &SCH_SELECTION_TOOL::SelectPrevious, SCH_ACTIONS::previousNetItem.MakeEvent() );
Go( &SCH_SELECTION_TOOL::updateSelection, EVENTS::SelectedItemsModified );
Go( &SCH_SELECTION_TOOL::updateSelection, EVENTS::SelectedItemsMoved );
Go( &SCH_SELECTION_TOOL::disambiguateCursor, EVENTS::DisambiguatePoint );
}

5
eeschema/tools/sch_selection_tool.h

@ -333,6 +333,11 @@ private:
*/
bool selectionContains( const VECTOR2I& aPoint ) const;
/**
* Event handler to update the selection VIEW_ITEM.
*/
int updateSelection( const TOOL_EVENT& aEvent );
/**
* Return true if the given item passes the stateful selection filter
*/

Loading…
Cancel
Save