Version: 0.6.0
gpparam.h
1 /******************************************************************************
2  * Project: wxGIS (GIS Toolbox)
3  * Purpose: parameter class.
4  * Author: Dmitry Baryshnikov (aka Bishop), polimax@mail.ru
5  ******************************************************************************
6 * Copyright (C) 2010,2012 Dmitry Baryshnikov
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  ****************************************************************************/
21 
22 #pragma once
23 
24 #include "wxgis/geoprocessing/geoprocessing.h"
25 #include "wxgis/geoprocessing/gpdomain.h"
26 
27 #include "wx/event.h"
28 
29 class WXDLLIMPEXP_GIS_GP wxGISGPParamEvent;
30 
31 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_GIS_GP, wxGPPARAM_CHANGED, wxGISGPParamEvent);
32 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_GIS_GP, wxGPPARAM_MSG_SET, wxGISGPParamEvent);
33 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_GIS_GP, wxGPPARAM_DOMAIN_ADDVAL, wxGISGPParamEvent);
34 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_GIS_GP, wxGPPARAM_DOMAIN_CLEAR, wxGISGPParamEvent);
35 
39 class WXDLLIMPEXP_GIS_GP wxGISGPParamEvent : public wxEvent
40 {
41 public:
42  wxGISGPParamEvent(int nId = wxID_ANY, wxEventType eventType = wxGPPARAM_CHANGED, const wxVariant &Value = wxNullVariant, const wxString &sName = wxEmptyString ) : wxEvent(nId, eventType)
43  {
44  m_Value = Value;
45  m_sName = sName;
46  }
47 
48  wxGISGPParamEvent(const wxGISGPParamEvent& event) : wxEvent(event)
49  {
50  m_Value = event.m_Value;
51  m_Value.UnShare();
52  m_sName = event.m_sName.Clone();
53  }
54 
55  wxVariant GetParamValue() const { return m_Value; }
56  void SetParamValue(const wxVariant &Value) { m_Value = Value; }
57  wxString GetName() const { return m_sName; }
58  void SetName(const wxString &sName) { m_sName = sName; }
59 
60  virtual wxEvent *Clone() const { return new wxGISGPParamEvent(*this); }
61 
62 protected:
63  wxVariant m_Value;
64  wxString m_sName;
65 private:
66  DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGISGPParamEvent)
67 };
68 
69 typedef void (wxEvtHandler::*wxGISGPParamEventFunction)(wxGISGPParamEvent&);
70 
71 #define wxGISGPParamEventHandler(func) \
72  wxEVENT_HANDLER_CAST(wxGISGPParamEventFunction, func)
73 
74 #define EVT_GPPARAM_CHANGED(func) wx__DECLARE_EVT0(wxGPPARAM_CHANGED, wxGISGPParamEventHandler(func))
75 #define EVT_GPPARAM_MSG_SET(func) wx__DECLARE_EVT0(wxGPPARAM_MSG_SET, wxGISGPParamEventHandler(func))
76 #define EVT_GPPARAM_DOMAIN_ADDVAL(func) wx__DECLARE_EVT0(wxGPPARAM_DOMAIN_ADDVAL, wxGISGPParamEventHandler(func))
77 #define EVT_GPPARAM_DOMAIN_CLEAR(func) wx__DECLARE_EVT0(wxGPPARAM_DOMAIN_CLEAR, wxGISGPParamEventHandler(func))
78 
82 class WXDLLIMPEXP_GIS_GP wxGISGPParameter :
83  public wxEvtHandler,
85  public IGISGPDomainParent
86 {
87  friend class wxGISGPParameterArray;
88  DECLARE_CLASS(wxGISGPParameter)
89 public:
90  wxGISGPParameter(void);
91  wxGISGPParameter(const wxString &sName, const wxString &sDisplayName, wxGISEnumGPParameterType eType, wxGISEnumGPParameterDataType eDataType);
92  virtual ~wxGISGPParameter(void);
93  virtual bool GetAltered(void) const;
94  virtual void SetAltered(bool bAltered);
95  virtual bool GetHasBeenValidated(void) const;
96  virtual void SetHasBeenValidated(bool bHasBeenValidated);
97  virtual bool IsValid(void) const;
98  virtual void SetValid(bool bIsValid);
99  virtual wxString GetName(void) const;
100  virtual void SetName(const wxString &sName);
101  virtual wxString GetDisplayName(void) const;
102  virtual void SetDisplayName(const wxString &sDisplayName);
103  virtual wxGISEnumGPParameterDataType GetDataType(void) const;
104  virtual void SetDataType(wxGISEnumGPParameterDataType nType);
105  virtual wxGISEnumGPParameterDirection GetDirection(void) const;
106  virtual void SetDirection(wxGISEnumGPParameterDirection nDirection);
107  virtual wxGISEnumGPParameterType GetParameterType(void) const;
108  virtual void SetParameterType(wxGISEnumGPParameterType nType);
109  virtual wxVariant GetValue(void) const;
110  virtual void SetValue(const wxVariant &Val);
111  virtual wxGISGPValueDomain* GetDomain(void) const;
112  virtual void SetDomain(wxGISGPValueDomain* pDomain);
113  virtual wxString GetMessage(void) const;
114  virtual wxGISEnumGPMessageType GetMessageType(void) const;
115  virtual void SetMessage(wxGISEnumGPMessageType nType = wxGISEnumGPMessageUnknown, const wxString &sMsg = wxEmptyString);
116  virtual void AddDependency(const wxString &sParamName);
117  virtual wxArrayString GetDependences(void) const;
122  virtual wxString GetAsString(void) const;
127  virtual bool SetFromString(wxString &sParam);
128  virtual int GetSelDomainValue(void) const;
129  virtual void SetSelDomainValue(int nNewSelection);
130  //
131  virtual void OnValueAdded(const wxVariant &Value, const wxString &sName);
132  virtual void OnCleared(void);
133 protected:
134  virtual void SetId(size_t nId);
135  virtual size_t GetId(void) const;
136 protected:
137  bool m_bAltered;
138  bool m_bHasBeenValidated;
139  bool m_bIsValid;
140  wxString m_sName;
141  wxString m_sDisplayName;
142  wxGISEnumGPParameterDataType m_DataType;
143  wxGISEnumGPParameterDirection m_Direction;
144  wxGISEnumGPParameterType m_ParameterType;
145  wxVariant m_Value;
146  wxGISGPValueDomain* m_pDomain;
147  wxString m_sMessage;
148  wxGISEnumGPMessageType m_nMsgType;
149  int m_nSelection;
150  wxArrayString m_saDependencies;
151  size_t m_nId;
152 };
153 
157 //WX_DECLARE_USER_EXPORTED_BASEARRAY(wxGISGPParameter *, wxGISGPParamArray, WXDLLIMPEXP_GIS_GP);
158 WX_DEFINE_USER_EXPORTED_ARRAY(wxGISGPParameter*, wxGISGPParamArray, class WXDLLIMPEXP_GIS_GP);
159 
160 class WXDLLIMPEXP_GIS_GP wxGISGPParameterArray : public wxGISGPParamArray
161 {
162 public:
163  void Add (wxGISGPParameter * item)
164  {
165  wxGISGPParamArray::Add(item, 1);
166  item->SetId(GetCount() - 1);
167  }
168  wxGISGPParameter * GetParameter(const wxString &sParamName) const
169  {
170  for(size_t i = 0; i < GetCount(); ++i)
171  if(Item(i)->GetName().IsSameAs(sParamName, false))
172  return Item(i);
173  return NULL;
174  }
175 };
176 
177 
183 class WXDLLIMPEXP_GIS_GP wxGISGPMultiParameter : public wxGISGPParameter
184 {
185  DECLARE_CLASS(wxGISGPMultiParameter)
186 public:
187  wxGISGPMultiParameter(void);
188  wxGISGPMultiParameter(const wxString &sName, const wxString &sDisplayName, wxGISEnumGPParameterType eType, wxGISEnumGPParameterDataType eDataType);
189  virtual ~wxGISGPMultiParameter(void);
190  virtual void AddColumn(const wxString &sName);
191  virtual void RemoveColumn(size_t nIndex);
192  virtual size_t GetColumnCount(void) const;
193  virtual wxString GetColumnName(size_t nIndex) const;
194  virtual size_t GetRowCount(void) const;
195  virtual void AddParameter(size_t nColIndex, size_t nRowIndex, wxGISGPParameter* pParam);
196  virtual bool IsValid(void) const;
197  virtual void SetValid(bool bIsValid);
198  virtual void Clear();
199  //wxGISGPParameter
200  virtual wxGISEnumGPParameterDataType GetDataType(void) const;
201  virtual wxString GetAsString(void) const;
202  virtual bool SetFromString(wxString &sParam);
203  virtual wxGISGPParameter* GetParameter(size_t nCol, size_t nRow) const;
204 protected:
205  wxGISGPParameterArray m_paParameters;
206  wxArrayString m_saColumnNames;
207 };
A Geoprocessing tools parameter class.
Definition: gpparam.h:82
Definition: gpparam.h:160
Definition: gptable.h:44
Definition: gpdomain.h:36
Definition: pointer.h:34
virtual void OnCleared(void)=0
virtual wxString GetAsString(void) const
Serialize parameter to string.
Definition: gpparam.cpp:286
virtual void OnValueAdded(const wxVariant &Value, const wxString &sName)=0
Definition: gpdomain.h:63
The wxGISProcess class event.
Definition: gpparam.h:39
virtual bool SetFromString(wxString &sParam)
Serialize parameter from string.
Definition: gpparam.cpp:293
A Geoprocessing tools multiparameter class.
Definition: gpparam.h:183