Cleanup and formatting.
This commit is contained in:
parent
f5e9a2a6da
commit
dd60fd47b2
|
@ -59,10 +59,12 @@ bool LIB_DRAWING_TOOLS::Init()
|
|||
{
|
||||
EE_TOOL_BASE::Init();
|
||||
|
||||
auto isDrawingCondition = [] ( const SELECTION& aSel ) {
|
||||
LIB_ITEM* item = (LIB_ITEM*) aSel.Front();
|
||||
return item && item->IsNew();
|
||||
};
|
||||
auto isDrawingCondition =
|
||||
[] ( const SELECTION& aSel )
|
||||
{
|
||||
LIB_ITEM* item = (LIB_ITEM*) aSel.Front();
|
||||
return item && item->IsNew();
|
||||
};
|
||||
|
||||
m_menu.GetMenu().AddItem( EE_ACTIONS::finishDrawing, isDrawingCondition, 2 );
|
||||
|
||||
|
@ -123,7 +125,9 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
if( evt->IsCancelInteractive() )
|
||||
{
|
||||
if( item )
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
|
@ -261,7 +265,7 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SYMBOL_EDITOR_SETTINGS* settings = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
|
||||
KICAD_T type = aEvent.Parameter<KICAD_T>();
|
||||
KICAD_T type = aEvent.Parameter<KICAD_T>();
|
||||
|
||||
// We might be running as the same shape in another co-routine. Make sure that one
|
||||
// gets whacked.
|
||||
|
@ -476,7 +480,9 @@ int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
|
|||
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
|
||||
}
|
||||
else
|
||||
{
|
||||
evt->SetPassEvent();
|
||||
}
|
||||
}
|
||||
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
|
|
|
@ -154,7 +154,9 @@ int LIB_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
if( item->IsMoving() )
|
||||
{
|
||||
m_toolMgr->RunAction( ACTIONS::refreshPreview, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
||||
|
@ -203,7 +205,9 @@ int LIB_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
|
|||
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
||||
|
||||
if( item->IsMoving() )
|
||||
{
|
||||
m_toolMgr->RunAction( ACTIONS::refreshPreview, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( selection.IsHover() )
|
||||
|
@ -281,10 +285,8 @@ int LIB_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
}
|
||||
|
||||
for( auto item : toDelete )
|
||||
{
|
||||
for( LIB_ITEM* item : toDelete )
|
||||
part->RemoveDrawItem( item );
|
||||
}
|
||||
|
||||
m_frame->RebuildView();
|
||||
m_frame->OnModify();
|
||||
|
@ -310,62 +312,63 @@ int LIB_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
|||
picker->SetCursor( KICURSOR::REMOVE );
|
||||
|
||||
picker->SetClickHandler(
|
||||
[this] ( const VECTOR2D& aPosition ) -> bool
|
||||
{
|
||||
if( m_pickerItem )
|
||||
[this]( const VECTOR2D& aPosition ) -> bool
|
||||
{
|
||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
selectionTool->UnbrightenItem( m_pickerItem );
|
||||
selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
|
||||
m_toolMgr->RunAction( ACTIONS::doDelete, true );
|
||||
m_pickerItem = nullptr;
|
||||
}
|
||||
if( m_pickerItem )
|
||||
{
|
||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
selectionTool->UnbrightenItem( m_pickerItem );
|
||||
selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
|
||||
m_toolMgr->RunAction( ACTIONS::doDelete, true );
|
||||
m_pickerItem = nullptr;
|
||||
}
|
||||
|
||||
return true;
|
||||
} );
|
||||
return true;
|
||||
} );
|
||||
|
||||
picker->SetMotionHandler(
|
||||
[this] ( const VECTOR2D& aPos )
|
||||
{
|
||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
EE_COLLECTOR collector;
|
||||
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
||||
collector.Collect( m_frame->GetScreen(), nonFields, (wxPoint) aPos, m_frame->GetUnit(),
|
||||
m_frame->GetConvert() );
|
||||
|
||||
// Remove unselectable items
|
||||
for( int i = collector.GetCount() - 1; i >= 0; --i )
|
||||
[this]( const VECTOR2D& aPos )
|
||||
{
|
||||
if( !selectionTool->Selectable( collector[ i ] ) )
|
||||
collector.Remove( i );
|
||||
}
|
||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
EE_COLLECTOR collector;
|
||||
|
||||
if( collector.GetCount() > 1 )
|
||||
selectionTool->GuessSelectionCandidates( collector, aPos );
|
||||
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
||||
collector.Collect( m_frame->GetScreen(), nonFields, (wxPoint) aPos,
|
||||
m_frame->GetUnit(), m_frame->GetConvert() );
|
||||
|
||||
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
||||
// Remove unselectable items
|
||||
for( int i = collector.GetCount() - 1; i >= 0; --i )
|
||||
{
|
||||
if( !selectionTool->Selectable( collector[ i ] ) )
|
||||
collector.Remove( i );
|
||||
}
|
||||
|
||||
if( m_pickerItem != item )
|
||||
{
|
||||
if( m_pickerItem )
|
||||
selectionTool->UnbrightenItem( m_pickerItem );
|
||||
if( collector.GetCount() > 1 )
|
||||
selectionTool->GuessSelectionCandidates( collector, aPos );
|
||||
|
||||
m_pickerItem = item;
|
||||
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
||||
|
||||
if( m_pickerItem )
|
||||
selectionTool->BrightenItem( m_pickerItem );
|
||||
}
|
||||
} );
|
||||
if( m_pickerItem != item )
|
||||
{
|
||||
if( m_pickerItem )
|
||||
selectionTool->UnbrightenItem( m_pickerItem );
|
||||
|
||||
m_pickerItem = item;
|
||||
|
||||
if( m_pickerItem )
|
||||
selectionTool->BrightenItem( m_pickerItem );
|
||||
}
|
||||
} );
|
||||
|
||||
picker->SetFinalizeHandler(
|
||||
[this] ( const int& aFinalState )
|
||||
{
|
||||
if( m_pickerItem )
|
||||
m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
||||
[this]( const int& aFinalState )
|
||||
{
|
||||
if( m_pickerItem )
|
||||
m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
||||
|
||||
// Wake the selection tool after exiting to ensure the cursor gets updated
|
||||
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
||||
} );
|
||||
// Wake the selection tool after exiting to ensure the cursor gets updated
|
||||
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
||||
} );
|
||||
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||
|
||||
|
|
|
@ -314,28 +314,6 @@ void LIB_MOVE_TOOL::moveItem( EDA_ITEM* aItem, VECTOR2I aDelta )
|
|||
}
|
||||
|
||||
|
||||
bool LIB_MOVE_TOOL::updateModificationPoint( EE_SELECTION& aSelection )
|
||||
{
|
||||
if( m_moveInProgress && aSelection.HasReferencePoint() )
|
||||
return false;
|
||||
|
||||
// When there is only one item selected, the reference point is its position...
|
||||
if( aSelection.Size() == 1 )
|
||||
{
|
||||
LIB_ITEM* item = static_cast<LIB_ITEM*>( aSelection.Front() );
|
||||
aSelection.SetReferencePoint( item->GetPosition() );
|
||||
}
|
||||
// ...otherwise modify items with regard to the grid-snapped cursor position
|
||||
else
|
||||
{
|
||||
m_cursor = getViewControls()->GetCursorPosition( true );
|
||||
aSelection.SetReferencePoint( m_cursor );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void LIB_MOVE_TOOL::setTransitions()
|
||||
{
|
||||
Go( &LIB_MOVE_TOOL::Main, EE_ACTIONS::move.MakeEvent() );
|
||||
|
|
|
@ -54,10 +54,6 @@ public:
|
|||
private:
|
||||
void moveItem( EDA_ITEM* aItem, VECTOR2I aDelta );
|
||||
|
||||
///> Returns the right modification point (e.g. for rotation), depending on the number of
|
||||
///> selected items.
|
||||
bool updateModificationPoint( EE_SELECTION& aSelection );
|
||||
|
||||
///> Sets up handlers for various events.
|
||||
void setTransitions() override;
|
||||
|
||||
|
|
|
@ -62,18 +62,17 @@ void ReannotateFromPCBNew( SCH_EDIT_FRAME* aFrame, std::string& aNetlist )
|
|||
|
||||
BACK_ANNOTATE backAnno( aFrame,
|
||||
reporter,
|
||||
false, //aRelinkFootprints
|
||||
false, //aProcessFootprints
|
||||
false, //aProcessValues
|
||||
true, //aProcessReferences
|
||||
false, //aProcessNetNames
|
||||
false ); //aDryRun
|
||||
false, // aRelinkFootprints
|
||||
false, // aProcessFootprints
|
||||
false, // aProcessValues
|
||||
true, // aProcessReferences
|
||||
false, // aProcessNetNames
|
||||
false ); // aDryRun
|
||||
|
||||
if( !backAnno.BackAnnotateSymbols( aNetlist ) )
|
||||
{
|
||||
aNetlist = _( "Errors reported by Eeschema:\n" )
|
||||
+ reporter.m_string.ToStdString(); //Assume the worst
|
||||
aNetlist += _( "\nAnnotation not performed!\n" );
|
||||
aNetlist = _( "Errors reported by Eeschema:\n" ) + reporter.m_string.ToStdString();
|
||||
aNetlist += _( "\nAnnotation not performed!\n" ); // Assume the worst
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -70,7 +70,7 @@ bool SCH_DRAWING_TOOLS::Init()
|
|||
return m_frame->GetCurrentSheet().Last() != &m_frame->Schematic().Root();
|
||||
};
|
||||
|
||||
auto& ctxMenu = m_menu.GetMenu();
|
||||
CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
|
||||
ctxMenu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 2 );
|
||||
|
||||
return true;
|
||||
|
@ -126,7 +126,8 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
|
|||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
m_frame->GetCanvas()->SetCurrentCursor( component ? KICURSOR::MOVING : KICURSOR::COMPONENT );
|
||||
m_frame->GetCanvas()->SetCurrentCursor( component ? KICURSOR::MOVING
|
||||
: KICURSOR::COMPONENT );
|
||||
};
|
||||
|
||||
// Set initial cursor
|
||||
|
@ -293,7 +294,9 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
|
|||
m_view->AddToPreview( component->Clone() );
|
||||
}
|
||||
else
|
||||
{
|
||||
evt->SetPassEvent();
|
||||
}
|
||||
|
||||
// Enable autopanning and cursor capture only when there is a footprint to be placed
|
||||
getViewControls()->SetAutoPan( component != nullptr );
|
||||
|
@ -399,7 +402,8 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
wxFileDialog dlg( m_frame, _( "Choose Image" ), wxEmptyString, wxEmptyString,
|
||||
_( "Image Files" ) + wxS( " " ) + wxImage::GetImageExtWildcard(), wxFD_OPEN );
|
||||
_( "Image Files" ) + wxS( " " ) + wxImage::GetImageExtWildcard(),
|
||||
wxFD_OPEN );
|
||||
|
||||
if( dlg.ShowModal() != wxID_OK )
|
||||
continue;
|
||||
|
@ -464,7 +468,9 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
m_view->RecacheAllItems(); // Bitmaps are cached in Opengl
|
||||
}
|
||||
else
|
||||
{
|
||||
evt->SetPassEvent();
|
||||
}
|
||||
|
||||
// Enable autopanning and cursor capture only when there is a footprint to be placed
|
||||
getViewControls()->SetAutoPan( image != nullptr );
|
||||
|
|
|
@ -206,26 +206,10 @@ bool SCH_EDIT_TOOL::Init()
|
|||
if( aSel.GetSize() == 0 )
|
||||
return true; // Show worksheet properties
|
||||
|
||||
SCH_ITEM* firstItem = dynamic_cast<SCH_ITEM*>( aSel.Front() );
|
||||
|
||||
wxCHECK( firstItem, false );
|
||||
|
||||
SCH_ITEM* firstItem = dynamic_cast<SCH_ITEM*>( aSel.Front() );
|
||||
const EE_SELECTION* eeSelection = dynamic_cast<const EE_SELECTION*>( &aSel );
|
||||
|
||||
wxCHECK( eeSelection, false );
|
||||
|
||||
if( aSel.GetSize() != 1
|
||||
&& !( aSel.GetSize() >= 1
|
||||
&& ( firstItem->Type() == SCH_LINE_T
|
||||
|| firstItem->Type() == SCH_BUS_WIRE_ENTRY_T )
|
||||
&& eeSelection->AllItemsHaveLineStroke() ) )
|
||||
return false;
|
||||
|
||||
if( aSel.GetSize() != 1
|
||||
&& !( aSel.GetSize() >= 1
|
||||
&& ( firstItem->Type() == SCH_JUNCTION_T )
|
||||
&& eeSelection->AreAllItemsIdentical() ) )
|
||||
return false;
|
||||
wxCHECK( firstItem, false );
|
||||
|
||||
switch( firstItem->Type() )
|
||||
{
|
||||
|
@ -242,18 +226,10 @@ bool SCH_EDIT_TOOL::Init()
|
|||
|
||||
case SCH_LINE_T:
|
||||
case SCH_BUS_WIRE_ENTRY_T:
|
||||
for( EDA_ITEM* item : aSel.GetItems() )
|
||||
{
|
||||
SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( item );
|
||||
|
||||
if( !schItem || !schItem->HasLineStroke() )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return eeSelection->AllItemsHaveLineStroke();
|
||||
|
||||
case SCH_JUNCTION_T:
|
||||
return true;
|
||||
return eeSelection->AreAllItemsIdentical();
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
@ -1073,64 +1049,64 @@ int SCH_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
|||
picker->SetCursor( KICURSOR::REMOVE );
|
||||
|
||||
picker->SetClickHandler(
|
||||
[this] ( const VECTOR2D& aPosition ) -> bool
|
||||
{
|
||||
if( m_pickerItem )
|
||||
[this]( const VECTOR2D& aPosition ) -> bool
|
||||
{
|
||||
SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( m_pickerItem );
|
||||
|
||||
if( sch_item && sch_item->IsLocked() )
|
||||
if( m_pickerItem )
|
||||
{
|
||||
STATUS_TEXT_POPUP statusPopup( m_frame );
|
||||
statusPopup.SetText( _( "Item locked." ) );
|
||||
statusPopup.PopupFor( 2000 );
|
||||
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
|
||||
return true;
|
||||
SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( m_pickerItem );
|
||||
|
||||
if( sch_item && sch_item->IsLocked() )
|
||||
{
|
||||
STATUS_TEXT_POPUP statusPopup( m_frame );
|
||||
statusPopup.SetText( _( "Item locked." ) );
|
||||
statusPopup.PopupFor( 2000 );
|
||||
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
|
||||
return true;
|
||||
}
|
||||
|
||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
selectionTool->UnbrightenItem( m_pickerItem );
|
||||
selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
|
||||
m_toolMgr->RunAction( ACTIONS::doDelete, true );
|
||||
m_pickerItem = nullptr;
|
||||
}
|
||||
|
||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
selectionTool->UnbrightenItem( m_pickerItem );
|
||||
selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
|
||||
m_toolMgr->RunAction( ACTIONS::doDelete, true );
|
||||
m_pickerItem = nullptr;
|
||||
}
|
||||
|
||||
return true;
|
||||
} );
|
||||
return true;
|
||||
} );
|
||||
|
||||
picker->SetMotionHandler(
|
||||
[this] ( const VECTOR2D& aPos )
|
||||
{
|
||||
EE_COLLECTOR collector;
|
||||
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
||||
collector.Collect( m_frame->GetScreen(), deletableItems, (wxPoint) aPos );
|
||||
|
||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
selectionTool->GuessSelectionCandidates( collector, aPos );
|
||||
|
||||
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
||||
|
||||
if( m_pickerItem != item )
|
||||
[this]( const VECTOR2D& aPos )
|
||||
{
|
||||
if( m_pickerItem )
|
||||
selectionTool->UnbrightenItem( m_pickerItem );
|
||||
EE_COLLECTOR collector;
|
||||
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
||||
collector.Collect( m_frame->GetScreen(), deletableItems, (wxPoint) aPos );
|
||||
|
||||
m_pickerItem = item;
|
||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
selectionTool->GuessSelectionCandidates( collector, aPos );
|
||||
|
||||
if( m_pickerItem )
|
||||
selectionTool->BrightenItem( m_pickerItem );
|
||||
}
|
||||
} );
|
||||
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
||||
|
||||
if( m_pickerItem != item )
|
||||
{
|
||||
if( m_pickerItem )
|
||||
selectionTool->UnbrightenItem( m_pickerItem );
|
||||
|
||||
m_pickerItem = item;
|
||||
|
||||
if( m_pickerItem )
|
||||
selectionTool->BrightenItem( m_pickerItem );
|
||||
}
|
||||
} );
|
||||
|
||||
picker->SetFinalizeHandler(
|
||||
[this] ( const int& aFinalState )
|
||||
{
|
||||
if( m_pickerItem )
|
||||
m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
||||
[this]( const int& aFinalState )
|
||||
{
|
||||
if( m_pickerItem )
|
||||
m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
||||
|
||||
// Wake the selection tool after exiting to ensure the cursor gets updated
|
||||
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
||||
} );
|
||||
// Wake the selection tool after exiting to ensure the cursor gets updated
|
||||
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
||||
} );
|
||||
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||
|
||||
|
|
|
@ -245,19 +245,20 @@ int SCH_EDITOR_CONTROL::UpdateFind( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
wxFindReplaceData* data = m_frame->GetFindReplaceData();
|
||||
|
||||
auto visit = [&]( EDA_ITEM* aItem, SCH_SHEET_PATH* aSheet )
|
||||
{
|
||||
if( data && aItem->Matches( *data, aSheet ) )
|
||||
{
|
||||
aItem->SetForceVisible( true );
|
||||
m_selectionTool->BrightenItem( aItem );
|
||||
}
|
||||
else if( aItem->IsBrightened() )
|
||||
{
|
||||
aItem->SetForceVisible( false );
|
||||
m_selectionTool->UnbrightenItem( aItem );
|
||||
}
|
||||
};
|
||||
auto visit =
|
||||
[&]( EDA_ITEM* aItem, SCH_SHEET_PATH* aSheet )
|
||||
{
|
||||
if( data && aItem->Matches( *data, aSheet ) )
|
||||
{
|
||||
aItem->SetForceVisible( true );
|
||||
m_selectionTool->BrightenItem( aItem );
|
||||
}
|
||||
else if( aItem->IsBrightened() )
|
||||
{
|
||||
aItem->SetForceVisible( false );
|
||||
m_selectionTool->UnbrightenItem( aItem );
|
||||
}
|
||||
};
|
||||
|
||||
if( aEvent.IsAction( &ACTIONS::find ) || aEvent.IsAction( &ACTIONS::findAndReplace )
|
||||
|| aEvent.IsAction( &ACTIONS::updateFind ) )
|
||||
|
@ -377,8 +378,8 @@ int SCH_EDITOR_CONTROL::FindNext( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
bool searchAllSheets = !( data->GetFlags() & FR_CURRENT_SHEET_ONLY );
|
||||
EE_SELECTION& selection = m_selectionTool->GetSelection();
|
||||
SCH_SCREEN* afterScreen = m_frame->GetScreen();
|
||||
EE_SELECTION& selection = m_selectionTool->GetSelection();
|
||||
SCH_SCREEN* afterScreen = m_frame->GetScreen();
|
||||
SCH_ITEM* afterItem = dynamic_cast<SCH_ITEM*>( selection.Front() );
|
||||
SCH_ITEM* item = nullptr;
|
||||
|
||||
|
@ -618,107 +619,107 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
|
|||
picker->SetCursor( KICURSOR::VOLTAGE_PROBE );
|
||||
|
||||
picker->SetClickHandler(
|
||||
[this, simFrame] ( const VECTOR2D& aPosition )
|
||||
{
|
||||
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
EDA_ITEM* item = nullptr;
|
||||
selTool->SelectPoint( aPosition, wiresAndPins, &item );
|
||||
|
||||
if( !item )
|
||||
return false;
|
||||
|
||||
if( item->IsType( wires ) )
|
||||
[this, simFrame]( const VECTOR2D& aPosition )
|
||||
{
|
||||
if( SCH_CONNECTION* conn = static_cast<SCH_ITEM*>( item )->Connection() )
|
||||
simFrame->AddVoltagePlot( UnescapeString( conn->Name() ) );
|
||||
}
|
||||
else if( item->Type() == SCH_PIN_T )
|
||||
{
|
||||
SCH_PIN* pin = (SCH_PIN*) item;
|
||||
SCH_COMPONENT* comp = (SCH_COMPONENT*) item->GetParent();
|
||||
wxString param;
|
||||
wxString primitive;
|
||||
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
EDA_ITEM* item = nullptr;
|
||||
selTool->SelectPoint( aPosition, wiresAndPins, &item );
|
||||
|
||||
primitive = NETLIST_EXPORTER_PSPICE::GetSpiceField( SF_PRIMITIVE, comp, 0 );
|
||||
primitive.LowerCase();
|
||||
if( !item )
|
||||
return false;
|
||||
|
||||
if( primitive == "c" || primitive == "l" || primitive == "r" )
|
||||
param = wxT( "I" );
|
||||
else if( primitive == "d" )
|
||||
param = wxT( "Id" );
|
||||
else
|
||||
param = wxString::Format( wxT( "I%s" ), pin->GetName().Lower() );
|
||||
if( item->IsType( wires ) )
|
||||
{
|
||||
if( SCH_CONNECTION* conn = static_cast<SCH_ITEM*>( item )->Connection() )
|
||||
simFrame->AddVoltagePlot( UnescapeString( conn->Name() ) );
|
||||
}
|
||||
else if( item->Type() == SCH_PIN_T )
|
||||
{
|
||||
SCH_PIN* pin = (SCH_PIN*) item;
|
||||
SCH_COMPONENT* comp = (SCH_COMPONENT*) item->GetParent();
|
||||
wxString param;
|
||||
wxString primitive;
|
||||
|
||||
simFrame->AddCurrentPlot( comp->GetRef( &m_frame->GetCurrentSheet() ), param );
|
||||
}
|
||||
primitive = NETLIST_EXPORTER_PSPICE::GetSpiceField( SF_PRIMITIVE, comp, 0 );
|
||||
primitive.LowerCase();
|
||||
|
||||
return true;
|
||||
} );
|
||||
if( primitive == "c" || primitive == "l" || primitive == "r" )
|
||||
param = wxT( "I" );
|
||||
else if( primitive == "d" )
|
||||
param = wxT( "Id" );
|
||||
else
|
||||
param = wxString::Format( wxT( "I%s" ), pin->GetName().Lower() );
|
||||
|
||||
simFrame->AddCurrentPlot( comp->GetRef( &m_frame->GetCurrentSheet() ), param );
|
||||
}
|
||||
|
||||
return true;
|
||||
} );
|
||||
|
||||
picker->SetMotionHandler(
|
||||
[this, picker] ( const VECTOR2D& aPos )
|
||||
{
|
||||
EE_COLLECTOR collector;
|
||||
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
||||
collector.Collect( m_frame->GetScreen(), wiresAndPins, (wxPoint) aPos );
|
||||
|
||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
selectionTool->GuessSelectionCandidates( collector, aPos );
|
||||
|
||||
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
||||
SCH_LINE* wire = dynamic_cast<SCH_LINE*>( item );
|
||||
|
||||
const SCH_CONNECTION* conn = nullptr;
|
||||
|
||||
if( wire )
|
||||
[this, picker]( const VECTOR2D& aPos )
|
||||
{
|
||||
item = nullptr;
|
||||
conn = wire->Connection();
|
||||
}
|
||||
EE_COLLECTOR collector;
|
||||
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
||||
collector.Collect( m_frame->GetScreen(), wiresAndPins, (wxPoint) aPos );
|
||||
|
||||
if( item && item->Type() == SCH_PIN_T )
|
||||
picker->SetCursor( KICURSOR::CURRENT_PROBE );
|
||||
else
|
||||
picker->SetCursor( KICURSOR::VOLTAGE_PROBE );
|
||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
selectionTool->GuessSelectionCandidates( collector, aPos );
|
||||
|
||||
if( m_pickerItem != item )
|
||||
{
|
||||
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
||||
SCH_LINE* wire = dynamic_cast<SCH_LINE*>( item );
|
||||
|
||||
if( m_pickerItem )
|
||||
selectionTool->UnbrightenItem( m_pickerItem );
|
||||
const SCH_CONNECTION* conn = nullptr;
|
||||
|
||||
m_pickerItem = item;
|
||||
if( wire )
|
||||
{
|
||||
item = nullptr;
|
||||
conn = wire->Connection();
|
||||
}
|
||||
|
||||
if( m_pickerItem )
|
||||
selectionTool->BrightenItem( m_pickerItem );
|
||||
}
|
||||
if( item && item->Type() == SCH_PIN_T )
|
||||
picker->SetCursor( KICURSOR::CURRENT_PROBE );
|
||||
else
|
||||
picker->SetCursor( KICURSOR::VOLTAGE_PROBE );
|
||||
|
||||
if( m_frame->GetHighlightedConnection() != conn )
|
||||
{
|
||||
m_frame->SetHighlightedConnection( conn );
|
||||
if( m_pickerItem != item )
|
||||
{
|
||||
|
||||
TOOL_EVENT dummyEvent;
|
||||
UpdateNetHighlighting( dummyEvent );
|
||||
}
|
||||
} );
|
||||
if( m_pickerItem )
|
||||
selectionTool->UnbrightenItem( m_pickerItem );
|
||||
|
||||
m_pickerItem = item;
|
||||
|
||||
if( m_pickerItem )
|
||||
selectionTool->BrightenItem( m_pickerItem );
|
||||
}
|
||||
|
||||
if( m_frame->GetHighlightedConnection() != conn )
|
||||
{
|
||||
m_frame->SetHighlightedConnection( conn );
|
||||
|
||||
TOOL_EVENT dummyEvent;
|
||||
UpdateNetHighlighting( dummyEvent );
|
||||
}
|
||||
} );
|
||||
|
||||
picker->SetFinalizeHandler(
|
||||
[this] ( const int& aFinalState )
|
||||
{
|
||||
if( m_pickerItem )
|
||||
m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
||||
|
||||
if( m_frame->GetHighlightedConnection() )
|
||||
[this]( const int& aFinalState )
|
||||
{
|
||||
m_frame->SetHighlightedConnection( nullptr );
|
||||
if( m_pickerItem )
|
||||
m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
||||
|
||||
TOOL_EVENT dummyEvent;
|
||||
UpdateNetHighlighting( dummyEvent );
|
||||
}
|
||||
if( m_frame->GetHighlightedConnection() )
|
||||
{
|
||||
m_frame->SetHighlightedConnection( nullptr );
|
||||
|
||||
// Wake the selection tool after exiting to ensure the cursor gets updated
|
||||
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
||||
} );
|
||||
TOOL_EVENT dummyEvent;
|
||||
UpdateNetHighlighting( dummyEvent );
|
||||
}
|
||||
|
||||
// Wake the selection tool after exiting to ensure the cursor gets updated
|
||||
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
||||
} );
|
||||
|
||||
std::string tool = aEvent.GetCommandStr().get();
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||
|
@ -737,65 +738,65 @@ int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
|
|||
picker->SetCursor( KICURSOR::TUNE );
|
||||
|
||||
picker->SetClickHandler(
|
||||
[this] ( const VECTOR2D& aPosition )
|
||||
{
|
||||
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
EDA_ITEM* item;
|
||||
selTool->SelectPoint( aPosition, fieldsAndComponents, &item );
|
||||
|
||||
if( !item )
|
||||
return false;
|
||||
|
||||
if( item->Type() != SCH_COMPONENT_T )
|
||||
[this]( const VECTOR2D& aPosition )
|
||||
{
|
||||
item = item->GetParent();
|
||||
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
EDA_ITEM* item;
|
||||
selTool->SelectPoint( aPosition, fieldsAndComponents, &item );
|
||||
|
||||
if( !item )
|
||||
return false;
|
||||
|
||||
if( item->Type() != SCH_COMPONENT_T )
|
||||
return false;
|
||||
}
|
||||
{
|
||||
item = item->GetParent();
|
||||
|
||||
SIM_PLOT_FRAME* simFrame =
|
||||
(SIM_PLOT_FRAME*) m_frame->Kiway().Player( FRAME_SIMULATOR, false );
|
||||
if( item->Type() != SCH_COMPONENT_T )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( simFrame )
|
||||
simFrame->AddTuner( static_cast<SCH_COMPONENT*>( item ) );
|
||||
SIM_PLOT_FRAME* simFrame =
|
||||
(SIM_PLOT_FRAME*) m_frame->Kiway().Player( FRAME_SIMULATOR, false );
|
||||
|
||||
return true;
|
||||
} );
|
||||
if( simFrame )
|
||||
simFrame->AddTuner( static_cast<SCH_COMPONENT*>( item ) );
|
||||
|
||||
return true;
|
||||
} );
|
||||
|
||||
picker->SetMotionHandler(
|
||||
[this] ( const VECTOR2D& aPos )
|
||||
{
|
||||
EE_COLLECTOR collector;
|
||||
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
||||
collector.Collect( m_frame->GetScreen(), fieldsAndComponents, (wxPoint) aPos );
|
||||
|
||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
selectionTool->GuessSelectionCandidates( collector, aPos );
|
||||
|
||||
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
||||
|
||||
if( m_pickerItem != item )
|
||||
[this]( const VECTOR2D& aPos )
|
||||
{
|
||||
if( m_pickerItem )
|
||||
selectionTool->UnbrightenItem( m_pickerItem );
|
||||
EE_COLLECTOR collector;
|
||||
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
||||
collector.Collect( m_frame->GetScreen(), fieldsAndComponents, (wxPoint) aPos );
|
||||
|
||||
m_pickerItem = item;
|
||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||
selectionTool->GuessSelectionCandidates( collector, aPos );
|
||||
|
||||
if( m_pickerItem )
|
||||
selectionTool->BrightenItem( m_pickerItem );
|
||||
}
|
||||
} );
|
||||
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
||||
|
||||
if( m_pickerItem != item )
|
||||
{
|
||||
if( m_pickerItem )
|
||||
selectionTool->UnbrightenItem( m_pickerItem );
|
||||
|
||||
m_pickerItem = item;
|
||||
|
||||
if( m_pickerItem )
|
||||
selectionTool->BrightenItem( m_pickerItem );
|
||||
}
|
||||
} );
|
||||
|
||||
picker->SetFinalizeHandler(
|
||||
[this] ( const int& aFinalState )
|
||||
{
|
||||
if( m_pickerItem )
|
||||
m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
||||
[this]( const int& aFinalState )
|
||||
{
|
||||
if( m_pickerItem )
|
||||
m_toolMgr->GetTool<EE_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
||||
|
||||
// Wake the selection tool after exiting to ensure the cursor gets updated
|
||||
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
||||
} );
|
||||
// Wake the selection tool after exiting to ensure the cursor gets updated
|
||||
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
||||
} );
|
||||
|
||||
std::string tool = aEvent.GetCommandStr().get();
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||
|
@ -844,7 +845,9 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
|
|||
conn = pins[0]->Connection();
|
||||
}
|
||||
else
|
||||
{
|
||||
conn = item->Connection();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -956,9 +959,7 @@ int SCH_EDITOR_CONTROL::AssignNetclass( const TOOL_EVENT& aEvent )
|
|||
NETCLASSPTR newNetclass = netSettings.m_NetClasses.Find( netclassName );
|
||||
|
||||
if( newNetclass )
|
||||
{
|
||||
newNetclass->Add( netName );
|
||||
}
|
||||
|
||||
netSettings.m_NetClassAssignments[ netName ] = netclassName;
|
||||
netSettings.ResolveNetClassAssignments();
|
||||
|
|
|
@ -182,14 +182,18 @@ bool SCH_LINE_WIRE_BUS_TOOL::Init()
|
|||
{
|
||||
EE_TOOL_BASE::Init();
|
||||
|
||||
auto wireOrBusTool = [ this ] ( const SELECTION& aSel ) {
|
||||
return ( m_frame->IsCurrentTool( EE_ACTIONS::drawWire )
|
||||
|| m_frame->IsCurrentTool( EE_ACTIONS::drawBus ) );
|
||||
};
|
||||
auto wireOrBusTool =
|
||||
[this]( const SELECTION& aSel )
|
||||
{
|
||||
return ( m_frame->IsCurrentTool( EE_ACTIONS::drawWire )
|
||||
|| m_frame->IsCurrentTool( EE_ACTIONS::drawBus ) );
|
||||
};
|
||||
|
||||
auto lineTool = [ this ] ( const SELECTION& aSel ) {
|
||||
return ( m_frame->IsCurrentTool( EE_ACTIONS::drawLines ) );
|
||||
};
|
||||
auto lineTool =
|
||||
[this]( const SELECTION& aSel )
|
||||
{
|
||||
return m_frame->IsCurrentTool( EE_ACTIONS::drawLines );
|
||||
};
|
||||
|
||||
auto belowRootSheetCondition =
|
||||
[&]( const SELECTION& aSel )
|
||||
|
@ -386,9 +390,9 @@ const SCH_SHEET_PIN* SCH_LINE_WIRE_BUS_TOOL::getSheetPin( const wxPoint& aPositi
|
|||
{
|
||||
SCH_SCREEN* screen = m_frame->GetScreen();
|
||||
|
||||
for( auto item : screen->Items().Overlapping( SCH_SHEET_T, aPosition ) )
|
||||
for( SCH_ITEM* item : screen->Items().Overlapping( SCH_SHEET_T, aPosition ) )
|
||||
{
|
||||
auto sheet = static_cast<SCH_SHEET*>( item );
|
||||
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
|
||||
|
||||
for( SCH_SHEET_PIN* pin : sheet->GetPins() )
|
||||
{
|
||||
|
@ -405,7 +409,7 @@ void SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint( const std::pair<SCH_LINE*, SCH_L
|
|||
wxPoint& aPosition )
|
||||
{
|
||||
wxCHECK_RET( aSegments.first && aSegments.second,
|
||||
wxT( "Cannot compute break point of NULL line segment." ) );
|
||||
wxT( "Cannot compute break point of NULL line segment." ) );
|
||||
|
||||
SCH_LINE* segment = aSegments.first;
|
||||
SCH_LINE* next_segment = aSegments.second;
|
||||
|
@ -415,7 +419,7 @@ void SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint( const std::pair<SCH_LINE*, SCH_L
|
|||
int iDy = segment->GetEndPoint().y - segment->GetStartPoint().y;
|
||||
|
||||
const SCH_SHEET_PIN* connectedPin = getSheetPin( segment->GetStartPoint() );
|
||||
auto force = connectedPin ? connectedPin->GetEdge() : SHEET_UNDEFINED_SIDE;
|
||||
SHEET_SIDE force = connectedPin ? connectedPin->GetEdge() : SHEET_UNDEFINED_SIDE;
|
||||
|
||||
if( force == SHEET_LEFT_SIDE || force == SHEET_RIGHT_SIDE )
|
||||
{
|
||||
|
@ -701,7 +705,7 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType,
|
|||
segment->SetEndPoint( cursorPos );
|
||||
}
|
||||
|
||||
for( auto wire : m_wires )
|
||||
for( SCH_LINE* wire : m_wires )
|
||||
{
|
||||
if( !wire->IsNull() )
|
||||
m_view->AddToPreview( wire->Clone() );
|
||||
|
@ -752,15 +756,9 @@ SCH_LINE* SCH_LINE_WIRE_BUS_TOOL::startSegments( int aType, const VECTOR2D& aPos
|
|||
|
||||
switch ( aType )
|
||||
{
|
||||
default:
|
||||
segment = new SCH_LINE( aPos, LAYER_NOTES );
|
||||
break;
|
||||
case LAYER_WIRE:
|
||||
segment = new SCH_LINE( aPos, LAYER_WIRE );
|
||||
break;
|
||||
case LAYER_BUS:
|
||||
segment = new SCH_LINE( aPos, LAYER_BUS );
|
||||
break;
|
||||
default: segment = new SCH_LINE( aPos, LAYER_NOTES ); break;
|
||||
case LAYER_WIRE: segment = new SCH_LINE( aPos, LAYER_WIRE ); break;
|
||||
case LAYER_BUS: segment = new SCH_LINE( aPos, LAYER_BUS ); break;
|
||||
}
|
||||
|
||||
// Give segments a parent so they find the default line/wire/bus widths
|
||||
|
@ -850,7 +848,7 @@ void SCH_LINE_WIRE_BUS_TOOL::finishSegments()
|
|||
std::vector< wxPoint > new_ends;
|
||||
|
||||
// Check each new segment for possible junctions and add/split if needed
|
||||
for( auto wire : m_wires )
|
||||
for( SCH_LINE* wire : m_wires )
|
||||
{
|
||||
if( wire->HasFlag( SKIP_STRUCT ) )
|
||||
continue;
|
||||
|
@ -859,10 +857,10 @@ void SCH_LINE_WIRE_BUS_TOOL::finishSegments()
|
|||
|
||||
new_ends.insert( new_ends.end(), tmpends.begin(), tmpends.end() );
|
||||
|
||||
for( auto i : connections )
|
||||
for( const wxPoint& pt : connections )
|
||||
{
|
||||
if( IsPointOnSegment( wire->GetStartPoint(), wire->GetEndPoint(), i ) )
|
||||
new_ends.push_back( i );
|
||||
if( IsPointOnSegment( wire->GetStartPoint(), wire->GetEndPoint(), pt ) )
|
||||
new_ends.push_back( pt );
|
||||
}
|
||||
itemList.PushItem( ITEM_PICKER( screen, wire, UNDO_REDO::NEWITEM ) );
|
||||
}
|
||||
|
@ -881,7 +879,7 @@ void SCH_LINE_WIRE_BUS_TOOL::finishSegments()
|
|||
m_frame->SaveCopyForRepeatItem( m_wires.back() );
|
||||
|
||||
// Add the new wires
|
||||
for( auto wire : m_wires )
|
||||
for( SCH_LINE* wire : m_wires )
|
||||
{
|
||||
wire->ClearFlags( IS_NEW | IS_MOVED );
|
||||
m_frame->AddToScreen( wire, screen );
|
||||
|
@ -899,24 +897,24 @@ void SCH_LINE_WIRE_BUS_TOOL::finishSegments()
|
|||
// Correct and remove segments that need to be merged.
|
||||
m_frame->SchematicCleanUp();
|
||||
|
||||
for( auto item : m_frame->GetScreen()->Items().OfType( SCH_COMPONENT_T ) )
|
||||
for( SCH_ITEM* item : m_frame->GetScreen()->Items().OfType( SCH_COMPONENT_T ) )
|
||||
{
|
||||
std::vector< wxPoint > pts = item->GetConnectionPoints();
|
||||
std::vector<wxPoint> pts = item->GetConnectionPoints();
|
||||
|
||||
if( pts.size() > 2 )
|
||||
continue;
|
||||
|
||||
for( auto i = pts.begin(); i != pts.end(); i++ )
|
||||
for( auto pt = pts.begin(); pt != pts.end(); pt++ )
|
||||
{
|
||||
for( auto j = i + 1; j != pts.end(); j++ )
|
||||
m_frame->TrimWire( *i, *j );
|
||||
for( auto secondPt = pt + 1; secondPt != pts.end(); secondPt++ )
|
||||
m_frame->TrimWire( *pt, *secondPt );
|
||||
}
|
||||
}
|
||||
|
||||
for( auto i : new_ends )
|
||||
for( const wxPoint& pt : new_ends )
|
||||
{
|
||||
if( m_frame->GetScreen()->IsJunctionNeeded( i, true ) )
|
||||
m_frame->AddJunction( m_frame->GetScreen(), i, true, false );
|
||||
if( m_frame->GetScreen()->IsJunctionNeeded( pt, true ) )
|
||||
m_frame->AddJunction( m_frame->GetScreen(), pt, true, false );
|
||||
}
|
||||
|
||||
if( m_busUnfold.in_progress )
|
||||
|
@ -938,7 +936,7 @@ int SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded( const TOOL_EVENT& aEvent )
|
|||
|
||||
for( unsigned ii = 0; ii < aSelection->GetSize(); ii++ )
|
||||
{
|
||||
SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aSelection->GetItem( ii ) );
|
||||
SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aSelection->GetItem( ii ) );
|
||||
|
||||
if( !item || !item->IsConnectable() )
|
||||
continue;
|
||||
|
@ -951,31 +949,34 @@ int SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded( const TOOL_EVENT& aEvent )
|
|||
if( item->Type() == SCH_LINE_T )
|
||||
{
|
||||
SCH_LINE* line = (SCH_LINE*) item;
|
||||
for( auto i : connections )
|
||||
|
||||
for( const wxPoint& pt : connections )
|
||||
{
|
||||
if( IsPointOnSegment( line->GetStartPoint(), line->GetEndPoint(), i ) )
|
||||
pts.push_back( i );
|
||||
if( IsPointOnSegment( line->GetStartPoint(), line->GetEndPoint(), pt ) )
|
||||
pts.push_back( pt );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clean up any wires that short non-wire connections in the list
|
||||
for( auto point = new_pts.begin(); point != new_pts.end(); point++ )
|
||||
for( auto pt = new_pts.begin(); pt != new_pts.end(); pt++ )
|
||||
{
|
||||
for( auto second_point = point + 1; second_point != new_pts.end(); second_point++ )
|
||||
m_frame->TrimWire( *point, *second_point );
|
||||
for( auto secondPt = pt + 1; secondPt != new_pts.end(); secondPt++ )
|
||||
m_frame->TrimWire( *pt, *secondPt );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We always have some overlapping connection points. Drop duplicates here
|
||||
std::sort( pts.begin(), pts.end(), []( const wxPoint& a, const wxPoint& b ) -> bool {
|
||||
return a.x < b.x || ( a.x == b.x && a.y < b.y );
|
||||
} );
|
||||
std::sort( pts.begin(), pts.end(),
|
||||
[]( const wxPoint& a, const wxPoint& b ) -> bool
|
||||
{
|
||||
return a.x < b.x || ( a.x == b.x && a.y < b.y );
|
||||
} );
|
||||
|
||||
pts.erase( unique( pts.begin(), pts.end() ), pts.end() );
|
||||
|
||||
for( auto point : pts )
|
||||
for( const wxPoint& point : pts )
|
||||
{
|
||||
if( m_frame->GetScreen()->IsJunctionNeeded( point, true ) )
|
||||
m_frame->AddJunction( m_frame->GetScreen(), point, true, false );
|
||||
|
|
Loading…
Reference in New Issue