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
54 void ViewDraw( int aLayer, KIGFX::VIEW* aView ) const override final;
55
56 void SetColor( const COLOR4D& aColor ) { m_color = aColor; }
57
58 void SetShowTicks( bool aShow ) { m_showTicks = aShow; }
59
60 void SetShowEndArrowHead( bool aShow ) { m_showEndArrowHead = aShow; }
61
65 wxArrayString GetDimensionStrings() const;
66
67#if defined(DEBUG)
68 void Show( int x, std::ostream& st ) const override
69 {
70 }
71#endif
72
78 wxString GetClass() const override
79 {
80 return wxT( "RULER_ITEM" );
81 }
82
88 void SwitchUnits( EDA_UNITS aUnits ) { m_userUnits = aUnits; }
89
90 void UpdateDir( bool aFlipX, bool aFlipY )
91 {
92 m_flipX = aFlipX;
93 m_flipY = aFlipY;
94 }
95
96private:
102 std::optional<COLOR4D> m_color;
103 bool m_showTicks = true;
104 bool m_showEndArrowHead = false;
105};
106
107} // PREVIEW
108} // KIGFX
109
110#endif // PREVIEW_ITEMS_RULER_ITEM_H
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:37
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
void SetShowEndArrowHead(bool aShow)
Definition ruler_item.h:60
RULER_ITEM(const TWO_POINT_GEOMETRY_MANAGER &m_geomMgr, const EDA_IU_SCALE &aIuScale, EDA_UNITS userUnits, bool aFlipX, bool aFlipY)
Return the bounding box of the item covering all its layers.
const TWO_POINT_GEOMETRY_MANAGER & m_geomMgr
Definition ruler_item.h:97
wxArrayString GetDimensionStrings() const
Get the strings for the dimensions of the ruler.
std::optional< COLOR4D > m_color
Definition ruler_item.h:102
wxString GetClass() const override
Get class name.
Definition ruler_item.h:78
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 all the layers within the VIEW the object is painted on.
void SwitchUnits(EDA_UNITS aUnits)
Switch the ruler units.
Definition ruler_item.h:88
const EDA_IU_SCALE & m_iuScale
Definition ruler_item.h:99
void UpdateDir(bool aFlipX, bool aFlipY)
Definition ruler_item.h:90
void SetColor(const COLOR4D &aColor)
Definition ruler_item.h:56
void SetShowTicks(bool aShow)
Definition ruler_item.h:58
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:29