]> SALOME platform Git repositories - modules/gui.git/blob - src/DDS/DDS_DicItem.h
Salome HOME
97091efb67c353892b22f3ee7da6e5b8070f0113
[modules/gui.git] / src / DDS / DDS_DicItem.h
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef DDS_DICITEM_H
24 #define DDS_DICITEM_H
25
26 #include "DDS.h"
27
28 #include <MMgt_TShared.hxx>
29
30 #include <TCollection_AsciiString.hxx>
31
32 #include <TColStd_HArray1OfInteger.hxx>
33 #include <TColStd_HArray1OfExtendedString.hxx>
34
35 #include <NCollection_DataMap.hxx>
36 #include <NCollection_DefineIndexedDataMap.hxx>
37
38 class LDOM_Element;
39 class DDS_Dictionary;
40 class TColStd_MapOfReal;
41 class TColStd_SequenceOfInteger;
42 class TColStd_SequenceOfAsciiString;
43 class TColStd_SequenceOfExtendedString;
44
45 //  Class, containing all information about one parameter:
46 //  unique    : id
47 //  obligative: label, type, short description, required
48 //  optional  : format, units,
49 //              min value, max value, default value.
50
51 class DDS_DicItem : public MMgt_TShared
52 {
53 public:
54   /*! Enum describes type of datum value */
55   enum Type
56   {
57     String,  //!< String type of value
58     Float,   //!< Real (double) numeric type of value
59     Integer, //!< Integer (int) numeric type of value
60     List,    //!< List type of enumerable value
61     Unknown  //!< Unknown or undefined type of value
62   };
63
64   /*! Enum describes the flags for existance of domain data */
65   enum Data
66   {
67     MinValue = 0x01,    //!< Flag of minimum value definition existence
68     MaxValue = 0x02,    //!< Flag of maximum value definition existence
69     DefaultValue = 0x04 //!< Flag of default value definition existence
70   };
71
72   // This struct is intended for map of Format, Units, Precision and Scale
73   struct UnitData
74   {
75     Standard_Real           myZero;
76     Standard_Real           myScale;
77     TCollection_AsciiString myUnits;
78     TCollection_AsciiString myFormat;
79     Standard_Integer        myPrecision;
80   };
81
82   typedef TCollection_AsciiString UnitSystem;
83
84 public:
85   Standard_EXPORT DDS_DicItem();
86
87   Standard_EXPORT TCollection_AsciiString            GetId() const;
88   Standard_EXPORT DDS_DicItem::Type                  GetType() const;
89   Standard_EXPORT TCollection_ExtendedString         GetLabel() const;
90   Standard_EXPORT TCollection_ExtendedString         GetFilter() const;
91   Standard_EXPORT TCollection_ExtendedString         GetRequired() const;
92   Standard_EXPORT DDS_MsgType                        GetWarningLevel() const;
93   Standard_EXPORT TCollection_ExtendedString         GetLongDescription() const;
94   Standard_EXPORT TCollection_ExtendedString         GetShortDescription() const;
95   Standard_EXPORT TCollection_AsciiString            GetComponent() const;
96
97   Standard_EXPORT virtual TCollection_AsciiString    GetUnits() const;
98   Standard_EXPORT virtual TCollection_AsciiString    GetUnits( const UnitSystem& ) const;
99
100   Standard_EXPORT TCollection_ExtendedString         GetDefaultValue() const;
101   Standard_EXPORT TCollection_ExtendedString         GetDefaultValue( const UnitSystem& ) const;
102
103   Standard_EXPORT Standard_Real                      GetMinValue() const;
104   Standard_EXPORT Standard_Real                      GetMinValue( const UnitSystem& ) const;
105
106   Standard_EXPORT Standard_Real                      GetMaxValue() const;
107   Standard_EXPORT Standard_Real                      GetMaxValue( const UnitSystem& ) const;
108
109   Standard_EXPORT virtual Standard_Integer           GetPrecision() const;
110   Standard_EXPORT virtual Standard_Integer           GetPrecision( const UnitSystem& ) const;
111
112   Standard_EXPORT virtual TCollection_AsciiString    GetFormat( const Standard_Boolean = Standard_True ) const;
113   Standard_EXPORT virtual TCollection_AsciiString    GetFormat( const UnitSystem&,
114                                                                 const Standard_Boolean = Standard_True ) const;
115   Standard_EXPORT TCollection_ExtendedString         GetNameOfValues() const;
116   Standard_EXPORT Standard_Boolean                   GetListOfValues( Handle(TColStd_HArray1OfExtendedString)&,
117                                                                       Handle(TColStd_HArray1OfInteger)& ) const;
118   Standard_EXPORT Standard_Boolean                   GetListOfValues( Handle(TColStd_HArray1OfExtendedString)&,
119                                                                       Handle(TColStd_HArray1OfInteger)&,
120                                                                       Handle(TColStd_HArray1OfExtendedString)& ) const;
121   Standard_EXPORT Standard_Boolean                   GetSpecialValues( TColStd_MapOfReal& ) const;
122
123   Standard_EXPORT Standard_Real                      GetMinZoom() const;
124   Standard_EXPORT Standard_Real                      GetMaxZoom() const;
125   Standard_EXPORT Standard_Real                      GetZoomOrder() const;
126
127   Standard_EXPORT virtual Standard_Real              ToSI( const Standard_Real ) const;
128   Standard_EXPORT virtual Standard_Real              FromSI( const Standard_Real ) const;
129
130   Standard_EXPORT virtual Standard_Real              ToSI( const Standard_Real, const UnitSystem& ) const;
131   Standard_EXPORT virtual Standard_Real              FromSI( const Standard_Real, const UnitSystem& ) const;
132
133   Standard_EXPORT Standard_Boolean                   HasData( const Standard_Integer ) const;
134
135   Standard_EXPORT TCollection_ExtendedString         GetOption( const TCollection_AsciiString& ) const;
136   Standard_EXPORT Standard_Boolean                   GetOptionNames( TColStd_SequenceOfAsciiString& ) const;
137
138 protected:
139   
140   Standard_EXPORT void                               SetId( const TCollection_AsciiString& );
141
142   Standard_EXPORT void                               SetComponent( const Handle(Standard_Transient)& );
143
144   Standard_EXPORT void                               SetLabel( const TCollection_AsciiString& );
145
146   Standard_EXPORT void                               SetFilter( const TCollection_AsciiString& );
147
148   Standard_EXPORT void                               SetRequired( const TCollection_AsciiString& );
149
150   Standard_EXPORT void                               SetWarningLevel( const Standard_Integer& );
151
152   Standard_EXPORT void                               SetMinZoom( const Standard_Real& );
153   Standard_EXPORT void                               SetMaxZoom( const Standard_Real& );
154   Standard_EXPORT void                               SetZoomOrder( const Standard_Real& );
155
156   Standard_EXPORT void                               SetShortDescription( const TCollection_ExtendedString& );
157   Standard_EXPORT void                               SetLongDescription( const TCollection_ExtendedString& );
158
159   Standard_EXPORT bool                               SetOption( const TCollection_AsciiString&, const TCollection_AsciiString& );
160   Standard_EXPORT void                               SetType( const DDS_DicItem::Type& );
161
162   Standard_EXPORT void                               SetMin( const Standard_Real& );
163   Standard_EXPORT void                               SetMax( const Standard_Real& );
164
165   Standard_EXPORT void                               SetDefaultValue( const Standard_Real& );
166   Standard_EXPORT void                               SetDefaultValue( const TCollection_AsciiString& );
167
168   Standard_EXPORT void                               SetListOfValues( const Handle(TColStd_HArray1OfExtendedString)&,
169                                                                       const Handle(TColStd_HArray1OfInteger)& );
170   Standard_EXPORT void                               SetListOfValues( const Handle(TColStd_HArray1OfExtendedString)&,
171                                                                       const Handle(TColStd_HArray1OfInteger)&,
172                                                                       const Handle(TColStd_HArray1OfExtendedString)& );
173
174 protected:
175
176   Standard_EXPORT DDS_DicItem( const DDS_DicItem& );
177
178   Standard_EXPORT void                               operator=( const DDS_DicItem& );
179
180   Standard_EXPORT virtual void                       FillDataMap( TCollection_AsciiString, const LDOM_Element&,
181                                                                   const LDOM_Element&, const LDOM_Element&,
182                                                                   const TColStd_SequenceOfAsciiString& );
183
184 private:
185
186   Standard_EXPORT void                               PrepareFormats( const TCollection_AsciiString& );
187   Standard_EXPORT void                               GetDefaultFormat();
188   Standard_EXPORT UnitSystem                         GetActiveUnitSystem() const;
189
190   Standard_EXPORT void                               GetStringFormat( const TCollection_AsciiString&,
191                                                                       const TCollection_AsciiString&,
192                                                                       const TCollection_AsciiString&,
193                                                                       const TCollection_AsciiString&,
194                                                                       TCollection_AsciiString& );
195   Standard_EXPORT void                               GetIntegerFormat( const TCollection_AsciiString&,
196                                                                        const TCollection_AsciiString&,
197                                                                        const TCollection_AsciiString&,
198                                                                        const TCollection_AsciiString&,
199                                                                        const Standard_Character,
200                                                                        TCollection_AsciiString& );
201   Standard_EXPORT void                               GetFloatFormat( const TCollection_AsciiString&,
202                                                                       const TCollection_AsciiString&,
203                                                                       const TCollection_AsciiString&,
204                                                                       const TCollection_AsciiString&,
205                                                                       const Standard_Character,
206                                                                       TCollection_AsciiString& );
207   Standard_EXPORT void                               Split( const TCollection_AsciiString&,
208                                                             Handle(TColStd_HArray1OfExtendedString)& );
209
210   Standard_EXPORT UnitData*                          GetUnitData( const UnitSystem& ) const;
211
212 private:
213   typedef NCollection_DataMap<TCollection_AsciiString, TCollection_ExtendedString> OptionsMap;
214
215 private:
216   TCollection_AsciiString                    myId;
217   TCollection_ExtendedString                 myLabel;
218   TCollection_ExtendedString                 myFilter;
219   TCollection_ExtendedString                 myRequired;
220
221   Standard_Integer                           myType;
222   Standard_Integer                           myWarnLevel;
223
224   TCollection_ExtendedString                 myLongDescr;
225   TCollection_ExtendedString                 myShortDescr;
226
227   Standard_Real                              myMax;
228   Standard_Real                              myMin;
229   Standard_Real                              myDefValue;
230   TCollection_ExtendedString                 myDefString;
231
232   Standard_Integer                           myData;
233
234   // valueList
235   TCollection_ExtendedString                 myListName;
236
237   Handle(TColStd_HArray1OfExtendedString)    myListRef;
238   Handle(TColStd_HArray1OfInteger)           myListRefID;
239   Handle(TColStd_HArray1OfExtendedString)    myListRefIcons;
240
241   // presentation
242   Standard_Real                              myMinZoom;
243   Standard_Real                              myMaxZoom;
244   Standard_Real                              myZoomOrder;
245
246   Handle(Standard_Transient)                 myComponent;
247
248   OptionsMap                                 myOptions;
249   // unitData
250   NCollection_DataMap<UnitSystem, UnitData>  myUnitData;
251
252   friend class DDS_DicGroup;
253
254 public:
255   // Declaration of CASCADE RTTI
256   DEFINE_STANDARD_RTTI(DDS_DicItem)
257 };
258
259 DEFINE_STANDARD_HANDLE(DDS_DicItem, MMgt_TShared)
260
261 typedef NCollection_IndexedDataMap<TCollection_AsciiString, Handle(DDS_DicItem)> DDS_IndexedDataMapOfDicItems;
262
263 #endif