MythTV  master
DynamicLineArt.h
Go to the documentation of this file.
1 /* DynamicLineArt.h
2 
3  Copyright (C) David C. J. Matthews 2004 dm at prolingua.co.uk
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  as published by the Free Software Foundation; either version 2
8  of the License, or (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
18  Or, point your browser to http://www.gnu.org/copyleft/gpl.html
19 
20 */
21 
22 
23 #if !defined(DYNAMICLINEART_H)
24 #define DYNAMICLINEART_H
25 
26 #include "Visible.h"
27 #include "BaseActions.h"
28 
29 class MHDynamicLineArt;
30 class MHDLADisplay;
31 
32 class MHDynamicLineArt : public MHLineArt
33 {
34  public:
35  MHDynamicLineArt() = default;
36  ~MHDynamicLineArt() override;
37  const char *ClassName() override // MHLineArt
38  { return "DynamicLineArt"; }
39  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHLineArt
40  void PrintMe(FILE *fd, int nTabs) const override; // MHLineArt
41  void Preparation(MHEngine *engine) override; // MHLineArt
42 
43  // Display function.
44  void Display(MHEngine *d) override; // MHLineArt
45  // Get the opaque area. This is only opaque if the background is.
46  QRegion GetOpaqueArea() override; // MHVisible
47 
48  // This action also has the effect of clearing the drawing.
49  void SetBoxSize(int nWidth, int nHeight, MHEngine *engine) override; // MHVisible
50 
51  // Actions
52  void Clear() override; // MHRoot
53  // These actions set the properties for subsequent drawing but don't affect anything drawn so far.
54  void SetFillColour(const MHColour &colour, MHEngine *engine) override; // MHLineArt
55  void SetLineColour(const MHColour &colour, MHEngine *engine) override; // MHLineArt
56  void SetLineWidth(int nWidth, MHEngine *engine) override; // MHLineArt
57  void SetLineStyle(int nStyle, MHEngine *engine) override; // MHLineArt
58 
59  void GetLineWidth(MHRoot *pResult) override // MHRoot
60  { pResult->SetVariableValue(m_nLineWidth); }
61  void GetLineStyle(MHRoot *pResult) override // MHRoot
62  { pResult->SetVariableValue(m_lineStyle); }
63  void GetLineColour(MHRoot *pResult) override; // MHRoot
64  void GetFillColour(MHRoot *pResult) override; // MHRoot
65  void DrawArcSector(bool fIsSector, int x, int y, int width, int height, int start, int arc, MHEngine *engine) override; // MHRoot
66  void DrawLine(int x1, int y1, int x2, int y2, MHEngine *engine) override; // MHRoot
67  void DrawOval(int x1, int y1, int width, int height, MHEngine *engine) override; // MHRoot
68  void DrawRectangle(int x1, int y1, int x2, int y2, MHEngine *engine) override; // MHRoot
69  void DrawPoly(bool fIsPolygon, const MHPointVec& xArray, const MHPointVec& yArray, MHEngine *engine) override; // MHRoot
70 
71  protected:
72  MHDLADisplay *m_picture {nullptr}; // The sequence of drawing actions.
73 };
74 
75 // Actions
76 // Get Line Width - return the current line width.
78 {
79  public:
80  MHGetLineWidth(): MHActionObjectRef(":GetLineWidth") {}
81  void CallAction(MHEngine */*engine*/, MHRoot *pTarget, MHRoot *pResult) override // MHActionObjectRef
82  { pTarget->GetLineWidth(pResult); }
83 };
84 
85 // Get Line Style - return the current line style.
87 {
88  public:
89  MHGetLineStyle(): MHActionObjectRef(":GetLineStyle") {}
90  void CallAction(MHEngine */*engine*/, MHRoot *pTarget, MHRoot *pResult) override // MHActionObjectRef
91  { pTarget->GetLineStyle(pResult); }
92 };
93 // Get Line Colour - return the current line colour.
95 {
96  public:
97  MHGetLineColour(): MHActionObjectRef(":GetLineColour") {}
98  void CallAction(MHEngine */*engine*/, MHRoot *pTarget, MHRoot *pResult) override // MHActionObjectRef
99  { pTarget->GetLineColour(pResult); }
100 };
101 // Get Fill Colour - return the current fill colour.
103 {
104  public:
105  MHGetFillColour(): MHActionObjectRef(":GetFillColour") {}
106  void CallAction(MHEngine */*engine*/, MHRoot *pTarget, MHRoot *pResult) override // MHActionObjectRef
107  { pTarget->GetLineWidth(pResult); }
108 };
109 // Clear - reset the drawing
110 class MHClear: public MHElemAction {
111  public:
112  MHClear(): MHElemAction(":Clear") {}
113  void Perform(MHEngine *engine) override // MHElemAction
114  { Target(engine)->Clear(); }
115 };
116 // Draw an arc or a sector (basically a filled arc).
118  public:
119  MHDrawArcSector(const char *name, bool fIsSector): MHActionInt6(name), m_fIsSector(fIsSector) {}
120  void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4, int nArg5, int nArg6) override // MHActionInt6
121  { pTarget->DrawArcSector(m_fIsSector, nArg1, nArg2, nArg3, nArg4, nArg5, nArg6, engine); }
122  protected:
124 };
125 // Draw a line.
126 class MHDrawLine: public MHActionInt4 {
127  public:
128  MHDrawLine(): MHActionInt4(":DrawLine") {}
129  void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4) override // MHActionInt4
130  { pTarget->DrawLine(nArg1, nArg2, nArg3, nArg4, engine); }
131 };
132 // Draw an oval.
133 class MHDrawOval: public MHActionInt4 {
134  public:
135  MHDrawOval(): MHActionInt4(":DrawOval") {}
136  void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4) override // MHActionInt4
137  { pTarget->DrawOval(nArg1, nArg2, nArg3, nArg4, engine); }
138 };
139 // Draw a rectangle.
141  public:
142  MHDrawRectangle(): MHActionInt4(":DrawRectangle") {}
143  void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4) override // MHActionInt4
144  { pTarget->DrawRectangle(nArg1, nArg2, nArg3, nArg4, engine); }
145 };
146 // Polygon and PolyLine
147 class MHDrawPoly: public MHElemAction {
148  public:
149  MHDrawPoly(const char *name, bool fIsPolygon): MHElemAction(name), m_fIsPolygon(fIsPolygon) {}
150  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
151  void Perform(MHEngine *engine) override; // MHElemAction
152  protected:
153  void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
156 };
157 
158 #endif
MHActionObjectRef
Definition: BaseActions.h:120
MHDrawRectangle
Definition: DynamicLineArt.h:140
MHDrawPoly::PrintArgs
void PrintArgs(FILE *fd, int nTabs) const override
Definition: DynamicLineArt.cpp:209
MHGetLineColour::MHGetLineColour
MHGetLineColour()
Definition: DynamicLineArt.h:97
MHDrawLine
Definition: DynamicLineArt.h:126
MHDrawRectangle::MHDrawRectangle
MHDrawRectangle()
Definition: DynamicLineArt.h:142
MHDynamicLineArt::DrawRectangle
void DrawRectangle(int x1, int y1, int x2, int y2, MHEngine *engine) override
Definition: DynamicLineArt.cpp:152
MHDrawOval::MHDrawOval
MHDrawOval()
Definition: DynamicLineArt.h:135
MHDynamicLineArt::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: DynamicLineArt.cpp:39
MHGetFillColour
Definition: DynamicLineArt.h:103
MHDLADisplay
Definition: freemheg.h:172
MHLineArt
Definition: Visible.h:90
MHEngine
Definition: Engine.h:72
MHDynamicLineArt::DrawPoly
void DrawPoly(bool fIsPolygon, const MHPointVec &xArray, const MHPointVec &yArray, MHEngine *engine) override
Definition: DynamicLineArt.cpp:171
MHDynamicLineArt::MHDynamicLineArt
MHDynamicLineArt()=default
x2
static int x2
Definition: mythsocket.cpp:61
MHGetFillColour::MHGetFillColour
MHGetFillColour()
Definition: DynamicLineArt.h:105
MHDrawArcSector
Definition: DynamicLineArt.h:117
MHGetLineWidth
Definition: DynamicLineArt.h:78
MHActionInt4
Definition: BaseActions.h:93
MHDynamicLineArt::Display
void Display(MHEngine *d) override
Definition: DynamicLineArt.cpp:64
Visible.h
MHDynamicLineArt::Preparation
void Preparation(MHEngine *engine) override
Definition: DynamicLineArt.cpp:55
MHDynamicLineArt::SetLineWidth
void SetLineWidth(int nWidth, MHEngine *engine) override
Definition: DynamicLineArt.cpp:108
MHLineArt::m_lineStyle
int m_lineStyle
Definition: Visible.h:117
MHDynamicLineArt::DrawLine
void DrawLine(int x1, int y1, int x2, int y2, MHEngine *engine) override
Definition: DynamicLineArt.cpp:146
MHDynamicLineArt::GetOpaqueArea
QRegion GetOpaqueArea() override
Definition: DynamicLineArt.cpp:70
mythburn.FILE
int FILE
Definition: mythburn.py:139
MHGetLineWidth::CallAction
void CallAction(MHEngine *, MHRoot *pTarget, MHRoot *pResult) override
Definition: DynamicLineArt.h:81
MHGetLineWidth::MHGetLineWidth
MHGetLineWidth()
Definition: DynamicLineArt.h:80
MHDynamicLineArt::Clear
void Clear() override
Definition: DynamicLineArt.cpp:80
MHDrawPoly::Initialise
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: DynamicLineArt.cpp:180
MHLineArt::m_nLineWidth
int m_nLineWidth
Definition: Visible.h:116
MHDrawArcSector::m_fIsSector
bool m_fIsSector
Definition: DynamicLineArt.h:123
hardwareprofile.config.p
p
Definition: config.py:33
MHDynamicLineArt::ClassName
const char * ClassName() override
Definition: DynamicLineArt.h:37
MHDynamicLineArt::SetLineStyle
void SetLineStyle(int nStyle, MHEngine *engine) override
Definition: DynamicLineArt.cpp:115
MHDynamicLineArt::PrintMe
void PrintMe(FILE *fd, int nTabs) const override
Definition: DynamicLineArt.cpp:46
MHDrawRectangle::CallAction
void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4) override
Definition: DynamicLineArt.h:143
x1
static int x1
Definition: mythsocket.cpp:60
MHColour
Definition: BaseClasses.h:142
MHDrawLine::MHDrawLine
MHDrawLine()
Definition: DynamicLineArt.h:128
MHDynamicLineArt::~MHDynamicLineArt
~MHDynamicLineArt() override
Definition: DynamicLineArt.cpp:33
MHDynamicLineArt::GetLineColour
void GetLineColour(MHRoot *pResult) override
Definition: DynamicLineArt.cpp:121
MHDynamicLineArt::GetLineWidth
void GetLineWidth(MHRoot *pResult) override
Definition: DynamicLineArt.h:59
MHElemAction::Target
MHRoot * Target(MHEngine *engine)
Definition: BaseActions.cpp:46
MHActionInt6
Definition: BaseActions.h:106
MHDrawPoly::m_fIsPolygon
bool m_fIsPolygon
Definition: DynamicLineArt.h:154
MHDynamicLineArt::DrawArcSector
void DrawArcSector(bool fIsSector, int x, int y, int width, int height, int start, int arc, MHEngine *engine) override
Definition: DynamicLineArt.cpp:164
MHDrawPoly::MHDrawPoly
MHDrawPoly(const char *name, bool fIsPolygon)
Definition: DynamicLineArt.h:149
MHDrawArcSector::MHDrawArcSector
MHDrawArcSector(const char *name, bool fIsSector)
Definition: DynamicLineArt.h:119
MHDynamicLineArt::GetFillColour
void GetFillColour(MHRoot *pResult) override
Definition: DynamicLineArt.cpp:134
MHRoot::Clear
virtual void Clear()
Definition: Root.h:192
MHDrawPoly::m_points
MHOwnPtrSequence< MHPointArg > m_points
Definition: DynamicLineArt.h:155
MHDynamicLineArt::SetBoxSize
void SetBoxSize(int nWidth, int nHeight, MHEngine *engine) override
Definition: DynamicLineArt.cpp:86
MHDynamicLineArt::m_picture
MHDLADisplay * m_picture
Definition: DynamicLineArt.h:72
MHDynamicLineArt::SetFillColour
void SetFillColour(const MHColour &colour, MHEngine *engine) override
Definition: DynamicLineArt.cpp:96
MHDynamicLineArt
Definition: DynamicLineArt.h:33
MHDrawPoly::Perform
void Perform(MHEngine *engine) override
Definition: DynamicLineArt.cpp:193
MHDrawLine::CallAction
void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4) override
Definition: DynamicLineArt.h:129
MHDynamicLineArt::DrawOval
void DrawOval(int x1, int y1, int width, int height, MHEngine *engine) override
Definition: DynamicLineArt.cpp:158
MHParseNode
Definition: ParseNode.h:39
MHDrawPoly
Definition: DynamicLineArt.h:147
MHGetLineColour::CallAction
void CallAction(MHEngine *, MHRoot *pTarget, MHRoot *pResult) override
Definition: DynamicLineArt.h:98
MHGetLineColour
Definition: DynamicLineArt.h:95
MHGetLineStyle::MHGetLineStyle
MHGetLineStyle()
Definition: DynamicLineArt.h:89
MHDynamicLineArt::SetLineColour
void SetLineColour(const MHColour &colour, MHEngine *engine) override
Definition: DynamicLineArt.cpp:102
MHGetLineStyle::CallAction
void CallAction(MHEngine *, MHRoot *pTarget, MHRoot *pResult) override
Definition: DynamicLineArt.h:90
d
static const iso6937table * d
Definition: iso6937tables.cpp:1025
MHElemAction
Definition: BaseActions.h:35
MHClear::Perform
void Perform(MHEngine *engine) override
Definition: DynamicLineArt.h:113
MHDrawArcSector::CallAction
void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4, int nArg5, int nArg6) override
Definition: DynamicLineArt.h:120
MHGetFillColour::CallAction
void CallAction(MHEngine *, MHRoot *pTarget, MHRoot *pResult) override
Definition: DynamicLineArt.h:106
MHDrawOval::CallAction
void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg1, int nArg2, int nArg3, int nArg4) override
Definition: DynamicLineArt.h:136
MHClear::MHClear
MHClear()
Definition: DynamicLineArt.h:112
BaseActions.h
MHOwnPtrSequence< MHPointArg >
MHClear
Definition: DynamicLineArt.h:110
MHGetLineStyle
Definition: DynamicLineArt.h:87
MHDrawOval
Definition: DynamicLineArt.h:133
MHPointVec
std::vector< int > MHPointVec
Definition: BaseClasses.h:34
MHRoot
Definition: Root.h:44
MHDynamicLineArt::GetLineStyle
void GetLineStyle(MHRoot *pResult) override
Definition: DynamicLineArt.h:61