// Created on: 1998-02-23 // Created by: Christian CAILLET // Copyright (c) 1998-1999 Matra Datavision // Copyright (c) 1999-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #ifndef _IFSelect_Editor_HeaderFile #define _IFSelect_Editor_HeaderFile #include "Standard.hxx" #include "Standard_Type.hxx" #include "Standard_Integer.hxx" #include "Standard_Transient.hxx" #include "NCollection_Array1.hxx" #include "TCollection_AsciiString.hxx" #include "IFSelect_EditValue.hxx" #include "TCollection_HAsciiString.hxx" #include "NCollection_Sequence.hxx" #include "NCollection_HSequence.hxx" #include "NCollection_DataMap.hxx" class Interface_TypedValue; class IFSelect_EditForm; class TCollection_HAsciiString; class IFSelect_ListEditor; class Interface_InterfaceModel; //! An Editor defines a set of values and a way to edit them, on //! an entity or on the model (e.g. on its header) //! //! Each Value is controlled by a TypedValue, with a number (it is //! an Integer) and a name under two forms (complete and short) //! and an edit mode class IFSelect_Editor : public Standard_Transient { public: //! Sets a Typed Value for a given ident and short name, with an //! Edit Mode Standard_EXPORT void SetValue(const int num, const occ::handle& typval, const char* const shortname = "", const IFSelect_EditValue accessmode = IFSelect_Editable); //! Sets a parameter to be a List //! max < 0 : not for a list (set when starting) //! max = 0 : list with no length limit (default for SetList) //! max > 0 : list limited to items Standard_EXPORT void SetList(const int num, const int max = 0); //! Returns the count of Typed Values Standard_EXPORT int NbValues() const; //! Returns a Typed Value from its ident Standard_EXPORT occ::handle TypedValue(const int num) const; //! Tells if a parameter is a list Standard_EXPORT bool IsList(const int num) const; //! Returns max length allowed for a list //! = 0 means : list with no limit //! < 0 means : not a list Standard_EXPORT int MaxList(const int num) const; //! Returns the name of a Value (complete or short) from its ident //! Short Name can be empty Standard_EXPORT const char* Name(const int num, const bool isshort = false) const; //! Returns the edit mode of a Value Standard_EXPORT IFSelect_EditValue EditMode(const int num) const; //! Returns the number (ident) of a Value, from its name, short or //! complete. If not found, returns 0 Standard_EXPORT int NameNumber(const char* const name) const; Standard_EXPORT void PrintNames(Standard_OStream& S) const; Standard_EXPORT void PrintDefs(Standard_OStream& S, const bool labels = false) const; //! Returns the MaxLength of, according to what : //! = -1 : length of short names //! = 0 : length of complete names //! = 1 : length of values labels Standard_EXPORT int MaxNameLength(const int what) const; //! Returns the specific label Standard_EXPORT virtual TCollection_AsciiString Label() const = 0; //! Builds and Returns an EditForm, empty (no data yet) //! Can be redefined to return a specific type of EditForm Standard_EXPORT virtual occ::handle Form(const bool readonly, const bool undoable = true) const; //! Tells if this Editor can work on this EditForm and its content //! (model, entity ?) Standard_EXPORT virtual bool Recognize(const occ::handle& form) const = 0; //! Returns the value of an EditForm, for a given item //! (if not a list. for a list, a Null String may be returned) Standard_EXPORT virtual occ::handle StringValue( const occ::handle& form, const int num) const = 0; //! Returns a ListEditor for a parameter which is a List //! Default returns a basic ListEditor for a List, a Null Handle //! if is not for a List. Can be redefined Standard_EXPORT virtual occ::handle ListEditor(const int num) const; //! Returns the value of an EditForm as a List, for a given item //! If not a list, a Null Handle should be returned //! Default returns a Null Handle, because many Editors have //! no list to edit. To be redefined as required Standard_EXPORT virtual occ::handle>> ListValue(const occ::handle& form, const int num) const; //! Loads original values from some data, to an EditForm //! Remark: may be Null, this means all is concerned //! Also may be Null, if no context applies for //! And both and may be Null, for a full static //! editor Standard_EXPORT virtual bool Load(const occ::handle& form, const occ::handle& ent, const occ::handle& model) const = 0; //! Updates the EditForm when a parameter is modified //! I.E. default does nothing, can be redefined, as follows : //! Returns True when done (even if does nothing), False in case //! of refuse (for instance, if the new value is not suitable) //! is the rank of the parameter for the EDITOR itself //! True means that protected parameters can be touched //! //! If a parameter commands the value of other ones, when it is //! modified, it is necessary to touch them by Touch from EditForm Standard_EXPORT virtual bool Update(const occ::handle& form, const int num, const occ::handle& newval, const bool enforce) const; //! Acts as Update, but when the value is a list Standard_EXPORT virtual bool UpdateList( const occ::handle& form, const int num, const occ::handle>>& newlist, const bool enforce) const; //! Applies modified values of the EditForm with some data //! Remark: may be Null, this means all is concerned //! Also may be Null, if no context applies for //! And both and may be Null, for a full static //! editor Standard_EXPORT virtual bool Apply(const occ::handle& form, const occ::handle& ent, const occ::handle& model) const = 0; DEFINE_STANDARD_RTTIEXT(IFSelect_Editor, Standard_Transient) protected: //! Prepares the list of Typed Values (gives its count) //! This count can be tuned later, to a LOWER value, this allows //! to initialize with a "maximum reservation" then cut the extra Standard_EXPORT IFSelect_Editor(const int nbval); //! Adjusts the true count of values. It can be LOWER or equal to //! the initial size (which then acts as a reservation), but never //! greater Standard_EXPORT void SetNbValues(const int nbval); private: int thenbval; int themaxsh; int themaxco; int themaxla; NCollection_DataMap thenames; NCollection_Array1> thevalues; NCollection_Array1 theshorts; NCollection_Array1 themodes; NCollection_Array1 thelists; }; #endif // _IFSelect_Editor_HeaderFile