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 (C) 2024 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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#pragma once
25
26#include <map>
27#include <bitmaps.h>
28#include <units_provider.h>
29#include <gal/color4d.h>
30#include <wx/translation.h>
31#include <geometry/shape.h>
32
33class OUTPUTFORMATTER;
34class MSG_PANEL_ITEM;
35
36namespace KIGFX
37{
38class RENDER_SETTINGS;
39}
40
41
45enum class LINE_STYLE
46{
47 DEFAULT = -1,
48 SOLID = 0,
50 DASH,
51 DOT,
52 DASHDOT,
55};
56
57
59{
60 wxString name;
62};
63
64
65/*
66 * Conversion map between LINE_STYLE values and style names displayed
67 */
68extern const std::map<LINE_STYLE, struct LINE_STYLE_DESC> lineTypeNames;
69
70
71#define DEFAULT_STYLE _( "Default" )
72#define INDETERMINATE_STYLE _( "Leave unchanged" )
73
74
79{
80public:
81 STROKE_PARAMS( int aWidth = 0, LINE_STYLE aLineStyle = LINE_STYLE::DEFAULT,
83 m_width( aWidth ),
84 m_lineStyle( aLineStyle ),
85 m_color( aColor )
86 {
87 }
88
89 int GetWidth() const { return m_width; }
90 void SetWidth( int aWidth ) { m_width = aWidth; }
91
93 void SetLineStyle( LINE_STYLE aLineStyle ) { m_lineStyle = aLineStyle; }
94
95 KIGFX::COLOR4D GetColor() const { return m_color; }
96 void SetColor( const KIGFX::COLOR4D& aColor ) { m_color = aColor; }
97
98 bool operator!=( const STROKE_PARAMS& aOther ) const
99 {
100 return m_width != aOther.m_width
101 || m_lineStyle != aOther.m_lineStyle
102 || m_color != aOther.m_color;
103 }
104
105 void Format( OUTPUTFORMATTER* out, const EDA_IU_SCALE& aIuScale ) const;
106
107 void GetMsgPanelInfo( UNITS_PROVIDER* aUnitsProvider, std::vector<MSG_PANEL_ITEM>& aList,
108 bool aIncludeStyle = true, bool aIncludeWidth = true );
109
110 // Helper functions
111
112 static wxString GetLineStyleToken( LINE_STYLE aStyle );
113
114 static void Stroke( const SHAPE* aShape, LINE_STYLE aLineStyle, int aWidth,
115 const KIGFX::RENDER_SETTINGS* aRenderSettings,
116 const std::function<void( const VECTOR2I& a, const VECTOR2I& b )>& aStroker );
117
118private:
122};
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition: color4d.h:398
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:54
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:322
An abstract shape on 2D plane.
Definition: shape.h:126
Simple container to manage line stroke parameters.
Definition: stroke_params.h:79
int GetWidth() const
Definition: stroke_params.h:89
void SetLineStyle(LINE_STYLE aLineStyle)
Definition: stroke_params.h:93
LINE_STYLE m_lineStyle
void SetWidth(int aWidth)
Definition: stroke_params.h:90
void SetColor(const KIGFX::COLOR4D &aColor)
Definition: stroke_params.h:96
void GetMsgPanelInfo(UNITS_PROVIDER *aUnitsProvider, std::vector< MSG_PANEL_ITEM > &aList, bool aIncludeStyle=true, bool aIncludeWidth=true)
STROKE_PARAMS(int aWidth=0, LINE_STYLE aLineStyle=LINE_STYLE::DEFAULT, const KIGFX::COLOR4D &aColor=KIGFX::COLOR4D::UNSPECIFIED)
Definition: stroke_params.h:81
LINE_STYLE GetLineStyle() const
Definition: stroke_params.h:92
bool operator!=(const STROKE_PARAMS &aOther) const
Definition: stroke_params.h:98
void Format(OUTPUTFORMATTER *out, const EDA_IU_SCALE &aIuScale) const
KIGFX::COLOR4D GetColor() const
Definition: stroke_params.h:95
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)
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
const std::map< LINE_STYLE, struct LINE_STYLE_DESC > lineTypeNames
LINE_STYLE
Dashed line types.
Definition: stroke_params.h:46
const BITMAPS bitmap
Definition: stroke_params.h:61