ToolMap
Loading...
Searching...
No Matches
tmsymbolrule.h
1/***************************************************************************
2 tmsymbolrule.h
3 -------------------
4 copyright : (C) 2012 CREALP Lucien Schreiber
5 ***************************************************************************/
6
7/***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15#ifndef _TMSYMBOLRULE_H_
16#define _TMSYMBOLRULE_H_
17
18// For compilers that support precompilation, includes "wx/wx.h".
19#include <wx/wxprec.h>
20
21// Include wxWidgets' headers
22#ifndef WX_PRECOMP
23#include <wx/wx.h>
24#endif
25
26#include <wx/clrpicker.h>
27
28#include "../components/wxserialize/tmserialize.h" // for object serialization
29#include "tmlayerpropertiesdef.h"
30
31class tmSymbolVector;
32
33class tmSymbolDLG;
34
36
37const int ID_SYMBOLEDIT_COLORCTRL = 10370;
38
40 private:
41 TM_GIS_SPATIAL_TYPES m_SpatialType;
42 wxString m_AttributFilter;
43 tmSymbolVector* m_SymbolData;
44 wxString m_RuleName;
45 bool m_Active;
46
47 int _GetRandomNumberForColor();
48
49 tmSymbolVector* _NewSymbolVectorBasedOnSpatType(TM_GIS_SPATIAL_TYPES spatialtype);
50
51 public:
52 tmSymbolRule(TM_GIS_SPATIAL_TYPES spatialtype, tmSymbolVector* symbol = nullptr);
53
54 virtual ~tmSymbolRule();
55
57
58 wxBrush GetBrush();
59
60 wxPen GetPen();
61
62 bool IsOriented();
63
64 inline const TM_GIS_SPATIAL_TYPES GetSpatialType() const;
65
66 inline const bool IsActive() const;
67
68 void SetActive(bool value);
69
70 inline const wxString GetAttributFilter() const;
71
72 void SetAttributFilter(wxString value);
73
74 inline const wxString GetRuleName() const;
75
76 void SetRuleName(wxString value);
77
78 void SetRandomColor();
79
80 static void InitRandomGenerator();
81
82 inline tmSymbolVector* GetSymbolData();
83
84 tmSymbolRule& operator=(tmSymbolRule& source);
85};
86
87inline const TM_GIS_SPATIAL_TYPES tmSymbolRule::GetSpatialType() const {
88 return m_SpatialType;
89}
90
91inline const bool tmSymbolRule::IsActive() const {
92 return m_Active;
93}
94
95inline const wxString tmSymbolRule::GetAttributFilter() const {
96 return m_AttributFilter;
97}
98
99inline const wxString tmSymbolRule::GetRuleName() const {
100 return m_RuleName;
101}
102
103inline tmSymbolVector* tmSymbolRule::GetSymbolData() {
104 return m_SymbolData;
105}
106
107WX_DECLARE_OBJARRAY(tmSymbolRule*, tmSymbolRuleArray);
108
109/***************************************************************************/
115 private:
116 tmSymbolRuleArray m_Rules;
117
118 int m_DlgSelectedPanel;
119 wxString m_DlgSelectedFieldname;
120 tmLayerProperties* m_LayerProperties;
121
122 void _CreateAttributIndex(tmLayerProperties* layerproperties);
123
124 public:
125 tmSymbolRuleManager(tmLayerProperties* layerproperties);
126
127 virtual ~tmSymbolRuleManager();
128
129 inline tmSymbolRuleArray* GetRulesRef();
130
131 bool ShowSymbolRuleDlg(wxWindow* parent, const wxPoint& position);
132
133 bool IsUsingRules();
134
135 wxString GetFieldName() {
136 return m_DlgSelectedFieldname;
137 }
138
139 bool Serialize(tmSerialize& s);
140
141 tmSymbolRuleManager& operator=(const tmSymbolRuleManager& source);
142
143 // utilities functions
144 static void RuleArrayClear(tmSymbolRuleArray* rules);
145
146 static void RuleArrayCopy(const tmSymbolRuleArray* srcrules, tmSymbolRuleArray* dstrules);
147};
148
149inline tmSymbolRuleArray* tmSymbolRuleManager::GetRulesRef() {
150 return &m_Rules;
151}
152
153/*************************************************************************************/
158class tmSymbolRuleEdit_DLG : public wxDialog {
159 private:
160 tmSymbolRule* m_Rule;
161
162 wxButton* m_ColourCtrl;
163 wxTextCtrl* m_NameCtrl;
164 wxTextCtrl* m_AttributeCtrl;
165 wxCheckBox* m_EnabledCtrl;
166
167 void _CreateControls();
168
169 virtual bool TransferDataFromWindow();
170
171 virtual bool TransferDataToWindow();
172
173 void OnSymbologyEdit(wxCommandEvent& event);
174
175 DECLARE_EVENT_TABLE();
176
177 public:
178 tmSymbolRuleEdit_DLG(wxWindow* parent, tmSymbolRule* rule, wxWindowID id = wxID_ANY,
179 const wxString& caption = _("Edit Symbology"), const wxPoint& pos = wxDefaultPosition,
180 const wxSize& size = wxDefaultSize);
181
182 virtual ~tmSymbolRuleEdit_DLG();
183
184 inline tmSymbolRule* GetRule() const;
185};
186
187inline tmSymbolRule* tmSymbolRuleEdit_DLG::GetRule() const {
188 return m_Rule;
189}
190
191#endif
Storing object of layer type.
Definition tmlayerproperties.h:47
Definition tmserialize.h:36
Definition tmsymboldlg.h:55
Edit rule symbology dialog.
Definition tmsymbolrule.h:158
Symbol Rule manager.
Definition tmsymbolrule.h:114
Definition tmsymbolrule.h:39
Definition tmsymbolvector.h:29