Move to shared COLLECTORS for sch and lib.

This commit is contained in:
Jeff Young 2019-05-06 03:32:01 +01:00
parent 2e43c6c64e
commit f87d371b8b
18 changed files with 149 additions and 332 deletions

View File

@ -167,7 +167,6 @@ set( EESCHEMA_SRCS
lib_arc.cpp
lib_bezier.cpp
lib_circle.cpp
lib_collectors.cpp
lib_draw_item.cpp
lib_field.cpp
lib_pin.cpp

View File

@ -964,6 +964,22 @@ LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType,
}
SEARCH_RESULT LIB_PART::Visit( INSPECTOR aInspector, void* aTestData, const KICAD_T aFilterTypes[] )
{
// The part itself is never inspected, only its children
for( LIB_ITEM& item : m_drawings )
{
if( item.IsType( aFilterTypes ) )
{
if( aInspector( &item, aTestData ) == SEARCH_QUIT )
return SEARCH_QUIT;
}
}
return SEARCH_CONTINUE;
}
void LIB_PART::SetUnitCount( int aCount )
{
if( m_unitCount == aCount )

View File

@ -276,7 +276,6 @@ public:
}
virtual void SetName( const wxString& aName );
const wxString& GetName() const;
const LIB_ID& GetLibId() const { return m_libId; }
@ -285,7 +284,6 @@ public:
const wxString GetLibraryName();
PART_LIB* GetLib() { return m_library; }
void SetLib( PART_LIB* aLibrary ) { m_library = aLibrary; }
wxArrayString GetAliasNames( bool aIncludeRoot = true ) const;
@ -295,7 +293,6 @@ public:
size_t GetAliasCount() const { return m_aliases.size(); }
LIB_ALIAS* GetAlias( size_t aIndex );
LIB_ALIAS* GetAlias( const wxString& aName );
timestamp_t GetDateLastEdition() const { return m_dateLastEdition; }
@ -620,6 +617,8 @@ public:
return m_drawings;
}
SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
/**
* Set the units per part count.
*

View File

@ -26,6 +26,7 @@
*/
#include <lib_draw_item.h>
#include <class_libentry.h>
#include <dialog_lib_edit_draw_item.h>
#include <lib_edit_frame.h>

View File

@ -1,144 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see AUTHORS.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 <macros.h>
#include <general.h>
#include <transform.h>
#include <lib_collectors.h>
const KICAD_T LIB_COLLECTOR::AllItems[] = {
LIB_ARC_T,
LIB_CIRCLE_T,
LIB_TEXT_T,
LIB_RECTANGLE_T,
LIB_POLYLINE_T,
LIB_BEZIER_T,
LIB_PIN_T,
LIB_FIELD_T,
EOT
};
const KICAD_T LIB_COLLECTOR::AllItemsButPins[] = {
LIB_ARC_T,
LIB_CIRCLE_T,
LIB_TEXT_T,
LIB_RECTANGLE_T,
LIB_POLYLINE_T,
LIB_BEZIER_T,
LIB_FIELD_T,
EOT
};
const KICAD_T LIB_COLLECTOR::EditableItems[] = {
LIB_ARC_T,
LIB_CIRCLE_T,
LIB_TEXT_T,
LIB_RECTANGLE_T,
LIB_POLYLINE_T,
LIB_BEZIER_T,
LIB_PIN_T,
LIB_FIELD_T,
EOT
};
const KICAD_T LIB_COLLECTOR::MovableItems[] = {
LIB_ARC_T,
LIB_CIRCLE_T,
LIB_TEXT_T,
LIB_RECTANGLE_T,
LIB_POLYLINE_T,
LIB_BEZIER_T,
LIB_PIN_T,
LIB_FIELD_T,
EOT
};
const KICAD_T LIB_COLLECTOR::RotatableItems[] = {
LIB_ARC_T,
LIB_CIRCLE_T,
LIB_TEXT_T,
LIB_RECTANGLE_T,
LIB_POLYLINE_T,
LIB_BEZIER_T,
LIB_PIN_T,
LIB_FIELD_T,
EOT
};
const KICAD_T LIB_COLLECTOR::DoubleClickItems[] = {
LIB_PIN_T,
LIB_ARC_T,
LIB_CIRCLE_T,
LIB_RECTANGLE_T,
LIB_POLYLINE_T,
LIB_TEXT_T,
LIB_FIELD_T,
LIB_BEZIER_T,
EOT
};
SEARCH_RESULT LIB_COLLECTOR::Inspect( EDA_ITEM* aItem, void* testData )
{
LIB_ITEM* item = (LIB_ITEM*) aItem;
// wxLogDebug( wxT( "Inspecting item %s, unit %d, convert %d" ),
// GetChars( item->GetSelectMenuText() ), item->GetUnit(), item->GetConvert() );
if( ( m_data.m_unit && item->GetUnit() && ( m_data.m_unit != item->GetUnit() ) )
|| ( m_data.m_convert && item->GetConvert() && ( m_data.m_convert != item->GetConvert() ) )
|| !item->HitTest( m_RefPos ) )
return SEARCH_CONTINUE;
Append( aItem );
return SEARCH_CONTINUE;
}
void LIB_COLLECTOR::Collect( LIB_ITEMS_CONTAINER& aItems, const KICAD_T aFilterList[],
const wxPoint& aPosition, int aUnit, int aConvert )
{
Empty(); // empty the collection just in case
SetScanTypes( aFilterList );
// remember where the snapshot was taken from and pass refPos to the Inspect() function.
SetRefPos( aPosition );
m_data.m_unit = aUnit;
m_data.m_convert = aConvert;
for( LIB_ITEM& item : aItems )
{
if( SEARCH_QUIT == item.Visit( m_inspector, NULL, m_ScanTypes ) )
break;
}
}

View File

@ -1,138 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2011 KiCad Developers, see AUTHORS.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
*/
#ifndef _LIB_COLLECTORS_H_
#define _LIB_COLLECTORS_H_
#include <collector.h>
#include <class_libentry.h>
class LIB_COLLECTOR;
class LIB_COLLECTOR_DATA
{
int m_unit;
int m_convert;
friend class LIB_COLLECTOR;
public:
LIB_COLLECTOR_DATA() :
m_unit( 0 ),
m_convert( 0 ) {}
};
/**
* Class LIB_COLLECTOR
*/
class LIB_COLLECTOR : public COLLECTOR
{
LIB_COLLECTOR_DATA m_data;
public:
/**
* A scan list for all schematic items.
*/
static const KICAD_T AllItems[];
/**
* A scan list for all editable schematic items.
*/
static const KICAD_T EditableItems[];
/**
* A scan list for all movable schematic items.
*/
static const KICAD_T MovableItems[];
/**
* A scan list for all rotatable schematic items.
*/
static const KICAD_T RotatableItems[];
/**
* A scan list for all double-clickable library items.
*/
static const KICAD_T DoubleClickItems[];
/**
* A scan list for all schematic items except pins.
*/
static const KICAD_T AllItemsButPins[];
/**
* Constructor LIB_COLLECTOR
*/
LIB_COLLECTOR( const KICAD_T* aScanTypes = LIB_COLLECTOR::AllItems )
{
SetScanTypes( aScanTypes );
}
/**
* Operator []
* overloads COLLECTOR::operator[](int) to return a LIB_ITEM* instead of
* an EDA_ITEM* type.
* @param aIndex The index into the list.
* @return LIB_ITEM* at \a aIndex or NULL.
*/
LIB_ITEM* operator[]( int aIndex ) const override
{
if( (unsigned)aIndex < (unsigned)GetCount() )
return (LIB_ITEM*) m_List[ aIndex ];
return NULL;
}
/**
* Function Inspect
* is the examining function within the INSPECTOR which is passed to the
* Iterate function.
*
* @param aItem An EDA_ITEM to examine.
* @param aTestData is not used in this class.
* @return SEARCH_RESULT #SEARCH_QUIT if the iterator is to stop the scan,
* else #SEARCH_CONTINUE;
*/
SEARCH_RESULT Inspect( EDA_ITEM* aItem, void* aTestData ) override;
/**
* Function Collect
* scans a SCH_ITEM using this class's Inspector method, which does the collection.
* @param aItem A SCH_ITEM to scan.
* @param aFilterList A list of #KICAD_T types with a terminating #EOT, that determines
* what is to be collected and the priority order of the resulting
* collection.
* @param aPosition A wxPoint to use in hit-testing.
* @param aUnit The unit of the items to collect or zero if all units.
* @param aConvert The convert of the items to collect or zero if all conversions.
*/
void Collect( LIB_ITEMS_CONTAINER& aItem, const KICAD_T aFilterList[], const wxPoint& aPosition,
int aUnit = 0, int aConvert = 0 );
};
#endif // _LIB_COLLECTORS_H_

View File

@ -47,6 +47,9 @@
bool LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
{
bool keyHandled = false;
wxPoint pos = aPosition;
// Filter out the 'fake' mouse motion after a keyboard movement
if( !aHotKey && m_movingCursorWithKeyboard )
{
@ -54,28 +57,16 @@ bool LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KE
return false;
}
// when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
// for next cursor position
// ( shift or ctrl key down are PAN command with mouse wheel)
bool snapToGrid = true;
if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) )
snapToGrid = false;
// Cursor is left off grid only if no block in progress
if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
snapToGrid = true;
wxPoint pos = aPosition;
bool keyHandled = GeneralControlKeyMovement( aHotKey, &pos, snapToGrid );
if( aHotKey )
keyHandled = GeneralControlKeyMovement( aHotKey, &pos, true );
if( GetToolId() == ID_NO_TOOL_SELECTED )
m_canvas->CrossHairOff( aDC );
else
m_canvas->CrossHairOn( aDC );
GetGalCanvas()->GetViewControls()->SetSnapping( snapToGrid );
SetCrossHairPosition( pos, snapToGrid );
GetGalCanvas()->GetViewControls()->SetSnapping( false );
SetCrossHairPosition( pos, false );
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( aDC, aPosition, true );

View File

@ -338,9 +338,12 @@ void LIB_EDIT_FRAME::setupTools()
m_toolManager->InitTools();
// Run the selection tool, it is supposed to be always active
// JEY TODO: not ready for modern toolset event processing yet....
#if 0
m_toolManager->InvokeTool( "eeschema.InteractiveSelection" );
GetCanvas()->SetEventDispatcher( m_toolDispatcher );
#endif
}
@ -1326,9 +1329,13 @@ LIB_ITEM* LIB_EDIT_FRAME::locateItem( const wxPoint& aPosition, const KICAD_T aF
if( !part )
return NULL;
#if 0
SCH_SELECTION_TOOL* selTool = m_toolManager->GetTool<SCH_SELECTION_TOOL>();
EDA_ITEM* item = selTool->SelectPoint( aPosition, aFilterList );
#else
LIB_ITEM* item = NULL;
m_collectedItems.Collect( part->GetDrawItems(), aFilterList, aPosition, m_unit, m_convert );
m_collectedItems.Collect( part, aFilterList, aPosition, m_unit, m_convert );
if( m_collectedItems.GetCount() == 0 )
{
@ -1336,7 +1343,7 @@ LIB_ITEM* LIB_EDIT_FRAME::locateItem( const wxPoint& aPosition, const KICAD_T aF
}
else if( m_collectedItems.GetCount() == 1 )
{
item = m_collectedItems[0];
item = (LIB_ITEM*) m_collectedItems[0];
}
else
{
@ -1363,6 +1370,7 @@ LIB_ITEM* LIB_EDIT_FRAME::locateItem( const wxPoint& aPosition, const KICAD_T aF
m_canvas->MoveCursorToCrossHair();
item = GetDrawItem();
}
#endif
if( item )
{
@ -1375,7 +1383,7 @@ LIB_ITEM* LIB_EDIT_FRAME::locateItem( const wxPoint& aPosition, const KICAD_T aF
ClearMsgPanel();
}
return item;
return (LIB_ITEM*) item;
}
@ -1453,9 +1461,9 @@ void LIB_EDIT_FRAME::OnSelectItem( wxCommandEvent& aEvent )
if( (id >= ID_SELECT_ITEM_START && id <= ID_SELECT_ITEM_END)
&& (index >= 0 && index < m_collectedItems.GetCount()) )
{
LIB_ITEM* item = m_collectedItems[index];
EDA_ITEM* item = m_collectedItems[index];
m_canvas->SetAbortRequest( false );
SetDrawItem( item );
SetDrawItem( (LIB_ITEM*) item );
}
}

View File

@ -31,7 +31,7 @@
#include <sch_base_frame.h>
#include <sch_screen.h>
#include <lib_draw_item.h>
#include <lib_collectors.h>
#include <sch_collectors.h>
#include <core/optional.h>
class SCH_EDIT_FRAME;
@ -52,7 +52,7 @@ 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.
LIB_PART* m_tempCopyComponent; ///< temp copy of a part during edit, I own it here.
LIB_COLLECTOR m_collectedItems; ///< Used for hit testing.
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
@ -596,7 +596,7 @@ private:
void EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem );
void EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem );
LIB_ITEM* LocateItemUsingCursor( const wxPoint& aPosition,
const KICAD_T aFilterList[] = LIB_COLLECTOR::AllItems );
const KICAD_T aFilterList[] = SCH_COLLECTOR::LibItems );
void EditField( LIB_FIELD* Field );
void refreshSchematic();

View File

@ -159,7 +159,7 @@ void LIB_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& aPosition )
if( !item || !item->InEditMode() )
{ // We can locate an item
item = LocateItemUsingCursor( aPosition, LIB_COLLECTOR::DoubleClickItems );
item = LocateItemUsingCursor( aPosition, SCH_COLLECTOR::LibItems );
if( item == NULL )
{

View File

@ -54,6 +54,19 @@ const KICAD_T SCH_COLLECTOR::AllItems[] = {
};
const KICAD_T SCH_COLLECTOR::LibItems[] = {
LIB_ARC_T,
LIB_CIRCLE_T,
LIB_TEXT_T,
LIB_RECTANGLE_T,
LIB_POLYLINE_T,
LIB_BEZIER_T,
LIB_PIN_T,
LIB_FIELD_T,
EOT
};
const KICAD_T SCH_COLLECTOR::AllItemsButPins[] = {
SCH_MARKER_T,
SCH_JUNCTION_T,
@ -126,6 +139,17 @@ const KICAD_T SCH_COLLECTOR::SheetsAndSheetLabels[] = {
SEARCH_RESULT SCH_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData )
{
if( m_Unit || m_Convert )
{
LIB_ITEM* lib_item = dynamic_cast<LIB_ITEM*>( aItem );
if( m_Unit && lib_item && lib_item->GetUnit() && lib_item->GetUnit() != m_Unit )
return SEARCH_CONTINUE;
if( m_Convert && lib_item && lib_item->GetConvert() != m_Convert )
return SEARCH_CONTINUE;
}
if( aItem->HitTest( m_RefPos ) )
Append( aItem );
@ -133,16 +157,22 @@ SEARCH_RESULT SCH_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData )
}
void SCH_COLLECTOR::Collect( SCH_ITEM* aItem, const KICAD_T aFilterList[], const wxPoint& aPos )
void SCH_COLLECTOR::Collect( EDA_ITEM* aItem, const KICAD_T aFilterList[], const wxPoint& aPos,
int aUnit, int aConvert )
{
Empty(); // empty the collection just in case
SetScanTypes( aFilterList );
m_Unit = aUnit;
m_Convert = aConvert;
// remember where the snapshot was taken from and pass refPos to the Inspect() function.
SetRefPos( aPos );
EDA_ITEM::IterateForward( aItem, m_inspector, NULL, m_ScanTypes );
if( aItem->Type() == LIB_PART_T )
static_cast<LIB_PART*>( aItem )->Visit( m_inspector, nullptr, m_ScanTypes );
else
EDA_ITEM::IterateForward( aItem, m_inspector, nullptr, m_ScanTypes );
}

View File

@ -39,6 +39,7 @@ class SCH_COLLECTOR : public COLLECTOR
{
public:
static const KICAD_T AllItems[];
static const KICAD_T LibItems[];
static const KICAD_T EditableItems[];
static const KICAD_T RotatableItems[];
static const KICAD_T AllItemsButPins[];
@ -73,14 +74,17 @@ public:
/**
* Function Collect
* scans a SCH_ITEM using this class's Inspector method, which does the collection.
* @param aItem A SCH_ITEM to scan.
* scans a EDA_ITEM using this class's Inspector method, which does the collection.
* @param aItem A EDA_ITEM to scan.
* @param aFilterList A list of #KICAD_T types with a terminating #EOT, that determines
* what is to be collected and the priority order of the resulting
* collection.
* @param aPos A wxPoint to use in hit-testing.
* @param aUnit A symbol unit filter (for symbol editor)
* @param aConvert A DeMorgan filter (for symbol editor)
*/
void Collect( SCH_ITEM* aItem, const KICAD_T aFilterList[], const wxPoint& aPos );
void Collect( EDA_ITEM* aItem, const KICAD_T aFilterList[], const wxPoint& aPos,
int aUnit = 0, int aConvert = 0 );
/**
* Function IsCorner
@ -105,6 +109,9 @@ public:
bool IsDraggableJunction() const;
public:
int m_Unit; // Fixed symbol unit filter (for symbol editor)
int m_Convert; // Fixed DeMorgan filter (for symbol editor)
wxString m_MenuTitle; // The title of selection disambiguation menu (if needed)
bool m_MenuCancelled; // Indicates selection disambiguation menu was cancelled
};

View File

@ -60,6 +60,7 @@
#include <thread>
#include <algorithm>
#include <future>
#include <array>
// TODO(JE) Debugging only
#include <profile.h>
@ -235,9 +236,13 @@ bool SCH_SCREEN::CheckIfOnDrawList( SCH_ITEM* aItem )
SCH_ITEM* SCH_SCREEN::GetItem( const wxPoint& aPosition, int aAccuracy, KICAD_T aType ) const
{
KICAD_T types[] = { aType, EOT };
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
{
if( (aType == SCH_FIELD_T) && (item->Type() == SCH_COMPONENT_T) )
switch( item->Type() )
{
case SCH_COMPONENT_T:
{
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
@ -245,25 +250,30 @@ SCH_ITEM* SCH_SCREEN::GetItem( const wxPoint& aPosition, int aAccuracy, KICAD_T
{
SCH_FIELD* field = component->GetField( i );
if( field->HitTest( aPosition, aAccuracy ) )
return (SCH_ITEM*) field;
if( field->IsType( types ) && field->HitTest( aPosition, aAccuracy ) )
return field;
}
break;
}
else if( (aType == SCH_SHEET_PIN_T) && (item->Type() == SCH_SHEET_T) )
case SCH_SHEET_T:
{
SCH_SHEET* sheet = (SCH_SHEET*)item;
SCH_SHEET_PIN* label = sheet->GetPin( aPosition );
SCH_SHEET_PIN* pin = sheet->GetPin( aPosition );
if( label )
return (SCH_ITEM*) label;
if( pin && pin->IsType( types ) )
return pin;
break;
}
else if( ( ( item->Type() == aType ) || ( aType == NOT_USED ) )
&& item->HitTest( aPosition, aAccuracy ) )
{
default:
break;
}
if( item->IsType( types ) && item->HitTest( aPosition, aAccuracy ) )
return item;
}
}
return NULL;
}

View File

@ -217,11 +217,11 @@ public:
*
* @param aPosition Position in drawing units.
* @param aAccuracy The maximum distance within \a Position to check for an item.
* @param aType The type of item to find or #NOT_USED to find any item type.
* @param aType The type of item to find.
* @return The item found that meets the search criteria or NULL if none found.
*/
SCH_ITEM* GetItem( const wxPoint& aPosition, int aAccuracy = 0,
KICAD_T aType = NOT_USED ) const;
KICAD_T aType = SCH_LOCATE_ANY_T ) const;
void Place( SCH_EDIT_FRAME* frame, wxDC* DC ) { };

View File

@ -28,6 +28,7 @@
#include <sch_selection_tool.h>
#include <sch_base_frame.h>
#include <sch_edit_frame.h>
#include <lib_edit_frame.h>
#include <sch_component.h>
#include <sch_sheet.h>
#include <sch_field.h>
@ -152,6 +153,9 @@ SCH_SELECTION_TOOL::SCH_SELECTION_TOOL() :
m_subtractive( false ),
m_multiple( false ),
m_skip_heuristics( false ),
m_isLibEdit( false ),
m_unit( 0 ),
m_convert( 0 ),
m_menu( *this )
{
}
@ -165,7 +169,16 @@ SCH_SELECTION_TOOL::~SCH_SELECTION_TOOL()
bool SCH_SELECTION_TOOL::Init()
{
m_frame = getEditFrame<SCH_EDIT_FRAME>();
m_frame = getEditFrame<SCH_BASE_FRAME>();
LIB_EDIT_FRAME* libEditFrame = dynamic_cast<LIB_EDIT_FRAME*>( m_frame );
if( libEditFrame )
{
m_isLibEdit = true;
m_unit = libEditFrame->GetUnit();
m_convert = libEditFrame->GetConvert();
}
static KICAD_T wireOrBusTypes[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, EOT };
@ -221,7 +234,7 @@ bool SCH_SELECTION_TOOL::Init()
void SCH_SELECTION_TOOL::Reset( RESET_REASON aReason )
{
m_frame = getEditFrame<SCH_EDIT_FRAME>();
m_frame = getEditFrame<SCH_BASE_FRAME>();
if( aReason == TOOL_BASE::MODEL_RELOAD )
{
@ -229,6 +242,15 @@ void SCH_SELECTION_TOOL::Reset( RESET_REASON aReason )
// properties (as they are already deleted while a new sheet is loaded)
m_selection.Clear();
getView()->GetPainter()->GetSettings()->SetHighlight( false );
LIB_EDIT_FRAME* libEditFrame = dynamic_cast<LIB_EDIT_FRAME*>( m_frame );
if( libEditFrame )
{
m_isLibEdit = true;
m_unit = libEditFrame->GetUnit();
m_convert = libEditFrame->GetConvert();
}
}
else
// Restore previous properties of selected items and remove them from containers
@ -382,9 +404,15 @@ SELECTION& SCH_SELECTION_TOOL::GetSelection()
EDA_ITEM* SCH_SELECTION_TOOL::SelectPoint( const VECTOR2I& aWhere, const KICAD_T* aFilterList,
bool* aSelectionCancelledFlag, bool aCheckLocked )
{
EDA_ITEM* start;
SCH_COLLECTOR collector;
collector.Collect( m_frame->GetScreen()->GetDrawItems(), aFilterList, (wxPoint) aWhere );
if( m_isLibEdit )
start = static_cast<LIB_EDIT_FRAME*>( m_frame )->GetCurPart();
else
start = m_frame->GetScreen()->GetDrawItems();
collector.Collect( start, aFilterList, (wxPoint) aWhere, m_unit, m_convert );
bool anyCollected = collector.GetCount() != 0;

View File

@ -236,6 +236,10 @@ private:
bool m_multiple; // Multiple selection mode is active
bool m_skip_heuristics; // Heuristics are not allowed when choosing item under cursor
bool m_isLibEdit;
int m_unit; // Fixed unit filter (for symbol editor)
int m_convert; // Fixed DeMorgan filter (for symbol editor)
TOOL_MENU m_menu;
};

View File

@ -283,6 +283,9 @@ public:
*/
virtual bool IsType( const KICAD_T aScanTypes[] )
{
if( aScanTypes[0] == SCH_LOCATE_ANY_T )
return true;
for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
{
if( m_StructType == *p )

View File

@ -133,6 +133,9 @@ enum KICAD_T
SCH_LINE_LOCATE_WIRE_T,
SCH_LINE_LOCATE_BUS_T,
// matches any type
SCH_LOCATE_ANY_T,
// General
SCH_SCREEN_T,