KiCad PCB EDA Suite
Loading...
Searching...
No Matches
stroke_params.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#pragma once
21
22#include <map>
23#include <units_provider.h>
24#include <gal/color4d.h>
25#include <wx/translation.h>
26#include <geometry/shape.h>
27
28
29class OUTPUTFORMATTER;
30class MSG_PANEL_ITEM;
31
32enum class BITMAPS : unsigned int;
33
34namespace KIGFX
35{
36class RENDER_SETTINGS;
37}
38
39
54
55
57{
58 wxString name;
60};
61
62
63// A cover of LINE_STYLE for the properties manager (so that it can have different
64// strings from the normal LINE_STYLE)
74
75
76
80extern const std::map<LINE_STYLE, struct LINE_STYLE_DESC> lineTypeNames;
81
82
83#define DEFAULT_LINE_STYLE_LABEL _( "Solid" )
84#define DEFAULT_WIRE_STYLE_LABEL _( "Default" )
85#define INDETERMINATE_STYLE _( "Leave unchanged" )
86
87
92{
93public:
94 STROKE_PARAMS( int aWidth = 0, LINE_STYLE aLineStyle = LINE_STYLE::DEFAULT,
96 m_width( aWidth ),
97 m_lineStyle( aLineStyle ),
98 m_color( aColor )
99 {
100 }
101
102 int GetWidth() const { return m_width; }
103 void SetWidth( int aWidth ) { m_width = aWidth; }
104
106 void SetLineStyle( LINE_STYLE aLineStyle ) { m_lineStyle = aLineStyle; }
107
108 KIGFX::COLOR4D GetColor() const { return m_color; }
109 void SetColor( const KIGFX::COLOR4D& aColor ) { m_color = aColor; }
110
111 bool operator==( const STROKE_PARAMS& aOther ) const
112 {
113 return m_width == aOther.m_width && m_lineStyle == aOther.m_lineStyle && m_color == aOther.m_color;
114 }
115
116 bool operator!=( const STROKE_PARAMS& aOther ) const { return !( *this == aOther ); }
117
118 bool operator<( const STROKE_PARAMS& aOther ) const;
119
120 void Format( OUTPUTFORMATTER* out, const EDA_IU_SCALE& aIuScale ) const;
121
122 void GetMsgPanelInfo( UNITS_PROVIDER* aUnitsProvider, std::vector<MSG_PANEL_ITEM>& aList,
123 bool aIncludeStyle = true, bool aIncludeWidth = true );
124
125 // Helper functions
126
127 static wxString GetLineStyleToken( LINE_STYLE aStyle );
128
129 static void Stroke( const SHAPE* aShape, LINE_STYLE aLineStyle, int aWidth,
130 const KIGFX::RENDER_SETTINGS* aRenderSettings,
131 const std::function<void( const VECTOR2I& a,
132 const VECTOR2I& b )>& aStroker );
133
134private:
138};
BITMAPS
A list of all bitmap identifiers.
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:400
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
EDA_MSG_PANEL items for displaying messages.
Definition msgpanel.h:50
An interface used to output 8 bit text in a convenient way.
Definition richio.h:294
An abstract shape on 2D plane.
Definition shape.h:124
Simple container to manage line stroke parameters.
int GetWidth() const
void SetLineStyle(LINE_STYLE aLineStyle)
LINE_STYLE m_lineStyle
void SetWidth(int aWidth)
void SetColor(const KIGFX::COLOR4D &aColor)
void GetMsgPanelInfo(UNITS_PROVIDER *aUnitsProvider, std::vector< MSG_PANEL_ITEM > &aList, bool aIncludeStyle=true, bool aIncludeWidth=true)
bool operator==(const STROKE_PARAMS &aOther) const
STROKE_PARAMS(int aWidth=0, LINE_STYLE aLineStyle=LINE_STYLE::DEFAULT, const KIGFX::COLOR4D &aColor=KIGFX::COLOR4D::UNSPECIFIED)
LINE_STYLE GetLineStyle() const
bool operator<(const STROKE_PARAMS &aOther) const
bool operator!=(const STROKE_PARAMS &aOther) const
void Format(OUTPUTFORMATTER *out, const EDA_IU_SCALE &aIuScale) const
KIGFX::COLOR4D GetColor() const
KIGFX::COLOR4D m_color
static void Stroke(const SHAPE *aShape, LINE_STYLE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, const std::function< void(const VECTOR2I &a, const VECTOR2I &b)> &aStroker)
static wxString GetLineStyleToken(LINE_STYLE aStyle)
@ SOLID
Definition eda_fill.h:43
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:30
const std::map< LINE_STYLE, struct LINE_STYLE_DESC > lineTypeNames
Conversion map between LINE_STYLE values and style names displayed.
LINE_STYLE
Dashed line types.
WIRE_STYLE
const BITMAPS bitmap
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708