KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ruler_item.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef PREVIEW_ITEMS_RULER_ITEM_H
21#define PREVIEW_ITEMS_RULER_ITEM_H
22
23#include <optional>
24
25#include <eda_item.h>
26#include <eda_units.h>
27#include <gal/color4d.h>
29
30namespace KIGFX
31{
32class GAL;
33
34namespace PREVIEW
35{
37
41class RULER_ITEM : public EDA_ITEM
42{
43public:
45 EDA_UNITS userUnits, bool aFlipX, bool aFlipY );
46
48 const BOX2I ViewBBox() const override;
49
51 std::vector<int> ViewGetLayers() const override;
52
53 void ViewDraw( int aLayer, KIGFX::VIEW* aView ) const override final;
54
55 void SetColor( const COLOR4D& aColor ) { m_color = aColor; }
56
57 void SetShowTicks( bool aShow ) { m_showTicks = aShow; }
58
59 void SetShowEndArrowHead( bool aShow ) { m_showEndArrowHead = aShow; }
60
64 wxArrayString GetDimensionStrings() const;
65
66#if defined(DEBUG)
67 void Show( int x, std::ostream& st ) const override
68 {
69 }
70#endif
71
77 wxString GetClass() const override
78 {
79 return wxT( "RULER_ITEM" );
80 }
81
87 void SwitchUnits( EDA_UNITS aUnits ) { m_userUnits = aUnits; }
88
89 void UpdateDir( bool aFlipX, bool aFlipY )
90 {
91 m_flipX = aFlipX;
92 m_flipY = aFlipY;
93 }
94
95private:
99 bool m_flipX;
101 std::optional<COLOR4D> m_color;
102 bool m_showTicks = true;
103 bool m_showEndArrowHead = false;
104};
105
106} // PREVIEW
107} // KIGFX
108
109#endif // PREVIEW_ITEMS_RULER_ITEM_H
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
Abstract interface for drawing on a 2D-surface.
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
void SetShowEndArrowHead(bool aShow)
Definition ruler_item.h:59
RULER_ITEM(const TWO_POINT_GEOMETRY_MANAGER &m_geomMgr, const EDA_IU_SCALE &aIuScale, EDA_UNITS userUnits, bool aFlipX, bool aFlipY)
const TWO_POINT_GEOMETRY_MANAGER & m_geomMgr
Definition ruler_item.h:96
wxArrayString GetDimensionStrings() const
Get the strings for the dimensions of the ruler.
std::optional< COLOR4D > m_color
Definition ruler_item.h:101
wxString GetClass() const override
Get class name.
Definition ruler_item.h:77
void ViewDraw(int aLayer, KIGFX::VIEW *aView) const override final
Draw the parts of the object belonging to layer aLayer.
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
void SwitchUnits(EDA_UNITS aUnits)
Switch the ruler units.
Definition ruler_item.h:87
const EDA_IU_SCALE & m_iuScale
Definition ruler_item.h:98
void UpdateDir(bool aFlipX, bool aFlipY)
Definition ruler_item.h:89
void SetColor(const COLOR4D &aColor)
Definition ruler_item.h:55
void SetShowTicks(bool aShow)
Definition ruler_item.h:57
Represent a very simple geometry manager for items that have a start and end point.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:63
EDA_UNITS
Definition eda_units.h:44
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:30