2015-06-18 15:51:53 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-05-04 12:59:14 +00:00
|
|
|
* Copyright (C) 2013-2016 CERN
|
2021-01-25 12:42:36 +00:00
|
|
|
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
2015-06-18 15:51:53 +00:00
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ORIGIN_VIEWITEM_H
|
|
|
|
#define __ORIGIN_VIEWITEM_H
|
|
|
|
|
|
|
|
#include <math/box2.h>
|
|
|
|
#include <view/view.h>
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h>
|
2015-06-18 15:51:53 +00:00
|
|
|
#include <gal/color4d.h>
|
2021-06-08 02:14:48 +00:00
|
|
|
#include <eda_item.h>
|
2020-10-14 02:46:39 +00:00
|
|
|
|
2015-06-18 15:51:53 +00:00
|
|
|
/**
|
|
|
|
* View item to draw an origin marker.
|
|
|
|
*/
|
|
|
|
namespace KIGFX {
|
|
|
|
|
2020-09-09 02:54:17 +00:00
|
|
|
class ORIGIN_VIEWITEM : public EDA_ITEM
|
2015-06-18 15:51:53 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-01-25 12:42:36 +00:00
|
|
|
///< Marker symbol styles
|
2020-01-19 04:42:10 +00:00
|
|
|
enum MARKER_STYLE
|
|
|
|
{
|
|
|
|
NO_GRAPHIC, CROSS, X, DOT, CIRCLE_CROSS, CIRCLE_X, CIRCLE_DOT, DASH_LINE
|
|
|
|
};
|
2015-06-18 15:51:53 +00:00
|
|
|
|
2015-09-05 19:47:35 +00:00
|
|
|
ORIGIN_VIEWITEM( const COLOR4D& aColor = COLOR4D( 1.0, 1.0, 1.0, 1.0 ),
|
|
|
|
MARKER_STYLE aStyle = CIRCLE_X, int aSize = 16,
|
|
|
|
const VECTOR2D& aPosition = VECTOR2D( 0, 0 ) );
|
2015-06-18 15:51:53 +00:00
|
|
|
|
2021-06-08 03:06:11 +00:00
|
|
|
ORIGIN_VIEWITEM( const VECTOR2D& aPosition, EDA_ITEM_FLAGS flags );
|
2018-01-24 21:27:56 +00:00
|
|
|
|
2018-01-24 10:19:33 +00:00
|
|
|
ORIGIN_VIEWITEM* Clone() const override;
|
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
const BOX2I ViewBBox() const override;
|
2015-06-18 15:51:53 +00:00
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
void ViewDraw( int aLayer, VIEW* aView ) const override;
|
2015-06-18 15:51:53 +00:00
|
|
|
|
2016-12-05 22:54:41 +00:00
|
|
|
void ViewGetLayers( int aLayers[], int& aCount ) const override
|
2015-06-18 15:51:53 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
aLayers[0] = LAYER_GP_OVERLAY;
|
2015-06-18 15:51:53 +00:00
|
|
|
aCount = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(DEBUG)
|
2016-09-24 18:53:15 +00:00
|
|
|
void Show( int x, std::ostream& st ) const override
|
2015-06-18 15:51:53 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-12-19 23:29:10 +00:00
|
|
|
/**
|
|
|
|
* Get class name.
|
|
|
|
*
|
|
|
|
* @return string "ORIGIN_VIEWITEM"
|
2015-06-18 15:51:53 +00:00
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
wxString GetClass() const override
|
2015-06-18 15:51:53 +00:00
|
|
|
{
|
|
|
|
return wxT( "ORIGIN_VIEWITEM" );
|
|
|
|
}
|
|
|
|
|
2015-09-05 19:47:35 +00:00
|
|
|
/**
|
2020-12-19 23:29:10 +00:00
|
|
|
* Set the draw at zero flag.
|
|
|
|
*
|
Fix source comment/doc typos (follow-up)
Found via `codespell -q 3 -S *.po,./thirdparty -L aactual,acount,aline,alocation,alog,anormal,anumber,aother,apoints,aparent,aray,dout,einstance,modul,ot,overide,serie,te,,tesselate,tesselator,tht`
2021-07-03 22:37:31 +00:00
|
|
|
* When set the marker will be drawn when its position is 0,0. Otherwise it will not
|
2020-12-19 23:29:10 +00:00
|
|
|
* be drawn when its position is 0,0.
|
|
|
|
*
|
|
|
|
* @param aDrawFlag The value to set the draw at zero flag.
|
2015-09-05 19:47:35 +00:00
|
|
|
*/
|
|
|
|
inline void SetDrawAtZero( bool aDrawFlag )
|
|
|
|
{
|
|
|
|
m_drawAtZero = aDrawFlag;
|
|
|
|
}
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void SetPosition( const VECTOR2I& aPosition ) override
|
2018-01-24 10:19:33 +00:00
|
|
|
{
|
|
|
|
m_position = VECTOR2D( aPosition );
|
|
|
|
}
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I GetPosition() const override
|
2015-06-18 15:51:53 +00:00
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
return VECTOR2I( m_position.x, m_position.y );
|
2015-06-18 15:51:53 +00:00
|
|
|
}
|
|
|
|
|
2020-01-19 04:42:10 +00:00
|
|
|
inline void SetEndPosition( const VECTOR2D& aPosition )
|
|
|
|
{
|
|
|
|
m_end = aPosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void SetEndPosition( const wxPoint& aPosition )
|
|
|
|
{
|
|
|
|
m_end = VECTOR2D( aPosition );
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const wxPoint GetEndPosition() const
|
|
|
|
{
|
|
|
|
return wxPoint( m_end.x, m_end.y );
|
|
|
|
}
|
|
|
|
|
2015-06-18 15:51:53 +00:00
|
|
|
inline void SetSize( int aSize )
|
|
|
|
{
|
|
|
|
m_size = aSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int GetSize() const
|
|
|
|
{
|
|
|
|
return m_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void SetColor( const KIGFX::COLOR4D& aColor )
|
|
|
|
{
|
|
|
|
m_color = aColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const KIGFX::COLOR4D& GetColor() const
|
|
|
|
{
|
|
|
|
return m_color;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void SetStyle( MARKER_STYLE aStyle )
|
|
|
|
{
|
|
|
|
m_style = aStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline MARKER_STYLE GetStyle() const
|
|
|
|
{
|
|
|
|
return m_style;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2021-01-25 12:42:36 +00:00
|
|
|
///< Marker coordinates.
|
2015-06-18 15:51:53 +00:00
|
|
|
VECTOR2D m_position;
|
|
|
|
|
2021-01-25 12:42:36 +00:00
|
|
|
///< Marker end position for markers that stretch between points
|
2020-01-19 04:42:10 +00:00
|
|
|
VECTOR2D m_end;
|
|
|
|
|
2021-01-25 12:42:36 +00:00
|
|
|
///< Marker size (in pixels).
|
2015-06-18 15:51:53 +00:00
|
|
|
int m_size;
|
|
|
|
|
2021-01-25 12:42:36 +00:00
|
|
|
///< Marker color.
|
2015-06-18 15:51:53 +00:00
|
|
|
COLOR4D m_color;
|
|
|
|
|
2021-01-25 12:42:36 +00:00
|
|
|
///< Marker symbol.
|
2015-06-18 15:51:53 +00:00
|
|
|
MARKER_STYLE m_style;
|
2015-09-05 19:47:35 +00:00
|
|
|
|
2021-01-25 12:42:36 +00:00
|
|
|
///< If set, the marker will be drawn even if its position is 0,0
|
2015-09-05 19:47:35 +00:00
|
|
|
bool m_drawAtZero;
|
2015-06-18 15:51:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace KIGFX
|
|
|
|
|
|
|
|
#endif
|