VR-Forces 4.7 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 
14 #include <readerWriter/rwString.h>
16 #include <readerWriter/rwBoolean.h>
17 #include <readerWriter/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 QCheckBox;
35 class QLabel;
37 
38 typedef boost::function<void (DtUiElement*)> DtElementChangedCallbackFcn;
39 
88 
91 {
92 public:
94  {
95  DtUiElementTypeUnknown = 0,
96  DtUiElementItemExpand = 1,
97  DtUiElementItemCollapse = 2,
98  DtUiElementHierarchySelectionChanged = 3,
99  DtUiElementAddedToHierarchy = 5,
100  DtUiElementRemovedFromHierarchy = 6,
101  DtUiElementMovedInHierarchy = 7,
102  DtUiElementReplacedInHierarchy = 8,
103  DtUiElementForceChanged = 9,
104  DtUiElementPositionModified = 12,
105  DtUiElementPositionDestroyed = 13,
106  DtUiBoundingVolumeModified = 14,
107  DtUiCanvasInitialized = 15,
108  DtUiCreateController = 19,
109  DtUiCleanup = 20,
110  DtUiElementHierarchyChanged = 21,
111  DtUiEnterEditMode = 22,
112  DtUiLeaveEditMode = 23,
113  DtUiSupportPointsModified = 24,
114  DtUiPreSaveEvent = 25,
115  DtSystemsRemoved = 26,
116  DtUiSuportPointsCalculated = 27,
117  DtUiBoundingVolumeCalculated = 28,
118  DtUiCalculateBoundingVolume = 29,
119  DtUiCalculateSupportPoints = 30,
120  DtUiMarkingChanged = 31,
121  DtUiChangeTrailEffect = 32,
122  DtUiStartSimulation = 33,
123  DtUiSetSpeedPercentage = 34,
124  DtUiSystemParameterDataChanged = 35,
125  DtUiAffectGui = 36,
126  DtUiDetonationPowerChanged = 37,
127  DtUiDamageTableChanged = 38,
128  DtUiHitTableChanged = 39,
129  DtUiElementDataChanged = 40,
130  DtUiAmmunitionChanged = 41,
131  DtUiHealthFix = 42,
132  DtUiIconListsChanged = 43,
133  DtUiSystemEvent = 44
134  };
135 
136 public:
137  DtUiElementEvent(DtUiElement* owner= 0, DtUiElementEventTypes type = DtUiElementTypeUnknown) : myOwner(owner), myType(type) {};
138  DtUiElementEvent(const DtUiElementEvent& orig) : myOwner(orig.myOwner), myType(orig.myType), myValue(orig.myValue) {};
139 
140  DtUiElementEvent& operator=(const DtUiElementEvent& rhs) { myOwner = rhs.myOwner; myValue = rhs.myValue; myType = rhs.myType; return *this; };
141 
142  DtUiElement* owner() const { return myOwner; };
143  DtUiElementEventTypes type() const { return myType; };
144  void setType(DtUiElementEventTypes t) { myType = t; };
145  void setValue(const QVariant& val) { myValue = val; };
146  const QVariant& value() const { return myValue; };
147 
148 protected:
149  DtUiElement* myOwner;
150  QVariant myValue;
152 };
153 
163 
165 {
166  Q_OBJECT
167 
168 public:
169  typedef boost::function<DtUiElement* (makVrv::DtDe&)> CreatorFunction;
170  typedef std::map<std::string, CreatorFunction> UiElementFactoryMap;
171 
174  (
175  makVrv::DtDe&
176  );
177 
179  virtual ~DtUiElement();
180 
181  virtual bool blockSignals(bool);
182 
183  virtual void init(QWidget* widget, QWidget* label, DtReaderWriter* originalData, DtReaderWriter* backupData,
185 
186  virtual void init(QWidget* widget, QWidget* label, const std::vector<DtReaderWriter*>& originalData,
187  const std::vector<DtReaderWriter*>& backupData,
189 
190  virtual void init(QWidget* widget, QWidget* label, const DtObjectType&, const DtString& platformType,
192 
193  virtual DtString displayUnits() const;
194  virtual void setDisplayUnits(const DtString& units);
195 
196  virtual void setLabelText(const QString&);
197 
198  virtual DtString sourceUnits() const;
199  virtual void setSourceUnits(const DtString& units);
200 
203  virtual void setFromSystemParameterData(const DtSystemParameterData* data, const DtComponentSystemDefinition*);
204 
209  virtual void objectParametersModified() {};
210 
212  virtual void connectedTo(QObject*);
213 
215  virtual void processUiEvent(const DtUiElementEvent&) {};
216 
218  virtual void setModelModified(DtModelSetEntry*);
219 
222  virtual DtString uniqueName() const;
223 
225  virtual bool supportsSystems() const;
226 
228  virtual const DtString& platformType() const;
229 
231  virtual void setPlatformType(const DtString&);
232 
234  virtual void setObjectTypes(const std::vector<DtObjectType>&);
235 
237  virtual void aboutToShow();
238 
239  const std::vector<DtReaderWriter*>& values() const { return myValues; };
240  const std::vector<DtReaderWriter*>& backupValues() const { return myBackupValues; };
241 
242 public:
244  static void registerUiTypes();
245  static DtUiElement* createUiElement(makVrv::DtDe&, const DtString& type);
246  static bool hasCreator(const DtString&);
247 
248  static void theNullFunction(DtUiElement*);
249 
250 public:
251  virtual bool isModified() const;
252 
255  virtual bool isValid() const;
256 
259  virtual void decorateElement();
260 
262  virtual void setFromParameters(DtReaderWriter* parentRw);
263 
266  virtual void setFromParameters(const std::vector<DtComponentSystemDefinition*>&);
267 
268  virtual void setFromParameters(const std::vector<DtReaderWriter*>& parentRw);
269 
273  virtual bool restoreFromBackup();
274 
275  static UiElementFactoryMap& elementFactory()
276  {
277  return theFactory;
278  }
279 
280  const std::vector<DtObjectType>& objectTypes() const
281  {
282  return myObjectTypes;
283  }
284 
285  const std::vector<DtComponentSystemDefinition*>& systems() const
286  {
287  return mySystems;
288  }
289 
290  virtual void sendEvent(const DtUiElementEvent&);
291 
292  virtual bool allValuesTheSame() const;
293 
294  static QString mixedText();
295  static void setMixedText(const QString&);
296 
299  virtual bool isMixedValue() const;
300 
302  virtual void setEnabled(bool);
303  virtual bool enabled() const;
304 
305  virtual void setControllingCheckBox(QCheckBox*);
306  QCheckBox* controllingCheckBox()
307  {
308  return myControllingCheckBox;
309  }
310 
311 public slots:
312  virtual void toggleDisplayed(bool display);
313 
314 protected slots:
315  virtual void elementChanged();
316 
320  virtual void enableIfChecked();
321 
325  virtual void disableIfChecked();
326 
327 signals:
328  void uiEvent(const DtUiElementEvent&);
329  void changed();
330 
331 protected:
332 
333  virtual double sourceToDisplayUnits(double) const;
334  virtual double displayToSourceUnits(double) const;
335 
336  virtual QString units() const;
337 
339  virtual void updateLabelTitle();
340 
342  virtual QString labelTitle() const;
343 
345  virtual void createControls(QWidget* parent);
346 
347 public:
348  QWidget* myWidget;
349  QWidget* myLabel;
350 
351 protected:
353 
356 
358  std::vector<DtReaderWriter*> myValues;
359  std::vector<DtReaderWriter*> myBackupValues;
360  bool myIsNew;
365 
367  std::vector<DtObjectType> myObjectTypes;
368  std::vector<DtComponentSystemDefinition*> mySystems;
369 
371 
372  bool myEnabled;
373 
374  std::vector<QObject*> myConnectedTo;
377 };

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)