return ( myData & flag ) == flag;
}
+/*!
+ Returns options for specified name \aname. If option not found then empty string returned.
+*/
+TCollection_ExtendedString DDS_DicItem::GetOption( const TCollection_AsciiString& name ) const
+{
+ TCollection_ExtendedString res;
+ if ( myOptions.IsBound( name ) )
+ res = myOptions.Find( name );
+ return res;
+}
+
+/*!
+ Returns names list of existing options in the specified sequence \anames.
+ If list not empty retunrs 'true' otherwise 'false'.
+*/
+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();
+}
+
+
/*!
Parse record in XML file and retrieve information relevant for this dictionary item
*/
}
}
+ // Quantity::Options
+ LDOM_Element anOpt = theDatum.GetChildByTagName( DDS_Dictionary::KeyWord( "OPTIONS" ) );
+ if ( !anOpt.isNull() )
+ {
+ LDOM_NodeList anOptions = anOpt.getElementsByTagName( DDS_Dictionary::KeyWord( "OPTION" ) );
+ for ( Standard_Integer oi = 0; oi < anOptions.getLength(); oi++ )
+ {
+ LDOM_Node node = anOptions.item( oi );
+ if ( node.getNodeType() != LDOM_Node::ELEMENT_NODE )
+ continue;
+
+ LDOM_Element& elem = (LDOM_Element&)node;
+ TCollection_AsciiString name = elem.getAttribute( DDS_Dictionary::KeyWord( "OPTION_NAME" ) );
+
+ TCollection_ExtendedString value;
+ const LDOM_Text& aText = (const LDOM_Text&)elem.getFirstChild();
+ LDOM_Text anOptTxt( aText );
+ if ( !anOptTxt.isNull() )
+ value = anOptTxt.getData();
+
+ if ( !name.IsEmpty() && value.Length() && !myOptions.IsBound( name ) )
+ myOptions.Bind( name, value );
+ }
+ }
+
NCollection_DataMap<UnitSystem, Handle(Units_Dimensions)> aDimMap;
for ( NCollection_DataMap<UnitSystem, UnitData>::Iterator it( myUnitData ); it.More(); it.Next() )
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 Standard_Real ToSI( const Standard_Real ) const;
+ Standard_EXPORT 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 Standard_Real ToSI( const Standard_Real, const UnitSystem& ) const;
+ Standard_EXPORT Standard_Real FromSI( const Standard_Real, const UnitSystem& ) 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;
+
private:
DDS_DicItem( const DDS_DicItem& );
void operator=( const DDS_DicItem& );
UnitData* GetUnitData( const UnitSystem& ) const;
+private:
+ typedef NCollection_DataMap<TCollection_AsciiString, TCollection_ExtendedString> OptionsMap;
+
private:
TCollection_AsciiString myId;
TCollection_ExtendedString myLabel;
Handle(Standard_Transient) myComponent;
+ OptionsMap myOptions;
// unitData
NCollection_DataMap<UnitSystem, UnitData> myUnitData;
<SHORT_D>[brief_desription_text]</SHORT_D>
<LONG_D>[full_description_text]</LONG_D>
</DESCR>
+ <OPTIONS>
+ <OPTION OPTION_NAME="[option_name_1]">[option_value_1]</OPTION>
+ <OPTION OPTION_NAME="[option_name_2]">[option_value_2]</OPTION>
+ ...
+ <OPTION OPTION_NAME="[option_name_n]">[option_value_n]</OPTION>
+ </OPTIONS>
</DATUM>
...
Tag "description" (key DESCR) can be defined under the tag "datum". This tag contains two sub tags:
\lo "short description" (key SHORT_D) specify a brief datum description text
\lo "long description" (key LONG_D) specify a detailed description text
-
+
+ Tag "options" (key OPTIONS) can be defined under the tag "datum". This tag contains one or more sub
+ tags "option" (key OPTION). Each of these XML elements should contain text option value and attribute
+ "name" (key OPTION_NAME) which specified option name.
+
Each tag "datum" define most common parameters of phisical characteristic.
This parameters placed in two groups:
\lo Domain parameters under tag "domain" (key DY_DOMAIN). This tag can contains value description tag
\li LZ_MINV - min
\li LZ_MAXV - max
\li LZ_ORDER - order
+ \li OPTIONS - options
+ \li OPTION - option
+ \li OPTION_NAME - name
*/
/*!
SetKeyWord( "LZ_MINV", "min" );
SetKeyWord( "LZ_MAXV", "max" );
SetKeyWord( "LZ_ORDER", "order" );
+
+ SetKeyWord( "OPTIONS", "options" );
+ SetKeyWord( "OPTION", "option" );
+ SetKeyWord( "OPTION_NAME", "name" );
}
/*!
#include <qvalidator.h>
#include <qmessagebox.h>
+#include <TColStd_SequenceOfAsciiString.hxx>
+
/*!
class: QDS_Datum::Wrapper
descr: Wrapper widget for sub widgets. [internal]
return sdStr;
}
+/*!
+ Returns the list of option names.
+*/
+QStringList QDS_Datum::options() const
+{
+ QStringList res;
+ if ( !dicItem().IsNull() )
+ {
+ TColStd_SequenceOfAsciiString lst;
+ dicItem()->GetOptionNames( lst );
+ for ( int i = 1; i <= lst.Length(); i++ )
+ res.append( toQString( lst.Value( i ) ) );
+ }
+ return res;
+}
+
+/*!
+ Returns the option specified by \aname as QVariant.
+ If option not exist then not valid QVariant returned.
+*/
+QVariant QDS_Datum::option( const QString& name ) const
+{
+ QVariant res;
+ if ( !dicItem().IsNull() )
+ res = QVariant( toQString( dicItem()->GetOption( toAsciiString( name ) ) ) );
+ return res;
+}
+
+/*!
+ Returns the option specified by \aname as QString.
+ If option not exist then empty string returned.
+*/
+QString QDS_Datum::optionString( const QString& name ) const
+{
+ QString res;
+ if ( !dicItem().IsNull() )
+ res = toQString( dicItem()->GetOption( toAsciiString( name ) ) );
+ return res;
+}
+
+/*!
+ Returns the option specified by \aname as double.
+ If option not exist then 0 returned.
+*/
+double QDS_Datum::optionDouble( const QString& name ) const
+{
+ double res = 0;
+ QVariant opt = option( name );
+ if ( opt.isValid() && opt.canCast( QVariant::Double ) )
+ res = opt.toDouble();
+ return res;
+}
+
+/*!
+ Returns the option specified by \aname as integer.
+ If option not exist then 0 returned.
+*/
+int QDS_Datum::optionInteger( const QString& name ) const
+{
+ int res = 0;
+ QVariant opt = option( name );
+ if ( opt.isValid() && opt.canCast( QVariant::Int ) )
+ res = opt.toInt();
+ return res;
+}
+
/*!
Returns the datum value as variant (QVariant object).
*/
QString minimumValue() const;
QString maximumValue() const;
+ QStringList options() const;
+ QVariant option( const QString& ) const;
+ QString optionString( const QString& ) const;
+ double optionDouble( const QString& ) const;
+ int optionInteger( const QString& ) const;
+
virtual QVariant value() const;
virtual QString stringValue() const;