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_EditForm_HeaderFile
0018 #define _IFSelect_EditForm_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 
0022 #include <TColStd_Array1OfInteger.hxx>
0023 #include <TColStd_Array1OfTransient.hxx>
0024 #include <Standard_Integer.hxx>
0025 #include <Standard_Transient.hxx>
0026 #include <TColStd_SequenceOfInteger.hxx>
0027 #include <TColStd_HSequenceOfHAsciiString.hxx>
0028 class IFSelect_Editor;
0029 class Interface_InterfaceModel;
0030 class IFSelect_ListEditor;
0031 class TCollection_HAsciiString;
0032 
0033 class IFSelect_EditForm;
0034 DEFINE_STANDARD_HANDLE(IFSelect_EditForm, Standard_Transient)
0035 
0036 //! An EditForm is the way to apply an Editor on an Entity or on
0037 //! the Model
0038 //! It gives read-only or read-write access, with or without undo
0039 //!
0040 //! It can be complete (all the values of the Editor are present)
0041 //! or partial (a sub-list of these value are present)
0042 //! Anyway, all references to Number (argument <num>) refer to
0043 //! Number of Value for the Editor
0044 //! While references to Rank are for rank in the EditForm, which
0045 //! may differ if it is not Complete
0046 //! Two methods give the correspondence between this Number and
0047 //! the Rank in the EditForm : RankFromNumber and NumberFromRank
0048 class IFSelect_EditForm : public Standard_Transient
0049 {
0050 public:
0051 
0052   //! Creates a complete EditForm from an Editor
0053   //! A specific Label can be given
0054   Standard_EXPORT IFSelect_EditForm(const Handle(IFSelect_Editor)& editor, const Standard_Boolean readonly, const Standard_Boolean undoable, const Standard_CString label = "");
0055   
0056   //! Creates an extracted EditForm from an Editor, limited to
0057   //! the values identified in <nums>
0058   //! A specific Label can be given
0059   Standard_EXPORT IFSelect_EditForm(const Handle(IFSelect_Editor)& editor, const TColStd_SequenceOfInteger& nums, const Standard_Boolean readonly, const Standard_Boolean undoable, const Standard_CString label = "");
0060   
0061   //! Returns and may change the keep status on modif
0062   //! It starts as False
0063   //! If it is True, Apply does not clear modification status
0064   //! and the EditForm can be loaded again, modified value remain
0065   //! and may be applied again
0066   //! Remark that ApplyData does not clear the modification status,
0067   //! a call to ClearEdit does
0068   Standard_EXPORT Standard_Boolean& EditKeepStatus();
0069   
0070   Standard_EXPORT Standard_CString Label() const;
0071   
0072   //! Tells if the EditForm is loaded now
0073   Standard_EXPORT Standard_Boolean IsLoaded() const;
0074   
0075   Standard_EXPORT void ClearData();
0076   
0077   Standard_EXPORT void SetData (const Handle(Standard_Transient)& ent, const Handle(Interface_InterfaceModel)& model);
0078   
0079   Standard_EXPORT void SetEntity (const Handle(Standard_Transient)& ent);
0080   
0081   Standard_EXPORT void SetModel (const Handle(Interface_InterfaceModel)& model);
0082   
0083   Standard_EXPORT Handle(Standard_Transient) Entity() const;
0084   
0085   Standard_EXPORT Handle(Interface_InterfaceModel) Model() const;
0086   
0087   Standard_EXPORT Handle(IFSelect_Editor) Editor() const;
0088   
0089   //! Tells if an EditForm is complete or is an extract from Editor
0090   Standard_EXPORT Standard_Boolean IsComplete() const;
0091   
0092   //! Returns the count of values
0093   //! <editable> True : count of editable values, i.e.
0094   //! For a complete EditForm, it is given by the Editor
0095   //! Else, it is the length of the extraction map
0096   //! <editable> False : all the values from the Editor
0097   Standard_EXPORT Standard_Integer NbValues (const Standard_Boolean editable) const;
0098   
0099   //! Returns the Value Number in the Editor from a given Rank in
0100   //! the EditForm
0101   //! For a complete EditForm, both are equal
0102   //! Else, it is given by the extraction map
0103   //! Returns 0 if <rank> exceeds the count of editable values,
0104   Standard_EXPORT Standard_Integer NumberFromRank (const Standard_Integer rank) const;
0105   
0106   //! Returns the Rank in the EditForm from a given Number of Value
0107   //! for the Editor
0108   //! For a complete EditForm, both are equal
0109   //! Else, it is given by the extraction map
0110   //! Returns 0 if <number> is not forecast to be edited, or is
0111   //! out of range
0112   Standard_EXPORT Standard_Integer RankFromNumber (const Standard_Integer number) const;
0113   
0114   //! Returns the Value Number in the Editor for a given Name
0115   //! i.e. the true ValueNumber which can be used in various methods
0116   //! of EditForm
0117   //! If it is not complete, for a recorded (in the Editor) but
0118   //! non-loaded name, returns negative value (- number)
0119   Standard_EXPORT Standard_Integer NameNumber (const Standard_CString name) const;
0120   
0121   //! Returns the Rank of Value in the EditForm for a given Name
0122   //! i.e. if it is not complete, for a recorded (in the Editor) but
0123   //! non-loaded name, returns 0
0124   Standard_EXPORT Standard_Integer NameRank (const Standard_CString name) const;
0125   
0126   //! For a read-write undoable EditForm, loads original values
0127   //! from defaults stored in the Editor
0128   Standard_EXPORT void LoadDefault();
0129   
0130   //! Loads modifications to data
0131   //! Default uses Editor. Can be redefined
0132   //! Remark that <ent> and/or <model> may be null, according to the
0133   //! kind of Editor. Shortcuts are available for these cases, but
0134   //! they finally call LoadData (hence, just ignore non-used args)
0135   Standard_EXPORT virtual Standard_Boolean LoadData (const Handle(Standard_Transient)& ent, const Handle(Interface_InterfaceModel)& model);
0136   
0137   //! Shortcut for LoadData when <model> is not used
0138   Standard_EXPORT Standard_Boolean LoadEntity (const Handle(Standard_Transient)& ent);
0139   
0140   //! Shortcut for LoadData when only the model is concerned
0141   Standard_EXPORT Standard_Boolean LoadModel (const Handle(Interface_InterfaceModel)& model);
0142   
0143   //! Shortcut when both <ent> and <model> are not used
0144   //! (when the Editor works on fully static or global data)
0145   Standard_EXPORT Standard_Boolean LoadData();
0146   
0147   //! Returns a ListEditor to edit the parameter <num> of the
0148   //! EditForm, if it is a List
0149   //! The Editor created it (by ListEditor) then loads it (by
0150   //! ListValue)
0151   //! For a single parameter, returns a Null Handle ...
0152   Standard_EXPORT Handle(IFSelect_ListEditor) ListEditor (const Standard_Integer num) const;
0153   
0154   //! Loads an original value (single). Called by the Editor only
0155   Standard_EXPORT void LoadValue (const Standard_Integer num, const Handle(TCollection_HAsciiString)& val);
0156   
0157   //! Loads an original value as a list. Called by the Editor only
0158   Standard_EXPORT void LoadList (const Standard_Integer num, const Handle(TColStd_HSequenceOfHAsciiString)& list);
0159   
0160   //! From an edited value, returns its ... value (original one)
0161   //! Null means that this value is not defined
0162   //! <num> is for the EditForm, not the Editor
0163   //! It is for a single parameter. For a list, gives a Null Handle
0164   Standard_EXPORT Handle(TCollection_HAsciiString) OriginalValue (const Standard_Integer num) const;
0165   
0166   //! Returns an original value, as a list
0167   //! <num> is for the EditForm, not the Editor
0168   //! For a single parameter, gives a Null Handle
0169   Standard_EXPORT Handle(TColStd_HSequenceOfHAsciiString) OriginalList (const Standard_Integer num) const;
0170   
0171   //! Returns the Edited (i.e. Modified) Value (string for single)
0172   //! <num> reports to the EditForm
0173   //! If IsModified is False, returns OriginalValue
0174   //! Null with IsModified True : means that this value is not
0175   //! defined or has been removed
0176   //! It is for a single parameter. For a list, gives a Null Handle
0177   Standard_EXPORT Handle(TCollection_HAsciiString) EditedValue (const Standard_Integer num) const;
0178   
0179   //! Returns the Edited Value as a list
0180   //! If IsModified is False, returns OriginalValue
0181   //! Null with IsModified True : means that this value is not
0182   //! defined or has been removed
0183   //! For a single parameter, gives a Null Handle
0184   Standard_EXPORT Handle(TColStd_HSequenceOfHAsciiString) EditedList (const Standard_Integer num) const;
0185   
0186   //! Tells if a Value (of the EditForm) is modified (directly or
0187   //! through touching by Update)
0188   Standard_EXPORT Standard_Boolean IsModified (const Standard_Integer num) const;
0189   
0190   //! Tells if a Value (of the EditForm) has been touched, i.e.
0191   //! not modified directly but by the modification of another one
0192   //! (by method Update from the Editor)
0193   Standard_EXPORT Standard_Boolean IsTouched (const Standard_Integer num) const;
0194   
0195   //! Gives a new value for the item <num> of the EditForm, if
0196   //! it is a single parameter (for a list, just returns False)
0197   //! Null means to Remove it
0198   //! <enforce> True to overpass Protected or Computed Access Mode
0199   //! Calls the method Update from the Editor, which can touch other
0200   //! parameters (see NbTouched)
0201   //! Returns True if well recorded, False if this value is not
0202   //! allowed
0203   //! Warning : Does not apply immediately : will be applied by the method
0204   //! Apply
0205   Standard_EXPORT Standard_Boolean Modify (const Standard_Integer num, const Handle(TCollection_HAsciiString)& newval, const Standard_Boolean enforce = Standard_False);
0206   
0207   //! Changes the value of an item of the EditForm, if it is a List
0208   //! (else, just returns False)
0209   //! The ListEditor contains the edited values of the list
0210   //! If no edition was recorded, just returns False
0211   //! Calls the method Update from the Editor, which can touch other
0212   //! parameters (see NbTouched)
0213   //! Returns True if well recorded, False if this value is not
0214   //! allowed
0215   //! Warning : Does not apply immediately : will be applied by the method
0216   //! Apply
0217   Standard_EXPORT Standard_Boolean ModifyList (const Standard_Integer num, const Handle(IFSelect_ListEditor)& edited, const Standard_Boolean enforce = Standard_False);
0218   
0219   //! As ModifyList but the new value is given as such
0220   //! Creates a ListEditor, Loads it, then calls ModifyList
0221   Standard_EXPORT Standard_Boolean ModifyListValue (const Standard_Integer num, const Handle(TColStd_HSequenceOfHAsciiString)& list, const Standard_Boolean enforce = Standard_False);
0222   
0223   //! Gives a new value computed by the Editor, if another parameter
0224   //! commands the value of <num>
0225   //! It is generally the case for a Computed Parameter for instance
0226   //! Increments the counter of touched parameters
0227   //! Warning : it gives no protection for ReadOnly etc... while it is the
0228   //! internal way of touching parameters
0229   //! Does not work (returns False) if <num> is for a list
0230   Standard_EXPORT Standard_Boolean Touch (const Standard_Integer num, const Handle(TCollection_HAsciiString)& newval);
0231   
0232   //! Acts as Touch but for a list
0233   //! Does not work (returns False) if <num> is for a single param
0234   Standard_EXPORT Standard_Boolean TouchList (const Standard_Integer num, const Handle(TColStd_HSequenceOfHAsciiString)& newlist);
0235   
0236   //! Returns the count of parameters touched by the last Modify
0237   //! (apart from the modified parameter itself)
0238   //! Normally it is zero
0239   Standard_EXPORT Standard_Integer NbTouched() const;
0240   
0241   //! Clears modification status : by default all, or one by its
0242   //! numbers (in the Editor)
0243   Standard_EXPORT void ClearEdit (const Standard_Integer num = 0);
0244   
0245   //! Prints Definitions, relative to the Editor
0246   Standard_EXPORT void PrintDefs (Standard_OStream& S) const;
0247   
0248   //! Prints Values, according to what and alsolist
0249   //! <names> True : prints Long Names; False : prints Short Names
0250   //! <what> < 0 : prints Original Values (+ flag Modified)
0251   //! <what> > 0 : prints Final Values (+flag Modified)
0252   //! <what> = 0 : prints Modified Values (Original + Edited)
0253   //! <alsolist> False (D) : lists are printed only as their count
0254   //! <alsolist> True : lists are printed for all their items
0255   Standard_EXPORT void PrintValues (Standard_OStream& S, const Standard_Integer what, const Standard_Boolean names, const Standard_Boolean alsolist = Standard_False) const;
0256   
0257   //! Applies modifications to own data
0258   //! Calls ApplyData then Clears Status according EditKeepStatus
0259   Standard_EXPORT Standard_Boolean Apply();
0260   
0261   //! Tells if this EditForm can work with its Editor and its actual
0262   //! Data (Entity and Model)
0263   //! Default uses Editor. Can be redefined
0264   Standard_EXPORT virtual Standard_Boolean Recognize() const;
0265   
0266   //! Applies modifications to data
0267   //! Default uses Editor. Can be redefined
0268   Standard_EXPORT virtual Standard_Boolean ApplyData (const Handle(Standard_Transient)& ent, const Handle(Interface_InterfaceModel)& model);
0269   
0270   //! For an undoable EditForm, Applies ... origibal values !
0271   //! and clears modified ones
0272   //! Can be run only once
0273   Standard_EXPORT Standard_Boolean Undo();
0274 
0275   DEFINE_STANDARD_RTTIEXT(IFSelect_EditForm,Standard_Transient)
0276 
0277 private:
0278 
0279   Standard_Boolean thecomplete;
0280   Standard_Boolean theloaded;
0281   Standard_Boolean thekeepst;
0282   TCollection_AsciiString thelabel;
0283   TColStd_Array1OfInteger thenums;
0284   TColStd_Array1OfTransient theorigs;
0285   TColStd_Array1OfTransient themodifs;
0286   TColStd_Array1OfInteger thestatus;
0287   Handle(IFSelect_Editor) theeditor;
0288   Handle(Standard_Transient) theent;
0289   Handle(Interface_InterfaceModel) themodel;
0290   Standard_Integer thetouched;
0291 
0292 };
0293 
0294 #endif // _IFSelect_EditForm_HeaderFile