Don't call OnModify() before placing new parts
Remove unnecessary calls to TestDanglingEnds() Disable real-time connectivity updates for now Revert "Remove unnecessary calls to TestDanglingEnds()" This reverts commit d93e3894f2bcd6239862ac9eae0cb2f994b9d52a. Remove debug code
This commit is contained in:
parent
74ace97249
commit
f1882f333e
|
@ -261,13 +261,14 @@ void CONNECTION_GRAPH::Reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CONNECTION_GRAPH::Recalculate( SCH_SHEET_LIST aSheetList )
|
void CONNECTION_GRAPH::Recalculate( SCH_SHEET_LIST aSheetList, bool aUnconditional )
|
||||||
{
|
{
|
||||||
#ifdef CONNECTIVITY_DEBUG
|
#ifdef CONNECTIVITY_PROFILE
|
||||||
PROF_COUNTER phase1;
|
PROF_COUNTER phase1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Reset();
|
if( aUnconditional )
|
||||||
|
Reset();
|
||||||
|
|
||||||
for( const auto& sheet : aSheetList )
|
for( const auto& sheet : aSheetList )
|
||||||
{
|
{
|
||||||
|
@ -276,7 +277,8 @@ void CONNECTION_GRAPH::Recalculate( SCH_SHEET_LIST aSheetList )
|
||||||
for( auto item = sheet.LastScreen()->GetDrawItems();
|
for( auto item = sheet.LastScreen()->GetDrawItems();
|
||||||
item; item = item->Next() )
|
item; item = item->Next() )
|
||||||
{
|
{
|
||||||
if( item->IsConnectable() )
|
if( item->IsConnectable() &&
|
||||||
|
( aUnconditional || item->IsConnectivityDirty() ) )
|
||||||
{
|
{
|
||||||
items.push_back( item );
|
items.push_back( item );
|
||||||
}
|
}
|
||||||
|
@ -285,7 +287,7 @@ void CONNECTION_GRAPH::Recalculate( SCH_SHEET_LIST aSheetList )
|
||||||
updateItemConnectivity( sheet, items );
|
updateItemConnectivity( sheet, items );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONNECTIVITY_DEBUG
|
#ifdef CONNECTIVITY_PROFILE
|
||||||
phase1.Stop();
|
phase1.Stop();
|
||||||
std::cout << "UpdateItemConnectivity() " << phase1.msecs() << " ms" << std::endl;
|
std::cout << "UpdateItemConnectivity() " << phase1.msecs() << " ms" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
@ -322,7 +324,7 @@ void CONNECTION_GRAPH::updateItemConnectivity( SCH_SHEET_PATH aSheet,
|
||||||
pin.Connection( aSheet )->Reset();
|
pin.Connection( aSheet )->Reset();
|
||||||
|
|
||||||
connection_map[ pin.GetTextPos() ].push_back( &pin );
|
connection_map[ pin.GetTextPos() ].push_back( &pin );
|
||||||
m_items.push_back( &pin );
|
m_items.insert( &pin );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( item->Type() == SCH_COMPONENT_T )
|
else if( item->Type() == SCH_COMPONENT_T )
|
||||||
|
@ -345,12 +347,12 @@ void CONNECTION_GRAPH::updateItemConnectivity( SCH_SHEET_PATH aSheet,
|
||||||
pin_connection->ConnectedItems().clear();
|
pin_connection->ConnectedItems().clear();
|
||||||
|
|
||||||
connection_map[ pos ].push_back( pin_connection );
|
connection_map[ pos ].push_back( pin_connection );
|
||||||
m_items.push_back( pin_connection );
|
m_items.insert( pin_connection );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_items.push_back( item );
|
m_items.insert( item );
|
||||||
|
|
||||||
if( !item->Connection( aSheet ) )
|
if( !item->Connection( aSheet ) )
|
||||||
{
|
{
|
||||||
|
@ -387,6 +389,8 @@ void CONNECTION_GRAPH::updateItemConnectivity( SCH_SHEET_PATH aSheet,
|
||||||
connection_map[ point ].push_back( item );
|
connection_map[ point ].push_back( item );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
item->SetConnectivityDirty( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( auto it : connection_map )
|
for( auto it : connection_map )
|
||||||
|
@ -497,7 +501,7 @@ void CONNECTION_GRAPH::updateItemConnectivity( SCH_SHEET_PATH aSheet,
|
||||||
|
|
||||||
void CONNECTION_GRAPH::buildConnectionGraph()
|
void CONNECTION_GRAPH::buildConnectionGraph()
|
||||||
{
|
{
|
||||||
#ifdef CONNECTIVITY_DEBUG
|
#ifdef CONNECTIVITY_PROFILE
|
||||||
PROF_COUNTER phase2;
|
PROF_COUNTER phase2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -762,10 +766,6 @@ void CONNECTION_GRAPH::buildConnectionGraph()
|
||||||
|
|
||||||
bool conflict = false;
|
bool conflict = false;
|
||||||
|
|
||||||
|
|
||||||
if( name == "/TDO" )
|
|
||||||
asm("nop;");
|
|
||||||
|
|
||||||
// First check the caches
|
// First check the caches
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1016,10 +1016,8 @@ void CONNECTION_GRAPH::buildConnectionGraph()
|
||||||
|
|
||||||
// Collapse net codes between hierarchical sheets
|
// Collapse net codes between hierarchical sheets
|
||||||
|
|
||||||
for( auto it = m_subgraphs.begin(); it < m_subgraphs.end(); it++ )
|
for( auto subgraph : m_subgraphs )
|
||||||
{
|
{
|
||||||
auto subgraph = *it;
|
|
||||||
|
|
||||||
if( !subgraph->m_driver || !subgraph->m_dirty )
|
if( !subgraph->m_driver || !subgraph->m_dirty )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1364,9 +1362,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if( subgraph->m_dirty )
|
if( subgraph->m_dirty )
|
||||||
{
|
|
||||||
subgraph->m_dirty = false;
|
subgraph->m_dirty = false;
|
||||||
}
|
|
||||||
|
|
||||||
if( subgraph->m_driver->Connection( subgraph->m_sheet )->IsBus() )
|
if( subgraph->m_driver->Connection( subgraph->m_sheet )->IsBus() )
|
||||||
continue;
|
continue;
|
||||||
|
@ -1375,7 +1371,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
|
||||||
m_net_code_to_subgraphs_map[ code ].push_back( subgraph );
|
m_net_code_to_subgraphs_map[ code ].push_back( subgraph );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONNECTIVITY_DEBUG
|
#ifdef CONNECTIVITY_PROFILE
|
||||||
phase2.Stop();
|
phase2.Stop();
|
||||||
std::cout << "BuildConnectionGraph() " << phase2.msecs() << " ms" << std::endl;
|
std::cout << "BuildConnectionGraph() " << phase2.msecs() << " ms" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1419,10 +1415,8 @@ std::vector<CONNECTION_SUBGRAPH*> CONNECTION_GRAPH::GetBusesNeedingMigration()
|
||||||
{
|
{
|
||||||
std::vector<CONNECTION_SUBGRAPH*> ret;
|
std::vector<CONNECTION_SUBGRAPH*> ret;
|
||||||
|
|
||||||
for( auto it = m_subgraphs.begin(); it < m_subgraphs.end(); it++ )
|
for( auto subgraph : m_subgraphs )
|
||||||
{
|
{
|
||||||
auto subgraph = *it;
|
|
||||||
|
|
||||||
// Graph is supposed to be up-to-date before calling this
|
// Graph is supposed to be up-to-date before calling this
|
||||||
wxASSERT( !subgraph->m_dirty );
|
wxASSERT( !subgraph->m_dirty );
|
||||||
|
|
||||||
|
@ -1452,11 +1446,8 @@ std::vector<CONNECTION_SUBGRAPH*> CONNECTION_GRAPH::GetBusesNeedingMigration()
|
||||||
|
|
||||||
bool CONNECTION_GRAPH::UsesNewBusFeatures() const
|
bool CONNECTION_GRAPH::UsesNewBusFeatures() const
|
||||||
{
|
{
|
||||||
for( auto it = m_subgraphs.begin(); it < m_subgraphs.end(); it++ )
|
for( auto subgraph : m_subgraphs )
|
||||||
{
|
{
|
||||||
auto subgraph = *it;
|
|
||||||
|
|
||||||
|
|
||||||
if( !subgraph->m_driver )
|
if( !subgraph->m_driver )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1478,10 +1469,8 @@ int CONNECTION_GRAPH::RunERC( const ERC_SETTINGS& aSettings, bool aCreateMarkers
|
||||||
{
|
{
|
||||||
int error_count = 0;
|
int error_count = 0;
|
||||||
|
|
||||||
for( auto it = m_subgraphs.begin(); it < m_subgraphs.end(); it++ )
|
for( auto subgraph : m_subgraphs )
|
||||||
{
|
{
|
||||||
auto subgraph = *it;
|
|
||||||
|
|
||||||
// Graph is supposed to be up-to-date before calling RunERC()
|
// Graph is supposed to be up-to-date before calling RunERC()
|
||||||
wxASSERT( !subgraph->m_dirty );
|
wxASSERT( !subgraph->m_dirty );
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,14 @@
|
||||||
// #define CONNECTIVITY_DEBUG
|
// #define CONNECTIVITY_DEBUG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONNECTIVITY_DEBUG
|
||||||
|
#define CONNECTIVITY_PROFILE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Uncomment this line to enable real-time connectivity updates
|
||||||
|
// TODO(JE) re-enable this once performance concerns are sorted out
|
||||||
|
// #define CONNECTIVITY_REAL_TIME
|
||||||
|
|
||||||
class SCH_PIN_CONNECTION;
|
class SCH_PIN_CONNECTION;
|
||||||
|
|
||||||
class SCH_EDIT_FRAME;
|
class SCH_EDIT_FRAME;
|
||||||
|
@ -133,9 +141,10 @@ public:
|
||||||
/**
|
/**
|
||||||
* Updates the connection graph for the given list of sheets.
|
* Updates the connection graph for the given list of sheets.
|
||||||
*
|
*
|
||||||
* @param aSheetList should be the whole schematic for now
|
* @param aSheetList is the list of possibly modified sheets
|
||||||
|
* @param aUnconditional is true if an unconditional full recalculation should be done
|
||||||
*/
|
*/
|
||||||
void Recalculate( SCH_SHEET_LIST aSheetList );
|
void Recalculate( SCH_SHEET_LIST aSheetList, bool aUnconditional = false );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the connectivity graph based on a single item
|
* Updates the connectivity graph based on a single item
|
||||||
|
@ -184,7 +193,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::vector<SCH_ITEM*> m_items;
|
std::unordered_set<SCH_ITEM*> m_items;
|
||||||
|
|
||||||
std::vector<CONNECTION_SUBGRAPH*> m_subgraphs;
|
std::vector<CONNECTION_SUBGRAPH*> m_subgraphs;
|
||||||
|
|
||||||
|
@ -254,6 +263,8 @@ private:
|
||||||
* the driver is first selected by CONNECTION_SUBGRAPH::ResolveDrivers(),
|
* the driver is first selected by CONNECTION_SUBGRAPH::ResolveDrivers(),
|
||||||
* and then the connection for the chosen driver is propagated to all the
|
* and then the connection for the chosen driver is propagated to all the
|
||||||
* other items in the subgraph.
|
* other items in the subgraph.
|
||||||
|
*
|
||||||
|
* @param aUnconditional is true if a full rebuild should be done
|
||||||
*/
|
*/
|
||||||
void buildConnectionGraph();
|
void buildConnectionGraph();
|
||||||
|
|
||||||
|
|
|
@ -299,7 +299,9 @@ void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation )
|
||||||
TestDanglingEnds();
|
TestDanglingEnds();
|
||||||
|
|
||||||
RefreshItem( item );
|
RefreshItem( item );
|
||||||
OnModify();
|
|
||||||
|
if( item->GetFlags() == 0 )
|
||||||
|
OnModify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -277,6 +277,8 @@ wxString SCH_CONNECTION::Name( bool aIgnoreSheet ) const
|
||||||
|
|
||||||
void SCH_CONNECTION::AppendInfoToMsgPanel( MSG_PANEL_ITEMS& aList ) const
|
void SCH_CONNECTION::AppendInfoToMsgPanel( MSG_PANEL_ITEMS& aList ) const
|
||||||
{
|
{
|
||||||
|
#ifdef CONNECTIVITY_REAL_TIME
|
||||||
|
|
||||||
wxString msg, group_name;
|
wxString msg, group_name;
|
||||||
std::vector<wxString> group_members;
|
std::vector<wxString> group_members;
|
||||||
|
|
||||||
|
@ -313,11 +315,14 @@ void SCH_CONNECTION::AppendInfoToMsgPanel( MSG_PANEL_ITEMS& aList ) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_CONNECTION::AppendDebugInfoToMsgPanel( MSG_PANEL_ITEMS& aList ) const
|
void SCH_CONNECTION::AppendDebugInfoToMsgPanel( MSG_PANEL_ITEMS& aList ) const
|
||||||
{
|
{
|
||||||
|
#ifdef CONNECTIVITY_REAL_TIME
|
||||||
wxString msg;
|
wxString msg;
|
||||||
|
|
||||||
AppendInfoToMsgPanel( aList );
|
AppendInfoToMsgPanel( aList );
|
||||||
|
@ -336,6 +341,7 @@ void SCH_CONNECTION::AppendDebugInfoToMsgPanel( MSG_PANEL_ITEMS& aList ) const
|
||||||
|
|
||||||
msg.Printf( "%s at %p", Parent()->GetSelectMenuText( MILLIMETRES ), Parent() );
|
msg.Printf( "%s at %p", Parent()->GetSelectMenuText( MILLIMETRES ), Parent() );
|
||||||
aList.push_back( MSG_PANEL_ITEM( _( "Attached To" ), msg, RED ) );
|
aList.push_back( MSG_PANEL_ITEM( _( "Attached To" ), msg, RED ) );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -780,8 +780,14 @@ void SCH_EDIT_FRAME::OnModify()
|
||||||
|
|
||||||
m_foundItems.SetForceSearch();
|
m_foundItems.SetForceSearch();
|
||||||
|
|
||||||
//RecalculateConnections( SCH_SHEET_LIST( g_CurrentSheet->Last() ) );
|
#ifdef CONNECTIVITY_DEBUG
|
||||||
|
// Debug mode: rebuild full graph on each modification (slow)
|
||||||
RecalculateConnections();
|
RecalculateConnections();
|
||||||
|
#else
|
||||||
|
#ifdef CONNECTIVITY_REAL_TIME
|
||||||
|
g_ConnectionGraph->Recalculate( SCH_SHEET_LIST( g_CurrentSheet->Last() ) );
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
}
|
}
|
||||||
|
@ -1521,7 +1527,7 @@ void SCH_EDIT_FRAME::RecalculateConnections()
|
||||||
for( const auto& sheet : list )
|
for( const auto& sheet : list )
|
||||||
SchematicCleanUp( false, sheet.LastScreen() );
|
SchematicCleanUp( false, sheet.LastScreen() );
|
||||||
|
|
||||||
g_ConnectionGraph->Recalculate( list );
|
g_ConnectionGraph->Recalculate( list, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ SCH_ITEM::SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType ) :
|
||||||
EDA_ITEM( aParent, aType )
|
EDA_ITEM( aParent, aType )
|
||||||
{
|
{
|
||||||
m_Layer = LAYER_WIRE; // It's only a default, in fact
|
m_Layer = LAYER_WIRE; // It's only a default, in fact
|
||||||
|
m_connectivity_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,6 +57,7 @@ SCH_ITEM::SCH_ITEM( const SCH_ITEM& aItem ) :
|
||||||
EDA_ITEM( aItem )
|
EDA_ITEM( aItem )
|
||||||
{
|
{
|
||||||
m_Layer = aItem.m_Layer;
|
m_Layer = aItem.m_Layer;
|
||||||
|
m_connectivity_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,9 @@ protected:
|
||||||
/// Stores connectivity information, per sheet
|
/// Stores connectivity information, per sheet
|
||||||
std::unordered_map<SCH_SHEET_PATH, SCH_CONNECTION*> m_connection_map;
|
std::unordered_map<SCH_SHEET_PATH, SCH_CONNECTION*> m_connection_map;
|
||||||
|
|
||||||
|
/// True if connectivity info might be out of date
|
||||||
|
bool m_connectivity_dirty;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType );
|
SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType );
|
||||||
|
|
||||||
|
@ -351,6 +354,10 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const { return true; }
|
virtual bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const { return true; }
|
||||||
|
|
||||||
|
bool IsConnectivityDirty() { return m_connectivity_dirty; }
|
||||||
|
|
||||||
|
void SetConnectivityDirty( bool aDirty = true ) { m_connectivity_dirty = aDirty; }
|
||||||
|
|
||||||
virtual bool HitTest( const wxPoint& aPosition ) const override
|
virtual bool HitTest( const wxPoint& aPosition ) const override
|
||||||
{
|
{
|
||||||
return HitTest( aPosition, 0 );
|
return HitTest( aPosition, 0 );
|
||||||
|
|
|
@ -870,7 +870,8 @@ void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem )
|
||||||
aItem->SetStoredPos( cursorpos );
|
aItem->SetStoredPos( cursorpos );
|
||||||
}
|
}
|
||||||
|
|
||||||
OnModify();
|
if( !aItem->IsNew() )
|
||||||
|
OnModify();
|
||||||
|
|
||||||
GetScreen()->SetCurItem( aItem );
|
GetScreen()->SetCurItem( aItem );
|
||||||
m_canvas->SetMouseCapture( moveItemWithMouseCursor, abortMoveItem );
|
m_canvas->SetMouseCapture( moveItemWithMouseCursor, abortMoveItem );
|
||||||
|
|
|
@ -120,6 +120,9 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
|
||||||
if( aItem == NULL || aCommandType == UR_WIRE_IMAGE )
|
if( aItem == NULL || aCommandType == UR_WIRE_IMAGE )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Connectivity may change
|
||||||
|
aItem->SetConnectivityDirty();
|
||||||
|
|
||||||
if( aAppend )
|
if( aAppend )
|
||||||
commandToUndo = GetScreen()->PopCommandFromUndoList();
|
commandToUndo = GetScreen()->PopCommandFromUndoList();
|
||||||
|
|
||||||
|
@ -211,6 +214,9 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
|
||||||
SCH_ITEM* item = (SCH_ITEM*) commandToUndo->GetPickedItem( ii );
|
SCH_ITEM* item = (SCH_ITEM*) commandToUndo->GetPickedItem( ii );
|
||||||
wxASSERT( item );
|
wxASSERT( item );
|
||||||
|
|
||||||
|
// Connectivity may change
|
||||||
|
item->SetConnectivityDirty();
|
||||||
|
|
||||||
UNDO_REDO_T command = commandToUndo->GetPickedItemStatus( ii );
|
UNDO_REDO_T command = commandToUndo->GetPickedItemStatus( ii );
|
||||||
|
|
||||||
if( command == UR_UNSPECIFIED )
|
if( command == UR_UNSPECIFIED )
|
||||||
|
|
Loading…
Reference in New Issue