// 1. Attributes (id,label,units?,format?,required?)
TCollection_AsciiString anID = aQuantity.getAttribute( DDS_Dictionary::KeyWord( "DATUM_ID" ) );
- Handle(DDS_DicItem) aDicItem = new DDS_DicItem();
+ Handle(DDS_DicItem) aDicItem = CreateItem();
aDicItem->myComponent = this;
aDicItem->FillDataMap( anID, aQuantity, theComponentData, theDocElement, unitSystems );
myDataMap.Add( anID, aDicItem );
-
+
bool exist = false;
for( int i=1, n=myKeys.Length(); i<=n && !exist; i++ )
if( myKeys.Value( i )==anID )
{
seq = myKeys;
}
+
+/*!
+ \brief Instantiate new dictionary item, used for customization of
+ data dictionary items.
+ \return New dictionary item instance.
+*/
+Handle(DDS_DicItem) DDS_DicGroup::CreateItem() const
+{
+ return new DDS_DicItem();
+}
+
+/*!
+ \brief Bind dictionary item to ID
+ \return Standard_True if the item has been succesfully bound.
+ Standard_False if there is an item with same id.
+*/
+Standard_Boolean DDS_DicGroup::AddDicItem( const TCollection_AsciiString& theID,
+ const Handle(DDS_DicItem)& theDicItem )
+{
+ if ( myDataMap.Contains( theID ) )
+ return Standard_False;
+
+ myDataMap.Add( theID, theDicItem );
+ myKeys.Append( theID );
+
+ return Standard_True;
+}
+
+/*!
+ \brief Check if there is item bounded by id.
+ \return Standard_True if there is an item bound in map with given id.
+*/
+Standard_Boolean DDS_DicGroup::HasDicItem( const TCollection_AsciiString& theID ) const
+{
+ return myDataMap.Contains( theID );
+}
+
+/*!
+ \brief Clear dictionary items map
+*/
+void DDS_DicGroup::RemoveAllDicItems()
+{
+ myDataMap.Clear();
+ myKeys.Clear();
+}
+
+/*!
+ \brief Returns a reference to a map. Can be used to iterate through
+ dictionary items.
+*/
+const DDS_IndexedDataMapOfDicItems& DDS_DicGroup::GetItemMap() const
+{
+ return myDataMap;
+}
+
+/*!
+ \brief Add new unit system and bind its label name.
+ \return Standard_False if there is other system bound by this key.
+*/
+Standard_Boolean DDS_DicGroup::AddUnitSystem( const TCollection_AsciiString& theSystemKey,
+ const TCollection_ExtendedString& theSystemLabel )
+{
+ return myUnitSystem.Bind( theSystemKey, theSystemLabel );
+}
class DDS_DicGroup : public MMgt_TShared
{
public:
- DDS_DicGroup( const TCollection_AsciiString& );
+ Standard_EXPORT DDS_DicGroup( const TCollection_AsciiString& );
- TCollection_AsciiString GetName() const;
- Standard_EXPORT void GetKeys( TColStd_SequenceOfAsciiString& ) const;
+ Standard_EXPORT TCollection_AsciiString GetName() const;
+ Standard_EXPORT void GetKeys( TColStd_SequenceOfAsciiString& ) const;
- Standard_EXPORT Handle(DDS_DicItem) GetDicItem( const TCollection_AsciiString& ) const;
+ Standard_EXPORT Handle(DDS_DicItem) GetDicItem( const TCollection_AsciiString& ) const;
- Standard_EXPORT void GetUnitSystems( TColStd_SequenceOfAsciiString& ) const;
- Standard_EXPORT TCollection_ExtendedString GetUnitSystemLabel( const TCollection_AsciiString& ) const;
+ Standard_EXPORT void GetUnitSystems( TColStd_SequenceOfAsciiString& ) const;
+ Standard_EXPORT TCollection_ExtendedString GetUnitSystemLabel( const TCollection_AsciiString& ) const;
- Standard_EXPORT TCollection_AsciiString GetActiveUnitSystem() const;
- Standard_EXPORT void SetActiveUnitSystem( const TCollection_AsciiString& );
+ Standard_EXPORT TCollection_AsciiString GetActiveUnitSystem() const;
+ Standard_EXPORT void SetActiveUnitSystem( const TCollection_AsciiString& );
-private:
- DDS_DicGroup( const DDS_DicGroup& );
+ virtual Standard_EXPORT Handle(DDS_DicItem) CreateItem() const;
+
+protected:
- void operator=( const DDS_DicGroup& );
+ Standard_EXPORT DDS_DicGroup( const DDS_DicGroup& );
- void FillDataMap( const LDOM_Element&, const LDOM_Element& );
+ Standard_EXPORT void operator=( const DDS_DicGroup& );
+
+ Standard_EXPORT virtual void FillDataMap( const LDOM_Element&, const LDOM_Element& );
+
+ Standard_EXPORT Standard_Boolean AddDicItem( const TCollection_AsciiString&,
+ const Handle(DDS_DicItem)& );
+
+ Standard_EXPORT Standard_Boolean HasDicItem( const TCollection_AsciiString& ) const;
+
+ Standard_EXPORT void RemoveAllDicItems();
+
+ Standard_EXPORT const
+ DDS_IndexedDataMapOfDicItems& GetItemMap() const;
+
+ Standard_EXPORT Standard_Boolean AddUnitSystem( const TCollection_AsciiString&,
+ const TCollection_ExtendedString& );
+
+protected:
-private:
typedef NCollection_DataMap<TCollection_AsciiString,
TCollection_ExtendedString> UnitSystemMap;
aSystem = aComponent->GetActiveUnitSystem();
return aSystem;
}
+
+/*!
+ \brief Set item's identify string.
+ \param theId identify string.
+*/
+void DDS_DicItem::SetId( const TCollection_AsciiString& theId )
+{
+ myId = theId;
+}
+
+/*!
+ \brief Set item's component pointer.
+ \param theComponent component pointer.
+*/
+void DDS_DicItem::SetComponent( const Handle(Standard_Transient)& theComponent )
+{
+ myComponent = theComponent;
+}
+
+/*!
+ \brief Set item's label string.
+ \param theLabel label string.
+*/
+void DDS_DicItem::SetLabel( const TCollection_AsciiString& theLabel )
+{
+ myLabel = theLabel;
+}
+
+/*!
+ \brief Set item's filter string.
+ \param theFilter filter string.
+*/
+void DDS_DicItem::SetFilter( const TCollection_AsciiString& theFilter )
+{
+ myFilter = theFilter;
+}
+
+/*!
+ \brief Set item's required value.
+ \param theRequired required value string.
+*/
+void DDS_DicItem::SetRequired( const TCollection_AsciiString& theRequired )
+{
+ myRequired = theRequired;
+}
+
+/*!
+ \brief Set item's warning level value.
+ \param theWarningLevel warning level value.
+*/
+void DDS_DicItem::SetWarningLevel( const Standard_Integer& theWarningLevel )
+{
+ myWarnLevel = theWarningLevel;
+}
+
+/*!
+ \brief Set item's minimum zoom value.
+ \param theMinZoom minimum zoom value.
+*/
+void DDS_DicItem::SetMinZoom( const Standard_Real& theMinZoom )
+{
+ myMinZoom = theMinZoom;
+}
+
+/*!
+ \brief Set item's maximum zoom value.
+ \param theMaxZoom maximum zoom value.
+*/
+void DDS_DicItem::SetMaxZoom( const Standard_Real& theMaxZoom )
+{
+ myMaxZoom = theMaxZoom;
+}
+
+/*!
+ \brief Set item's zoom order value.
+ \param theZoomOrder zoom order value.
+*/
+void DDS_DicItem::SetZoomOrder( const Standard_Real& theZoomOrder )
+{
+ myZoomOrder = theZoomOrder;
+}
+
+/*!
+ \brief Set item's short description.
+ \param theShortDescr short description string.
+*/
+void DDS_DicItem::SetShortDescription( const TCollection_ExtendedString& theShortDescr )
+{
+ myShortDescr = theShortDescr;
+}
+
+/*!
+ \brief Set item's long description.
+ \param theLongDescr long description string.
+*/
+void DDS_DicItem::SetLongDescription( const TCollection_ExtendedString& theLongDescr )
+{
+ myLongDescr = theLongDescr;
+}
+
+/*!
+ \brief Add item's option.
+ \param theOptionName option name string.
+ \param theOptionValue option value string.
+*/
+bool DDS_DicItem::SetOption( const TCollection_AsciiString& theOptionName,
+ const TCollection_AsciiString& theOptionValue )
+{
+ return myOptions.Bind( theOptionName, theOptionValue );
+}
+
+/*!
+ \brief Set item's type value.
+ \param theType item value type.
+*/
+void DDS_DicItem::SetType( const DDS_DicItem::Type& theType )
+{
+ myType = theType;
+}
+
+/*!
+ \brief Set item's minimum value.
+ \param theMinVal minimum possible value.
+*/
+void DDS_DicItem::SetMin( const Standard_Real& theMinVal )
+{
+ myData |= MinValue;
+ myMin = theMinVal;
+}
+
+/*!
+ \brief Set item's maximum value.
+ \param theMaxVal maximum possible value.
+*/
+void DDS_DicItem::SetMax( const Standard_Real& theMaxVal )
+{
+ myData |= MaxValue;
+ myMax = theMaxVal;
+}
+
+/*!
+ \brief Set item's default value as a real number.
+ \param theDefVal default value.
+*/
+void DDS_DicItem::SetDefaultValue( const Standard_Real& theDefVal )
+{
+ myData |= DefaultValue;
+ myDefValue = theDefVal;
+}
+
+/*!
+ \brief Set item's default value as a string.
+ \param theDefStr default value.
+*/
+void DDS_DicItem::SetDefaultValue( const TCollection_AsciiString& theDefStr )
+{
+ myDefString = theDefStr;
+}
+
+/*!
+ \brief Set item's value list.
+ \param theStrings list of value strings.
+ \param theIntegers list of integer values associated with string item.
+*/
+void DDS_DicItem::SetListOfValues( const Handle(TColStd_HArray1OfExtendedString)& theStrings,
+ const Handle(TColStd_HArray1OfInteger)& theIntegers )
+{
+ myListRef = theStrings;
+ myListRefID = theIntegers;
+}
+
+/*!
+ \brief Set item's value list and icons.
+ \param theStrings list of value strings.
+ \param theIntegers list of integer values associated with string item.
+ \param theIcons list of icons associated with string item.
+*/
+void DDS_DicItem::SetListOfValues( const Handle(TColStd_HArray1OfExtendedString)& theStrings,
+ const Handle(TColStd_HArray1OfInteger)& theIntegers,
+ const Handle(TColStd_HArray1OfExtendedString)& theIcons )
+{
+ myListRef = theStrings;
+ myListRefID = theIntegers;
+ myListRefIcons = theIcons;
+}
typedef TCollection_AsciiString UnitSystem;
public:
- DDS_DicItem();
+ Standard_EXPORT DDS_DicItem();
- Standard_EXPORT TCollection_AsciiString GetId() const;
- Standard_EXPORT DDS_DicItem::Type GetType() const;
- Standard_EXPORT TCollection_ExtendedString GetLabel() const;
- Standard_EXPORT TCollection_ExtendedString GetFilter() const;
- Standard_EXPORT TCollection_ExtendedString GetRequired() const;
- Standard_EXPORT DDS_MsgType GetWarningLevel() const;
- Standard_EXPORT TCollection_ExtendedString GetLongDescription() const;
- Standard_EXPORT TCollection_ExtendedString GetShortDescription() const;
- Standard_EXPORT TCollection_AsciiString GetComponent() const;
+ Standard_EXPORT TCollection_AsciiString GetId() const;
+ Standard_EXPORT DDS_DicItem::Type GetType() const;
+ Standard_EXPORT TCollection_ExtendedString GetLabel() const;
+ Standard_EXPORT TCollection_ExtendedString GetFilter() const;
+ Standard_EXPORT TCollection_ExtendedString GetRequired() const;
+ Standard_EXPORT DDS_MsgType GetWarningLevel() const;
+ Standard_EXPORT TCollection_ExtendedString GetLongDescription() const;
+ Standard_EXPORT TCollection_ExtendedString GetShortDescription() const;
+ Standard_EXPORT TCollection_AsciiString GetComponent() const;
- Standard_EXPORT TCollection_AsciiString GetUnits() const;
- Standard_EXPORT TCollection_AsciiString GetUnits( const UnitSystem& ) const;
+ Standard_EXPORT virtual TCollection_AsciiString GetUnits() const;
+ Standard_EXPORT virtual TCollection_AsciiString GetUnits( const UnitSystem& ) const;
- Standard_EXPORT TCollection_ExtendedString GetDefaultValue() const;
- Standard_EXPORT TCollection_ExtendedString GetDefaultValue( const UnitSystem& ) const;
+ Standard_EXPORT TCollection_ExtendedString GetDefaultValue() const;
+ Standard_EXPORT TCollection_ExtendedString GetDefaultValue( const UnitSystem& ) const;
- Standard_EXPORT Standard_Real GetMinValue() const;
- Standard_EXPORT Standard_Real GetMinValue( const UnitSystem& ) const;
+ Standard_EXPORT Standard_Real GetMinValue() const;
+ Standard_EXPORT Standard_Real GetMinValue( const UnitSystem& ) const;
- Standard_EXPORT Standard_Real GetMaxValue() const;
- Standard_EXPORT Standard_Real GetMaxValue( const UnitSystem& ) const;
+ Standard_EXPORT Standard_Real GetMaxValue() const;
+ Standard_EXPORT Standard_Real GetMaxValue( const UnitSystem& ) const;
- Standard_EXPORT Standard_Integer GetPrecision() const;
- Standard_EXPORT Standard_Integer GetPrecision( const UnitSystem& ) const;
+ Standard_EXPORT virtual Standard_Integer GetPrecision() const;
+ Standard_EXPORT virtual Standard_Integer GetPrecision( const UnitSystem& ) const;
- Standard_EXPORT TCollection_AsciiString GetFormat( const Standard_Boolean = Standard_True ) const;
- Standard_EXPORT TCollection_AsciiString GetFormat( const UnitSystem&,
- const Standard_Boolean = Standard_True ) const;
- Standard_EXPORT TCollection_ExtendedString GetNameOfValues() const;
- Standard_EXPORT Standard_Boolean GetListOfValues( Handle(TColStd_HArray1OfExtendedString)&,
- Handle(TColStd_HArray1OfInteger)& ) const;
- Standard_EXPORT Standard_Boolean GetListOfValues( Handle(TColStd_HArray1OfExtendedString)&,
- Handle(TColStd_HArray1OfInteger)&,
- Handle(TColStd_HArray1OfExtendedString)& ) const;
- Standard_EXPORT Standard_Boolean GetSpecialValues( TColStd_MapOfReal& ) const;
+ Standard_EXPORT virtual TCollection_AsciiString GetFormat( const Standard_Boolean = Standard_True ) const;
+ Standard_EXPORT virtual TCollection_AsciiString GetFormat( const UnitSystem&,
+ const Standard_Boolean = Standard_True ) const;
+ Standard_EXPORT TCollection_ExtendedString GetNameOfValues() const;
+ Standard_EXPORT Standard_Boolean GetListOfValues( Handle(TColStd_HArray1OfExtendedString)&,
+ Handle(TColStd_HArray1OfInteger)& ) const;
+ Standard_EXPORT Standard_Boolean GetListOfValues( Handle(TColStd_HArray1OfExtendedString)&,
+ Handle(TColStd_HArray1OfInteger)&,
+ Handle(TColStd_HArray1OfExtendedString)& ) const;
+ Standard_EXPORT Standard_Boolean GetSpecialValues( TColStd_MapOfReal& ) const;
- Standard_EXPORT Standard_Real GetMinZoom() const;
- Standard_EXPORT Standard_Real GetMaxZoom() const;
- Standard_EXPORT Standard_Real GetZoomOrder() const;
+ Standard_EXPORT Standard_Real GetMinZoom() const;
+ Standard_EXPORT Standard_Real GetMaxZoom() const;
+ Standard_EXPORT Standard_Real GetZoomOrder() const;
- Standard_EXPORT Standard_Real ToSI( const Standard_Real ) const;
- Standard_EXPORT Standard_Real FromSI( const Standard_Real ) const;
+ Standard_EXPORT virtual Standard_Real ToSI( const Standard_Real ) const;
+ Standard_EXPORT virtual Standard_Real FromSI( const Standard_Real ) const;
- Standard_EXPORT Standard_Real ToSI( const Standard_Real, const UnitSystem& ) const;
- Standard_EXPORT Standard_Real FromSI( const Standard_Real, const UnitSystem& ) const;
+ Standard_EXPORT virtual Standard_Real ToSI( const Standard_Real, const UnitSystem& ) const;
+ Standard_EXPORT virtual Standard_Real FromSI( const Standard_Real, const UnitSystem& ) const;
- Standard_EXPORT Standard_Boolean HasData( const Standard_Integer ) const;
+ Standard_EXPORT Standard_Boolean HasData( const Standard_Integer ) const;
- Standard_EXPORT TCollection_ExtendedString GetOption( const TCollection_AsciiString& ) const;
- Standard_EXPORT Standard_Boolean GetOptionNames( TColStd_SequenceOfAsciiString& ) const;
+ Standard_EXPORT TCollection_ExtendedString GetOption( const TCollection_AsciiString& ) const;
+ Standard_EXPORT Standard_Boolean GetOptionNames( TColStd_SequenceOfAsciiString& ) const;
+
+protected:
+
+ Standard_EXPORT void SetId( const TCollection_AsciiString& );
+
+ Standard_EXPORT void SetComponent( const Handle(Standard_Transient)& );
+
+ Standard_EXPORT void SetLabel( const TCollection_AsciiString& );
+
+ Standard_EXPORT void SetFilter( const TCollection_AsciiString& );
+
+ Standard_EXPORT void SetRequired( const TCollection_AsciiString& );
+
+ Standard_EXPORT void SetWarningLevel( const Standard_Integer& );
+
+ Standard_EXPORT void SetMinZoom( const Standard_Real& );
+ Standard_EXPORT void SetMaxZoom( const Standard_Real& );
+ Standard_EXPORT void SetZoomOrder( const Standard_Real& );
+
+ Standard_EXPORT void SetShortDescription( const TCollection_ExtendedString& );
+ Standard_EXPORT void SetLongDescription( const TCollection_ExtendedString& );
+
+ Standard_EXPORT bool SetOption( const TCollection_AsciiString&, const TCollection_AsciiString& );
+ Standard_EXPORT void SetType( const DDS_DicItem::Type& );
+
+ Standard_EXPORT void SetMin( const Standard_Real& );
+ Standard_EXPORT void SetMax( const Standard_Real& );
+
+ Standard_EXPORT void SetDefaultValue( const Standard_Real& );
+ Standard_EXPORT void SetDefaultValue( const TCollection_AsciiString& );
+
+ Standard_EXPORT void SetListOfValues( const Handle(TColStd_HArray1OfExtendedString)&,
+ const Handle(TColStd_HArray1OfInteger)& );
+ Standard_EXPORT void SetListOfValues( const Handle(TColStd_HArray1OfExtendedString)&,
+ const Handle(TColStd_HArray1OfInteger)&,
+ const Handle(TColStd_HArray1OfExtendedString)& );
+
+protected:
+
+ Standard_EXPORT DDS_DicItem( const DDS_DicItem& );
+
+ Standard_EXPORT void operator=( const DDS_DicItem& );
+
+ Standard_EXPORT virtual void FillDataMap( TCollection_AsciiString, const LDOM_Element&,
+ const LDOM_Element&, const LDOM_Element&,
+ const TColStd_SequenceOfAsciiString& );
private:
- DDS_DicItem( const DDS_DicItem& );
- void operator=( const DDS_DicItem& );
- void FillDataMap( TCollection_AsciiString, const LDOM_Element&,
- const LDOM_Element&, const LDOM_Element&,
- const TColStd_SequenceOfAsciiString& );
- void PrepareFormats( const TCollection_AsciiString& );
- void GetDefaultFormat();
- UnitSystem GetActiveUnitSystem() const;
-
- void GetStringFormat( const TCollection_AsciiString&,
- const TCollection_AsciiString&,
- const TCollection_AsciiString&,
- const TCollection_AsciiString&,
- TCollection_AsciiString& );
- void GetIntegerFormat( const TCollection_AsciiString&,
- const TCollection_AsciiString&,
- const TCollection_AsciiString&,
- const TCollection_AsciiString&,
- const Standard_Character,
- TCollection_AsciiString& );
- void GetFloatFormat( const TCollection_AsciiString&,
- const TCollection_AsciiString&,
- const TCollection_AsciiString&,
- const TCollection_AsciiString&,
- const Standard_Character,
- TCollection_AsciiString& );
- void Split( const TCollection_AsciiString&,
- Handle(TColStd_HArray1OfExtendedString)& );
-
- UnitData* GetUnitData( const UnitSystem& ) const;
+
+ Standard_EXPORT void PrepareFormats( const TCollection_AsciiString& );
+ Standard_EXPORT void GetDefaultFormat();
+ Standard_EXPORT UnitSystem GetActiveUnitSystem() const;
+
+ Standard_EXPORT void GetStringFormat( const TCollection_AsciiString&,
+ const TCollection_AsciiString&,
+ const TCollection_AsciiString&,
+ const TCollection_AsciiString&,
+ TCollection_AsciiString& );
+ Standard_EXPORT void GetIntegerFormat( const TCollection_AsciiString&,
+ const TCollection_AsciiString&,
+ const TCollection_AsciiString&,
+ const TCollection_AsciiString&,
+ const Standard_Character,
+ TCollection_AsciiString& );
+ Standard_EXPORT void GetFloatFormat( const TCollection_AsciiString&,
+ const TCollection_AsciiString&,
+ const TCollection_AsciiString&,
+ const TCollection_AsciiString&,
+ const Standard_Character,
+ TCollection_AsciiString& );
+ Standard_EXPORT void Split( const TCollection_AsciiString&,
+ Handle(TColStd_HArray1OfExtendedString)& );
+
+ Standard_EXPORT UnitData* GetUnitData( const UnitSystem& ) const;
private:
typedef NCollection_DataMap<TCollection_AsciiString, TCollection_ExtendedString> OptionsMap;
IMPLEMENT_STANDARD_HANDLE(DDS_Dictionary, MMgt_TShared)
IMPLEMENT_STANDARD_RTTIEXT(DDS_Dictionary, MMgt_TShared)
+Handle(DDS_Dictionary) DDS_Dictionary::myDictionary = Handle(DDS_Dictionary)();
+
/*!
\class DDS_Dictionary
\brief This class provides an information about used datums,
*/
Handle_DDS_Dictionary DDS_Dictionary::Get()
{
- static Handle(DDS_Dictionary) sDictionary;
-
- if ( sDictionary.IsNull() )
- sDictionary = new DDS_Dictionary();
+ if ( myDictionary.IsNull() )
+ myDictionary = new DDS_Dictionary();
- return sDictionary;
+ return myDictionary;
}
/*!
LDOM_Document aDoc = aParser.getDocument();
LDOM_Element aDocElement = aDoc.getDocumentElement();
- for ( LDOM_Element aComponentElem = aDocElement.GetChildByTagName( KeyWord( "COMPONENT" ) );
- !aComponentElem.isNull(); aComponentElem = aComponentElem.GetSiblingByTagName() )
- aDic->FillDataMap( aComponentElem, aDocElement );
+ if ( !aDocElement.isNull() )
+ aDic->FillDataMap( aDocElement );
_LoadMap.Add( theFileName );
/*!
\brief Fill the internal data structures from the XML node.
- \param theComponentData component XML node
\param theDocElement document XML node
*/
-void DDS_Dictionary::FillDataMap( const LDOM_Element& theComponentData, const LDOM_Element& theDocElement )
+void DDS_Dictionary::FillDataMap( const LDOM_Element& theDocElement )
{
- TCollection_AsciiString aCompName = theComponentData.getAttribute( KeyWord( "COMPONENT_NAME" ) );
- if ( !myGroupMap.Contains( aCompName ) )
- myGroupMap.Add( aCompName, new DDS_DicGroup( aCompName ) );
- Handle(DDS_DicGroup) aDicGroup = myGroupMap.FindFromKey( aCompName );
- aDicGroup->FillDataMap( theComponentData, theDocElement );
- myGroupMap.Add( aCompName, aDicGroup );
+ for ( LDOM_Element aComponentElem = theDocElement.GetChildByTagName( KeyWord( "COMPONENT" ) );
+ !aComponentElem.isNull(); aComponentElem = aComponentElem.GetSiblingByTagName() )
+ {
+ TCollection_AsciiString aCompName = aComponentElem.getAttribute( KeyWord( "COMPONENT_NAME" ) );
+ if ( !myGroupMap.Contains( aCompName ) )
+ myGroupMap.Add( aCompName, CreateGroup( aCompName ) );
+ Handle(DDS_DicGroup) aDicGroup = myGroupMap.FindFromKey( aCompName );
+ aDicGroup->FillDataMap( aComponentElem, theDocElement );
+ myGroupMap.Add( aCompName, aDicGroup );
+ }
}
/*!
if( !aDicGroup.IsNull() )
aDicGroup->GetKeys( seq );
}
+
+/*!
+ \brief Create instance of a dictionary group. This method can
+ be used for customization data dictionary by specific
+ groups design.
+ \return New dictionary group instance.
+*/
+Handle(DDS_DicGroup) DDS_Dictionary::CreateGroup( const TCollection_AsciiString& theCompName ) const
+{
+ return new DDS_DicGroup( theCompName );
+}
+
+/*!
+ \brief Set instance of dictionary. This method might be used in descendant classes to initialize
+ custom dictionary and replace the default implementation.
+ This method overrides static handle on dictionary that is available
+ through Get() method
+*/
+void DDS_Dictionary::SetDictionary( const Handle(DDS_Dictionary)& theDict )
+{
+ myDictionary = theDict;
+}
static Standard_EXPORT LDOMString KeyWord( const TCollection_AsciiString& );
-private:
- DDS_Dictionary();
- DDS_Dictionary( const DDS_Dictionary& );
+protected:
- void operator=( const DDS_Dictionary& );
+ Standard_EXPORT virtual Handle(DDS_DicGroup) CreateGroup( const TCollection_AsciiString& ) const;
- void FillDataMap( const LDOM_Element&, const LDOM_Element& );
+protected:
+
+ Standard_EXPORT DDS_Dictionary();
+
+ Standard_EXPORT DDS_Dictionary( const DDS_Dictionary& );
+
+ Standard_EXPORT void operator=( const DDS_Dictionary& );
+
+ Standard_EXPORT virtual void FillDataMap( const LDOM_Element& );
+
+ Standard_EXPORT static void SetDictionary(const Handle(DDS_Dictionary)& theDict);
+
+protected:
-private:
DDS_IndexedDataMapOfDicGroups myGroupMap;
+private:
+
+ static Handle(DDS_Dictionary) myDictionary;
+
public:
DEFINE_STANDARD_RTTI(DDS_Dictionary)
};
#include <QMenu>
#include <QVBoxLayout>
-#include <utilities.h>
-
/*!
\brief Constructor.
char* synchronous = getenv("PYTHON_CONSOLE_SYNC");
if (synchronous && atoi(synchronous))
{
- MESSAGE("Python console is synchronous");
myEditor->setIsSync(true);
}
myEditor->viewport()->installEventFilter( this );
bool isChecked() const;
void setChecked( const bool );
+ virtual QString getString() const;
+
virtual void clear();
signals:
QCheckBox* checkBox() const;
virtual QWidget* createControl( QWidget* );
- virtual QString getString() const;
virtual void setString( const QString& );
};
{
QtxComboBox* cb = new QtxComboBox( parent );
cb->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ) );
- connect( cb, SIGNAL( textChanged( const QString& ) ), this,
+ connect( cb, SIGNAL( editTextChanged( const QString& ) ), this,
SLOT( onTextChanged( const QString& ) ) );
connect( cb, SIGNAL( activated( int ) ), this, SLOT( onActivated( int ) ) );
return cb;
void setValues( const QList<int>&, const QStringList& );
void setValues( const QStringList& );
+ virtual QString getString() const;
+
virtual void reset();
int stringToValue( const QString& ) const;
QtxComboBox* comboBox() const;
virtual QWidget* createControl( QWidget* );
- virtual QString getString() const;
virtual void setString( const QString& );
virtual void unitSystemChanged( const QString& );
QVariant QDS_Datum::value() const
{
QVariant val;
- if ( !isEmpty() )
- val = stringValue();
+ // trying to return QVariant containing value of correct data type
+ if ( dicItem().IsNull() )
+ {
+ if ( !isEmpty() )
+ val = stringValue();
+ }
+ else
+ {
+ switch( type() )
+ {
+ case DDS_DicItem::Float:
+ val = doubleValue();
+ break;
+ case DDS_DicItem::Integer:
+ case DDS_DicItem::List:
+ val = integerValue();
+ break;
+ case DDS_DicItem::String:
+ case DDS_DicItem::Unknown:
+ val = stringValue();
+ break;
+ }
+ }
return val;
}
*/
void QDS_Datum::setValue( const QVariant& val )
{
+ // trying to extract data of correct type from QVariant
+ if ( !dicItem().IsNull() )
+ {
+ bool isOk = false;
+ switch( type() )
+ {
+ case DDS_DicItem::Float:
+ {
+ double aDblVal = val.toDouble( &isOk );
+ if ( isOk )
+ {
+ setDoubleValue( aDblVal );
+ return;
+ }
+ break;
+ }
+ case DDS_DicItem::Integer:
+ case DDS_DicItem::List:
+ {
+ int anIntVal = val.toInt( &isOk );
+ if ( isOk )
+ {
+ setIntegerValue( anIntVal );
+ return;
+ }
+ break;
+ }
+ case DDS_DicItem::String:
+ case DDS_DicItem::Unknown:
+ break;
+ }
+ }
+
if ( val.isValid() && val.canConvert( QVariant::String ) )
setStringValue( val.toString() );
else
if ( wrapper( Control ) )
l->addWidget( wrapper( Control ) );
if ( wrapper( Units ) )
- l->addWidget( unitsWidget() );
+ l->addWidget( wrapper( Units ) );
}
/*!
static QString format( const double, const QString&, const bool = false );
static QString units( const QString& );
+ virtual QString getString() const = 0;
+
virtual bool eventFilter( QObject*, QEvent* );
operator QWidget*() const;
virtual QLabel* createUnits( QWidget* );
virtual QWidget* createControl( QWidget* ) = 0;
- virtual QString getString() const = 0;
virtual void setString( const QString& ) = 0;
virtual bool validate( const QString& ) const;
bool hasSelection() const;
void setSelection( const bool );
+ virtual QString getString() const;
+
signals:
void returnPressed();
virtual QWidget* createControl( QWidget* );
QLineEdit* lineEdit() const;
- virtual QString getString() const;
virtual void setString( const QString& );
virtual void unitSystemChanged( const QString& );
void setValues( const QList<int>&, const QStringList& );
void setValues( const QStringList& );
+ virtual QString getString() const;
+
signals:
void activated( int );
virtual QWidget* createControl( QWidget* );
void buttons( QList<QRadioButton*>& ) const;
- virtual QString getString() const;
virtual void setString( const QString& );
virtual void unitSystemChanged( const QString& );
int step() const;
void setStep( const int );
+ virtual QString getString() const;
+
private slots:
void onValueChanged( int );
virtual QWidget* createControl( QWidget* );
- virtual QString getString() const;
virtual void setString( const QString& );
virtual void unitSystemChanged( const QString& );
double step() const;
void setStep( const double );
+ virtual QString getString() const;
+
private slots:
void onValueChanged( double );
QtxDoubleSpinBox* spinBox() const;
virtual QWidget* createControl( QWidget* );
- virtual QString getString() const;
virtual void setString( const QString& );
virtual void unitSystemChanged( const QString& );
QDS_TextEdit( const QString&, QWidget* = 0, const int = All, const QString& = QString() );
virtual ~QDS_TextEdit();
+ virtual QString getString() const;
+
signals:
void returnPressed();
QTextEdit* textEdit() const;
virtual QWidget* createControl( QWidget* );
- virtual QString getString() const;
virtual void setString( const QString& );
};
*/
void QtxWorkstackArea::updateCurrent()
{
- QWidget* cur = child( widget( myBar->tabId( myBar->currentIndex() ) ) );
+ QWidget* cur = child( myBar->tabId( myBar->currentIndex() ) );
if ( cur )
myStack->setCurrentWidget( cur );
}
bool restoreState( QDataStream&, QMap<QString, QtxWorkstackChild*>& );
};
-class QtxWorkstackArea : public QFrame
+class QTX_EXPORT QtxWorkstackArea : public QFrame
{
Q_OBJECT
// Create menus
int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1, MenuFileId, 0 );
- int editMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, MenuEditId, 10 );
+ // Let the application developers insert some menus between Edit and View
+ int editMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, MenuEditId, 5 );
int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1, MenuViewId, 10 );
int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, MenuHelpId, 1000 );
*/
void SUIT_DataBrowser::setShortcutKey( const int id, const int key )
{
- ShortcutMap::iterator it = myShortcutMap.find( key );
+ ShortcutMap::iterator it = myShortcutMap.find( id );
if( it != myShortcutMap.end() )
(*it)->setKey(key);
}
myParent = p;
}
+/*!
+ \brief Sets modification state of the object.
+
+ When the object has been modified (modified is set to true)
+ a signal is emitted to notify the tree model and eventually redraw the data object.
+
+ \param modified modified state
+*/
+void SUIT_DataObject::setModified(bool modified)
+{
+ if ( _modified == modified )
+ return;
+
+ _modified = modified;
+ if ( _modified )
+ signal()->emitModified( this );
+}
+
/*!
\brief Get data object name.
emit( removed( object, parent ) );
}
+/*!
+ \brief Emit a signal to notify that the data object has been modified.
+ \param object data object that has been modified
+*/
+void SUIT_DataObject::Signal::emitModified( SUIT_DataObject* object )
+{
+ emit( modified( object ) );
+}
+
/*!
\brief Schedule data object for the late deleting.
\param object data object to be deleted later
virtual void assignParent( SUIT_DataObject* );
void insertChildAtPos( SUIT_DataObject* obj, int position );
bool modified(){return _modified;};
- void setModified(bool modified){_modified = modified;};
+ virtual void setModified(bool modified);
virtual QString name() const;
virtual QString text( const int = NameId ) const;
void emitDestroyed( SUIT_DataObject* );
void emitInserted( SUIT_DataObject*, SUIT_DataObject* );
void emitRemoved( SUIT_DataObject*, SUIT_DataObject* );
+ void emitModified( SUIT_DataObject* );
void deleteLater( SUIT_DataObject* );
void destroyed( SUIT_DataObject* );
void inserted( SUIT_DataObject*, SUIT_DataObject* );
void removed( SUIT_DataObject*, SUIT_DataObject* );
+ void modified( SUIT_DataObject* );
friend class SUIT_DataObject;
this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) );
SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ),
this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) );
+ SUIT_DataObject::disconnect( SIGNAL( modifed( SUIT_DataObject* ) ),
+ this, SLOT( onModified( SUIT_DataObject* ) ) );
delete myRoot;
}
\param id - column name
\param state - visible state
+ \param emitChanged - if set to false, blocks dataChanged() signal, this can be used to
+ prevent emitting dataChanged() several times for the same data object
*/
-void SUIT_TreeModel::setVisibilityState( const QString& id, Qtx::VisibilityState state )
+void SUIT_TreeModel::setVisibilityState( const QString& id, Qtx::VisibilityState state, bool emitChanged )
{
VisibilityMap::const_iterator it = myVisibilityMap.find( id );
if ( it != myVisibilityMap.end() && it.value() == state )
else {
needSignal = myVisibilityMap.remove( id ) > 0;
}
- if ( needSignal ) {
+ if ( emitChanged && needSignal ) {
QModelIndexList lst;
if ( searcher() ) {
SUIT_DataObject* o = searcher()->findObject( id );
/*!
\brief Set visibility state for all objects.
- \param id - column name
\param state - visible state
*/
void SUIT_TreeModel::setVisibilityStateForAll( Qtx::VisibilityState state )
this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) );
SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ),
this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) );
+ SUIT_DataObject::disconnect( SIGNAL( modified( SUIT_DataObject* ) ),
+ this, SLOT( onModified( SUIT_DataObject* ) ) );
delete myRoot;
+
+ if ( myRootItem ) {
+ QList<TreeItem*> items = myRootItem->children();
+ for ( QList<TreeItem*>::iterator anIt = items.begin(); anIt != items.end(); anIt++ )
+ delete *anIt;
+ }
}
myRoot = r;
this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) );
SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ),
this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) );
+ SUIT_DataObject::disconnect( SIGNAL( modified( SUIT_DataObject* ) ),
+ this, SLOT( onModified( SUIT_DataObject* ) ) );
myAutoUpdate = on;
if ( myAutoUpdate ) {
this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) );
SUIT_DataObject::connect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ),
this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) );
+ SUIT_DataObject::connect( SIGNAL( modified( SUIT_DataObject* ) ),
+ this, SLOT( onModified( SUIT_DataObject* ) ) );
updateTree();
}
this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) );
SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ),
this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) );
+ SUIT_DataObject::disconnect( SIGNAL( modified( SUIT_DataObject* ) ),
+ this, SLOT( onModified( SUIT_DataObject* ) ) );
if ( autoUpdate() ) {
SUIT_DataObject::connect( SIGNAL( inserted( SUIT_DataObject*, SUIT_DataObject* ) ),
this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) );
SUIT_DataObject::connect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ),
this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) );
+ SUIT_DataObject::connect( SIGNAL( modified( SUIT_DataObject* ) ),
+ this, SLOT( onModified( SUIT_DataObject* ) ) );
}
myItems.clear(); // ????? is it really necessary
QModelIndex lastIdx = index( obj, columnCount() - 1 );
emit dataChanged( firstIdx, lastIdx );
obj->setModified(false);
- if( emitLayoutChanged )
+ if ( emitLayoutChanged )
emit layoutChanged();
}
updateTree( parent );
}
+/*!
+ \brief Called when the data object is modified. TreeSync is not used here for maximum efficiency.
+ It is assumed that it is up to the application to decide when its data objects are modified.
+ \param obj data object that has been modified
+*/
+void SUIT_TreeModel::onModified( SUIT_DataObject* obj )
+{
+ if ( autoUpdate() )
+ {
+ QModelIndex firstIdx = index( obj, 0 );
+ QModelIndex lastIdx = index( obj, columnCount() - 1 );
+ emit dataChanged( firstIdx, lastIdx );
+ obj->setModified(false);
+ }
+}
+
/*!
\brief Drag and Drop support.
*/
\param id - column name
\param state - visible state
+ \param emitChanged - if set to false, blocks dataChanged() signal, this can be used to
+ prevent emitting dataChanged() several times for the same data object
*/
-void SUIT_ProxyModel::setVisibilityState(const QString& id, Qtx::VisibilityState state)
-{
+void SUIT_ProxyModel::setVisibilityState(const QString& id, Qtx::VisibilityState state, bool emitChanged ) {
if(treeModel())
- treeModel()->setVisibilityState(id,state);
+ treeModel()->setVisibilityState(id,state,emitChanged);
}
/*!
virtual QPixmap columnIcon( const QString& name ) const = 0;
virtual void setAppropriate( const QString& name, const Qtx::Appropriate appr ) = 0;
virtual Qtx::Appropriate appropriate( const QString& name ) const = 0;
- virtual void setVisibilityState(const QString& id, Qtx::VisibilityState state) = 0;
+ virtual void setVisibilityState(const QString& id, Qtx::VisibilityState state, bool emitChanged = true) = 0;
virtual void setVisibilityStateForAll(Qtx::VisibilityState state) = 0;
virtual Qtx::VisibilityState visibilityState(const QString& id) const = 0;
virtual void setHeaderFlags( const QString& name, const Qtx::HeaderViewFlags flags ) = 0;
virtual QPixmap columnIcon( const QString& name ) const;
virtual void setAppropriate( const QString& name, const Qtx::Appropriate appr );
virtual Qtx::Appropriate appropriate( const QString& name ) const;
- virtual void setVisibilityState(const QString& id, Qtx::VisibilityState state);
+ virtual void setVisibilityState(const QString& id, Qtx::VisibilityState state, bool emitChanged = true);
virtual void setVisibilityStateForAll(Qtx::VisibilityState state);
virtual Qtx::VisibilityState visibilityState(const QString& id) const;
virtual void setHeaderFlags( const QString& name, const Qtx::HeaderViewFlags flags );
private slots:
void onInserted( SUIT_DataObject*, SUIT_DataObject* );
void onRemoved( SUIT_DataObject*, SUIT_DataObject* );
+ void onModified( SUIT_DataObject* );
private:
typedef QMap<SUIT_DataObject*, TreeItem*> ItemMap;
virtual QPixmap columnIcon( const QString& name ) const;
virtual void setAppropriate( const QString& name, const Qtx::Appropriate appr );
virtual Qtx::Appropriate appropriate( const QString& name ) const;
- virtual void setVisibilityState(const QString& id, Qtx::VisibilityState state);
+ virtual void setVisibilityState(const QString& id, Qtx::VisibilityState state, bool emitChanged = true);
virtual void setVisibilityStateForAll(Qtx::VisibilityState state);
virtual Qtx::VisibilityState visibilityState(const QString& id) const;
virtual void setHeaderFlags( const QString& name, const Qtx::HeaderViewFlags flags );