VR-Forces 5.0.3 Developer's Guide
 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 
11 #if !defined(Q_MOC_RUN)
15 #include <readerWriter/rwString.h>
17 #include <readerWriter/rwBoolean.h>
18 #include <readerWriter/rwInt.h>
21 #endif
22 
23 #include <QtCore/QObject>
24 #include <QtCore/QVariant>
25 #include <boost/function.hpp>
26 #include <boost/bind.hpp>
27 
28 class QWidget;
29 class DtUiForParameter;
33 class DtModelSetEntry;
34 class QPushButton;
35 class DtUiElement;
36 class QToolButton;
37 class QWidget;
38 class QCheckBox;
39 class QDoubleSpinBox;
40 class QLabel;
42 class QBoxLayout;
43 class QHBoxLayout;
44 
45 typedef boost::function<void (DtUiElement*)> DtElementChangedCallbackFcn;
46 
95 
98 {
99 public:
101  {
102  DtUiElementTypeUnknown = 0,
103  DtUiElementItemExpand = 1,
104  DtUiElementItemCollapse = 2,
105  DtUiElementHierarchySelectionChanged = 3,
106  DtUiElementAddedToHierarchy = 5,
107  DtUiElementRemovedFromHierarchy = 6,
108  DtUiElementMovedInHierarchy = 7,
109  DtUiElementReplacedInHierarchy = 8,
110  DtUiElementForceChanged = 9,
111  DtUiElementPositionModified = 12,
112  DtUiElementPositionDestroyed = 13,
113  DtUiBoundingVolumeModified = 14,
114  DtUiCanvasInitialized = 15,
115  DtUiCreateController = 19,
116  DtUiCleanup = 20,
117  DtUiElementHierarchyChanged = 21,
118  DtUiEnterEditMode = 22,
119  DtUiLeaveEditMode = 23,
120  DtUiSupportPointsModified = 24,
121  DtUiPreSaveEvent = 25,
122  DtSystemsRemoved = 26,
123  DtUiSuportPointsCalculated = 27,
124  DtUiBoundingVolumeCalculated = 28,
125  DtUiCalculateBoundingVolume = 29,
126  DtUiCalculateSupportPoints = 30,
127  DtUiMarkingChanged = 31,
128  DtUiChangeTrailEffect = 32,
129  DtUiStartSimulation = 33,
130  DtUiSetSpeedPercentage = 34,
131  DtUiSystemParameterDataChanged = 35,
132  DtUiAffectGui = 36,
133  DtUiDetonationPowerChanged = 37,
134  DtUiDamageTableChanged = 38,
135  DtUiHitTableChanged = 39,
136  DtUiElementDataChanged = 40,
137  DtUiAmmunitionChanged = 41,
138  DtUiHealthFix = 42,
139  DtUiIconListsChanged = 43,
140  DtUiSystemEvent = 44,
141  DtArtPartUpdated = 45,
142  DtArtPartAssociated = 46,
143  DtUiAccept = 47
144  };
145 
146 public:
147  DtUiElementEvent(DtUiElement* owner= 0, DtUiElementEventTypes type = DtUiElementTypeUnknown) : myOwner(owner), myType(type) {};
148  DtUiElementEvent(const DtUiElementEvent& orig) : myOwner(orig.myOwner), myType(orig.myType), myValue(orig.myValue) {};
149 
150  DtUiElementEvent& operator=(const DtUiElementEvent& rhs) { myOwner = rhs.myOwner; myValue = rhs.myValue; myType = rhs.myType; return *this; };
151 
152  DtUiElement* owner() const { return myOwner; };
153  DtUiElementEventTypes type() const { return myType; };
154  void setType(DtUiElementEventTypes t) { myType = t; };
155  void setValue(const QVariant& val) { myValue = val; };
156  const QVariant& value() const { return myValue; };
157  bool operator==(const DtUiElementEvent& rhs) const
158  {
159  return ((myValue == rhs.myValue) && (myType == rhs.myType));
160  }
161 
162  bool operator!=(const DtUiElementEvent& rhs) const { return !(*this == rhs); };
163 
164 protected:
165  DtUiElement* myOwner;
166  QVariant myValue;
168 };
169 
179 
181 {
182  Q_OBJECT
183 
184 public:
185  typedef boost::function<DtUiElement* (makVrv::DtDe&)> CreatorFunction;
186  typedef std::map<std::string, CreatorFunction> UiElementFactoryMap;
187 
190  (
191  makVrv::DtDe&
192  );
193 
195  virtual ~DtUiElement();
196 
197  virtual bool blockSignals(bool);
198 
199  virtual void init(QWidget* widget, QWidget* label, DtReaderWriter* originalData, DtReaderWriter* backupData,
201 
202  virtual void init(QWidget* widget, QWidget* label, const std::vector<DtReaderWriter*>& originalData,
203  const std::vector<DtReaderWriter*>& backupData,
205 
206  virtual void init(QWidget* widget, QWidget* label, const DtObjectType&, const DtString& platformType,
208 
209  virtual DtString displayUnits() const;
210  virtual void setDisplayUnits(const DtString& units);
211 
212  virtual void setLabelText(const QString&);
213 
214  virtual DtString sourceUnits() const;
215  virtual void setSourceUnits(const DtString& units);
216 
219  virtual void setFromSystemParameterData(const DtSystemParameterData* data, const DtComponentSystemDefinition*);
220 
225  virtual void objectParametersModified() {};
226 
228  virtual void connectedTo(QObject*);
229 
231  virtual void processUiEvent(const DtUiElementEvent&) {};
232 
234  virtual void setModelModified(DtModelSetEntry*);
235 
238  virtual DtString uniqueName() const;
239 
241  virtual bool supportsSystems() const;
242 
244  virtual const DtString& platformType() const;
245 
247  virtual void setPlatformType(const DtString&);
248 
250  virtual void setObjectTypes(const std::vector<DtObjectType>&);
251 
253  virtual void aboutToShow();
254 
255  const std::vector<DtReaderWriter*>& values() const { return myValues; };
256  const std::vector<DtReaderWriter*>& backupValues() const { return myBackupValues; };
257 
258 public:
260  static void registerUiTypes();
261  static DtUiElement* createUiElement(makVrv::DtDe&, const DtString& type);
262  static bool hasCreator(const DtString&);
263 
264  static void theNullFunction(DtUiElement*);
265 
266 public:
267  virtual bool isModified() const;
268 
271  virtual bool isValid() const;
272 
275  virtual void decorateElement();
276 
278  virtual void setFromParameters(DtReaderWriter* parentRw);
279 
282  virtual void setFromParameters(const std::vector<DtComponentSystemDefinition*>&);
283 
284  virtual void setFromParameters(const std::vector<DtReaderWriter*>& parentRw);
285 
289  virtual bool restoreFromBackup();
290 
292  QHBoxLayout* findLayoutThatHas(QWidget* w, QBoxLayout* layout);
293 
296  QBoxLayout* findUsableLayoutFor(QWidget* w);
297 
299  {
300  return theFactory;
301  }
302 
303  const std::vector<DtObjectType>& objectTypes() const
304  {
305  return myObjectTypes;
306  }
307 
308  const std::vector<DtComponentSystemDefinition*>& systems() const
309  {
310  return mySystems;
311  }
312 
313  virtual void sendEvent(const DtUiElementEvent&);
314 
315  virtual bool allValuesTheSame() const;
316 
317  static QString mixedText();
318  static void setMixedText(const QString&);
319 
322  virtual bool isMixedValue() const;
323 
325  virtual void setEnabled(bool);
326  virtual bool enabled() const;
327 
328  virtual void setControllingCheckBox(QCheckBox*);
330  {
331  return myControllingCheckBox;
332  }
333 
335  virtual void populateParentValues(std::string elementName);
336 
337 public slots:
338  virtual void toggleDisplayed(bool display);
339 
340 protected slots:
341  virtual void elementChanged();
342 
346  virtual void enableIfChecked();
347 
351  virtual void disableIfChecked();
352 
353 signals:
354  void uiEvent(const DtUiElementEvent&);
355  void changed();
356 
357 protected:
358 
359  virtual double sourceToDisplayUnits(double) const;
360  virtual double displayToSourceUnits(double) const;
361 
362  virtual QString units() const;
363 
365  virtual void updateLabelTitle();
366 
368  virtual QString labelTitle() const;
369 
371  virtual void createControls(QWidget* parent);
372 
373 public:
374  QWidget* myWidget;
375  QWidget* myLabel;
376 
377 protected:
379 
382 
384  std::vector<DtReaderWriter*> myValues;
385  std::vector<DtReaderWriter*> myBackupValues;
386 
387  //cache the value from the parent file
389 
390  bool myIsNew;
395 
397  std::vector<DtObjectType> myObjectTypes;
398  std::vector<DtComponentSystemDefinition*> mySystems;
399 
401 
402  bool myEnabled;
403 
404  std::vector<QObject*> myConnectedTo;
407 
409 };
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:63
DtReaderWriter * myParentValue
Definition: uiElement.h:388
const std::vector< DtReaderWriter * > & backupValues() const
Definition: uiElement.h:256
QVariant myValue
Definition: uiElement.h:166
QWidget * myLabel
Definition: uiElement.h:375
DtUnit mySource
Definition: uiElement.h:392
const std::vector< DtObjectType > & objectTypes() const
Definition: uiElement.h:303
bool operator==(const DtUiElementEvent &rhs) const
Definition: uiElement.h:157
bool myIsNew
Definition: uiElement.h:390
const QVariant & value() const
Definition: uiElement.h:156
Definition: readerWriterRegistryData.h:25
DtUiElementEventTypes
Definition: uiElement.h:100
DtElementChangedCallbackFcn myElementChangedCallbackFunction
Definition: uiElement.h:391
int myUniqueId
Definition: uiElement.h:405
static UiElementFactoryMap & elementFactory()
Definition: uiElement.h:298
virtual void processUiEvent(const DtUiElementEvent &)
Process ui event. Default does nothing.
Definition: uiElement.h:231
Definition: uiForParameter.h:27
Definition: readerWriter.h:85
DtString mySourceUnits
Definition: uiElement.h:381
QCheckBox * controllingCheckBox()
Definition: uiElement.h:329
boost::function< DtUiElement *(makVrv::DtDe &)> CreatorFunction
Definition: uiElement.h:185
DtUiElementEvent(const DtUiElementEvent &orig)
Definition: uiElement.h:148
Definition: unitConversions.h:314
QCheckBox * myControllingCheckBox
Definition: uiElement.h:406
DtUiElementEventTypes myType
Definition: uiElement.h:167
DtUiElement * myOwner
Definition: uiElement.h:162
Definition: objectType.h:27
DtComponentSystemDefinition.
Definition: componentSystemDefinition.h:25
QWidget * myWidget
Definition: uiElement.h:374
Definition: modelSetEntry.h:34
std::map< std::string, CreatorFunction > UiElementFactoryMap
Definition: uiElement.h:186
binderNoArgs< _Fn > bind(const _Fn &_Func, const _Ty &_Left)
Definition: DtSTLUtilities.h:76
boost::function< void(DtUiElement *)> DtElementChangedCallbackFcn
Definition: uiElement.h:43
virtual void objectParametersModified()
This method is called any time that any of the parameters for the object are modified. It is not called for the UI element that caused the modification itself, to avoid infinite loops. Default implementation does nothing.
Definition: uiElement.h:225
const std::vector< DtComponentSystemDefinition * > & systems() const
Definition: uiElement.h:308
const DtComponentSystemDefinition * mySystemDefinition
Definition: uiElement.h:400
std::vector< DtObjectType > myObjectTypes
Definition: uiElement.h:397
DtString myPlatformType
Definition: uiElement.h:396
bool operator!=(const DtUiElementEvent &rhs) const
Definition: uiElement.h:162
Base class for RW objects that describe a system parameter. This data is used by the entity editor to...
Definition: systemParameterData.h:30
DtUiElementEvent & operator=(const DtUiElementEvent &rhs)
Definition: uiElement.h:150
DtUiElementEventTypes type() const
Definition: uiElement.h:153
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
DtUnit myDestination
Definition: uiElement.h:393
std::vector< DtReaderWriter * > myValues
Assumes 1 - 1 order that original and backup are same index in lists.
Definition: uiElement.h:384
static void theNullFunction(DtUiElement *)
bool myEnabled
Definition: uiElement.h:402
The DtUiElement class is the base for which all UI elements are defined. If you wish to create a new ...
Definition: uiElement.h:97
std::vector< DtComponentSystemDefinition * > mySystems
Definition: uiElement.h:398
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:70
std::vector< DtReaderWriter * > myBackupValues
Definition: uiElement.h:385
void setType(DtUiElementEventTypes t)
Definition: uiElement.h:154
std::vector< QObject * > myConnectedTo
Definition: uiElement.h:404
static UiElementFactoryMap theFactory
Definition: uiElement.h:378
QToolButton * myRevertToParentButton
Definition: uiElement.h:408
const std::vector< DtReaderWriter * > & values() const
Definition: uiElement.h:255
void setValue(const QVariant &val)
Definition: uiElement.h:155
DtUiElement * owner() const
Definition: uiElement.h:152
DtUiElementEvent(DtUiElement *owner=0, DtUiElementEventTypes type=DtUiElementTypeUnknown)
Definition: uiElement.h:147
#define DT_DLL_simulationObjectEditorimpl
This file is used to determine how to build.
Definition: simulationObjectEditorImplDefines.h:33
Base class of the ui element class chain. Properties available through designer for all ui elements a...
Definition: uiElement.h:180
DtString myDisplayUnits
Definition: uiElement.h:380
makVrv::DtDe & myDe
Definition: uiElement.h:394

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)