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  };
150 
151 public:
152  DtUiElementEvent(DtUiElement* owner= 0, DtUiElementEventTypes type = DtUiElementTypeUnknown) : myOwner(owner), myType(type) {};
153  DtUiElementEvent(const DtUiElementEvent& orig) : myOwner(orig.myOwner), myType(orig.myType), myValue(orig.myValue) {};
154 
155  DtUiElementEvent& operator=(const DtUiElementEvent& rhs) { myOwner = rhs.myOwner; myValue = rhs.myValue; myType = rhs.myType; return *this; };
156 
157  DtUiElement* owner() const { return myOwner; };
158  DtUiElementEventTypes type() const { return myType; };
159  void setType(DtUiElementEventTypes t) { myType = t; };
160  void setValue(const QVariant& val) { myValue = val; };
161  const QVariant& value() const { return myValue; };
162  bool operator==(const DtUiElementEvent& rhs) const
163  {
164  return ((myValue == rhs.myValue) && (myType == rhs.myType));
165  }
166 
167  bool operator!=(const DtUiElementEvent& rhs) const { return !(*this == rhs); };
168 
169 protected:
170  DtUiElement* myOwner;
171  QVariant myValue;
173 };
174 
184 
186 {
187  Q_OBJECT
188 
189 public:
190  typedef boost::function<DtUiElement* (makVrv::DtDe&)> CreatorFunction;
191  typedef std::map<std::string, CreatorFunction> UiElementFactoryMap;
192 
195  (
196  makVrv::DtDe&
197  );
198 
200  virtual ~DtUiElement() override;
201 
202  virtual bool blockSignals(bool);
203 
204  virtual void init(QWidget* widget, QWidget* label, DtReaderWriter* originalData, DtReaderWriter* backupData,
205  DtElementChangedCallbackFcn = boost::bind(&DtUiElement::theNullFunction, boost::placeholders::_1));
206 
207  virtual void init(QWidget* widget, QWidget* label, const std::vector<DtReaderWriter*>& originalData,
208  const std::vector<DtReaderWriter*>& backupData,
209  DtElementChangedCallbackFcn = boost::bind(&DtUiElement::theNullFunction, boost::placeholders::_1));
210 
211  virtual void init(QWidget* widget, QWidget* label, const DtEntityType&, const DtString& platformType,
212  DtElementChangedCallbackFcn = boost::bind(&DtUiElement::theNullFunction, boost::placeholders::_1));
213 
214  virtual DtString displayUnits() const;
215  virtual void setDisplayUnits(const DtString& units);
216 
217  virtual void setLabelText(const QString&);
218 
219  virtual DtString sourceUnits() const;
220  virtual void setSourceUnits(const DtString& units);
221 
224  virtual void setFromSystemParameterData(const DtSystemParameterData* data, const DtComponentSystemDefinition*);
225 
230  virtual void objectParametersModified() {};
231 
233  virtual void connectedTo(QObject*);
234 
236  virtual void processUiEvent(const DtUiElementEvent&) {};
237 
239  virtual void setModelModified(DtModelSetEntry*);
240 
243  virtual DtString uniqueName() const;
244 
246  virtual bool supportsSystems() const;
247 
249  virtual const DtString& platformType() const;
250 
252  virtual void setPlatformType(const DtString&);
253 
255  virtual void setObjectTypes(const std::vector<DtEntityType>&);
256 
258  virtual void aboutToShow();
259 
260  const std::vector<DtReaderWriter*>& values() const { return myValues; };
261  const std::vector<DtReaderWriter*>& backupValues() const { return myBackupValues; };
262 
263 public:
265  static void registerUiTypes();
266  static DtUiElement* createUiElement(makVrv::DtDe&, const DtString& type);
267  static bool hasCreator(const DtString&);
268 
269  static void theNullFunction(DtUiElement*);
270 
271 public:
272  virtual bool isModified() const;
273 
276  virtual bool isValid() const;
277 
280  virtual void decorateElement();
281 
283  virtual void setFromParameters(DtReaderWriter* parentRw);
284 
287  virtual void setFromParameters(const std::vector<DtComponentSystemDefinition*>&);
288 
289  virtual void setFromParameters(const std::vector<DtReaderWriter*>& parentRw);
290 
294  virtual bool restoreFromBackup();
295 
297  QHBoxLayout* findLayoutThatHas(QWidget* w, QBoxLayout* layout);
298 
301  QBoxLayout* findUsableLayoutFor(QWidget* w);
302 
304  {
305  return theFactory;
306  }
307 
308  const std::vector<DtEntityType>& objectTypes() const
309  {
310  return myObjectTypes;
311  }
312 
313  const std::vector<DtComponentSystemDefinition*>& systems() const
314  {
315  return mySystems;
316  }
317 
318  virtual void sendEvent(const DtUiElementEvent&);
319 
320  virtual bool allValuesTheSame() const;
321 
322  static QString mixedText();
323  static void setMixedText(const QString&);
324 
327  virtual bool isMixedValue() const;
328 
330  virtual void setEnabled(bool);
331  virtual bool enabled() const;
332 
333  virtual void setControllingCheckBox(QCheckBox*);
335  {
336  return myControllingCheckBox;
337  }
338 
340  virtual void populateParentValues(std::string elementName);
341 
342 public slots:
343  virtual void toggleDisplayed(bool display);
344 
345 protected slots:
346  virtual void elementChanged();
347 
351  virtual void enableIfChecked();
352 
356  virtual void disableIfChecked();
357 
358 signals:
359  void uiEvent(const DtUiElementEvent&);
360  void changed();
361 
362 protected:
363 
364  virtual double sourceToDisplayUnits(double) const;
365  virtual double displayToSourceUnits(double) const;
366 
367  virtual QString units() const;
368 
370  virtual void updateLabelTitle();
371 
373  virtual QString labelTitle() const;
374 
376  virtual void createControls(QWidget* parent);
377 
378 public:
379  QWidget* myWidget;
380  QWidget* myLabel;
381 
382 protected:
384 
387 
389  std::vector<DtReaderWriter*> myValues;
390  std::vector<DtReaderWriter*> myBackupValues;
391 
392  //cache the value from the parent file
394 
395  bool myIsNew;
400 
402  std::vector<DtEntityType> myObjectTypes;
403  std::vector<DtComponentSystemDefinition*> mySystems;
404 
406 
407  bool myEnabled;
408 
409  std::vector<QObject*> myConnectedTo;
412 
414 };
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:64
DtReaderWriter * myParentValue
Definition: uiElement.h:393
const std::vector< DtReaderWriter * > & backupValues() const
Definition: uiElement.h:261
QVariant myValue
Definition: uiElement.h:171
QWidget * myLabel
Definition: uiElement.h:380
DtUnit mySource
Definition: uiElement.h:397
bool operator==(const DtUiElementEvent &rhs) const
Definition: uiElement.h:162
bool myIsNew
Definition: uiElement.h:395
const QVariant & value() const
Definition: uiElement.h:161
const std::vector< DtEntityType > & objectTypes() const
Definition: uiElement.h:308
Definition: readerWriterRegistryData.h:25
DtUiElementEventTypes
Definition: uiElement.h:100
DtElementChangedCallbackFcn myElementChangedCallbackFunction
Definition: uiElement.h:396
int myUniqueId
Definition: uiElement.h:410
static UiElementFactoryMap & elementFactory()
Definition: uiElement.h:303
virtual void processUiEvent(const DtUiElementEvent &)
Process ui event. Default does nothing.
Definition: uiElement.h:236
Definition: uiForParameter.h:27
Definition: readerWriter.h:85
DtString mySourceUnits
Definition: uiElement.h:386
QCheckBox * controllingCheckBox()
Definition: uiElement.h:334
boost::function< DtUiElement *(makVrv::DtDe &)> CreatorFunction
Definition: uiElement.h:190
DtUiElementEvent(const DtUiElementEvent &orig)
Definition: uiElement.h:153
Definition: unitConversions.h:309
QCheckBox * myControllingCheckBox
Definition: uiElement.h:411
DtUiElementEventTypes myType
Definition: uiElement.h:172
DtUiElement * myOwner
Definition: uiElement.h:167
std::vector< DtEntityType > myObjectTypes
Definition: uiElement.h:402
DtComponentSystemDefinition.
Definition: componentSystemDefinition.h:27
QWidget * myWidget
Definition: uiElement.h:379
Definition: modelSetEntry.h:34
std::map< std::string, CreatorFunction > UiElementFactoryMap
Definition: uiElement.h:191
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:230
const std::vector< DtComponentSystemDefinition * > & systems() const
Definition: uiElement.h:313
const DtComponentSystemDefinition * mySystemDefinition
Definition: uiElement.h:405
DtString myPlatformType
Definition: uiElement.h:401
bool operator!=(const DtUiElementEvent &rhs) const
Definition: uiElement.h:167
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:155
DtUiElementEventTypes type() const
Definition: uiElement.h:158
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
DtUnit myDestination
Definition: uiElement.h:398
std::vector< DtReaderWriter * > myValues
Assumes 1 - 1 order that original and backup are same index in lists.
Definition: uiElement.h:389
static void theNullFunction(DtUiElement *)
bool myEnabled
Definition: uiElement.h:407
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:403
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:390
void setType(DtUiElementEventTypes t)
Definition: uiElement.h:159
std::vector< QObject * > myConnectedTo
Definition: uiElement.h:409
static UiElementFactoryMap theFactory
Definition: uiElement.h:383
QToolButton * myRevertToParentButton
Definition: uiElement.h:413
const std::vector< DtReaderWriter * > & values() const
Definition: uiElement.h:260
void setValue(const QVariant &val)
Definition: uiElement.h:160
DtUiElement * owner() const
Definition: uiElement.h:157
DtUiElementEvent(DtUiElement *owner=0, DtUiElementEventTypes type=DtUiElementTypeUnknown)
Definition: uiElement.h:152
#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:185
DtString myDisplayUnits
Definition: uiElement.h:385
makVrv::DtDe & myDe
Definition: uiElement.h:399

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)