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:
Jon Evans 2019-03-30 11:57:30 -04:00 committed by Wayne Stambaugh
parent 74ace97249
commit f1882f333e
9 changed files with 66 additions and 36 deletions

View File

@ -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;
#endif
Reset();
if( aUnconditional )
Reset();
for( const auto& sheet : aSheetList )
{
@ -276,7 +277,8 @@ void CONNECTION_GRAPH::Recalculate( SCH_SHEET_LIST aSheetList )
for( auto item = sheet.LastScreen()->GetDrawItems();
item; item = item->Next() )
{
if( item->IsConnectable() )
if( item->IsConnectable() &&
( aUnconditional || item->IsConnectivityDirty() ) )
{
items.push_back( item );
}
@ -285,7 +287,7 @@ void CONNECTION_GRAPH::Recalculate( SCH_SHEET_LIST aSheetList )
updateItemConnectivity( sheet, items );
}
#ifdef CONNECTIVITY_DEBUG
#ifdef CONNECTIVITY_PROFILE
phase1.Stop();
std::cout << "UpdateItemConnectivity() " << phase1.msecs() << " ms" << std::endl;
#endif
@ -322,7 +324,7 @@ void CONNECTION_GRAPH::updateItemConnectivity( SCH_SHEET_PATH aSheet,
pin.Connection( aSheet )->Reset();
connection_map[ pin.GetTextPos() ].push_back( &pin );
m_items.push_back( &pin );
m_items.insert( &pin );
}
}
else if( item->Type() == SCH_COMPONENT_T )
@ -345,12 +347,12 @@ void CONNECTION_GRAPH::updateItemConnectivity( SCH_SHEET_PATH aSheet,
pin_connection->ConnectedItems().clear();
connection_map[ pos ].push_back( pin_connection );
m_items.push_back( pin_connection );
m_items.insert( pin_connection );
}
}
else
{
m_items.push_back( item );
m_items.insert( item );
if( !item->Connection( aSheet ) )
{
@ -387,6 +389,8 @@ void CONNECTION_GRAPH::updateItemConnectivity( SCH_SHEET_PATH aSheet,
connection_map[ point ].push_back( item );
}
}
item->SetConnectivityDirty( false );
}
for( auto it : connection_map )
@ -497,7 +501,7 @@ void CONNECTION_GRAPH::updateItemConnectivity( SCH_SHEET_PATH aSheet,
void CONNECTION_GRAPH::buildConnectionGraph()
{
#ifdef CONNECTIVITY_DEBUG
#ifdef CONNECTIVITY_PROFILE
PROF_COUNTER phase2;
#endif
@ -762,10 +766,6 @@ void CONNECTION_GRAPH::buildConnectionGraph()
bool conflict = false;
if( name == "/TDO" )
asm("nop;");
// First check the caches
try
{
@ -1016,10 +1016,8 @@ void CONNECTION_GRAPH::buildConnectionGraph()
// 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 )
continue;
@ -1364,9 +1362,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
continue;
if( subgraph->m_dirty )
{
subgraph->m_dirty = false;
}
if( subgraph->m_driver->Connection( subgraph->m_sheet )->IsBus() )
continue;
@ -1375,7 +1371,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
m_net_code_to_subgraphs_map[ code ].push_back( subgraph );
}
#ifdef CONNECTIVITY_DEBUG
#ifdef CONNECTIVITY_PROFILE
phase2.Stop();
std::cout << "BuildConnectionGraph() " << phase2.msecs() << " ms" << std::endl;
#endif
@ -1419,10 +1415,8 @@ std::vector<CONNECTION_SUBGRAPH*> CONNECTION_GRAPH::GetBusesNeedingMigration()
{
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
wxASSERT( !subgraph->m_dirty );
@ -1452,11 +1446,8 @@ std::vector<CONNECTION_SUBGRAPH*> CONNECTION_GRAPH::GetBusesNeedingMigration()
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 )
continue;
@ -1478,10 +1469,8 @@ int CONNECTION_GRAPH::RunERC( const ERC_SETTINGS& aSettings, bool aCreateMarkers
{
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()
wxASSERT( !subgraph->m_dirty );

View File

@ -35,6 +35,14 @@
// #define CONNECTIVITY_DEBUG
#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_EDIT_FRAME;
@ -133,9 +141,10 @@ public:
/**
* 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
@ -184,7 +193,7 @@ public:
private:
std::vector<SCH_ITEM*> m_items;
std::unordered_set<SCH_ITEM*> m_items;
std::vector<CONNECTION_SUBGRAPH*> m_subgraphs;
@ -254,6 +263,8 @@ private:
* the driver is first selected by CONNECTION_SUBGRAPH::ResolveDrivers(),
* and then the connection for the chosen driver is propagated to all the
* other items in the subgraph.
*
* @param aUnconditional is true if a full rebuild should be done
*/
void buildConnectionGraph();

View File

@ -299,7 +299,9 @@ void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation )
TestDanglingEnds();
RefreshItem( item );
OnModify();
if( item->GetFlags() == 0 )
OnModify();
}

View File

@ -277,6 +277,8 @@ wxString SCH_CONNECTION::Name( bool aIgnoreSheet ) const
void SCH_CONNECTION::AppendInfoToMsgPanel( MSG_PANEL_ITEMS& aList ) const
{
#ifdef CONNECTIVITY_REAL_TIME
wxString msg, group_name;
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
{
#ifdef CONNECTIVITY_REAL_TIME
wxString msg;
AppendInfoToMsgPanel( aList );
@ -336,6 +341,7 @@ void SCH_CONNECTION::AppendDebugInfoToMsgPanel( MSG_PANEL_ITEMS& aList ) const
msg.Printf( "%s at %p", Parent()->GetSelectMenuText( MILLIMETRES ), Parent() );
aList.push_back( MSG_PANEL_ITEM( _( "Attached To" ), msg, RED ) );
#endif
}

View File

@ -780,8 +780,14 @@ void SCH_EDIT_FRAME::OnModify()
m_foundItems.SetForceSearch();
//RecalculateConnections( SCH_SHEET_LIST( g_CurrentSheet->Last() ) );
#ifdef CONNECTIVITY_DEBUG
// Debug mode: rebuild full graph on each modification (slow)
RecalculateConnections();
#else
#ifdef CONNECTIVITY_REAL_TIME
g_ConnectionGraph->Recalculate( SCH_SHEET_LIST( g_CurrentSheet->Last() ) );
#endif
#endif
m_canvas->Refresh();
}
@ -1521,7 +1527,7 @@ void SCH_EDIT_FRAME::RecalculateConnections()
for( const auto& sheet : list )
SchematicCleanUp( false, sheet.LastScreen() );
g_ConnectionGraph->Recalculate( list );
g_ConnectionGraph->Recalculate( list, true );
}

View File

@ -49,6 +49,7 @@ SCH_ITEM::SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType ) :
EDA_ITEM( aParent, aType )
{
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 )
{
m_Layer = aItem.m_Layer;
m_connectivity_dirty = true;
}

View File

@ -132,6 +132,9 @@ protected:
/// Stores connectivity information, per sheet
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:
SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType );
@ -351,6 +354,10 @@ public:
*/
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
{
return HitTest( aPosition, 0 );

View File

@ -870,7 +870,8 @@ void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem )
aItem->SetStoredPos( cursorpos );
}
OnModify();
if( !aItem->IsNew() )
OnModify();
GetScreen()->SetCurItem( aItem );
m_canvas->SetMouseCapture( moveItemWithMouseCursor, abortMoveItem );

View File

@ -120,6 +120,9 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
if( aItem == NULL || aCommandType == UR_WIRE_IMAGE )
return;
// Connectivity may change
aItem->SetConnectivityDirty();
if( aAppend )
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 );
wxASSERT( item );
// Connectivity may change
item->SetConnectivityDirty();
UNDO_REDO_T command = commandToUndo->GetPickedItemStatus( ii );
if( command == UR_UNSPECIFIED )