Back to home page

EIC code displayed by LXR

 
 

    


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

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