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>
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  DtUiAppearanceModified = 48,
145  DtUiAnimateArtPart = 49,
146  DtUiFireArtPart = 50
147  };
148 
149 public:
150  DtUiElementEvent(DtUiElement* owner= 0, DtUiElementEventTypes type = DtUiElementTypeUnknown) : myOwner(owner), myType(type) {};
151  DtUiElementEvent(const DtUiElementEvent& orig) : myOwner(orig.myOwner), myType(orig.myType), myValue(orig.myValue) {};
152 
153  DtUiElementEvent& operator=(const DtUiElementEvent& rhs) { myOwner = rhs.myOwner; myValue = rhs.myValue; myType = rhs.myType; return *this; };
154 
155  DtUiElement* owner() const { return myOwner; };
156  DtUiElementEventTypes type() const { return myType; };
157  void setType(DtUiElementEventTypes t) { myType = t; };
158  void setValue(const QVariant& val) { myValue = val; };
159  const QVariant& value() const { return myValue; };
160  bool operator==(const DtUiElementEvent& rhs) const
161  {
162  return ((myValue == rhs.myValue) && (myType == rhs.myType));
163  }
164 
165  bool operator!=(const DtUiElementEvent& rhs) const { return !(*this == rhs); };
166 
167 protected:
168  DtUiElement* myOwner;
169  QVariant myValue;
171 };
172 
182 
184 {
185  Q_OBJECT
186 
187 public:
188  typedef boost::function<DtUiElement* (makVrv::DtDe&)> CreatorFunction;
189  typedef std::map<std::string, CreatorFunction> UiElementFactoryMap;
190 
193  (
194  makVrv::DtDe&
195  );
196 
198  virtual ~DtUiElement();
199 
200  virtual bool blockSignals(bool);
201 
202  virtual void init(QWidget* widget, QWidget* label, DtReaderWriter* originalData, DtReaderWriter* backupData,
204 
205  virtual void init(QWidget* widget, QWidget* label, const std::vector<DtReaderWriter*>& originalData,
206  const std::vector<DtReaderWriter*>& backupData,
208 
209  virtual void init(QWidget* widget, QWidget* label, const DtObjectType&, const DtString& platformType,
211 
212  virtual DtString displayUnits() const;
213  virtual void setDisplayUnits(const DtString& units);
214 
215  virtual void setLabelText(const QString&);
216 
217  virtual DtString sourceUnits() const;
218  virtual void setSourceUnits(const DtString& units);
219 
222  virtual void setFromSystemParameterData(const DtSystemParameterData* data, const DtComponentSystemDefinition*);
223 
228  virtual void objectParametersModified() {};
229 
231  virtual void connectedTo(QObject*);
232 
234  virtual void processUiEvent(const DtUiElementEvent&) {};
235 
237  virtual void setModelModified(DtModelSetEntry*);
238 
241  virtual DtString uniqueName() const;
242 
244  virtual bool supportsSystems() const;
245 
247  virtual const DtString& platformType() const;
248 
250  virtual void setPlatformType(const DtString&);
251 
253  virtual void setObjectTypes(const std::vector<DtObjectType>&);
254 
256  virtual void aboutToShow();
257 
258  const std::vector<DtReaderWriter*>& values() const { return myValues; };
259  const std::vector<DtReaderWriter*>& backupValues() const { return myBackupValues; };
260 
261 public:
263  static void registerUiTypes();
264  static DtUiElement* createUiElement(makVrv::DtDe&, const DtString& type);
265  static bool hasCreator(const DtString&);
266 
267  static void theNullFunction(DtUiElement*);
268 
269 public:
270  virtual bool isModified() const;
271 
274  virtual bool isValid() const;
275 
278  virtual void decorateElement();
279 
281  virtual void setFromParameters(DtReaderWriter* parentRw);
282 
285  virtual void setFromParameters(const std::vector<DtComponentSystemDefinition*>&);
286 
287  virtual void setFromParameters(const std::vector<DtReaderWriter*>& parentRw);
288 
292  virtual bool restoreFromBackup();
293 
295  QHBoxLayout* findLayoutThatHas(QWidget* w, QBoxLayout* layout);
296 
299  QBoxLayout* findUsableLayoutFor(QWidget* w);
300 
302  {
303  return theFactory;
304  }
305 
306  const std::vector<DtObjectType>& objectTypes() const
307  {
308  return myObjectTypes;
309  }
310 
311  const std::vector<DtComponentSystemDefinition*>& systems() const
312  {
313  return mySystems;
314  }
315 
316  virtual void sendEvent(const DtUiElementEvent&);
317 
318  virtual bool allValuesTheSame() const;
319 
320  static QString mixedText();
321  static void setMixedText(const QString&);
322 
325  virtual bool isMixedValue() const;
326 
328  virtual void setEnabled(bool);
329  virtual bool enabled() const;
330 
331  virtual void setControllingCheckBox(QCheckBox*);
333  {
334  return myControllingCheckBox;
335  }
336 
338  virtual void populateParentValues(std::string elementName);
339 
340 public slots:
341  virtual void toggleDisplayed(bool display);
342 
343 protected slots:
344  virtual void elementChanged();
345 
349  virtual void enableIfChecked();
350 
354  virtual void disableIfChecked();
355 
356 signals:
357  void uiEvent(const DtUiElementEvent&);
358  void changed();
359 
360 protected:
361 
362  virtual double sourceToDisplayUnits(double) const;
363  virtual double displayToSourceUnits(double) const;
364 
365  virtual QString units() const;
366 
368  virtual void updateLabelTitle();
369 
371  virtual QString labelTitle() const;
372 
374  virtual void createControls(QWidget* parent);
375 
376 public:
377  QWidget* myWidget;
378  QWidget* myLabel;
379 
380 protected:
382 
385 
387  std::vector<DtReaderWriter*> myValues;
388  std::vector<DtReaderWriter*> myBackupValues;
389 
390  //cache the value from the parent file
392 
393  bool myIsNew;
398 
400  std::vector<DtObjectType> myObjectTypes;
401  std::vector<DtComponentSystemDefinition*> mySystems;
402 
404 
405  bool myEnabled;
406 
407  std::vector<QObject*> myConnectedTo;
410 
412 };
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:63
DtReaderWriter * myParentValue
Definition: uiElement.h:391
const std::vector< DtReaderWriter * > & backupValues() const
Definition: uiElement.h:259
QVariant myValue
Definition: uiElement.h:169
QWidget * myLabel
Definition: uiElement.h:378
DtUnit mySource
Definition: uiElement.h:395
const std::vector< DtObjectType > & objectTypes() const
Definition: uiElement.h:306
bool operator==(const DtUiElementEvent &rhs) const
Definition: uiElement.h:160
bool myIsNew
Definition: uiElement.h:393
const QVariant & value() const
Definition: uiElement.h:159
Definition: readerWriterRegistryData.h:25
DtUiElementEventTypes
Definition: uiElement.h:100
DtElementChangedCallbackFcn myElementChangedCallbackFunction
Definition: uiElement.h:394
int myUniqueId
Definition: uiElement.h:408
static UiElementFactoryMap & elementFactory()
Definition: uiElement.h:301
virtual void processUiEvent(const DtUiElementEvent &)
Process ui event. Default does nothing.
Definition: uiElement.h:234
Definition: uiForParameter.h:27
Definition: readerWriter.h:85
DtString mySourceUnits
Definition: uiElement.h:384
QCheckBox * controllingCheckBox()
Definition: uiElement.h:332
boost::function< DtUiElement *(makVrv::DtDe &)> CreatorFunction
Definition: uiElement.h:188
DtUiElementEvent(const DtUiElementEvent &orig)
Definition: uiElement.h:151
Definition: unitConversions.h:314
QCheckBox * myControllingCheckBox
Definition: uiElement.h:409
DtUiElementEventTypes myType
Definition: uiElement.h:170
DtUiElement * myOwner
Definition: uiElement.h:165
DtComponentSystemDefinition.
Definition: componentSystemDefinition.h:25
QWidget * myWidget
Definition: uiElement.h:377
Definition: modelSetEntry.h:34
std::map< std::string, CreatorFunction > UiElementFactoryMap
Definition: uiElement.h:189
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:228
const std::vector< DtComponentSystemDefinition * > & systems() const
Definition: uiElement.h:311
const DtComponentSystemDefinition * mySystemDefinition
Definition: uiElement.h:403
std::vector< DtObjectType > myObjectTypes
Definition: uiElement.h:400
DtString myPlatformType
Definition: uiElement.h:399
bool operator!=(const DtUiElementEvent &rhs) const
Definition: uiElement.h:165
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:153
DtUiElementEventTypes type() const
Definition: uiElement.h:156
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
DtUnit myDestination
Definition: uiElement.h:396
std::vector< DtReaderWriter * > myValues
Assumes 1 - 1 order that original and backup are same index in lists.
Definition: uiElement.h:387
static void theNullFunction(DtUiElement *)
bool myEnabled
Definition: uiElement.h:405
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:401
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:72
std::vector< DtReaderWriter * > myBackupValues
Definition: uiElement.h:388
void setType(DtUiElementEventTypes t)
Definition: uiElement.h:157
std::vector< QObject * > myConnectedTo
Definition: uiElement.h:407
static UiElementFactoryMap theFactory
Definition: uiElement.h:381
QToolButton * myRevertToParentButton
Definition: uiElement.h:411
const std::vector< DtReaderWriter * > & values() const
Definition: uiElement.h:258
void setValue(const QVariant &val)
Definition: uiElement.h:158
DtUiElement * owner() const
Definition: uiElement.h:155
DtUiElementEvent(DtUiElement *owner=0, DtUiElementEventTypes type=DtUiElementTypeUnknown)
Definition: uiElement.h:150
#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:183
DtString myDisplayUnits
Definition: uiElement.h:383
makVrv::DtDe & myDe
Definition: uiElement.h:397

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)