VR-Forces 4.3.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 
13 #include "vrfutil/readerWriter.h"
14 #include "vrfutil/rwString.h"
16 #include "vrfutil/rwBoolean.h"
17 #include "vrfutil/rwInt.h"
19 #include <vrfExtProtocol/objectType.h>
20 
21 #include <QtCore/QObject>
22 #include <QtCore/QVariant>
23 #include <boost/function.hpp>
24 #include <boost/bind.hpp>
25 
26 class QWidget;
27 class DtUiForParameter;
31 class DtModelSetEntry;
32 class DtUiElement;
33 class QWidget;
34 class QLabel;
36 
37 typedef boost::function<void (DtUiElement*)> DtElementChangedCallbackFcn;
38 
87 
90 {
91 public:
93  {
94  DtUiElementTypeUnknown = 0,
95  DtUiElementItemExpand = 1,
96  DtUiElementItemCollapse = 2,
97  DtUiElementHierarchySelectionChanged = 3,
98  DtUiElementAddedToHierarchy = 5,
99  DtUiElementRemovedFromHierarchy = 6,
100  DtUiElementMovedInHierarchy = 7,
101  DtUiElementReplacedInHierarchy = 8,
102  DtUiElementForceChanged = 9,
103  DtUiElementPositionModified = 12,
104  DtUiElementPositionDestroyed = 13,
105  DtUiBoundingVolumeModified = 14,
106  DtUiCanvasInitialized = 15,
107  DtUiCreateController = 19,
108  DtUiCleanup = 20,
109  DtUiElementHierarchyChanged = 21,
110  DtUiEnterEditMode = 22,
111  DtUiLeaveEditMode = 23,
112  DtUiSupportPointsModified = 24,
113  DtUiPreSaveEvent = 25,
114  DtSystemsRemoved = 26
115  };
116 
117 public:
118  DtUiElementEvent(DtUiElement* owner= 0, DtUiElementEventTypes type = DtUiElementTypeUnknown) : myOwner(owner), myType(type) {};
119  DtUiElementEvent(const DtUiElementEvent& orig) : myOwner(orig.myOwner), myType(orig.myType), myValue(orig.myValue) {};
120 
121  DtUiElementEvent& operator=(const DtUiElementEvent& rhs) { myOwner = rhs.myOwner; myValue = rhs.myValue; myType = rhs.myType; return *this; };
122 
123  DtUiElement* owner() const { return myOwner; };
124  DtUiElementEventTypes type() const { return myType; };
125  void setType(DtUiElementEventTypes t) { myType = t; };
126  void setValue(const QVariant& val) { myValue = val; };
127  const QVariant& value() const { return myValue; };
128 
129 protected:
130  DtUiElement* myOwner;
131  QVariant myValue;
133 };
134 
144 
146 {
147  Q_OBJECT
148 
149 public:
150  typedef boost::function<DtUiElement* (makVrv::DtDe&)> CreatorFunction;
151  typedef std::map<std::string, CreatorFunction> UiElementFactoryMap;
152 
155  (
156  makVrv::DtDe&
157  );
158 
160  virtual ~DtUiElement();
161 
162  virtual bool blockSignals(bool);
163 
164  virtual void init(QWidget* widget, QWidget* label, DtReaderWriter* originalData, DtReaderWriter* backupData,
166 
167  virtual void init(QWidget* widget, QWidget* label, const std::vector<DtReaderWriter*>& originalData,
168  const std::vector<DtReaderWriter*>& backupData,
170 
171  virtual void init(QWidget* widget, QWidget* label, const DtObjectType&, const DtString& platformType,
173 
174  virtual DtString displayUnits() const;
175  virtual void setDisplayUnits(const DtString& units);
176 
177  virtual void setLabelText(const QString&);
178 
179  virtual DtString sourceUnits() const;
180  virtual void setSourceUnits(const DtString& units);
181 
184  virtual void setFromSystemParameterData(const DtSystemParameterData* data, const DtComponentSystemDefinition*);
185 
190  virtual void objectParametersModified() {};
191 
193  virtual void connectedTo(QObject*);
194 
196  virtual void processUiEvent(const DtUiElementEvent&) {};
197 
199  virtual void setModelModified(DtModelSetEntry*);
200 
203  virtual DtString uniqueName() const;
204 
206  virtual bool supportsSystems() const;
207 
209  virtual const DtString& platformType() const;
210 
212  virtual void setPlatformType(const DtString&);
213 
215  virtual void setObjectTypes(const std::vector<DtObjectType>&);
216 
218  virtual void aboutToShow();
219 
220 public:
222  static void registerUiTypes();
223  static DtUiElement* createUiElement(makVrv::DtDe&, const DtString& type);
224  static bool hasCreator(const DtString&);
225 
226  static void theNullFunction(DtUiElement*);
227 
228 public:
229  virtual bool isModified() const;
230 
233  virtual void decorateElement();
234 
236  virtual void setFromParameters(DtReaderWriter* parentRw);
237 
238  virtual void setFromParameters(const std::vector<DtReaderWriter*>& parentRw);
239 
243  virtual bool restoreFromBackup();
244 
245  static UiElementFactoryMap& elementFactory()
246  {
247  return theFactory;
248  }
249 
250  const std::vector<DtObjectType>& objectTypes() const
251  {
252  return myObjectTypes;
253  }
254 
255  virtual void sendEvent(const DtUiElementEvent&);
256 
257  virtual bool allValuesTheSame() const;
258 
259  static QString mixedText();
260  static void setMixedText(const QString&);
261 
264  virtual bool isMixedValue() const;
265 
267  virtual void setEnabled(bool);
268  virtual bool enabled() const;
269 
270 public slots:
271  virtual void toggleDisplayed(bool display);
272 
273 protected slots:
274  virtual void elementChanged();
275 
279  virtual void enableIfChecked();
280 
284  virtual void disableIfChecked();
285 
286 signals:
287  void uiEvent(const DtUiElementEvent&);
288 
289 protected:
290 
291  virtual double sourceToDisplayUnits(double) const;
292  virtual double displayToSourceUnits(double) const;
293 
294  virtual QString units() const;
295 
297  virtual void updateLabelTitle();
298 
300  virtual QString labelTitle() const;
301 
303  virtual void createControls(QWidget* parent);
304 
305 public:
308 
309 protected:
311 
314 
316  std::vector<DtReaderWriter*> myValues;
317  std::vector<DtReaderWriter*> myBackupValues;
318  bool myIsNew;
323 
325  std::vector<DtObjectType> myObjectTypes;
326 
328 
329  bool myEnabled;
330 
331  std::vector<QObject*> myConnectedTo;
333 };

Document ID: Generated on Wed Jul 29 00:55:00 EDT 2015 from SVN revision 155257
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)