More sharing between SchEdit and LibEdit.

This commit is contained in:
Jeff Young 2019-05-10 20:22:26 +01:00
parent 717b1d37be
commit 0c2ba94b16
16 changed files with 64 additions and 69 deletions

View File

@ -194,7 +194,7 @@ jp charras:
* Add item clarification context menu to EESchema when multiple unresolved
items are found at the current cross hair position.
* Add collector class SCH_COLLECTOR for supporting multiple item hit testing.
* Add collector class EE_COLLECTOR for supporting multiple item hit testing.
* Removed bit wise masked filtering from schematic item hit testing.
* Removed all old hit testing functions and methods scattered about the
EESchema source code.

View File

@ -186,7 +186,7 @@ set( EESCHEMA_SRCS
sch_base_frame.cpp
sch_bitmap.cpp
sch_bus_entry.cpp
sch_collectors.cpp
ee_collectors.cpp
sch_component.cpp
sch_connection.cpp
sch_eagle_plugin.cpp

View File

@ -27,19 +27,19 @@
#include <sch_sheet_path.h>
#include <transform.h>
#include <sch_collectors.h>
#include <ee_collectors.h>
#include <sch_component.h>
#include <sch_line.h>
#include <sch_bus_entry.h>
const KICAD_T SCH_COLLECTOR::AllItems[] = {
const KICAD_T EE_COLLECTOR::AllItems[] = {
SCH_LOCATE_ANY_T,
EOT
};
const KICAD_T SCH_COLLECTOR::EditableItems[] = {
const KICAD_T EE_COLLECTOR::EditableItems[] = {
SCH_TEXT_T,
SCH_LABEL_T,
SCH_GLOBAL_LABEL_T,
@ -53,7 +53,7 @@ const KICAD_T SCH_COLLECTOR::EditableItems[] = {
EOT
};
const KICAD_T SCH_COLLECTOR::RotatableItems[] = {
const KICAD_T EE_COLLECTOR::RotatableItems[] = {
SCH_TEXT_T,
SCH_LABEL_T,
SCH_GLOBAL_LABEL_T,
@ -70,26 +70,26 @@ const KICAD_T SCH_COLLECTOR::RotatableItems[] = {
};
const KICAD_T SCH_COLLECTOR::ComponentsOnly[] = {
const KICAD_T EE_COLLECTOR::ComponentsOnly[] = {
SCH_COMPONENT_T,
EOT
};
const KICAD_T SCH_COLLECTOR::SheetsOnly[] = {
const KICAD_T EE_COLLECTOR::SheetsOnly[] = {
SCH_SHEET_T,
EOT
};
const KICAD_T SCH_COLLECTOR::SheetsAndSheetLabels[] = {
const KICAD_T EE_COLLECTOR::SheetsAndSheetLabels[] = {
SCH_SHEET_PIN_T,
SCH_SHEET_T,
EOT
};
SEARCH_RESULT SCH_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData )
SEARCH_RESULT EE_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData )
{
if( aItem->Type() == LIB_PIN_T )
{
@ -115,7 +115,7 @@ SEARCH_RESULT SCH_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData )
}
void SCH_COLLECTOR::Collect( EDA_ITEM* aItem, const KICAD_T aFilterList[], const wxPoint& aPos,
void EE_COLLECTOR::Collect( EDA_ITEM* aItem, const KICAD_T aFilterList[], const wxPoint& aPos,
int aUnit, int aConvert )
{
Empty(); // empty the collection just in case
@ -134,7 +134,7 @@ void SCH_COLLECTOR::Collect( EDA_ITEM* aItem, const KICAD_T aFilterList[], const
}
bool SCH_COLLECTOR::IsCorner() const
bool EE_COLLECTOR::IsCorner() const
{
if( GetCount() != 2 )
return false;
@ -155,7 +155,7 @@ bool SCH_COLLECTOR::IsCorner() const
}
bool SCH_COLLECTOR::IsDraggableJunction() const
bool EE_COLLECTOR::IsDraggableJunction() const
{
for( size_t i = 0; i < m_List.size(); i++ )
if( ( (SCH_ITEM*) m_List[ i ] )->Type() == SCH_JUNCTION_T )
@ -230,7 +230,7 @@ SCH_ITEM* SCH_FIND_COLLECTOR::GetItem( int ndx ) const
for( unsigned i = 0; i < m_sheetPaths.size(); i++ )
{
EDA_ITEM::IterateForward( m_sheetPaths[ i ].LastDrawList(),
inspector, nullptr, SCH_COLLECTOR::AllItems );
inspector, nullptr, EE_COLLECTOR::AllItems );
}
return item;
@ -453,7 +453,7 @@ void SCH_FIND_COLLECTOR::Collect( SCH_FIND_REPLACE_DATA& aFindReplaceData,
}
SEARCH_RESULT SCH_TYPE_COLLECTOR::Inspect( EDA_ITEM* aItem, void* testData )
SEARCH_RESULT EE_TYPE_COLLECTOR::Inspect( EDA_ITEM* aItem, void* testData )
{
// The Vist() function only visits the testItem if its type was in the
// the scanList, so therefore we can collect anything given to us here.
@ -463,7 +463,7 @@ SEARCH_RESULT SCH_TYPE_COLLECTOR::Inspect( EDA_ITEM* aItem, void* testData )
}
void SCH_TYPE_COLLECTOR::Collect( SCH_ITEM* aItem, const KICAD_T aFilterList[] )
void EE_TYPE_COLLECTOR::Collect( SCH_ITEM* aItem, const KICAD_T aFilterList[] )
{
Empty(); // empty the collection

View File

@ -22,8 +22,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _SCH_COLLECTORS_H_
#define _SCH_COLLECTORS_H_
#ifndef EE_COLLECTORS_H
#define EE_COLLECTORS_H
#include <collector.h>
@ -33,9 +33,9 @@
/**
* Class SCH_COLLECTOR
* Class EE_COLLECTOR
*/
class SCH_COLLECTOR : public COLLECTOR
class EE_COLLECTOR : public COLLECTOR
{
public:
static const KICAD_T AllItems[];
@ -45,10 +45,7 @@ public:
static const KICAD_T SheetsOnly[];
static const KICAD_T SheetsAndSheetLabels[];
/**
* Constructor SCH_COLLECTOR
*/
SCH_COLLECTOR( const KICAD_T* aScanTypes = SCH_COLLECTOR::AllItems ) :
EE_COLLECTOR( const KICAD_T* aScanTypes = EE_COLLECTOR::AllItems ) :
m_MenuCancelled( false )
{
SetScanTypes( aScanTypes );
@ -191,7 +188,7 @@ public:
/**
* Constructor SCH_FIND_COLLECTOR
*/
SCH_FIND_COLLECTOR( const KICAD_T* aScanTypes = SCH_COLLECTOR::AllItems )
SCH_FIND_COLLECTOR( const KICAD_T* aScanTypes = EE_COLLECTOR::AllItems )
{
SetScanTypes( aScanTypes );
m_foundIndex = 0;
@ -313,13 +310,13 @@ public:
/**
* Class TYPE_COLLECTOR
* Class EE_TYPE_COLLECTOR
* merely gathers up all SCH_ITEMs of a given set of KICAD_T type(s). It does
* no hit-testing.
*
* @see class COLLECTOR
*/
class SCH_TYPE_COLLECTOR : public SCH_COLLECTOR
class EE_TYPE_COLLECTOR : public EE_COLLECTOR
{
public:
/**
@ -339,8 +336,8 @@ public:
* @param aItem The head of a DLIST to scan.
* @param aScanList The KICAD_Ts to gather up.
*/
void Collect( SCH_ITEM* aItem, const KICAD_T aScanList[] );
void Collect( EDA_ITEM* aItem, const KICAD_T aScanList[] );
};
#endif // _SCH_COLLECTORS_H_
#endif // EE_COLLECTORS_H

View File

@ -606,9 +606,9 @@ bool SCH_EDIT_FRAME::AppendSchematic()
// Check for duplicate sheet names in the current page.
wxArrayString duplicateSheetNames;
SCH_TYPE_COLLECTOR sheets;
EE_TYPE_COLLECTOR sheets;
sheets.Collect( screen->GetDrawItems(), SCH_COLLECTOR::SheetsOnly );
sheets.Collect( screen->GetDrawItems(), EE_COLLECTOR::SheetsOnly );
for( int i = 0; i < sheets.GetCount(); ++i )
{
@ -853,12 +853,12 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
GetScreen()->m_Initialized = true;
SCH_TYPE_COLLECTOR components;
EE_TYPE_COLLECTOR components;
SCH_SCREENS allScreens;
for( SCH_SCREEN* screen = allScreens.GetFirst(); screen; screen = allScreens.GetNext() )
{
components.Collect( screen->GetDrawItems(), SCH_COLLECTOR::ComponentsOnly );
components.Collect( screen->GetDrawItems(), EE_COLLECTOR::ComponentsOnly );
for( int cmpIdx = 0; cmpIdx < components.GetCount(); ++cmpIdx )
{

View File

@ -31,7 +31,7 @@
#include <sch_base_frame.h>
#include <sch_screen.h>
#include <lib_draw_item.h>
#include <sch_collectors.h>
#include <ee_collectors.h>
#include <core/optional.h>
class SCH_EDIT_FRAME;
@ -51,7 +51,6 @@ class LIB_MANAGER;
class LIB_EDIT_FRAME : public SCH_BASE_FRAME
{
LIB_PART* m_my_part; ///< a part I own, it is not in any library, but a copy could be.
SCH_COLLECTOR m_collectedItems; ///< Used for hit testing.
wxComboBox* m_partSelectBox; ///< a Box to select a part to edit (if any)
SYMBOL_TREE_PANE* m_treePane; ///< component search tree widget
LIB_MANAGER* m_libMgr; ///< manager taking care of temporary modificatoins

View File

@ -388,7 +388,7 @@ static bool sort_by_libid( const SCH_COMPONENT* ref, SCH_COMPONENT* cmp )
}
void SCH_COMPONENT::ResolveAll( const SCH_COLLECTOR& aComponents, SYMBOL_LIB_TABLE& aLibTable,
void SCH_COMPONENT::ResolveAll( const EE_COLLECTOR& aComponents, SYMBOL_LIB_TABLE& aLibTable,
PART_LIB* aCacheLib )
{
std::vector<SCH_COMPONENT*> cmp_list;
@ -432,7 +432,7 @@ void SCH_COMPONENT::ResolveAll( const SCH_COLLECTOR& aComponents, SYMBOL_LIB_TAB
}
void SCH_COMPONENT::UpdatePins( const SCH_COLLECTOR& aComponents )
void SCH_COMPONENT::UpdatePins( const EE_COLLECTOR& aComponents )
{
for( int i = 0; i < aComponents.GetCount(); ++i )
{

View File

@ -46,7 +46,7 @@ class LIB_PART;
class NETLIST_OBJECT_LIST;
class PART_LIB;
class PART_LIBS;
class SCH_COLLECTOR;
class EE_COLLECTOR;
class SCH_SCREEN;
class SYMBOL_LIB_TABLE;
@ -199,7 +199,7 @@ public:
bool Resolve( SYMBOL_LIB_TABLE& aLibTable, PART_LIB* aCacheLib = NULL );
static void ResolveAll( const SCH_COLLECTOR& aComponents, SYMBOL_LIB_TABLE& aLibTable,
static void ResolveAll( const EE_COLLECTOR& aComponents, SYMBOL_LIB_TABLE& aLibTable,
PART_LIB* aCacheLib = NULL );
int GetUnit() const { return m_unit; }
@ -209,7 +209,7 @@ public:
*
* @param aComponents collector of components in screen
*/
static void UpdatePins( const SCH_COLLECTOR& aComponents );
static void UpdatePins( const EE_COLLECTOR& aComponents );
/**
* Updates the local cache of SCH_PIN_CONNECTION objects for each pin

View File

@ -31,7 +31,7 @@
#include <undo_redo_container.h>
#include <template_fieldnames.h>
#include <block_commande.h>
#include <sch_collectors.h>
#include <ee_collectors.h>
#include <tool/selection.h>
#include <erc_settings.h>
#include <sch_draw_panel.h>

View File

@ -508,9 +508,9 @@ void SCH_SCREEN::UpdateSymbolLinks( bool aForce )
{
SYMBOL_LIB_TABLE* libs = Prj().SchSymbolLibTable();
int mod_hash = libs->GetModifyHash();
SCH_TYPE_COLLECTOR c;
EE_TYPE_COLLECTOR c;
c.Collect( GetDrawItems(), SCH_COLLECTOR::ComponentsOnly );
c.Collect( GetDrawItems(), EE_COLLECTOR::ComponentsOnly );
// Must we resolve?
if( (m_modification_sync != mod_hash) || aForce )

View File

@ -90,7 +90,7 @@ void EE_INSPECTION_TOOL::Reset( RESET_REASON aReason )
int EE_INSPECTION_TOOL::ShowDatasheet( const TOOL_EVENT& aEvent )
{
SELECTION& selection = m_selectionTool->RequestSelection( SCH_COLLECTOR::ComponentsOnly );
SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::ComponentsOnly );
if( selection.Empty() )
return 0;

View File

@ -40,7 +40,7 @@
#include <tool/tool_manager.h>
#include <tools/sch_wire_bus_tool.h>
#include <ee_actions.h>
#include <sch_collectors.h>
#include <ee_collectors.h>
#include <painter.h>
#include <eeschema_id.h>
#include <menus_helpers.h>
@ -314,7 +314,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
if( m_selection.Empty() )
{
SelectPoint( evt->Position(), SCH_COLLECTOR::AllItems, &selectionCancelled );
SelectPoint( evt->Position(), EE_COLLECTOR::AllItems, &selectionCancelled );
m_selection.SetIsHover( true );
}
@ -414,7 +414,7 @@ EDA_ITEM* EE_SELECTION_TOOL::SelectPoint( const VECTOR2I& aWhere, const KICAD_T*
bool* aSelectionCancelledFlag, bool aCheckLocked )
{
EDA_ITEM* start;
SCH_COLLECTOR collector;
EE_COLLECTOR collector;
if( m_isLibEdit )
start = static_cast<LIB_EDIT_FRAME*>( m_frame )->GetCurPart();
@ -478,8 +478,7 @@ EDA_ITEM* EE_SELECTION_TOOL::SelectPoint( const VECTOR2I& aWhere, const KICAD_T*
}
void EE_SELECTION_TOOL::guessSelectionCandidates( SCH_COLLECTOR& collector,
const VECTOR2I& aWhere )
void EE_SELECTION_TOOL::guessSelectionCandidates( EE_COLLECTOR& collector, const VECTOR2I& aPos )
{
// There are certain parent/child and enclosure combinations that can be handled
// automatically. Since schematics are meant to be human-readable we don't have
@ -647,7 +646,7 @@ static KICAD_T nodeTypes[] =
EDA_ITEM* EE_SELECTION_TOOL::GetNode( VECTOR2I aPosition )
{
SCH_COLLECTOR collector;
EE_COLLECTOR collector;
collector.Collect( m_frame->GetScreen()->GetDrawItems(), nodeTypes, (wxPoint) aPosition );
@ -785,7 +784,7 @@ int EE_SELECTION_TOOL::ClearSelection( const TOOL_EVENT& aEvent )
int EE_SELECTION_TOOL::SelectionMenu( const TOOL_EVENT& aEvent )
{
SCH_COLLECTOR* collector = aEvent.Parameter<SCH_COLLECTOR*>();
EE_COLLECTOR* collector = aEvent.Parameter<EE_COLLECTOR*>();
if( !doSelectionMenu( collector ) )
collector->m_MenuCancelled = true;
@ -794,7 +793,7 @@ int EE_SELECTION_TOOL::SelectionMenu( const TOOL_EVENT& aEvent )
}
bool EE_SELECTION_TOOL::doSelectionMenu( SCH_COLLECTOR* aCollector )
bool EE_SELECTION_TOOL::doSelectionMenu( EE_COLLECTOR* aCollector )
{
EDA_ITEM* current = nullptr;
CONTEXT_MENU menu;

View File

@ -28,12 +28,12 @@
#include <tool/context_menu.h>
#include <tool/selection.h>
#include <tool/tool_menu.h>
#include <sch_collectors.h>
#include <ee_collectors.h>
#include <sch_component.h>
class SCH_BASE_FRAME;
class SCH_ITEM;
class SCH_COLLECTOR;
class EE_COLLECTOR;
namespace KIGFX
{
@ -88,7 +88,7 @@ public:
* Returns either an existing selection (filtered), or the selection at the current
* cursor if the existing selection is empty.
*/
SELECTION& RequestSelection( const KICAD_T* aFilterList = SCH_COLLECTOR::AllItems );
SELECTION& RequestSelection( const KICAD_T* aFilterList = EE_COLLECTOR::AllItems );
/**
* Function selectPoint()
@ -101,7 +101,7 @@ public:
* @param aCheckLocked indicates if locked items should be excluded
*/
EDA_ITEM* SelectPoint( const VECTOR2I& aWhere,
const KICAD_T* aFilterList = SCH_COLLECTOR::AllItems,
const KICAD_T* aFilterList = EE_COLLECTOR::AllItems,
bool* aSelectionCancelledFlag = NULL, bool aCheckLocked = false );
int AddItemToSel( const TOOL_EVENT& aEvent );
@ -149,7 +149,7 @@ private:
* Apply heuristics to try and determine a single object when multiple are found under the
* cursor.
*/
void guessSelectionCandidates( SCH_COLLECTOR& collector, const VECTOR2I& aWhere );
void guessSelectionCandidates( EE_COLLECTOR& collector, const VECTOR2I& aWhere );
/**
* Allows the selection of a single item from a list via pop-up menu. The items are
@ -157,7 +157,7 @@ private:
* the picked item.
* @return true if an item was picked
*/
bool doSelectionMenu( SCH_COLLECTOR* aItems );
bool doSelectionMenu( EE_COLLECTOR* aItems );
/**
* Function clearSelection()

View File

@ -681,7 +681,7 @@ int SCH_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType )
item = m_frame->CreateNewText( LAYER_NOTES );
break;
case SCH_SHEET_PIN_T:
item = m_selectionTool->SelectPoint( cursorPos, SCH_COLLECTOR::SheetsAndSheetLabels );
item = m_selectionTool->SelectPoint( cursorPos, EE_COLLECTOR::SheetsAndSheetLabels );
if( item )
{

View File

@ -466,7 +466,7 @@ void SCH_EDIT_TOOL::Reset( RESET_REASON aReason )
int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
{
SELECTION& selection = m_selectionTool->RequestSelection( SCH_COLLECTOR::RotatableItems );
SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::RotatableItems );
if( selection.GetSize() == 0 )
return 0;
@ -606,7 +606,7 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
int SCH_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
{
SELECTION& selection = m_selectionTool->RequestSelection( SCH_COLLECTOR::RotatableItems );
SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::RotatableItems );
if( selection.GetSize() == 0 )
return 0;
@ -1056,7 +1056,7 @@ int SCH_EDIT_TOOL::EditField( const TOOL_EVENT& aEvent )
int SCH_EDIT_TOOL::AutoplaceFields( const TOOL_EVENT& aEvent )
{
SELECTION& selection = m_selectionTool->RequestSelection( SCH_COLLECTOR::ComponentsOnly );
SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::ComponentsOnly );
if( selection.Empty() )
return 0;
@ -1077,7 +1077,7 @@ int SCH_EDIT_TOOL::AutoplaceFields( const TOOL_EVENT& aEvent )
int SCH_EDIT_TOOL::ConvertDeMorgan( const TOOL_EVENT& aEvent )
{
SELECTION& selection = m_selectionTool->RequestSelection( SCH_COLLECTOR::ComponentsOnly );
SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::ComponentsOnly );
if( selection.Empty() )
return 0;
@ -1097,7 +1097,7 @@ int SCH_EDIT_TOOL::ConvertDeMorgan( const TOOL_EVENT& aEvent )
int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
{
SELECTION& selection = m_selectionTool->RequestSelection( SCH_COLLECTOR::EditableItems );
SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::EditableItems );
if( selection.Empty() )
return 0;
@ -1264,7 +1264,7 @@ int SCH_EDIT_TOOL::BreakWire( const TOOL_EVENT& aEvent )
int SCH_EDIT_TOOL::CleanupSheetPins( const TOOL_EVENT& aEvent )
{
SELECTION& selection = m_selectionTool->RequestSelection( SCH_COLLECTOR::SheetsOnly );
SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
if( !sheet )

View File

@ -665,7 +665,7 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
int SCH_EDITOR_CONTROL::EditWithSymbolEditor( const TOOL_EVENT& aEvent )
{
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
SELECTION& selection = selTool->RequestSelection( SCH_COLLECTOR::ComponentsOnly );
SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::ComponentsOnly );
SCH_COMPONENT* comp = nullptr;
if( selection.GetSize() >= 1 )
@ -692,7 +692,7 @@ int SCH_EDITOR_CONTROL::EditWithSymbolEditor( const TOOL_EVENT& aEvent )
int SCH_EDITOR_CONTROL::EnterSheet( const TOOL_EVENT& aEvent )
{
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
const SELECTION& selection = selTool->RequestSelection( SCH_COLLECTOR::SheetsOnly );
const SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
if( selection.GetSize() == 1 )
{