Hide temporarily ratsnest when it is too complex for real-time calculation
This commit is contained in:
parent
1ac34b44bf
commit
f303bf2999
|
@ -275,7 +275,12 @@ void CONNECTIVITY_DATA::ComputeDynamicRatsnest( const std::vector<BOARD_ITEM*>&
|
||||||
void CONNECTIVITY_DATA::ClearDynamicRatsnest()
|
void CONNECTIVITY_DATA::ClearDynamicRatsnest()
|
||||||
{
|
{
|
||||||
m_connAlgo->ForEachAnchor( [] (CN_ANCHOR_PTR anchor ) { anchor->SetNoLine( false ); } );
|
m_connAlgo->ForEachAnchor( [] (CN_ANCHOR_PTR anchor ) { anchor->SetNoLine( false ); } );
|
||||||
|
HideDynamicRatsnest();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CONNECTIVITY_DATA::HideDynamicRatsnest()
|
||||||
|
{
|
||||||
m_dynamicConnectivity.reset();
|
m_dynamicConnectivity.reset();
|
||||||
m_dynamicRatsnest.clear();
|
m_dynamicRatsnest.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,11 +164,16 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function ClearDynamicRatsnest()
|
* Function ClearDynamicRatsnest()
|
||||||
* Erases the temporary dynamic ratsnest (i.e. the ratsnest lines that)
|
* Erases the temporary dynamic ratsnest (i.e. the ratsnest lines that
|
||||||
* pcbnew displays when moving an item/set of items
|
* pcbnew displays when moving an item/set of items)
|
||||||
*/
|
*/
|
||||||
void ClearDynamicRatsnest();
|
void ClearDynamicRatsnest();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hides the temporary dynamic ratsnest lines.
|
||||||
|
*/
|
||||||
|
void HideDynamicRatsnest();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function ComputeDynamicRatsnest()
|
* Function ComputeDynamicRatsnest()
|
||||||
* Calculates the temporary dynamic ratsnest (i.e. the ratsnest lines that)
|
* Calculates the temporary dynamic ratsnest (i.e. the ratsnest lines that)
|
||||||
|
|
|
@ -375,6 +375,13 @@ bool PCB_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_DRAW_PANEL_GAL::RedrawRatsnest()
|
||||||
|
{
|
||||||
|
if( m_ratsnest )
|
||||||
|
m_view->Update( m_ratsnest.get() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_DRAW_PANEL_GAL::setDefaultLayerDeps()
|
void PCB_DRAW_PANEL_GAL::setDefaultLayerDeps()
|
||||||
{
|
{
|
||||||
// caching makes no sense for Cairo and other software renderers
|
// caching makes no sense for Cairo and other software renderers
|
||||||
|
|
|
@ -99,6 +99,9 @@ public:
|
||||||
|
|
||||||
bool SwitchBackend( GAL_TYPE aGalType ) override;
|
bool SwitchBackend( GAL_TYPE aGalType ) override;
|
||||||
|
|
||||||
|
///> Forces refresh of the ratsnest visual representation
|
||||||
|
void RedrawRatsnest();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
///> Reassigns layer order to the initial settings.
|
///> Reassigns layer order to the initial settings.
|
||||||
void setDefaultLayerOrder();
|
void setDefaultLayerOrder();
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
#include <wxPcbStruct.h>
|
#include <wxPcbStruct.h>
|
||||||
#include <class_board.h>
|
#include <class_board.h>
|
||||||
#include <class_zone.h>
|
#include <class_zone.h>
|
||||||
#include <class_draw_panel_gal.h>
|
#include <pcb_draw_panel_gal.h>
|
||||||
#include <class_module.h>
|
#include <class_module.h>
|
||||||
#include <class_mire.h>
|
#include <class_mire.h>
|
||||||
#include <connectivity.h>
|
#include <connectivity.h>
|
||||||
|
@ -53,6 +53,7 @@
|
||||||
#include <view/view_group.h>
|
#include <view/view_group.h>
|
||||||
#include <view/view_controls.h>
|
#include <view/view_controls.h>
|
||||||
#include <origin_viewitem.h>
|
#include <origin_viewitem.h>
|
||||||
|
#include <profile.h>
|
||||||
|
|
||||||
#include <tools/tool_event_utils.h>
|
#include <tools/tool_event_utils.h>
|
||||||
|
|
||||||
|
@ -239,6 +240,7 @@ PCB_EDITOR_CONTROL::PCB_EDITOR_CONTROL() :
|
||||||
m_placeOrigin.reset( new KIGFX::ORIGIN_VIEWITEM( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
|
m_placeOrigin.reset( new KIGFX::ORIGIN_VIEWITEM( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
|
||||||
KIGFX::ORIGIN_VIEWITEM::CIRCLE_CROSS ) );
|
KIGFX::ORIGIN_VIEWITEM::CIRCLE_CROSS ) );
|
||||||
m_probingSchToPcb = false;
|
m_probingSchToPcb = false;
|
||||||
|
m_slowRatsnest = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -309,6 +311,10 @@ bool PCB_EDITOR_CONTROL::Init()
|
||||||
menu.AddMenu( zoneMenu.get(), false, toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ) );
|
menu.AddMenu( zoneMenu.get(), false, toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_ratsnestTimer.SetOwner( this );
|
||||||
|
Connect( m_ratsnestTimer.GetId(), wxEVT_TIMER,
|
||||||
|
wxTimerEventHandler( PCB_EDITOR_CONTROL::ratsnestTimer ), NULL, this );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1138,21 +1144,32 @@ int PCB_EDITOR_CONTROL::UpdateSelectionRatsnest( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
||||||
auto& selection = selectionTool->GetSelection();
|
auto& selection = selectionTool->GetSelection();
|
||||||
|
auto connectivity = getModel<BOARD>()->GetConnectivity();
|
||||||
|
|
||||||
if( selection.Empty() )
|
if( selection.Empty() )
|
||||||
{
|
{
|
||||||
getModel<BOARD>()->GetConnectivity()->ClearDynamicRatsnest();
|
connectivity->ClearDynamicRatsnest();
|
||||||
|
}
|
||||||
|
else if( m_slowRatsnest )
|
||||||
|
{
|
||||||
|
// Compute ratsnest only when user stops dragging for a moment
|
||||||
|
connectivity->HideDynamicRatsnest();
|
||||||
|
m_ratsnestTimer.Start( 40 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto connectivity = getModel<BOARD>()->GetConnectivity();
|
// Check how much time doest it take to calculate ratsnest
|
||||||
std::vector<BOARD_ITEM*> items;
|
PROF_COUNTER counter;
|
||||||
items.reserve( selection.Size() );
|
calculateSelectionRatsnest();
|
||||||
|
counter.Stop();
|
||||||
|
|
||||||
for( auto item : selection )
|
// If it is too slow, then switch to 'slow ratsnest' mode when
|
||||||
items.push_back( static_cast<BOARD_ITEM*>( item ) );
|
// ratsnest is calculated when user stops dragging items for a moment
|
||||||
|
if( counter.msecs() > 10 )
|
||||||
connectivity->ComputeDynamicRatsnest( items );
|
{
|
||||||
|
m_slowRatsnest = true;
|
||||||
|
connectivity->HideDynamicRatsnest();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1162,11 +1179,35 @@ int PCB_EDITOR_CONTROL::UpdateSelectionRatsnest( const TOOL_EVENT& aEvent )
|
||||||
int PCB_EDITOR_CONTROL::HideSelectionRatsnest( const TOOL_EVENT& aEvent )
|
int PCB_EDITOR_CONTROL::HideSelectionRatsnest( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
getModel<BOARD>()->GetConnectivity()->ClearDynamicRatsnest();
|
getModel<BOARD>()->GetConnectivity()->ClearDynamicRatsnest();
|
||||||
|
m_slowRatsnest = false;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_EDITOR_CONTROL::ratsnestTimer( wxTimerEvent& aEvent )
|
||||||
|
{
|
||||||
|
m_ratsnestTimer.Stop();
|
||||||
|
calculateSelectionRatsnest();
|
||||||
|
static_cast<PCB_DRAW_PANEL_GAL*>( m_frame->GetGalCanvas() )->RedrawRatsnest();
|
||||||
|
m_frame->GetGalCanvas()->Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_EDITOR_CONTROL::calculateSelectionRatsnest()
|
||||||
|
{
|
||||||
|
auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
||||||
|
auto& selection = selectionTool->GetSelection();
|
||||||
|
auto connectivity = getModel<BOARD>()->GetConnectivity();
|
||||||
|
std::vector<BOARD_ITEM*> items;
|
||||||
|
items.reserve( selection.Size() );
|
||||||
|
|
||||||
|
for( auto item : selection )
|
||||||
|
items.push_back( static_cast<BOARD_ITEM*>( item ) );
|
||||||
|
|
||||||
|
connectivity->ComputeDynamicRatsnest( items );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_EDITOR_CONTROL::setTransitions()
|
void PCB_EDITOR_CONTROL::setTransitions()
|
||||||
{
|
{
|
||||||
// Track & via size control
|
// Track & via size control
|
||||||
|
|
|
@ -38,7 +38,7 @@ class PCB_EDIT_FRAME;
|
||||||
*
|
*
|
||||||
* Handles actions specific to the board editor in pcbnew.
|
* Handles actions specific to the board editor in pcbnew.
|
||||||
*/
|
*/
|
||||||
class PCB_EDITOR_CONTROL : public PCB_TOOL
|
class PCB_EDITOR_CONTROL : public wxEvtHandler, public PCB_TOOL
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PCB_EDITOR_CONTROL();
|
PCB_EDITOR_CONTROL();
|
||||||
|
@ -111,10 +111,16 @@ public:
|
||||||
///> Shows local ratsnest of a component
|
///> Shows local ratsnest of a component
|
||||||
int ShowLocalRatsnest( const TOOL_EVENT& aEvent );
|
int ShowLocalRatsnest( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
private:
|
||||||
|
///> Event handler to recalculate dynamic ratsnest
|
||||||
|
void ratsnestTimer( wxTimerEvent& aEvent );
|
||||||
|
|
||||||
|
///> Recalculates dynamic ratsnest for the current selection
|
||||||
|
void calculateSelectionRatsnest();
|
||||||
|
|
||||||
///> Sets up handlers for various events.
|
///> Sets up handlers for various events.
|
||||||
void setTransitions() override;
|
void setTransitions() override;
|
||||||
|
|
||||||
private:
|
|
||||||
///> Pointer to the currently used edit frame.
|
///> Pointer to the currently used edit frame.
|
||||||
PCB_EDIT_FRAME* m_frame;
|
PCB_EDIT_FRAME* m_frame;
|
||||||
|
|
||||||
|
@ -124,6 +130,12 @@ private:
|
||||||
///> Flag to ignore a single crossprobe message from eeschema.
|
///> Flag to ignore a single crossprobe message from eeschema.
|
||||||
bool m_probingSchToPcb;
|
bool m_probingSchToPcb;
|
||||||
|
|
||||||
|
///> Flag to indicate whether the current selection ratsnest is slow to calculate.
|
||||||
|
bool m_slowRatsnest;
|
||||||
|
|
||||||
|
///> Timer that start ratsnest calculation when it is slow to compute.
|
||||||
|
wxTimer m_ratsnestTimer;
|
||||||
|
|
||||||
///> How to modify a property for selected items.
|
///> How to modify a property for selected items.
|
||||||
enum MODIFY_MODE { ON, OFF, TOGGLE };
|
enum MODIFY_MODE { ON, OFF, TOGGLE };
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue