X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FDDS%2FDDS_DicItem.cxx;h=5fd63eefff81ea5a6433f2b822c47e7cc8e4f2dc;hb=b6e35aa42d3c67a529d7f9339718dfaed6891323;hp=b7a0e1bad57f965ad7a1d7571c9ead252e3b911e;hpb=758c66ca44d214e40e828e41790408af0540231f;p=modules%2Fgui.git diff --git a/src/DDS/DDS_DicItem.cxx b/src/DDS/DDS_DicItem.cxx index b7a0e1bad..5fd63eeff 100644 --- a/src/DDS/DDS_DicItem.cxx +++ b/src/DDS/DDS_DicItem.cxx @@ -1,9 +1,28 @@ +// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + #include "DDS_DicItem.h" #include "DDS_Dictionary.h" -#include -#include - #include #include #include @@ -11,71 +30,120 @@ #include #include -#include -#include +IMPLEMENT_STANDARD_RTTIEXT(DDS_DicItem, Standard_Transient) + +/*! + \class DDS_DicItem + \brief This class provides an information about datum (phisical characteristic parameter). +*/ -IMPLEMENT_STANDARD_HANDLE(DDS_DicItem, MMgt_TShared) -IMPLEMENT_STANDARD_RTTIEXT(DDS_DicItem, MMgt_TShared) +/*! + \brief Constructor. + Creates the instance of empty dictionary item. +*/ DDS_DicItem::DDS_DicItem() : myType( 0 ), -myDefValue( 0 ), -myMax( 0 ), -myMin( 0 ), -myMinZoom( 0.1 ), -myMaxZoom( 10 ), -myZoomOrder( 2 ) + myMax( 0 ), + myMin( 0 ), + myDefValue( 0 ), + myMinZoom( 0.1 ), + myMaxZoom( 10 ), + myZoomOrder( 2 ) { } +/*! + \brief Copy constructor (put in private section to prevent object copying). +*/ DDS_DicItem::DDS_DicItem( const DDS_DicItem& ) +: Standard_Transient() { } +/*! + \brief Assignment operator (put in private section to prevent object copying). +*/ void DDS_DicItem::operator=( const DDS_DicItem& ) { } +/*! + \brief Get the identifier of parameter. + \return parameter ID +*/ TCollection_AsciiString DDS_DicItem::GetId() const { return myId; } +/*! + \brief Get the type of parameter. + \return parameter type +*/ DDS_DicItem::Type DDS_DicItem::GetType() const { return (DDS_DicItem::Type)myType; } +/*! + \brief Get the label of the parameter. + \return parameter label +*/ TCollection_ExtendedString DDS_DicItem::GetLabel() const { return myLabel; } +/*! + \brief Get the filter (regular expression) for the parameter values. + \return parameter filter +*/ TCollection_ExtendedString DDS_DicItem::GetFilter() const { return myFilter; } +/*! + \brief Get the Required attribute of the parameter. + \return Required attribute +*/ TCollection_ExtendedString DDS_DicItem::GetRequired() const { return myRequired; } +/*! + \brief Get the wrong value warning level of the parameter. + \return warning level +*/ DDS_MsgType DDS_DicItem::GetWarningLevel() const { return (DDS_MsgType)myWarnLevel; } +/*! + \brief Get the long description of the parameter. + \return long description +*/ TCollection_ExtendedString DDS_DicItem::GetLongDescription() const { return myLongDescr; } +/*! + \brief Get the short description of the parameter. + \return short description +*/ TCollection_ExtendedString DDS_DicItem::GetShortDescription() const { return myShortDescr; } +/*! + \brief Get the name of the component (parameter owner). + \return component name +*/ TCollection_AsciiString DDS_DicItem::GetComponent() const { TCollection_AsciiString aCompName; @@ -85,11 +153,23 @@ TCollection_AsciiString DDS_DicItem::GetComponent() const return aCompName; } +/*! + \brief Get the parameter measure units for active units system. + \return parameter units +*/ TCollection_AsciiString DDS_DicItem::GetUnits() const { return GetUnits( GetActiveUnitSystem() ); } +/*! + \brief Get the parameter measure units for specified units system \a theSystem. + + If specified units system doesn't exist, empty string is returned. + + \param theSystem units system + \return parameter units +*/ TCollection_AsciiString DDS_DicItem::GetUnits( const UnitSystem& theSystem ) const { TCollection_AsciiString anUnits; @@ -99,31 +179,77 @@ TCollection_AsciiString DDS_DicItem::GetUnits( const UnitSystem& theSystem ) con return anUnits; } +/*! + \brief Get the minimum value of the parameter for active units system. + + Returned value is converted to SI. + + \return minimum value +*/ Standard_Real DDS_DicItem::GetMinValue() const { return GetMinValue( GetActiveUnitSystem() ); } +/*! + \brief Get the minimum value of the parameter for the specified + units system \a theSystem. + + Returned value is converted to SI. + + \param theUnitsSystem units system + \return minimum value +*/ Standard_Real DDS_DicItem::GetMinValue( const UnitSystem& theUnitsSystem ) const { return FromSI( myMin, theUnitsSystem ); } +/*! + \brief Get the maximum value of the parameter for active units system. + + Returned value converted to SI. + + \return maximum value +*/ Standard_Real DDS_DicItem::GetMaxValue() const { return GetMaxValue( GetActiveUnitSystem() ); } +/*! + \brief Get the maximum value of the parameter for specified + units system \a theSystem. + + Returned value converted to SI. + + \param theUnitsSystem units system + \return maximum value +*/ Standard_Real DDS_DicItem::GetMaxValue( const UnitSystem& theUnitsSystem ) const { return FromSI( myMax, theUnitsSystem ); } +/*! + \brief Get the precision (number of digits after decimal point) + of the parameter for active units system. + \return parameter precision +*/ Standard_Integer DDS_DicItem::GetPrecision() const { return GetPrecision( GetActiveUnitSystem() ); } +/*! + \brief Get the precision (number of digits after decimal point) of the parameter + for specified units system \a theSystem. + + If specified units system doesn't exist, zero is returned. + + \param theSystem units system + \return parameter precision +*/ Standard_Integer DDS_DicItem::GetPrecision( const UnitSystem& theSystem ) const { Standard_Integer aRes = 0; @@ -133,11 +259,31 @@ Standard_Integer DDS_DicItem::GetPrecision( const UnitSystem& theSystem ) const return aRes; } +/*! + \brief Get the default value of the parameter for active units system. + + Default value is returned as string. + If type of the value is numerical (Float or Integer) and default value + is defined, then the returning value is converted to SI. + + \return default value +*/ TCollection_ExtendedString DDS_DicItem::GetDefaultValue() const { return GetDefaultValue( GetActiveUnitSystem() ); } +/*! + \brief Get the default value of the parameter for specified + units system \a theSystem. + + Default value is returned as string. + If type of the value is numerical (Float or Integer) and default value + is defined, then the returning value is converted to SI. + + \param theSystem units system + \return default value +*/ TCollection_ExtendedString DDS_DicItem::GetDefaultValue( const UnitSystem& theSystem ) const { if ( !myDefString.Length() ) @@ -161,11 +307,31 @@ TCollection_ExtendedString DDS_DicItem::GetDefaultValue( const UnitSystem& theSy return aStr; } +/*! + \brief Get the format string of the parameter for active units system. + + If argument \a theCanonical is \c true, format string is reduced according + to the sprintf() specification (without extra non standard qualifiers). + + \param theCanonical 'canonical form' flag + \return format string +*/ TCollection_AsciiString DDS_DicItem::GetFormat( const Standard_Boolean theCanonical ) const { return GetFormat( GetActiveUnitSystem(), theCanonical ); } +/*! + \brief Get the format string of the parameter for specified + units system \a theSystem. + + If argument \a theCanonical is \c true, format string is reduced according + to the sprintf() specification (without extra non standard qualifiers). + + \param theSystem units system + \param theCanonical 'canonical form' flag + \return format string +*/ TCollection_AsciiString DDS_DicItem::GetFormat( const UnitSystem& theSystem, const Standard_Boolean theCanonical ) const { @@ -194,8 +360,14 @@ TCollection_AsciiString DDS_DicItem::GetFormat( const UnitSystem& theSystem, } /*! - Access valueList:name of the parameter. This string is void if the list is - not defined - then use other properties: Type, DefaultValue, MaxValue, MinValue + \brief Get the name of a list referenced by the parameter. + + This string is empty if the list reference is not defined. + In this case, other properties (Type, DefaultValue, MaxValue, MinValue) + should be used. + + \return referenced list name + \sa GetListOfValues() */ TCollection_ExtendedString DDS_DicItem::GetNameOfValues() const { @@ -203,8 +375,17 @@ TCollection_ExtendedString DDS_DicItem::GetNameOfValues() const } /*! - Access valueList of the parameter. This sequence is empty if the list is - not defined - then use other properties: Type, DefaultValue, MaxValue, MinValue + \brief Get item names and item identifiers of a list referenced + by the parameter. + + These sequences are empty if the list reference is not defined. + In this case, other properties (Type, DefaultValue, MaxValue, MinValue) + should be used. + + \param theStrings returning items names + \param theIntegers returning items identifiers + \return \c true if returning lists are not empty + \sa GetNameOfValues() */ Standard_Boolean DDS_DicItem::GetListOfValues( Handle(TColStd_HArray1OfExtendedString)& theStrings, Handle(TColStd_HArray1OfInteger)& theIntegers ) const @@ -215,8 +396,20 @@ Standard_Boolean DDS_DicItem::GetListOfValues( Handle(TColStd_HArray1OfExtendedS } /*! - Access valueList of the parameter. This sequence is empty if the list is not - defined - then use other properties: Type, DefaultValue, MaxValue, MinValue + \brief Get item names, item identifiers and item icons of a list + referenced by the parameter. + + \overload + + These sequences are empty if the list reference is not defined. + In this case, other properties (Type, DefaultValue, MaxValue, MinValue) + should be used. + + \param theStrings returning items names + \param theIntegers returning items identifiers + \param theIcons returning items icons + \return \c true if returning lists are not empty + \sa GetNameOfValues() */ Standard_Boolean DDS_DicItem::GetListOfValues( Handle(TColStd_HArray1OfExtendedString)& theStrings, Handle(TColStd_HArray1OfInteger)& theIntegers, @@ -228,6 +421,12 @@ Standard_Boolean DDS_DicItem::GetListOfValues( Handle(TColStd_HArray1OfExtendedS return !theIntegers.IsNull() && !theStrings.IsNull() && !theIcons.IsNull(); } + +/*! + \brief Get special values of the parameter. + \param theMap returning map of the special values + \return \c true if returning map is not empty +*/ Standard_Boolean DDS_DicItem::GetSpecialValues( TColStd_MapOfReal& theMap ) const { theMap.Clear(); @@ -248,7 +447,8 @@ Standard_Boolean DDS_DicItem::GetSpecialValues( TColStd_MapOfReal& theMap ) cons } /*! - Returns min value of lateral zooming + \brief Get minimum value of lateral zooming. + \return lateral zooming minimum value */ Standard_Real DDS_DicItem::GetMinZoom() const { @@ -256,7 +456,8 @@ Standard_Real DDS_DicItem::GetMinZoom() const } /*! - Returns Max Value of lateral zooming + \brief Get maximum value of lateral zooming. + \return lateral zooming maximum value */ Standard_Real DDS_DicItem::GetMaxZoom() const { @@ -264,25 +465,42 @@ Standard_Real DDS_DicItem::GetMaxZoom() const } /*! - Get Order of lateral zooming + \brief Get order of lateral zooming. + \return lateral zooming order */ Standard_Real DDS_DicItem::GetZoomOrder() const { return myZoomOrder; } +/*! + \brief Convert value \a theVal to the default SI units + according to the active units system. + \param theVal value being converted + \return value converted to SI +*/ Standard_Real DDS_DicItem::ToSI( const Standard_Real theVal ) const { return ToSI( theVal, GetActiveUnitSystem() ); } +/*! + \brief Convert value \a theVal from the default SI units + according to the active units system. + \param theVal value being converted + \return value converted from SI +*/ Standard_Real DDS_DicItem::FromSI( const Standard_Real theVal ) const { return FromSI( theVal, GetActiveUnitSystem() ); } /*! - Convert value to default SI units according to current units + \brief Convert value to the default SI units according to the + units system \a theUnitsSystem. + \param theVal value being converted + \param theUnitsSystem units system + \return value converted to the specified units system */ Standard_Real DDS_DicItem::ToSI( const Standard_Real theVal, const UnitSystem& theUnitsSystem ) const { @@ -294,7 +512,11 @@ Standard_Real DDS_DicItem::ToSI( const Standard_Real theVal, const UnitSystem& t } /*! - Convert value from default SI units according to current units + \brief Convert value from the default SI units according to the + units system \a theUnitsSystem. + \param theVal value being converted + \param theUnitsSystem units system + \return value converted from the specified units system */ Standard_Real DDS_DicItem::FromSI( const Standard_Real theVal, const UnitSystem& theUnitsSystem ) const { @@ -306,10 +528,59 @@ Standard_Real DDS_DicItem::FromSI( const Standard_Real theVal, const UnitSystem& } /*! - Parse record in XML file and retrieve information relevant for this data dic item + \brief Check data existence. + \param flag data flag + \return \c true if data specified by \a flag exists +*/ +Standard_Boolean DDS_DicItem::HasData( const Standard_Integer flag ) const +{ + return ( myData & flag ) == flag; +} + +/*! + \brief Get option for specified name \a name. + + If option is not found, empty string is returned. + + \param name option name + \return option value +*/ +TCollection_ExtendedString DDS_DicItem::GetOption( const TCollection_AsciiString& name ) const +{ + TCollection_ExtendedString res; + if ( myOptions.IsBound( name ) ) + res = myOptions.Find( name ); + return res; +} + +/*! + \brief Get names of all existing options. + \param names returning list of options + \return \c true if list is not empty +*/ +Standard_Boolean DDS_DicItem::GetOptionNames( TColStd_SequenceOfAsciiString& names ) const +{ + names.Clear(); + + for ( OptionsMap::Iterator it( myOptions ); it.More(); it.Next() ) + names.Append( it.Key() ); + + return !names.IsEmpty(); +} + + +/*! + \brief Parse record from XML file and retrieve information relevant for + the dictionary item. + \param theID item identifier + \param theDatum datum XML node + \param theCompElement component XML node + \param theDocElement document XML node + \param theSystems units system names */ void DDS_DicItem::FillDataMap( TCollection_AsciiString theID, const LDOM_Element& theDatum, - const LDOM_Element& theDocElement, const TColStd_SequenceOfAsciiString& theSystems ) + const LDOM_Element& theCompElement, const LDOM_Element& theDocElement, + const TColStd_SequenceOfAsciiString& theSystems ) { TCollection_AsciiString aLabel = theDatum.getAttribute( DDS_Dictionary::KeyWord( "DATUM_LABEL" ) ); TCollection_AsciiString aFormat = theDatum.getAttribute( DDS_Dictionary::KeyWord( "DATUM_FORMAT" ) ); @@ -318,7 +589,7 @@ void DDS_DicItem::FillDataMap( TCollection_AsciiString theID, const LDOM_Element TCollection_AsciiString aBaseKeyWord = DDS_Dictionary::KeyWord( "DATUM_UNITS" ); - for ( Standard_Integer j = 0; j < theSystems.Length(); j++ ) + for ( Standard_Integer j = 1; j <= theSystems.Length(); j++ ) { UnitSystem anUnitSystem = theSystems.Value( j ); if ( !anUnitSystem.Length() ) @@ -435,15 +706,22 @@ void DDS_DicItem::FillDataMap( TCollection_AsciiString theID, const LDOM_Element else if ( aType.IsEqual( "Integer" ) ) aEnumType = Integer; + if ( !aValueDescr.getAttributeNode( DDS_Dictionary::KeyWord( "VD_MINV" ) ).isNull() ) + myData |= MinValue; aMinV = aValueDescr.getAttribute( DDS_Dictionary::KeyWord( "VD_MINV" ) ); aMinV.RemoveAll( ' ' ); if ( aMinV.IsRealValue() ) aRealMinV = aMinV.RealValue(); + if ( !aValueDescr.getAttributeNode( DDS_Dictionary::KeyWord( "VD_MAXV" ) ).isNull() ) + myData |= MaxValue; aMaxV = aValueDescr.getAttribute( DDS_Dictionary::KeyWord( "VD_MAXV" ) ); aMaxV.RemoveAll( ' ' ); if ( aMaxV.IsRealValue() ) aRealMaxV = aMaxV.RealValue(); aDefV = aValueDescr.getAttribute( DDS_Dictionary::KeyWord( "VD_DEFV" ) ); + if ( !aValueDescr.getAttributeNode( DDS_Dictionary::KeyWord( "VD_DEFV" ) ).isNull() ) + myData |= DefaultValue; + aDefV.RemoveAll( ' ' ); if ( aDefV.IsRealValue() ) aRealDefV = aDefV.RealValue(); @@ -462,32 +740,46 @@ void DDS_DicItem::FillDataMap( TCollection_AsciiString theID, const LDOM_Element LDOMString aListId = aListRef.getAttribute( DDS_Dictionary::KeyWord( "VLR_LIST" ) ); aDefV = aListRef.getAttribute( DDS_Dictionary::KeyWord( "VD_DEFV" ) ); aDefV.RemoveAll( ' ' ); - for ( LDOM_Element aListItem = theDocElement.GetChildByTagName( DDS_Dictionary::KeyWord( "VALUE_LIST" ) ); - aListItem != NULL; aListItem = aListItem.GetSiblingByTagName() ) + LDOM_Element foundListItem; + for ( LDOM_Element aListItem = theCompElement.GetChildByTagName( DDS_Dictionary::KeyWord( "VALUE_LIST" ) ); + aListItem != NULL && foundListItem == NULL; aListItem = aListItem.GetSiblingByTagName() ) { if ( aListItem.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_ID" ) ).equals( aListId ) ) + foundListItem = aListItem; + + } + for ( LDOM_Element aLstItem = theDocElement.GetChildByTagName( DDS_Dictionary::KeyWord( "VALUE_LIST" ) ); + aLstItem != NULL && foundListItem == NULL; aLstItem = aLstItem.GetSiblingByTagName() ) + { + if ( aLstItem.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_ID" ) ).equals( aListId ) ) + foundListItem = aLstItem; + } + + if ( foundListItem != NULL ) + { + // The appropriate list of values is found: store the list name + aListName = foundListItem.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_NAME" ) ); + // Iteration through the list of values + LDOM_Element aListItemValue = foundListItem.GetChildByTagName( DDS_Dictionary::KeyWord( "VALUE_LIST_VALUE" ) ); + while ( aListItemValue != NULL ) { - // The appropriate list of values is found: store the list name - aListName = aListItem.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_NAME" ) ); - // Iteration through the list of values - LDOM_Element aListItemValue = aListItem.GetChildByTagName( DDS_Dictionary::KeyWord( "VALUE_LIST_VALUE" ) ); - while ( aListItemValue != NULL ) + // read value ID + TCollection_AsciiString aListValueID = aListItemValue.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_VALUEID" ) ); + if ( aListValueID.IsIntegerValue() ) { - // read value ID - TCollection_AsciiString aListValueID = aListItemValue.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_VALUEID" ) ); - if ( aListValueID.IsIntegerValue() ) + // Read the text in the element "value" + //LDOM_Text aListItemTxt = (const LDOM_Text&)aListItemValue.getFirstChild(); + LDOM_Node aNode = aListItemValue.getFirstChild(); + const LDOM_Text& aText = (const LDOM_Text&) aNode; + LDOM_Text aListItemTxt(aText); + if ( !aListItemTxt.isNull() ) { - // Read the text in the element "value" - LDOM_Text aListItemTxt = (const LDOM_Text&)aListItemValue.getFirstChild(); - if ( !aListItemTxt.isNull() ) - { - // adding ID and text value to sequence - aSeqOfValueID.Append( aListValueID.IntegerValue() ); - aSeqOfValue.Append( aListItemTxt.getData() ); - // adding icon file name (optional) to sequence - TCollection_ExtendedString aListValueIcon = aListItemValue.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_VALUEICON" ) ); - aSeqOfValueIconName.Append( aListValueIcon ); - } + // adding ID and text value to sequence + aSeqOfValueID.Append( aListValueID.IntegerValue() ); + aSeqOfValue.Append( aListItemTxt.getData() ); + // adding icon file name (optional) to sequence + TCollection_ExtendedString aListValueIcon = aListItemValue.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_VALUEICON" ) ); + aSeqOfValueIconName.Append( aListValueIcon ); } aListItemValue = aListItemValue.GetSiblingByTagName(); } @@ -506,7 +798,10 @@ void DDS_DicItem::FillDataMap( TCollection_AsciiString theID, const LDOM_Element if ( !aShDescr.isNull() ) { // text is always a sub-node of element, containing it - LDOM_Text aShDescrTxt = (const LDOM_Text&)aShDescr.getFirstChild(); + //LDOM_Text aShDescrTxt = (const LDOM_Text&)aShDescr.getFirstChild(); + LDOM_Node aNode = aShDescr.getFirstChild(); + const LDOM_Text& aText = (const LDOM_Text&) aNode; + LDOM_Text aShDescrTxt(aText); if ( !aShDescrTxt.isNull() ) aShortD = aShDescrTxt.getData(); } @@ -516,12 +811,60 @@ void DDS_DicItem::FillDataMap( TCollection_AsciiString theID, const LDOM_Element if ( !aLDescr.isNull() ) { // text is always a sub-node of element, containing it - LDOM_Text aLDescrTxt = (const LDOM_Text&)aLDescr.getFirstChild(); + //LDOM_Text aLDescrTxt = (const LDOM_Text&)aLDescr.getFirstChild(); + LDOM_Node aNode = aLDescr.getFirstChild(); + const LDOM_Text& aText = (const LDOM_Text&) aNode; + LDOM_Text aLDescrTxt(aText); if ( !aLDescrTxt.isNull() ) aLongD = aLDescrTxt.getData(); } } + // Quantity::Options + LDOM_Element anOpt = theDatum.GetChildByTagName( DDS_Dictionary::KeyWord( "OPTIONS" ) ); + if ( !anOpt.isNull() ) + { + LDOM_NodeList anOptions = anOpt.GetAttributesList();//anOpt.getElementsByTagName( DDS_Dictionary::KeyWord( "OPTION" ) ); + for ( Standard_Integer oi = 0; oi < anOptions.getLength(); oi++ ) + { + LDOM_Node node = anOptions.item( oi ); + LDOM_Node::NodeType t = node.getNodeType(); + + TCollection_AsciiString name; + TCollection_ExtendedString value; + + if( t==LDOM_Node::ELEMENT_NODE ) + { + const LDOM_Element& elem = ( const LDOM_Element& )node; + name = elem.getAttribute( DDS_Dictionary::KeyWord( "OPTION_NAME" ) ); + + const LDOM_Node aNode = elem.getFirstChild(); + LDOM_Text anOptTxt( (const LDOM_Text&)(aNode) ); + if ( !anOptTxt.isNull() ) + value = anOptTxt.getData(); + } + else if( t==LDOM_Node::ATTRIBUTE_NODE ) + { + const LDOM_Attr& attr = ( const LDOM_Attr& )node; + name = ( Standard_CString )attr.getName().GetString(); + LDOMString v = attr.getValue(); + if( v.Type()==LDOMBasicString::LDOM_Integer ) + { + Standard_Integer ival; + v.GetInteger( ival ); + value = TCollection_ExtendedString( ival ); + } + else + value = ( Standard_CString )v.GetString(); + } + else + continue; + + if ( !name.IsEmpty() && value.Length() && !myOptions.IsBound( name ) ) + myOptions.Bind( name, value ); + } + } + NCollection_DataMap aDimMap; for ( NCollection_DataMap::Iterator it( myUnitData ); it.More(); it.Next() ) @@ -546,7 +889,7 @@ void DDS_DicItem::FillDataMap( TCollection_AsciiString theID, const LDOM_Element else if ( anUnitData.myUnits.ToCString()[0] ) // treat '%' as unit with scale 100 anUnitData.myScale = 0.01; } - catch( Standard_Failure ) { + catch( Standard_Failure& ) { anUnitData.myUnits.Clear(); } @@ -565,7 +908,7 @@ void DDS_DicItem::FillDataMap( TCollection_AsciiString theID, const LDOM_Element } if ( !aStatus ) - printf( "Error in DataDictionary: Different dimensions for %s item", theID ); + printf( "Error in DataDictionary: Different dimensions for %s item", theID.ToCString() ); } myId = theID; @@ -607,7 +950,7 @@ void DDS_DicItem::FillDataMap( TCollection_AsciiString theID, const LDOM_Element } /*! - Returns default formats for each unit systems + \brief Restore default formats for all the units systems. */ void DDS_DicItem::GetDefaultFormat() { @@ -632,7 +975,12 @@ void DDS_DicItem::GetDefaultFormat() } /*! - Returns format for the string + \brief Get format for the string. + \param theFlags format flags + \param theWidth field width + \param thePrecision precision + \param theTypePrefix type prefix + \param theFormat returning format string */ void DDS_DicItem::GetStringFormat( const TCollection_AsciiString& theFlags, const TCollection_AsciiString& theWidth, @@ -655,7 +1003,13 @@ void DDS_DicItem::GetStringFormat( const TCollection_AsciiString& theFlags, } /*! - Returns format for the integer + \brief Get format for the integer. + \param theFlags format flags + \param theWidth field width + \param thePrecision precision + \param theTypePrefix type prefix + \param theType integer value type + \param theFormat returning format string */ void DDS_DicItem::GetIntegerFormat( const TCollection_AsciiString& theFlags, const TCollection_AsciiString& theWidth, @@ -693,7 +1047,13 @@ void DDS_DicItem::GetIntegerFormat( const TCollection_AsciiString& theFlags, } /*! - Returns format for the float + \brief Returns format for the float. + \param theFlags format flags + \param theWidth field width + \param thePrecision precision + \param theTypePrefix type prefix + \param theType floating point value type + \param theFormat returning format string */ void DDS_DicItem::GetFloatFormat( const TCollection_AsciiString& theFlags, const TCollection_AsciiString& theWidth, @@ -739,9 +1099,10 @@ void DDS_DicItem::GetFloatFormat( const TCollection_AsciiString& theFlags, } /*! - Prepares three formants for each unit systems + \brief Prepare formats for all units systems. + \param theFormat format string */ -void DDS_DicItem::PrepareFormats( const TCollection_AsciiString& theFormat ) +void DDS_DicItem::PrepareFormats( const TCollection_AsciiString& theFormat ) { for ( NCollection_DataMap::Iterator it( myUnitData ); it.More(); it.Next() ) { @@ -861,6 +1222,11 @@ void DDS_DicItem::PrepareFormats( const TCollection_AsciiString& theFormat ) } } +/*! + \brief Split the string \a theStr separated by spaces. + \param theStr source string + \param aRes returning substrings array +*/ void DDS_DicItem::Split( const TCollection_AsciiString& theStr, Handle(TColStd_HArray1OfExtendedString)& aRes ) { aRes.Nullify(); @@ -892,6 +1258,11 @@ void DDS_DicItem::Split( const TCollection_AsciiString& theStr, Handle(TColStd_H } } +/*! + \brief Get units structure for specified units system \a sys. + \param sys units system + \return units system information structure +*/ DDS_DicItem::UnitData* DDS_DicItem::GetUnitData( const UnitSystem& sys ) const { UnitData* unit = 0; @@ -902,6 +1273,10 @@ DDS_DicItem::UnitData* DDS_DicItem::GetUnitData( const UnitSystem& sys ) const return unit; } +/*! + \brief Get the active units system. + \return active units system +*/ DDS_DicItem::UnitSystem DDS_DicItem::GetActiveUnitSystem() const { UnitSystem aSystem; @@ -910,3 +1285,188 @@ DDS_DicItem::UnitSystem DDS_DicItem::GetActiveUnitSystem() const 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; +}