VR-Forces 4.10 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 
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 <QtWidgets/QPushButton>
26 #include <QtWidgets/QBoxLayout>
27 #include <boost/function.hpp>
28 #include <boost/bind.hpp>
29 
30 class QWidget;
31 class DtUiForParameter;
35 class DtModelSetEntry;
36 class DtUiElement;
37 class QWidget;
38 class QCheckBox;
39 class QDoubleSpinBox;
40 class QLabel;
42 
43 typedef boost::function<void (DtUiElement*)> DtElementChangedCallbackFcn;
44 
93 
96 {
97 public:
99  {
100  DtUiElementTypeUnknown = 0,
101  DtUiElementItemExpand = 1,
102  DtUiElementItemCollapse = 2,
103  DtUiElementHierarchySelectionChanged = 3,
104  DtUiElementAddedToHierarchy = 5,
105  DtUiElementRemovedFromHierarchy = 6,
106  DtUiElementMovedInHierarchy = 7,
107  DtUiElementReplacedInHierarchy = 8,
108  DtUiElementForceChanged = 9,
109  DtUiElementPositionModified = 12,
110  DtUiElementPositionDestroyed = 13,
111  DtUiBoundingVolumeModified = 14,
112  DtUiCanvasInitialized = 15,
113  DtUiCreateController = 19,
114  DtUiCleanup = 20,
115  DtUiElementHierarchyChanged = 21,
116  DtUiEnterEditMode = 22,
117  DtUiLeaveEditMode = 23,
118  DtUiSupportPointsModified = 24,
119  DtUiPreSaveEvent = 25,
120  DtSystemsRemoved = 26,
121  DtUiSuportPointsCalculated = 27,
122  DtUiBoundingVolumeCalculated = 28,
123  DtUiCalculateBoundingVolume = 29,
124  DtUiCalculateSupportPoints = 30,
125  DtUiMarkingChanged = 31,
126  DtUiChangeTrailEffect = 32,
127  DtUiStartSimulation = 33,
128  DtUiSetSpeedPercentage = 34,
129  DtUiSystemParameterDataChanged = 35,
130  DtUiAffectGui = 36,
131  DtUiDetonationPowerChanged = 37,
132  DtUiDamageTableChanged = 38,
133  DtUiHitTableChanged = 39,
134  DtUiElementDataChanged = 40,
135  DtUiAmmunitionChanged = 41,
136  DtUiHealthFix = 42,
137  DtUiIconListsChanged = 43,
138  DtUiSystemEvent = 44,
139  DtArtPartUpdated = 45,
140  DtArtPartAssociated = 46,
141  DtUiAccept = 47
142  };
143 
144 public:
145  DtUiElementEvent(DtUiElement* owner= 0, DtUiElementEventTypes type = DtUiElementTypeUnknown) : myOwner(owner), myType(type) {};
146  DtUiElementEvent(const DtUiElementEvent& orig) : myOwner(orig.myOwner), myType(orig.myType), myValue(orig.myValue) {};
147 
148  DtUiElementEvent& operator=(const DtUiElementEvent& rhs) { myOwner = rhs.myOwner; myValue = rhs.myValue; myType = rhs.myType; return *this; };
149 
150  DtUiElement* owner() const { return myOwner; };
151  DtUiElementEventTypes type() const { return myType; };
152  void setType(DtUiElementEventTypes t) { myType = t; };
153  void setValue(const QVariant& val) { myValue = val; };
154  const QVariant& value() const { return myValue; };
155 
156 protected:
157  DtUiElement* myOwner;
158  QVariant myValue;
160 };
161 
171 
173 {
174  Q_OBJECT
175 
176 public:
177  typedef boost::function<DtUiElement* (makVrv::DtDe&)> CreatorFunction;
178  typedef std::map<std::string, CreatorFunction> UiElementFactoryMap;
179 
182  (
183  makVrv::DtDe&
184  );
185 
187  virtual ~DtUiElement();
188 
189  virtual bool blockSignals(bool);
190 
191  virtual void init(QWidget* widget, QWidget* label, DtReaderWriter* originalData, DtReaderWriter* backupData,
193 
194  virtual void init(QWidget* widget, QWidget* label, const std::vector<DtReaderWriter*>& originalData,
195  const std::vector<DtReaderWriter*>& backupData,
197 
198  virtual void init(QWidget* widget, QWidget* label, const DtObjectType&, const DtString& platformType,
200 
201  virtual DtString displayUnits() const;
202  virtual void setDisplayUnits(const DtString& units);
203 
204  virtual void setLabelText(const QString&);
205 
206  virtual DtString sourceUnits() const;
207  virtual void setSourceUnits(const DtString& units);
208 
211  virtual void setFromSystemParameterData(const DtSystemParameterData* data, const DtComponentSystemDefinition*);
212 
217  virtual void objectParametersModified() {};
218 
220  virtual void connectedTo(QObject*);
221 
223  virtual void processUiEvent(const DtUiElementEvent&) {};
224 
226  virtual void setModelModified(DtModelSetEntry*);
227 
230  virtual DtString uniqueName() const;
231 
233  virtual bool supportsSystems() const;
234 
236  virtual const DtString& platformType() const;
237 
239  virtual void setPlatformType(const DtString&);
240 
242  virtual void setObjectTypes(const std::vector<DtObjectType>&);
243 
245  virtual void aboutToShow();
246 
247  const std::vector<DtReaderWriter*>& values() const { return myValues; };
248  const std::vector<DtReaderWriter*>& backupValues() const { return myBackupValues; };
249 
250 public:
252  static void registerUiTypes();
253  static DtUiElement* createUiElement(makVrv::DtDe&, const DtString& type);
254  static bool hasCreator(const DtString&);
255 
256  static void theNullFunction(DtUiElement*);
257 
258 public:
259  virtual bool isModified() const;
260 
263  virtual bool isValid() const;
264 
267  virtual void decorateElement();
268 
270  virtual void setFromParameters(DtReaderWriter* parentRw);
271 
274  virtual void setFromParameters(const std::vector<DtComponentSystemDefinition*>&);
275 
276  virtual void setFromParameters(const std::vector<DtReaderWriter*>& parentRw);
277 
281  virtual bool restoreFromBackup();
282 
284  QHBoxLayout* findLayoutThatHas(QWidget* w, QBoxLayout* layout);
285 
288  QBoxLayout* findUsableLayoutFor(QWidget* w);
289 
291  {
292  return theFactory;
293  }
294 
295  const std::vector<DtObjectType>& objectTypes() const
296  {
297  return myObjectTypes;
298  }
299 
300  const std::vector<DtComponentSystemDefinition*>& systems() const
301  {
302  return mySystems;
303  }
304 
305  virtual void sendEvent(const DtUiElementEvent&);
306 
307  virtual bool allValuesTheSame() const;
308 
309  static QString mixedText();
310  static void setMixedText(const QString&);
311 
314  virtual bool isMixedValue() const;
315 
317  virtual void setEnabled(bool);
318  virtual bool enabled() const;
319 
320  virtual void setControllingCheckBox(QCheckBox*);
322  {
323  return myControllingCheckBox;
324  }
325 
327  virtual void populateParentValues(std::string elementName);
328 
329 public slots:
330  virtual void toggleDisplayed(bool display);
331 
332 protected slots:
333  virtual void elementChanged();
334 
338  virtual void enableIfChecked();
339 
343  virtual void disableIfChecked();
344 
345 signals:
346  void uiEvent(const DtUiElementEvent&);
347  void changed();
348 
349 protected:
350 
351  virtual double sourceToDisplayUnits(double) const;
352  virtual double displayToSourceUnits(double) const;
353 
354  virtual QString units() const;
355 
357  virtual void updateLabelTitle();
358 
360  virtual QString labelTitle() const;
361 
363  virtual void createControls(QWidget* parent);
364 
365 public:
366  QWidget* myWidget;
367  QWidget* myLabel;
368 
369 protected:
371 
374 
376  std::vector<DtReaderWriter*> myValues;
377  std::vector<DtReaderWriter*> myBackupValues;
378 
379  //cache the value from the parent file
381 
382  bool myIsNew;
387 
389  std::vector<DtObjectType> myObjectTypes;
390  std::vector<DtComponentSystemDefinition*> mySystems;
391 
393 
394  bool myEnabled;
395 
396  std::vector<QObject*> myConnectedTo;
399 
401 
402 };
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:59
DtReaderWriter * myParentValue
Definition: uiElement.h:380
const std::vector< DtReaderWriter * > & backupValues() const
Definition: uiElement.h:248
QVariant myValue
Definition: uiElement.h:158
QWidget * myLabel
Definition: uiElement.h:367
DtUnit mySource
Definition: uiElement.h:384
const std::vector< DtObjectType > & objectTypes() const
Definition: uiElement.h:295
bool myIsNew
Definition: uiElement.h:382
const QVariant & value() const
Definition: uiElement.h:154
Definition: readerWriterRegistryData.h:25
DtUiElementEventTypes
Definition: uiElement.h:98
DtElementChangedCallbackFcn myElementChangedCallbackFunction
Definition: uiElement.h:383
int myUniqueId
Definition: uiElement.h:397
static UiElementFactoryMap & elementFactory()
Definition: uiElement.h:290
virtual void processUiEvent(const DtUiElementEvent &)
Process ui event. Default does nothing.
Definition: uiElement.h:223
Definition: uiForParameter.h:27
Definition: readerWriter.h:85
DtString mySourceUnits
Definition: uiElement.h:373
QCheckBox * controllingCheckBox()
Definition: uiElement.h:321
boost::function< DtUiElement *(makVrv::DtDe &)> CreatorFunction
Definition: uiElement.h:177
DtUiElementEvent(const DtUiElementEvent &orig)
Definition: uiElement.h:146
Definition: unitConversions.h:314
QCheckBox * myControllingCheckBox
Definition: uiElement.h:398
DtUiElementEventTypes myType
Definition: uiElement.h:159
DtUiElement * myOwner
Definition: uiElement.h:154
Definition: objectType.h:27
DtComponentSystemDefinition.
Definition: componentSystemDefinition.h:25
QWidget * myWidget
Definition: uiElement.h:366
Description: A model is a set of items that defines a model to create in the back-end from the front-...
Definition: modelSetEntry.h:24
std::map< std::string, CreatorFunction > UiElementFactoryMap
Definition: uiElement.h:178
binderNoArgs< _Fn > bind(const _Fn &_Func, const _Ty &_Left)
Definition: DtSTLUtilities.h:76
boost::function< void(DtUiElement *)> DtElementChangedCallbackFcn
Definition: uiElement.h:41
virtual void objectParametersModified()
This method is called any time that any of the parameters for the object are modified.
Definition: uiElement.h:217
const std::vector< DtComponentSystemDefinition * > & systems() const
Definition: uiElement.h:300
const DtComponentSystemDefinition * mySystemDefinition
Definition: uiElement.h:392
std::vector< DtObjectType > myObjectTypes
Definition: uiElement.h:389
DtString myPlatformType
Definition: uiElement.h:388
Base class for RW objects that describe a system parameter.
Definition: systemParameterData.h:30
DtUiElementEvent & operator=(const DtUiElementEvent &rhs)
Definition: uiElement.h:148
DtUiElementEventTypes type() const
Definition: uiElement.h:151
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
DtUnit myDestination
Definition: uiElement.h:385
std::vector< DtReaderWriter * > myValues
Assumes 1 - 1 order that original and backup are same index in lists.
Definition: uiElement.h:376
static void theNullFunction(DtUiElement *)
bool myEnabled
Definition: uiElement.h:394
The DtUiElement class is the base for which all UI elements are defined.
Definition: uiElement.h:95
QPushButton * myRevertToParentButton
Definition: uiElement.h:400
std::vector< DtComponentSystemDefinition * > mySystems
Definition: uiElement.h:390
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
std::vector< DtReaderWriter * > myBackupValues
Definition: uiElement.h:377
void setType(DtUiElementEventTypes t)
Definition: uiElement.h:152
std::vector< QObject * > myConnectedTo
Definition: uiElement.h:396
static UiElementFactoryMap theFactory
Definition: uiElement.h:370
const std::vector< DtReaderWriter * > & values() const
Definition: uiElement.h:247
void setValue(const QVariant &val)
Definition: uiElement.h:153
DtUiElement * owner() const
Definition: uiElement.h:150
DtUiElementEvent(DtUiElement *owner=0, DtUiElementEventTypes type=DtUiElementTypeUnknown)
Definition: uiElement.h:145
#define DT_DLL_simulationObjectEditorimpl
This file is used to determine how to build.
Definition: simulationObjectEditorImplDefines.h:32
Base class of the ui element class chain.
Definition: uiElement.h:172
DtString myDisplayUnits
Definition: uiElement.h:372
makVrv::DtDe & myDe
Definition: uiElement.h:386

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)