VR-Forces 4.2 Class Documentation
uiElement.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 2013 MaK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 
8 
9 #pragma once
10 
13 #include "vrfutil/rdrWritr.h"
14 #include "vrfutil/rwString.h"
16 #include "vrfutil/rwBoolean.h"
17 #include "vrfutil/rwInt.h"
18 #include "vrfutil/callbackList.h"
19 #include <vrfExtProtocol/objType.h>
20 
21 #include <QtCore/QObject>
22 #include <QtCore/QVariant>
23 #include <boost/function.hpp>
24 #include <boost/bind.hpp>
25 
26 class QWidget;
27 class DtUiForParameter;
31 class DtModelSetEntry;
32 class DtUiElement;
33 class QWidget;
34 class QLabel;
35 
36 typedef boost::function<void (DtUiElement*)> DtElementChangedCallbackFcn;
37 
86 
89 {
90 public:
92  {
93  DtUiElementTypeUnknown = 0,
94  DtUiElementItemExpand = 1,
95  DtUiElementItemCollapse = 2,
96  DtUiElementHierarchySelectionChanged = 3,
97  DtUiElementAddedToHierarchy = 5,
98  DtUiElementRemovedFromHierarchy = 6,
99  DtUiElementMovedInHierarchy = 7,
100  DtUiElementReplacedInHierarchy = 8,
101  DtUiElementForceChanged = 9,
102  DtUiElementPositionModified = 12,
103  DtUiElementPositionDestroyed = 13,
104  DtUiBoundingVolumeModified = 14,
105  DtUiCanvasInitialized = 15,
106  DtUiCreateController = 19,
107  DtUiCleanup = 20,
108  DtUiElementHierarchyChanged = 21,
109  DtUiEnterEditMode = 22,
110  DtUiLeaveEditMode = 23,
111  DtUiSupportPointsModified = 24
112  };
113 
114 public:
115  DtUiElementEvent(DtUiElement* owner= 0, DtUiElementEventTypes type = DtUiElementTypeUnknown) : myOwner(owner), myType(type) {};
116  DtUiElementEvent(const DtUiElementEvent& orig) : myOwner(orig.myOwner), myType(orig.myType), myValue(orig.myValue) {};
117 
118  DtUiElementEvent& operator=(const DtUiElementEvent& rhs) { myOwner = rhs.myOwner; myValue = rhs.myValue; myType = rhs.myType; return *this; };
119 
120  DtUiElement* owner() const { return myOwner; };
121  DtUiElementEventTypes type() const { return myType; };
122  void setType(DtUiElementEventTypes t) { myType = t; };
123  void setValue(const QVariant& val) { myValue = val; };
124  const QVariant& value() const { return myValue; };
125 
126 protected:
127  DtUiElement* myOwner;
128  QVariant myValue;
130 };
131 
141 
143 {
144  Q_OBJECT
145 
146 public:
147  typedef boost::function<DtUiElement* (makVrv::DtDe&)> CreatorFunction;
148  typedef std::map<std::string, CreatorFunction> UiElementFactoryMap;
149 
152  (
153  makVrv::DtDe&
154  );
155 
157  virtual ~DtUiElement();
158 
159  virtual bool blockSignals(bool);
160 
161  virtual void init(QWidget* widget, QWidget* label, DtReaderWriter* originalData, DtReaderWriter* backupData,
163 
164  virtual void init(QWidget* widget, QWidget* label, const std::vector<DtReaderWriter*>& originalData,
165  const std::vector<DtReaderWriter*>& backupData,
167 
168  virtual void init(QWidget* widget, QWidget* label, const DtObjectType&, const DtString& platformType,
170 
171  virtual DtString displayUnits() const;
172  virtual void setDisplayUnits(const DtString& units);
173 
174  virtual void setLabelText(const QString&);
175 
176  virtual DtString sourceUnits() const;
177  virtual void setSourceUnits(const DtString& units);
178 
181  virtual void setFromSystemParameterData(const DtSystemParameterData* data);
182 
187  virtual void objectParametersModified() {};
188 
190  virtual void processUiEvent(const DtUiElementEvent&) {};
191 
193  virtual void setModelModified(DtModelSetEntry*);
194 
197  virtual DtString uniqueName() const;
198 
200  virtual bool supportsSystems() const;
201 
203  virtual const DtString& platformType() const;
204 
206  virtual void setPlatformType(const DtString&);
207 
209  virtual void setObjectTypes(const std::vector<DtObjectType>&);
210 
212  virtual void aboutToShow();
213 
214 public:
216  static void registerUiTypes();
217  static DtUiElement* createUiElement(makVrv::DtDe&, const DtString& type);
218  static bool hasCreator(const DtString&);
219 
220  static void theNullFunction(DtUiElement*);
221 
222 public:
223  virtual bool isModified() const;
224 
227  virtual void decorateElement();
228 
230  virtual void setFromParameters(DtReaderWriter* parentRw);
231 
232  virtual void setFromParameters(const std::vector<DtReaderWriter*>& parentRw);
233 
237  virtual bool restoreFromBackup();
238 
239  static UiElementFactoryMap& elementFactory()
240  {
241  return theFactory;
242  }
243 
244  const std::vector<DtObjectType>& objectTypes() const
245  {
246  return myObjectTypes;
247  }
248 
249  virtual void sendEvent(const DtUiElementEvent&);
250 
251  virtual bool allValuesTheSame() const;
252 
253  static QString mixedText();
254  static void setMixedText(const QString&);
255 
258  virtual bool isMixedValue() const;
259 
260 public slots:
261  virtual void toggleDisplayed(bool display);
262 
263 protected slots:
264  virtual void elementChanged();
265 
269  virtual void enableIfChecked();
270 
274  virtual void disableIfChecked();
275 
276 signals:
277  void uiEvent(const DtUiElementEvent&);
278 
279 protected:
280 
281  virtual double sourceToDisplayUnits(double) const;
282  virtual double displayToSourceUnits(double) const;
283 
284  virtual QString units() const;
285 
287  virtual void updateLabelTitle();
288 
290  virtual QString labelTitle() const;
291 
293  virtual void createControls(QWidget* parent);
294 
295 public:
298 
299 protected:
301 
304 
306  std::vector<DtReaderWriter*> myValues;
307  std::vector<DtReaderWriter*> myBackupValues;
308  bool myIsNew;
312  makVrv::DtDe& myDe;
313 
315  std::vector<DtObjectType> myObjectTypes;
316 };

Document ID: Generated on Sun Nov 24 19:49:21 EST 2013 from SVN revision 133924
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)