Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 09:16:42

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 <TCollection_HAsciiString.hxx>
0024 #include <NCollection_Sequence.hxx>
0025 #include <NCollection_HSequence.hxx>
0026 #include <Standard_Transient.hxx>
0027 class Interface_TypedValue;
0028 class Interface_InterfaceModel;
0029 class TCollection_HAsciiString;
0030 
0031 //! A ListEditor is an auxiliary operator for Editor/EditForm
0032 //! I.E. it works on parameter values expressed as strings
0033 //!
0034 //! For a parameter which is a list, it may not be edited in once
0035 //! by just setting a new value (as a string)
0036 //!
0037 //! Firstly, a list can be long (and tedious to be accessed flat)
0038 //! then requires a better way of accessing
0039 //!
0040 //! Moreover, not only its VALUES may be changed (SetValue), but
0041 //! also its LENGTH : items may be added or removed ...
0042 //!
0043 //! Hence, the way of editing a parameter as a list is :
0044 //! - edit it separately, with the help of a ListEditor
0045 //! - it remains possible to prepare a new list of values apart
0046 //! - then give the new list in once to the EditForm
0047 //!
0048 //! An EditList is produced by the Editor, with a basic definition
0049 //! This definition (brought by this class) can be redefined
0050 //! Hence the Editor may produce a specific ListEditor as needed
0051 class IFSelect_ListEditor : public Standard_Transient
0052 {
0053 
0054 public:
0055   //! Creates a ListEditor with absolutely no constraint
0056   Standard_EXPORT IFSelect_ListEditor();
0057 
0058   //! Creates a ListEditor, for which items of the list to edit are
0059   //! defined by <def>, and <max> describes max length :
0060   //! 0 (D) means no limit
0061   //! value > 0 means : no more the <max> items are allowed
0062   Standard_EXPORT IFSelect_ListEditor(const occ::handle<Interface_TypedValue>& def,
0063                                       const int                                max = 0);
0064 
0065   //! Loads a Model. It is used to check items of type Entity(Ident)
0066   Standard_EXPORT void LoadModel(const occ::handle<Interface_InterfaceModel>& model);
0067 
0068   //! Loads the original values for the list.
0069   //! Remark : If its length is more then MaxLength, editions remain allowed, except Add
0070   Standard_EXPORT void LoadValues(
0071     const occ::handle<NCollection_HSequence<occ::handle<TCollection_HAsciiString>>>& vals);
0072 
0073   //! Declares this ListEditor to have been touched (whatever action)
0074   Standard_EXPORT void SetTouched();
0075 
0076   //! Clears all editions already recorded
0077   Standard_EXPORT void ClearEdit();
0078 
0079   //! Loads a new list to replace the older one, in once !
0080   //! By default (can be redefined) checks the length of the list
0081   //! and the value of each item according to the def
0082   //! Items are all recorded as Modified
0083   //!
0084   //! If no def has been given at creation time, no check is done
0085   //! Returns True when done, False if checks have failed ... a
0086   //! specialisation may also lock it by returning always False ...
0087   Standard_EXPORT virtual bool LoadEdited(
0088     const occ::handle<NCollection_HSequence<occ::handle<TCollection_HAsciiString>>>& 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 bool SetValue(const int                                    num,
0096                                         const occ::handle<TCollection_HAsciiString>& val);
0097 
0098   //! Adds a new item. By default appends (at the end of the list)
0099   //! Can insert before a given rank <num>, if positive
0100   //! Returns True when done. False if MaxLength may be overpassed
0101   //! or if <val> does not satisfy the definition
0102   Standard_EXPORT virtual bool AddValue(const occ::handle<TCollection_HAsciiString>& val,
0103                                         const int                                    atnum = 0);
0104 
0105   //! Removes items from the list
0106   //! By default removes one item. Else, count given by <howmany>
0107   //! Remove from rank <num> included. By default, from the end
0108   //! Returns True when done, False (and does not work) if case of
0109   //! out of range of if <howmany> is greater than current length
0110   Standard_EXPORT virtual bool Remove(const int num = 0, const int howmany = 1);
0111 
0112   //! Returns the value from which the edition started
0113   Standard_EXPORT occ::handle<NCollection_HSequence<occ::handle<TCollection_HAsciiString>>>
0114                   OriginalValues() const;
0115 
0116   //! Returns the result of the edition
0117   Standard_EXPORT occ::handle<NCollection_HSequence<occ::handle<TCollection_HAsciiString>>>
0118                   EditedValues() const;
0119 
0120   //! Returns count of values, edited (D) or original
0121   Standard_EXPORT int NbValues(const bool edited = true) const;
0122 
0123   //! Returns a value given its rank. Edited (D) or Original
0124   //! A Null String means the value is cleared but not removed
0125   Standard_EXPORT occ::handle<TCollection_HAsciiString> Value(const int  num,
0126                                                               const bool edited = true) const;
0127 
0128   //! Tells if a value (in edited list) has been changed, i.e.
0129   //! either modified-value, or added
0130   Standard_EXPORT bool IsChanged(const int num) const;
0131 
0132   //! Tells if a value (in edited list) has been modified-value
0133   //! (not added)
0134   Standard_EXPORT bool IsModified(const int num) const;
0135 
0136   //! Tells if a value (in edited list) has been added (new one)
0137   Standard_EXPORT bool IsAdded(const int num) const;
0138 
0139   //! Tells if at least one edition (SetValue-AddValue-Remove) has
0140   //! been recorded
0141   Standard_EXPORT bool IsTouched() const;
0142 
0143   DEFINE_STANDARD_RTTIEXT(IFSelect_ListEditor, Standard_Transient)
0144 
0145 private:
0146   int                                                                       themax;
0147   occ::handle<Interface_TypedValue>                                         thedef;
0148   int                                                                       thetouc;
0149   occ::handle<NCollection_HSequence<occ::handle<TCollection_HAsciiString>>> theorig;
0150   occ::handle<NCollection_HSequence<occ::handle<TCollection_HAsciiString>>> theedit;
0151   occ::handle<NCollection_HSequence<int>>                                   thestat;
0152   occ::handle<Interface_InterfaceModel>                                     themodl;
0153 };
0154 
0155 #endif // _IFSelect_ListEditor_HeaderFile