VR-Forces Development_Version Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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/readerWriter.h"
14 #include "vrfutil/rwString.h"
16 #include "vrfutil/rwBoolean.h"
17 #include "vrfutil/rwInt.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;
36 
37 typedef boost::function<void (DtUiElement*)> DtElementChangedCallbackFcn;
38 
87 
90 {
91 public:
93  {
94  DtUiElementTypeUnknown = 0,
95  DtUiElementItemExpand = 1,
96  DtUiElementItemCollapse = 2,
97  DtUiElementHierarchySelectionChanged = 3,
98  DtUiElementAddedToHierarchy = 5,
99  DtUiElementRemovedFromHierarchy = 6,
100  DtUiElementMovedInHierarchy = 7,
101  DtUiElementReplacedInHierarchy = 8,
102  DtUiElementForceChanged = 9,
103  DtUiElementPositionModified = 12,
104  DtUiElementPositionDestroyed = 13,
105  DtUiBoundingVolumeModified = 14,
106  DtUiCanvasInitialized = 15,
107  DtUiCreateController = 19,
108  DtUiCleanup = 20,
109  DtUiElementHierarchyChanged = 21,
110  DtUiEnterEditMode = 22,
111  DtUiLeaveEditMode = 23,
112  DtUiSupportPointsModified = 24,
113  DtUiPreSaveEvent = 25,
114  DtSystemsRemoved = 26,
115  DtUiSuportPointsCalculated = 27,
116  DtUiBoundingVolumeCalculated = 28,
117  DtUiCalculateBoundingVolume = 29,
118  DtUiCalculateSupportPoints = 30
119  };
120 
121 public:
122  DtUiElementEvent(DtUiElement* owner= 0, DtUiElementEventTypes type = DtUiElementTypeUnknown) : myOwner(owner), myType(type) {};
123  DtUiElementEvent(const DtUiElementEvent& orig) : myOwner(orig.myOwner), myType(orig.myType), myValue(orig.myValue) {};
124 
125  DtUiElementEvent& operator=(const DtUiElementEvent& rhs) { myOwner = rhs.myOwner; myValue = rhs.myValue; myType = rhs.myType; return *this; };
126 
127  DtUiElement* owner() const { return myOwner; };
128  DtUiElementEventTypes type() const { return myType; };
129  void setType(DtUiElementEventTypes t) { myType = t; };
130  void setValue(const QVariant& val) { myValue = val; };
131  const QVariant& value() const { return myValue; };
132 
133 protected:
134  DtUiElement* myOwner;
135  QVariant myValue;
137 };
138 
148 
150 {
151  Q_OBJECT
152 
153 public:
154  typedef boost::function<DtUiElement* (makVrv::DtDe&)> CreatorFunction;
155  typedef std::map<std::string, CreatorFunction> UiElementFactoryMap;
156 
159  (
160  makVrv::DtDe&
161  );
162 
164  virtual ~DtUiElement();
165 
166  virtual bool blockSignals(bool);
167 
168  virtual void init(QWidget* widget, QWidget* label, DtReaderWriter* originalData, DtReaderWriter* backupData,
170 
171  virtual void init(QWidget* widget, QWidget* label, const std::vector<DtReaderWriter*>& originalData,
172  const std::vector<DtReaderWriter*>& backupData,
174 
175  virtual void init(QWidget* widget, QWidget* label, const DtObjectType&, const DtString& platformType,
177 
178  virtual DtString displayUnits() const;
179  virtual void setDisplayUnits(const DtString& units);
180 
181  virtual void setLabelText(const QString&);
182 
183  virtual DtString sourceUnits() const;
184  virtual void setSourceUnits(const DtString& units);
185 
188  virtual void setFromSystemParameterData(const DtSystemParameterData* data, const DtComponentSystemDefinition*);
189 
194  virtual void objectParametersModified() {};
195 
197  virtual void connectedTo(QObject*);
198 
200  virtual void processUiEvent(const DtUiElementEvent&) {};
201 
203  virtual void setModelModified(DtModelSetEntry*);
204 
207  virtual DtString uniqueName() const;
208 
210  virtual bool supportsSystems() const;
211 
213  virtual const DtString& platformType() const;
214 
216  virtual void setPlatformType(const DtString&);
217 
219  virtual void setObjectTypes(const std::vector<DtObjectType>&);
220 
222  virtual void aboutToShow();
223 
224 public:
226  static void registerUiTypes();
227  static DtUiElement* createUiElement(makVrv::DtDe&, const DtString& type);
228  static bool hasCreator(const DtString&);
229 
230  static void theNullFunction(DtUiElement*);
231 
232 public:
233  virtual bool isModified() const;
234 
237  virtual void decorateElement();
238 
240  virtual void setFromParameters(DtReaderWriter* parentRw);
241 
242  virtual void setFromParameters(const std::vector<DtReaderWriter*>& parentRw);
243 
247  virtual bool restoreFromBackup();
248 
249  static UiElementFactoryMap& elementFactory()
250  {
251  return theFactory;
252  }
253 
254  const std::vector<DtObjectType>& objectTypes() const
255  {
256  return myObjectTypes;
257  }
258 
259  virtual void sendEvent(const DtUiElementEvent&);
260 
261  virtual bool allValuesTheSame() const;
262 
263  static QString mixedText();
264  static void setMixedText(const QString&);
265 
268  virtual bool isMixedValue() const;
269 
271  virtual void setEnabled(bool);
272  virtual bool enabled() const;
273 
274 public slots:
275  virtual void toggleDisplayed(bool display);
276 
277 protected slots:
278  virtual void elementChanged();
279 
283  virtual void enableIfChecked();
284 
288  virtual void disableIfChecked();
289 
290 signals:
291  void uiEvent(const DtUiElementEvent&);
292 
293 protected:
294 
295  virtual double sourceToDisplayUnits(double) const;
296  virtual double displayToSourceUnits(double) const;
297 
298  virtual QString units() const;
299 
301  virtual void updateLabelTitle();
302 
304  virtual QString labelTitle() const;
305 
307  virtual void createControls(QWidget* parent);
308 
309 public:
312 
313 protected:
315 
318 
320  std::vector<DtReaderWriter*> myValues;
321  std::vector<DtReaderWriter*> myBackupValues;
322  bool myIsNew;
327 
329  std::vector<DtObjectType> myObjectTypes;
330 
332 
333  bool myEnabled;
334 
335  std::vector<QObject*> myConnectedTo;
337 };

Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)