Move SCH_EDIT_FRAME::GetSchematicConnections into SCH_SCREEN::GetConnections
This commit is contained in:
parent
64105dcf84
commit
7332c0c54d
|
@ -41,31 +41,6 @@
|
|||
#include <trigo.h>
|
||||
|
||||
|
||||
std::vector<VECTOR2I> SCH_EDIT_FRAME::GetSchematicConnections()
|
||||
{
|
||||
std::vector<VECTOR2I> retval;
|
||||
|
||||
for( SCH_ITEM* item : GetScreen()->Items() )
|
||||
{
|
||||
// Avoid items that are changing
|
||||
if( !( item->GetEditFlags() & ( IS_MOVING | IS_DELETED ) ) )
|
||||
{
|
||||
std::vector<VECTOR2I> pts = item->GetConnectionPoints();
|
||||
retval.insert( retval.end(), pts.begin(), pts.end() );
|
||||
}
|
||||
}
|
||||
|
||||
// We always have some overlapping connection points. Drop duplicates here
|
||||
std::sort( retval.begin(), retval.end(),
|
||||
[]( const VECTOR2I& a, const VECTOR2I& b ) -> bool
|
||||
{ return a.x < b.x || (a.x == b.x && a.y < b.y); } );
|
||||
retval.erase(
|
||||
std::unique( retval.begin(), retval.end() ), retval.end() );
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::TestDanglingEnds()
|
||||
{
|
||||
std::function<void( SCH_ITEM* )> changeHandler =
|
||||
|
|
|
@ -504,13 +504,6 @@ public:
|
|||
*/
|
||||
bool TrimWire( const VECTOR2I& aStart, const VECTOR2I& aEnd );
|
||||
|
||||
/**
|
||||
* Collect a unique list of all possible connection points in the schematic.
|
||||
*
|
||||
* @return vector of connections
|
||||
*/
|
||||
std::vector<VECTOR2I> GetSchematicConnections();
|
||||
|
||||
void OnOpenPcbnew( wxCommandEvent& event );
|
||||
void OnOpenCvpcb( wxCommandEvent& event );
|
||||
void OnUpdatePCB( wxCommandEvent& event );
|
||||
|
|
|
@ -1405,6 +1405,32 @@ std::vector<SCH_LINE*> SCH_SCREEN::GetBusesAndWires( const VECTOR2I& aPosition,
|
|||
}
|
||||
|
||||
|
||||
std::vector<VECTOR2I> SCH_SCREEN::GetConnections() const
|
||||
{
|
||||
std::vector<VECTOR2I> retval;
|
||||
|
||||
for( SCH_ITEM* item : Items() )
|
||||
{
|
||||
// Avoid items that are changing
|
||||
if( !( item->GetEditFlags() & ( IS_MOVING | IS_DELETED ) ) )
|
||||
{
|
||||
std::vector<VECTOR2I> pts = item->GetConnectionPoints();
|
||||
retval.insert( retval.end(), pts.begin(), pts.end() );
|
||||
}
|
||||
}
|
||||
|
||||
// We always have some overlapping connection points. Drop duplicates here
|
||||
std::sort( retval.begin(), retval.end(),
|
||||
[]( const VECTOR2I& a, const VECTOR2I& b ) -> bool
|
||||
{
|
||||
return a.x < b.x || ( a.x == b.x && a.y < b.y );
|
||||
} );
|
||||
retval.erase( std::unique( retval.begin(), retval.end() ), retval.end() );
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
SCH_LABEL_BASE* SCH_SCREEN::GetLabel( const VECTOR2I& aPosition, int aAccuracy ) const
|
||||
{
|
||||
for( SCH_ITEM* item : Items().Overlapping( aPosition, aAccuracy ) )
|
||||
|
|
|
@ -445,6 +445,13 @@ public:
|
|||
*/
|
||||
std::vector<SCH_LINE*> GetBusesAndWires( const VECTOR2I& aPosition, bool aIgnoreEndpoints = false ) const;
|
||||
|
||||
/**
|
||||
* Collect a unique list of all possible connection points in the schematic.
|
||||
*
|
||||
* @return vector of connections
|
||||
*/
|
||||
std::vector<VECTOR2I> GetConnections() const;
|
||||
|
||||
/**
|
||||
* Return a label item located at \a aPosition.
|
||||
*
|
||||
|
|
|
@ -1138,7 +1138,7 @@ void SCH_LINE_WIRE_BUS_TOOL::finishSegments()
|
|||
simplifyWireList();
|
||||
|
||||
// Collect the possible connection points for the new lines
|
||||
std::vector<VECTOR2I> connections = m_frame->GetSchematicConnections();
|
||||
std::vector<VECTOR2I> connections = screen->GetConnections();
|
||||
std::vector<VECTOR2I> new_ends;
|
||||
|
||||
// Check each new segment for possible junctions and add/split if needed
|
||||
|
@ -1286,13 +1286,15 @@ int SCH_LINE_WIRE_BUS_TOOL::TrimOverLappingWires( EE_SELECTION* aSelection )
|
|||
|
||||
int SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded( EE_SELECTION* aSelection )
|
||||
{
|
||||
SCH_SCREEN* screen = m_frame->GetScreen();
|
||||
|
||||
std::vector<VECTOR2I> pts;
|
||||
std::vector<VECTOR2I> connections = m_frame->GetSchematicConnections();
|
||||
std::vector<VECTOR2I> connections = screen->GetConnections();
|
||||
|
||||
std::set<SCH_LINE*> lines;
|
||||
BOX2I bb = aSelection->GetBoundingBox();
|
||||
|
||||
for( EDA_ITEM* item : m_frame->GetScreen()->Items().Overlapping( SCH_LINE_T, bb ) )
|
||||
for( EDA_ITEM* item : screen->Items().Overlapping( SCH_LINE_T, bb ) )
|
||||
lines.insert( static_cast<SCH_LINE*>( item ) );
|
||||
|
||||
for( unsigned ii = 0; ii < aSelection->GetSize(); ii++ )
|
||||
|
@ -1330,7 +1332,7 @@ int SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded( EE_SELECTION* aSelection )
|
|||
|
||||
for( const VECTOR2I& point : pts )
|
||||
{
|
||||
if( m_frame->GetScreen()->IsExplicitJunctionNeeded( point ) )
|
||||
if( screen->IsExplicitJunctionNeeded( point ) )
|
||||
m_frame->AddJunction( m_frame->GetScreen(), point, true, false );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue