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>
|
|
|
|
* Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 2004-2015 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
|
|
|
|
*/
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
/**
|
|
|
|
* @file base_struct.h
|
2011-09-30 18:15:37 +00:00
|
|
|
* @brief Basic classes for most KiCad items.
|
2011-09-07 19:41:04 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-11-30 21:15:56 +00:00
|
|
|
#ifndef BASE_STRUCT_H_
|
|
|
|
#define BASE_STRUCT_H_
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2014-06-06 09:44:21 +00:00
|
|
|
#include <core/typeinfo.h>
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <colors.h>
|
|
|
|
#include <bitmaps.h>
|
2012-04-01 20:51:56 +00:00
|
|
|
#include <richio.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>
|
2014-11-08 12:25:29 +00:00
|
|
|
#include <class_eda_rect.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
#if defined(DEBUG)
|
2007-08-06 02:02:39 +00:00
|
|
|
#include <iostream> // needed for Show()
|
2009-11-23 20:18:47 +00:00
|
|
|
extern std::ostream& operator <<( std::ostream& out, const wxSize& size );
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
extern std::ostream& operator <<( std::ostream& out, const wxPoint& pt );
|
2007-08-06 02:02:39 +00:00
|
|
|
#endif
|
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2013-10-27 18:21:53 +00:00
|
|
|
/// Flag to enable find and replace tracing using the WXTRACE environment variable.
|
|
|
|
extern const wxString traceFindReplace;
|
|
|
|
|
|
|
|
|
2012-04-12 21:31:31 +00:00
|
|
|
/**
|
|
|
|
* Enum FILL_T
|
|
|
|
* is the set of fill types used in plotting or drawing enclosed areas.
|
|
|
|
*/
|
|
|
|
enum FILL_T {
|
|
|
|
NO_FILL, // Poly, Square, Circle, Arc = option No Fill
|
|
|
|
FILLED_SHAPE, /* Poly, Square, Circle, Arc = option Fill
|
|
|
|
* with current color ("Solid shape") */
|
|
|
|
FILLED_WITH_BG_BODYCOLOR /* Poly, Square, Circle, Arc = option Fill
|
|
|
|
* with background body color, translucent
|
|
|
|
* (texts inside this shape can be seen)
|
|
|
|
* not filled in B&W mode when plotting or
|
|
|
|
* printing */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-08-06 20:26:59 +00:00
|
|
|
enum SEARCH_RESULT {
|
|
|
|
SEARCH_QUIT,
|
|
|
|
SEARCH_CONTINUE
|
2007-10-31 17:47:44 +00:00
|
|
|
};
|
2007-08-06 20:26:59 +00:00
|
|
|
|
|
|
|
|
2011-11-17 01:06:08 +00:00
|
|
|
class wxFindReplaceData;
|
2010-12-08 20:12:46 +00:00
|
|
|
class EDA_ITEM;
|
2011-01-21 19:30:59 +00:00
|
|
|
class EDA_DRAW_FRAME;
|
2011-03-29 19:33:07 +00:00
|
|
|
class EDA_RECT;
|
2011-11-17 01:06:08 +00:00
|
|
|
class DHEAD;
|
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
|
|
|
/**
|
|
|
|
* Class INSPECTOR
|
2007-10-31 17:47:44 +00:00
|
|
|
* is an abstract class that is used to inspect and possibly collect the
|
2007-08-06 20:26:59 +00:00
|
|
|
* (search) results of Iterating over a list or tree of KICAD_T objects.
|
2007-08-06 21:02:23 +00:00
|
|
|
* Extend from this class and implement the Inspect function and provide for
|
2007-08-06 20:26:59 +00:00
|
|
|
* a way for the extension to collect the results of the search/scan data and
|
|
|
|
* provide them to the caller.
|
|
|
|
*/
|
|
|
|
class INSPECTOR
|
|
|
|
{
|
|
|
|
public:
|
2007-08-20 01:20:48 +00:00
|
|
|
virtual ~INSPECTOR()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2007-08-06 20:26:59 +00:00
|
|
|
/**
|
|
|
|
* Function Inspect
|
2007-10-31 17:47:44 +00:00
|
|
|
* is the examining function within the INSPECTOR which is passed to the
|
2011-12-08 15:45:01 +00:00
|
|
|
* EDA_ITEM::Iterate() function. It is used primarily for searching, but
|
|
|
|
* not limited to that. It can also collect or modify the scanned objects.
|
2007-08-06 21:02:23 +00:00
|
|
|
*
|
2011-12-08 15:45:01 +00:00
|
|
|
* @param aItem An EDA_ITEM to examine.
|
|
|
|
* @param aTestData is arbitrary data needed by the inspector to determine
|
|
|
|
* if the EDA_ITEM under test meets its match criteria.
|
|
|
|
* @return A #SEARCH_RESULT type #SEARCH_QUIT if the iterator function is to
|
|
|
|
* stop the scan, else #SEARCH_CONTINUE;
|
2007-10-31 17:47:44 +00:00
|
|
|
*/
|
2012-02-28 21:30:46 +00:00
|
|
|
virtual SEARCH_RESULT Inspect( EDA_ITEM* aItem, const void* aTestData ) = 0;
|
2007-08-06 20:26:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
// These define are used for the .m_Flags and .m_UndoRedoStatus member of the
|
2010-12-08 20:12:46 +00:00
|
|
|
// class EDA_ITEM
|
2012-03-26 23:47:08 +00:00
|
|
|
#define IS_CHANGED (1 << 0) ///< Item was edited, and modified
|
|
|
|
#define IS_LINKED (1 << 1) ///< Used in calculation to mark linked items (temporary use)
|
|
|
|
#define IN_EDIT (1 << 2) ///< Item currently edited
|
|
|
|
#define IS_MOVED (1 << 3) ///< Item being moved
|
|
|
|
#define IS_NEW (1 << 4) ///< New item, just created
|
|
|
|
#define IS_RESIZED (1 << 5) ///< Item being resized
|
|
|
|
#define IS_DRAGGED (1 << 6) ///< Item being dragged
|
2010-10-25 15:43:42 +00:00
|
|
|
#define IS_DELETED (1 << 7)
|
2014-02-11 21:54:30 +00:00
|
|
|
#define IS_WIRE_IMAGE (1 << 8) ///< Item to be drawn as wireframe while editing
|
2010-10-25 15:43:42 +00:00
|
|
|
#define STARTPOINT (1 << 9)
|
|
|
|
#define ENDPOINT (1 << 10)
|
|
|
|
#define SELECTED (1 << 11)
|
|
|
|
#define SELECTEDNODE (1 << 12) ///< flag indicating that the structure has already selected
|
|
|
|
#define STRUCT_DELETED (1 << 13) ///< flag indication structures to be erased
|
|
|
|
#define CANDIDATE (1 << 14) ///< flag indicating that the structure is connected
|
|
|
|
#define SKIP_STRUCT (1 << 15) ///< flag indicating that the structure should be ignored
|
|
|
|
#define DO_NOT_DRAW (1 << 16) ///< Used to disable draw function
|
|
|
|
#define IS_CANCELLED (1 << 17) ///< flag set when edit dialogs are canceled when editing a
|
|
|
|
///< new object
|
2011-02-13 17:53:48 +00:00
|
|
|
#define TRACK_LOCKED (1 << 18) ///< Pcbnew: track locked: protected from global deletion
|
|
|
|
#define TRACK_AR (1 << 19) ///< Pcbnew: autorouted track
|
|
|
|
#define FLAG1 (1 << 20) ///< Pcbnew: flag used in local computations
|
|
|
|
#define FLAG0 (1 << 21) ///< Pcbnew: flag used in local computations
|
|
|
|
#define BEGIN_ONPAD (1 << 22) ///< Pcbnew: flag set for track segment starting on a pad
|
|
|
|
#define END_ONPAD (1 << 23) ///< Pcbnew: flag set for track segment ending on a pad
|
|
|
|
#define BUSY (1 << 24) ///< Pcbnew: flag indicating that the structure has
|
2011-12-21 13:42:02 +00:00
|
|
|
///< already been edited, in some functions
|
2013-08-06 07:31:08 +00:00
|
|
|
#define HIGHLIGHTED (1 << 25) ///< item is drawn in normal colors, when the rest is darkened
|
|
|
|
#define BRIGHTENED (1 << 26) ///< item is drawn with a bright contour
|
|
|
|
|
2015-02-17 23:44:23 +00:00
|
|
|
#define DP_COUPLED (1 << 27) ///< item is coupled with another item making a differential pair
|
2015-02-18 16:53:46 +00:00
|
|
|
///< (applies to segments only)
|
2015-02-17 23:44:23 +00:00
|
|
|
|
2011-03-03 01:58:12 +00:00
|
|
|
#define EDA_ITEM_ALL_FLAGS -1
|
|
|
|
|
2013-03-28 19:12:46 +00:00
|
|
|
typedef unsigned STATUS_FLAGS;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2011-11-17 01:06:08 +00:00
|
|
|
/**
|
|
|
|
* Class EDA_ITEM
|
|
|
|
* is a base class for most all the KiCad significant classes, used in
|
|
|
|
* schematics and boards.
|
|
|
|
*/
|
2013-10-14 14:13:35 +00:00
|
|
|
class EDA_ITEM : public KIGFX::VIEW_ITEM
|
2009-07-23 15:37:00 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run time identification, _keep private_ so it can never be changed after
|
2009-11-23 20:18:47 +00:00
|
|
|
* a constructor sets it. See comment near SetType() regarding virtual
|
2010-12-08 20:12:46 +00:00
|
|
|
* functions.
|
2009-07-23 15:37:00 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
KICAD_T m_StructType;
|
2013-03-28 19:12:46 +00:00
|
|
|
STATUS_FLAGS m_Status;
|
2009-07-23 15:37:00 +00:00
|
|
|
|
|
|
|
protected:
|
2011-12-12 08:37:05 +00:00
|
|
|
EDA_ITEM* Pnext; ///< next in linked list
|
|
|
|
EDA_ITEM* Pback; ///< previous in linked list
|
|
|
|
DHEAD* m_List; ///< which DLIST I am on.
|
|
|
|
|
2013-11-19 16:27:13 +00:00
|
|
|
EDA_ITEM* m_Parent; ///< Linked list: Link (parent struct)
|
2012-05-25 01:52:04 +00:00
|
|
|
time_t m_TimeStamp; ///< Time stamp used for logical links
|
2009-07-23 15:37:00 +00:00
|
|
|
|
2011-12-13 15:37:33 +00:00
|
|
|
/// Set to true to override the visibility setting of the item.
|
|
|
|
bool m_forceVisible;
|
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
/// Flag bits for editing and other uses.
|
2013-03-28 19:12:46 +00:00
|
|
|
STATUS_FLAGS m_Flags;
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
// Link to an copy of the item use to save the item's state for undo/redo feature.
|
|
|
|
EDA_ITEM* m_Image;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
private:
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2015-01-20 12:06:44 +00:00
|
|
|
void initVars();
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2015-01-29 15:27:24 +00:00
|
|
|
protected:
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM( EDA_ITEM* parent, KICAD_T idType );
|
|
|
|
EDA_ITEM( KICAD_T idType );
|
|
|
|
EDA_ITEM( const EDA_ITEM& base );
|
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
|
|
|
/**
|
|
|
|
* Function Type()
|
|
|
|
*
|
|
|
|
* returns the type of object. This attribute should never be changed
|
|
|
|
* after a constructor sets it, so there is no public "setter" method.
|
|
|
|
* @return KICAD_T - the type of object.
|
|
|
|
*/
|
|
|
|
inline KICAD_T Type() const
|
|
|
|
{
|
|
|
|
return m_StructType;
|
|
|
|
}
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2012-05-25 01:52:04 +00:00
|
|
|
void SetTimeStamp( time_t aNewTimeStamp ) { m_TimeStamp = aNewTimeStamp; }
|
|
|
|
time_t GetTimeStamp() const { return m_TimeStamp; }
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2014-04-30 19:16:22 +00:00
|
|
|
EDA_ITEM* Next() const { return Pnext; }
|
|
|
|
EDA_ITEM* Back() const { return Pback; }
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* GetParent() const { return m_Parent; }
|
2008-12-16 19:44:57 +00:00
|
|
|
DHEAD* GetList() const { return m_List; }
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SetNext( EDA_ITEM* aNext ) { Pnext = aNext; }
|
|
|
|
void SetBack( EDA_ITEM* aBack ) { Pback = aBack; }
|
|
|
|
void SetParent( EDA_ITEM* aParent ) { m_Parent = aParent; }
|
|
|
|
void SetList( DHEAD* aList ) { m_List = aList; }
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
inline bool IsNew() const { return m_Flags & IS_NEW; }
|
|
|
|
inline bool IsModified() const { return m_Flags & IS_CHANGED; }
|
|
|
|
inline bool IsMoving() const { return m_Flags & IS_MOVED; }
|
|
|
|
inline bool IsDragging() const { return m_Flags & IS_DRAGGED; }
|
2014-02-11 21:54:30 +00:00
|
|
|
inline bool IsWireImage() const { return m_Flags & IS_WIRE_IMAGE; }
|
2010-11-03 14:13:15 +00:00
|
|
|
inline bool IsSelected() const { return m_Flags & SELECTED; }
|
2011-07-08 19:55:41 +00:00
|
|
|
inline bool IsResized() const { return m_Flags & IS_RESIZED; }
|
2013-08-06 07:31:08 +00:00
|
|
|
inline bool IsHighlighted() const { return m_Flags & HIGHLIGHTED; }
|
|
|
|
inline bool IsBrightened() const { return m_Flags & BRIGHTENED; }
|
|
|
|
|
2014-02-11 21:54:30 +00:00
|
|
|
inline void SetWireImage() { SetFlags( IS_WIRE_IMAGE ); }
|
2013-09-02 09:49:46 +00:00
|
|
|
inline void SetSelected() { SetFlags( SELECTED ); ViewUpdate( COLOR ); }
|
|
|
|
inline void SetHighlighted() { SetFlags( HIGHLIGHTED ); ViewUpdate( COLOR ); }
|
2013-09-16 09:00:59 +00:00
|
|
|
inline void SetBrightened() { SetFlags( BRIGHTENED ); }
|
2013-08-06 07:31:08 +00:00
|
|
|
|
2013-09-02 09:49:46 +00:00
|
|
|
inline void ClearSelected() { ClearFlags( SELECTED ); ViewUpdate( COLOR ); }
|
|
|
|
inline void ClearHighlighted() { ClearFlags( HIGHLIGHTED ); ViewUpdate( COLOR ); }
|
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();
|
|
|
|
|
2007-10-31 06:40:15 +00:00
|
|
|
int GetState( int type ) const
|
|
|
|
{
|
|
|
|
return m_Status & type;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetState( int type, int state )
|
|
|
|
{
|
|
|
|
if( state )
|
2007-10-31 17:47:44 +00:00
|
|
|
m_Status |= type; // state = ON or OFF
|
2007-10-31 06:40:15 +00:00
|
|
|
else
|
|
|
|
m_Status &= ~type;
|
|
|
|
}
|
2007-08-04 04:42:49 +00:00
|
|
|
|
2013-03-28 19:12:46 +00:00
|
|
|
STATUS_FLAGS GetStatus() const { return m_Status; }
|
|
|
|
void SetStatus( STATUS_FLAGS aStatus ) { m_Status = aStatus; }
|
2007-08-04 04:42:49 +00:00
|
|
|
|
2013-03-28 19:12:46 +00:00
|
|
|
void SetFlags( STATUS_FLAGS aMask ) { m_Flags |= aMask; }
|
|
|
|
void ClearFlags( STATUS_FLAGS aMask = EDA_ITEM_ALL_FLAGS ) { m_Flags &= ~aMask; }
|
|
|
|
STATUS_FLAGS GetFlags() const { return m_Flags; }
|
2008-12-16 19:44:57 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
void SetImage( EDA_ITEM* aItem ) { m_Image = aItem; }
|
|
|
|
|
2011-12-13 15:37:33 +00:00
|
|
|
/**
|
|
|
|
* Function SetForceVisible
|
|
|
|
* is used to set and cleag force visible flag used to force the item to be drawn
|
|
|
|
* even if it's draw attribute is set to not visible.
|
|
|
|
*
|
|
|
|
* @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; }
|
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
/**
|
2013-01-12 17:32:24 +00:00
|
|
|
* Function GetMsgPanelInfo
|
|
|
|
* populates \a aList of #MSG_PANEL_ITEM objects with it's internal state for display
|
|
|
|
* purposes.
|
|
|
|
*
|
|
|
|
* @note This method replaces DisplayInfo() so that KiCad objects no longer have any
|
|
|
|
* knowledge of wxWidgets UI objects.
|
|
|
|
*
|
|
|
|
* @param aList is the list to populate.
|
2007-10-31 17:47:44 +00:00
|
|
|
*/
|
2013-01-12 17:32:24 +00:00
|
|
|
virtual void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
|
|
|
}
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
/**
|
|
|
|
* Function HitTest
|
2012-03-15 14:31:16 +00:00
|
|
|
* tests if \a aPosition is contained within or on the bounding area of an item.
|
|
|
|
*
|
|
|
|
* @param aPosition A reference to a wxPoint object containing the coordinates to test.
|
|
|
|
* @return True if \a aPosition is within or on the item bounding area.
|
2007-08-08 03:50:44 +00:00
|
|
|
*/
|
2014-05-04 17:08:36 +00:00
|
|
|
virtual bool HitTest( const wxPoint& aPosition ) const
|
2007-08-08 03:50:44 +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
|
|
|
/**
|
|
|
|
* Function GetBoundingBox
|
2009-11-23 20:18:47 +00:00
|
|
|
* returns 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
|
|
|
|
* system.
|
2008-03-15 04:18:32 +00:00
|
|
|
* It is OK to overestimate the size by a few counts.
|
|
|
|
*/
|
2013-11-24 17:48:14 +00:00
|
|
|
virtual const EDA_RECT GetBoundingBox() const
|
2008-03-15 04:18:32 +00:00
|
|
|
{
|
2009-11-23 20:18:47 +00:00
|
|
|
#if defined(DEBUG)
|
2008-12-16 19:44:57 +00:00
|
|
|
printf( "Missing GetBoundingBox()\n" );
|
2010-12-10 19:47:44 +00:00
|
|
|
Show( 0, std::cout ); // tell me which classes still need GetBoundingBox support
|
2008-03-20 01:50:21 +00:00
|
|
|
#endif
|
2008-12-16 19:44:57 +00:00
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
// return a zero-sized box per default. derived classes should override
|
|
|
|
// this
|
2011-03-29 19:33:07 +00:00
|
|
|
return EDA_RECT( wxPoint( 0, 0 ), wxSize( 0, 0 ) );
|
2008-03-15 04:18:32 +00:00
|
|
|
}
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
/**
|
2011-12-12 08:37:05 +00:00
|
|
|
* Function Clone
|
2010-12-21 15:13:09 +00:00
|
|
|
* creates a duplicate of this item with linked list members set to NULL.
|
|
|
|
*
|
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
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
/**
|
|
|
|
* Function IterateForward
|
2007-10-31 17:47:44 +00:00
|
|
|
* walks through the object tree calling the inspector() on each object
|
2007-08-09 21:15:08 +00:00
|
|
|
* type requested in scanTypes.
|
|
|
|
*
|
2010-12-08 20:12:46 +00:00
|
|
|
* @param listStart The first in a list of EDA_ITEMs to iterate over.
|
2007-10-31 17:47:44 +00:00
|
|
|
* @param inspector Is an INSPECTOR to call on each object that is one of
|
2011-12-01 16:49:28 +00:00
|
|
|
* the requested scanTypes.
|
|
|
|
* @param testData Is an aid to testFunc, and should be sufficient to allow
|
|
|
|
* it to fully determine if an item meets the match criteria,
|
|
|
|
* but it may also be used to collect output.
|
|
|
|
* @param scanTypes A KICAD_T array that is EOT terminated, and provides both
|
|
|
|
* the order and interest level of of the types of objects to
|
2011-12-13 15:37:33 +00:00
|
|
|
* be iterated over.
|
2011-12-01 16:49:28 +00:00
|
|
|
* @return SEARCH_RESULT SEARCH_QUIT if the called INSPECTOR returned
|
|
|
|
* SEARCH_QUIT, else SCAN_CONTINUE;
|
2007-08-09 21:15:08 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
static SEARCH_RESULT IterateForward( EDA_ITEM* listStart,
|
|
|
|
INSPECTOR* inspector,
|
|
|
|
const void* testData,
|
|
|
|
const KICAD_T scanTypes[] );
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
/**
|
|
|
|
* Function Visit
|
|
|
|
* may be re-implemented for each derived class in order to handle
|
|
|
|
* all the types given by its member data. Implementations should call
|
2009-11-23 20:18:47 +00:00
|
|
|
* inspector->Inspect() on types in scanTypes[], and may use
|
|
|
|
* IterateForward()
|
2007-08-09 21:15:08 +00:00
|
|
|
* to do so on lists of such data.
|
|
|
|
* @param inspector An INSPECTOR instance to use in the inspection.
|
|
|
|
* @param testData Arbitrary data used by the inspector.
|
2007-10-31 17:47:44 +00:00
|
|
|
* @param scanTypes Which KICAD_T types are of interest and the order
|
2011-12-01 16:49:28 +00:00
|
|
|
* is significant too, terminated by EOT.
|
|
|
|
* @return SEARCH_RESULT SEARCH_QUIT if the Iterator is to stop the scan,
|
|
|
|
* else SCAN_CONTINUE, and determined by the inspector.
|
2007-08-09 21:15:08 +00:00
|
|
|
*/
|
2009-11-23 20:18:47 +00:00
|
|
|
virtual SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
|
|
|
|
const KICAD_T scanTypes[] );
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
/**
|
|
|
|
* Function GetClass
|
|
|
|
* returns the class name.
|
|
|
|
* @return wxString
|
|
|
|
*/
|
2015-03-06 08:58:32 +00:00
|
|
|
virtual wxString GetClass() const = 0;
|
2007-08-07 06:21:19 +00:00
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
/**
|
|
|
|
* Function GetSelectMenuText
|
|
|
|
* returns the text to display to be used in the selection clarification context menu
|
|
|
|
* when multiple items are found at the current cursor position. 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.
|
|
|
|
*
|
|
|
|
* @return The menu text string.
|
|
|
|
*/
|
|
|
|
virtual wxString GetSelectMenuText() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetMenuImage
|
|
|
|
* returns a pointer to an image to be used in menus. The default version returns
|
2011-12-01 16:49:28 +00:00
|
|
|
* the right arrow image. Override this function to provide object specific menu
|
2011-03-25 19:16:05 +00:00
|
|
|
* images.
|
|
|
|
* @return The menu image associated with the item.
|
|
|
|
*/
|
2011-08-29 03:04:59 +00:00
|
|
|
virtual BITMAP_DEF GetMenuImage() const { return right_xpm; }
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2011-11-17 01:06:08 +00:00
|
|
|
/**
|
|
|
|
* Function Matches
|
|
|
|
* compares the item against the search criteria in \a aSearchData.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
* @param aAuxData A pointer to optional data required for the search or NULL
|
|
|
|
* if not used.
|
|
|
|
* @param aFindLocation A pointer to a wxPoint object to store the location of
|
2011-12-13 15:37:33 +00:00
|
|
|
* matched item. The pointer can be NULL if it is not used.
|
|
|
|
* @return True if the item's text matches the search criteria in \a aSearchData.
|
2011-11-17 01:06:08 +00:00
|
|
|
*/
|
|
|
|
virtual bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-01-20 12:06:44 +00:00
|
|
|
* Helper function used in search and replace dialog
|
2011-12-13 15:37:33 +00:00
|
|
|
* Function Replace
|
|
|
|
* performs a text replace on \a aText using the find and replace criteria in
|
|
|
|
* \a aSearchData on items that support text find and replace.
|
|
|
|
*
|
|
|
|
* @param aSearchData A reference to a wxFindReplaceData object containing the
|
|
|
|
* search and replace criteria.
|
|
|
|
* @param aText A reference to a wxString object containing the text to be
|
|
|
|
* replaced.
|
|
|
|
* @return True if \a aText was modified, otherwise false.
|
|
|
|
*/
|
|
|
|
bool Replace( wxFindReplaceData& aSearchData, wxString& aText );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Replace
|
|
|
|
* performs a text replace using the find and replace criteria in \a aSearchData
|
|
|
|
* on items that support text find and replace.
|
|
|
|
*
|
|
|
|
* This function must be overridden for items that support text replace.
|
|
|
|
*
|
|
|
|
* @param aSearchData A reference to a wxFindReplaceData object containing the
|
|
|
|
* search and replace criteria.
|
2011-12-21 20:21:15 +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 text was modified, otherwise false.
|
|
|
|
*/
|
2011-12-21 20:21:15 +00:00
|
|
|
virtual bool Replace( wxFindReplaceData& aSearchData, void* aAuxData = NULL ) { return false; }
|
2011-12-13 15:37:33 +00:00
|
|
|
|
2011-11-17 01:06:08 +00:00
|
|
|
/**
|
|
|
|
* Function IsReplaceable
|
|
|
|
* <p>
|
|
|
|
* Override this method in any derived object that supports test find and
|
|
|
|
* replace.
|
|
|
|
* </p>
|
|
|
|
*
|
|
|
|
* @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;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Sort
|
|
|
|
* is a helper function to be used by the C++ STL sort algorithm for sorting a STL
|
|
|
|
* container of EDA_ITEM pointers.
|
|
|
|
*
|
|
|
|
* @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
|
|
|
|
2015-03-02 17:29:18 +00:00
|
|
|
#if 0
|
2012-01-09 20:26:55 +00:00
|
|
|
/**
|
|
|
|
* Operator assignment
|
|
|
|
* is used to assign the members of \a aItem to another object.
|
|
|
|
*
|
|
|
|
* @warning This is still a work in progress and not ready for prime time. Do not use
|
|
|
|
* as there is a known issue with wxString buffers.
|
|
|
|
*/
|
|
|
|
virtual EDA_ITEM& operator=( const EDA_ITEM& aItem );
|
2015-03-02 17:29:18 +00:00
|
|
|
#define USE_EDA_ITEM_OP_EQ
|
|
|
|
#endif
|
2012-01-09 20:26:55 +00:00
|
|
|
|
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
|
|
|
/// @copydoc VIEW_ITEM::ViewBBox()
|
|
|
|
virtual const BOX2I ViewBBox() const;
|
|
|
|
|
|
|
|
/// @copydoc VIEW_ITEM::ViewGetLayers()
|
|
|
|
virtual void ViewGetLayers( int aLayers[], int& aCount ) const;
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Function Show
|
|
|
|
* is used to output the object tree, currently for debugging only.
|
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;
|
|
|
|
// pure virtual so compiler warns if somebody mucks up a derived declaration
|
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
|
|
|
/**
|
2007-08-06 02:02:39 +00:00
|
|
|
* Function NestedSpace
|
|
|
|
* outputs nested space for pretty indenting.
|
|
|
|
* @param nestLevel The nest count
|
|
|
|
* @param os The ostream&, where to output
|
|
|
|
* @return std::ostream& - for continuation.
|
|
|
|
**/
|
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:
|
|
|
|
/**
|
|
|
|
* Function Matches
|
|
|
|
* compares \a aText against search criteria in \a aSearchData.
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
bool Matches( const wxString& aText, wxFindReplaceData& aSearchData );
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
/**
|
|
|
|
* Function new_clone
|
2011-03-25 19:16:05 +00:00
|
|
|
* provides 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
|
|
|
|
|
|
|
|
2011-11-30 21:15:56 +00:00
|
|
|
#endif // BASE_STRUCT_H_
|