Back to index

salome-gui  6.5.0
DDS_DicItem.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #ifndef DDS_DICITEM_H
00024 #define DDS_DICITEM_H
00025 
00026 #include "DDS.h"
00027 
00028 #include <MMgt_TShared.hxx>
00029 
00030 #include <TCollection_AsciiString.hxx>
00031 
00032 #include <TColStd_HArray1OfInteger.hxx>
00033 #include <TColStd_HArray1OfExtendedString.hxx>
00034 
00035 #include <NCollection_DataMap.hxx>
00036 #include <NCollection_DefineIndexedDataMap.hxx>
00037 
00038 class LDOM_Element;
00039 class DDS_Dictionary;
00040 class TColStd_MapOfReal;
00041 class TColStd_SequenceOfInteger;
00042 class TColStd_SequenceOfAsciiString;
00043 class TColStd_SequenceOfExtendedString;
00044 
00045 //  Class, containing all information about one parameter:
00046 //  unique    : id
00047 //  obligative: label, type, short description, required
00048 //  optional  : format, units,
00049 //              min value, max value, default value.
00050 
00051 class DDS_DicItem : public MMgt_TShared
00052 {
00053 public:
00055   enum Type
00056   {
00057     String,  
00058     Float,   
00059     Integer, 
00060     List,    
00061     Unknown  
00062   };
00063 
00065   enum Data
00066   {
00067     MinValue = 0x01,    
00068     MaxValue = 0x02,    
00069     DefaultValue = 0x04 
00070   };
00071 
00072   // This struct is intended for map of Format, Units, Precision and Scale
00073   struct UnitData
00074   {
00075     Standard_Real           myZero;
00076     Standard_Real           myScale;
00077     TCollection_AsciiString myUnits;
00078     TCollection_AsciiString myFormat;
00079     Standard_Integer        myPrecision;
00080   };
00081 
00082   typedef TCollection_AsciiString UnitSystem;
00083 
00084 public:
00085   DDS_DicItem();
00086 
00087   Standard_EXPORT TCollection_AsciiString    GetId() const;
00088   Standard_EXPORT DDS_DicItem::Type          GetType() const;
00089   Standard_EXPORT TCollection_ExtendedString GetLabel() const;
00090   Standard_EXPORT TCollection_ExtendedString GetFilter() const;
00091   Standard_EXPORT TCollection_ExtendedString GetRequired() const;
00092   Standard_EXPORT DDS_MsgType                GetWarningLevel() const;
00093   Standard_EXPORT TCollection_ExtendedString GetLongDescription() const;
00094   Standard_EXPORT TCollection_ExtendedString GetShortDescription() const;
00095   Standard_EXPORT TCollection_AsciiString    GetComponent() const;
00096 
00097   Standard_EXPORT TCollection_AsciiString    GetUnits() const;
00098   Standard_EXPORT TCollection_AsciiString    GetUnits( const UnitSystem& ) const;
00099 
00100   Standard_EXPORT TCollection_ExtendedString GetDefaultValue() const;
00101   Standard_EXPORT TCollection_ExtendedString GetDefaultValue( const UnitSystem& ) const;
00102 
00103   Standard_EXPORT Standard_Real              GetMinValue() const;
00104   Standard_EXPORT Standard_Real              GetMinValue( const UnitSystem& ) const;
00105 
00106   Standard_EXPORT Standard_Real              GetMaxValue() const;
00107   Standard_EXPORT Standard_Real              GetMaxValue( const UnitSystem& ) const;
00108 
00109   Standard_EXPORT Standard_Integer           GetPrecision() const;
00110   Standard_EXPORT Standard_Integer           GetPrecision( const UnitSystem& ) const;
00111 
00112   Standard_EXPORT TCollection_AsciiString    GetFormat( const Standard_Boolean = Standard_True ) const;
00113   Standard_EXPORT TCollection_AsciiString    GetFormat( const UnitSystem&,
00114                                                         const Standard_Boolean = Standard_True ) const;
00115   Standard_EXPORT TCollection_ExtendedString GetNameOfValues() const;
00116   Standard_EXPORT Standard_Boolean           GetListOfValues( Handle(TColStd_HArray1OfExtendedString)&,
00117                                                               Handle(TColStd_HArray1OfInteger)& ) const;
00118   Standard_EXPORT Standard_Boolean           GetListOfValues( Handle(TColStd_HArray1OfExtendedString)&,
00119                                                               Handle(TColStd_HArray1OfInteger)&,
00120                                                               Handle(TColStd_HArray1OfExtendedString)& ) const;
00121   Standard_EXPORT Standard_Boolean           GetSpecialValues( TColStd_MapOfReal& ) const;
00122 
00123   Standard_EXPORT Standard_Real              GetMinZoom() const;
00124   Standard_EXPORT Standard_Real              GetMaxZoom() const;
00125   Standard_EXPORT Standard_Real              GetZoomOrder() const;
00126 
00127   Standard_EXPORT Standard_Real              ToSI( const Standard_Real ) const;
00128   Standard_EXPORT Standard_Real              FromSI( const Standard_Real ) const;
00129 
00130   Standard_EXPORT Standard_Real              ToSI( const Standard_Real, const UnitSystem& ) const;
00131   Standard_EXPORT Standard_Real              FromSI( const Standard_Real, const UnitSystem& ) const;
00132 
00133   Standard_EXPORT Standard_Boolean           HasData( const Standard_Integer ) const;
00134 
00135   Standard_EXPORT TCollection_ExtendedString GetOption( const TCollection_AsciiString& ) const;
00136   Standard_EXPORT Standard_Boolean           GetOptionNames( TColStd_SequenceOfAsciiString& ) const;
00137 
00138 private:
00139   DDS_DicItem( const DDS_DicItem& );
00140   void                                       operator=( const DDS_DicItem& );
00141   void                                       FillDataMap( TCollection_AsciiString, const LDOM_Element&,
00142                                                           const LDOM_Element&, const LDOM_Element&,
00143                                                           const TColStd_SequenceOfAsciiString& );
00144   void                                       PrepareFormats( const TCollection_AsciiString& );
00145   void                                       GetDefaultFormat();
00146   UnitSystem                                 GetActiveUnitSystem() const;
00147 
00148   void                                       GetStringFormat( const TCollection_AsciiString&,
00149                                                               const TCollection_AsciiString&,
00150                                                               const TCollection_AsciiString&,
00151                                                               const TCollection_AsciiString&,
00152                                                               TCollection_AsciiString& );
00153   void                                       GetIntegerFormat( const TCollection_AsciiString&,
00154                                                                const TCollection_AsciiString&,
00155                                                                const TCollection_AsciiString&,
00156                                                                const TCollection_AsciiString&,
00157                                                                const Standard_Character,
00158                                                                TCollection_AsciiString& );
00159   void                                       GetFloatFormat( const TCollection_AsciiString&,
00160                                                              const TCollection_AsciiString&,
00161                                                              const TCollection_AsciiString&,
00162                                                              const TCollection_AsciiString&,
00163                                                              const Standard_Character,
00164                                                              TCollection_AsciiString& );
00165   void                                       Split( const TCollection_AsciiString&,
00166                                                     Handle(TColStd_HArray1OfExtendedString)& );
00167 
00168   UnitData*                                  GetUnitData( const UnitSystem& ) const;
00169 
00170 private:
00171   typedef NCollection_DataMap<TCollection_AsciiString, TCollection_ExtendedString> OptionsMap;
00172 
00173 private:
00174   TCollection_AsciiString                    myId;
00175   TCollection_ExtendedString                 myLabel;
00176   TCollection_ExtendedString                 myFilter;
00177   TCollection_ExtendedString                 myRequired;
00178 
00179   Standard_Integer                           myType;
00180   Standard_Integer                           myWarnLevel;
00181 
00182   TCollection_ExtendedString                 myLongDescr;
00183   TCollection_ExtendedString                 myShortDescr;
00184 
00185   Standard_Real                              myMax;
00186   Standard_Real                              myMin;
00187   Standard_Real                              myDefValue;
00188   TCollection_ExtendedString                 myDefString;
00189 
00190   Standard_Integer                           myData;
00191 
00192   // valueList
00193   TCollection_ExtendedString                 myListName;
00194 
00195   Handle(TColStd_HArray1OfExtendedString)    myListRef;
00196   Handle(TColStd_HArray1OfInteger)           myListRefID;
00197   Handle(TColStd_HArray1OfExtendedString)    myListRefIcons;
00198 
00199   // presentation
00200   Standard_Real                              myMinZoom;
00201   Standard_Real                              myMaxZoom;
00202   Standard_Real                              myZoomOrder;
00203 
00204   Handle(Standard_Transient)                 myComponent;
00205 
00206   OptionsMap                                 myOptions;
00207   // unitData
00208   NCollection_DataMap<UnitSystem, UnitData>  myUnitData;
00209 
00210   friend class DDS_DicGroup;
00211 
00212 public:
00213   // Declaration of CASCADE RTTI
00214   DEFINE_STANDARD_RTTI(DDS_DicItem)
00215 };
00216 
00217 DEFINE_STANDARD_HANDLE(DDS_DicItem, MMgt_TShared)
00218 
00219 DEFINE_BASECOLLECTION(DDS_BaseCollectionOfDicItems, Handle(DDS_DicItem))
00220 DEFINE_INDEXEDDATAMAP(DDS_IndexedDataMapOfDicItems, DDS_BaseCollectionOfDicItems,
00221                       TCollection_AsciiString, Handle(DDS_DicItem))
00222 
00223 #endif