Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:54

0001 // Created on: 1998-07-28
0002 // Created by: Christian CAILLET
0003 // Copyright (c) 1998-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _IFSelect_ListEditor_HeaderFile
0018 #define _IFSelect_ListEditor_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 
0022 #include <Standard_Integer.hxx>
0023 #include <TColStd_HSequenceOfHAsciiString.hxx>
0024 #include <TColStd_HSequenceOfInteger.hxx>
0025 #include <Standard_Transient.hxx>
0026 class Interface_TypedValue;
0027 class Interface_InterfaceModel;
0028 class TCollection_HAsciiString;
0029 
0030 class IFSelect_ListEditor;
0031 DEFINE_STANDARD_HANDLE(IFSelect_ListEditor, Standard_Transient)
0032 
0033 //! A ListEditor is an auxiliary operator for Editor/EditForm
0034 //! I.E. it works on parameter values expressed as strings
0035 //!
0036 //! For a parameter which is a list, it may not be edited in once
0037 //! by just setting a new value (as a string)
0038 //!
0039 //! Firstly, a list can be long (and tedious to be accessed flat)
0040 //! then requires a better way of accessing
0041 //!
0042 //! Moreover, not only its VALUES may be changed (SetValue), but
0043 //! also its LENGTH : items may be added or removed ...
0044 //!
0045 //! Hence, the way of editing a parameter as a list is :
0046 //! - edit it separately, with the help of a ListEditor
0047 //! - it remains possible to prepare a new list of values apart
0048 //! - then give the new list in once to the EditForm
0049 //!
0050 //! An EditList is produced by the Editor, with a basic definition
0051 //! This definition (brought by this class) can be redefined
0052 //! Hence the Editor may produce a specific ListEditor as needed
0053 class IFSelect_ListEditor : public Standard_Transient
0054 {
0055 
0056 public:
0057 
0058   //! Creates a ListEditor with absolutely no constraint
0059   Standard_EXPORT IFSelect_ListEditor();
0060   
0061   //! Creates a ListEditor, for which items of the list to edit are
0062   //! defined by <def>, and <max> describes max length :
0063   //! 0 (D) means no limit
0064   //! value > 0 means : no more the <max> items are allowed
0065   Standard_EXPORT IFSelect_ListEditor(const Handle(Interface_TypedValue)& def, const Standard_Integer max = 0);
0066   
0067   //! Loads a Model. It is used to check items of type Entity(Ident)
0068   Standard_EXPORT void LoadModel (const Handle(Interface_InterfaceModel)& model);
0069 
0070   //! Loads the original values for the list.
0071   //! Remark : If its length is more then MaxLength, editions remain allowed, except Add
0072   Standard_EXPORT void LoadValues (const Handle(TColStd_HSequenceOfHAsciiString)& vals);
0073 
0074   //! Declares this ListEditor to have been touched (whatever action)
0075   Standard_EXPORT void SetTouched();
0076   
0077   //! Clears all editions already recorded
0078   Standard_EXPORT void ClearEdit();
0079   
0080   //! Loads a new list to replace the older one, in once !
0081   //! By default (can be redefined) checks the length of the list
0082   //! and the value of each item according to the def
0083   //! Items are all recorded as Modified
0084   //!
0085   //! If no def has been given at creation time, no check is done
0086   //! Returns True when done, False if checks have failed ... a
0087   //! specialisation may also lock it by returning always False ...
0088   Standard_EXPORT virtual Standard_Boolean LoadEdited (const Handle(TColStd_HSequenceOfHAsciiString)& list);
0089   
0090   //! Sets a new value for the item <num> (in edited list)
0091   //! <val> may be a Null Handle, then the value will be cleared but
0092   //! not removed
0093   //! Returns True when done. False if <num> is out of range or if
0094   //! <val> does not satisfy the definition
0095   Standard_EXPORT virtual Standard_Boolean SetValue (const Standard_Integer num, const Handle(TCollection_HAsciiString)& val);
0096   
0097   //! Adds a new item. By default appends (at the end of the list)
0098   //! Can insert before a given rank <num>, if positive
0099   //! Returns True when done. False if MaxLength may be overpassed
0100   //! or if <val> does not satisfy the definition
0101   Standard_EXPORT virtual Standard_Boolean AddValue (const Handle(TCollection_HAsciiString)& val, const Standard_Integer atnum = 0);
0102   
0103   //! Removes items from the list
0104   //! By default removes one item. Else, count given by <howmany>
0105   //! Remove from rank <num> included. By default, from the end
0106   //! Returns True when done, False (and does not work) if case of
0107   //! out of range of if <howmany> is greater than current length
0108   Standard_EXPORT virtual Standard_Boolean Remove (const Standard_Integer num = 0, const Standard_Integer howmany = 1);
0109   
0110   //! Returns the value from which the edition started
0111   Standard_EXPORT Handle(TColStd_HSequenceOfHAsciiString) OriginalValues() const;
0112   
0113   //! Returns the result of the edition
0114   Standard_EXPORT Handle(TColStd_HSequenceOfHAsciiString) EditedValues() const;
0115   
0116   //! Returns count of values, edited (D) or original
0117   Standard_EXPORT Standard_Integer NbValues (const Standard_Boolean edited = Standard_True) const;
0118   
0119   //! Returns a value given its rank. Edited (D) or Original
0120   //! A Null String means the value is cleared but not removed
0121   Standard_EXPORT Handle(TCollection_HAsciiString) Value (const Standard_Integer num, const Standard_Boolean edited = Standard_True) const;
0122   
0123   //! Tells if a value (in edited list) has been changed, i.e.
0124   //! either modified-value, or added
0125   Standard_EXPORT Standard_Boolean IsChanged (const Standard_Integer num) const;
0126   
0127   //! Tells if a value (in edited list) has been modified-value
0128   //! (not added)
0129   Standard_EXPORT Standard_Boolean IsModified (const Standard_Integer num) const;
0130   
0131   //! Tells if a value (in edited list) has been added (new one)
0132   Standard_EXPORT Standard_Boolean IsAdded (const Standard_Integer num) const;
0133   
0134   //! Tells if at least one edition (SetValue-AddValue-Remove) has
0135   //! been recorded
0136   Standard_EXPORT Standard_Boolean IsTouched() const;
0137 
0138   DEFINE_STANDARD_RTTIEXT(IFSelect_ListEditor,Standard_Transient)
0139 
0140 private:
0141 
0142   Standard_Integer themax;
0143   Handle(Interface_TypedValue) thedef;
0144   Standard_Integer thetouc;
0145   Handle(TColStd_HSequenceOfHAsciiString) theorig;
0146   Handle(TColStd_HSequenceOfHAsciiString) theedit;
0147   Handle(TColStd_HSequenceOfInteger) thestat;
0148   Handle(Interface_InterfaceModel) themodl;
0149 
0150 };
0151 
0152 #endif // _IFSelect_ListEditor_HeaderFile