VR-Forces 4.0.4 Class Documentation
include/entityEditorImpl/uiElement.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 ** Copyright (c) 2007 MaK Technologies, Inc.
00003 ** All rights reserved.
00004 *********************************************************************/
00005 /*********************************************************************
00006 ** $RCSfile: uiElement.h,v $ $Revision: 1.17 $ $State: Exp $
00007 *********************************************************************/
00008 
00011 
00012 #ifndef DTUIELEMENT_H_
00013 #define DTUIELEMENT_H_
00014 
00015 #include "vrfutil/rdrWritr.h"
00016 #include "vrfutil/readerWriterFactory.h"
00017 #include "vrfutil/rwString.h"
00018 #include "entityEditorImpl/rwEquality.h"
00019 #include "vrfutil/rwBoolean.h"
00020 #include "vrfutil/rwInt.h"
00021 #include "drawerNative/conversions.h"
00022 #include "vrfutil/callbackList.h"
00023 #include "entityEditorImpl/entityEditorImplDefines.h"
00024 
00025 #include <QtCore/QObject>
00026 #include <QtCore/QVariant>
00027 
00028 class QWidget;
00029 class DtUiForParameter;
00030 class DtVrfObjectParameters;
00031 class DtReaderWriterRegistryData;
00032 class DtSystemParameterData;
00033 class DtModelSetEntry;
00034 class DtUiElement;
00035 class QWidget;
00036 
00037 typedef DtCallbackList<DtUiElement*>::DtCallbackFunctionType DtElementChangedCallbackFcn;
00038 
00094 
00096 class DT_DLL_entityeditorimpl DtUiElementEvent
00097 {
00098 public:
00099    enum DtUiElementEventTypes
00100    {
00101       DtUiElementTypeUnknown = 0,
00102       DtUiElementItemExpand   = 1,
00103       DtUiElementItemCollapse = 2,
00104       DtUiElementHierarchySelectionChanged = 3,
00105       DtUiElementSaveStateChanged = 4,
00106       DtUiElementAddedToHierarchy = 5,
00107       DtUiElementRemovedFromHierarchy = 6,
00108       DtUiElementMovedInHierarchy = 7,
00109       DtUiElementReplacedInHierarchy = 8,
00110       DtUiElementForceChanged = 9,
00111       DtUiElementConfigureDiGuyOn = 10,
00112       DtUiElementConfigureDiGuyOff = 11,
00113       DtUiElementPositionModified = 12,
00114       DtUiElementPositionDestroyed = 13,
00115       DtUiBoundingVolumeModified = 14,
00116       DtUiCanvasInitialized = 15,
00117       DtUiDiGuyDataChanged = 16,
00118       DtUiRequestDiGuyData = 17,
00119       DtUiDiGuyDataResponse = 18,
00120       DtUiCreateController = 19,
00121       DtUiCleanup = 20
00122    };
00123 
00124 public:
00125    DtUiElementEvent(DtUiElement* owner= 0, DtUiElementEventTypes type = DtUiElementTypeUnknown) : myOwner(owner), myType(type) {};
00126    DtUiElementEvent(const DtUiElementEvent& orig) : myOwner(orig.myOwner), myType(orig.myType), myValue(orig.myValue) {};
00127 
00128    DtUiElementEvent& operator=(const DtUiElementEvent& rhs) { myOwner = rhs.myOwner; myValue = rhs.myValue; myType = rhs.myType; return *this; };
00129 
00130    DtUiElement* owner() const { return myOwner; };
00131    DtUiElementEventTypes type() const { return myType; };
00132    void setType(DtUiElementEventTypes t) { myType = t; };
00133    void setValue(const QVariant& val) { myValue = val; };
00134    const QVariant& value() const { return myValue; };
00135 
00136 protected:
00137    DtUiElement*            myOwner;
00138    QVariant                myValue;
00139    DtUiElementEventTypes   myType;
00140 };
00141 
00142 class DT_DLL_entityeditorimpl DtUiElementSignalHandler : public QObject
00143 {
00144    Q_OBJECT
00145       
00146 public:
00147    DtUiElementSignalHandler() : myParent(NULL) {};
00148 
00149    void setUiElement(DtUiElement* parent) { myParent = parent; };
00150 
00151 public slots:
00152    virtual void elementChanged();
00153 
00155    virtual void sendEvent(const DtUiElementEvent&);
00156 
00157 signals:
00158    void uiEvent(const DtUiElementEvent&);
00159 
00160 protected:
00161    DtUiElement* myParent;
00162 };
00163 
00164 class DT_DLL_entityeditorimpl DtUiElement : public DtReaderWriter
00165 {
00166 public:
00167 
00169    DtUiElement
00170    (
00171       const DtString& name,
00172       DtReaderWriterRegistry* const parentRegistry = NULL
00173    );
00174 
00176    virtual ~DtUiElement();
00177 
00179    DtUiElement(const DtUiElement& orig);
00180 
00182    DtUiElement& operator=(const DtUiElement& orig);
00183 
00184    virtual const DtString& objectName() const;
00185 
00186    virtual void setTitle(const DtString& s);
00187    virtual void setObjectName(const DtString& s);
00188 
00189    virtual void mergeInto(DtUiForParameter*);
00190    virtual DtUiElement* elementNamed(const DtString&);
00191 
00192    virtual bool mergeInto(const DtString& readerWriterName, bool after, DtUiElement* element);
00193 
00194    virtual void init();
00195 
00196    virtual DtString sourceReaderWriterName() const;
00197    virtual void setSourceReaderWriterName(const DtString& name);
00198 
00199    virtual DtString displayUnits() const;
00200    virtual void setDisplayUnits(const DtString& units);
00201 
00202    virtual DtString sourceUnits() const;
00203    virtual void setSourceUnits(const DtString& units);
00204 
00205    virtual DtString tooltip() const;
00206    virtual void setTooltip(const DtString& text);
00207 
00210    virtual void setFromSystemParameterData(const DtSystemParameterData* data);
00211 
00216    virtual void objectParametersModified() {};
00217 
00219    virtual void processUiEvent(const DtUiElementEvent&) {};
00220 
00221    DtReaderWriterRegistryData* value() const;
00222    DtReaderWriterRegistryData* backupValue() const;
00223 
00225    virtual void initForControls();
00226 
00228    virtual void setModelModified(DtModelSetEntry*);
00229 
00230    DtUiElementSignalHandler* signalHandler() { return &mySignalHandler; };
00231 
00233    virtual void uiState(QMap<QString, QVariant>& state) const;
00234    virtual void setUiState(const QMap<QString, QVariant>&);
00235 
00237    virtual void sendUpdatedUiState();
00238 
00239 public:
00241    static void registerUiTypes();
00242    static DtUiElement* createUiElement(const DtString& type, const DtString& name,
00243       DtReaderWriterRegistry* parentRegistry = NULL);
00244 
00245 public:
00246    virtual DtUiElement* clone() = 0;
00247    virtual bool isModified() const;
00248 
00251    virtual void decorateElement();
00252 
00255    virtual QWidget* createLabelWidget(QWidget* parent);
00257    virtual QWidget* createControls(QWidget* parent);
00258    virtual void setFromParameters(DtReaderWriter* parentRw);
00259    virtual void elementChanged();
00260 
00261    virtual void addElementChangedCallback(DtElementChangedCallbackFcn f, void* usr);
00262    virtual void removeElementChangedCallback(DtElementChangedCallbackFcn f, void* usr);
00263    virtual void removeAllCallbacks();
00264 
00268    virtual DtReaderWriterRegistryData* createBackup(const DtString& backupName);
00272    virtual bool restoreFromBackup(const DtString& backupName, bool deleteBackup = false);
00275    virtual void deleteBackup(const DtString& backupName);
00276 
00277    const DtCallbackList<DtUiElement*>& elementChangedCallbackList() const;
00278    void setElementChangedCallbackList(const DtCallbackList<DtUiElement*>&);
00279 
00282    virtual DtReaderWriterRegistryData* value(DtReaderWriter* parentRw);
00283    virtual DtReaderWriterRegistryData* value(DtReaderWriter* parentRw, const DtString& rw,
00284       DtReaderWriterRegistryData** backupValue);
00285 
00286    static DtReaderWriterFactory* elementFactory();
00287 
00289    virtual bool centerElement() const;
00290 
00292    virtual void finalizeSize(QWidget*);
00293 
00294 protected:
00295    static DtReaderWriterFactory theFactory;
00296    virtual QWidget* createDataEntryElement(QWidget*);
00297 
00298    virtual double sourceToDestination(double) const;
00299    virtual double destinationToSource(double) const;
00300 
00301    virtual QString units() const;
00302 
00303 protected:
00304    DtRwString  myReaderWriterName;
00305    DtRwString  myTitle;
00306    DtRwString  myDisplayUnits;
00307    DtRwString  mySourceUnits;
00308    DtRwString  myObjectName;
00309    DtRwString  myTooltip;
00310    DtRwBoolean myCenterElement;
00311    DtRwInt myMaximumWidth;
00312    DtRwInt myMaximumHeight;
00313    DtRwInt myMinimumWidth;
00314    DtRwInt myMinimumHeight;
00315    DtReaderWriterRegistryData*   myValue;
00316    DtReaderWriterRegistryData*   myBackupValue;
00317    DtUiElementSignalHandler   mySignalHandler;
00318    DtRwBoolean mySetVisible;
00319    bool myIsNew;
00320    QWidget*     myLabel;
00321    //DtElementChangedCallbackFcn myElementChangedCallback;
00322    DtCallbackList<DtUiElement*> myElementChangedCallbackList;
00323    //void* myUserVariable;
00324    DtUnit mySource;
00325    DtUnit myDestination;
00326 
00327    static DtUnitConverterFactory theConversionFactory;
00328 };
00329 
00330 inline const DtCallbackList<DtUiElement*>& DtUiElement::elementChangedCallbackList() const
00331 {
00332    return myElementChangedCallbackList;
00333 }
00334 
00335 inline void DtUiElement::setElementChangedCallbackList(const DtCallbackList<DtUiElement*>& lst)
00336 {
00337    myElementChangedCallbackList = lst;
00338 }
00339 
00340 inline DtReaderWriterRegistryData* DtUiElement::value() const
00341 {
00342    return myValue;
00343 }
00344 
00345 inline DtReaderWriterRegistryData* DtUiElement::backupValue() const
00346 {
00347    return myBackupValue;
00348 }
00349 
00350 #endif

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)