2011-10-31 20:49:48 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 2004-2011 KiCad Developers, see change_log.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
|
|
|
|
*/
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2011-10-31 20:49:48 +00:00
|
|
|
/**
|
|
|
|
* @file class_libentry.h
|
|
|
|
* @brief Class LIB_ITEM definition.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
#ifndef _LIB_ITEM_H_
|
|
|
|
#define _LIB_ITEM_H_
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <base_struct.h>
|
|
|
|
#include <transform.h>
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
#include <boost/ptr_container/ptr_vector.hpp>
|
|
|
|
|
|
|
|
|
2011-10-31 20:49:48 +00:00
|
|
|
class LINE_READER;
|
2011-11-01 15:06:26 +00:00
|
|
|
class OUTPUTFORMATTER;
|
2010-10-08 20:40:57 +00:00
|
|
|
class LIB_COMPONENT;
|
|
|
|
class PLOTTER;
|
2011-04-27 19:44:32 +00:00
|
|
|
class LIB_ITEM;
|
2010-10-08 20:40:57 +00:00
|
|
|
class LIB_PIN;
|
2013-01-12 17:32:24 +00:00
|
|
|
class MSG_PANEL_ITEM;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
extern const int fill_tab[];
|
|
|
|
|
|
|
|
|
2011-05-25 10:42:56 +00:00
|
|
|
#define MINIMUM_SELECTION_DISTANCE 2 // Minimum selection distance in internal units
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper for defining a list of library draw object pointers. The Boost
|
|
|
|
* pointer containers are responsible for deleting object pointers placed
|
|
|
|
* in them. If you access a object pointer from the list, do not delete
|
|
|
|
* it directly.
|
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
typedef boost::ptr_vector< LIB_ITEM > LIB_ITEMS;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper for defining a list of pin object pointers. The list does not
|
2011-10-31 20:49:48 +00:00
|
|
|
* use a Boost pointer class so the object pointers do not accidentally get
|
2010-10-08 20:40:57 +00:00
|
|
|
* deleted when the container is deleted.
|
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
typedef std::vector< LIB_PIN* > LIB_PINS;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2012-02-27 23:02:08 +00:00
|
|
|
* Class LIB_ITEM
|
|
|
|
* is the base class for drawable items used by schematic library components.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
class LIB_ITEM : public EDA_ITEM
|
2010-10-08 20:40:57 +00:00
|
|
|
{
|
2010-10-20 20:24:26 +00:00
|
|
|
/**
|
2012-03-26 23:47:08 +00:00
|
|
|
* Function drawGraphic
|
|
|
|
*
|
|
|
|
* draws the item on \a aPanel.
|
|
|
|
*
|
|
|
|
* @param aPanel A pointer to the panel to draw the object upon.
|
|
|
|
* @param aDC A pointer to the device context used to draw the object.
|
|
|
|
* @param aOffset A reference to a wxPoint object containing the offset where to draw
|
|
|
|
* from the object's current position.
|
|
|
|
* @param aColor An #EDA_COLOR_T to draw the object or -1 to draw the object in it's
|
|
|
|
* default color.
|
|
|
|
* @param aDrawMode The mode used to perform the draw (#GR_OR, #GR_COPY, etc.).
|
2012-04-01 20:51:56 +00:00
|
|
|
* @param aData A pointer to any object specific data required to perform the draw.
|
2012-03-26 23:47:08 +00:00
|
|
|
* @param aTransform A reference to a #TRANSFORM object containing drawing transform.
|
2010-10-20 20:24:26 +00:00
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
virtual void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
2012-09-02 12:06:47 +00:00
|
|
|
const wxPoint& aOffset, EDA_COLOR_T aColor,
|
2012-09-01 13:38:27 +00:00
|
|
|
GR_DRAWMODE aDrawMode, void* aData,
|
|
|
|
const TRANSFORM& aTransform ) = 0;
|
2010-10-20 20:24:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw any editing specific graphics when the item is being edited.
|
|
|
|
*
|
2012-03-26 23:47:08 +00:00
|
|
|
* @param aClipBox Clip box of the current device context.
|
|
|
|
* @param aDC The device context to draw on.
|
|
|
|
* @param aColor The index of the color to draw.
|
2010-10-20 20:24:26 +00:00
|
|
|
*/
|
2012-09-02 12:06:47 +00:00
|
|
|
virtual void drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, EDA_COLOR_T aColor ) {}
|
2010-10-20 20:24:26 +00:00
|
|
|
|
|
|
|
/**
|
2012-03-26 23:47:08 +00:00
|
|
|
* Calculates the attributes of an item at \a aPosition when it is being edited.
|
2010-10-20 20:24:26 +00:00
|
|
|
*
|
|
|
|
* This method gets called by the Draw() method when the item is being edited. This
|
|
|
|
* probably should be a pure virtual method but bezier curves are not yet editable in
|
|
|
|
* the component library editor. Therefore, the default method does nothing.
|
|
|
|
*
|
2012-03-26 23:47:08 +00:00
|
|
|
* @param aPosition The current mouse position in drawing coordinates.
|
2010-10-20 20:24:26 +00:00
|
|
|
*/
|
|
|
|
virtual void calcEdit( const wxPoint& aPosition ) {}
|
|
|
|
|
|
|
|
bool m_eraseLastDrawItem; ///< Used when editing a new draw item to prevent drawing
|
|
|
|
///< artifacts.
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
friend class LIB_COMPONENT;
|
|
|
|
|
|
|
|
protected:
|
2010-10-08 20:40:57 +00:00
|
|
|
/**
|
|
|
|
* Unit identification for multiple parts per package. Set to 0 if the
|
|
|
|
* item is common to all units.
|
|
|
|
*/
|
|
|
|
int m_Unit;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shape identification for alternate body styles. Set 0 if the item
|
|
|
|
* is common to all body styles. This is commonly referred to as
|
2011-09-30 18:15:37 +00:00
|
|
|
* DeMorgan style and this is typically how it is used in KiCad.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
|
|
|
int m_Convert;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The body fill type. This has meaning only for some items. For a list of
|
|
|
|
* fill types see #FILL_T.
|
|
|
|
*/
|
|
|
|
FILL_T m_Fill;
|
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
wxString m_typeName; ///< Name of object displayed in the message panel.
|
|
|
|
|
|
|
|
wxPoint m_initialPos; ///< Temporary position when moving an existing item.
|
|
|
|
wxPoint m_initialCursorPos; ///< Initial cursor position at the beginning of a move.
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2012-02-27 23:02:08 +00:00
|
|
|
/** Flag to indicate if draw item is fillable. Default is false. */
|
|
|
|
bool m_isFillable;
|
|
|
|
|
2010-10-08 20:40:57 +00:00
|
|
|
public:
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM( KICAD_T aType,
|
|
|
|
LIB_COMPONENT* aComponent = NULL,
|
|
|
|
int aUnit = 0,
|
|
|
|
int aConvert = 0,
|
|
|
|
FILL_T aFillType = NO_FILL );
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2012-01-09 20:26:55 +00:00
|
|
|
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
virtual ~LIB_ITEM() { }
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
wxString GetTypeName() { return m_typeName; }
|
|
|
|
|
2010-10-08 20:40:57 +00:00
|
|
|
/**
|
2010-10-20 20:24:26 +00:00
|
|
|
* Begin an editing a component library draw item in \a aEditMode at \a aPosition.
|
2010-10-08 20:40:57 +00:00
|
|
|
*
|
|
|
|
* This is used to start an editing action such as resize or move a draw object.
|
|
|
|
* It typically would be called on a left click when a draw tool is selected in
|
|
|
|
* the component library editor and one of the graphics tools is selected. It
|
2010-10-25 15:43:42 +00:00
|
|
|
* allows the draw item to maintain it's own internal state while it is being
|
2010-10-08 20:40:57 +00:00
|
|
|
* edited. Call AbortEdit() to quit the editing mode.
|
|
|
|
*
|
2012-03-26 23:47:08 +00:00
|
|
|
* @param aEditMode The editing mode being performed. See base_struct.h for a list
|
|
|
|
* of mode flags.
|
|
|
|
* @param aPosition The position in drawing coordinates where the editing mode was
|
|
|
|
* started. This may or may not be required depending on the item
|
|
|
|
* being edited and the edit mode.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2013-03-28 19:12:46 +00:00
|
|
|
virtual void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition = wxPoint( 0, 0 ) ) {}
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
/**
|
2010-10-20 20:24:26 +00:00
|
|
|
* Continue an edit in progress at \a aPosition.
|
2010-10-08 20:40:57 +00:00
|
|
|
*
|
|
|
|
* This is used to perform the next action while editing a draw item. This would be
|
|
|
|
* called for each additional left click when the mouse is captured while the item
|
|
|
|
* is being edited.
|
2010-10-20 20:24:26 +00:00
|
|
|
*
|
2012-03-26 23:47:08 +00:00
|
|
|
* @param aPosition The position of the mouse left click in drawing coordinates.
|
2010-10-20 20:24:26 +00:00
|
|
|
* @return True if additional mouse clicks are required to complete the edit in progress.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2010-10-20 20:24:26 +00:00
|
|
|
virtual bool ContinueEdit( const wxPoint aPosition ) { return false; }
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* End an object editing action.
|
|
|
|
*
|
2010-10-20 20:24:26 +00:00
|
|
|
* This is used to end or abort an edit action in progress initiated by BeginEdit().
|
|
|
|
*
|
2012-03-26 23:47:08 +00:00
|
|
|
* @param aPosition The position of the last edit event in drawing coordinates.
|
|
|
|
* @param aAbort Set to true to abort the current edit in progress.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2010-10-20 20:24:26 +00:00
|
|
|
virtual void EndEdit( const wxPoint& aPosition, bool aAbort = false ) { m_Flags = 0; }
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
/**
|
2010-10-20 20:24:26 +00:00
|
|
|
* Draw an item
|
2010-10-08 20:40:57 +00:00
|
|
|
*
|
2012-03-26 23:47:08 +00:00
|
|
|
* @param aPanel DrawPanel to use (can be null) mainly used for clipping purposes.
|
|
|
|
* @param aDC Device Context (can be null)
|
|
|
|
* @param aOffset Offset to draw
|
|
|
|
* @param aColor -1 to use the normal body item color, or use this color if >= 0
|
|
|
|
* @param aDrawMode GR_OR, GR_XOR, ...
|
|
|
|
* @param aData Value or pointer used to pass others parameters, depending on body items.
|
|
|
|
* Used for some items to force to force no fill mode ( has meaning only for
|
|
|
|
* items what can be filled ). used in printing or moving objects mode or to
|
|
|
|
* pass reference to the lib component for pins.
|
|
|
|
* @param aTransform Transform Matrix (rotation, mirror ..)
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2012-09-01 13:38:27 +00:00
|
|
|
virtual void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint &aOffset,
|
2012-09-02 12:06:47 +00:00
|
|
|
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
|
2012-09-01 13:38:27 +00:00
|
|
|
const TRANSFORM& aTransform );
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
/**
|
2012-03-26 23:47:08 +00:00
|
|
|
* Function GetPenSize
|
|
|
|
*
|
2010-10-08 20:40:57 +00:00
|
|
|
* @return the size of the "pen" that be used to draw or plot this item
|
|
|
|
*/
|
2011-04-18 20:22:17 +00:00
|
|
|
virtual int GetPenSize() const = 0;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
/**
|
2011-11-01 15:06:26 +00:00
|
|
|
* Function Save
|
|
|
|
* writes draw item object to \a aFormatter in component library "*.lib" format.
|
2010-10-08 20:40:57 +00:00
|
|
|
*
|
2012-02-27 23:02:08 +00:00
|
|
|
* @param aFormatter A reference to an #OUTPUTFORMATTER object to write the
|
2011-11-01 15:06:26 +00:00
|
|
|
* component library item to.
|
|
|
|
* @return True if success writing else false.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2011-11-01 15:06:26 +00:00
|
|
|
virtual bool Save( OUTPUTFORMATTER& aFormatter ) = 0;
|
|
|
|
|
2011-10-31 20:49:48 +00:00
|
|
|
virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ) = 0;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
LIB_COMPONENT* GetParent()
|
|
|
|
{
|
|
|
|
return (LIB_COMPONENT *)m_Parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool HitTest( const wxPoint& aPosition )
|
|
|
|
{
|
2012-03-26 23:47:08 +00:00
|
|
|
return EDA_ITEM::HitTest( aPosition );
|
2010-10-08 20:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-03-26 23:47:08 +00:00
|
|
|
* @param aPosition A wxPoint to test.
|
|
|
|
* @param aThreshold Maximum distance to this object (usually the half thickness of a line)
|
|
|
|
* if < 0, it will be automatically set to half pen size when locating
|
|
|
|
* lines or arcs and set to 0 for other items.
|
|
|
|
* @param aTransform The transform matrix.
|
|
|
|
* @return True if the point \a aPosition is near this object
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2010-12-14 15:56:30 +00:00
|
|
|
virtual bool HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ) = 0;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the boundary box for this, in library coordinates
|
|
|
|
*/
|
2011-03-29 19:33:07 +00:00
|
|
|
virtual EDA_RECT GetBoundingBox() const { return EDA_ITEM::GetBoundingBox(); }
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2010-11-17 18:41:20 +00:00
|
|
|
/**
|
2013-01-12 17:32:24 +00:00
|
|
|
* Function GetMsgPanelInfo
|
2011-10-31 20:49:48 +00:00
|
|
|
* displays basic info (type, part and convert) about the current item
|
|
|
|
* in message panel.
|
|
|
|
* <p>
|
|
|
|
* This base function is used to display the information common to the
|
|
|
|
* all library items. Call the base class from the derived class or the
|
|
|
|
* common information will not be updated in the message panel.
|
|
|
|
* </p>
|
2013-01-12 17:32:24 +00:00
|
|
|
* @param aList is the list to populate.
|
2010-11-17 18:41:20 +00:00
|
|
|
*/
|
2013-01-12 17:32:24 +00:00
|
|
|
virtual void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
/**
|
2011-04-27 19:44:32 +00:00
|
|
|
* Test LIB_ITEM objects for equivalence.
|
2010-10-08 20:40:57 +00:00
|
|
|
*
|
2012-03-26 23:47:08 +00:00
|
|
|
* @param aOther Object to test against.
|
|
|
|
* @return True if object is identical to this object.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
bool operator==( const LIB_ITEM& aOther ) const;
|
|
|
|
bool operator==( const LIB_ITEM* aOther ) const
|
2010-10-08 20:40:57 +00:00
|
|
|
{
|
|
|
|
return *this == *aOther;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test if another draw item is less than this draw object.
|
|
|
|
*
|
|
|
|
* @param aOther - Draw item to compare against.
|
|
|
|
* @return - True if object is less than this object.
|
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
bool operator<( const LIB_ITEM& aOther) const;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
/**
|
2012-02-27 23:02:08 +00:00
|
|
|
* Function Offset
|
|
|
|
* sets the drawing object by \a aOffset from the current position.
|
2010-10-08 20:40:57 +00:00
|
|
|
*
|
2012-02-27 23:02:08 +00:00
|
|
|
* @param aOffset Coordinates to offset the item position.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2012-02-27 23:02:08 +00:00
|
|
|
virtual void SetOffset( const wxPoint& aOffset ) = 0;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
/**
|
2012-02-27 23:02:08 +00:00
|
|
|
* Function Inside
|
|
|
|
* tests if any part of the draw object is inside rectangle bounds of \a aRect.
|
2010-10-08 20:40:57 +00:00
|
|
|
*
|
2012-02-27 23:02:08 +00:00
|
|
|
* @param aRect Rectangle to check against.
|
|
|
|
* @return True if object is inside rectangle.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2012-02-27 23:02:08 +00:00
|
|
|
virtual bool Inside( EDA_RECT& aRect ) const = 0;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
/**
|
2012-02-27 23:02:08 +00:00
|
|
|
* Function Move
|
|
|
|
* moves a draw object to \a aPosition.
|
2010-10-08 20:40:57 +00:00
|
|
|
*
|
2012-02-27 23:02:08 +00:00
|
|
|
* @param aPosition Position to move draw item to.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2012-02-27 23:02:08 +00:00
|
|
|
virtual void Move( const wxPoint& aPosition ) = 0;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
/**
|
2012-02-27 23:02:08 +00:00
|
|
|
* Function GetPosition
|
|
|
|
* returns the current draw object position.
|
|
|
|
*
|
|
|
|
* @return A wxPoint object containing the position of the object.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2012-02-27 23:02:08 +00:00
|
|
|
virtual wxPoint GetPosition() const = 0;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2012-02-27 23:02:08 +00:00
|
|
|
void SetPosition( const wxPoint& aPosition ) { Move( aPosition ); }
|
2010-12-07 16:10:42 +00:00
|
|
|
|
2010-10-08 20:40:57 +00:00
|
|
|
/**
|
2012-02-27 23:02:08 +00:00
|
|
|
* Function MirrorHorizontal
|
|
|
|
* mirrors the draw object along the horizontal (X) axis about \a aCenter point.
|
2010-10-08 20:40:57 +00:00
|
|
|
*
|
2012-02-27 23:02:08 +00:00
|
|
|
* @param aCenter Point to mirror around.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2012-02-27 23:02:08 +00:00
|
|
|
virtual void MirrorHorizontal( const wxPoint& aCenter ) = 0;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2011-05-20 18:29:35 +00:00
|
|
|
/**
|
2012-02-27 23:02:08 +00:00
|
|
|
* Function MirrorVertical
|
|
|
|
* mirrors the draw object along the MirrorVertical (Y) axis about \a aCenter point.
|
2011-05-20 18:29:35 +00:00
|
|
|
*
|
2012-02-27 23:02:08 +00:00
|
|
|
* @param aCenter Point to mirror around.
|
2011-05-20 18:29:35 +00:00
|
|
|
*/
|
2012-02-27 23:02:08 +00:00
|
|
|
virtual void MirrorVertical( const wxPoint& aCenter ) = 0;
|
2011-05-20 18:29:35 +00:00
|
|
|
|
|
|
|
/**
|
2012-02-27 23:02:08 +00:00
|
|
|
* Function Rotate
|
|
|
|
* rotates the object about \a aCenter point.
|
2011-05-20 18:29:35 +00:00
|
|
|
*
|
2012-02-27 23:02:08 +00:00
|
|
|
* @param aCenter Point to rotate around.
|
|
|
|
* @param aRotateCCW True to rotate counter clockwise. False to rotate clockwise.
|
2011-05-20 18:29:35 +00:00
|
|
|
*/
|
2012-02-27 23:02:08 +00:00
|
|
|
virtual void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) = 0;
|
2011-05-20 18:29:35 +00:00
|
|
|
|
2010-10-20 20:24:26 +00:00
|
|
|
/**
|
|
|
|
* Rotate the draw item.
|
|
|
|
*/
|
|
|
|
virtual void Rotate() {}
|
|
|
|
|
2010-10-08 20:40:57 +00:00
|
|
|
/**
|
|
|
|
* Plot the draw item using the plot object.
|
|
|
|
*
|
2012-02-27 23:02:08 +00:00
|
|
|
* @param aPlotter The plot object to plot to.
|
|
|
|
* @param aOffset Plot offset position.
|
|
|
|
* @param aFill Flag to indicate whether or not the object is filled.
|
|
|
|
* @param aTransform The plot transform.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2012-02-27 23:02:08 +00:00
|
|
|
virtual void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
|
|
|
|
const TRANSFORM& aTransform ) = 0;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
/**
|
2012-02-27 23:02:08 +00:00
|
|
|
* Function GetWidth
|
|
|
|
* return the width of the draw item.
|
2010-10-08 20:40:57 +00:00
|
|
|
*
|
|
|
|
* @return Width of draw object.
|
|
|
|
*/
|
2012-02-27 23:02:08 +00:00
|
|
|
virtual int GetWidth() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetWidth
|
|
|
|
* sets the width of the draw item to \a aWidth.
|
|
|
|
*/
|
|
|
|
virtual void SetWidth( int aWidth ) = 0;
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if draw object can be filled.
|
|
|
|
*
|
|
|
|
* The default setting is false. If the derived object support filling,
|
|
|
|
* set the m_isFillable member to true.
|
|
|
|
*
|
2012-03-26 23:47:08 +00:00
|
|
|
* @return True if draw object can be filled. Default is false.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2010-10-25 15:43:42 +00:00
|
|
|
bool IsFillable() const { return m_isFillable; }
|
2010-10-20 20:24:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the draw item editing mode status.
|
|
|
|
*
|
2012-03-26 23:47:08 +00:00
|
|
|
* @return True if the item is being edited.
|
2010-10-20 20:24:26 +00:00
|
|
|
*/
|
2013-01-01 20:52:37 +00:00
|
|
|
bool InEditMode() const { return ( m_Flags & ( IS_NEW | IS_DRAGGED | IS_MOVED | IS_RESIZED ) ) != 0; }
|
2010-10-20 20:24:26 +00:00
|
|
|
|
|
|
|
void SetEraseLastDrawItem( bool aErase = true ) { m_eraseLastDrawItem = aErase; }
|
|
|
|
|
2012-09-02 12:06:47 +00:00
|
|
|
virtual EDA_COLOR_T GetDefaultColor();
|
2010-10-20 20:24:26 +00:00
|
|
|
|
|
|
|
void SetUnit( int aUnit ) { m_Unit = aUnit; }
|
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
int GetUnit() const { return m_Unit; }
|
2010-10-20 20:24:26 +00:00
|
|
|
|
|
|
|
void SetConvert( int aConvert ) { m_Convert = aConvert; }
|
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
int GetConvert() const { return m_Convert; }
|
|
|
|
|
|
|
|
void SetFillMode( FILL_T aFillMode ) { m_Fill = aFillMode; }
|
|
|
|
|
|
|
|
FILL_T GetFillMode() const { return m_Fill; }
|
2010-10-08 20:40:57 +00:00
|
|
|
|
2011-12-14 17:25:42 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
|
|
|
|
#endif
|
|
|
|
|
2012-02-27 23:02:08 +00:00
|
|
|
private:
|
2010-10-08 20:40:57 +00:00
|
|
|
|
|
|
|
/**
|
2012-02-27 23:02:08 +00:00
|
|
|
* Function compare
|
2012-03-26 23:47:08 +00:00
|
|
|
* provides the draw object specific comparison called by the == and < operators.
|
2010-10-08 20:40:57 +00:00
|
|
|
*
|
2012-03-26 23:47:08 +00:00
|
|
|
* The base object sort order which always proceeds the derived object sort order
|
|
|
|
* is as follows:
|
2010-10-08 20:40:57 +00:00
|
|
|
* - Component alternate part (DeMorgan) number.
|
|
|
|
* - Component part number.
|
|
|
|
* - KICAD_T enum value.
|
|
|
|
* - Result of derived classes comparison.
|
2012-03-26 23:47:08 +00:00
|
|
|
*
|
|
|
|
* @param aOther A reference to the other #LIB_ITEM to compare the arc against.
|
|
|
|
* @return An integer value less than 0 if the object is less than \a aOther ojbect,
|
|
|
|
* zero if the object is equal to \a aOther object, or greater than 0 if the
|
|
|
|
* object is greater than \a aOther object.
|
2010-10-08 20:40:57 +00:00
|
|
|
*/
|
2012-02-27 23:02:08 +00:00
|
|
|
virtual int compare( const LIB_ITEM& aOther ) const = 0;
|
2010-10-08 20:40:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
#endif // _LIB_ITEM_H_
|