2011-12-01 16:49:28 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-01-28 21:43:46 +00:00
|
|
|
* Copyright (C) 2013-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2008-2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2017-09-21 12:58:08 +00:00
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
2022-08-20 09:27:35 +00:00
|
|
|
* Copyright (C) 2004-2022 KiCad Developers, see change_log.txt for contributors.
|
2011-12-01 16:49:28 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2020-10-14 01:06:53 +00:00
|
|
|
#ifndef EDA_ITEM_H
|
|
|
|
#define EDA_ITEM_H
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2019-05-30 13:33:59 +00:00
|
|
|
#include <deque>
|
|
|
|
|
2014-06-06 09:44:21 +00:00
|
|
|
#include <core/typeinfo.h>
|
2021-06-08 03:06:11 +00:00
|
|
|
#include <eda_item_flags.h>
|
2022-08-05 02:40:38 +00:00
|
|
|
#include <eda_search_data.h>
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
#include <view/view_item.h>
|
2020-10-24 04:00:49 +00:00
|
|
|
#include <kiid.h>
|
2012-04-12 21:31:31 +00:00
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
enum class BITMAPS : unsigned int;
|
|
|
|
|
2012-04-12 21:31:31 +00:00
|
|
|
|
2022-07-30 00:00:39 +00:00
|
|
|
enum class INSPECT_RESULT
|
2019-12-28 00:55:11 +00:00
|
|
|
{
|
|
|
|
QUIT,
|
|
|
|
CONTINUE
|
2007-10-31 17:47:44 +00:00
|
|
|
};
|
2007-08-06 20:26:59 +00:00
|
|
|
|
|
|
|
|
2019-07-26 23:52:17 +00:00
|
|
|
/**
|
|
|
|
* Additional flag values wxFindReplaceData::m_Flags
|
|
|
|
*/
|
2022-09-28 03:13:55 +00:00
|
|
|
class UNITS_PROVIDER;
|
2011-01-21 19:30:59 +00:00
|
|
|
class EDA_DRAW_FRAME;
|
2013-01-12 17:32:24 +00:00
|
|
|
class MSG_PANEL_ITEM;
|
2011-11-17 01:06:08 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-08-06 20:26:59 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Used to inspect and possibly collect the (search) results of iterating over a list or
|
|
|
|
* tree of #KICAD_T objects.
|
2016-07-12 19:05:54 +00:00
|
|
|
*
|
2020-12-18 14:04:03 +00:00
|
|
|
* Provide an implementation as needed to inspect EDA_ITEMs visited via #EDA_ITEM::Visit()
|
|
|
|
* and #EDA_ITEM::IterateForward().
|
|
|
|
*
|
|
|
|
* FYI the std::function may hold a lambda, std::bind, pointer to func, or ptr to member
|
|
|
|
* function, per modern C++. It is used primarily for searching, but not limited to that.
|
|
|
|
* It can also collect or modify the scanned objects. 'Capturing' lambdas are particularly
|
|
|
|
* convenient because they can use context and this often means @a aTestData is not used.
|
|
|
|
*
|
|
|
|
* @param aItem An #EDA_ITEM to examine.
|
2016-07-12 19:05:54 +00:00
|
|
|
* @param aTestData is arbitrary data needed by the inspector to determine
|
Pcbnew: major swig fix.
* Switched hashtables.h over to std::undordered_map from boost version.
* Added new macros DECL_VEC_FOR_SWIG() and DECL_MAP_FOR_SWIG() in macros.h.
These along with future DECL_HASH_FOR_SWIG() unify the declaration to swig
and C++ so that the resultant type name is common in both languages, and
the types AGREE.
* Fixed swigging of NETINFO_ITEM and NETINFO_LIST via magic.
* Newly exposed (python wrapped) are: D_PADS, TRACKS (was TRACK_PTRS),
NETNAME_MAP, NETCODE_MAP, wxString (without constructor purposely, read
comment in wx.i), MARKERS, ZONE_CONTAINERS, NETCLASSPTR, KICAD_T types.
* std::vector<SOMETHING*> tends to end up named SOMETHINGS in C++ and python.
Having the name consistent between like types is helpful, and between
languages. std::map<> ends up as SOMETHING_MAP.
* NETINFO_LIST::m_netNames and NETINFO_LIST::m_netCodes are now std::map
instead of hashtables, because swig does not yet support std::unordered_map.
* You can now get to any netclass or net info. NETNAMES_MAP and NETCODES_MAP
are traversable basically the same as a python dictionary using a python
string (not wsString) as the key! The wxString typemap converts python
string to wxString before the lookup happens. Iteration also works.
2016-07-18 17:23:09 +00:00
|
|
|
* if the EDA_ITEM under test meets its match criteria, and is often NULL
|
|
|
|
* with the advent of capturing lambdas.
|
2016-07-12 19:05:54 +00:00
|
|
|
* @return A #SEARCH_RESULT type #SEARCH_QUIT if the iterator function is to
|
|
|
|
* stop the scan, else #SEARCH_CONTINUE;
|
2007-08-06 20:26:59 +00:00
|
|
|
*/
|
2022-07-30 00:00:39 +00:00
|
|
|
typedef std::function< INSPECT_RESULT ( EDA_ITEM* aItem, void* aTestData ) > INSPECTOR_FUNC;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2020-12-18 14:04:03 +00:00
|
|
|
///< std::function passed to nested users by ref, avoids copying std::function.
|
|
|
|
typedef const INSPECTOR_FUNC& INSPECTOR;
|
2007-08-06 20:26:59 +00:00
|
|
|
|
|
|
|
|
2011-11-17 01:06:08 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* A base class for most all the KiCad significant classes used in schematics and boards.
|
2011-11-17 01:06:08 +00:00
|
|
|
*/
|
2013-10-14 14:13:35 +00:00
|
|
|
class EDA_ITEM : public KIGFX::VIEW_ITEM
|
2009-07-23 15:37:00 +00:00
|
|
|
{
|
2015-01-29 15:27:24 +00:00
|
|
|
public:
|
2010-12-08 20:12:46 +00:00
|
|
|
virtual ~EDA_ITEM() { };
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2014-06-06 09:44:21 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Returns the type of object.
|
|
|
|
*
|
|
|
|
* This attribute should never be changed after a ctor sets it, so there is no public
|
|
|
|
* "setter" method.
|
2014-06-06 09:44:21 +00:00
|
|
|
*
|
2020-12-18 14:04:03 +00:00
|
|
|
* @return the type of object.
|
2014-06-06 09:44:21 +00:00
|
|
|
*/
|
2020-11-14 18:11:28 +00:00
|
|
|
inline KICAD_T Type() const { return m_structType; }
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2020-11-14 18:11:28 +00:00
|
|
|
EDA_ITEM* GetParent() const { return m_parent; }
|
|
|
|
virtual void SetParent( EDA_ITEM* aParent ) { m_parent = aParent; }
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2020-11-14 18:11:28 +00:00
|
|
|
inline bool IsModified() const { return m_flags & IS_CHANGED; }
|
|
|
|
inline bool IsNew() const { return m_flags & IS_NEW; }
|
2021-05-30 21:04:07 +00:00
|
|
|
inline bool IsMoving() const { return m_flags & IS_MOVING; }
|
2022-12-28 14:59:38 +00:00
|
|
|
|
2020-11-14 18:11:28 +00:00
|
|
|
inline bool IsSelected() const { return m_flags & SELECTED; }
|
2020-12-29 12:33:37 +00:00
|
|
|
inline bool IsEntered() const { return m_flags & ENTERED; }
|
2020-11-14 18:11:28 +00:00
|
|
|
inline bool IsBrightened() const { return m_flags & BRIGHTENED; }
|
2013-08-06 07:31:08 +00:00
|
|
|
|
2022-08-27 18:14:57 +00:00
|
|
|
inline bool IsRollover() const
|
|
|
|
{
|
|
|
|
return ( m_flags & ( IS_ROLLOVER | IS_MOVING ) ) == IS_ROLLOVER;
|
|
|
|
}
|
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
inline void SetSelected() { SetFlags( SELECTED ); }
|
2013-09-16 09:00:59 +00:00
|
|
|
inline void SetBrightened() { SetFlags( BRIGHTENED ); }
|
2013-08-06 07:31:08 +00:00
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
inline void ClearSelected() { ClearFlags( SELECTED ); }
|
2013-09-16 09:00:59 +00:00
|
|
|
inline void ClearBrightened() { ClearFlags( BRIGHTENED ); }
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
void SetModified();
|
|
|
|
|
2021-06-08 03:06:11 +00:00
|
|
|
void SetFlags( EDA_ITEM_FLAGS aMask ) { m_flags |= aMask; }
|
2022-12-10 18:16:28 +00:00
|
|
|
void XorFlags( EDA_ITEM_FLAGS aMask ) { m_flags ^= aMask; }
|
2021-06-08 03:06:11 +00:00
|
|
|
void ClearFlags( EDA_ITEM_FLAGS aMask = EDA_ITEM_ALL_FLAGS ) { m_flags &= ~aMask; }
|
|
|
|
EDA_ITEM_FLAGS GetFlags() const { return m_flags; }
|
|
|
|
bool HasFlag( EDA_ITEM_FLAGS aFlag ) const { return ( m_flags & aFlag ) == aFlag; }
|
2008-12-16 19:44:57 +00:00
|
|
|
|
2021-06-08 03:06:11 +00:00
|
|
|
EDA_ITEM_FLAGS GetEditFlags() const
|
2019-04-22 08:58:06 +00:00
|
|
|
{
|
2022-12-28 14:59:38 +00:00
|
|
|
constexpr int mask =
|
|
|
|
( IS_NEW | IS_PASTED | IS_MOVING | IS_BROKEN | IS_CHANGED | STRUCT_DELETED );
|
2020-05-22 21:46:22 +00:00
|
|
|
|
2020-11-14 18:11:28 +00:00
|
|
|
return m_flags & mask;
|
2019-04-22 08:58:06 +00:00
|
|
|
}
|
|
|
|
|
2019-05-01 11:37:35 +00:00
|
|
|
void ClearTempFlags()
|
|
|
|
{
|
2022-12-28 14:27:15 +00:00
|
|
|
ClearFlags( CANDIDATE | SELECTED_BY_DRAG | IS_LINKED | SKIP_STRUCT );
|
2019-05-11 10:06:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClearEditFlags()
|
|
|
|
{
|
|
|
|
ClearFlags( GetEditFlags() );
|
2019-05-01 11:37:35 +00:00
|
|
|
}
|
|
|
|
|
2022-05-13 21:36:20 +00:00
|
|
|
virtual bool RenderAsBitmap( double aWorldScale ) const { return false; }
|
|
|
|
|
|
|
|
void SetIsShownAsBitmap( bool aBitmap )
|
|
|
|
{
|
|
|
|
if( aBitmap )
|
|
|
|
SetFlags( IS_SHOWN_AS_BITMAP );
|
|
|
|
else
|
|
|
|
ClearFlags( IS_SHOWN_AS_BITMAP );
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsShownAsBitmap() const { return m_flags & IS_SHOWN_AS_BITMAP; }
|
|
|
|
|
2018-09-06 13:11:01 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Check whether the item is one of the listed types.
|
|
|
|
*
|
2018-09-06 13:11:01 +00:00
|
|
|
* @param aScanTypes List of item types
|
|
|
|
* @return true if the item type is contained in the list aScanTypes
|
|
|
|
*/
|
2022-08-21 19:54:07 +00:00
|
|
|
virtual bool IsType( const std::vector<KICAD_T>& aScanTypes ) const
|
2018-09-06 13:11:01 +00:00
|
|
|
{
|
2022-08-20 09:27:35 +00:00
|
|
|
for( KICAD_T scanType : aScanTypes )
|
2018-09-06 13:11:01 +00:00
|
|
|
{
|
2022-08-20 09:27:35 +00:00
|
|
|
if( scanType == SCH_LOCATE_ANY_T || scanType == m_structType )
|
2018-09-06 13:11:01 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-12-13 15:37:33 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Set and clear force visible flag used to force the item to be drawn even if it's draw
|
|
|
|
* attribute is set to not visible.
|
2011-12-13 15:37:33 +00:00
|
|
|
*
|
|
|
|
* @param aEnable True forces the item to be drawn. False uses the item's visibility
|
|
|
|
* setting to determine if the item is to be drawn.
|
|
|
|
*/
|
|
|
|
void SetForceVisible( bool aEnable ) { m_forceVisible = aEnable; }
|
2020-04-18 11:04:52 +00:00
|
|
|
bool IsForceVisible() const { return m_forceVisible; }
|
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Populate \a aList of #MSG_PANEL_ITEM objects with it's internal state for display
|
2013-01-12 17:32:24 +00:00
|
|
|
* purposes.
|
|
|
|
*
|
|
|
|
* @param aList is the list to populate.
|
2007-10-31 17:47:44 +00:00
|
|
|
*/
|
2020-04-24 13:36:10 +00:00
|
|
|
virtual void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
|
|
|
}
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2022-11-25 16:49:21 +00:00
|
|
|
virtual wxString GetFriendlyName() const;
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
/**
|
2021-12-06 00:16:17 +00:00
|
|
|
* Test if \a aPosition is inside or on the boundary of this item.
|
2012-03-15 14:31:16 +00:00
|
|
|
*
|
2022-01-01 06:04:08 +00:00
|
|
|
* @param aPosition A reference to a VECTOR2I object containing the coordinates to test.
|
2019-05-05 10:33:34 +00:00
|
|
|
* @param aAccuracy Increase the item bounding box by this amount.
|
|
|
|
* @return True if \a aPosition is within the item bounding box.
|
2007-08-08 03:50:44 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
virtual bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const
|
2007-08-08 03:50:44 +00:00
|
|
|
{
|
|
|
|
return false; // derived classes should override this function
|
|
|
|
}
|
|
|
|
|
2019-05-05 10:33:34 +00:00
|
|
|
/**
|
2021-12-06 00:16:17 +00:00
|
|
|
* Test if \a aRect intersects this item.
|
2019-05-05 10:33:34 +00:00
|
|
|
*
|
2022-08-31 16:17:14 +00:00
|
|
|
* @param aRect A reference to a #BOX2I object containing the rectangle to test.
|
2019-05-05 10:33:34 +00:00
|
|
|
* @param aContained Set to true to test for containment instead of an intersection.
|
|
|
|
* @param aAccuracy Increase \a aRect by this amount.
|
|
|
|
* @return True if \a aRect contains or intersects the item bounding box.
|
|
|
|
*/
|
2022-08-31 09:33:46 +00:00
|
|
|
virtual bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const
|
2019-05-05 10:33:34 +00:00
|
|
|
{
|
|
|
|
return false; // derived classes should override this function
|
|
|
|
}
|
2008-01-06 12:43:57 +00:00
|
|
|
|
2008-03-15 04:18:32 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Return the orthogonal bounding box of this object for display purposes.
|
|
|
|
*
|
2008-03-15 04:18:32 +00:00
|
|
|
* This box should be an enclosing perimeter for visible components of this
|
2009-11-23 20:18:47 +00:00
|
|
|
* object, and the units should be in the pcb or schematic coordinate
|
2020-12-18 14:04:03 +00:00
|
|
|
* system. It is OK to overestimate the size by a few counts.
|
2008-03-15 04:18:32 +00:00
|
|
|
*/
|
2022-08-31 09:15:42 +00:00
|
|
|
virtual const BOX2I GetBoundingBox() const;
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
virtual VECTOR2I GetPosition() const { return VECTOR2I(); }
|
|
|
|
virtual void SetPosition( const VECTOR2I& aPos ){};
|
2020-04-24 13:36:10 +00:00
|
|
|
|
2020-04-27 16:22:42 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Similar to GetPosition, but allows items to return their visual center rather
|
2020-04-27 16:22:42 +00:00
|
|
|
* than their anchor.
|
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
virtual const VECTOR2I GetFocusPosition() const { return GetPosition(); }
|
2020-04-27 16:22:42 +00:00
|
|
|
|
2022-03-03 14:35:57 +00:00
|
|
|
/**
|
|
|
|
* Return the coordinates that should be used for sorting this element
|
|
|
|
* visually compared to other elements. For instance, for lines the midpoint
|
|
|
|
* might be a better sorting point than either end.
|
|
|
|
*
|
|
|
|
* @return X,Y coordinate of the sort point
|
|
|
|
*/
|
|
|
|
virtual VECTOR2I GetSortPosition() const { return GetPosition(); }
|
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Create a duplicate of this item with linked list members set to NULL.
|
2010-12-21 15:13:09 +00:00
|
|
|
*
|
2012-03-17 14:39:27 +00:00
|
|
|
* The default version will return NULL in release builds and likely crash the
|
|
|
|
* program. In debug builds, a warning message indicating the derived class
|
|
|
|
* has not implemented cloning. This really should be a pure virtual function.
|
|
|
|
* Due to the fact that there are so many objects derived from EDA_ITEM, the
|
|
|
|
* decision was made to return NULL until all the objects derived from EDA_ITEM
|
|
|
|
* implement cloning. Once that happens, this function should be made pure.
|
2011-12-12 08:37:05 +00:00
|
|
|
*
|
2010-12-21 15:13:09 +00:00
|
|
|
* @return A clone of the item.
|
|
|
|
*/
|
2012-03-17 14:39:27 +00:00
|
|
|
virtual EDA_ITEM* Clone() const; // should not be inline, to save the ~ 6 bytes per call site.
|
2008-12-16 19:44:57 +00:00
|
|
|
|
2019-05-30 13:33:59 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* May be re-implemented for each derived class in order to handle all the types given
|
|
|
|
* by its member data.
|
|
|
|
*
|
2022-08-20 09:27:35 +00:00
|
|
|
* Implementations should call inspector->Inspect() on types in aScanTypes, and may use
|
2020-12-18 14:04:03 +00:00
|
|
|
* #IterateForward() to do so on lists of such data.
|
|
|
|
*
|
|
|
|
* @param inspector An #INSPECTOR instance to use in the inspection.
|
2019-05-30 13:33:59 +00:00
|
|
|
* @param testData Arbitrary data used by the inspector.
|
2022-08-20 09:27:35 +00:00
|
|
|
* @param aScanTypes Which #KICAD_T types are of interest and the order in which they should
|
|
|
|
* be processed.
|
2020-12-18 14:04:03 +00:00
|
|
|
* @return #SEARCH_RESULT SEARCH_QUIT if the Iterator is to stop the scan,
|
|
|
|
* else #SCAN_CONTINUE, and determined by the inspector.
|
2019-05-30 13:33:59 +00:00
|
|
|
*/
|
2022-08-20 09:27:35 +00:00
|
|
|
virtual INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
|
2022-08-21 19:54:07 +00:00
|
|
|
const std::vector<KICAD_T>& aScanTypes );
|
2019-05-30 13:33:59 +00:00
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* This changes first parameter to avoid the DList and use the main queue instead.
|
2007-08-09 21:15:08 +00:00
|
|
|
*/
|
2019-05-30 13:33:59 +00:00
|
|
|
template< class T >
|
2022-08-20 09:27:35 +00:00
|
|
|
static INSPECT_RESULT IterateForward( std::deque<T>& aList, INSPECTOR inspector, void* testData,
|
2022-08-21 19:54:07 +00:00
|
|
|
const std::vector<KICAD_T>& scanTypes )
|
2019-05-30 13:33:59 +00:00
|
|
|
{
|
2022-08-20 09:27:35 +00:00
|
|
|
for( const auto& it : aList )
|
2019-05-30 13:33:59 +00:00
|
|
|
{
|
2022-08-20 09:27:35 +00:00
|
|
|
if( static_cast<EDA_ITEM*>( it )->Visit( inspector,
|
|
|
|
testData,
|
|
|
|
scanTypes ) == INSPECT_RESULT::QUIT )
|
|
|
|
{
|
2022-07-30 00:00:39 +00:00
|
|
|
return INSPECT_RESULT::QUIT;
|
2022-08-20 09:27:35 +00:00
|
|
|
}
|
2019-05-30 13:33:59 +00:00
|
|
|
}
|
|
|
|
|
2022-07-30 00:00:39 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2019-05-30 13:33:59 +00:00
|
|
|
}
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2020-02-20 12:11:04 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Change first parameter to avoid the DList and use std::vector instead.
|
2019-12-28 00:55:11 +00:00
|
|
|
*/
|
|
|
|
template <class T>
|
2022-08-20 09:27:35 +00:00
|
|
|
static INSPECT_RESULT IterateForward( std::vector<T>& aList, INSPECTOR inspector,
|
2022-08-21 19:54:07 +00:00
|
|
|
void* testData, const std::vector<KICAD_T>& scanTypes )
|
2019-12-28 00:55:11 +00:00
|
|
|
{
|
2022-08-20 09:27:35 +00:00
|
|
|
for( const auto& it : aList )
|
2019-12-28 00:55:11 +00:00
|
|
|
{
|
2022-08-20 09:27:35 +00:00
|
|
|
if( static_cast<EDA_ITEM*>( it )->Visit( inspector,
|
|
|
|
testData,
|
|
|
|
scanTypes ) == INSPECT_RESULT::QUIT )
|
|
|
|
{
|
2022-07-30 00:00:39 +00:00
|
|
|
return INSPECT_RESULT::QUIT;
|
2022-08-20 09:27:35 +00:00
|
|
|
}
|
2019-12-28 00:55:11 +00:00
|
|
|
}
|
|
|
|
|
2022-07-30 00:00:39 +00:00
|
|
|
return INSPECT_RESULT::CONTINUE;
|
2019-12-28 00:55:11 +00:00
|
|
|
}
|
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Return the class name.
|
2007-08-07 06:21:19 +00:00
|
|
|
*/
|
2015-03-06 08:58:32 +00:00
|
|
|
virtual wxString GetClass() const = 0;
|
2007-08-07 06:21:19 +00:00
|
|
|
|
2022-05-08 22:54:24 +00:00
|
|
|
/**
|
|
|
|
* Return a translated description of the type for this EDA_ITEM for display in user facing
|
|
|
|
* messages.
|
|
|
|
*/
|
2022-11-25 16:49:21 +00:00
|
|
|
wxString GetTypeDesc() const;
|
2022-05-08 22:54:24 +00:00
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
/**
|
2023-01-12 03:27:44 +00:00
|
|
|
* Return a user-visible description string of this item. This description is used in
|
|
|
|
* disambiguation menus, the message panel, ERC/DRC reports, etc.
|
2020-12-18 14:04:03 +00:00
|
|
|
*
|
|
|
|
* The default version of this function raises an assertion in the debug mode and
|
|
|
|
* returns a string to indicate that it was not overridden to provide the object
|
|
|
|
* specific text.
|
2011-03-25 19:16:05 +00:00
|
|
|
*
|
|
|
|
* @return The menu text string.
|
|
|
|
*/
|
2023-01-12 03:27:44 +00:00
|
|
|
virtual wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Return a pointer to an image to be used in menus.
|
|
|
|
*
|
|
|
|
* The default version returns the right arrow image. Override this function to provide
|
|
|
|
* object specific menu images.
|
|
|
|
*
|
2011-03-25 19:16:05 +00:00
|
|
|
* @return The menu image associated with the item.
|
|
|
|
*/
|
2021-03-08 02:59:07 +00:00
|
|
|
virtual BITMAPS GetMenuImage() const;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2011-11-17 01:06:08 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Compare the item against the search criteria in \a aSearchData.
|
2011-11-17 01:06:08 +00:00
|
|
|
*
|
|
|
|
* The base class returns false since many of the objects derived from EDA_ITEM
|
|
|
|
* do not have any text to search.
|
|
|
|
*
|
2011-12-01 16:49:28 +00:00
|
|
|
* @param aSearchData A reference to a wxFindReplaceData object containing the
|
2011-11-17 01:06:08 +00:00
|
|
|
* search criteria.
|
2020-12-18 14:04:03 +00:00
|
|
|
* @param aAuxData A pointer to optional data required for the search or NULL if not used.
|
2011-12-13 15:37:33 +00:00
|
|
|
* @return True if the item's text matches the search criteria in \a aSearchData.
|
2011-11-17 01:06:08 +00:00
|
|
|
*/
|
2022-08-05 02:40:38 +00:00
|
|
|
virtual bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
|
2011-11-17 01:06:08 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Perform a text replace on \a aText using the find and replace criteria in
|
2011-12-13 15:37:33 +00:00
|
|
|
* \a aSearchData on items that support text find and replace.
|
|
|
|
*
|
|
|
|
* @param aSearchData A reference to a wxFindReplaceData object containing the
|
|
|
|
* search and replace criteria.
|
2020-12-18 14:04:03 +00:00
|
|
|
* @param aText A reference to a wxString object containing the text to be replaced.
|
2011-12-13 15:37:33 +00:00
|
|
|
* @return True if \a aText was modified, otherwise false.
|
|
|
|
*/
|
2022-08-05 02:40:38 +00:00
|
|
|
static bool Replace( const EDA_SEARCH_DATA& aSearchData, wxString& aText );
|
2011-12-13 15:37:33 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Perform a text replace using the find and replace criteria in \a aSearchData
|
2011-12-13 15:37:33 +00:00
|
|
|
* on items that support text find and replace.
|
|
|
|
*
|
|
|
|
* This function must be overridden for items that support text replace.
|
|
|
|
*
|
2020-12-18 14:04:03 +00:00
|
|
|
* @param aSearchData A reference to a wxFindReplaceData object containing the search and
|
|
|
|
* replace criteria.
|
|
|
|
* @param aAuxData A pointer to optional data required for the search or NULL if not used.
|
2011-12-13 15:37:33 +00:00
|
|
|
* @return True if the item text was modified, otherwise false.
|
|
|
|
*/
|
2022-08-05 02:40:38 +00:00
|
|
|
virtual bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData = nullptr )
|
2020-12-18 14:04:03 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2011-12-13 15:37:33 +00:00
|
|
|
|
2011-11-17 01:06:08 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Override this method in any derived object that supports test find and replace.
|
2011-11-17 01:06:08 +00:00
|
|
|
*
|
|
|
|
* @return True if the item has replaceable text that can be modified using
|
|
|
|
* the find and replace dialog.
|
|
|
|
*/
|
|
|
|
virtual bool IsReplaceable() const { return false; }
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
/**
|
|
|
|
* Test if another item is less than this object.
|
|
|
|
*
|
|
|
|
* @param aItem - Item to compare against.
|
|
|
|
* @return - True if \a aItem is less than the item.
|
|
|
|
*/
|
|
|
|
bool operator<( const EDA_ITEM& aItem ) const;
|
|
|
|
|
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Helper function to be used by the C++ STL sort algorithm for sorting a STL
|
|
|
|
* container of #EDA_ITEM pointers.
|
2011-04-27 19:44:32 +00:00
|
|
|
*
|
|
|
|
* @param aLeft The left hand item to compare.
|
|
|
|
* @param aRight The right hand item to compare.
|
|
|
|
* @return True if \a aLeft is less than \a aRight.
|
|
|
|
*/
|
|
|
|
static bool Sort( const EDA_ITEM* aLeft, const EDA_ITEM* aRight ) { return *aLeft < *aRight; }
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2012-01-09 20:26:55 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Assign the members of \a aItem to another object.
|
2012-01-09 20:26:55 +00:00
|
|
|
*/
|
2016-05-31 08:27:52 +00:00
|
|
|
EDA_ITEM& operator=( const EDA_ITEM& aItem );
|
2012-01-09 20:26:55 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual const BOX2I ViewBBox() const override;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
#if defined(DEBUG)
|
2007-09-13 11:28:58 +00:00
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Output the object tree, currently for debugging only.
|
|
|
|
*
|
|
|
|
* This is pure virtual so compiler warns if somebody mucks up a derived declaration.
|
|
|
|
*
|
2007-10-31 17:47:44 +00:00
|
|
|
* @param nestLevel An aid to prettier tree indenting, and is the level
|
2011-12-01 16:49:28 +00:00
|
|
|
* of nesting of this object within the overall tree.
|
2007-08-06 02:02:39 +00:00
|
|
|
* @param os The ostream& to output to.
|
|
|
|
*/
|
2011-12-14 17:25:42 +00:00
|
|
|
virtual void Show( int nestLevel, std::ostream& os ) const = 0;
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2011-12-14 17:25:42 +00:00
|
|
|
void ShowDummy( std::ostream& os ) const; ///< call this if you are a lazy developer
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Output nested space for pretty indenting.
|
|
|
|
*
|
|
|
|
* @param nestLevel The nest count.
|
2007-08-06 02:02:39 +00:00
|
|
|
* @param os The ostream&, where to output
|
2020-12-18 14:04:03 +00:00
|
|
|
* @return The std::ostream& for continuation.
|
2007-08-06 02:02:39 +00:00
|
|
|
**/
|
2009-11-23 20:18:47 +00:00
|
|
|
static std::ostream& NestedSpace( int nestLevel, std::ostream& os );
|
2007-08-06 20:26:59 +00:00
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
#endif
|
2015-01-28 21:43:46 +00:00
|
|
|
|
|
|
|
protected:
|
2020-12-18 14:04:03 +00:00
|
|
|
EDA_ITEM( EDA_ITEM* parent, KICAD_T idType );
|
|
|
|
EDA_ITEM( KICAD_T idType );
|
|
|
|
EDA_ITEM( const EDA_ITEM& base );
|
|
|
|
|
2015-01-28 21:43:46 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Compare \a aText against search criteria in \a aSearchData.
|
|
|
|
*
|
2015-01-28 21:43:46 +00:00
|
|
|
* This is a helper function for simplify derived class logic.
|
|
|
|
*
|
|
|
|
* @param aText A reference to a wxString object containing the string to test.
|
|
|
|
* @param aSearchData The criteria to search against.
|
|
|
|
* @return True if \a aText matches the search criteria in \a aSearchData.
|
|
|
|
*/
|
2022-08-05 02:40:38 +00:00
|
|
|
bool Matches( const wxString& aText, const EDA_SEARCH_DATA& aSearchData ) const;
|
2020-12-18 14:04:03 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
const KIID m_Uuid;
|
|
|
|
|
|
|
|
protected:
|
2021-06-08 03:06:11 +00:00
|
|
|
EDA_ITEM* m_parent; ///< Linked list: Link (parent struct)
|
|
|
|
bool m_forceVisible;
|
|
|
|
EDA_ITEM_FLAGS m_flags;
|
2020-12-18 14:04:03 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Run time identification, _keep private_ so it can never be changed after a ctor
|
|
|
|
* sets it. See comment near SetType() regarding virtual functions.
|
|
|
|
*/
|
|
|
|
KICAD_T m_structType;
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
/**
|
2020-12-18 14:04:03 +00:00
|
|
|
* Provide cloning capabilities for all Boost pointer containers of #EDA_ITEM pointers.
|
2010-12-21 15:13:09 +00:00
|
|
|
*
|
|
|
|
* @param aItem EDA_ITEM to clone.
|
|
|
|
* @return Clone of \a aItem.
|
|
|
|
*/
|
|
|
|
inline EDA_ITEM* new_clone( const EDA_ITEM& aItem ) { return aItem.Clone(); }
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define list of drawing items for screens.
|
|
|
|
*
|
2011-12-01 16:49:28 +00:00
|
|
|
* The standard C++ container was chosen so the pointer can be removed from a list without
|
2011-03-25 19:16:05 +00:00
|
|
|
* it being destroyed.
|
2010-12-21 15:13:09 +00:00
|
|
|
*/
|
2011-03-25 19:16:05 +00:00
|
|
|
typedef std::vector< EDA_ITEM* > EDA_ITEMS;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2020-12-18 14:04:03 +00:00
|
|
|
#endif // EDA_ITEM_H
|