VR-Forces 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>
20 #include <vlpi/entityType.h>
21 #endif
22 
23 #include <QtCore/QObject>
24 #include <QtCore/QVariant>
25 #include <boost/function.hpp>
26 #include <boost/bind/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  DtUiAppearanceModified = 48,
145  DtUiAnimateArtPart = 49,
146  DtUiFireArtPart = 50,
147  DtUiDamagePointsTableChanged = 51,
148  DtUiSetHeading = 52,
149  DtUiSystemPropertiesChanged = 53,
150  DtUiHitZoneDestroyed = 54,
151  DtUiHitZoneDestroyAllVisualizations = 55,
152  DtUiHitZoneRefreshSystems = 56,
153  DtUiHitZoneRemoveFromSystems = 57,
154  DtUiHitZoneSmokeParticleAddOrUpdateVisualizer = 58,
155  DtUiHitZoneSmokeParticleDestroyVisualizer = 59,
156  DtUiHitZoneModified = 60
157  };
158 
159 public:
160  DtUiElementEvent(DtUiElement* owner= 0, DtUiElementEventTypes type = DtUiElementTypeUnknown) : myOwner(owner), myType(type) {};
161  DtUiElementEvent(const DtUiElementEvent& orig) : myOwner(orig.myOwner), myType(orig.myType), myValue(orig.myValue) {};
162 
163  DtUiElementEvent& operator=(const DtUiElementEvent& rhs) { myOwner = rhs.myOwner; myValue = rhs.myValue; myType = rhs.myType; return *this; };
164 
165  DtUiElement* owner() const { return myOwner; };
166  DtUiElementEventTypes type() const { return myType; };
167  void setType(DtUiElementEventTypes t) { myType = t; };
168  void setValue(const QVariant& val) { myValue = val; };
169  const QVariant& value() const { return myValue; };
170  bool operator==(const DtUiElementEvent& rhs) const
171  {
172  return ((myValue == rhs.myValue) && (myType == rhs.myType));
173  }
174 
175  bool operator!=(const DtUiElementEvent& rhs) const { return !(*this == rhs); };
176 
177 protected:
178  DtUiElement* myOwner;
179  QVariant myValue;
181 };
182 
192 
194 {
195  Q_OBJECT
196 
197 public:
198  typedef boost::function<DtUiElement* (makVrv::DtDe&)> CreatorFunction;
199  typedef std::map<std::string, CreatorFunction> UiElementFactoryMap;
200 
203  (
204  makVrv::DtDe&
205  );
206 
208  virtual ~DtUiElement() override;
209 
210  virtual bool blockSignals(bool);
211 
212  virtual void init(QWidget* widget, QWidget* label, DtReaderWriter* originalData, DtReaderWriter* backupData,
213  DtElementChangedCallbackFcn = boost::bind(&DtUiElement::theNullFunction, boost::placeholders::_1));
214 
215  virtual void init(QWidget* widget, QWidget* label, const std::vector<DtReaderWriter*>& originalData,
216  const std::vector<DtReaderWriter*>& backupData,
217  DtElementChangedCallbackFcn = boost::bind(&DtUiElement::theNullFunction, boost::placeholders::_1));
218 
219  virtual void init(QWidget* widget, QWidget* label, const DtEntityType&, const DtString& platformType,
220  DtElementChangedCallbackFcn = boost::bind(&DtUiElement::theNullFunction, boost::placeholders::_1));
221 
222  virtual DtString displayUnits() const;
223  virtual void setDisplayUnits(const DtString& units);
224 
225  virtual void setLabelText(const QString&);
226 
227  virtual DtString sourceUnits() const;
228  virtual void setSourceUnits(const DtString& units);
229 
232  virtual void setFromSystemParameterData(const DtSystemParameterData* data, const DtComponentSystemDefinition*);
233 
238  virtual void objectParametersModified() {};
239 
241  virtual void connectedTo(QObject*);
242 
244  virtual void processUiEvent(const DtUiElementEvent&) {};
245 
247  virtual void setModelModified(DtModelSetEntry*);
248 
251  virtual DtString uniqueName() const;
252 
254  virtual bool supportsSystems() const;
255 
257  virtual const DtString& platformType() const;
258 
260  virtual void setPlatformType(const DtString&);
261 
263  virtual void setObjectTypes(const std::vector<DtEntityType>&);
264 
266  virtual void aboutToShow();
267 
268  const std::vector<DtReaderWriter*>& values() const { return myValues; };
269  const std::vector<DtReaderWriter*>& backupValues() const { return myBackupValues; };
270 
271 public:
273  static void registerUiTypes();
274  static DtUiElement* createUiElement(makVrv::DtDe&, const DtString& type);
275  static bool hasCreator(const DtString&);
276 
277  static void theNullFunction(DtUiElement*);
278 
279 public:
280  virtual bool isModified() const;
281 
284  virtual bool isValid() const;
285 
288  virtual void decorateElement();
289 
291  virtual void setFromParameters(DtReaderWriter* parentRw);
292 
295  virtual void setFromParameters(const std::vector<DtComponentSystemDefinition*>&);
296 
297  virtual void setFromParameters(const std::vector<DtReaderWriter*>& parentRw);
298 
302  virtual bool restoreFromBackup();
303 
305  QHBoxLayout* findLayoutThatHas(QWidget* w, QBoxLayout* layout);
306 
309  QBoxLayout* findUsableLayoutFor(QWidget* w);
310 
312  {
313  return theFactory;
314  }
315 
316  const std::vector<DtEntityType>& objectTypes() const
317  {
318  return myObjectTypes;
319  }
320 
321  const std::vector<DtComponentSystemDefinition*>& systems() const
322  {
323  return mySystems;
324  }
325 
326  virtual void sendEvent(const DtUiElementEvent&);
327 
328  virtual bool allValuesTheSame() const;
329 
330  static QString mixedText();
331  static void setMixedText(const QString&);
332 
335  virtual bool isMixedValue() const;
336 
338  virtual void setEnabled(bool);
339  virtual bool enabled() const;
340 
341  virtual void setControllingCheckBox(QCheckBox*);
343  {
344  return myControllingCheckBox;
345  }
346 
348  virtual void populateParentValues(std::string elementName);
349 
350 public slots:
351  virtual void toggleDisplayed(bool display);
352 
353 protected slots:
354  virtual void elementChanged();
355 
359  virtual void enableIfChecked();
360 
364  virtual void disableIfChecked();
365 
366 signals:
367  void uiEvent(const DtUiElementEvent&);
368  void changed();
369 
370 protected:
371 
372  virtual double sourceToDisplayUnits(double) const;
373  virtual double displayToSourceUnits(double) const;
374 
375  virtual QString units() const;
376 
378  virtual void updateLabelTitle();
379 
381  virtual QString labelTitle() const;
382 
384  virtual void createControls(QWidget* parent);
385 
386 public:
387  QWidget* myWidget;
388  QWidget* myLabel;
389 
390 protected:
392 
395 
397  std::vector<DtReaderWriter*> myValues;
398  std::vector<DtReaderWriter*> myBackupValues;
399 
400  //cache the value from the parent file
402 
403  bool myIsNew;
408 
410  std::vector<DtEntityType> myObjectTypes;
411  std::vector<DtComponentSystemDefinition*> mySystems;
412 
414 
415  bool myEnabled;
416 
417  std::vector<QObject*> myConnectedTo;
420 
422 };
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:64
DtReaderWriter * myParentValue
Definition: uiElement.h:401
const std::vector< DtReaderWriter * > & backupValues() const
Definition: uiElement.h:269
QVariant myValue
Definition: uiElement.h:179
QWidget * myLabel
Definition: uiElement.h:388
DtUnit mySource
Definition: uiElement.h:405
bool operator==(const DtUiElementEvent &rhs) const
Definition: uiElement.h:170
bool myIsNew
Definition: uiElement.h:403
const QVariant & value() const
Definition: uiElement.h:169
const std::vector< DtEntityType > & objectTypes() const
Definition: uiElement.h:316
Definition: readerWriterRegistryData.h:25
DtUiElementEventTypes
Definition: uiElement.h:100
DtElementChangedCallbackFcn myElementChangedCallbackFunction
Definition: uiElement.h:404
int myUniqueId
Definition: uiElement.h:418
static UiElementFactoryMap & elementFactory()
Definition: uiElement.h:311
virtual void processUiEvent(const DtUiElementEvent &)
Process ui event. Default does nothing.
Definition: uiElement.h:244
Definition: uiForParameter.h:27
Definition: readerWriter.h:85
DtString mySourceUnits
Definition: uiElement.h:394
QCheckBox * controllingCheckBox()
Definition: uiElement.h:342
boost::function< DtUiElement *(makVrv::DtDe &)> CreatorFunction
Definition: uiElement.h:198
DtUiElementEvent(const DtUiElementEvent &orig)
Definition: uiElement.h:161
Definition: unitConversions.h:309
QCheckBox * myControllingCheckBox
Definition: uiElement.h:419
DtUiElementEventTypes myType
Definition: uiElement.h:180
DtUiElement * myOwner
Definition: uiElement.h:175
std::vector< DtEntityType > myObjectTypes
Definition: uiElement.h:410
Reader/Writer class which specifies the contents of a DtComponentSystem. This lists the sensors...
Definition: componentSystemDefinition.h:31
QWidget * myWidget
Definition: uiElement.h:387
Definition: modelSetEntry.h:34
std::map< std::string, CreatorFunction > UiElementFactoryMap
Definition: uiElement.h:199
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:238
const std::vector< DtComponentSystemDefinition * > & systems() const
Definition: uiElement.h:321
const DtComponentSystemDefinition * mySystemDefinition
Definition: uiElement.h:413
DtString myPlatformType
Definition: uiElement.h:409
bool operator!=(const DtUiElementEvent &rhs) const
Definition: uiElement.h:175
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:163
DtUiElementEventTypes type() const
Definition: uiElement.h:166
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
DtUnit myDestination
Definition: uiElement.h:406
std::vector< DtReaderWriter * > myValues
Assumes 1 - 1 order that original and backup are same index in lists.
Definition: uiElement.h:397
static void theNullFunction(DtUiElement *)
bool myEnabled
Definition: uiElement.h:415
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:411
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:76
std::vector< DtReaderWriter * > myBackupValues
Definition: uiElement.h:398
void setType(DtUiElementEventTypes t)
Definition: uiElement.h:167
std::vector< QObject * > myConnectedTo
Definition: uiElement.h:417
static UiElementFactoryMap theFactory
Definition: uiElement.h:391
QToolButton * myRevertToParentButton
Definition: uiElement.h:421
const std::vector< DtReaderWriter * > & values() const
Definition: uiElement.h:268
void setValue(const QVariant &val)
Definition: uiElement.h:168
DtUiElement * owner() const
Definition: uiElement.h:165
DtUiElementEvent(DtUiElement *owner=0, DtUiElementEventTypes type=DtUiElementTypeUnknown)
Definition: uiElement.h:160
#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:193
DtString myDisplayUnits
Definition: uiElement.h:393
makVrv::DtDe & myDe
Definition: uiElement.h:407

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)