VR-Forces 4.6.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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  const std::vector<DtReaderWriter*>& values() const { return myValues; };
225  const std::vector<DtReaderWriter*>& backupValues() const { return myBackupValues; };
226 
227 public:
229  static void registerUiTypes();
230  static DtUiElement* createUiElement(makVrv::DtDe&, const DtString& type);
231  static bool hasCreator(const DtString&);
232 
233  static void theNullFunction(DtUiElement*);
234 
235 public:
236  virtual bool isModified() const;
237 
240  virtual void decorateElement();
241 
243  virtual void setFromParameters(DtReaderWriter* parentRw);
244 
245  virtual void setFromParameters(const std::vector<DtReaderWriter*>& parentRw);
246 
250  virtual bool restoreFromBackup();
251 
252  static UiElementFactoryMap& elementFactory()
253  {
254  return theFactory;
255  }
256 
257  const std::vector<DtObjectType>& objectTypes() const
258  {
259  return myObjectTypes;
260  }
261 
262  virtual void sendEvent(const DtUiElementEvent&);
263 
264  virtual bool allValuesTheSame() const;
265 
266  static QString mixedText();
267  static void setMixedText(const QString&);
268 
271  virtual bool isMixedValue() const;
272 
274  virtual void setEnabled(bool);
275  virtual bool enabled() const;
276 
277 public slots:
278  virtual void toggleDisplayed(bool display);
279 
280 protected slots:
281  virtual void elementChanged();
282 
286  virtual void enableIfChecked();
287 
291  virtual void disableIfChecked();
292 
293 signals:
294  void uiEvent(const DtUiElementEvent&);
295 
296 protected:
297 
298  virtual double sourceToDisplayUnits(double) const;
299  virtual double displayToSourceUnits(double) const;
300 
301  virtual QString units() const;
302 
304  virtual void updateLabelTitle();
305 
307  virtual QString labelTitle() const;
308 
310  virtual void createControls(QWidget* parent);
311 
312 public:
313  QWidget* myWidget;
314  QWidget* myLabel;
315 
316 protected:
318 
321 
323  std::vector<DtReaderWriter*> myValues;
324  std::vector<DtReaderWriter*> myBackupValues;
325  bool myIsNew;
330 
332  std::vector<DtObjectType> myObjectTypes;
333 
335 
336  bool myEnabled;
337 
338  std::vector<QObject*> myConnectedTo;
340 };

Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)