18 changed files with 149 additions and 332 deletions
-
1eeschema/CMakeLists.txt
-
16eeschema/class_libentry.cpp
-
5eeschema/class_libentry.h
-
1eeschema/dialogs/dialog_lib_edit_draw_item.cpp
-
144eeschema/lib_collectors.cpp
-
138eeschema/lib_collectors.h
-
23eeschema/libedit/controller.cpp
-
18eeschema/libedit/lib_edit_frame.cpp
-
6eeschema/libedit/lib_edit_frame.h
-
2eeschema/libedit/libedit_onleftclick.cpp
-
34eeschema/sch_collectors.cpp
-
13eeschema/sch_collectors.h
-
32eeschema/sch_screen.cpp
-
4eeschema/sch_screen.h
-
34eeschema/tools/sch_selection_tool.cpp
-
4eeschema/tools/sch_selection_tool.h
-
3include/base_struct.h
-
3include/core/typeinfo.h
@ -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; |
|
||||
} |
|
||||
} |
|
@ -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_ |
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue