Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-28 09:20:26

0001 // Created on: 1998-02-23
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_Editor_HeaderFile
0018 #define _IFSelect_Editor_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Standard_Integer.hxx>
0024 #include <Standard_Transient.hxx>
0025 #include <NCollection_Array1.hxx>
0026 #include <TCollection_AsciiString.hxx>
0027 #include <IFSelect_EditValue.hxx>
0028 #include <TCollection_HAsciiString.hxx>
0029 #include <NCollection_Sequence.hxx>
0030 #include <NCollection_HSequence.hxx>
0031 #include <NCollection_DataMap.hxx>
0032 class Interface_TypedValue;
0033 class IFSelect_EditForm;
0034 class TCollection_HAsciiString;
0035 class IFSelect_ListEditor;
0036 class Interface_InterfaceModel;
0037 
0038 //! An Editor defines a set of values and a way to edit them, on
0039 //! an entity or on the model (e.g. on its header)
0040 //!
0041 //! Each Value is controlled by a TypedValue, with a number (it is
0042 //! an Integer) and a name under two forms (complete and short)
0043 //! and an edit mode
0044 class IFSelect_Editor : public Standard_Transient
0045 {
0046 
0047 public:
0048   //! Sets a Typed Value for a given ident and short name, with an
0049   //! Edit Mode
0050   Standard_EXPORT void SetValue(const int                                num,
0051                                 const occ::handle<Interface_TypedValue>& typval,
0052                                 const char* const                        shortname = "",
0053                                 const IFSelect_EditValue accessmode = IFSelect_Editable);
0054 
0055   //! Sets a parameter to be a List
0056   //! max < 0 : not for a list (set when starting)
0057   //! max = 0 : list with no length limit (default for SetList)
0058   //! max > 0 : list limited to <max> items
0059   Standard_EXPORT void SetList(const int num, const int max = 0);
0060 
0061   //! Returns the count of Typed Values
0062   Standard_EXPORT int NbValues() const;
0063 
0064   //! Returns a Typed Value from its ident
0065   Standard_EXPORT occ::handle<Interface_TypedValue> TypedValue(const int num) const;
0066 
0067   //! Tells if a parameter is a list
0068   Standard_EXPORT bool IsList(const int num) const;
0069 
0070   //! Returns max length allowed for a list
0071   //! = 0 means : list with no limit
0072   //! < 0 means : not a list
0073   Standard_EXPORT int MaxList(const int num) const;
0074 
0075   //! Returns the name of a Value (complete or short) from its ident
0076   //! Short Name can be empty
0077   Standard_EXPORT const char* Name(const int num, const bool isshort = false) const;
0078 
0079   //! Returns the edit mode of a Value
0080   Standard_EXPORT IFSelect_EditValue EditMode(const int num) const;
0081 
0082   //! Returns the number (ident) of a Value, from its name, short or
0083   //! complete. If not found, returns 0
0084   Standard_EXPORT int NameNumber(const char* const name) const;
0085 
0086   Standard_EXPORT void PrintNames(Standard_OStream& S) const;
0087 
0088   Standard_EXPORT void PrintDefs(Standard_OStream& S, const bool labels = false) const;
0089 
0090   //! Returns the MaxLength of, according to what :
0091   //! <what> = -1 : length of short names
0092   //! <what> =  0 : length of complete names
0093   //! <what> =  1 : length of values labels
0094   Standard_EXPORT int MaxNameLength(const int what) const;
0095 
0096   //! Returns the specific label
0097   Standard_EXPORT virtual TCollection_AsciiString Label() const = 0;
0098 
0099   //! Builds and Returns an EditForm, empty (no data yet)
0100   //! Can be redefined to return a specific type of EditForm
0101   Standard_EXPORT virtual occ::handle<IFSelect_EditForm> Form(const bool readonly,
0102                                                               const bool undoable = true) const;
0103 
0104   //! Tells if this Editor can work on this EditForm and its content
0105   //! (model, entity ?)
0106   Standard_EXPORT virtual bool Recognize(const occ::handle<IFSelect_EditForm>& form) const = 0;
0107 
0108   //! Returns the value of an EditForm, for a given item
0109   //! (if not a list. for a list, a Null String may be returned)
0110   Standard_EXPORT virtual occ::handle<TCollection_HAsciiString> StringValue(
0111     const occ::handle<IFSelect_EditForm>& form,
0112     const int                             num) const = 0;
0113 
0114   //! Returns a ListEditor for a parameter which is a List
0115   //! Default returns a basic ListEditor for a List, a Null Handle
0116   //! if <num> is not for a List. Can be redefined
0117   Standard_EXPORT virtual occ::handle<IFSelect_ListEditor> ListEditor(const int num) const;
0118 
0119   //! Returns the value of an EditForm as a List, for a given item
0120   //! If not a list, a Null Handle should be returned
0121   //! Default returns a Null Handle, because many Editors have
0122   //! no list to edit. To be redefined as required
0123   Standard_EXPORT virtual occ::handle<NCollection_HSequence<occ::handle<TCollection_HAsciiString>>>
0124     ListValue(const occ::handle<IFSelect_EditForm>& form, const int num) const;
0125 
0126   //! Loads original values from some data, to an EditForm
0127   //! Remark: <ent> may be Null, this means all <model> is concerned
0128   //! Also <model> may be Null, if no context applies for <ent>
0129   //! And both <ent> and <model> may be Null, for a full static
0130   //! editor
0131   Standard_EXPORT virtual bool Load(const occ::handle<IFSelect_EditForm>&        form,
0132                                     const occ::handle<Standard_Transient>&       ent,
0133                                     const occ::handle<Interface_InterfaceModel>& model) const = 0;
0134 
0135   //! Updates the EditForm when a parameter is modified
0136   //! I.E.  default does nothing, can be redefined, as follows :
0137   //! Returns True when done (even if does nothing), False in case
0138   //! of refuse (for instance, if the new value is not suitable)
0139   //! <num> is the rank of the parameter for the EDITOR itself
0140   //! <enforce> True means that protected parameters can be touched
0141   //!
0142   //! If a parameter commands the value of other ones, when it is
0143   //! modified, it is necessary to touch them by Touch from EditForm
0144   Standard_EXPORT virtual bool Update(const occ::handle<IFSelect_EditForm>&        form,
0145                                       const int                                    num,
0146                                       const occ::handle<TCollection_HAsciiString>& newval,
0147                                       const bool                                   enforce) const;
0148 
0149   //! Acts as Update, but when the value is a list
0150   Standard_EXPORT virtual bool UpdateList(
0151     const occ::handle<IFSelect_EditForm>&                                            form,
0152     const int                                                                        num,
0153     const occ::handle<NCollection_HSequence<occ::handle<TCollection_HAsciiString>>>& newlist,
0154     const bool                                                                       enforce) const;
0155 
0156   //! Applies modified values of the EditForm with some data
0157   //! Remark: <ent> may be Null, this means all <model> is concerned
0158   //! Also <model> may be Null, if no context applies for <ent>
0159   //! And both <ent> and <model> may be Null, for a full static
0160   //! editor
0161   Standard_EXPORT virtual bool Apply(const occ::handle<IFSelect_EditForm>&        form,
0162                                      const occ::handle<Standard_Transient>&       ent,
0163                                      const occ::handle<Interface_InterfaceModel>& model) const = 0;
0164 
0165   DEFINE_STANDARD_RTTIEXT(IFSelect_Editor, Standard_Transient)
0166 
0167 protected:
0168   //! Prepares the list of Typed Values (gives its count)
0169   //! This count can be tuned later, to a LOWER value, this allows
0170   //! to initialize with a "maximum reservation" then cut the extra
0171   Standard_EXPORT IFSelect_Editor(const int nbval);
0172 
0173   //! Adjusts the true count of values. It can be LOWER or equal to
0174   //! the initial size (which then acts as a reservation), but never
0175   //! greater
0176   Standard_EXPORT void SetNbValues(const int nbval);
0177 
0178 private:
0179   int                                                 thenbval;
0180   int                                                 themaxsh;
0181   int                                                 themaxco;
0182   int                                                 themaxla;
0183   NCollection_DataMap<TCollection_AsciiString, int>   thenames;
0184   NCollection_Array1<occ::handle<Standard_Transient>> thevalues;
0185   NCollection_Array1<TCollection_AsciiString>         theshorts;
0186   NCollection_Array1<int>                             themodes;
0187   NCollection_Array1<int>                             thelists;
0188 };
0189 
0190 #endif // _IFSelect_Editor_HeaderFile