More cleanup.
This commit is contained in:
parent
32765ebffd
commit
2d28ab7dd2
|
@ -179,7 +179,6 @@ set( EESCHEMA_SRCS
|
|||
netlist_generator.cpp
|
||||
netlist_object_list.cpp
|
||||
netlist_object.cpp
|
||||
operations_on_items_lists.cpp
|
||||
pin_number.cpp
|
||||
pin_shape.cpp
|
||||
pin_type.cpp
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2009 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2014-2019 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <pgm_base.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <general.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_component.h>
|
||||
#include <sch_line.h>
|
||||
#include <tool/selection.h>
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::CheckConnections( SELECTION& aSelection, bool aUndoAppend )
|
||||
{
|
||||
std::vector< wxPoint > pts;
|
||||
std::vector< wxPoint > connections;
|
||||
|
||||
GetSchematicConnections( connections );
|
||||
for( unsigned ii = 0; ii < aSelection.GetSize(); ii++ )
|
||||
{
|
||||
SCH_ITEM* item = static_cast<SCH_ITEM*>( aSelection.GetItem( ii ) );
|
||||
std::vector< wxPoint > new_pts;
|
||||
|
||||
if( !item->IsConnectable() )
|
||||
continue;
|
||||
|
||||
item->GetConnectionPoints( new_pts );
|
||||
pts.insert( pts.end(), new_pts.begin(), new_pts.end() );
|
||||
|
||||
// If the item is a line, we also add any connection points from the rest of the schematic
|
||||
// that terminate on the line after it is moved.
|
||||
if( item->Type() == SCH_LINE_T )
|
||||
{
|
||||
SCH_LINE* line = (SCH_LINE*) item;
|
||||
for( auto i : connections )
|
||||
if( IsPointOnSegment( line->GetStartPoint(), line->GetEndPoint(), i ) )
|
||||
pts.push_back( i );
|
||||
}
|
||||
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 second_point = point + 1; second_point != new_pts.end(); second_point++ )
|
||||
{
|
||||
aUndoAppend |= TrimWire( *point, *second_point, aUndoAppend );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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); } );
|
||||
pts.erase( unique( pts.begin(), pts.end() ), pts.end() );
|
||||
|
||||
for( auto point : pts )
|
||||
{
|
||||
if( GetScreen()->IsJunctionNeeded( point, true ) )
|
||||
{
|
||||
AddJunction( point, aUndoAppend );
|
||||
aUndoAppend = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -134,7 +134,6 @@ private:
|
|||
BLOCK_SELECTOR m_blockItems; ///< List of selected items.
|
||||
SCH_ITEM* m_item_to_repeat; ///< Last item to insert by the repeat command.
|
||||
int m_repeatLabelDelta; ///< Repeat label number increment step.
|
||||
SCH_COLLECTOR m_collectedItems; ///< List of collected items.
|
||||
SCH_FIND_COLLECTOR m_foundItems; ///< List of find/replace items.
|
||||
SCH_ITEM* m_undoItem; ///< Copy of the current item being edited.
|
||||
wxString m_simulatorCommand; ///< Command line used to call the circuit
|
||||
|
@ -969,15 +968,6 @@ public:
|
|||
*/
|
||||
void DeleteJunction( SCH_ITEM* aItem, bool aAppend = false );
|
||||
|
||||
/**
|
||||
* Adds junctions if needed to each item in the list after they have been
|
||||
* moved.
|
||||
*
|
||||
* @param aItemsList The list of items to check
|
||||
* @param aUndoAppend True if we are updating a previous commit
|
||||
*/
|
||||
void CheckConnections( SELECTION& aSelection, bool aUndoAppend = false );
|
||||
|
||||
int GetLabelIncrement() const { return m_repeatLabelDelta; }
|
||||
|
||||
/**
|
||||
|
@ -1079,14 +1069,6 @@ private:
|
|||
*/
|
||||
void GetSchematicFromUndoList( wxCommandEvent& event );
|
||||
|
||||
/**
|
||||
* Add the context menu items to \a aMenu for \a aJunction.
|
||||
*
|
||||
* @param aMenu The menu to add the items to.
|
||||
* @param aJunction The SCH_JUNCTION object selected.
|
||||
*/
|
||||
void addJunctionMenuEntries( wxMenu* aMenu, SCH_JUNCTION* aJunction );
|
||||
|
||||
public:
|
||||
/**
|
||||
* Initialize the parameters used by the block paste command.
|
||||
|
|
|
@ -175,6 +175,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
|
||||
bool restore_state = false;
|
||||
bool chain_commands = false;
|
||||
bool appendUndo = false;
|
||||
OPT_TOOL_EVENT evt = aEvent;
|
||||
VECTOR2I prevPos;
|
||||
|
||||
|
@ -230,9 +231,6 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
m_selectionTool->AddItemsToSel( &dragAdditions, QUIET_MODE );
|
||||
|
||||
for( EDA_ITEM* item : dragAdditions )
|
||||
saveCopyInUndoList( (SCH_ITEM*) item, UR_CHANGED, true );
|
||||
}
|
||||
|
||||
// Mark the edges of the block with dangling flags for a move.
|
||||
|
@ -250,7 +248,6 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
|
||||
// Generic setup
|
||||
//
|
||||
bool first = true;
|
||||
for( EDA_ITEM* item : selection )
|
||||
{
|
||||
if( item->IsNew() || ( item->GetParent() && item->GetParent()->IsSelected() ) )
|
||||
|
@ -259,8 +256,8 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
saveCopyInUndoList( (SCH_ITEM*) item, UR_CHANGED, !first );
|
||||
first = false;
|
||||
saveCopyInUndoList( (SCH_ITEM*) item, UR_CHANGED, appendUndo );
|
||||
appendUndo = true;
|
||||
}
|
||||
|
||||
// Apply any initial offset in case we're coming from a previous command.
|
||||
|
@ -434,7 +431,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->CheckConnections( selection, true );
|
||||
addJunctionsIfNeeded( selection, &appendUndo );
|
||||
m_frame->SchematicCleanUp( true );
|
||||
m_frame->TestDanglingEnds();
|
||||
m_frame->OnModify();
|
||||
|
@ -514,6 +511,61 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aItem, wxPoint aPoint, EDA_
|
|||
}
|
||||
|
||||
|
||||
void SCH_MOVE_TOOL::addJunctionsIfNeeded( SELECTION& aSelection, bool* aAppendUndo )
|
||||
{
|
||||
std::vector< wxPoint > pts;
|
||||
std::vector< wxPoint > connections;
|
||||
|
||||
m_frame->GetSchematicConnections( connections );
|
||||
|
||||
for( unsigned ii = 0; ii < aSelection.GetSize(); ii++ )
|
||||
{
|
||||
SCH_ITEM* item = static_cast<SCH_ITEM*>( aSelection.GetItem( ii ) );
|
||||
std::vector< wxPoint > new_pts;
|
||||
|
||||
if( !item->IsConnectable() )
|
||||
continue;
|
||||
|
||||
item->GetConnectionPoints( new_pts );
|
||||
pts.insert( pts.end(), new_pts.begin(), new_pts.end() );
|
||||
|
||||
// If the item is a line, we also add any connection points from the rest of the schematic
|
||||
// that terminate on the line after it is moved.
|
||||
if( item->Type() == SCH_LINE_T )
|
||||
{
|
||||
SCH_LINE* line = (SCH_LINE*) item;
|
||||
for( auto i : connections )
|
||||
if( IsPointOnSegment( line->GetStartPoint(), line->GetEndPoint(), i ) )
|
||||
pts.push_back( i );
|
||||
}
|
||||
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 second_point = point + 1; second_point != new_pts.end(); second_point++ )
|
||||
*aAppendUndo |= m_frame->TrimWire( *point, *second_point, *aAppendUndo );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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); } );
|
||||
|
||||
pts.erase( unique( pts.begin(), pts.end() ), pts.end() );
|
||||
|
||||
for( auto point : pts )
|
||||
{
|
||||
if( m_frame->GetScreen()->IsJunctionNeeded( point, true ) )
|
||||
{
|
||||
m_frame->AddJunction( point, aAppendUndo );
|
||||
*aAppendUndo = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SCH_MOVE_TOOL::moveItem( SCH_ITEM* aItem, VECTOR2I aDelta, bool isDrag )
|
||||
{
|
||||
switch( aItem->Type() )
|
||||
|
|
|
@ -63,6 +63,10 @@ private:
|
|||
///> Connected wires are included with any un-connected ends flagged (STARTPOINT or ENDPOINT).
|
||||
void getConnectedDragItems( SCH_ITEM* aItem, wxPoint aPoint, EDA_ITEMS& aList );
|
||||
|
||||
///> Adds junctions if needed to each item in the list after they have been
|
||||
///> moved.
|
||||
void addJunctionsIfNeeded( SELECTION& aSelection, bool* aAppendUndo );
|
||||
|
||||
///> Returns the right modification point (e.g. for rotation), depending on the number of
|
||||
///> selected items.
|
||||
bool updateModificationPoint( SELECTION& aSelection );
|
||||
|
|
Loading…
Reference in New Issue