1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

2
src/IFSelect/FILES Executable file
View File

@@ -0,0 +1,2 @@
IFSelect_ActFunc.hxx
IFSelect_ActFunc.cxx

229
src/IFSelect/IFSelect.cdl Executable file
View File

@@ -0,0 +1,229 @@
-- File: IFSelect.cdl
-- Created: Mon Sep 21 11:33:50 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
package IFSelect
---Purpose : Gives tools to manage Selecting a group of Entities
-- processed by an Interface, for instance to divide up an
-- original Model (from a File) to several smaller ones
-- They use description of an Interface Model as a graph
--
-- Remark that this corresponds to the description of a
-- "scenario" of sharing out a File. Parts of this Scenario
-- are intended to be permanently stored. IFSelect provides
-- the Transient, active counterparts (to run the Scenario).
-- But a permanent one (either as Persistent Objects or as
-- interpretable Text) must be provided elsewhere.
uses MMgt, Standard, Message, TCollection, TColStd,
Interface, IFGraph, Dico, MoniTool
is
deferred class Signature; -- to select an entity according a string (its signature)
class SignMultiple; -- liste of signatures
class SignType; -- signature = type cdl
class SignCategory; -- signature = category
class SignValidity; -- signature = validity
class SignAncestor; -- signature = type cdl + all ancestors
class ShareOut;
class AppliedModifiers;
class ShareOutResult;
class PacketList;
deferred class Dispatch;
class DispGlobal; -- takes all result in only ONE group
class DispPerOne; -- defines one group per selected entity
class DispPerCount; -- one group for a count of entities
class DispPerSignature; -- groups given by a SignatureList
class DispPerFiles; -- a determined count of groups
-- Other classes can be added for a specific Interface
class SelectionIterator;
deferred class Selection;
deferred class SelectBase; -- attached directly to the ShareOut :
class SelectModelRoots; -- roots knows as such in the model
class SelectModelEntities; -- all entities of the model
class SelectEntityNumber; -- one entity having a given Number
class SelectPointed; -- directly pointed items
deferred class SelectCombine; -- algebraic operators
class SelectUnion; -- "OR" operator between Selections
class SelectIntersection; -- "AND" operator between Selections
deferred class SelectControl; -- a main list controlled by a second
class SelectDiff; -- "Minus" operator between Selections
deferred class SelectDeduct; -- computed lists :
class SelectShared; -- directly shared entities
class SelectSharing; -- directly sharing entities
deferred class SelectAnyList; -- from a list in an entity
deferred class SelectInList; -- from a list of single entities
generic class SelectList; -- from an entity as a list
class SelectSuite; -- macro-select-deduct
deferred class SelectExtract; -- sorted lists (can be inverted) :
class SelectUnknownEntities;
class SelectErrorEntities;
class SelectIncorrectEntities; -- (according ComputeCheck)
class SelectRoots; -- roots local in a given group
class SelectRootComps; -- idem but manages cycles
class SelectRange; -- range in a list (from i-th to j-th)
deferred class SelectAnyType; -- type to be precised in sub-class
class SelectType; -- type given as a parameter
class SelectSignature; -- signature matching
class SelectFlag; -- flag recorded in the Graph
class SelectSent; -- sent/remaining entities to file
-- Other classes can be added for a specific Interface
-- (in particular, instantiations of SelectType)
-- Other classes can be added for a specific Interface
-- (in particular, instantiations of SelectList)
deferred class SelectExplore;
class SelectSignedShared; -- shared entities + signature
class SelectSignedSharing; -- sharing entities + signature
class IntParam; -- defines externally accessible integer parameters
class SignatureList;
class CheckCounter;
class SignCounter;
class GraphCounter;
deferred class Editor;
class ParamEditor;
class EditForm;
class ListEditor;
class ContextModif; -- (set of data used by Modifiers)
class ContextWrite; -- (set of data used by Modifiers)
deferred class Transformer; -- frame for data transformations
class TransformStandard; -- works with Modifiers
class ModelCopier; -- performs transfers (to produce files)
deferred class GeneralModifier; -- set of criteria for all Modifiers
deferred class Modifier; -- defines modifying actions on transferred model
class ModifReorder; -- reorder whole model from roots
class ModifEditForm; -- applies an EditForm
deferred generic class FileModifier; -- defines actions on file sending
deferred generic class ModelModifier; -- specific actions on model
-- -- Session Management -- --
class WorkSession; -- a set of useful facilities
deferred class WorkLibrary; -- capability of user extents
alias Option is Option from MoniTool; -- pre-defined values for a field
alias Profile is Profile from MoniTool; -- set of options bound/piloted together
class SessionFile;
deferred class SessionDumper;
class BasicDumper;
deferred class Activator;
class SessionPilot;
class Act;
primitive ActFunc;
class Functions;
-- individual functions to be added by Act
enumeration ReturnStatus is RetVoid, RetDone, RetError, RetFail, RetStop;
---Purpose : Qualifies an execution status :
-- RetVoid : normal execution which created nothing, or
-- no data to process
-- RetDone : normal execution with a result
-- RetError : error in command or input data, no execution
-- RetFail : execution was run and has failed
-- RetStop : indicates end or stop (such as Raise)
enumeration RemainMode is
RemainForget, RemainCompute, RemainDisplay, RemainUndo;
-- used to pilot SetRemaining from the WorkSession
enumeration PrintCount is ItemsByEntity, CountByItem, ShortByItem, ListByItem, EntitiesByItem, CountSummary,
GeneralInfo, Mapping, ResultCount;
---Purpose:
-- Lets you choose the manner in which you want to analyze an
-- IGES or STEP file. Your analysis can be either message-oriented or
-- entity-oriented. The specific values are as follows:
-- - ItemsByEntity is a sequential list of all
-- messages per entity of the defined type
-- - CountByItem is the number of entities of the defined
-- type, with their rank number per message
-- - ShortByItem is the number of entities of the defined
-- type, with their types per message; displays the rank
-- numbers of the first five entities of the defined type
-- per message
-- - ListByItem is the number of entities of the defined type
-- per message and the numbers of the entities
-- - EntitiesByItem is the number of entities of the
-- defined type, with their types, rank numbers and
-- Directory Entry numbers per message
-- - GeneralInfo is general information on transfer such as:
-- - number of entities
-- - number of roots
-- - number of resulting Open CASCADE shapes
-- - number of warnings and failures
-- - CountSummary summary statistics for counters and signatures
-- - ResultCount information that contains the number of
-- roots in the IGES file and the number of resulting Open CASCADE shapes.
-- - Mapping of the IGES root entities to the resulting Open
-- CASCADE shape (including type and form of the IGES entity
-- and type of the resulting shape).
enumeration PrintFail is FailOnly, FailAndWarn;
---Purpose: Indicates whether there will
-- be information on warnings as well as on failures. The
-- terms of this enumeration have the following semantics:
-- - IFSelect_FailOnly gives information on failures only
-- - IFSelect_FailAndWarn gives information on both
-- failures and warnings. used to pilot PrintCheckList
enumeration EditValue is
Optional, Editable, EditProtected, EditComputed, EditRead, EditDynamic;
---Purpose : Controls access on Values by an Editor
-- EditOptional : normal access, in addition may be removed
-- Editable : normal access, must be present
-- EditProtected : access must be validated
-- EditComputed : why write it ? it will be recomputed
-- EditRead : no way to write it, only for read
-- EditDynamic : not a field, only to be displayed
-- -- Instantiations -- --
class TSeqOfDispatch instantiates Sequence from TCollection (Dispatch);
class TSeqOfSelection instantiates Sequence from TCollection (Selection);
class HSeqOfSelection instantiates HSequence from TCollection
(Selection,TSeqOfSelection);
-- the followings sequences are used by ModelCopier (definition or result)
class SequenceOfGeneralModifier instantiates Sequence from TCollection
(GeneralModifier);
class SequenceOfInterfaceModel instantiates Sequence from TCollection
(InterfaceModel from Interface);
class SequenceOfAppliedModifiers instantiates Sequence from TCollection
(AppliedModifiers);
-- Package Methods --
SaveSession (WS : any WorkSession; file : CString) returns Boolean;
---Purpose : Saves the state of a WorkSession from IFSelect, by using a
-- SessionFile from IFSelect. Returns True if Done, False in
-- case of Error on Writing. <file> gives the name of the File
-- to be produced (this avoids to export the class SessionFile).
RestoreSession (WS : mutable WorkSession; file : CString) returns Boolean;
---Purpose : Restore the state of a WorkSession from IFSelect, by using a
-- SessionFile from IFSelect. Returns True if Done, False in
-- case of Error on Writing. <file> gives the name of the File
-- to be used (this avoids to export the class SessionFile).
end IFSelect;

21
src/IFSelect/IFSelect.cxx Executable file
View File

@@ -0,0 +1,21 @@
#include <IFSelect.ixx>
#include <IFSelect_SessionFile.hxx>
// Methodes de confort, evitant de devoir connaitre SessionFile, qui est un
// Tool non destine a l export (en particulier, pas un Handle)
Standard_Boolean IFSelect::SaveSession
(const Handle(IFSelect_WorkSession)& WS, const Standard_CString file)
{
IFSelect_SessionFile sesfile(WS,file);
return sesfile.IsDone();
}
Standard_Boolean IFSelect::RestoreSession
(const Handle(IFSelect_WorkSession)& WS, const Standard_CString file)
{
IFSelect_SessionFile sesfile(WS);
return (sesfile.Read(file) == 0);
}

73
src/IFSelect/IFSelect_Act.cdl Executable file
View File

@@ -0,0 +1,73 @@
-- File: IFSelect_Act.cdl
-- Created: Tue Mar 5 09:44:33 1996
-- Author: Christian CAILLET
-- <cky@fidox>
---Copyright: Matra Datavision 1996
class Act from IFSelect inherits Activator
---Purpose : Act gives a simple way to define and add functions to be ran
-- from a SessionPilot, as follows :
--
-- Define a function as
-- static IFSelect_RetStatus myfunc
-- (const Standard_CString name,
-- const Handle(IFSelect_SessionPilot)& pilot)
-- { ... }
-- When ran, it receives the exact name (string) of the called
-- function, and the SessionPilot which brings other infos
--
-- Add it by
-- IFSelect_Act::AddFunc (name,help,myfunc);
-- for a normal function, or
-- IFSelect_Act::AddFSet (name,help,myfunc);
-- for a function which is intended to create a control item
-- name and help are given as CString
--
-- Then, it is available for run
uses CString, AsciiString, SessionPilot, ActFunc, ReturnStatus
raises DomainError
is
Create (name, help : CString; func : ActFunc) returns mutable Act;
---Purpose : Creates an Act with a name, help and a function
-- mode (Add or AddSet) is given when recording
Do (me : mutable; number : Integer; pilot : mutable SessionPilot)
returns ReturnStatus;
---Purpose : Execution of Command Line. remark that <number> is senseless
-- because each Act brings one and only one function
Help (me; number : Integer) returns CString;
---Purpose : Short Help for commands : returns the help given to create
-- to record functions
SetGroup (myclass; group : CString; file : CString = "");
---Purpose : Changes the default group name for the following Acts
-- group empty means to come back to default from Activator
-- Also a file name can be precised (to query by getsource)
AddFunc (myclass; name, help : CString; func : ActFunc)
---Purpose : Adds a function with its name and help : creates an Act then
-- records it as normal function
raises DomainError;
-- Error if <name> already recorded (see Activator)
AddFSet (myclass; name, help : CString; func : ActFunc)
---Purpose : Adds a function with its name and help : creates an Act then
-- records it as function for XSET (i.e. to create control item)
raises DomainError;
-- Error if <name> already recorded (see Activator)
fields
thename : AsciiString;
thehelp : AsciiString;
thefunc : ActFunc;
end Act;

46
src/IFSelect/IFSelect_Act.cxx Executable file
View File

@@ -0,0 +1,46 @@
#include <IFSelect_Act.ixx>
#include <TCollection_AsciiString.hxx>
static TCollection_AsciiString thedefgr, thedefil;
IFSelect_Act::IFSelect_Act
(const Standard_CString name, const Standard_CString help,
const IFSelect_ActFunc func)
: thename (name) , thehelp (help) , thefunc (func) { }
IFSelect_ReturnStatus IFSelect_Act::Do
(const Standard_Integer, const Handle(IFSelect_SessionPilot)& pilot)
{
if (!thefunc) return IFSelect_RetVoid;
return thefunc (pilot);
}
Standard_CString IFSelect_Act::Help (const Standard_Integer) const
{ return thehelp.ToCString(); }
void IFSelect_Act::SetGroup
(const Standard_CString group, const Standard_CString file)
{ thedefgr.Clear(); if (group[0] != '\0') thedefgr.AssignCat(group);
thedefil.Clear(); if (file [0] != '\0') thedefil.AssignCat(file); }
void IFSelect_Act::AddFunc
(const Standard_CString name, const Standard_CString help,
const IFSelect_ActFunc func)
{
Handle(IFSelect_Act) act = new IFSelect_Act (name,help,func);
if (thedefgr.Length() > 0) act->SetForGroup (thedefgr.ToCString());
act->Add (1,name);
}
void IFSelect_Act::AddFSet
(const Standard_CString name, const Standard_CString help,
const IFSelect_ActFunc func)
{
Handle(IFSelect_Act) act = new IFSelect_Act (name,help,func);
if (thedefgr.Length() > 0)
act->SetForGroup (thedefgr.ToCString(),thedefil.ToCString());
act->AddSet (1,name);
}

View File

@@ -0,0 +1,21 @@
// File: IFSelect_ActFunc.cxx
// Created: Tue Feb 29 15:57:24 2000
// Author: data exchange team
// <det@kinox>
#include <IFSelect_ActFunc.hxx>
//=======================================================================
//function : IFSelect_ActFunc_Type_
//purpose :
//=======================================================================
Handle(Standard_Type)& STANDARD_TYPE(IFSelect_ActFunc)
{
static Handle(Standard_Type) _aType =
new Standard_Type("IFSelect_ActFunc", sizeof(IFSelect_ActFunc), 0, NULL);
return _aType;
}

View File

@@ -0,0 +1,17 @@
// File: IFSelect_ActFunc.hxx<2>
// Created: Tue Feb 29 15:56:12 2000
// Author: data exchange team
// <det@kinox>
#ifndef _IFSelect_ActFunc_HeaderFile
#define _IFSelect_ActFunc_HeaderFile
#include <Standard_Type.hxx>
#include <Handle_IFSelect_SessionPilot.hxx>
#include <IFSelect_ReturnStatus.hxx>
typedef IFSelect_ReturnStatus (*IFSelect_ActFunc) (const Handle(IFSelect_SessionPilot)&);
Standard_EXPORT Handle(Standard_Type)& STANDARD_TYPE(IFSelect_ActFunc);
#endif

View File

@@ -0,0 +1,134 @@
-- File: IFSelect_Activator.cdl
-- Created: Tue Jul 27 16:12:17 1993
-- Author: Christian CAILLET
-- <cky@meteox>
---Copyright: Matra Datavision 1993
deferred class Activator from IFSelect inherits TShared
---Purpose : Defines the general frame for working with a SessionPilot.
-- Each Activator treats a set of Commands. Commands are given as
-- alphanumeric strings. They can be of two main forms :
-- - classic, to list, evaluate, enrich the session (by itself) :
-- no specific remark, its complete execution must be described
-- - creation of a new item : instead of creatinf it plus adding
-- it to the session (which is a classic way), it is possible
-- to create it and make it recorded by the SessionPilot :
-- then, the Pilot will add it to the session; this way allows
-- the Pilot to manage itself named items
--
-- In order to make easier the use of Activator, this class
-- provides a simple way to Select an Actor for a Command :
-- each sub-class of SectionActor defines the command titles it
-- recognizes, plus attaches a Number, unique for this sub-class,
-- to each distinct command title.
--
-- Each time an action is required, the corresponding Number
-- can then be given to help the selection of the action to do.
--
-- The result of an Execution must indicate if it is worth to be
-- recorded or not : see method Do
uses CString, OStream,
AsciiString from TCollection,
HSequenceOfAsciiString from TColStd,
SessionPilot, ReturnStatus
raises DomainError
is
Adding (myclass;
actor : Activator;
number : Integer;
command : CString;
mode : Integer)
---Purpose : Records, in a Dictionary available for all the Activators,
-- the command title an Activator can process, attached with
-- its number, proper for this Activator
-- <mode> allows to distinguish various execution modes
-- 0: default mode; 1 : for xset
raises DomainError;
-- Error if a command title (exactly the same) is recorded more
-- than once
Add (me; number : Integer; command : CString)
---Purpose : Allows a self-definition by an Activator of the Commands it
-- processes, call the class method Adding (mode 0)
raises DomainError;
-- Error if a command title (exactly the same) is recorded more
-- than once
AddSet (me; number : Integer; command : CString)
---Purpose : Same as Add but specifies that this command is candidate for
-- xset (creation of items, xset : named items; mode 1)
raises DomainError;
Remove (myclass; command : CString);
---Purpose : Removes a Command, if it is recorded (else, does nothing)
SetAlias (myclass; conf, command, aliasname : CString);
---Purpose : Records, for a configuration named <conf>, that the command
-- <command> may be aliased by another command <alias>
--
-- To be used by call to Alias (no automatic redirection)
-- The configuration typically refers to a norm
SetCurrentAlias (myclass; conf : CString);
---Purpose : Sets <conf> as current configuration for aliases
Alias (myclass; command : CString) returns AsciiString;
---Purpose : Returns, in the current configuration, what alias has been
-- recorded for <command>
-- The returned string is empty if no alias is recorded
Select (myclass; command : CString;
number : out Integer; actor : out mutable Activator)
returns Boolean;
---Purpose : Selects, for a Command given by its title, an actor with its
-- command number. Returns True if found, False else
Mode (myclass; command : CString) returns Integer;
---Purpose : Returns mode recorded for a command. -1 if not found
Commands (myclass; mode : Integer = -1; command : CString = "")
returns HSequenceOfAsciiString from TColStd;
---Purpose : Returns, for a root of command title, the list of possible
-- commands.
-- <mode> : -1 (D) for all commands if <commands> is empty
-- -1 + command : about a Group , >= 0 see Adding
-- By default, it returns the whole list of known commands.
Initialize;
---Purpose : Sets the default values
Do (me : mutable; number : Integer; pilot : mutable SessionPilot)
returns ReturnStatus is deferred;
---Purpose : Tries to execute a Command Line. <number> is the number of the
-- command for this Activator. It Must forecast to record the
-- result of the execution, for need of Undo-Redo
-- Must Returns : 0 for a void command (not to be recorded),
-- 1 if execution OK, -1 if command incorrect, -2 if error
-- on execution
Help (me; number : Integer) returns CString is deferred;
---Purpose : Sends a short help message for a given command identified by
-- it number for this Activator (must take one line max)
Group (me) returns CString;
File (me) returns CString;
SetForGroup (me : mutable; group : CString; file : CString = "");
---Purpose : Group and SetGroup define a "Group of commands" which
-- correspond to an Activator. Default is "XSTEP"
-- Also a file may be attached
fields
thegroup : AsciiString;
thefile : AsciiString;
end Activator;

View File

@@ -0,0 +1,149 @@
#include <IFSelect_Activator.ixx>
#include <Dico_DictionaryOfInteger.hxx>
#include <Dico_IteratorOfDictionaryOfInteger.hxx>
#include <TColStd_SequenceOfInteger.hxx>
#include <TColStd_SequenceOfTransient.hxx>
#include <Standard_DomainError.hxx>
#include <IFSelect_Profile.hxx>
#include <IFSelect_Option.hxx>
#include <TCollection_HAsciiString.hxx>
#include <Interface_Macros.hxx>
static Handle(Dico_DictionaryOfInteger) thedico; // = new Dico_DictionaryOfInteger;
static TColStd_SequenceOfInteger thenums, themodes;
static TColStd_SequenceOfTransient theacts;
static Handle(IFSelect_Profile) thealiases;
void IFSelect_Activator::Adding
(const Handle(IFSelect_Activator)& actor,
const Standard_Integer number,
const Standard_CString command,
const Standard_Integer mode)
{
Standard_Boolean deja;
if (thedico.IsNull()) thedico = new Dico_DictionaryOfInteger;
Standard_Integer& num = thedico->NewItem(command,deja,Standard_True);
if (deja) {
#ifdef DEB
cout<<"**** XSTEP commands, name conflict on "<<command<<" first defined remains ****"<<endl;
// Standard_DomainError::Raise("IFSelect_Activator : Add");
#endif
}
num = thenums.Length() + 1;
thenums.Append(number);
theacts.Append(actor);
themodes.Append(mode);
}
void IFSelect_Activator::Add
(const Standard_Integer number, const Standard_CString command) const
{ Adding (this,number,command,0); }
void IFSelect_Activator::AddSet
(const Standard_Integer number, const Standard_CString command) const
{ Adding (this,number,command,1); }
void IFSelect_Activator::Remove (const Standard_CString command)
{ thedico->RemoveItem(command); }
// ALIAS : gere avec un Profile
// Chaque commande est representee par une Option
// Au sein de laquelle chaque configuration nomme un cas, dont la valeur
// est le nom de son alias pour cette conf
// Et chaque conf porte un switch sur cette option avec pour valeur le propre
// nom de la conf
void IFSelect_Activator::SetAlias
(const Standard_CString conf,
const Standard_CString command, const Standard_CString alias)
{
if (thealiases.IsNull()) thealiases = new IFSelect_Profile;
Handle(IFSelect_Option) opt = thealiases->Option(command);
if (opt.IsNull()) {
opt = new IFSelect_Option(STANDARD_TYPE(TCollection_HAsciiString),command);
thealiases->AddOption (opt);
}
opt->Add (conf,new TCollection_HAsciiString(alias));
if (!thealiases->HasConf(conf)) thealiases->AddConf (conf);
thealiases->AddSwitch (conf,command,conf);
}
void IFSelect_Activator::SetCurrentAlias (const Standard_CString conf)
{
if (!thealiases.IsNull()) thealiases->SetCurrent (conf);
}
TCollection_AsciiString IFSelect_Activator::Alias
(const Standard_CString command)
{
TCollection_AsciiString str;
if (thealiases.IsNull()) return str;
Handle(TCollection_HAsciiString) val;
if (!thealiases->Value(command,val)) return str;
str.AssignCat (val->ToCString());
return str;
}
Standard_Boolean IFSelect_Activator::Select
(const Standard_CString command, Standard_Integer& number,
Handle(IFSelect_Activator)& actor)
{
Standard_Integer num;
if (!thedico->GetItem(command,num,Standard_False)) return Standard_False;
number = thenums(num);
actor = Handle(IFSelect_Activator)::DownCast(theacts(num));
return Standard_True;
}
Standard_Integer IFSelect_Activator::Mode
(const Standard_CString command)
{
Standard_Integer num;
if (!thedico->GetItem(command,num,Standard_False)) return -1;
return themodes(num);
}
Handle(TColStd_HSequenceOfAsciiString) IFSelect_Activator::Commands
(const Standard_Integer mode, const Standard_CString command)
{
Standard_Integer num;
Dico_IteratorOfDictionaryOfInteger iter (thedico,command);
Handle(TColStd_HSequenceOfAsciiString) list =
new TColStd_HSequenceOfAsciiString();
for (iter.Start(); iter.More(); iter.Next()) {
if (mode < 0) {
DeclareAndCast(IFSelect_Activator,acti,theacts(iter.Value()));
if (acti.IsNull()) continue;
if (command[0] == '\0' || !strcmp(command,acti->Group()) )
list->Append(iter.Name());
} else {
num = iter.Value();
if (themodes(num) == mode) list->Append(iter.Name());
}
}
return list;
}
IFSelect_Activator::IFSelect_Activator ()
: thegroup ("XSTEP") { }
void IFSelect_Activator::SetForGroup
(const Standard_CString group, const Standard_CString file)
{ thegroup.Clear(); thegroup.AssignCat (group);
thefile.Clear(); thefile.AssignCat (file); }
Standard_CString IFSelect_Activator::Group () const
{ return thegroup.ToCString(); }
Standard_CString IFSelect_Activator::File () const
{ return thefile.ToCString(); }

View File

@@ -0,0 +1,90 @@
-- File: IFSelect_AppliedModifiers.cdl
-- Created: Mon May 2 18:34:11 1994
-- Author: Christian CAILLET
-- <cky@bravox>
---Copyright: Matra Datavision 1994
class AppliedModifiers from IFSelect inherits TShared
---Purpose : This class allows to memorize and access to the modifiers
-- which are to be applied to a file. To each modifier, is bound
-- a list of integers (optionnal) : if this list is absent, the
-- modifier applies to all the file. Else, it applies to the
-- entities designated by these numbers in the produced file.
--
-- To record a modifier, and a possible list of entity numbers
-- to be applied on :
-- AddModif (amodifier);
-- loop on AddNum (anumber);
--
-- To query it, Count gives the count of recorded modifiers,
-- then for each one :
-- Item (numodif, amodifier, entcount);
-- IsForAll () -> can be called, if True, applies on the whole file
--
-- for (i = 1; i <= entcount; i ++)
-- nument = ItemNum (i); -> return an entity number
uses GeneralModifier, SequenceOfGeneralModifier,
HSequenceOfInteger from TColStd, IntList
is
Create (nbmax,nbent : Integer) returns mutable AppliedModifiers;
---Purpose : Creates an AppliedModifiers, ready to record up to <nbmax>
-- modifiers, on a model of <nbent> entities
AddModif (me : mutable; modif : mutable GeneralModifier) returns Boolean;
---Purpose : Records a modifier. By default, it is to apply on all a
-- produced file. Further calls to AddNum will restrict this.
-- Returns True if done, False if too many modifiers are already
-- recorded
AddNum (me : mutable; nument : Integer) returns Boolean;
---Purpose : Adds a number of entity of the output file to be applied on.
-- If a sequence of AddNum is called after AddModif, this
-- Modifier will be applied on the list of designated entities.
-- Else, it will be applied on all the file
-- Returns True if done, False if no modifier has yet been added
Count (me) returns Integer;
---Purpose : Returns the count of recorded modifiers
Item (me : mutable; num : Integer;
modif : out mutable GeneralModifier; entcount : out Integer)
returns Boolean;
---Purpose : Returns the description for applied modifier n0 <num> :
-- the modifier itself, and the count of entities to be applied
-- on. If no specific list of number has been defined, returns
-- the total count of entities of the file
-- If this count is zero, then the modifier applies to all
-- the file (see below). Else, the numbers are then queried by
-- calls to ItemNum between 1 and <entcount>
-- Returns True if OK, False if <num> is out of range
ItemNum (me; nument : Integer) returns Integer;
---Purpose : Returns a numero of entity to be applied on, given its rank
-- in the list. If no list is defined (i.e. for all the file),
-- returns <nument> itself, to give all the entities of the file
-- Returns 0 if <nument> out of range
ItemList (me) returns HSequenceOfInteger;
---Purpose : Returns the list of entities to be applied on (see Item)
-- as a HSequence (IsForAll produces the complete list of all
-- the entity numbers of the file
IsForAll (me) returns Boolean;
---Purpose : Returns True if the applied modifier queried by last call to
-- Item is to be applied to all the produced file.
-- Else, <entcount> returned by Item gives the count of entity
-- numbers, each one is queried by ItemNum
fields
themodifs : SequenceOfGeneralModifier;
thelists : IntList;
thenbent : Integer;
theentcnt : Integer;
end AppliedModifiers;

View File

@@ -0,0 +1,57 @@
#include <IFSelect_AppliedModifiers.ixx>
IFSelect_AppliedModifiers::IFSelect_AppliedModifiers
(const Standard_Integer nbmax, const Standard_Integer nbent)
: thelists (nbmax+1)
{
thenbent = nbent; theentcnt = 0;
}
Standard_Boolean IFSelect_AppliedModifiers::AddModif
(const Handle(IFSelect_GeneralModifier)& modif)
{
if (themodifs.Length() >= thelists.NbEntities()) return Standard_False;
themodifs.Append(modif);
thelists.SetNumber (themodifs.Length());
return Standard_True;
}
Standard_Boolean IFSelect_AppliedModifiers::AddNum
(const Standard_Integer nument)
{
thelists.Add (nument);
return Standard_True;
}
Standard_Integer IFSelect_AppliedModifiers::Count () const
{ return themodifs.Length(); }
Standard_Boolean IFSelect_AppliedModifiers::Item
(const Standard_Integer num,
Handle(IFSelect_GeneralModifier)& modif,
Standard_Integer& entcount)
{
if (num < 1 || num > themodifs.Length()) return Standard_False;
modif = themodifs.Value(num);
thelists.SetNumber (num);
theentcnt = thelists.Length();
entcount = (theentcnt > 0 ? theentcnt : thenbent);
return Standard_True;
}
Standard_Integer IFSelect_AppliedModifiers::ItemNum
(const Standard_Integer nument) const
{ return (theentcnt > 0 ? thelists.Value(nument) : nument); }
Handle(TColStd_HSequenceOfInteger) IFSelect_AppliedModifiers::ItemList () const
{
Handle(TColStd_HSequenceOfInteger) list = new TColStd_HSequenceOfInteger();
Standard_Integer i, nb = (theentcnt > 0 ? theentcnt : thenbent);
for (i = 1; i <= nb; i ++) list->Append (ItemNum(i));
return list;
}
Standard_Boolean IFSelect_AppliedModifiers::IsForAll () const
{ return (theentcnt == 0); }

View File

@@ -0,0 +1,31 @@
-- File: IFSelect_BasicDumper.cdl
-- Created: Thu Nov 4 12:06:15 1993
-- Author: Christian CAILLET
-- <cky@sdsun2>
---Copyright: Matra Datavision 1993
class BasicDumper from IFSelect inherits SessionDumper
---Purpose : BasicDumper takes into account, for SessionFile, all the
-- classes defined in the package IFSelect : Selections,
-- Dispatches (there is no Modifier)
uses Transient, AsciiString from TCollection, SessionFile
is
Create returns mutable BasicDumper;
---Purpose : Creates a BasicDumper and puts it into the Library of Dumper
WriteOwn (me; file : in out SessionFile; item : Transient) returns Boolean;
---Purpose : Write the Own Parameters of Types defined in package IFSelect
-- Returns True if <item> has been processed, False else
ReadOwn (me; file : in out SessionFile;
type : AsciiString from TCollection; item : out mutable Transient)
returns Boolean;
---Purpose : Recognizes and Read Own Parameters for Types of package
-- IFSelect. Returns True if done and <item> created, False else
end BasicDumper;

View File

@@ -0,0 +1,178 @@
#include <IFSelect_BasicDumper.ixx>
#include <IFSelect_IntParam.hxx>
#include <IFSelect_WorkSession.hxx>
#include <IFSelect_ShareOut.hxx>
#include <IFSelect_SelectModelRoots.hxx>
#include <IFSelect_SelectModelEntities.hxx>
#include <IFSelect_SelectEntityNumber.hxx>
#include <IFSelect_SelectPointed.hxx>
#include <IFSelect_SelectUnion.hxx>
#include <IFSelect_SelectIntersection.hxx>
#include <IFSelect_SelectDiff.hxx>
#include <IFSelect_SelectUnknownEntities.hxx>
#include <IFSelect_SelectErrorEntities.hxx>
#include <IFSelect_SelectIncorrectEntities.hxx>
#include <IFSelect_SelectRoots.hxx>
#include <IFSelect_SelectRootComps.hxx>
#include <IFSelect_SelectRange.hxx>
//#include <IFSelect_SelectTextType.hxx>
#include <IFSelect_SelectShared.hxx>
#include <IFSelect_SelectSharing.hxx>
#include <IFSelect_DispPerOne.hxx>
#include <IFSelect_DispGlobal.hxx>
#include <IFSelect_DispPerCount.hxx>
#include <IFSelect_TransformStandard.hxx>
#include <Interface_Macros.hxx>
#define FIRSTCHAR 1
// Param litteral "own" sous la forme :"<val>" -> first = 3
// A present, forme simplifiee : <val> directement -> first = 1
IFSelect_BasicDumper::IFSelect_BasicDumper () { }
Standard_Boolean IFSelect_BasicDumper::WriteOwn
(IFSelect_SessionFile& file, const Handle(Standard_Transient)& item) const
{
Handle(Standard_Type) type = item->DynamicType();
if (type == STANDARD_TYPE(IFSelect_SelectModelRoots)) return Standard_True;
if (type == STANDARD_TYPE(IFSelect_SelectModelEntities)) return Standard_True;
if (type == STANDARD_TYPE(IFSelect_SelectEntityNumber)) {
DeclareAndCast(IFSelect_SelectEntityNumber,sen,item);
file.SendItem(sen->Number());
return Standard_True;
}
if (type == STANDARD_TYPE(IFSelect_SelectPointed)) return Standard_True;
if (type == STANDARD_TYPE(IFSelect_SelectUnion)) return Standard_True;
if (type == STANDARD_TYPE(IFSelect_SelectIntersection)) return Standard_True;
if (type == STANDARD_TYPE(IFSelect_SelectDiff)) return Standard_True;
if (type == STANDARD_TYPE(IFSelect_SelectUnknownEntities)) return Standard_True;
if (type == STANDARD_TYPE(IFSelect_SelectErrorEntities)) return Standard_True;
if (type == STANDARD_TYPE(IFSelect_SelectIncorrectEntities)) return Standard_True;
if (type == STANDARD_TYPE(IFSelect_SelectRoots)) return Standard_True;
if (type == STANDARD_TYPE(IFSelect_SelectRootComps)) return Standard_True;
if (type == STANDARD_TYPE(IFSelect_SelectRange)) {
DeclareAndCast(IFSelect_SelectRange,sra,item);
file.SendItem(sra->Lower());
file.SendItem(sra->Upper());
return Standard_True;
}
/* if (type == STANDARD_TYPE(IFSelect_SelectTextType)) {
DeclareAndCast(IFSelect_SelectTextType,sty,item);
if (sty->IsExact()) file.SendText("exact");
else file.SendText("contains");
file.SendText(sty->SignatureText().ToCString());
return Standard_True;
} */
if (type == STANDARD_TYPE(IFSelect_SelectShared)) return Standard_True;
if (type == STANDARD_TYPE(IFSelect_SelectSharing)) return Standard_True;
if (type == STANDARD_TYPE(IFSelect_DispPerOne)) return Standard_True;
if (type == STANDARD_TYPE(IFSelect_DispGlobal)) return Standard_True;
if (type == STANDARD_TYPE(IFSelect_DispPerCount)) {
DeclareAndCast(IFSelect_DispPerCount,dpc,item);
file.SendItem(dpc->Count());
return Standard_True;
}
if (type == STANDARD_TYPE(IFSelect_TransformStandard)) {
DeclareAndCast(IFSelect_TransformStandard,trs,item);
if (trs->CopyOption()) file.SendText("copy");
else file.SendText("onthespot");
Standard_Integer nbm = trs->NbModifiers();
for (Standard_Integer i = 1; i <= nbm; i ++)
file.SendItem(trs->Modifier(i));
}
return Standard_False;
}
Standard_Boolean IFSelect_BasicDumper::ReadOwn
(IFSelect_SessionFile& file, const TCollection_AsciiString& type,
Handle(Standard_Transient)& item) const
{
if (type.IsEqual("IFSelect_SelectModelRoots"))
{ item = new IFSelect_SelectModelRoots (); return Standard_True; }
if (type.IsEqual("IFSelect_SelectModelEntities"))
{ item = new IFSelect_SelectModelEntities (); return Standard_True; }
if (type.IsEqual("IFSelect_SelectEntityNumber")) {
Handle(IFSelect_SelectEntityNumber) sen =
new IFSelect_SelectEntityNumber ();
sen->SetNumber (GetCasted(IFSelect_IntParam,file.ItemValue(1)));
item = sen;
return Standard_True;
}
if (type.IsEqual("IFSelect_SelectPointed"))
{ item = new IFSelect_SelectPointed; return Standard_True; }
if (type.IsEqual("IFSelect_SelectUnion"))
{ item = new IFSelect_SelectUnion; return Standard_True; }
if (type.IsEqual("IFSelect_SelectIntersection"))
{ item = new IFSelect_SelectIntersection; return Standard_True; }
if (type.IsEqual("IFSelect_SelectDiff"))
{ item = new IFSelect_SelectDiff; return Standard_True; }
if (type.IsEqual("IFSelect_SelectUnknownEntities"))
{ item = new IFSelect_SelectUnknownEntities; return Standard_True; }
if (type.IsEqual("IFSelect_SelectErrorEntities"))
{ item = new IFSelect_SelectErrorEntities; return Standard_True; }
if (type.IsEqual("IFSelect_SelectIncorrectEntities"))
{ item = new IFSelect_SelectIncorrectEntities; return Standard_True; }
if (type.IsEqual("IFSelect_SelectRoots"))
{ item = new IFSelect_SelectRoots; return Standard_True; }
if (type.IsEqual("IFSelect_SelectRootComps"))
{ item = new IFSelect_SelectRootComps; return Standard_True; }
if (type.IsEqual("IFSelect_SelectRange")) {
Handle(IFSelect_SelectRange) sra = new IFSelect_SelectRange;
sra->SetRange (GetCasted(IFSelect_IntParam,file.ItemValue(1)),
GetCasted(IFSelect_IntParam,file.ItemValue(2)) );
item = sra;
return Standard_True;
}
if (type.IsEqual("IFSelect_SelectTextType")) {
Standard_Boolean exact;
const TCollection_AsciiString exname = file.ParamValue(1);
if (exname.Length() < FIRSTCHAR) return Standard_False;
if (exname.Value(FIRSTCHAR) == 'e') exact = Standard_True;
else if (exname.Value(FIRSTCHAR) == 'c') exact = Standard_False;
else return Standard_False;
// item = new IFSelect_SelectTextType (file.TextValue(2).ToCString(),exact);
// return Standard_True;
}
if (type.IsEqual("IFSelect_SelectShared"))
{ item = new IFSelect_SelectShared; return Standard_True; }
if (type.IsEqual("IFSelect_SelectSharing"))
{ item = new IFSelect_SelectSharing; return Standard_True; }
if (type.IsEqual("IFSelect_DispPerOne"))
{ item = new IFSelect_DispPerOne; return Standard_True; }
if (type.IsEqual("IFSelect_DispGlobal"))
{ item = new IFSelect_DispGlobal; return Standard_True; }
if (type.IsEqual("IFSelect_DispPerCount")) {
Handle(IFSelect_DispPerCount) dpc = new IFSelect_DispPerCount;
dpc->SetCount (GetCasted(IFSelect_IntParam,file.ItemValue(1)) );
item = dpc;
return Standard_True;
}
if (type.IsEqual("IFSelect_TransformStandard")) {
Standard_Boolean copyoption;
const TCollection_AsciiString copyname = file.ParamValue(1);
if (copyname.Length() < FIRSTCHAR) return Standard_False;
if (copyname.Value(FIRSTCHAR) == 'c') copyoption = Standard_True;
else if (copyname.Value(FIRSTCHAR) == 'o') copyoption = Standard_False;
else return Standard_False;
Handle(IFSelect_TransformStandard) trs = new IFSelect_TransformStandard;
trs->SetCopyOption(copyoption);
Standard_Integer nbp = file.NbParams();
for (Standard_Integer i = 2; i <= nbp; i ++) {
DeclareAndCast(IFSelect_Modifier,modif,file.ItemValue(i));
if (!modif.IsNull()) trs->AddModifier(modif);
}
item = trs;
return Standard_True;
}
return Standard_False;
}

View File

@@ -0,0 +1,47 @@
-- File: IFSelect_CheckCounter.cdl
-- Created: Mon Nov 7 18:34:38 1994
-- Author: Christian CAILLET
-- <cky@stylox>
---Copyright: Matra Datavision 1994
class CheckCounter from IFSelect inherits SignatureList
---Purpose : A CheckCounter allows to see a CheckList (i.e. CheckIterator)
-- not per entity, its messages, but per message, the entities
-- attached (count and list). Because many messages can be
-- repeated if they are due to systematic errors
uses CheckIterator, InterfaceModel, SignText from MoniTool
is
Create (withlist : Boolean = Standard_False) returns mutable CheckCounter;
---Purpose : Creates a CheckCounter, empty ready to work
SetSignature (me : mutable; sign : SignText);
---Purpose : Sets a specific signature
-- Else, the current SignType (in the model) is used
Signature (me) returns SignText;
---Purpose : Returns the Signature;
Analyse (me : mutable;
list : CheckIterator;
model : InterfaceModel;
original : Boolean = Standard_False;
failsonly : Boolean = Standard_False);
---Purpose : Analyses a CheckIterator according a Model (which detains the
-- entities for which the CheckIterator has messages), i.e.
-- counts messages for entities
-- If <original> is True, does not consider final messages but
-- those before interpretation (such as inserting variables :
-- integers, reals, strings)
-- If <failsonly> is True, only Fails are considered
-- Remark : global messages are recorded with a Null entity
fields
thesign : SignText; -- optional
end CheckCounter;

View File

@@ -0,0 +1,82 @@
#include <IFSelect_CheckCounter.ixx>
#include <Standard_Transient.hxx>
#include <Interface_Check.hxx>
#include <stdio.h>
//=======================================================================
//function : IFSelect_CheckCounter
//purpose :
//=======================================================================
IFSelect_CheckCounter::IFSelect_CheckCounter(const Standard_Boolean withlist)
: IFSelect_SignatureList (withlist)
{
SetName("Check");
}
//=======================================================================
//function : SetSignature
//purpose :
//=======================================================================
void IFSelect_CheckCounter::SetSignature(const Handle(MoniTool_SignText)& sign)
{
thesign = sign;
}
//=======================================================================
//function : Signature
//purpose :
//=======================================================================
Handle(MoniTool_SignText) IFSelect_CheckCounter::Signature () const
{
return thesign;
}
//=======================================================================
//function : Analyse
//purpose :
//=======================================================================
void IFSelect_CheckCounter::Analyse(const Interface_CheckIterator& list,
const Handle(Interface_InterfaceModel)& model,
const Standard_Boolean original,
const Standard_Boolean failsonly)
{
Standard_Integer i,nb,num, nbe = (model.IsNull() ? 0 : model->NbEntities());
char mess[300];
sprintf (mess,"Check %s",list.Name());
SetName (mess);
for (list.Start(); list.More(); list.Next()) {
num = list.Number();
Handle(Standard_Transient) ent;
const Handle(Interface_Check) check = list.Value();
ent = check->Entity();
if (ent.IsNull() && num > 0 && num <= nbe) ent = model->Value(num);
nb = check->NbFails();
Standard_CString tystr = NULL;
if (!ent.IsNull()) {
if (!thesign.IsNull()) tystr = thesign->Text (ent,model).ToCString();
else if (!model.IsNull()) tystr = model->TypeName (ent);
else tystr =
Interface_InterfaceModel::ClassName(ent->DynamicType()->Name());
}
for (i = 1; i <= nb; i ++) {
if (ent.IsNull()) sprintf(mess,"F: %s",check->CFail(i,original));
else sprintf(mess,"F:%s: %s",tystr,check->CFail(i,original));
Add (ent,mess);
}
nb = 0;
if (!failsonly) nb = check->NbWarnings();
for (i = 1; i <= nb; i ++) {
if (ent.IsNull()) sprintf(mess,"W: %s",check->CWarning(i,original));
else sprintf(mess,"W:%s: %s",tystr,check->CWarning(i,original));
Add (ent,mess);
}
}
}

View File

@@ -0,0 +1,196 @@
-- File: IFSelect_ContextModif.cdl
-- Created: Wed Jun 8 11:15:14 1994
-- Author: Christian CAILLET
-- <cky@bravox>
---Copyright: Matra Datavision 1994
class ContextModif from IFSelect
---Purpose : This class gathers various informations used by Model Modifiers
-- apart from the target model itself, and the CopyTool which
-- must be passed directly.
--
-- These informations report to original data : model, entities,
-- and the selection list if there is one : it allows to query
-- about such or such starting entity, or result entity, or
-- iterate on selection list ...
-- Also data useful for file output are available (because some
-- Modifiers concern models produced for file output).
--
-- Furthermore, in return, ContextModif can record Checks, either
-- one for all, or one for each Entity. It supports trace too.
uses Transient, CString, AsciiString from TCollection,
Graph, InterfaceModel, CopyTool, CopyControl, EntityIterator,
Protocol from Interface, Check, CheckIterator, GeneralModifier
raises NoSuchObject
is
Create (graph : Graph; TC : CopyTool; filename : CString = "")
returns ContextModif;
---Purpose : Prepares a ContextModif with these informations :
-- - the graph established from original model (target passed
-- directly to Modifier)
-- - the CopyTool which detains the CopyControl, which maps
-- starting (in original) and result (in target) entities
-- - an optional file name (for file output)
--
-- Such a ContextModif is considered to be applied on all
-- transferred entities (no filter active)
Create (graph : Graph; filename : CString = "")
returns ContextModif;
---Purpose : Prepares a ContextModif with these informations :
-- - the graph established from original model (target passed
-- directly to Modifier)
-- - an optional file name (for file output)
-- Here, no CopyControl, hence all entities are considered equal
-- as starting and result
--
-- Such a ContextModif is considered to be applied on all
-- transferred entities (no filter active)
Select (me : in out; list : in out EntityIterator) is static;
---Purpose : This method requires ContextModif to be applied with a filter.
-- If a ModelModifier is defined with a Selection criterium,
-- the result of this Selection is used as a filter :
-- - if none of its items has been transferred, the modification
-- does not apply at all
-- - else, the Modifier can query for what entities were selected
-- and what are their results
-- - if this method is not called before working, the Modifier
-- has to work on the whole Model
OriginalGraph (me) returns Graph is static;
---Purpose : Returns the original Graph (compared to OriginalModel, it
-- gives more query capabilitites)
---C++ : return const &
OriginalModel (me) returns InterfaceModel is static;
---Purpose : Returns the original model
SetProtocol (me : in out; proto : Protocol from Interface);
---Purpose : Allows to transmit a Protocol as part of a ContextModif
Protocol (me) returns Protocol from Interface;
---Purpose : Returns the Protocol (Null if not set)
HasFileName (me) returns Boolean is static;
---Purpose : Returns True if a non empty file name has been defined
FileName (me) returns CString is static;
---Purpose : Returns File Name (can be empty)
Control (me) returns CopyControl is static;
---Purpose : Returns the map for a direct use, if required
IsForNone (me) returns Boolean is static;
---Purpose : Returns True if Select has determined that a Modifier may not
-- be run (filter defined and empty)
IsForAll (me) returns Boolean is static;
---Purpose : Returns True if no filter is defined : a Modifier has to work
-- on all entities of the resulting (target) model
IsTransferred (me; ent : Transient) returns Boolean is static;
---Purpose : Returns True if a starting item has been transferred
IsSelected (me; ent : Transient) returns Boolean is static;
---Purpose : Returns True if a starting item has been transferred and selected
Search (me; ent : Transient; res : out any Transient)
returns Boolean is static;
---Purpose : Returns True if a starting entity has been transferred, and
-- the result is in <res>. Returns False else
-- (direct call to the map)
SelectedOriginal (me) returns EntityIterator is static;
---Purpose : Returns the list of original selected items.
-- See also the iteration
SelectedResult (me) returns EntityIterator is static;
---Purpose : Returns the list of resulting counterparts of selected items.
-- See also the iteration
SelectedCount (me) returns Integer is static;
---Purpose : Returns the count of selected and transferred items
Start (me : in out) is static;
---Purpose : Starts an iteration on selected items. It takes into account
-- IsForAll/IsForNone, by really iterating on all selected items.
More (me) returns Boolean is static;
---Purpose : Returns True until the iteration has finished
Next (me : in out) is static;
---Purpose : Advances the iteration
ValueOriginal (me) returns Transient raises NoSuchObject is static;
---Purpose : Returns the current selected item in the original model
ValueResult (me) returns any Transient raises NoSuchObject is static;
---Purpose : Returns the result counterpart of current selected item
-- (in the target model)
TraceModifier (me : in out; modif : GeneralModifier) is static;
---Purpose : Traces the application of a Modifier. Works with default trace
-- File and Level. Fills the trace if default trace level is at
-- least 1. Traces the Modifier (its Label) and its Selection if
-- there is one (its Label).
-- To be called after Select (because status IsForAll is printed)
-- Worths to trace a global modification. See also Trace below
Trace (me : in out; mess : CString = "") is static;
---Purpose : Traces the modification of the current entity (see above,
-- ValueOriginal and ValueResult) for default trace level >= 2.
-- To be called on each indivudual entity really modified
-- <mess> is an optionnal additional message
AddCheck (me : in out; check : Check) is static;
---Purpose : Adds a Check to the CheckList. If it is empty, nothing is done
-- If it concerns an Entity from the Original Model (by SetEntity)
-- to which another Check is attached, it is merged to it.
-- Else, it is added or merged as to GlobalCheck.
AddWarning (me : in out; start : Transient; mess : CString; orig : CString = "");
---Purpose : Adds a Warning Message for an Entity from the original Model
-- If <start> is not an Entity from the original model (e.g. the
-- model itself) this message is added to Global Check.
AddFail (me : in out; start : Transient; mess : CString; orig : CString = "");
---Purpose : Adds a Fail Message for an Entity from the original Model
-- If <start> is not an Entity from the original model (e.g. the
-- model itself) this message is added to Global Check.
CCheck (me : in out; num : Integer = 0) returns Check;
---Purpose : Returns a Check given an Entity number (in the original Model)
-- by default a Global Check. Creates it the first time.
-- It can then be acknowledged on the spot, in condition that the
-- caller works by reference ("Interface_Check& check = ...")
CCheck (me : in out; start : Transient) returns Check;
---Purpose : Returns a Check attached to an Entity from the original Model
-- It can then be acknowledged on the spot, in condition that the
-- caller works by reference ("Interface_Check& check = ...")
CheckList (me) returns CheckIterator is static;
---Purpose : Returns the complete CheckList
fields
thegraf : Graph;
theprot : Protocol from Interface;
themap : CopyControl;
thefile : AsciiString;
thelist : AsciiString;
thechek : CheckIterator;
thesel : Boolean;
thecurr : Integer;
thecurt : Integer;
end ContextModif;

View File

@@ -0,0 +1,442 @@
#include <IFSelect_ContextModif.ixx>
#include <IFSelect_Selection.hxx>
#include <Message_Messenger.hxx>
#include <Message.hxx>
#include <Standard_NoSuchObject.hxx>
//=======================================================================
//function : IFSelect_ContextModif
//purpose :
//=======================================================================
IFSelect_ContextModif::IFSelect_ContextModif(const Interface_Graph& graph,
const Interface_CopyTool& TC,
const Standard_CString filename)
: thegraf (graph,Standard_False) , thefile (filename) ,
thelist (graph.Size(),' ')
{
themap = TC.Control(); thesel = Standard_False; thecurr = thecurt = 0;
Standard_Integer nb = thelist.Length();
Handle(Standard_Transient) newent;
for (Standard_Integer i = 1; i <= nb; i ++) {
if (themap->Search(graph.Entity(i),newent)) thelist.SetValue(i,'1');
}
}
//=======================================================================
//function : IFSelect_ContextModif
//purpose :
//=======================================================================
IFSelect_ContextModif::IFSelect_ContextModif(const Interface_Graph& graph,
const Standard_CString filename)
: thegraf (graph,Standard_False) , thefile (filename) ,
thelist (graph.Size(),' ')
{
thesel = Standard_False; thecurr = thecurt = 0;
Standard_Integer nb = thelist.Length();
Handle(Standard_Transient) newent;
for (Standard_Integer i = 1; i <= nb; i ++) thelist.SetValue(i,'1');
}
//=======================================================================
//function : Select
//purpose :
//=======================================================================
void IFSelect_ContextModif::Select (Interface_EntityIterator& list)
{
thesel = Standard_True;
Standard_Integer nb = thelist.Length();
for (Standard_Integer i = 1; i <= nb; i ++) thelist.SetValue(i,' ');
for (list.Start(); list.More(); list.Next()) {
Handle(Standard_Transient) start,newent;
start = list.Value();
Standard_Integer num = thegraf.EntityNumber(start);
if (num > nb || num < 0) num = 0;
if (themap.IsNull() && num > 0) thelist.SetValue(num,'1');
else if (themap->Search (start,newent)) {
if (num > 0) thelist.SetValue(num,'1');
}
}
}
//=======================================================================
//function : OriginalGraph
//purpose :
//=======================================================================
const Interface_Graph& IFSelect_ContextModif::OriginalGraph () const
{
return thegraf;
}
//=======================================================================
//function : OriginalModel
//purpose :
//=======================================================================
Handle(Interface_InterfaceModel) IFSelect_ContextModif::OriginalModel() const
{
return thegraf.Model();
}
//=======================================================================
//function : SetProtocol
//purpose :
//=======================================================================
void IFSelect_ContextModif::SetProtocol(const Handle(Interface_Protocol)& prot)
{
theprot = prot;
}
//=======================================================================
//function : Protocol
//purpose :
//=======================================================================
Handle(Interface_Protocol) IFSelect_ContextModif::Protocol() const
{
return theprot;
}
//=======================================================================
//function : HasFileName
//purpose :
//=======================================================================
Standard_Boolean IFSelect_ContextModif::HasFileName() const
{
return (thefile.Length() > 0);
}
//=======================================================================
//function : FileName
//purpose :
//=======================================================================
Standard_CString IFSelect_ContextModif::FileName () const
{
return thefile.ToCString();
}
//=======================================================================
//function : Control
//purpose :
//=======================================================================
Handle(Interface_CopyControl) IFSelect_ContextModif::Control () const
{
return themap;
}
//=======================================================================
//function : IsForNone
//purpose :
//=======================================================================
Standard_Boolean IFSelect_ContextModif::IsForNone () const
{
if (!thesel) return Standard_False;
Standard_Integer nb = thelist.Length();
for (Standard_Integer i = 1; i <= nb; i ++) {
if (thelist.Value(i) != ' ') return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : IsForAll
//purpose :
//=======================================================================
Standard_Boolean IFSelect_ContextModif::IsForAll () const
{
return (!thesel);
}
//=======================================================================
//function : IsTransferred
//purpose :
//=======================================================================
Standard_Boolean IFSelect_ContextModif::IsTransferred
(const Handle(Standard_Transient)& ent) const
{
if (themap.IsNull()) return Standard_True;
Handle(Standard_Transient) newent;
return themap->Search(ent,newent);
}
//=======================================================================
//function : IsSelected
//purpose :
//=======================================================================
Standard_Boolean IFSelect_ContextModif::IsSelected
(const Handle(Standard_Transient)& ent) const
{
// Select a deja verifie "IsTransferred"
Standard_Integer num = thegraf.EntityNumber(ent);
if (num == 0) return Standard_False;
return (thelist.Value(num) != ' ');
}
//=======================================================================
//function : SelectedOriginal
//purpose :
//=======================================================================
Interface_EntityIterator IFSelect_ContextModif::SelectedOriginal () const
{
Interface_EntityIterator list;
Standard_Integer nb = thelist.Length();
for (Standard_Integer i = 1; i <= nb; i ++) {
if (thelist.Value(i) != ' ') list.GetOneItem (thegraf.Entity(i));
}
return list;
}
//=======================================================================
//function : SelectedResult
//purpose :
//=======================================================================
Interface_EntityIterator IFSelect_ContextModif::SelectedResult () const
{
Interface_EntityIterator list;
Standard_Integer nb = thelist.Length();
for (Standard_Integer i = 1; i <= nb; i ++) {
Handle(Standard_Transient) newent;
if (themap.IsNull()) newent = thegraf.Entity(i);
else if (thelist.Value(i) != ' ') themap->Search (thegraf.Entity(i),newent);
if (!newent.IsNull()) list.GetOneItem (newent);
}
return list;
}
//=======================================================================
//function : SelectedCount
//purpose :
//=======================================================================
Standard_Integer IFSelect_ContextModif::SelectedCount () const
{
Standard_Integer nb = thelist.Length();
Standard_Integer ns = 0;
for (Standard_Integer i = 1; i <= nb; i ++)
{ if (thelist.Value(i) != ' ') ns ++; }
return ns;
}
//=======================================================================
//function : Start
//purpose :
//=======================================================================
void IFSelect_ContextModif::Start ()
{
thecurr = thecurt = 0;
Next();
}
//=======================================================================
//function : More
//purpose :
//=======================================================================
Standard_Boolean IFSelect_ContextModif::More () const
{
return (thecurr > 0);
}
//=======================================================================
//function : Next
//purpose :
//=======================================================================
void IFSelect_ContextModif::Next()
{
Standard_Integer nb = thelist.Length();
// thecurr = thecurt;
// if (thecurr <= 0 && thecurt >= 0) return;
for (Standard_Integer i = thecurr+1; i <= nb; i ++) {
if (thelist.Value(i) != ' ') { thecurr = i; thecurt ++; return; }
}
thecurr = thecurt = 0;
}
//=======================================================================
//function : ValueOriginal
//purpose :
//=======================================================================
Handle(Standard_Transient) IFSelect_ContextModif::ValueOriginal () const
{
if (thecurr <= 0) Standard_NoSuchObject::Raise("IFSelect_ContextModif");
return thegraf.Entity(thecurr);
}
//=======================================================================
//function : ValueResult
//purpose :
//=======================================================================
Handle(Standard_Transient) IFSelect_ContextModif::ValueResult () const
{
if (thecurr <= 0) Standard_NoSuchObject::Raise("IFSelect_ContextModif");
Handle(Standard_Transient) ent,newent;
ent = thegraf.Entity(thecurr);
if (themap.IsNull()) newent = ent;
else themap->Search(ent,newent);
return newent;
}
//=======================================================================
//function : TraceModifier
//purpose :
//=======================================================================
void IFSelect_ContextModif::TraceModifier
(const Handle(IFSelect_GeneralModifier)& modif)
{
if (modif.IsNull()) return;
Handle(Message_Messenger) sout = Message::DefaultMessenger();
sout << "--- Run Modifier:" << endl;
Handle(IFSelect_Selection) sel = modif->Selection();
if (!sel.IsNull()) sout<<" Selection:"<<sel->Label();
else sout<<" (no Selection)";
// on va simplement compter les entites
Standard_Integer ne = 0, nb = thelist.Length();
for (Standard_Integer i = 1; i <= nb; i ++) {
if (thelist.Value(i) != ' ') ne ++;
}
if (nb == ne) sout<<" All Model ("<<nb<<" Entities)"<<endl;
else sout<<" Entities,Total:"<<nb<<" Concerned:"<<ne<<endl;
}
//=======================================================================
//function : Trace
//purpose :
//=======================================================================
void IFSelect_ContextModif::Trace (const Standard_CString mess)
{
// Trace courante
if (thecurr <= 0) return;
Handle(Message_Messenger) sout = Message::DefaultMessenger();
if (ValueOriginal() == ValueResult())
sout<<"-- ContextModif. Entity n0 "<<thecurr<<endl;
else
sout<<"-- ContextModif. Entity in Original, n0 "<<thecurr<<" in Result, n0 "
<<thecurt<<endl;
if (mess[0] != '\0') sout<<"-- Message:"<<mess<<endl;
}
//=======================================================================
//function : AddCheck
//purpose :
//=======================================================================
void IFSelect_ContextModif::AddCheck(const Handle(Interface_Check)& check)
{
if (check->NbFails() + check->NbWarnings() == 0) return;
const Handle(Standard_Transient)& ent = check->Entity();
Standard_Integer num = thegraf.EntityNumber(ent);
if (num == 0 && !ent.IsNull()) num = -1; // force enregistrement
thechek.Add(check,num);
}
//=======================================================================
//function : AddWarning
//purpose :
//=======================================================================
void IFSelect_ContextModif::AddWarning(const Handle(Standard_Transient)& start,
const Standard_CString mess,
const Standard_CString orig)
{
thechek.CCheck(thegraf.EntityNumber(start))->AddWarning(mess,orig);
}
//=======================================================================
//function : AddFail
//purpose :
//=======================================================================
void IFSelect_ContextModif::AddFail(const Handle(Standard_Transient)& start,
const Standard_CString mess,
const Standard_CString orig)
{
thechek.CCheck(thegraf.EntityNumber(start))->AddFail(mess,orig);
}
//=======================================================================
//function : CCheck
//purpose :
//=======================================================================
Handle(Interface_Check) IFSelect_ContextModif::CCheck(const Standard_Integer num)
{
Handle(Interface_Check) ach = thechek.CCheck(num);
if (num > 0 && num <= thegraf.Size()) ach->SetEntity(thegraf.Entity(num));
return ach;
}
//=======================================================================
//function : CCheck
//purpose :
//=======================================================================
Handle(Interface_Check) IFSelect_ContextModif::CCheck
(const Handle(Standard_Transient)& ent)
{
Standard_Integer num = thegraf.EntityNumber(ent);
if (num == 0) num = -1; // force l enregistrement
Handle(Interface_Check)& ach = thechek.CCheck(num);
ach->SetEntity(ent);
return ach;
}
//=======================================================================
//function : CheckList
//purpose :
//=======================================================================
Interface_CheckIterator IFSelect_ContextModif::CheckList () const
{
return thechek;
}

View File

@@ -0,0 +1,148 @@
-- File: IFSelect_ContextWrite.cdl
-- Created: Fri Jan 26 13:20:13 1996
-- Author: Christian CAILLET
-- <cky@fidox>
---Copyright: Matra Datavision 1996
class ContextWrite from IFSelect
---Purpose : This class gathers various informations used by File Modifiers
-- apart from the writer object, which is specific of the norm
-- and of the physical format
--
-- These informations are controlled by an object AppliedModifiers
-- (if it is not defined, no modification is allowed on writing)
--
-- Furthermore, in return, ContextModif can record Checks, either
-- one for all, or one for each Entity. It supports trace too.
uses Transient, CString, AsciiString from TCollection,
InterfaceModel, EntityIterator, Graph, HGraph,
Protocol from Interface, Check, CheckIterator, GeneralModifier,
AppliedModifiers
raises NoSuchObject
is
Create (model : InterfaceModel; proto : Protocol;
applieds : mutable AppliedModifiers; filename : CString)
returns ContextWrite;
---Purpose : Prepares a ContextWrite with these informations :
-- - the model which is to be written
-- - the protocol to be used
-- - the filename
-- - an object AppliedModifiers to work. It gives a list of
-- FileModifiers to be ran, and for each one it can give
-- a restricted list of entities (in the model), else all
-- the model is considered
Create (hgraph : HGraph; proto : Protocol;
applieds : mutable AppliedModifiers; filename : CString)
returns ContextWrite;
---Purpose : Same as above but with an already computed Graph
Model (me) returns InterfaceModel;
---Purpose : Returns the Model
Protocol (me) returns Protocol;
---Purpose : Returns the Protocol;
FileName (me) returns CString;
---Purpose : Returns the File Name
AppliedModifiers (me) returns mutable AppliedModifiers;
---Purpose : Returns the object AppliedModifiers
Graph (me : in out) returns Graph;
---Purpose : Returns the Graph, either given when created, else created
-- the first time it is queried
---C++ : return const &
-- -- Control when running -- --
NbModifiers (me) returns Integer;
---Purpose : Returns the count of recorded File Modifiers
SetModifier (me : in out; numod : Integer) returns Boolean;
---Purpose : Sets active the File Modifier n0 <numod>
-- Then, it prepares the list of entities to consider, if any
-- Returns False if <numod> out of range
FileModifier (me) returns mutable GeneralModifier;
---Purpose : Returns the currently active File Modifier. Cast to be done
-- Null if not properly set : must be test IsNull after casting
IsForNone (me) returns Boolean;
---Purpose : Returns True if no modifier is currently set
IsForAll (me) returns Boolean;
---Purpose : Returns True if the current modifier is to be applied to
-- the whole model. Else, a restricted list of selected entities
-- is defined, it can be exploited by the File Modifier
NbEntities (me) returns Integer;
---Purpose : Returns the total count of selected entities
Start (me : in out);
---Purpose : Starts an iteration on selected items. It takes into account
-- IsForAll/IsForNone, by really iterating on all selected items.
More (me) returns Boolean;
---Purpose : Returns True until the iteration has finished
Next (me : in out);
---Purpose : Advances the iteration
Value (me) returns Transient raises NoSuchObject;
---Purpose : Returns the current selected entity in the model
-- -- Trace and Check -- --
AddCheck (me : in out; check : Check) is static;
---Purpose : Adds a Check to the CheckList. If it is empty, nothing is done
-- If it concerns an Entity from the Model (by SetEntity)
-- to which another Check is attached, it is merged to it.
-- Else, it is added or merged as to GlobalCheck.
AddWarning (me : in out; start : Transient; mess : CString; orig : CString = "");
---Purpose : Adds a Warning Message for an Entity from the Model
-- If <start> is not an Entity from the model (e.g. the
-- model itself) this message is added to Global Check.
AddFail (me : in out; start : Transient; mess : CString; orig : CString = "");
---Purpose : Adds a Fail Message for an Entity from the Model
-- If <start> is not an Entity from the model (e.g. the
-- model itself) this message is added to Global Check.
CCheck (me : in out; num : Integer = 0) returns Check;
---Purpose : Returns a Check given an Entity number (in the Model)
-- by default a Global Check. Creates it the first time.
-- It can then be acknowledged on the spot, in condition that the
-- caller works by reference ("Interface_Check& check = ...")
CCheck (me : in out; start : Transient) returns Check;
---Purpose : Returns a Check attached to an Entity from the Model
-- It can then be acknowledged on the spot, in condition that the
-- caller works by reference ("Interface_Check& check = ...")
CheckList (me) returns CheckIterator is static;
---Purpose : Returns the complete CheckList
fields
themodel : InterfaceModel;
theproto : Protocol;
thefile : AsciiString;
theapply : AppliedModifiers;
thehgraf : HGraph;
thecheck : CheckIterator;
thenumod : Integer;
thenbent : Integer;
thecurr : Integer;
themodif : GeneralModifier;
end ContextWrite;

View File

@@ -0,0 +1,277 @@
#include <IFSelect_ContextWrite.ixx>
#include <Standard_NoSuchObject.hxx>
//=======================================================================
//function : IFSelect_ContextWrite
//purpose :
//=======================================================================
IFSelect_ContextWrite::IFSelect_ContextWrite
(const Handle(Interface_InterfaceModel)& model,
const Handle(Interface_Protocol)& proto,
const Handle(IFSelect_AppliedModifiers)& applieds,
const Standard_CString filename)
: themodel (model) , theproto (proto) , thefile (filename) ,
theapply (applieds) , thenumod(0) , thenbent (0) , thecurr (0) { }
//=======================================================================
//function : IFSelect_ContextWrite
//purpose :
//=======================================================================
IFSelect_ContextWrite::IFSelect_ContextWrite
(const Handle(Interface_HGraph)& hgraph,
const Handle(Interface_Protocol)& proto,
const Handle(IFSelect_AppliedModifiers)& applieds,
const Standard_CString filename)
: themodel (hgraph->Graph().Model()) ,
theproto (proto) , thefile (filename) , theapply (applieds) ,
thehgraf (hgraph) , thenumod(0) , thenbent (0) , thecurr (0) { }
//=======================================================================
//function : Model
//purpose :
//=======================================================================
Handle(Interface_InterfaceModel) IFSelect_ContextWrite::Model () const
{
return themodel;
}
//=======================================================================
//function : Protocol
//purpose :
//=======================================================================
Handle(Interface_Protocol) IFSelect_ContextWrite::Protocol () const
{
return theproto;
}
//=======================================================================
//function : FileName
//purpose :
//=======================================================================
Standard_CString IFSelect_ContextWrite::FileName () const
{
return thefile.ToCString();
}
//=======================================================================
//function : AppliedModifiers
//purpose :
//=======================================================================
Handle(IFSelect_AppliedModifiers) IFSelect_ContextWrite::AppliedModifiers () const
{
return theapply;
}
//=======================================================================
//function : Graph
//purpose :
//=======================================================================
const Interface_Graph& IFSelect_ContextWrite::Graph ()
{
if (thehgraf.IsNull()) thehgraf = new Interface_HGraph(themodel,theproto);
return thehgraf->Graph();
}
//=======================================================================
//function : NbModifiers
//purpose :
//=======================================================================
Standard_Integer IFSelect_ContextWrite::NbModifiers () const
{ return (theapply.IsNull() ? 0 : theapply->Count()); }
Standard_Boolean IFSelect_ContextWrite::SetModifier
(const Standard_Integer numod)
{
themodif.Nullify(); thenumod = thenbent = thecurr = 0;
if (theapply.IsNull()) return Standard_False;
if (numod < 1 || numod > theapply->Count()) return Standard_False;
theapply->Item(numod,themodif,thenbent);
return Standard_True;
}
//=======================================================================
//function : FileModifier
//purpose :
//=======================================================================
Handle(IFSelect_GeneralModifier) IFSelect_ContextWrite::FileModifier () const
{
return themodif;
}
//=======================================================================
//function : IsForNone
//purpose :
//=======================================================================
Standard_Boolean IFSelect_ContextWrite::IsForNone () const
{
return (thenbent == 0);
}
//=======================================================================
//function : IsForAll
//purpose :
//=======================================================================
Standard_Boolean IFSelect_ContextWrite::IsForAll () const
{
return theapply->IsForAll();
}
//=======================================================================
//function : NbEntities
//purpose :
//=======================================================================
Standard_Integer IFSelect_ContextWrite::NbEntities () const
{
return thenbent;
}
//=======================================================================
//function : Start
//purpose :
//=======================================================================
void IFSelect_ContextWrite::Start ()
{
thecurr = 1;
}
//=======================================================================
//function : More
//purpose :
//=======================================================================
Standard_Boolean IFSelect_ContextWrite::More () const
{
return (thecurr <= thenbent);
}
//=======================================================================
//function : Next
//purpose :
//=======================================================================
void IFSelect_ContextWrite::Next ()
{
thecurr ++;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
Handle(Standard_Transient) IFSelect_ContextWrite::Value() const
{
if (thecurr < 1 || thecurr > thenbent)
Standard_NoSuchObject::Raise("IFSelect_ContextWrite:Value");
Standard_Integer num = theapply->ItemNum (thecurr);
return themodel->Value(num);
}
//=======================================================================
//function : AddCheck
//purpose :
//=======================================================================
void IFSelect_ContextWrite::AddCheck (const Handle(Interface_Check)& check)
{
if (check->NbFails() + check->NbWarnings() == 0) return;
const Handle(Standard_Transient)& ent = check->Entity();
Standard_Integer num = themodel->Number(ent);
if (num == 0 && !ent.IsNull()) num = -1; // force enregistrement
thecheck.Add(check,num);
}
//=======================================================================
//function : AddWarning
//purpose :
//=======================================================================
void IFSelect_ContextWrite::AddWarning(const Handle(Standard_Transient)& start,
const Standard_CString mess,
const Standard_CString orig)
{
thecheck.CCheck(themodel->Number(start))->AddWarning(mess,orig);
}
//=======================================================================
//function : AddFail
//purpose :
//=======================================================================
void IFSelect_ContextWrite::AddFail(const Handle(Standard_Transient)& start,
const Standard_CString mess,
const Standard_CString orig)
{
thecheck.CCheck(themodel->Number(start))->AddFail(mess,orig);
}
//=======================================================================
//function : CCheck
//purpose :
//=======================================================================
Handle(Interface_Check) IFSelect_ContextWrite::CCheck (const Standard_Integer num)
{
Handle(Interface_Check) ach = thecheck.CCheck(num);
if (num > 0 && num <= themodel->NbEntities()) ach->SetEntity(themodel->Value(num));
return ach;
}
//=======================================================================
//function : CCheck
//purpose :
//=======================================================================
Handle(Interface_Check) IFSelect_ContextWrite::CCheck(const Handle(Standard_Transient)& ent)
{
Standard_Integer num = themodel->Number(ent);
if (num == 0) num = -1; // force l enregistrement
Handle(Interface_Check) ach = thecheck.CCheck(num);
ach->SetEntity(ent);
return ach;
}
//=======================================================================
//function : CheckList
//purpose :
//=======================================================================
Interface_CheckIterator IFSelect_ContextWrite::CheckList () const
{
return thecheck;
}

View File

@@ -0,0 +1,38 @@
-- File: DispGlobal.cdl
-- Created: Tue Nov 17 18:30:59 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
class DispGlobal from IFSelect inherits Dispatch
---Purpose : A DispGlobal gathers all the input Entities into only one
-- global Packet
uses AsciiString from TCollection, Graph, SubPartsIterator
is
Create returns mutable DispGlobal;
---Purpose : Creates a DispGlobal
Label (me) returns AsciiString from TCollection;
---Purpose : Returns as Label, "One File for all Input"
-- -- Evaluation -- --
LimitedMax (me; nbent : Integer; max : out Integer) returns Boolean
is redefined;
---Purpose : Returns True : maximum equates 1
PacketsCount (me; G : Graph; count : out Integer) returns Boolean
is redefined;
---Purpose : Returns True (count of packets is well known) and count is 1
Packets (me; G : Graph; packs : in out SubPartsIterator);
---Purpose : Computes the list of produced Packets. It is made of only ONE
-- Packet, which gets the RootResult from the Final Selection.
-- Remark : the inherited exception raising is never activated.
end DispGlobal;

View File

@@ -0,0 +1,27 @@
#include <IFSelect_DispGlobal.ixx>
#include <IFSelect_Selection.hxx>
#include <Interface_EntityIterator.hxx>
// Genere un seul paquet avec la sortie finale
IFSelect_DispGlobal::IFSelect_DispGlobal () { }
TCollection_AsciiString IFSelect_DispGlobal::Label () const
{ return TCollection_AsciiString ("One File for All Input"); }
Standard_Boolean IFSelect_DispGlobal::LimitedMax
(const Standard_Integer /* nbent */, Standard_Integer& pcount) const
{ pcount = 1; return Standard_True; }
Standard_Boolean IFSelect_DispGlobal::PacketsCount
(const Interface_Graph& /* G */, Standard_Integer& pcount) const
{ pcount = 1; return Standard_True; }
// 1 packet ( a partir de UniqueResult)
void IFSelect_DispGlobal::Packets
(const Interface_Graph& G, IFGraph_SubPartsIterator& packs) const
{
packs.AddPart();
packs.GetFromIter(FinalSelection()->UniqueResult(G));
}

View File

@@ -0,0 +1,58 @@
-- File: DispPerCount.cdl
-- Created: Tue Nov 17 18:38:45 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
class DispPerCount from IFSelect inherits Dispatch
---Purpose : A DispPerCount gathers all the input Entities into one or
-- several Packets, each containing a defined count of Entity
-- This count is a Parameter of the DispPerCount, given as an
-- IntParam, thus allowing external control of its Value
uses AsciiString from TCollection, Graph, SubPartsIterator, IntParam
raises InterfaceError
is
Create returns mutable DispPerCount;
---Purpose : Creates a DispPerCount with no Count (default value 1)
Count (me) returns mutable IntParam;
---Purpose : Returns the Count Parameter used for splitting
SetCount (me : mutable; count : mutable IntParam);
---Purpose : Sets a new Parameter for Count
CountValue (me) returns Integer;
---Purpose : Returns the effective value of the count parameter
-- (if Count Parameter not Set or value not positive, returns 1)
Label (me) returns AsciiString from TCollection;
---Purpose : Returns as Label, "One File per <count> Input Entities"
-- -- Evaluation -- --
LimitedMax (me; nbent : Integer; max : out Integer) returns Boolean
is redefined;
---Purpose : Returns True, maximum count is given as <nbent>
PacketsCount (me; G : Graph; count : out Integer) returns Boolean
is redefined;
---Purpose : Returns True (count is easy to know) and count is computed
-- from length of input list (RootResult from Final Selection)
Packets (me; G : Graph; packs : in out SubPartsIterator)
raises InterfaceError;
---Purpose : Computes the list of produced Packets. It defines Packets in
-- order to have at most <Count> Entities per Packet, Entities
-- are given by RootResult from the Final Selection.
fields
thecount : IntParam;
end DispPerCount;

View File

@@ -0,0 +1,64 @@
#include <IFSelect_DispPerCount.ixx>
#include <IFSelect_Selection.hxx>
#include <IFGraph_SCRoots.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Interface_EntityIterator.hxx>
IFSelect_DispPerCount::IFSelect_DispPerCount () { }
Handle(IFSelect_IntParam) IFSelect_DispPerCount::Count () const
{ return thecount; }
void IFSelect_DispPerCount::SetCount
(const Handle(IFSelect_IntParam)& pcount)
{ thecount = pcount; }
Standard_Integer IFSelect_DispPerCount::CountValue () const
{
Standard_Integer pcount = 0;
if (!thecount.IsNull()) pcount = thecount->Value();
if (pcount <= 0) pcount = 1; // option prise par defaut
return pcount;
}
TCollection_AsciiString IFSelect_DispPerCount::Label () const
{
TCollection_AsciiString lab(CountValue());
lab.Insert(1,"One File per ");
lab.AssignCat(" Entities");
return lab;
}
Standard_Boolean IFSelect_DispPerCount::LimitedMax
(const Standard_Integer nbent, Standard_Integer& pcount) const
{
pcount = 1 + nbent / CountValue();
return Standard_True;
}
Standard_Boolean IFSelect_DispPerCount::PacketsCount
(const Interface_Graph& G, Standard_Integer& /*count*/) const
{ return 1 + G.Size() / CountValue(); }
void IFSelect_DispPerCount::Packets
(const Interface_Graph& G, IFGraph_SubPartsIterator& packs) const
{
// Ressemble a DispPerOne, mais fait un AddPart tous les "count" racines
Standard_Integer pcount = CountValue();
IFGraph_SCRoots roots(G,Standard_False);
roots.SetLoad();
roots.GetFromIter(FinalSelection()->UniqueResult(G));
// SCRoots a initie la resolution : decoupage en StrongComponants + selection
// des racines. Un paquet correspond des lors a <count> racines
// Donc, il faut iterer sur les Parts de roots et les prendre par <count>
Standard_Integer i = 0;
for (roots.Start(); roots.More(); roots.Next()) {
if (i == 0) packs.AddPart();
i ++; if (i >= pcount) i = 0; // regroupement selon "count"
packs.GetFromIter(roots.Entities());
}
}

View File

@@ -0,0 +1,62 @@
-- File: IFSelect_DispPerFiles.cdl
-- Created: Wed Dec 21 10:58:04 1994
-- Author: Christian CAILLET
-- <cky@anion>
---Copyright: Matra Datavision 1994
class DispPerFiles from IFSelect inherits Dispatch
---Purpose : A DispPerFiles produces a determined count of Packets from the
-- input Entities. It divides, as equally as possible, the input
-- list into a count of files. This count is the parameter of the
-- DispPerFiles. If the input list has less than this count, of
-- course there will be one packet per input entity.
-- This count is a Parameter of the DispPerFiles, given as an
-- IntParam, thus allowing external control of its Value
uses AsciiString from TCollection, Graph, SubPartsIterator, IntParam
raises InterfaceError
is
Create returns mutable DispPerFiles;
---Purpose : Creates a DispPerFiles with no Count (default value 1 file)
Count (me) returns mutable IntParam;
---Purpose : Returns the Count Parameter used for splitting
SetCount (me : mutable; count : mutable IntParam);
---Purpose : Sets a new Parameter for Count
CountValue (me) returns Integer;
---Purpose : Returns the effective value of the count parameter
-- (if Count Parameter not Set or value not positive, returns 1)
Label (me) returns AsciiString from TCollection;
---Purpose : Returns as Label, "Maximum <count> Files"
-- -- Evaluation -- --
LimitedMax (me; nbent : Integer; max : out Integer) returns Boolean
is redefined;
---Purpose : Returns True, maximum count is given as CountValue
PacketsCount (me; G : Graph; count : out Integer) returns Boolean
is redefined;
---Purpose : Returns True (count is easy to know) and count is the minimum
-- value between length of input list and CountValue
Packets (me; G : Graph; packs : in out SubPartsIterator)
raises InterfaceError;
---Purpose : Computes the list of produced Packets. It defines Packets in
-- order to have <Count> Packets, except if the input count of
-- Entities is lower. Entities are given by RootResult from the
-- Final Selection.
fields
thecount : IntParam;
end DispPerFiles;

View File

@@ -0,0 +1,67 @@
#include <IFSelect_DispPerFiles.ixx>
#include <IFSelect_Selection.hxx>
#include <IFGraph_SCRoots.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Interface_EntityIterator.hxx>
IFSelect_DispPerFiles::IFSelect_DispPerFiles () { }
Handle(IFSelect_IntParam) IFSelect_DispPerFiles::Count () const
{ return thecount; }
void IFSelect_DispPerFiles::SetCount
(const Handle(IFSelect_IntParam)& pcount)
{ thecount = pcount; }
Standard_Integer IFSelect_DispPerFiles::CountValue () const
{
Standard_Integer pcount = 0;
if (!thecount.IsNull()) pcount = thecount->Value();
if (pcount <= 0) pcount = 1; // option prise par defaut
return pcount;
}
TCollection_AsciiString IFSelect_DispPerFiles::Label () const
{
TCollection_AsciiString lab(CountValue());
lab.Insert(1,"Maximum ");
lab.AssignCat(" Files");
return lab;
}
Standard_Boolean IFSelect_DispPerFiles::LimitedMax
(const Standard_Integer /* nbent */, Standard_Integer& pcount) const
{
pcount = CountValue();
return Standard_True;
}
Standard_Boolean IFSelect_DispPerFiles::PacketsCount
(const Interface_Graph& G, Standard_Integer& /*count*/) const
{ return (G.Size() < CountValue() ? G.Size() : CountValue()); }
void IFSelect_DispPerFiles::Packets
(const Interface_Graph& G, IFGraph_SubPartsIterator& packs) const
{
// Ressemble a DispPerOne, mais fait "count" AddPart racines
Standard_Integer pcount = CountValue();
IFGraph_SCRoots roots(G,Standard_False);
roots.SetLoad();
roots.GetFromIter(FinalSelection()->UniqueResult(G));
// SCRoots a initie la resolution : decoupage en StrongComponants + selection
// des racines. Un paquet correspond des lors a <count> racines
// Donc, il faut iterer sur les Parts de roots et les prendre par <count>
roots.Start(); // Start fait Evaluate specifique
Standard_Integer nb = roots.NbParts();
if (pcount > 0) pcount = (nb-1) / pcount +1; // par packet
Standard_Integer i = 0;
for (; roots.More(); roots.Next()) { // Start deja fait
if (i == 0) packs.AddPart();
i ++; if (i >= pcount) i = 0; // regroupement selon "count"
packs.GetFromIter(roots.Entities());
}
}

View File

@@ -0,0 +1,39 @@
-- File: DispPerOne.cdl
-- Created: Tue Nov 17 18:35:40 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
class DispPerOne from IFSelect inherits Dispatch
---Purpose : A DispPerOne gathers all the input Entities into as many
-- Packets as there Root Entities from the Final Selection,
-- that is, one Packet per Entity
uses AsciiString from TCollection, Graph, SubPartsIterator
is
Create returns mutable DispPerOne;
---Purpose : Creates a DispPerOne
Label (me) returns AsciiString from TCollection;
---Purpose : Returns as Label, "One File per Input Entity"
-- -- Evaluation -- --
LimitedMax (me; nbent : Integer; max : out Integer) returns Boolean
is redefined;
---Purpose : Returns True, maximum limit is given as <nbent>
PacketsCount (me; G : Graph; count : out Integer) returns Boolean
is redefined;
---Purpose : Returns True (count is easy to know) and count is the length
-- of the input list (RootResult from FinalSelection)
Packets (me; G : Graph; packs : in out SubPartsIterator);
---Purpose : Returns the list of produced Packets. It defines one Packet
-- per Entity given by RootResult from the Final Selection.
end DispPerOne;

View File

@@ -0,0 +1,34 @@
#include <IFSelect_DispPerOne.ixx>
#include <IFSelect_Selection.hxx>
#include <IFGraph_SCRoots.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Interface_EntityIterator.hxx>
// Genere un paquet par racine (strong comp.) locale a la liste transmise
IFSelect_DispPerOne::IFSelect_DispPerOne () { }
TCollection_AsciiString IFSelect_DispPerOne::Label () const
{ return TCollection_AsciiString ("One File per Input Entity"); }
Standard_Boolean IFSelect_DispPerOne::LimitedMax
(const Standard_Integer nbent, Standard_Integer& pcount) const
{ pcount = nbent; return Standard_True; }
Standard_Boolean IFSelect_DispPerOne::PacketsCount
(const Interface_Graph& G, Standard_Integer& pcount) const
{ pcount = G.Size(); return Standard_True; }
void IFSelect_DispPerOne::Packets
(const Interface_Graph& G, IFGraph_SubPartsIterator& packs) const
{
IFGraph_SCRoots packsc(G,Standard_False); // OK pour SubPartsIterator
packsc.SetLoad();
packsc.GetFromIter(FinalSelection()->UniqueResult(G));
// SCRoots a initie la resolution : decoupage en StrongComponants + selection
// des Racines. Chaque Racine correspond a un Packet. CQFD
packs.GetParts(packsc);
}

View File

@@ -0,0 +1,56 @@
-- File: IFSelect_DispPerSignature.cdl
-- Created: Wed Dec 21 10:41:37 1994
-- Author: Christian CAILLET
-- <cky@anion>
---Copyright: Matra Datavision 1994
class DispPerSignature from IFSelect inherits Dispatch
---Purpose : A DispPerSignature sorts input Entities according to a
-- Signature : it works with a SignCounter to do this.
uses AsciiString from TCollection, Graph, SubPartsIterator, SignCounter
raises InterfaceError
is
Create returns mutable DispPerSignature;
---Purpose : Creates a DispPerSignature with no SignCounter (by default,
-- produces only one packet)
SignCounter (me) returns mutable SignCounter;
---Purpose : Returns the SignCounter used for splitting
SetSignCounter (me : mutable; sign : mutable SignCounter);
---Purpose : Sets a SignCounter for sort
-- Remark : it is set to record lists of entities, not only counts
SignName (me) returns CString;
---Purpose : Returns the name of the SignCounter, which caracterises the
-- sorting criterium for this Dispatch
Label (me) returns AsciiString from TCollection;
---Purpose : Returns as Label, "One File per Signature <name>"
-- -- Evaluation -- --
LimitedMax (me; nbent : Integer; max : out Integer) returns Boolean
is redefined;
---Purpose : Returns True, maximum count is given as <nbent>
-- PacketsCount (me; G : Graph; count : out Integer) returns Boolean
-- is not redefined : Packets must be first determined before counting
Packets (me; G : Graph; packs : in out SubPartsIterator)
raises InterfaceError;
---Purpose : Computes the list of produced Packets. It defines Packets from
-- the SignCounter, which sirts the input Entities per Signature
-- (specific of the SignCounter).
fields
thesign : SignCounter;
end DispPerSignature;

View File

@@ -0,0 +1,60 @@
#include <IFSelect_DispPerSignature.ixx>
#include <IFSelect_Selection.hxx>
#include <TColStd_HSequenceOfHAsciiString.hxx>
#include <TCollection_HAsciiString.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <Interface_EntityIterator.hxx>
#include <stdio.h>
IFSelect_DispPerSignature::IFSelect_DispPerSignature () { }
Handle(IFSelect_SignCounter) IFSelect_DispPerSignature::SignCounter () const
{ return thesign; }
void IFSelect_DispPerSignature::SetSignCounter
(const Handle(IFSelect_SignCounter)& sign)
{ thesign = sign; thesign->SetList (Standard_True); }
Standard_CString IFSelect_DispPerSignature::SignName () const
{ return (Standard_CString ) (thesign.IsNull() ? "???" : thesign->Name()); }
TCollection_AsciiString IFSelect_DispPerSignature::Label () const
{
char lab[50];
sprintf (lab,"One File per Signature %s",SignName());
return TCollection_AsciiString(lab);
}
Standard_Boolean IFSelect_DispPerSignature::LimitedMax
(const Standard_Integer nbent, Standard_Integer& max) const
{
max = nbent;
return Standard_True;
}
void IFSelect_DispPerSignature::Packets
(const Interface_Graph& G, IFGraph_SubPartsIterator& packs) const
{
if (thesign.IsNull()) {
packs.AddPart();
packs.GetFromIter (FinalSelection()->RootResult(G));
return;
}
thesign->Clear();
thesign->AddList (FinalSelection()->RootResult(G).Content(),G.Model());
Handle(TColStd_HSequenceOfHAsciiString) list = thesign->List();
Standard_Integer i,nb,is,nbs = list->Length();
Handle(TCollection_HAsciiString) asign;
Handle(TColStd_HSequenceOfTransient) ents;
for (is = 1; is <= nbs; is ++) {
asign = list->Value(is);
ents = thesign->Entities (asign->ToCString());
if (ents.IsNull()) continue;
packs.AddPart();
nb = ents->Length();
for (i = 1; i <= nb; i ++)
packs.GetFromEntity (ents->Value(i),Standard_False);
}
}

View File

@@ -0,0 +1,123 @@
-- File: Dispatch.cdl
-- Created: Tue Nov 17 14:27:26 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
deferred class Dispatch from IFSelect inherits TShared
---Purpose : This class allows to describe how a set of Entities has to be
-- dispatched into resulting Packets : a Packet is a sub-set of
-- the initial set of entities.
--
-- Thus, it can generate zero, one, or more Packets according
-- input set and criterium of dispatching. And it can let apart
-- some entities : it is the Remainder, which can be recovered
-- by a specific Selection (RemainderFromDispatch).
--
-- Depending of sub-classes, a Dispatch can potentially generate
-- a limited or not count of packet, and a remainder or none.
--
-- The input set is read from a specified Selection, attached to
-- the Dispatch : the Final Selection of the Dispatch. The input
-- is the Unique Root Entities list of the Final Selection
uses AsciiString from TCollection, HAsciiString from TCollection,
SubPartsIterator, EntityIterator,
Graph, Selection, SelectionIterator
raises InterfaceError
is
SetRootName (me : mutable; name : mutable HAsciiString);
---Purpose : Sets a Root Name as an HAsciiString
-- To reset it, give a Null Handle (then, a ShareOut will have
-- to define the Default Root Name)
HasRootName (me) returns Boolean;
---Purpose : Returns True if a specific Root Name has been set
-- (else, the Default Root Name has to be used)
RootName (me) returns any HAsciiString;
---Purpose : Returns the Root Name for files produced by this dispatch
-- It is empty if it has not been set or if it has been reset
---C++ : return const &
SetFinalSelection (me : mutable; sel : mutable Selection);
---Purpose : Stores (or Changes) the Final Selection for a Dispatch
FinalSelection (me) returns mutable Selection;
---Purpose : Returns the Final Selection of a Dispatch
-- we 'd like : C++ : return const &
Selections (me) returns SelectionIterator;
---Purpose : Returns the complete list of source Selections (starting
-- from FinalSelection)
CanHaveRemainder (me) returns Boolean is virtual;
---Purpose : Returns True if a Dispatch can have a Remainder, i.e. if its
-- criterium can let entities apart. It is a potential answer,
-- remainder can be empty at run-time even if answer is True.
-- (to attach a RemainderFromDispatch Selection is not allowed if
-- answer is True).
-- Default answer given here is False (can be redefined)
LimitedMax (me; nbent : Integer; max : out Integer) returns Boolean is virtual;
---Purpose : Returns True if a Dispatch generates a count of Packets always
-- less than or equal to a maximum value : it can be computed
-- from the total count of Entities to be dispatched : <nbent>.
-- If answer is False, no limited maximum is expected for account
-- If answer is True, expected maximum is given in argument <max>
-- Default answer given here is False (can be redefined)
Label (me) returns AsciiString from TCollection is deferred;
---Purpose : Returns a text which defines the way a Dispatch produces
-- packets (which will become files) from its Input
-- -- Evaluation -- --
GetEntities (me; G : Graph) returns EntityIterator;
---Purpose : Gets Unique Root Entities from the Final Selection, given an
-- input Graph
-- This the starting step for an Evaluation (Packets - Remainder)
PacketsCount (me; G : Graph; count : out Integer) returns Boolean is virtual;
---Purpose : Returns True if Count of Packets is actually known, and the
-- value of the count in argument "count". Returns False if
-- this count is unknown. Input is given as a Graph.
-- This method is intended to be quick (used for file names)
-- hence if this count is long to compute (that is, as a result
-- of complete evaluation made by method Packets), it is
-- preferable to answer "unknown" by returning False
-- Default answer if False. Can be redefined.
Packets (me; G : Graph; packs : in out SubPartsIterator)
raises InterfaceError is deferred;
---Purpose : Returns the list of produced Packets into argument <pack>.
-- Each Packet corresponds to a Part, the Entities listed are the
-- Roots given by the Selection. Input is given as a Graph.
-- Thus, to create a file from a packet, it suffices to take the
-- entities listed in a Part of Packets (that is, a Packet)
-- without worrying about Shared entities
-- This method can raise an Exception if data are not coherent
Packeted (me; G : Graph) returns EntityIterator;
---Purpose : Returns the list of all Input Entities (see GetEntities) which
-- are put in a Packet. That is, Entities listed in GetEntities
-- but not in Remainder (see below). Input is given as a Graph.
---See also : GetEntities, Remainder
Remainder (me; G : Graph) returns EntityIterator is virtual;
---Purpose : Returns Remainder which is a set of Entities. Can be empty.
-- Default evaluation is empty (has to be redefined if
-- CanHaveRemainder is redefined to return True).
fields
thename : HAsciiString;
thefinal : Selection;
end Dispatch;

View File

@@ -0,0 +1,65 @@
#include <IFSelect_Dispatch.ixx>
#include <IFGraph_Compare.hxx>
void IFSelect_Dispatch::SetRootName
(const Handle(TCollection_HAsciiString)& name)
{
thename = name;
}
Standard_Boolean IFSelect_Dispatch::HasRootName () const
{ return (!thename.IsNull()); }
const Handle(TCollection_HAsciiString)& IFSelect_Dispatch::RootName () const
{ return thename; }
void IFSelect_Dispatch::SetFinalSelection
(const Handle(IFSelect_Selection)& sel)
{ thefinal = sel; }
Handle(IFSelect_Selection) IFSelect_Dispatch::FinalSelection () const
{ return thefinal; }
IFSelect_SelectionIterator IFSelect_Dispatch::Selections () const
{
IFSelect_SelectionIterator iter;
iter.AddItem(thefinal);
for(; iter.More(); iter.Next()) {
iter.Value()->FillIterator(iter); // Iterateur qui se court apres
}
return iter;
}
Standard_Boolean IFSelect_Dispatch::CanHaveRemainder () const
{ return Standard_False; }
Standard_Boolean IFSelect_Dispatch::LimitedMax
(const Standard_Integer , Standard_Integer& max) const
{ max = 0; return Standard_False; }
Interface_EntityIterator IFSelect_Dispatch::GetEntities
(const Interface_Graph& G) const
{ return thefinal->UniqueResult(G); }
Standard_Boolean IFSelect_Dispatch::PacketsCount
(const Interface_Graph& , Standard_Integer& pcount) const
{ pcount = 0; return Standard_False; } // par defaut 0
Interface_EntityIterator IFSelect_Dispatch::Packeted
(const Interface_Graph& G) const
{
Interface_EntityIterator total = GetEntities(G);
Interface_EntityIterator remain = Remainder(G);
if (remain.NbEntities() == 0) return total;
// sinon, faire la difference !
IFGraph_Compare GC(G);
GC.GetFromIter (total, Standard_True);
GC.GetFromIter (remain,Standard_False);
return GC.FirstOnly();
}
Interface_EntityIterator IFSelect_Dispatch::Remainder
(const Interface_Graph& ) const
{ Interface_EntityIterator iter; return iter; } // par defaut vide

View File

@@ -0,0 +1,295 @@
-- File: IFSelect_EditForm.cdl
-- Created: Mon Feb 23 15:16:04 1998
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class EditForm from IFSelect inherits TShared
---Purpose : An EditForm is the way to apply an Editor on an Entity or on
-- the Model
-- It gives read-only or read-write access, with or without undo
--
-- It can be complete (all the values of the Editor are present)
-- or partial (a sub-list of these value are present)
-- Anyway, all references to Number (argument <num>) refer to
-- Number of Value for the Editor
-- While references to Rank are for rank in the EditForm, which
-- may differ if it is not Complete
-- Two methods give the correspondance between this Number and
-- the Rank in the EditForm : RankFromNumber and NumberFromRank
--
uses CString, Transient,
AsciiString from TCollection,
HAsciiString from TCollection,
Array1OfInteger from TColStd,
SequenceOfInteger from TColStd,
Array1OfTransient from TColStd,
HSequenceOfHAsciiString from TColStd,
Messenger from Message,
InterfaceModel from Interface,
Editor from IFSelect, ListEditor from IFSelect
is
Create (editor : Editor; readonly : Boolean; undoable : Boolean;
label : CString = "") returns EditForm;
---Purpose : Creates a complete EditForm from an Editor
-- A specific Label can be given
Create (editor : Editor; nums : SequenceOfInteger;
readonly : Boolean; undoable : Boolean;
label : CString = "") returns EditForm;
---Purpose : Creates an extracted EditForm from an Editor, limited to
-- the values identified in <nums>
-- A specific Label can be given
EditKeepStatus (me : mutable) returns Boolean;
---Purpose : Returns and may change the keep status on modif
-- It starts as False
-- If it is True, Apply does not clear modification status
-- and the EditForm can be loaded again, modified value remain
-- and may be applied again
-- Remark that ApplyData does not clear the modification status,
-- a call to ClearEdit does
---C++ : return &
Label (me) returns CString;
IsLoaded (me) returns Boolean;
---Purpose : Tells if the EditForm is loaded now
ClearData (me : mutable);
SetData (me : mutable; ent : Transient; model : InterfaceModel);
SetEntity (me : mutable; ent : Transient);
SetModel (me : mutable; model : InterfaceModel);
Entity (me) returns Transient;
Model (me) returns InterfaceModel;
Editor (me) returns Editor;
IsComplete (me) returns Boolean;
---Purpose : Tells if an EditForm is complete or is an extract from Editor
NbValues (me; editable : Boolean) returns Integer;
---Purpose : Returns the count of values
-- <editable> True : count of editable values, i.e.
-- For a complete EditForm, it is given by the Editor
-- Else, it is the length of the extraction map
-- <editable> False : all the values from the Editor
NumberFromRank (me; rank : Integer) returns Integer;
---Purpose : Returns the Value Number in the Editor from a given Rank in
-- the EditForm
-- For a complete EditForm, both are equal
-- Else, it is given by the extraction map
-- Returns 0 if <rank> exceeds the count of editable values,
RankFromNumber (me; number : Integer) returns Integer;
---Purpose : Returns the Rank in the EditForm from a given Number of Value
-- for the Editor
-- For a complete EditForm, both are equal
-- Else, it is given by the extraction map
-- Returns 0 if <number> is not forecast to be edited, or is
-- out of range
NameNumber (me; name : CString) returns Integer;
---Purpose : Returns the Value Number in the Editor for a given Name
-- i.e. the true ValueNumber which can be used in various methods
-- of EditForm
-- If it is not complete, for a recorded (in the Editor) but
-- non-loaded name, returns negative value (- number)
NameRank (me; name : CString) returns Integer;
---Purpose : Returns the Rank of Value in the EditForm for a given Name
-- i.e. if it is not complete, for a recorded (in the Editor) but
-- non-loaded name, returns 0
LoadDefault (me : mutable);
---Purpose : For a read-write undoable EditForm, loads original values
-- from defaults stored in the Editor
LoadData (me : mutable; ent : Transient; model : InterfaceModel)
returns Boolean is virtual;
---Purpose : Loads modifications to data
-- Default uses Editor. Can be redefined
-- Remark that <ent> and/or <model> may be null, according to the
-- kind of Editor. Shortcuts are available for these cases, but
-- they finally call LoadData (hence, just ignore non-used args)
LoadEntity (me : mutable; ent : Transient) returns Boolean;
---Purpose : Shortcut for LoadData when <model> is not used
LoadModel (me : mutable; model : InterfaceModel) returns Boolean;
---Purpose : Shortcut for LoadData when only the model is concerned
LoadData (me : mutable) returns Boolean;
---Purpose : Shortcut when both <ent> and <model> are not used
-- (when the Editor works on fully static or global data)
ListEditor (me; num : Integer) returns ListEditor;
---Purpose : Returns a ListEditor to edit the parameter <num> of the
-- EditForm, if it is a List
-- The Editor created it (by ListEditor) then loads it (by
-- ListValue)
-- For a single parameter, returns a Null Handle ...
LoadValue (me : mutable; num : Integer; val : HAsciiString);
---Purpose : Loads an original value (single). Called by the Editor only
LoadList (me : mutable; num : Integer; list : HSequenceOfHAsciiString);
---Purpose : Loads an original value as a list. Called by the Editor only
OriginalValue (me; num : Integer) returns HAsciiString;
---Purpose : From an edited value, returns its ... value (original one)
-- Null means that this value is not defined
-- <num> is for the EditForm, not the Editor
-- It is for a single parameter. For a list, gives a Null Handle
OriginalList (me; num : Integer) returns HSequenceOfHAsciiString;
---Purpose : Returns an original value, as a list
-- <num> is for the EditForm, not the Editor
-- For a single parameter, gives a Null Handle
EditedValue (me; num : Integer) returns HAsciiString;
---Purpose : Returns the Edited (i.e. Modified) Value (string for single)
-- <num> reports to the EditForm
-- If IsModified is False, returns OriginalValue
-- Null with IsModified True : means that this value is not
-- defined or has been removed
-- It is for a single parameter. For a list, gives a Null Handle
EditedList (me; num : Integer) returns HSequenceOfHAsciiString;
---Purpose : Returns the Edited Value as a list
-- If IsModified is False, returns OriginalValue
-- Null with IsModified True : means that this value is not
-- defined or has been removed
-- For a single parameter, gives a Null Handle
IsModified (me; num : Integer) returns Boolean;
---Purpose : Tells if a Value (of the EditForm) is modified (directly or
-- through touching by Update)
IsTouched (me; num : Integer) returns Boolean;
---Purpose : Tells if a Value (of the EditForm) has been touched, i.e.
-- not modified directly but by the modification of another one
-- (by method Update from the Editor)
Modify (me : mutable; num : Integer; newval : HAsciiString;
enforce : Boolean = Standard_False) returns Boolean;
---Purpose : Gives a new value for the item <num> of the EditForm, if
-- it is a single parameter (for a list, just returns False)
-- Null means to Remove it
-- <enforce> True to overpass Protected or Computed Access Mode
-- Calls the method Update from the Editor, which can touch other
-- parameters (see NbTouched)
-- Returns True if well recorded, False if this value is not
-- allowed
-- Warning : Does not apply immediately : will be applied by the method
-- Apply
ModifyList (me : mutable; num : Integer; edited : ListEditor;
enforce : Boolean = Standard_False) returns Boolean;
---Purpose : Changes the value of an item of the EditForm, if it is a List
-- (else, just returns False)
-- The ListEditor contains the edited values of the list
-- If no edition was recorded, just returns False
-- Calls the method Update from the Editor, which can touch other
-- parameters (see NbTouched)
-- Returns True if well recorded, False if this value is not
-- allowed
-- Warning : Does not apply immediately : will be applied by the method
-- Apply
ModifyListValue (me : mutable; num : Integer; list : HSequenceOfHAsciiString;
enforce : Boolean = Standard_False) returns Boolean;
---Purpose : As ModifyList but the new value is given as such
-- Creates a ListEditor, Loads it, then calls ModifyList
Touch (me : mutable; num : Integer; newval : HAsciiString) returns Boolean;
---Purpose : Gives a new value computed by the Editor, if another parameter
-- commands the value of <num>
-- It is generally the case for a Computed Parameter for instance
-- Increments the counter of touched parameters
-- Warning : it gives no protection for ReadOnly etc... while it is the
-- internal way of touching parameters
-- Does not work (returns False) if <num> is for a list
TouchList (me : mutable; num : Integer; newlist : HSequenceOfHAsciiString)
returns Boolean;
---Purpose : Acts as Touch but for a list
-- Does not work (returns False) if <num> is for a single param
NbTouched (me) returns Integer;
---Purpose : Returns the count of parameters touched by the last Modify
-- (apart from the modified parameter itself)
-- Normally it is zero
ClearEdit (me : mutable; num : Integer = 0);
---Purpose : Clears modification status : by default all, or one by its
-- numbers (in the Editor)
PrintDefs (me; S : Messenger from Message);
---Purpose : Prints Definitions, relative to the Editor
PrintValues (me; S : Messenger from Message; what : Integer;
names : Boolean; alsolist : Boolean = Standard_False);
---Purpose : Prints Values, according to what and alsolist
-- <names> True : prints Long Names; False : prints Short Names
-- <what> < 0 : prints Original Values (+ flag Modified)
-- <what> > 0 : prints Final Values (+flag Modified)
-- <what> = 0 : prints Modified Values (Original + Edited)
-- <alsolist> False (D) : lists are printed only as their count
-- <alsolist> True : lists are printed for all their items
Apply (me : mutable) returns Boolean;
---Purpose : Applies modifications to own data
-- Calls ApplyData then Clears Status according EditKeepStatus
-- Specific methods : they work with the Editor (which provides the
-- specific behavior) but they can be redefined
Recognize (me) returns Boolean is virtual;
---Purpose : Tells if this EditForm can work with its Editor and its actual
-- Data (Entity and Model)
-- Default uses Editor. Can be redefined
ApplyData (me : mutable; ent : Transient; model : InterfaceModel)
returns Boolean is virtual;
---Purpose : Applies modifications to data
-- Default uses Editor. Can be redefined
Undo (me : mutable) returns Boolean;
---Purpose : For an undoable EditForm, Applies ... origibal values !
-- and clears modified ones
-- Can be run only once
fields
thecomplete : Boolean; -- complete ? else see thenums for mapping
theloaded : Boolean; -- loaded ?
thekeepst : Boolean; -- to keep edits
thelabel : AsciiString;
thenums : Array1OfInteger;
theorigs : Array1OfTransient;
themodifs : Array1OfTransient;
thestatus : Array1OfInteger;
theeditor : Editor;
theent : Transient;
themodel : InterfaceModel;
thetouched : Integer;
end EditForm;

View File

@@ -0,0 +1,525 @@
#include <IFSelect_EditForm.ixx>
#include <Interface_TypedValue.hxx>
#include <Interface_MSG.hxx>
#include <Message_Messenger.hxx>
#include <Message.hxx>
IFSelect_EditForm::IFSelect_EditForm
(const Handle(IFSelect_Editor)& editor,
const Standard_Boolean readonly, const Standard_Boolean undoable,
const Standard_CString label)
: thecomplete (Standard_True) ,
theloaded (Standard_False) ,
thekeepst (Standard_False) ,
thelabel (label) ,
thenums (0,1) ,
theorigs (0, (undoable ? editor->NbValues() : 0) ) ,
themodifs (0, (readonly ? 0 : editor->NbValues()) ) ,
thestatus (0, (readonly ? 0 : editor->NbValues()) ) ,
theeditor (editor) ,
thetouched (0) { }
IFSelect_EditForm::IFSelect_EditForm
(const Handle(IFSelect_Editor)& editor,
const TColStd_SequenceOfInteger& nums,
const Standard_Boolean readonly, const Standard_Boolean undoable,
const Standard_CString label)
: thecomplete (Standard_False) ,
theloaded (Standard_False) ,
thekeepst (Standard_False) ,
thelabel (label) ,
thenums (0,nums.Length()) ,
theorigs (0, (undoable ? nums.Length() : 0) ) ,
themodifs (0, (readonly ? 0 : nums.Length()) ) ,
thestatus (0, (readonly ? 0 : nums.Length()) ) ,
theeditor (editor) ,
thetouched (0)
{
Standard_Integer i,nb = nums.Length();
for (i = 1; i <= nb; i ++) thenums.SetValue (i,nums.Value(i));
}
Standard_Boolean& IFSelect_EditForm::EditKeepStatus ()
{ return thekeepst; }
Standard_CString IFSelect_EditForm::Label () const
{ return thelabel.ToCString(); }
Standard_Boolean IFSelect_EditForm::IsLoaded () const
{ return theloaded; }
void IFSelect_EditForm::ClearData ()
{ theent.Nullify(); themodel.Nullify(); theloaded = Standard_False; }
void IFSelect_EditForm::SetData
(const Handle(Standard_Transient)& ent,
const Handle(Interface_InterfaceModel)& model)
{ theent = ent; themodel = model; }
void IFSelect_EditForm::SetEntity
(const Handle(Standard_Transient)& ent)
{ theent = ent; }
void IFSelect_EditForm::SetModel
(const Handle(Interface_InterfaceModel)& model)
{ themodel = model; }
Handle(Standard_Transient) IFSelect_EditForm::Entity () const
{ return theent; }
Handle(Interface_InterfaceModel) IFSelect_EditForm::Model () const
{ return themodel; }
Handle(IFSelect_Editor) IFSelect_EditForm::Editor () const
{ return theeditor; }
Standard_Boolean IFSelect_EditForm::IsComplete () const
{ return thecomplete; }
Standard_Integer IFSelect_EditForm::NbValues
(const Standard_Boolean editable) const
{
if (!editable || thecomplete) return theeditor->NbValues();
return thenums.Upper();
}
Standard_Integer IFSelect_EditForm::NumberFromRank
(const Standard_Integer rank) const
{
if (thecomplete) return rank;
if (rank < 1 || rank > thenums.Upper()) return 0;
return thenums.Value(rank);
}
Standard_Integer IFSelect_EditForm::RankFromNumber
(const Standard_Integer num) const
{
if (thecomplete) return num;
Standard_Integer i, n = thenums.Upper();
for (i = 1; i <= n; i ++) {
if (thenums.Value(i) == num) return i;
}
return 0;
}
Standard_Integer IFSelect_EditForm::NameNumber
(const Standard_CString name) const
{
Standard_Integer res = theeditor->NameNumber(name);
if (thecomplete || res == 0) return res;
// Sinon, chercher res dans thenums
Standard_Integer i, nb = thenums.Length();
for (i = 1; i <= nb; i ++) {
if (res == thenums.Value(i)) return res;
}
return -res;
}
Standard_Integer IFSelect_EditForm::NameRank
(const Standard_CString name) const
{
Standard_Integer res = theeditor->NameNumber(name);
if (thecomplete || res == 0) return res;
// Sinon, chercher res dans thenums
Standard_Integer i, nb = thenums.Length();
for (i = 1; i <= nb; i ++) {
if (res == thenums.Value(i)) return i;
}
return 0;
}
void IFSelect_EditForm::LoadDefault ()
{
theloaded = Standard_True;
thetouched = 0;
Standard_Integer i,nb = theorigs.Upper();
if (nb == 0) return;
for (i = 1; i <= nb; i ++) {
Standard_Integer num = NumberFromRank(i);
if (num == 0) continue;
Handle(TCollection_HAsciiString) str = theeditor->StringValue (this,num);
theorigs.SetValue (i,str);
}
}
Standard_Boolean IFSelect_EditForm::LoadData
(const Handle(Standard_Transient)& ent,
const Handle(Interface_InterfaceModel)& model)
{
thetouched = 0;
if (!theeditor->Load (this,ent,model)) return Standard_False;
SetData (ent,model);
theloaded = Standard_True;
return Standard_True;
}
Standard_Boolean IFSelect_EditForm::LoadEntity
(const Handle(Standard_Transient)& ent)
{
thetouched = 0;
Handle(Interface_InterfaceModel) model;
if (!theeditor->Load (this,ent,model)) return Standard_False;
SetEntity (ent);
theloaded = Standard_True;
return Standard_True;
}
Standard_Boolean IFSelect_EditForm::LoadModel
(const Handle(Interface_InterfaceModel)& model)
{
thetouched = 0;
Handle(Standard_Transient) ent;
if (!theeditor->Load (this,ent,model)) return Standard_False;
SetData (ent,model);
theloaded = Standard_True;
return Standard_True;
}
Standard_Boolean IFSelect_EditForm::LoadData ()
{
thetouched = 0;
Handle(Interface_InterfaceModel) model;
Handle(Standard_Transient) ent;
if (!theeditor->Load (this,ent,model)) return Standard_False;
theloaded = Standard_True;
return Standard_True;
}
// ######## VALUES ########
Handle(IFSelect_ListEditor) IFSelect_EditForm::ListEditor
(const Standard_Integer num) const
{
Standard_Integer n = RankFromNumber(num);
Handle(IFSelect_ListEditor) led;
if (n <= 0 || n > theorigs.Upper()) return led;
if (!theeditor->IsList(n)) return led;
led = theeditor->ListEditor (num);
Handle(TColStd_HSequenceOfHAsciiString) lis = theeditor->ListValue(this,num);
led->LoadModel (themodel);
led->LoadValues (lis);
return led;
}
void IFSelect_EditForm::LoadValue
(const Standard_Integer num, const Handle(TCollection_HAsciiString)& val)
{
Standard_Integer n = RankFromNumber(num);
if (n <= 0 || n > theorigs.Upper()) return;
theorigs.SetValue (n,val);
}
void IFSelect_EditForm::LoadList
(const Standard_Integer num, const Handle(TColStd_HSequenceOfHAsciiString)& list)
{
Standard_Integer n = RankFromNumber(num);
if (n <= 0 || n > theorigs.Upper()) return;
theorigs.SetValue (n,list);
}
Handle(TCollection_HAsciiString) IFSelect_EditForm::OriginalValue
(const Standard_Integer num) const
{
Standard_Integer n = RankFromNumber(num);
Handle(TCollection_HAsciiString) val;
if (theorigs.Upper() == 0) return theeditor->StringValue (this,num);
else return Handle(TCollection_HAsciiString)::DownCast(theorigs.Value(n));
}
Handle(TColStd_HSequenceOfHAsciiString) IFSelect_EditForm::OriginalList
(const Standard_Integer num) const
{
Standard_Integer n = RankFromNumber(num);
Handle(TColStd_HSequenceOfHAsciiString) list;
if (theorigs.Upper() == 0) return theeditor->ListValue (this,num);
else return Handle(TColStd_HSequenceOfHAsciiString)::DownCast(theorigs.Value(n));
}
Handle(TCollection_HAsciiString) IFSelect_EditForm::EditedValue
(const Standard_Integer num) const
{
if (themodifs.Upper() == 0) return OriginalValue(num);
if (!IsModified(num)) return OriginalValue(num);
Standard_Integer n = RankFromNumber(num);
return Handle(TCollection_HAsciiString)::DownCast(themodifs.Value(n));
}
Handle(TColStd_HSequenceOfHAsciiString) IFSelect_EditForm::EditedList
(const Standard_Integer num) const
{
if (themodifs.Upper() == 0) return OriginalList(num);
if (!IsModified(num)) return OriginalList(num);
Standard_Integer n = RankFromNumber(num);
return Handle(TColStd_HSequenceOfHAsciiString)::DownCast(themodifs.Value(n));
}
Standard_Boolean IFSelect_EditForm::IsModified
(const Standard_Integer num) const
{
if (thestatus.Upper() == 0) return Standard_False;
Standard_Integer n = RankFromNumber(num);
return (thestatus.Value(n) != 0);
}
Standard_Boolean IFSelect_EditForm::IsTouched
(const Standard_Integer num) const
{
if (thestatus.Upper() == 0) return Standard_False;
Standard_Integer n = RankFromNumber(num);
return (thestatus.Value(n) == 2);
}
Standard_Boolean IFSelect_EditForm::Modify
(const Standard_Integer num, const Handle(TCollection_HAsciiString)& newval,
const Standard_Boolean enforce)
{
// Peut-on editer
thetouched = 0;
if (themodifs.Upper() == 0) return Standard_False;
Standard_Integer tnum = RankFromNumber(num);
if (tnum == 0) return Standard_False;
IFSelect_EditValue acc = theeditor->EditMode (num);
if (newval.IsNull() && acc != IFSelect_Optional) return Standard_False;
if (!enforce && (acc == IFSelect_EditProtected || acc == IFSelect_EditComputed)) return Standard_False;
// Satisfies ?
Handle(Interface_TypedValue) typval = theeditor->TypedValue(num);
if (!typval->Satisfies(newval)) return Standard_False;
Interface_ParamType pty = typval->Type();
if (pty == Interface_ParamIdent && !newval.IsNull()) {
if (themodel.IsNull()) return Standard_False;
if (themodel->NextNumberForLabel(newval->ToCString(),0,Standard_False) <= 0)
return Standard_False;
}
// Update ?
if (!theeditor->Update(this,num,newval,enforce)) return Standard_False;
thestatus.SetValue (tnum,1);
themodifs.SetValue (tnum,newval);
return Standard_True;
}
Standard_Boolean IFSelect_EditForm::ModifyList
(const Standard_Integer num, const Handle(IFSelect_ListEditor)& edited,
const Standard_Boolean enforce)
{
// Faut-il prendre
if (edited.IsNull()) return Standard_False;
if (!edited->IsTouched()) return Standard_False;
Handle(TColStd_HSequenceOfHAsciiString) newlist = edited->EditedValues();
// Peut-on editer
thetouched = 0;
if (themodifs.Upper() == 0) return Standard_False;
Standard_Integer tnum = RankFromNumber(num);
if (tnum == 0) return Standard_False;
IFSelect_EditValue acc = theeditor->EditMode (num);
if (acc == IFSelect_EditRead || acc == IFSelect_EditDynamic) return Standard_False;
if (newlist.IsNull() && acc != IFSelect_Optional) return Standard_False;
if (!enforce && (acc == IFSelect_EditProtected || acc == IFSelect_EditComputed)) return Standard_False;
// Update ?
if (!theeditor->UpdateList(this,num,newlist,enforce)) return Standard_False;
thestatus.SetValue (tnum,1);
themodifs.SetValue (tnum,newlist);
return Standard_True;
}
Standard_Boolean IFSelect_EditForm::ModifyListValue
(const Standard_Integer num, const Handle(TColStd_HSequenceOfHAsciiString)& list,
const Standard_Boolean enforce)
{
Handle(IFSelect_ListEditor) led = ListEditor (num);
if (led.IsNull()) return Standard_False;
if (!led->LoadEdited(list)) return Standard_False;
return ModifyList (num,led,enforce);
}
Standard_Boolean IFSelect_EditForm::Touch
(const Standard_Integer num, const Handle(TCollection_HAsciiString)& newval)
{
if (themodifs.Upper() == 0) return Standard_False;
Standard_Integer tnum = RankFromNumber(num);
if (tnum == 0) return Standard_False;
thestatus.SetValue (tnum,2);
themodifs.SetValue (tnum,newval);
thetouched ++;
return Standard_True;
}
Standard_Boolean IFSelect_EditForm::TouchList
(const Standard_Integer num, const Handle(TColStd_HSequenceOfHAsciiString)& newlist)
{
if (themodifs.Upper() == 0) return Standard_False;
Standard_Integer tnum = RankFromNumber(num);
if (tnum == 0) return Standard_False;
thestatus.SetValue (tnum,2);
themodifs.SetValue (tnum,newlist);
thetouched ++;
return Standard_True;
}
void IFSelect_EditForm::ClearEdit (const Standard_Integer num)
{
Standard_Integer i, nb = thestatus.Upper();
if (num == 0) {
for (i = 1; i <= nb; i ++) thestatus.SetValue (i,0);
} else {
Standard_Integer tnum = RankFromNumber(num);
if (tnum > 0 && num <= nb) thestatus.SetValue (tnum,0);
}
}
void IFSelect_EditForm::PrintDefs (const Handle(Message_Messenger)& S) const
{
Standard_Integer iv, nbv = NbValues(Standard_True);
S<<"***** EditForm, Label : "<<Label()<<endl;
if (IsComplete()) S<<"Complete, "<<nbv<<" Values"<<endl;
else {
S<<"Extraction on "<<nbv<<" Values : (extracted<-editor)"<<endl;
for (iv = 1; iv <= nbv; iv ++) S<<" "<<iv<<"<-"<<NumberFromRank(iv);
S<<endl;
}
S<<"*****"<<endl;
}
static void PrintList
(const Handle(TColStd_HSequenceOfHAsciiString)& list,
const Handle(Message_Messenger)& S, const Standard_Boolean alsolist)
{
if (list.IsNull()) { S<<"(NULL LIST)"<<endl; return; }
Standard_Integer i,nb = list->Length();
S<<"(List : "<<nb<<" Items)"<<endl;
if (!alsolist) return;
for (i = 1; i <= nb; i ++) {
Handle(TCollection_HAsciiString) str = list->Value(i);
S<<" ["<<i<<"] "<< (str.IsNull() ? "(NULL)" : str->ToCString())<<endl;
}
}
void IFSelect_EditForm::PrintValues
(const Handle(Message_Messenger)& S, const Standard_Integer what,
const Standard_Boolean names, const Standard_Boolean alsolist) const
{
Standard_Integer iv, nbv = NbValues(Standard_True);
S<< "****************************************************"<<endl;
S<<"***** "<<Label()<<Interface_MSG::Blanks(Label(),40)<<"*****"<<endl;
S<<"***** *****"<<endl;
if (!theloaded)
S<<"***** Values are NOT loaded *****"<<endl;
else {
// Donnees sur lesquelles on a travaille
if (themodel.IsNull()) {
if (theent.IsNull()) S<<"***** No loaded data";
else S<<"***** No loaded Model. Loaded object : type "<<theent->DynamicType()->Name();
} else {
if (theent.IsNull()) S<<"***** No loaded entity";
else { S<<"***** Loaded entity : "; themodel->PrintLabel (theent,S); }
}
}
S<<endl<<"****************************************************"<<endl<<endl;
// Affichage des valeurs
Standard_Boolean nams = names;
Standard_Integer maxnam = theeditor->MaxNameLength (names ? 0 : -1);
if (maxnam == 0) { maxnam = theeditor->MaxNameLength (0); nams = Standard_True; }
Standard_Integer nbmod = 0;
if (what != 0) S<<"Mod N0 Name Value"<<endl;
else S<<" N0 Name Value"<<endl;
for (iv = 1; iv <= nbv; iv ++) {
Standard_Integer jv = NumberFromRank(iv);
Standard_CString name = theeditor->Name(jv,!nams);
// Original ou Final
if (what != 0) {
Handle(TCollection_HAsciiString) str;
if (IsModified(jv)) S<<"* ";
else S<<" ";
S <<Interface_MSG::Blanks(iv,3)<<iv<<" "
<<name<<Interface_MSG::Blanks(name,maxnam)<<" ";
if (theeditor->IsList(jv)) {
Handle(TColStd_HSequenceOfHAsciiString) list;
if (what < 0) list = OriginalList (jv);
if (what > 0) list = EditedList (jv);
PrintList (list,S,alsolist);
continue;
}
if (what < 0) str = OriginalValue (jv);
if (what > 0) str = EditedValue (jv);
S << (str.IsNull() ? "(NULL)" : str->ToCString()) <<endl;
// Modified only
} else {
if (!IsModified(jv)) continue;
nbmod ++;
if (theeditor->IsList(jv)) {
Handle(TColStd_HSequenceOfHAsciiString) list= OriginalList (jv);
S <<Interface_MSG::Blanks(iv,3)<<iv<<" "
<<name<<Interface_MSG::Blanks(name,maxnam)<<" ORIG:";
PrintList (list,S,alsolist);
list = EditedList (jv);
S<<Interface_MSG::Blanks("",maxnam+5)<<"MOD :";
PrintList (list,S,alsolist);
continue;
}
Handle(TCollection_HAsciiString) str = OriginalValue (jv);
S <<Interface_MSG::Blanks(iv,3)<<iv<<" "
<<name<<Interface_MSG::Blanks(name,maxnam)<<" ORIG:"
<< (str.IsNull() ? "(NULL)" : str->ToCString()) <<endl;
str = EditedValue (jv);
S<<Interface_MSG::Blanks("",maxnam+4)<<" MOD :"<< (str.IsNull() ? "(NULL)" : str->ToCString()) <<endl;
}
}
if (what == 0) S<<"On "<<nbv<<" Values, "<<nbmod<<" Modified"<<endl;
}
Standard_Boolean IFSelect_EditForm::Apply ()
{
Standard_Boolean stat = ApplyData(theent,themodel);
if (stat && !thekeepst) ClearEdit();
return stat;
}
Standard_Boolean IFSelect_EditForm::Recognize () const
{ return theeditor->Recognize(this); }
Standard_Boolean IFSelect_EditForm::ApplyData
(const Handle(Standard_Transient)& ent,
const Handle(Interface_InterfaceModel)& model)
{ return theeditor->Apply (this,ent,model); }
Standard_Boolean IFSelect_EditForm::Undo ()
{
if (thestatus.Upper() == 0 || theorigs.Upper() == 0) return Standard_False;
Standard_Integer i, nb = thestatus.Upper();
for (i = 1; i <= nb; i ++) {
if (thestatus.Value (i) != 0) themodifs.SetValue (i,theorigs.Value(i));
}
return Apply ();
}

169
src/IFSelect/IFSelect_Editor.cdl Executable file
View File

@@ -0,0 +1,169 @@
-- File: IFSelect_Editor.cdl
-- Created: Mon Feb 23 15:04:39 1998
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
deferred class Editor from IFSelect inherits TShared
---Purpose : 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
uses CString, Messenger from Message,
AsciiString from TCollection, HAsciiString from TCollection,
Array1OfTransient from TColStd, Array1OfAsciiString from TColStd,
Array1OfInteger from TColStd, DictionaryOfInteger from Dico,
HSequenceOfHAsciiString from TColStd,
InterfaceModel from Interface,
TypedValue from Interface, EditValue from IFSelect,
EditForm from IFSelect, ListEditor from IFSelect
raises OutOfRange from Standard
is
Initialize (nbval : Integer);
---Purpose : 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
SetNbValues (me : mutable; nbval : Integer)
---Purpose : 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
raises OutOfRange is protected;
-- Error if <nbval> exceeds the initial reservation
SetValue (me : mutable; num : Integer;
typval : TypedValue;
shortname : CString = "";
accessmode : EditValue = IFSelect_Editable);
---Purpose : Sets a Typed Value for a given ident and short name, with an
-- Edit Mode
SetList (me : mutable; num : Integer; max : Integer = 0);
---Purpose : 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 <max> items
NbValues (me) returns Integer;
---Purpose : Returns the count of Typed Values
TypedValue (me; num : Integer) returns TypedValue;
---Purpose : Returns a Typed Value from its ident
IsList (me; num : Integer) returns Boolean;
---Purpose : Tells if a parameter is a list
MaxList (me; num : Integer) returns Integer;
---Purpose : Returns max length allowed for a list
-- = 0 means : list with no limit
-- < 0 means : not a list
Name (me; num : Integer; isshort : Boolean = Standard_False) returns CString;
---Purpose : Returns the name of a Value (complete or short) from its ident
-- Short Name can be empty
EditMode (me; num : Integer) returns EditValue;
---Purpose : Returns the edit mode of a Value
NameNumber (me; name : CString) returns Integer;
---Purpose : Returns the number (ident) of a Value, from its name, short or
-- complete. If not found, returns 0
-- Printings
PrintNames (me; S : Messenger from Message);
PrintDefs (me; S : Messenger from Message; labels : Boolean = Standard_False);
MaxNameLength (me; what : Integer) returns Integer;
---Purpose : Returns the MaxLength of, according to what :
-- <what> = -1 : length of short names
-- <what> = 0 : length of complete names
-- <what> = 1 : length of values labels
-- Specific methods
Label (me) returns AsciiString is deferred;
---Purpose : Returns the specific label
Form (me; readonly : Boolean; undoable : Boolean = Standard_True)
returns EditForm is virtual;
---Purpose : Builds and Returns an EditForm, empty (no data yet)
-- Can be redefined to return a specific type of EditForm
Recognize (me; form : EditForm) returns Boolean is deferred;
---Purpose : Tells if this Editor can work on this EditForm and its content
-- (model, entity ?)
StringValue (me; form : EditForm; num : Integer)
returns HAsciiString from TCollection is deferred;
---Purpose : Returns the value of an EditForm, for a given item
-- (if not a list. for a list, a Null String may be returned)
ListEditor (me; num : Integer) returns ListEditor is virtual;
---Purpose : Returns a ListEditor for a parameter which is a List
-- Default returns a basic ListEditor for a List, a Null Handle
-- if <num> is not for a List. Can be redefined
ListValue (me; form : EditForm; num : Integer)
returns HSequenceOfHAsciiString from TColStd is virtual;
---Purpose : 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
Load (me; form : mutable EditForm; ent : Transient; model : InterfaceModel)
returns Boolean is deferred;
---Purpose : Loads original values from some data, to an EditForm
-- Remark: <ent> may be Null, this means all <model> is concerned
-- Also <model> may be Null, if no context applies for <ent>
-- And both <ent> and <model> may be Null, for a full static
-- editor
Update (me; form : mutable EditForm; num : Integer;
newval : HAsciiString; enforce : Boolean)
returns Boolean is virtual;
---Purpose : 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)
-- <num> is the rank of the parameter for the EDITOR itself
-- <enforce> 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
UpdateList (me; form : mutable EditForm; num : Integer;
newlist : HSequenceOfHAsciiString; enforce : Boolean)
returns Boolean is virtual;
---Purpose : Acts as Update, but when the value is a list
Apply (me; form : EditForm; ent : Transient; model : InterfaceModel)
returns Boolean is deferred;
---Purpose : Applies modified values of the EditForm with some data
-- Remark: <ent> may be Null, this means all <model> is concerned
-- Also <model> may be Null, if no context applies for <ent>
-- And both <ent> and <model> may be Null, for a full static
-- editor
fields
thenbval : Integer;
themaxsh : Integer;
themaxco : Integer;
themaxla : Integer;
thenames : DictionaryOfInteger;
thevalues : Array1OfTransient;
theshorts : Array1OfAsciiString;
themodes : Array1OfInteger;
thelists : Array1OfInteger;
end Editor;

205
src/IFSelect/IFSelect_Editor.cxx Executable file
View File

@@ -0,0 +1,205 @@
#include <IFSelect_Editor.ixx>
#include <Interface_MSG.hxx>
#include <string.h>
IFSelect_Editor::IFSelect_Editor (const Standard_Integer nbval)
: thenbval (nbval) , themaxsh (0) , themaxco (0) , themaxla (0) ,
thevalues (1,nbval) , theshorts (1,nbval) , themodes (1,nbval) ,
thelists (1,nbval)
{ thenames = new Dico_DictionaryOfInteger; thelists.Init(-1); }
void IFSelect_Editor::SetNbValues (const Standard_Integer nbval)
{
if (nbval > thevalues.Upper()) Standard_OutOfRange::Raise("IFSelect_Editor:SetNbValues");
thenbval = nbval;
}
void IFSelect_Editor::SetValue
(const Standard_Integer num, const Handle(Interface_TypedValue)& typval,
const Standard_CString shortname, const IFSelect_EditValue editmode)
{
if (num < 1 || num > thenbval) return;
TCollection_AsciiString shn (shortname);
Standard_Integer lng = shn.Length();
if (lng > 0) thenames->SetItem (shortname,num);
if (lng > themaxsh) themaxsh = lng;
lng = strlen (typval->Name());
if (lng > themaxco) themaxco = lng;
lng = strlen (typval->Label());
if (lng > themaxla) themaxla = lng;
thenames->SetItem (typval->Name(),num);
Standard_Integer edm = (Standard_Integer) editmode;
thevalues.SetValue (num,typval);
theshorts.SetValue (num,shn);
themodes.SetValue (num,edm);
}
void IFSelect_Editor::SetList
(const Standard_Integer num, const Standard_Integer max)
{
if (num < 1 || num > thenbval) return;
thelists.SetValue (num,max);
}
Standard_Integer IFSelect_Editor::NbValues () const
{ return thenbval; }
Handle(Interface_TypedValue) IFSelect_Editor::TypedValue
(const Standard_Integer num) const
{ return Handle(Interface_TypedValue)::DownCast(thevalues.Value(num)); }
Standard_Boolean IFSelect_Editor::IsList (const Standard_Integer num) const
{
if (num < 1 || num > thenbval) return Standard_False;
return (thelists.Value(num) >= 0);
}
Standard_Integer IFSelect_Editor::MaxList (const Standard_Integer num) const
{
if (num < 1 || num > thenbval) return -1;
return thelists.Value(num);
}
Standard_CString IFSelect_Editor::Name
(const Standard_Integer num, const Standard_Boolean isshort) const
{
if (num < 1 || num > thenbval) return "";
if (isshort) return theshorts.Value (num).ToCString();
else return TypedValue (num)->Name();
}
IFSelect_EditValue IFSelect_Editor::EditMode
(const Standard_Integer num) const
{
if (num < 1 || num > thenbval) return IFSelect_EditDynamic;
Standard_Integer edm = themodes.Value(num);
return (IFSelect_EditValue) edm;
}
void IFSelect_Editor::PrintNames (const Handle(Message_Messenger)& S) const
{
Standard_Integer i, nb = NbValues();
S<<"**** Editor : "<<Label()<<endl;
S<<"**** Nb Values = "<<nb<<" **** Names / Labels"<<endl;
S<<" Num ";
if (themaxsh > 0) S<<"Short"<<Interface_MSG::Blanks("Short",themaxsh)<<" ";
S<<"Complete"<<Interface_MSG::Blanks("Complete",themaxco)<<" Label"<<endl;
for (i = 1; i <= nb; i ++) {
Handle(Interface_TypedValue) tv = TypedValue(i);
if (tv.IsNull()) continue;
S<<Interface_MSG::Blanks(i,3)<<i<<" ";
if (themaxsh > 0) {
const TCollection_AsciiString& sho = theshorts(i);
S<<sho<<Interface_MSG::Blanks(sho.ToCString(),themaxsh)<<" ";
}
S<<tv->Name()<<Interface_MSG::Blanks(tv->Name(),themaxco)<<" "<<tv->Label()<<endl;
}
}
void IFSelect_Editor::PrintDefs
(const Handle(Message_Messenger)& S, const Standard_Boolean labels) const
{
Standard_Integer i, nb = NbValues();
S<<"**** Editor : "<<Label()<<endl;
S<<"**** Nb Values = "<<nb<<" **** "<<(labels ? "Labels" : "Names")<<" / Definitions"<<endl;
S<<" Num ";
if (labels) S<<"Label"<<Interface_MSG::Blanks("Label",themaxla);
else {
if (themaxsh > 0) S<<"Short"<<Interface_MSG::Blanks("Short",themaxsh+1);
S<<"Complete"<<Interface_MSG::Blanks("Complete",themaxco);
}
S<<" Edit Mode & Definition"<<endl;
for (i = 1; i <= nb; i ++) {
Handle(Interface_TypedValue) tv = TypedValue(i);
if (tv.IsNull()) continue;
S<<" "<<Interface_MSG::Blanks(i,3)<<i<<" ";
if (labels) S<<tv->Label()<<Interface_MSG::Blanks(tv->Label(),themaxla);
else {
if (themaxsh > 0) {
const TCollection_AsciiString& sho = theshorts(i);
S<<sho<<Interface_MSG::Blanks(sho.ToCString(),themaxsh)<<" ";
}
S<<tv->Name()<<Interface_MSG::Blanks(tv->Name(),themaxco);
}
S<<" ";
Standard_Integer maxls = MaxList (i);
if (maxls == 0) S<<" (List) ";
else if (maxls > 0) S<<" (List <= "<<maxls<<" Items) ";
else S<<" ";
IFSelect_EditValue edm = EditMode (i);
switch (edm) {
case IFSelect_Optional : S<<"Optional "; break;
case IFSelect_Editable : S<<"Editable "; break;
case IFSelect_EditProtected : S<<"Protected"; break;
case IFSelect_EditComputed : S<<"Computed "; break;
case IFSelect_EditRead : S<<"ReadOnly "; break;
case IFSelect_EditDynamic : S<<"Dynamic "; break;
default : S<<"?????????"; break;
}
S<<" "<<tv->Definition()<<endl;
}
}
Standard_Integer IFSelect_Editor::MaxNameLength
(const Standard_Integer what) const
{
if (what == -1) return themaxsh;
if (what == 0) return themaxco;
if (what == 1) return themaxla;
return 0;
}
Standard_Integer IFSelect_Editor::NameNumber
(const Standard_CString name) const
{
Standard_Integer res;
if (thenames->GetItem(name,res,Standard_False)) return res;
res = atoi (name); // si c est un entier, on tente le coup
if (res < 1 || res > NbValues()) res = 0;
return res;
}
Handle(IFSelect_EditForm) IFSelect_Editor::Form
(const Standard_Boolean readonly, const Standard_Boolean undoable) const
{
return new IFSelect_EditForm (this,readonly,undoable,Label().ToCString());
}
Handle(IFSelect_ListEditor) IFSelect_Editor::ListEditor
(const Standard_Integer num) const
{
Handle(IFSelect_ListEditor) led;
Standard_Integer max = MaxList (num);
if (max < 0) return led;
led = new IFSelect_ListEditor (TypedValue(num),max);
return led;
}
Handle(TColStd_HSequenceOfHAsciiString) IFSelect_Editor::ListValue
(const Handle(IFSelect_EditForm)& /*form*/, const Standard_Integer /*num*/) const
{
Handle(TColStd_HSequenceOfHAsciiString) list;
return list;
}
Standard_Boolean IFSelect_Editor::Update
(const Handle(IFSelect_EditForm)& /*form*/, const Standard_Integer /*num*/,
const Handle(TCollection_HAsciiString)& /*newval*/,
const Standard_Boolean /*enforce*/) const
{ return Standard_True; }
Standard_Boolean IFSelect_Editor::UpdateList
(const Handle(IFSelect_EditForm)& /*form*/, const Standard_Integer /*num*/,
const Handle(TColStd_HSequenceOfHAsciiString)& /*newval*/,
const Standard_Boolean /*enforce*/) const
{ return Standard_True; }

View File

@@ -0,0 +1,49 @@
-- File: IFSelect_FileModifier.cdl
-- Created: Mon Mar 21 10:49:35 1994
-- Author: Christian CAILLET
-- <cky@ecolox>
---Copyright: Matra Datavision 1994
deferred generic class FileModifier from IFSelect
(Writer as any) -- according each Interface
inherits GeneralModifier
---Purpose : Allows to precise the frame work for File Modifiers able to
-- run with an Interface (such as STEP, VDA, IGES ...)
--
-- Remember that File Modifiers are activated by a WorkLibrary :
-- if they inherit from an instantiation of FileModifier with the
-- data from this Interface, this will be easier to do.
-- They are activated before sending the file, in the order
-- given by the ModielCopier.
--
-- For each Interface on which File Modifiers have to be defined,
-- The way to follow is firstly to instantiate FileModifier with
-- its specific data :
-- Model is the InterfaceModel specific to the considered norm
-- Writer is the Writer specific to the considered norm
-- Then to define the various classes which inherit from it and
-- define their method Perform
uses ContextWrite
is
Initialize;
---Purpose : Sets a File Modifier to keep the graph of dependences
-- unchanges (because it works on the model already produced)
Perform (me; ctx : in out ContextWrite; writer : in out Writer)
is deferred;
---Purpose : Perform the action specific to each class of File Modifier
-- <ctx> is the ContextWrite, which brings : the model, the
-- protocol, the file name, plus the object AppliedModifiers
-- (not used here) and the CheckList
-- Remark that the model has to be casted for specific access
--
-- <writer> is the Writer and is specific to each norm, on which
-- to act
end FileModifier;

View File

@@ -0,0 +1,6 @@
//#include <IFSelect_FileModifier.ixx>
IFSelect_FileModifier::IFSelect_FileModifier ()
: IFSelect_GeneralModifier (Standard_False) { }

View File

@@ -0,0 +1,60 @@
-- File: IFSelect_Functions.cdl
-- Created: Wed Jul 28 09:49:21 1993
-- Author: Christian CAILLET
-- <cky@meteox>
---Copyright: Matra Datavision 1993
class Functions from IFSelect
---Purpose : Functions gives access to all the actions which can be
-- commanded with the resources provided by IFSelect : especially
-- WorkSession and various types of Selections and Dispatches
--
-- It works by adding functions by method Init
uses CString, HSequenceOfTransient from TColStd,
WorkSession from IFSelect , Dispatch from IFSelect
is
GiveEntity (myclass; WS : WorkSession; name : CString = "")
returns Transient;
---Purpose : Takes the name of an entity, either as argument, or (if <name>
-- is empty) on keybord, and returns the entity
-- name can be a label or a number (in alphanumeric), it is
-- searched by NumberFromLabel from WorkSession.
-- If <name> doesn't match en entity, a Null Handle is returned
GiveEntityNumber (myclass; WS : WorkSession; name : CString = "")
returns Integer;
---Purpose : Same as GetEntity, but returns the number in the model of the
-- entity. Returns 0 for null handle
GiveList (myclass; WS : WorkSession; first, second : CString = "")
returns HSequenceOfTransient;
---Purpose : Computes a List of entities from a WorkSession and two idents,
-- first and second, as follows :
-- if <first> is a Number or Label of an entity : this entity
-- if <first> is the name of a Selection in <WS>, and <second>
-- not defined, the standard result of this Selection
-- if <first> is for a Selection and <second> is defined, the
-- standard result of this selection from the list computed
-- with <second> (an entity or a selection)
-- If <second> is erroneous, it is ignored
GiveDispatch (myclass; WS : WorkSession; name : CString;
mode : Boolean = Standard_True)
returns Dispatch from IFSelect;
---Purpose : Evaluates and returns a Dispatch, from data of a WorkSession
-- if <mode> is False, searches for exact name of Dispatch in WS
-- Else (D), allows a parameter between brackets :
-- ex.: dispatch_name(parameter)
-- The parameter can be: an integer for DispPerCount or DispPerFiles
-- or the name of a Signature for DispPerSignature
-- Returns Null Handle if not found not well evaluated
Init (myclass);
---Purpose : Defines and loads all basic functions (as ActFunc)
end Functions;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,97 @@
-- File: IFSelect_GeneralModifier.cdl
-- Created: Tue Oct 19 17:22:55 1993
-- Author: Christian CAILLET
-- <cky@sdsun2>
---Copyright: Matra Datavision 1993
deferred class GeneralModifier from IFSelect inherits TShared
---Purpose : This class gives a frame for Actions which modify the effect
-- of a Dispatch, i.e. :
-- By Selections and Dispatches, an original Model can be
-- splitted into one or more "target" Models : these Models
-- contain Entities copied from the original one (that is, a
-- part of it). Basically, these dispatched Entities are copied
-- as identical to their original counterparts. Also the copied
-- Models reproduce the Header of the original one.
--
-- Modifiers allow to change this copied content : this is the
-- way to be used for any kind of alterations, adaptations ...
-- They are exploited by a ModelCopier, which firstly performs
-- the copy operation described by Dispatches, then invokes the
-- Modifiers to work on the result.
--
-- Each GeneralModifier can be attached to :
-- - all the Models produced
-- - a Dispatch (it will be applied to all the Models obtained
-- from this Dispatch) designated by its Ident in a ShareOut
-- - in addition, to a Selection (facultative) : this adds a
-- criterium, the Modifier is invoked on a produced Model only
-- if this Model contains an Entity copied from one of the
-- Entities designated by this Selection.
-- (for special Modifiers from IFAdapt, while they must work on
-- definite Entities, this Selection is mandatory to run)
--
-- Remark : this class has no action attached, it only provides
-- a frame to work on criteria. Then, sub-classes will define
-- their kind of action, which can be applied at a precise step
-- of the production of a File : see Modifier, and in the
-- package IFAdapt, EntityModifier and EntityCopier
uses AsciiString from TCollection, Selection, Dispatch
is
Initialize (maychangegraph : Boolean);
---Purpose : Sets the Modifier criteria to default Values
-- (i.e. "always applies")
-- <maychangegraph> must be provided at creation time, to :
-- - False if this GeneralModifier surely lets the graph of
-- dependencies unchanged (NO edition of any reference, BUT
-- also NO entity added or replaced or removed)
-- - True if there is a possibility of changing the graph of
-- dependencies when this modifier is applied
MayChangeGraph (me) returns Boolean;
---Purpose : Returns True if this modifier may change the graph of
-- dependences (aknowledged at creation time)
SetDispatch (me : mutable; disp : any Dispatch);
---Purpose : Attaches to a Dispatch. If <disp> is Null, Resets it
-- (to apply the Modifier on every Dispatch)
Dispatch (me) returns any Dispatch;
---Purpose : Returns the Dispatch to be matched, Null if not set
Applies (me; disp : Dispatch) returns Boolean;
---Purpose : Returns True if a Model obtained from the Dispatch <disp>
-- is to be treated (apart from the Selection criterium)
-- If Dispatch(me) is Null, returns True. Else, checks <disp>
SetSelection (me : mutable; sel : mutable Selection);
---Purpose : Sets a Selection : a Model is treated if it contains one or
-- more Entities designated by the Selection
ResetSelection (me : mutable);
---Purpose : Resets the Selection : this criterium is not longer active
HasSelection (me) returns Boolean;
---Purpose : Returns True if a Selection is set as an additionnal criterium
Selection (me) returns mutable Selection;
---Purpose : Returns the Selection, or a Null Handle if not set
Label (me) returns AsciiString from TCollection is deferred;
---Purpose : Returns a short text which defines the operation performed
fields
thesel : Selection;
thedisp : Dispatch;
thechgr : Boolean;
end GeneralModifier;

View File

@@ -0,0 +1,38 @@
#include <IFSelect_GeneralModifier.ixx>
IFSelect_GeneralModifier::IFSelect_GeneralModifier
(const Standard_Boolean maychangegraph) { thechgr = maychangegraph; }
Standard_Boolean IFSelect_GeneralModifier::MayChangeGraph () const
{ return thechgr; }
void IFSelect_GeneralModifier::SetDispatch
(const Handle(IFSelect_Dispatch)& disp)
{ thedisp = disp; }
Handle(IFSelect_Dispatch) IFSelect_GeneralModifier::Dispatch () const
{ return thedisp; }
Standard_Boolean IFSelect_GeneralModifier::Applies
(const Handle(IFSelect_Dispatch)& disp) const
{
if (thedisp.IsNull()) return Standard_True;
if (thedisp != disp) return Standard_False;
return Standard_True;
}
void IFSelect_GeneralModifier::SetSelection
(const Handle(IFSelect_Selection)& sel)
{ thesel = sel; }
void IFSelect_GeneralModifier::ResetSelection ()
{ thesel.Nullify(); }
Standard_Boolean IFSelect_GeneralModifier::HasSelection () const
{ return !thesel.IsNull(); }
Handle(IFSelect_Selection) IFSelect_GeneralModifier::Selection () const
{ return thesel; }

View File

@@ -0,0 +1,43 @@
-- File: IFSelect_GraphCounter.cdl
-- Created: Thu Oct 15 14:58:46 1998
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class GraphCounter from IFSelect inherits SignCounter from IFSelect
---Purpose : A GraphCounter computes values to be sorted with the help of
-- a Graph. I.E. not from a Signature
--
-- The default GraphCounter works with an Applied Selection (a
-- SelectDeduct), the value is the count of selected entities
-- from each input entities)
uses HSequenceOfTransient from TColStd,
Graph from Interface, SelectDeduct from IFSelect
is
Create (withmap : Boolean = Standard_True;
withlist : Boolean = Standard_False) returns mutable GraphCounter;
---Purpose : Creates a GraphCounter, without applied selection
Applied (me) returns SelectDeduct;
---Purpose : Returns the applied selection
SetApplied (me : mutable; sel : SelectDeduct);
---Purpose : Sets a new applied selection
AddWithGraph (me : mutable; list : HSequenceOfTransient; graph : Graph)
is redefined virtual;
---Purpose : Adds a list of entities in the context given by the graph
-- Default takes the count of entities selected by the applied
-- selection, when it is given each entity of the list
-- Can be redefined
fields
theapplied : SelectDeduct;
end GraphCounter;

View File

@@ -0,0 +1,49 @@
#include <IFSelect_GraphCounter.ixx>
#include <Interface_EntityIterator.hxx>
#include <IFSelect_SelectPointed.hxx>
#include <stdio.h>
#include <string.h>
IFSelect_GraphCounter::IFSelect_GraphCounter
(const Standard_Boolean withmap, const Standard_Boolean withlist)
: IFSelect_SignCounter (withmap,withlist) { }
Handle(IFSelect_SelectDeduct) IFSelect_GraphCounter::Applied () const
{ return theapplied; }
void IFSelect_GraphCounter::SetApplied
(const Handle(IFSelect_SelectDeduct)& applied)
{ theapplied = applied; }
void IFSelect_GraphCounter::AddWithGraph
(const Handle(TColStd_HSequenceOfTransient)& list,
const Interface_Graph& graph)
{
if (theapplied.IsNull()) { AddList (list,graph.Model()); return; }
if (list.IsNull()) return;
Standard_Integer i, nb = list->Length();
for (i = 1; i <= nb; i ++) {
char val[12];
Handle(Standard_Transient) ent = list->Value(i);
theapplied->Alternate()->SetEntity (ent);
Interface_EntityIterator iter = theapplied->UniqueResult(graph);
Standard_Integer n = iter.NbEntities();
switch (n) {
case 0: Add (ent,"0"); break;
case 1: Add (ent,"1"); break;
case 2: Add (ent,"2"); break;
case 3: Add (ent,"3"); break;
case 4: Add (ent,"4"); break;
case 5: Add (ent,"5"); break;
case 6: Add (ent,"6"); break;
case 7: Add (ent,"7"); break;
case 8: Add (ent,"8"); break;
case 9: Add (ent,"9"); break;
default :
sprintf (val,"%d",n);
Add (ent,val);
break;
}
}
}

View File

@@ -0,0 +1,60 @@
-- File: IntParam.cdl
-- Created: Mon Nov 30 16:57:11 1992
-- Author: Christian CAILLET
-- <cky@sdsun1>
---Copyright: Matra Datavision 1992
class IntParam from IFSelect inherits TShared
---Purpose : This class simply allows to access an Integer value through a
-- Handle, as a String can be (by using HString).
-- Hence, this value can be accessed : read and modified, without
-- passing through the specific object which detains it. Thus,
-- parameters of a Selection or a Dispatch (according its type)
-- can be controlled directly from the ShareOut which contains them
--
-- Additionnaly, an IntParam can be bound to a Static.
-- Remember that for a String, binding is immediate, because the
-- string value of a Static is a HAsciiString, it then suffices
-- to get its Handle.
-- For an Integer, an IntParam can designate (by its name) a
-- Static : each time its value is required or set, the Static
-- is aknowledged
uses Integer, CString, AsciiString
is
Create returns mutable IntParam;
---Purpose : Creates an IntParam. Initial value is set to zer
SetStaticName (me : mutable; statname : CString);
---Purpose : Commands this IntParam to be bound to a Static
-- Hence, Value will return the value if this Static if it is set
-- Else, Value works on the locally stored value
-- SetValue also will set the value of the Static
-- This works only for a present static of type integer or enum
-- Else, it is ignored
--
-- If <statname> is empty, disconnects the IntParam from Static
StaticName (me) returns CString;
---Purpose : Returns the name of static parameter to which this IntParam
-- is bound, empty if none
Value (me) returns Integer is static;
---Purpose : Reads Integer Value of the IntParam. If a StaticName is
-- defined and the Static is set, looks in priority the value
-- of the static
SetValue (me : mutable; val : Integer) is static;
---Purpose : Sets a new Integer Value for the IntParam. If a StaticName is
-- defined and the Static is set, also sets the value of the static
fields
theval : Integer;
thestn : AsciiString;
end IntParam;

View File

@@ -0,0 +1,24 @@
#include <IFSelect_IntParam.ixx>
#include <Interface_Static.hxx>
IFSelect_IntParam::IFSelect_IntParam ()
{ theval = 0; }
void IFSelect_IntParam::SetStaticName (const Standard_CString statname)
{ thestn.Clear(); thestn.AssignCat (statname); }
Standard_Integer IFSelect_IntParam::Value () const
{
if (thestn.Length() == 0) return theval;
if (!Interface_Static::IsSet(thestn.ToCString()) ) return theval;
return Interface_Static::IVal(thestn.ToCString());
}
void IFSelect_IntParam::SetValue (const Standard_Integer val)
{
theval = val;
if (thestn.Length() == 0) return;
if (!Interface_Static::IsPresent(thestn.ToCString()) ) return;
Interface_Static::SetIVal (thestn.ToCString(),theval);
}

View File

@@ -0,0 +1,141 @@
-- File: IFSelect_ListEditor.cdl
-- Created: Tue Jul 28 11:17:08 1998
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class ListEditor from IFSelect inherits TShared from MMgt
---Purpose : A ListEditor is an auxiliary operator for Editor/EditForm
-- I.E. it works on parameter values expressed as strings
--
-- For a parameter which is a list, it may not be edited in once
-- by just setting a new value (as a string)
--
-- Firstly, a list can be long (and tedious to be accessed flat)
-- then requires a better way of accessing
--
-- Moreover, not only its VALUES may be changed (SetValue), but
-- also its LENGTH : items may be added or removed ...
--
-- Hence, the way of editing a parameter as a list is :
-- - edit it separately, with the help of a ListEditor
-- - it remains possible to prepare a new list of values apart
-- - then give the new list in once to the EditForm
--
-- An EditList is produced by the Editor, with a basic definition
-- This definition (brought by this class) can be redefined
-- Hence the Editor may produce a specific ListEditor as needed
uses CString, HAsciiString from TCollection,
HSequenceOfHAsciiString from TColStd,
HSequenceOfInteger from TColStd,
TypedValue from Interface, InterfaceModel from Interface
is
Create returns ListEditor;
---Purpose : Creates a ListEditor with absolutely no constraint
Create (def : TypedValue; max : Integer = 0) returns ListEditor;
---Purpose : Creates a ListEditor, for which items of the list to edit are
-- defined by <def>, and <max> describes max length :
-- 0 (D) means no limit
-- value > 0 means : no more the <max> items are allowed
LoadModel (me : mutable; model : InterfaceModel);
---Purpose : Loads a Model. It is used to check items of type Entity(Ident)
LoadValues (me : mutable; vals : HSequenceOfHAsciiString);
---Purpose : Loads the original values for the list
-- Remark : If its length is mor then MaxLength, editions remain
-- allowed, except Add
SetTouched (me : mutable);
---Purpose : Declares this ListEditor to have been touched (whatever action)
ClearEdit (me : mutable);
---Purpose : Clears all editions already recorded
--- Editing : can be specialised
LoadEdited (me : mutable; list : HSequenceOfHAsciiString)
returns Boolean is virtual;
---Purpose : Loads a new list to replace the older one, in once !
-- By default (can be redefined) checks the length of the list
-- and the value of each item according to the def
-- Items are all recorded as Modified
--
-- If no def has been given at creation time, no check is done
-- Returns True when done, False if checks have failed ... a
-- specialisation may also lock it by returning always False ...
SetValue (me : mutable; num : Integer; val : HAsciiString)
returns Boolean is virtual;
---Purpose : Sets a new value for the item <num> (in edited list)
-- <val> may be a Null Handle, then the value will be cleared but
-- not removed
-- Returns True when done. False if <num> is out of range or if
-- <val> does not satisfy the definition
AddValue (me : mutable; val : HAsciiString; atnum : Integer = 0)
returns Boolean is virtual;
---Purpose : Adds a new item. By default appends (at the end of the list)
-- Can insert before a given rank <num>, if positive
-- Returns True when done. False if MaxLength may be overpassed
-- or if <val> does not satisfy the definition
Remove (me : mutable; num : Integer = 0; howmany : Integer = 1)
returns Boolean is virtual;
---Purpose : Removes items from the list
-- By default removes one item. Else, count given by <howmany>
-- Remove from rank <num> included. By default, from the end
-- Returns True when done, False (and does not work) if case of
-- out of range of if <howmany> is greater than current length
-- Results
OriginalValues (me) returns HSequenceOfHAsciiString;
---Purpose : Returns the value from which the edition started
EditedValues (me) returns HSequenceOfHAsciiString;
---Purpose : Returns the result of the edition
NbValues (me; edited : Boolean = Standard_True) returns Integer;
---Purpose : Returns count of values, edited (D) or original
Value (me; num : Integer; edited : Boolean = Standard_True)
returns HAsciiString;
---Purpose : Returns a value given its rank. Edited (D) or Original
-- A Null String means the value is cleared but not removed
IsChanged (me; num : Integer) returns Boolean;
---Purpose : Tells if a value (in edited list) has been changed, i.e.
-- either modified-value, or added
IsModified (me; num : Integer) returns Boolean;
---Purpose : Tells if a value (in edited list) has been modified-value
-- (not added)
IsAdded (me; num : Integer) returns Boolean;
---Purpose : Tells if a value (in edited list) has been added (new one)
IsTouched (me) returns Boolean;
---Purpose : Tells if at least one edition (SetValue-AddValue-Remove) has
-- been recorded
fields
themax : Integer;
thedef : TypedValue;
thetouc : Integer; -- global IsTouched
theorig : HSequenceOfHAsciiString;
theedit : HSequenceOfHAsciiString;
thestat : HSequenceOfInteger;
themodl : InterfaceModel;
end ListEditor;

View File

@@ -0,0 +1,192 @@
#include <IFSelect_ListEditor.ixx>
IFSelect_ListEditor::IFSelect_ListEditor ()
: themax (0) , thetouc (0) { }
IFSelect_ListEditor::IFSelect_ListEditor
(const Handle(Interface_TypedValue)& def, const Standard_Integer max)
: themax (max) , thedef (def) , thetouc (0) { }
void IFSelect_ListEditor::LoadModel (const Handle(Interface_InterfaceModel)& model)
{ themodl = model; }
void IFSelect_ListEditor::LoadValues (const Handle(TColStd_HSequenceOfHAsciiString)& vals)
{
theorig = vals;
ClearEdit();
}
void IFSelect_ListEditor::SetTouched ()
{ thetouc = 1; }
void IFSelect_ListEditor::ClearEdit ()
{
theedit = new TColStd_HSequenceOfHAsciiString();
thestat = new TColStd_HSequenceOfInteger();
if (theorig.IsNull()) return;
Standard_Integer i,nb = theorig->Length();
for (i = 1; i <= nb; i ++) {
theedit->Append (theorig->Value(i));
thestat->Append (0);
}
thetouc = 0;
}
// ######## CHECK ########
static Standard_Boolean CheckValue
(const Handle(TCollection_HAsciiString)& val,
const Handle(Interface_InterfaceModel)& modl,
const Handle(Interface_TypedValue)& thedef)
{
if (val.IsNull() || modl.IsNull() || thedef.IsNull()) return Standard_True;
Interface_ParamType pty = thedef->Type();
if (!thedef->Satisfies(val)) return Standard_False;
if (pty == Interface_ParamIdent && !val.IsNull()) {
if (modl->NextNumberForLabel(val->ToCString(),0) <= 0)
return Standard_False;
}
return Standard_True;
}
// ######## EDITION ########
Standard_Boolean IFSelect_ListEditor::LoadEdited
(const Handle(TColStd_HSequenceOfHAsciiString)& list)
{
if (list.IsNull()) return Standard_False;
Standard_Integer i, nb = list->Length();
if (nb > themax) return Standard_False;
Interface_ParamType pty = Interface_ParamText;
// check values
if (!thedef.IsNull()) {
pty = thedef->Type();
for (i = 1; i <= nb; i ++) {
Handle(TCollection_HAsciiString) newval = list->Value(i);
if (!CheckValue (newval,themodl,thedef)) return Standard_False;
}
}
// OK
theedit = list;
thestat = new TColStd_HSequenceOfInteger();
for (i = 1; i <= nb; i ++) thestat->Append (1);
thetouc = 1;
return Standard_True;
}
Standard_Boolean IFSelect_ListEditor::SetValue
(const Standard_Integer num, const Handle(TCollection_HAsciiString)& val)
{
if (theedit.IsNull()) return Standard_False;
if (num < 1 || num > theedit->Length()) return Standard_False;
// check value
if (!CheckValue(val,themodl,thedef)) return Standard_False;
// OK
theedit->SetValue (num,val);
thestat->SetValue (num,1);
thetouc = 1;
return Standard_True;
}
Standard_Boolean IFSelect_ListEditor::AddValue
(const Handle(TCollection_HAsciiString)& val, const Standard_Integer atnum)
{
if (theedit.IsNull()) return Standard_False;
if (themax > 0 && theedit->Length() >= themax) return Standard_False;
if (!CheckValue (val,themodl,thedef)) return Standard_False;
if (atnum > 0) {
theedit->InsertBefore (atnum,val);
thestat->InsertBefore (atnum,2);
} else {
theedit->Append (val);
thestat->Append (2);
}
thetouc = 2;
return Standard_True;
}
Standard_Boolean IFSelect_ListEditor::Remove
(const Standard_Integer num, const Standard_Integer howmany)
{
if (theedit.IsNull()) return Standard_False;
Standard_Integer nb = theedit->Length();
if (num < 0) return Standard_False;
if (num == 0) return Remove (nb-howmany,howmany);
if ((num+howmany) > nb) return Standard_False;
theedit->Remove(num,howmany);
thestat->Remove(num,howmany);
thetouc = 3;
return Standard_True;
}
// ######## QUERIES ########
Handle(TColStd_HSequenceOfHAsciiString) IFSelect_ListEditor::OriginalValues () const
{ return theorig; }
Handle(TColStd_HSequenceOfHAsciiString) IFSelect_ListEditor::EditedValues () const
{ return theedit; }
Standard_Integer IFSelect_ListEditor::NbValues (const Standard_Boolean edited) const
{
if (edited) return (theedit.IsNull() ? 0 : theedit->Length());
return (theorig.IsNull() ? 0 : theorig->Length());
}
Handle(TCollection_HAsciiString) IFSelect_ListEditor::Value
(const Standard_Integer num, const Standard_Boolean edited) const
{
Handle(TCollection_HAsciiString) val;
if (edited) {
if (theedit.IsNull()) return val;
if (num < 1 || num > theedit->Length()) return val;
val = theedit->Value(num);
} else {
if (theorig.IsNull()) return val;
if (num < 1 || num > theorig->Length()) return val;
val = theorig->Value(num);
}
return val;
}
Standard_Boolean IFSelect_ListEditor::IsChanged (const Standard_Integer num) const
{
if (thestat.IsNull()) return Standard_False;
if (num < 1 || num > thestat->Length()) return Standard_False;
Standard_Integer stat = thestat->Value(num);
return (stat != 0);
}
Standard_Boolean IFSelect_ListEditor::IsModified (const Standard_Integer num) const
{
if (thestat.IsNull()) return Standard_False;
if (num < 1 || num > thestat->Length()) return Standard_False;
Standard_Integer stat = thestat->Value(num);
return (stat == 1);
}
Standard_Boolean IFSelect_ListEditor::IsAdded (const Standard_Integer num) const
{
if (thestat.IsNull()) return Standard_False;
if (num < 1 || num > thestat->Length()) return Standard_False;
Standard_Integer stat = thestat->Value(num);
return (stat == 2);
}
Standard_Boolean IFSelect_ListEditor::IsTouched () const
{ return (thetouc != 0); }

View File

@@ -0,0 +1,258 @@
-- File: IFSelect_ModelCopier.cdl
-- Created: Thu Aug 26 17:47:09 1993
-- Author: Christian CAILLET
-- <cky@bravox>
---Copyright: Matra Datavision 1993
class ModelCopier from IFSelect inherits TShared
---Purpose : This class performs the Copy operations involved by the
-- description of a ShareOut (evaluated by a ShareOutResult)
-- plus, if there are, the Modifications on the results, with
-- the help of Modifiers. Each Modifier can work on one or more
-- resulting packets, accoding its criteria : it operates on a
-- Model once copied and filled with the content of the packet.
--
-- Modifiers can be :
-- - Model Modifiers, inheriting from the specific class Modifier
-- able to run on the content of a Model (header or entities),
-- activated by the ModelCopier itself
-- - File Modifiers, inheriting directly from GeneralModifier,
-- intended to be activated under the control of a WorkLibrary,
-- once the Model has been produced (i.e. to act on output
-- format, or other specific file features)
--
-- The Copy operations can be :
-- - immediately put to files : for each packet, a Model is
-- created and filled, then the file is output, at that's all
-- - memorized : for each packet, a Model is created and filled,
-- it is memorized with the corresponding file name.
-- it is possible to query the result of memorization (list of
-- produced Models and their file names)
-- -> it is also possible to send it into the files :
-- once files are written, the result is cleared
--
-- In addition, a list of really written files is managed :
-- A first call to BeginSentFiles clears the list and commands,
-- either to begin a new list, or to stop recording it. A call
-- to SentFiles returns the list (if recording has been required)
-- This list allows to globally exploit the set of produced files
--
-- Remark : For operations which concern specific Entities, see
-- also in package IFAdapt : a sub-class of ModelCopier allows
-- to work with EntityModifier, in addition to Modifier itself
-- which still applies to a whole copied Model.
uses AsciiString from TCollection,
HSequenceOfInteger from TColStd, HArray1OfInteger from TColStd,
SequenceOfAsciiString, HSequenceOfHAsciiString from TColStd,
InterfaceModel, Protocol, Graph, EntityIterator, CopyTool, CheckIterator,
ShareOutResult, ShareOut, WorkLibrary, GeneralModifier, Modifier,
SequenceOfGeneralModifier, SequenceOfInterfaceModel,
AppliedModifiers, SequenceOfAppliedModifiers
is
Create returns mutable ModelCopier;
---Purpose : Creates an empty ModelCopier
SetShareOut (me : mutable; sho : ShareOut);
---Purpose : Sets the ShareOut, which is used to define Modifiers to apply
ClearResult (me : mutable);
---Purpose : Clears the list of produced Models
AddFile (me : mutable; filename : AsciiString from TCollection;
content : InterfaceModel) returns Boolean;
---Purpose : Records a new File to be sent, as a couple
-- (Name as AsciiString, Content as InterfaceModel)
-- Returns True if Done, False if <filename> is already attached
-- to another File
NameFile (me : mutable; num : Integer; filename : AsciiString)
returns Boolean;
---Purpose : Changes the Name attached to a File which was formerly defined
-- by a call to AddFile
-- Returns True if Done, False else : if <num> out of range or if
-- the new <filename> is already attached to another File
-- Remark : Giving an empty File Name is equivalent to ClearFile
ClearFile (me : mutable; num : Integer) returns Boolean;
---Purpose : Clears the Name attached to a File which was formerly defined
-- by a call to AddFile. This Clearing can be undone by a call to
-- NameFile (with same <num>)
-- Returns True if Done, False else : if <num> is out of range
SetAppliedModifiers (me : mutable; num : Integer;
applied : mutable AppliedModifiers) returns Boolean;
---Purpose : Sets a list of File Modifiers to be applied on a file
ClearAppliedModifiers (me : mutable; num : Integer) returns Boolean;
---Purpose : Clears the list of File Modifiers to be applied on a file
Copy (me : mutable; eval : in out ShareOutResult;
WL : WorkLibrary; protocol : Protocol)
returns CheckIterator;
---Purpose : Performs the Copy Operations, which include the Modifications
-- defined by the list of Modifiers. Memorizes the result, as a
-- list of InterfaceModels with the corresponding FileNames
-- They can then be sent, by the method Send, or queried
-- Copy calls internal method Copying.
-- Returns the produced CheckList
Copying (me : mutable; eval : in out ShareOutResult;
WL : WorkLibrary; protocol : Protocol; TC : in out CopyTool)
returns CheckIterator is protected;
---Purpose : Internal routine which does the effective Copy. It allows to
-- work, either with a standard CopyTool, or a specialised one
-- Copying itself is done by <WL> which uses a CopyTool
SendCopied (me : mutable; WL : WorkLibrary; protocol : Protocol)
returns CheckIterator;
---Purpose : Sends the formerly defined results (see method Copy) to files,
-- then clears it
-- Remark : A Null File Name cause file to be not produced
Send (me : mutable; eval : in out ShareOutResult;
WL : WorkLibrary; protocol : Protocol)
returns CheckIterator;
---Purpose : Performs the Copy Operations (which include the Modifications)
-- and Sends the result on files, without memorizing it.
-- (the memorized result is ignored : neither queried not filled)
Sending (me : mutable; eval : in out ShareOutResult;
WL : WorkLibrary; protocol : Protocol; TC : in out CopyTool)
returns CheckIterator is protected;
---Purpose : Internal routine which does the effective Send. It allows to
-- work, either with a standard CopyTool, or a specialised one
SendAll (me : mutable; filename : CString; G : Graph;
WL : WorkLibrary; protocol : Protocol)
returns CheckIterator;
---Purpose : Sends a model (defined in <G>) into one file, without managing
-- remaining data, already sent files, etc. Applies the Model and
-- File Modifiers.
-- Returns True if well done, False else
SendSelected (me : mutable; filename : CString; G : Graph;
WL : WorkLibrary; protocol : Protocol;
iter : EntityIterator)
returns CheckIterator;
---Purpose : Sends a part of a model into one file. Model is gotten from
-- <G>, the part is defined in <iter>.
-- Remaining data are managed and can be later be worked on.
-- Returns True if well done, False else
CopiedModel (me; G : Graph;
WL : WorkLibrary;
protocol : Protocol;
topcopy : EntityIterator;
filename : AsciiString from TCollection;
dispnum, numod : Integer;
TC : in out CopyTool;
newmod : out mutable InterfaceModel;
applied : out mutable AppliedModifiers;
checks : out CheckIterator)
is protected;
---Purpose : Performs the Copy of a unitary Packet
-- Input parameters are :
-- <G> is the graph which defines the starting entities, it
-- contains the original InterfaceModel
-- <WL> performs the copy by using <TC>
-- <protocol> is the used protocol (can be usefull for Modifiers)
-- <topcopy> is the list of Entities which are the Roots of the
-- packet to be copied
-- <filename> is the name of the file which will receive it
-- <dispid> is the Identifier of the Dispatch which have produced
-- this packet, <numod> is the rank of the packet for this
-- Dispatch
-- <TC> is a CopyTool, which performs the copy
--
-- Returned values (as arguments) are :
-- <newmod> is the result of the copy, as a new InterfaceModel on
-- which Model Modifiers have already been applied (if there are)
-- <applied> determines the File Modifiers which remain to be
-- applied (when the file itself will be output) : for each File
-- Modifier recorded in <me>, <applied>'s Value is :
-- - Null if this Modifier has not to be applied
-- - an empty list if this Modifier has to be applied without
-- distinguishing specific entities
-- - a list of numbers of entities in <model> if this Modifier
-- concerns particularly these entities (which are the results
-- of copying the result of its input selection)
-- <checks> is the produced Check List (by Modifiers as required)
--
-- Warning : File Modifiers are evaluated at the time of Copy itself
-- If their list is changed between this Copy and the Sending
-- itself of the file, these changes are ignored
CopiedRemaining (me : mutable; G : Graph;
WL : WorkLibrary;
TC : in out CopyTool;
newmod : out mutable InterfaceModel);
---Purpose : Produces a Model copied from the Remaining List as <newmod>
-- <newmod> is a Null Handle if this list is empty
-- <WL> performs the copy by using <TC>
-- <TC> is assumed to have been defined with the starting model
-- same as defined by <G>.
SetRemaining (me; CG : in out Graph) returns Boolean;
---Purpose : Updates Graph status for remaining data, for each entity :
-- - Entities just Sent to file or Copied (by CopiedRemaining)
-- have their status set to 1
-- - the other keep their former status (1 for Send/Copied,
-- 0 for Remaining)
-- These status are computed by Copying/Sending/CopiedRemaining
-- Then, SetRemaining updates graph status, and mustr be called
-- just after one of these method has been called
-- Returns True if done, False if remaining info if not in phase
-- which the Graph (not same counts of items)
NbFiles (me) returns Integer;
---Purpose : Returns the count of Files produced, i.e. the count of Models
-- memorized (produced by the mmethod Copy) with their file names
FileName (me; num : Integer) returns AsciiString from TCollection;
---Purpose : Returns the File Name for a file given its rank
-- It is empty after a call to ClearFile on same <num>
FileModel (me; num : Integer) returns mutable InterfaceModel;
---Purpose : Returns the content of a file before sending, under the form
-- of an InterfaceModel, given its rank
AppliedModifiers (me; num : Integer) returns mutable AppliedModifiers;
---Purpose : Returns the list of File Modifiers to be applied on a file
-- when it will be sent, as computed by CopiedModel :
-- If it is a null handle, no File Modifier has to be applied.
BeginSentFiles (me : mutable; sho : mutable ShareOut; record : Boolean);
---Purpose : Begins a sequence of recording the really sent files
-- <sho> : the default file numbering is cleared
-- If <record> is False, clears the list and stops recording
-- If <record> is True, clears the list and commands recording
-- Creation time corresponds to "stop recording"
AddSentFile (me : mutable; filename : CString);
---Purpose : Adds the name of a just sent file, if BeginSentFiles
-- has commanded recording; else does nothing
-- It is called by methods SendCopied Sending
SentFiles (me) returns HSequenceOfHAsciiString from TColStd;
---Purpose : Returns the list of recorded names of sent files. Can be empty
-- (if no file has been sent). Returns a Null Handle if
-- BeginSentFiles has stopped recording.
fields
thefilemodels : SequenceOfInterfaceModel;
thefilenames : SequenceOfAsciiString;
theapplieds : SequenceOfAppliedModifiers;
theshareout : ShareOut; -- for copy-send operation (names, modifiers)
theremain : HArray1OfInteger;
thesentfiles : HSequenceOfHAsciiString;
end ModelCopier;

View File

@@ -0,0 +1,514 @@
#include <IFSelect_ModelCopier.ixx>
#include <IFSelect_Selection.hxx>
#include <IFSelect_GeneralModifier.hxx>
#include <IFSelect_Modifier.hxx>
#include <IFSelect_ContextModif.hxx>
#include <IFSelect_ContextWrite.hxx>
#include <TColStd_HSequenceOfInteger.hxx>
#include <TCollection_HAsciiString.hxx>
#include <Interface_Check.hxx>
#include <Interface_CheckIterator.hxx>
#include <Interface_GeneralLib.hxx>
#include <Message_Messenger.hxx>
#include <Message.hxx>
#include <stdio.h>
//#define MISOPOINT
IFSelect_ModelCopier::IFSelect_ModelCopier () { }
void IFSelect_ModelCopier::SetShareOut
(const Handle(IFSelect_ShareOut)& sho)
{ theshareout = sho; }
// ########################################################################
// ######## OPERATIONS DE TRANSFERT GLOBAL (memorise ou non) ########
void IFSelect_ModelCopier::ClearResult ()
{ thefilemodels.Clear(); thefilenames.Clear(); theapplieds.Clear();
theremain.Nullify(); }
Standard_Boolean IFSelect_ModelCopier::AddFile
(const TCollection_AsciiString& filename,
const Handle(Interface_InterfaceModel)& content)
{
Standard_Integer nb = thefilenames.Length();
for (Standard_Integer i = 1; i <= nb; i ++) {
if (filename.IsEmpty()) continue;
if (thefilenames(i).IsEqual(filename)) return Standard_False;
}
Handle(IFSelect_AppliedModifiers) nulapplied;
thefilenames.Append (filename);
thefilemodels.Append (content);
theapplieds.Append (nulapplied);
return Standard_True;
}
Standard_Boolean IFSelect_ModelCopier::NameFile
(const Standard_Integer num,
const TCollection_AsciiString& filename)
{
Standard_Integer nb = thefilenames.Length();
if (num <= 0 || num > nb) return Standard_False;
for (Standard_Integer i = 1; i <= nb; i ++) {
if (filename.IsEmpty()) continue;
if (thefilenames(i).IsEqual(filename)) return Standard_False;
}
thefilenames.SetValue(num,filename);
return Standard_True;
}
Standard_Boolean IFSelect_ModelCopier::ClearFile
(const Standard_Integer num)
{
Standard_Integer nb = thefilenames.Length();
if (num <= 0 || num > nb) return Standard_False;
thefilenames.ChangeValue(num).Clear();
return Standard_True;
}
Standard_Boolean IFSelect_ModelCopier::SetAppliedModifiers
(const Standard_Integer num, const Handle(IFSelect_AppliedModifiers)& applied)
{
Standard_Integer nb = theapplieds.Length();
if (num <= 0 || num > nb) return Standard_False;
theapplieds.SetValue(num,applied);
return Standard_True;
}
Standard_Boolean IFSelect_ModelCopier::ClearAppliedModifiers
(const Standard_Integer num)
{
Standard_Integer nb = theapplieds.Length();
if (num <= 0 || num > nb) return Standard_False;
theapplieds.ChangeValue(num).Nullify();
return Standard_True;
}
// .... Copy : Opere les Transferts, les Memorise (pas d envoi fichier ici)
Interface_CheckIterator IFSelect_ModelCopier::Copy
(IFSelect_ShareOutResult& eval,
const Handle(IFSelect_WorkLibrary)& WL,
const Handle(Interface_Protocol)& protocol)
{
Interface_CopyTool TC (eval.Graph().Model(), protocol);
return Copying (eval,WL,protocol,TC);
}
// Copy Interne
Interface_CheckIterator IFSelect_ModelCopier::Copying
(IFSelect_ShareOutResult& eval,
const Handle(IFSelect_WorkLibrary)& WL,
const Handle(Interface_Protocol)& protocol,
Interface_CopyTool& TC)
{
Message::DefaultMessenger() <<
"** WorkSession : Copying split data before sending"<<endl;
const Interface_Graph& G = eval.Graph();
Interface_CheckIterator checks;
theshareout = eval.ShareOut();
theremain = new TColStd_HArray1OfInteger(0,G.Size()); theremain->Init(0);
for (eval.Evaluate(); eval.More(); eval.Next()) {
Handle(Interface_InterfaceModel) model;
TCollection_AsciiString filename = eval.FileName();
Standard_Integer dispnum = eval.DispatchRank();
Standard_Integer numod, nbmod;
eval.PacketsInDispatch (numod,nbmod);
Handle(IFSelect_AppliedModifiers) curapp;
CopiedModel (G, WL,protocol, eval.PacketRoot(), filename,dispnum,numod, TC,
model, curapp,checks);
AddFile (filename, model);
theapplieds.SetValue (theapplieds.Length(), curapp);
}
theshareout->SetLastRun (theshareout->NbDispatches());
checks.SetName ("X-STEP WorkSession : Split Copy (no Write)");
return checks;
}
// Send a deux arguments : Envoi Fichier du Resultat deja memorise
Interface_CheckIterator IFSelect_ModelCopier::SendCopied
(const Handle(IFSelect_WorkLibrary)& WL,
const Handle(Interface_Protocol)& protocol)
{
Message::DefaultMessenger() <<
"** WorkSession : Sending split data already copied"<<endl;
Standard_Integer nb = NbFiles();
Interface_CheckIterator checks;
if (nb > 0) {
for (Standard_Integer i = 1; i <= nb; i ++) {
if (FileName(i).Length() == 0) continue;
Handle(IFSelect_AppliedModifiers) curapp = theapplieds.Value(i);
IFSelect_ContextWrite ctx (FileModel(i),protocol,curapp,FileName(i).ToCString());
Standard_Boolean res = WL->WriteFile (ctx);
Interface_CheckIterator checklst = ctx.CheckList();
checks.Merge(checklst);
// (FileName(i).ToCString(), FileModel(i),protocol,curapp,checks);
// if (!checks.IsEmpty(Standard_False)) {
// sout<<" ** On Sending File n0."<<i<<", Check Messages : **"<<endl;
// checks.Print (sout,Standard_False);
// }
if (!res) {
char mess[100]; sprintf(mess,"Split Send (WriteFile) abandon on file n0.%d",i);
checks.CCheck(0)->AddFail (mess);
Message::DefaultMessenger() <<
" ** Sending File n0."<<i<<" has failed, abandon **"<<endl;
return checks;
}
AddSentFile (FileName(i).ToCString());
}
ClearResult();
}
checks.SetName ("X-STEP WorkSession : Split Send (Copy+Write)");
return checks;
}
// .... Send a 4 arguments : Calcul du Transfert et Envoi sur Fichier
Interface_CheckIterator IFSelect_ModelCopier::Send
(IFSelect_ShareOutResult& eval,
const Handle(IFSelect_WorkLibrary)& WL,
const Handle(Interface_Protocol)& protocol)
{
Interface_CopyTool TC (eval.Graph().Model(), protocol);
return Sending (eval,WL,protocol,TC);
}
Interface_CheckIterator IFSelect_ModelCopier::Sending
(IFSelect_ShareOutResult& eval,
const Handle(IFSelect_WorkLibrary)& WL,
const Handle(Interface_Protocol)& protocol,
Interface_CopyTool& TC)
{
const Interface_Graph& G = eval.Graph();
Interface_CheckIterator checks;
Standard_Integer i = 0;
Message::DefaultMessenger() <<
"** WorkSession : Copying then sending split data"<<endl;
theshareout = eval.ShareOut();
theremain = new TColStd_HArray1OfInteger(0,G.Size()); theremain->Init(0);
for (eval.Evaluate(); eval.More(); eval.Next()) {
i ++;
Handle(Interface_InterfaceModel) model;
TCollection_AsciiString filename = eval.FileName();
Standard_Integer dispnum = eval.DispatchRank();
Standard_Integer numod, nbmod;
eval.PacketsInDispatch (numod,nbmod);
Handle(IFSelect_AppliedModifiers) curapp;
CopiedModel (G, WL,protocol, eval.PacketRoot(), filename,dispnum,numod, TC,
model, curapp, checks);
IFSelect_ContextWrite ctx (model,protocol,curapp,filename.ToCString());
Standard_Boolean res = WL->WriteFile (ctx);
Interface_CheckIterator checklst = ctx.CheckList();
checks.Merge(checklst);
// (filename.ToCString(), model, protocol, curapp, checks);
// if (!checks.IsEmpty(Standard_False)) {
// sout<<" ** On Sending File "<<filename<<", Check Messages : **"<<endl;
// checks.Print (sout,model,Standard_False);
// }
if (!res) {
char mess[100]; sprintf(mess,"Split Send (WriteFile) abandon on file n0.%d",i);
checks.CCheck(0)->AddFail (mess);
Message::DefaultMessenger() <<
" ** Sending File "<<filename<<" has failed, abandon **"<<endl;
checks.SetName ("X-STEP WorkSession : Split Send (only Write)");
return checks;
}
AddSentFile (filename.ToCString());
}
theshareout->SetLastRun (theshareout->NbDispatches());
checks.SetName ("X-STEP WorkSession : Split Send (only Write)");
return checks;
}
// .... SendAll : Donnees a tranferer dans G, aucun split, envoi sur fichier
Interface_CheckIterator IFSelect_ModelCopier::SendAll
(const Standard_CString filename, const Interface_Graph& G,
const Handle(IFSelect_WorkLibrary)& WL,
const Handle(Interface_Protocol)& protocol)
{
Interface_CheckIterator checks;
checks.SetName ("X-STEP WorkSession : Send All");
Message::DefaultMessenger() <<
"** WorkSession : Sending all data"<<endl;
Handle(Interface_InterfaceModel) model = G.Model();
if (model.IsNull() || protocol.IsNull() || WL.IsNull()) return checks;
Interface_CopyTool TC (model, protocol);
Standard_Integer i, nb = model->NbEntities();
for (i = 1; i <= nb; i ++) TC.Bind (model->Value(i),model->Value(i));
Interface_EntityIterator pipo;
Handle(Interface_InterfaceModel) newmod;
Handle(IFSelect_AppliedModifiers) applied;
CopiedModel (G, WL,protocol,pipo,TCollection_AsciiString(filename),
0,0,TC,newmod, applied,checks);
IFSelect_ContextWrite ctx (model,protocol,applied,filename);
Standard_Boolean res = WL->WriteFile (ctx);
Interface_CheckIterator checklst = ctx.CheckList();
checks.Merge(checklst);
if (!res) checks.CCheck(0)->AddFail ("SendAll (WriteFile) has failed");
// if (!checks.IsEmpty(Standard_False)) {
// Message::DefaultMessenger() <<
// " ** SendAll has produced Check Messages : **"<<endl;
// checks.Print (sout,model,Standard_False);
// }
return checks;
}
// .... SendSelected : Donnees a tranferer dans G, filtrees par iter,
// aucun split, envoi sur fichier
Interface_CheckIterator IFSelect_ModelCopier::SendSelected
(const Standard_CString filename, const Interface_Graph& G,
const Handle(IFSelect_WorkLibrary)& WL,
const Handle(Interface_Protocol)& protocol,
const Interface_EntityIterator& list)
{
Interface_CheckIterator checks;
checks.SetName ("X-STEP WorkSession : Send Selected");
Message::DefaultMessenger() <<
"** WorkSession : Sending selected data"<<endl;
Handle(Interface_InterfaceModel) original = G.Model();
if (original.IsNull() || protocol.IsNull() || WL.IsNull()) return checks;
Handle(Interface_InterfaceModel) newmod = original->NewEmptyModel();
Interface_CopyTool TC (original, protocol);
TC.FillModel(newmod); // pour Header ...
// Pas de copie : AddWithRefs plus declaration de Bind
Interface_GeneralLib lib(protocol);
for (list.Start(); list.More(); list.Next()) {
newmod->AddWithRefs (list.Value(),lib);
}
Standard_Integer i, nb = newmod->NbEntities();
for (i = 1; i <= nb; i ++) TC.Bind (newmod->Value(i),newmod->Value(i));
if (theremain.IsNull())
{ theremain = new TColStd_HArray1OfInteger(0,G.Size()); theremain->Init(0); }
Interface_EntityIterator pipo;
Handle(IFSelect_AppliedModifiers) applied;
CopiedModel (G, WL,protocol, pipo,TCollection_AsciiString(filename),
0,0,TC,newmod, applied,checks);
// Alimenter Remaining : les entites copiees sont a noter
Handle(Standard_Transient) ent1,ent2;
for (Standard_Integer ic = TC.LastCopiedAfter (0,ent1,ent2); ic > 0;
ic = TC.LastCopiedAfter (ic,ent1,ent2) ) {
if (ic <= theremain->Upper())
theremain->SetValue(ic,theremain->Value(ic)+1);
}
IFSelect_ContextWrite ctx (newmod,protocol,applied,filename);
Standard_Boolean res = WL->WriteFile (ctx);
Interface_CheckIterator checklst = ctx.CheckList();
checks.Merge(checklst);
if (!res) checks.CCheck(0)->AddFail ("SendSelected (WriteFile) has failed");
// if (!checks.IsEmpty(Standard_False)) {
// Message::DefaultMessenger() <<
// " ** SendSelected has produced Check Messages : **"<<endl;
// checks.Print (sout,original,Standard_False);
// }
return checks;
}
// ##########################################################################
// ######## UN TRANSFERT UNITAIRE (avec Modifications) ########
void IFSelect_ModelCopier::CopiedModel
(const Interface_Graph& G,
const Handle(IFSelect_WorkLibrary)& WL,
const Handle(Interface_Protocol)& protocol,
const Interface_EntityIterator& tocopy,
const TCollection_AsciiString& filename,
const Standard_Integer dispnum, const Standard_Integer /* numod */,
Interface_CopyTool& TC,
Handle(Interface_InterfaceModel)& newmod,
Handle(IFSelect_AppliedModifiers)& applied,
Interface_CheckIterator& checks) const
{
// ... Premiere partie "standard" : remplissage du modele ...
// On cree le Modele, on le remplit avec les Entites, et avec le Header depart
// ATTENTION : dispnum = 0 signifie prendre modele original, ne rien copier
// et aussi : pas de Dispatch (envoi en bloc)
applied.Nullify();
Handle(Interface_InterfaceModel) original = G.Model();
if (dispnum > 0) {
newmod = original->NewEmptyModel();
TC.Clear();
WL->CopyModel (original,newmod,tocopy,TC);
Handle(Standard_Transient) ent1,ent2;
// Alimenter Remaining : les entites copiees sont a noter
for (Standard_Integer ic = TC.LastCopiedAfter (0,ent1,ent2); ic > 0;
ic = TC.LastCopiedAfter (ic,ent1,ent2) ) {
if (ic <= theremain->Upper())
theremain->SetValue(ic,theremain->Value(ic)+1);
}
}
else if (newmod.IsNull()) newmod = original;
// ... Ensuite : On prend en compte les Model Modifiers ...
Standard_Integer nbmod = 0;
if (!theshareout.IsNull()) nbmod = theshareout->NbModifiers(Standard_True);
Standard_Integer i; // svv Jan11 2000 : porting on DEC
for (i = 1; i <= nbmod; i ++) {
Handle(IFSelect_Modifier) unmod = theshareout->ModelModifier(i);
// D abord, critere Dispatch/Packet
if (dispnum > 0)
if (!unmod->Applies (theshareout->Dispatch(dispnum))) continue;
IFSelect_ContextModif ctx (G,TC,filename.ToCString());
// Ensuite, la Selection
Handle(IFSelect_Selection) sel = unmod->Selection();
if (!sel.IsNull()) {
Interface_EntityIterator entiter = sel->UniqueResult(G);
ctx.Select (entiter);
}
if (ctx.IsForNone()) continue;
unmod->Perform (ctx,newmod,protocol,TC);
Interface_CheckIterator checklst = ctx.CheckList();
checks.Merge (checklst);
// Faut-il enregistrer les erreurs dans newmod ? bonne question
// if (!checks.IsEmpty(Standard_False)) {
// Message::DefaultMessenger() <<
// " Messages on Copied Model n0 "<<numod<<", Dispatch Rank "<<dispnum<<endl;
// checks.Print(sout,newmod,Standard_False);
// }
}
// ... Puis les File Modifiers : en fait, on les enregistre ...
nbmod = 0;
if (!theshareout.IsNull()) nbmod = theshareout->NbModifiers(Standard_False);
if (nbmod == 0) return;
applied = new IFSelect_AppliedModifiers (nbmod,newmod->NbEntities());
for (i = 1; i <= nbmod; i ++) {
Handle(IFSelect_GeneralModifier) unmod = theshareout->GeneralModifier(Standard_False,i);
// D abord, critere Dispatch/Packet
if (dispnum > 0)
if (!unmod->Applies (theshareout->Dispatch(dispnum))) continue;
// Ensuite, la Selection
Handle(IFSelect_Selection) sel = unmod->Selection();
if (sel.IsNull()) applied->AddModif (unmod); // vide -> on prend tout
else {
Interface_EntityIterator list = sel->UniqueResult(G);
Handle(Standard_Transient) newent;
// Entites designees par la Selection et Copiees ?
// -> s ilyena au moins une, le Modifier s applique, sinon il est rejete
// -> et cette liste est exploitable par le Modifier ...
for (list.Start(); list.More(); list.Next()) {
if (TC.Search (list.Value(),newent))
applied->AddNum (newmod->Number(newent));
}
}
}
}
void IFSelect_ModelCopier::CopiedRemaining
(const Interface_Graph& G, const Handle(IFSelect_WorkLibrary)& WL,
Interface_CopyTool& TC, Handle(Interface_InterfaceModel)& newmod)
{
Handle(Interface_InterfaceModel) original = G.Model();
// Interface_CopyTool TC(original,protocol);
newmod = original->NewEmptyModel();
TC.Clear();
Interface_EntityIterator tocopy;
Standard_Integer nb = G.Size();
theremain = new TColStd_HArray1OfInteger(0,nb+1); theremain->Init(0);
for (Standard_Integer i = 1; i <= nb; i ++) {
if (G.Status(i) == 0) tocopy.AddItem (original->Value(i));
else theremain->SetValue(i,-1); // ?? -1
}
WL->CopyModel (original,newmod,tocopy,TC);
if (newmod->NbEntities() == 0) newmod.Nullify();
else {
// CE QUI SUIT NE DOIT PAS ETRE SUPPRIME ! cf theremain
Handle(Standard_Transient) ent1,ent2;
for (Standard_Integer ic = TC.LastCopiedAfter (0,ent1,ent2); ic > 0;
ic = TC.LastCopiedAfter (ic,ent1,ent2) ) {
if (ic <= theremain->Upper())
theremain->SetValue(ic,1);
}
// qq impressions de mise au point
#ifdef MISOPOINT
cout << " Remaining Model : " << newmod->NbEntities() << " Entities"<<endl;
Standard_Integer ne = 0;
for (i = 1; i <= nb; i ++) {
if (theremain->Value(i) == 0) {
if (ne == 0) cout << " Refractaires : ";
ne ++; cout << " " << i;
}
}
if (ne > 0) cout << " -- " << ne << " Entities" << endl;
else cout<<" -- Remaining data complete"<<endl;
#endif
}
}
Standard_Boolean IFSelect_ModelCopier::SetRemaining
(Interface_Graph& CG) const
{
Standard_Integer nb = CG.Size();
if (theremain.IsNull()) return (nb == 0);
if (nb != theremain->Upper()) return Standard_False;
for (Standard_Integer i = 1; i <= nb; i ++) {
if (CG.Status(i) >= 0) CG.SetStatus(i,CG.Status(i)+theremain->Value(i));
}
theremain->Init(0);
return Standard_True;
}
// ##########################################################################
// ######## RESULTAT de la Memorisation des Transferts ########
Standard_Integer IFSelect_ModelCopier::NbFiles () const
{ return thefilemodels.Length(); }
TCollection_AsciiString IFSelect_ModelCopier::FileName
(const Standard_Integer num) const
{ return thefilenames.Value(num); }
Handle(Interface_InterfaceModel) IFSelect_ModelCopier::FileModel
(const Standard_Integer num) const
{ return thefilemodels.Value(num); }
Handle(IFSelect_AppliedModifiers) IFSelect_ModelCopier::AppliedModifiers
(const Standard_Integer num) const
{ return theapplieds.Value(num); }
void IFSelect_ModelCopier::BeginSentFiles
(const Handle(IFSelect_ShareOut)& sho, const Standard_Boolean record)
{
thesentfiles.Nullify();
if (record) thesentfiles = new TColStd_HSequenceOfHAsciiString();
// et numerotation des fichiers par defaut : detenue par ShareOut
if (sho.IsNull()) return;
Standard_Integer lastrun = sho->LastRun();
sho->ClearResult (Standard_True);
sho->SetLastRun (lastrun); // on ne s interesse quaux numeros
}
void IFSelect_ModelCopier::AddSentFile (const Standard_CString filename)
{ if (!thesentfiles.IsNull())
thesentfiles->Append(new TCollection_HAsciiString(filename)); }
Handle(TColStd_HSequenceOfHAsciiString) IFSelect_ModelCopier::SentFiles () const
{ return thesentfiles; }

View File

@@ -0,0 +1,63 @@
-- File: IFSelect_ModelModifier.cdl
-- Created: Mon Mar 21 16:07:03 1994
-- Author: Christian CAILLET
-- <cky@ecolox>
---Copyright: Matra Datavision 1994
deferred generic class ModelModifier from IFSelect
(Model as InterfaceModel; Proto as Protocol from Interface)
inherits Modifier
---Purpose : Allows to precise the frame work for Model Modifiers able to
-- run with an Interface (such as STEP, VDA, IGES ...)
--
-- Acts as a Modifier but properly casts Model and Protocol
-- according to each Interface, and refuses to work if cast
-- has failed (i.e. if it is not used in good context)
--
-- Then, it is finer to make specific Model Modifier inherit
-- from an instantiated ModelModifier, instead of Modifier itself
-- (though it is not mandatory)
--
-- For each Interface on which Model Modifiers have to be defined,
-- The way to follow is firstly to instantiate ModelModifier with
-- its specific data :
-- Model is the InterfaceModel specific to the considered norm
-- Then to define the various classes which inherit from it and
-- define their method Perform
uses CString, InterfaceModel, Protocol from Interface, CopyTool, ContextModif
is
Initialize (maychangegraph : Boolean);
---Purpose : Calls inherited Initialize, transmits to it the information
-- <maychangegraph>
Perform (me; ctx : in out ContextModif;
target : mutable InterfaceModel;
protocol : Protocol from Interface;
TC : in out CopyTool);
---Purpose : The inherited Perform does the required cast (and refuses to
-- go further if cast has failed) then calls the instantiated
-- Performing
PerformProtocol (me; ctx : in out ContextModif;
target : mutable Model;
proto : Proto;
TC : in out CopyTool) is virtual;
---Purpose : Specific Perform with Protocol. It is defined to let the
-- Protocol unused and to call Performing without Protocol
-- (most current case). It can be redefined if specific action
-- requires Protocol.
Performing (me; ctx : in out ContextModif;
target : mutable Model;
TC : in out CopyTool) is deferred;
---Purpose : Specific Perform, without Protocol. If Performing with
-- Protocol is redefined, Performing without Protocol must
-- though be defined to do nothing (not called, but demanded
-- by the linker)
end ModelModifier;

View File

@@ -0,0 +1,28 @@
//#include <IFSelect_ModelModifier.ixx>
#include <Interface_Check.hxx>
IFSelect_ModelModifier::IFSelect_ModelModifier (const Standard_Boolean grf)
: IFSelect_Modifier (grf) { }
void IFSelect_ModelModifier::Perform
(IFSelect_ContextModif& ctx,
const Handle(Interface_InterfaceModel)& target,
const Handle(Interface_Protocol)& protocol,
Interface_CopyTool& TC) const
{
ctx.TraceModifier(this);
Handle(Model) targ = Handle(Model)::DownCast(target);
Handle(Proto) prot = Handle(Proto)::DownCast(protocol);
if (targ.IsNull()) {
ctx.CCheck()->AddFail("Model to Modify : unproper type");
return;
}
PerformProtocol (ctx,targ,prot,TC);
}
void IFSelect_ModelModifier::PerformProtocol
(IFSelect_ContextModif& ctx,
const Handle(Model)& target,
const Handle(Proto)& protocol,
Interface_CopyTool& TC) const
{ ctx.SetProtocol(protocol); Performing (ctx,target,TC); }

View File

@@ -0,0 +1,37 @@
-- File: IFSelect_ModifEditForm.cdl
-- Created: Fri Feb 27 18:24:16 1998
-- Author: Christian CAILLET
-- <cky@heliox>
---Copyright: Matra Datavision 1996
class ModifEditForm from IFSelect inherits Modifier
---Purpose : This modifier applies an EditForm on the entities selected
uses CString, AsciiString from TCollection,
InterfaceModel, CopyTool, Protocol from Interface, ContextModif,
EditForm
is
Create (editform : EditForm) returns mutable ModifEditForm;
---Purpose : Creates a ModifEditForm. It may not change the graph
EditForm (me) returns EditForm;
---Purpose : Returns the EditForm
Perform (me; ctx : in out ContextModif;
target : mutable InterfaceModel;
protocol : Protocol from Interface;
TC : in out CopyTool);
---Purpose : Acts by applying an EditForm to entities, selected or all model
Label (me) returns AsciiString from TCollection;
---Purpose : Returns Label as "Apply EditForm <+ label of EditForm>"
fields
theedit : EditForm;
end ModifEditForm;

View File

@@ -0,0 +1,33 @@
#include <IFSelect_ModifEditForm.ixx>
IFSelect_ModifEditForm::IFSelect_ModifEditForm
(const Handle(IFSelect_EditForm)& editform)
: IFSelect_Modifier (Standard_False) { theedit = editform; }
Handle(IFSelect_EditForm) IFSelect_ModifEditForm::EditForm () const
{ return theedit; }
void IFSelect_ModifEditForm::Perform
(IFSelect_ContextModif& ctx,
const Handle(Interface_InterfaceModel)& target,
const Handle(Interface_Protocol)& protocol,
Interface_CopyTool& TC) const
{
for (ctx.Start(); ctx.More(); ctx.Next()) {
Standard_Boolean done = theedit->ApplyData(ctx.ValueResult(),target);
if (done) ctx.Trace();
else ctx.AddWarning (ctx.ValueResult(),"EditForm could not be applied");
}
}
TCollection_AsciiString IFSelect_ModifEditForm::Label () const
{
Standard_CString editlab = theedit->Label();
TCollection_AsciiString lab ("Apply EditForm");
if (editlab && editlab[0] != '\0') {
lab.AssignCat (" : ");
lab.AssignCat (editlab);
}
return lab;
}

View File

@@ -0,0 +1,41 @@
-- File: IFSelect_ModifReorder.cdl
-- Created: Fri Mar 15 09:37:46 1996
-- Author: Christian CAILLET
-- <cky@fidox>
---Copyright: Matra Datavision 1996
class ModifReorder from IFSelect inherits Modifier
---Purpose : This modifier reorders a whole model from its roots, i.e.
-- according to <rootlast> status, it considers each of its
-- roots, then it orders all its shared entities at any level,
-- the result begins by the lower level entities ... ends by
-- the roots.
uses CString, AsciiString from TCollection,
InterfaceModel, CopyTool, Protocol from Interface, ContextModif
is
Create (rootlast : Boolean = Standard_True) returns mutable ModifReorder;
---Purpose : Creates a ModifReorder. It may change the graph (it does !)
-- If <rootlast> is True (D), roots are set at the end of packets
-- Else, they are set at beginning (as done by AddWithRefs)
Perform (me; ctx : in out ContextModif;
target : mutable InterfaceModel;
protocol : Protocol from Interface;
TC : in out CopyTool);
---Purpose : Acts by computing orders (by method All from ShareTool) then
-- forcing them in the model. Remark that selection is ignored :
-- ALL the model is processed in once
Label (me) returns AsciiString from TCollection;
---Purpose : Returns Label as "Reorder, Roots (last or first)"
fields
thertl : Boolean;
end ModifReorder;

View File

@@ -0,0 +1,23 @@
#include <IFSelect_ModifReorder.ixx>
#include <Interface_ShareTool.hxx>
#include <Interface_EntityIterator.hxx>
IFSelect_ModifReorder::IFSelect_ModifReorder (const Standard_Boolean rootlast)
: IFSelect_Modifier (Standard_True) { thertl = rootlast; }
void IFSelect_ModifReorder::Perform
(IFSelect_ContextModif& ctx, const Handle(Interface_InterfaceModel)& target,
const Handle(Interface_Protocol)& protocol, Interface_CopyTool& TC) const
{
Interface_ShareTool sht (ctx.OriginalGraph());
Interface_EntityIterator list = sht.All (ctx.OriginalModel(),thertl);
target->ClearEntities();
for (list.Start(); list.More(); list.Next()) target->AddEntity (list.Value());
}
TCollection_AsciiString IFSelect_ModifReorder::Label () const
{
Standard_CString astr = (Standard_CString ) ( thertl ? "Reorder, Roots last" : "Reorder, Roots first");
return TCollection_AsciiString( astr ) ;
// ( thertl ? "Reorder, Roots last" : "Reorder, Roots first");
}

View File

@@ -0,0 +1,42 @@
-- File: IFSelect_Modifier.cdl
-- Created: Thu Aug 26 15:58:50 1993
-- Author: Christian CAILLET
-- <cky@bravox>
---Copyright: Matra Datavision 1993
deferred class Modifier from IFSelect inherits GeneralModifier
---Purpose : This class gives a frame for Actions which can work globally
-- on a File once completely defined (i.e. afterwards)
--
-- Remark : if no Selection is set as criterium, the Modifier is
-- set to work and should consider all the content of the Model
-- produced.
uses CString, InterfaceModel, CopyTool, Protocol from Interface, ContextModif
is
Initialize (maychangegraph : Boolean);
---Purpose : Calls inherited Initialize, transmits to it the information
-- <maychangegraph>
Perform (me; ctx : in out ContextModif;
target : mutable InterfaceModel;
protocol : Protocol from Interface;
TC : in out CopyTool) is deferred;
---Purpose : This deferred method defines the action specific to each class
-- of Modifier. It is called by a ModelCopier, once the Model
-- generated and filled. ModelCopier has already checked the
-- criteria (Dispatch, Model Rank, Selection) before calling it.
--
-- <ctx> detains informations about original data and selection.
-- The result of copying, on which modifications are to be done,
-- is <target>.
-- <TC> allows to run additional copies as required
--
-- In case of Error, use methods CCheck from the ContextModif
-- to aknowledge an entity Check or a Global Check with messages
end Modifier;

View File

@@ -0,0 +1,5 @@
#include <IFSelect_Modifier.ixx>
IFSelect_Modifier::IFSelect_Modifier (const Standard_Boolean grf)
: IFSelect_GeneralModifier (grf) { }

View File

@@ -0,0 +1,94 @@
-- File: IFSelect_PacketList.cdl
-- Created: Fri Sep 2 17:02:43 1994
-- Author: Christian CAILLET
-- <cky@anion>
---Copyright: Matra Datavision 1994
class PacketList from IFSelect inherits TShared
---Purpose : This class gives a simple way to return then consult a
-- list of packets, determined from the content of a Model,
-- by various criteria.
--
-- It allows to describe several lists with entities from a
-- given model, possibly more than one list knowing every entity,
-- and to determine the remaining list (entities in no lists) and
-- the duplications (with their count).
uses Array1OfInteger, IntList, HSequenceOfTransient, AsciiString,
EntityIterator, InterfaceModel
raises InterfaceError
is
Create (model : InterfaceModel) returns mutable PacketList;
---Purpose : Creates a PackList, empty, ready to receive entities from a
-- given Model
SetName (me : mutable; name : CString) is static;
---Purpose : Sets a name to a packet list : this makes easier a general
-- routine to print it. Default is "Packets"
Name (me) returns CString is static;
---Purpose : Returns the recorded name for a packet list
Model (me) returns InterfaceModel;
---Purpose : Returns the Model of reference
AddPacket (me : mutable);
---Purpose : Declares a new Packet, ready to be filled
-- The entities to be added will be added to this Packet
Add (me : mutable; ent : Transient)
---Purpose : Adds an entity from the Model into the current packet for Add
raises InterfaceError;
-- Error if <ent> is not from the Model, or if no AddPacket was
-- yet called
AddList (me : mutable; list : HSequenceOfTransient)
---Purpose : Adds an list of entities into the current packet for Add
raises InterfaceError;
-- Error if on of the items of <list> is not from the Model, or
-- if no AddPacket was yet called
NbPackets (me) returns Integer;
---Purpose : Returns the count of non-empty packets
NbEntities (me; numpack : Integer) returns Integer;
---Purpose : Returns the count of entities in a Packet given its rank, or 0
Entities (me; numpack : Integer) returns EntityIterator;
---Purpose : Returns the content of a Packet given its rank
-- Null Handle if <numpack> is out of range
HighestDuplicationCount (me) returns Integer;
---Purpose : Returns the highest number of packets which know a same entity
-- For no duplication, should be one
NbDuplicated (me; count : Integer; andmore : Boolean) returns Integer;
---Purpose : Returns the count of entities duplicated :
-- <count> times, if <andmore> is False, or
-- <count> or more times, if <andmore> is True
-- See Duplicated for more details
Duplicated (me; count : Integer; andmore : Boolean) returns EntityIterator;
---Purpose : Returns a list of entities duplicated :
-- <count> times, if <andmore> is False, or
-- <count> or more times, if <andmore> is True
-- Hence, count=2 & andmore=True gives all duplicated entities
-- count=1 gives non-duplicated entities (in only one packet)
-- count=0 gives remaining entities (in no packet at all)
fields
themodel : InterfaceModel;
thedupls : Array1OfInteger;
thepacks : IntList;
theflags : Array1OfInteger; -- for only once par packet !
thelast : Integer;
thebegin : Boolean;
thename : AsciiString;
end PacketList;

View File

@@ -0,0 +1,132 @@
// Copyright: Matra-Datavision 1994
// File: IFSelect_PacketList.cxx
// Created: Fri Sep 2 17:22:21 1994
// Author: Christian CAILLET
// <cky>
#include <IFSelect_PacketList.ixx>
#include <TColStd_HSequenceOfInteger.hxx>
#include <Interface_InterfaceError.hxx>
IFSelect_PacketList::IFSelect_PacketList
(const Handle(Interface_InterfaceModel)& model)
: thedupls (0,model->NbEntities()) ,
thepacks (100) ,
theflags (0,model->NbEntities()) ,
thename ("Packets")
{
themodel = model; thelast = 0; thebegin = Standard_False; // begin-begin
thedupls.Init(0); theflags.Init(0);
}
void IFSelect_PacketList::SetName (const Standard_CString name)
{ thename.Clear(); thename.AssignCat (name); }
Standard_CString IFSelect_PacketList::Name () const
{ return thename.ToCString(); }
Handle(Interface_InterfaceModel) IFSelect_PacketList::Model () const
{ return themodel; }
void IFSelect_PacketList::AddPacket ()
{
Standard_Integer nbl = thepacks.NbEntities();
Standard_Integer nbe = theflags.Upper();
for (Standard_Integer i = 1; i <= nbe; i ++) theflags.SetValue(i,0);
if (thelast >= nbl) thepacks.SetNbEntities (nbl*2);
if (!thebegin) thelast ++;
thepacks.SetNumber (thelast);
thebegin = Standard_False;
}
void IFSelect_PacketList::Add
(const Handle(Standard_Transient)& ent)
{
Standard_Integer num = themodel->Number(ent);
if (num == 0) Interface_InterfaceError::Raise
("PacketList:Add, Entity not in Model");
if (thelast == 0) Interface_InterfaceError::Raise
("PacketList:Add, no Packet yet added");
if (theflags(num) != 0) return;
theflags(num) = 1;
thedupls(num) ++;
thepacks.Add(num);
thebegin = Standard_False;
}
void IFSelect_PacketList::AddList
(const Handle(TColStd_HSequenceOfTransient)& list)
{
if (list.IsNull()) return;
Standard_Integer i , nb = list->Length();
thepacks.Reservate (nb+1);
for (i = 1; i <= nb; i ++) Add (list->Value(i));
}
Standard_Integer IFSelect_PacketList::NbPackets () const
{ return (thebegin ? thelast-1 : thelast); }
Standard_Integer IFSelect_PacketList::NbEntities
(const Standard_Integer numpack) const
{
if (numpack <= 0 || numpack > NbPackets()) return 0;
Interface_IntList lisi(thepacks,Standard_False); lisi.SetNumber (numpack);
return lisi.Length();
}
Interface_EntityIterator IFSelect_PacketList::Entities
(const Standard_Integer numpack) const
{
Interface_EntityIterator list;
if (numpack <= 0 || numpack > NbPackets()) return list;
Interface_IntList lisi(thepacks,Standard_False); lisi.SetNumber (numpack);
Standard_Integer i , nb = lisi.Length();
for (i = 1; i <= nb; i ++)
list.AddItem(themodel->Value(lisi.Value(i)));
return list;
}
Standard_Integer IFSelect_PacketList::HighestDuplicationCount () const
{
Standard_Integer i , nb = themodel->NbEntities();
Standard_Integer high = 0;
for (i = 1; i <= nb; i ++) {
Standard_Integer j = thedupls.Value(i);
if (j > high) high = j;
}
return high;
}
Standard_Integer IFSelect_PacketList::NbDuplicated
(const Standard_Integer newcount, const Standard_Boolean andmore) const
{
Standard_Integer i, nb = themodel->NbEntities();
Standard_Integer nbdu = 0;
for (i = 1; i <= nb; i ++) {
Standard_Integer j = thedupls.Value(i);
if (j == newcount || (j > newcount && andmore)) nbdu ++;
}
return nbdu;
}
Interface_EntityIterator IFSelect_PacketList::Duplicated
(const Standard_Integer newcount, const Standard_Boolean andmore) const
{
Standard_Integer nb = themodel->NbEntities();
Interface_EntityIterator list;
Standard_Integer i;
for (i = 1; i <= nb; i ++) {
Standard_Integer j = thedupls.Value(i);
if (j == newcount || (j > newcount && andmore)) list.AddItem(themodel->Value(i));
}
return list;
}

View File

@@ -0,0 +1,65 @@
-- File: IFSelect_ParamEditor.cdl
-- Created: Thu Jul 30 15:59:48 1998
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class ParamEditor from IFSelect inherits Editor from IFSelect
---Purpose : A ParamEditor gives access for edition to a list of TypedValue
-- (i.e. of Static too)
-- Its definition is made of the TypedValue to edit themselves,
-- and can add some constants, which can then be displayed but
-- not changed (for instance, system name, processor version ...)
--
-- I.E. it gives a way of editing or at least displaying
-- parameters as global
uses CString, Transient, AsciiString, HAsciiString, HSequenceOfHAsciiString,
InterfaceModel, EditForm, TypedValue
is
Create (nbmax : Integer = 100; label : CString = "") returns ParamEditor;
---Purpose : Creates a ParamEditor, empty, with a maximum count of params
-- (default is 100)
-- And a label, by default it will be "Param Editor"
AddValue (me : mutable; val : TypedValue; shortname : CString = "");
---Purpose : Adds a TypedValue
-- By default, its short name equates its complete name, it can
-- be explicited
AddConstantText (me : mutable; val : CString;
shortname : CString; completename : CString = "");
---Purpose : Adds a Constant Text, it will be Read Only
-- By default, its long name equates its shortname
Label (me) returns AsciiString;
Recognize (me; form : EditForm) returns Boolean;
StringValue (me; form : EditForm; num : Integer)
returns HAsciiString from TCollection;
Load (me; form : EditForm; ent : Transient; model : InterfaceModel)
returns Boolean;
Apply (me; form : EditForm; ent : Transient; model : InterfaceModel)
returns Boolean;
StaticEditor (myclass; list : HSequenceOfHAsciiString;
label : CString = "") returns ParamEditor;
---Purpose : Returns a ParamEditor to work on the Static Parameters of
-- which names are listed in <list>
-- Null Handle if <list> is null or empty
fields
thelabel : AsciiString;
end ParamEditor;

View File

@@ -0,0 +1,84 @@
#include <IFSelect_ParamEditor.ixx>
#include <Interface_Static.hxx>
IFSelect_ParamEditor::IFSelect_ParamEditor
(const Standard_Integer nbmax, const Standard_CString label)
: IFSelect_Editor (nbmax) , thelabel (label)
{
SetNbValues (0);
if (thelabel.Length() == 0) thelabel.AssignCat ("Param Editor");
}
void IFSelect_ParamEditor::AddValue
(const Handle(Interface_TypedValue)& val, const Standard_CString shortname)
{
SetNbValues (NbValues() + 1);
SetValue (NbValues(), val, shortname);
}
void IFSelect_ParamEditor::AddConstantText
(const Standard_CString val, const Standard_CString shortname,
const Standard_CString longname)
{
Handle(Interface_TypedValue) tv = new Interface_TypedValue
(longname[0] == '\0' ? shortname : longname);
tv->SetCStringValue (val);
SetNbValues (NbValues() + 1);
SetValue (NbValues(), tv, shortname, IFSelect_EditRead);
}
TCollection_AsciiString IFSelect_ParamEditor::Label () const
{ return thelabel; }
Standard_Boolean IFSelect_ParamEditor::Recognize
(const Handle(IFSelect_EditForm)& form) const
{ return Standard_True; } // pas de contrainte
Handle(TCollection_HAsciiString) IFSelect_ParamEditor::StringValue
(const Handle(IFSelect_EditForm)& form,const Standard_Integer num) const
{ return TypedValue(num)->HStringValue(); }
Standard_Boolean IFSelect_ParamEditor::Load
(const Handle(IFSelect_EditForm)& form,
const Handle(Standard_Transient)& ent,
const Handle(Interface_InterfaceModel)& model) const
{
Standard_Integer i, nb = NbValues();
for (i = 1; i <= nb; i ++) form->LoadValue (i,TypedValue(i)->HStringValue());
return Standard_True;
}
Standard_Boolean IFSelect_ParamEditor::Apply
(const Handle(IFSelect_EditForm)& form,
const Handle(Standard_Transient)& ent,
const Handle(Interface_InterfaceModel)& model) const
{
Standard_Integer i, nb = NbValues();
for (i = 1; i <= nb; i ++)
if (form->IsModified(i))
TypedValue (i)->SetHStringValue (form->EditedValue(i));
return Standard_True;
}
Handle(IFSelect_ParamEditor) IFSelect_ParamEditor::StaticEditor
(const Handle(TColStd_HSequenceOfHAsciiString)& list,
const Standard_CString label)
{
Handle(IFSelect_ParamEditor) editor;
if (list.IsNull()) return editor;
Standard_Integer i,nb = list->Length();
// if (nb == 0) return editor;
editor = new IFSelect_ParamEditor (nb+10,label);
for (i = 1; i <= nb; i ++) {
Handle(Interface_Static) val = Interface_Static::Static
(list->Value(i)->ToCString());
if (!val.IsNull()) editor->AddValue(val);
}
return editor;
}

View File

@@ -0,0 +1,114 @@
-- File: IFSelect_SelectAnyList.cdl
-- Created: Wed Dec 9 11:57:08 1992
-- Author: Christian CAILLET
-- <cky@topsn3>
---Copyright: Matra Datavision 1992
deferred class SelectAnyList from IFSelect inherits SelectDeduct
---Purpose : A SelectAnyList kind Selection selects a List of an Entity, as
-- well as this Entity contains some. A List contains sub-entities
-- as one per Item, or several (for instance if an Entity binds
-- couples of sub-entities, each item is one of these couples).
-- Remark that only Entities are taken into account (neither
-- Reals, nor Strings, etc...)
--
-- To define the list on which to work, SelectAnyList has two
-- deferred methods : NbItems (which gives the length of the
-- list), FillResult (which fills an EntityIterator). They are
-- intended to get a List in an Entity of the required Type (and
-- consider that list is empty if Entity has not required Type)
--
-- In addition, remark that some types of Entity define more than
-- one list in each instance : a given sub-class of SelectAnyList
-- must be attached to one list
--
-- SelectAnyList keeps or rejects a sub-set of the list,
-- that is the Items of which rank in the list is in a given
-- range (for instance form 2nd to 6th, etc...)
-- Range is defined by two Integer values. In order to allow
-- external control of them, these values are not directly
-- defined as fields, but accessed through IntParams, that is,
-- referenced as Transient (Handle) objects
--
-- Warning : the Input can be any kind of Selection, BUT its
-- RootResult must have zero (empty) or one Entity maximum
uses AsciiString from TCollection, Transient, EntityIterator, Graph, IntParam
raises OutOfRange, InterfaceError
is
KeepInputEntity (me; iter : in out EntityIterator) is deferred;
---Purpose : Keeps Input Entity, as having required type. It works by
-- keeping in <iter>, only suitable Entities (SelectType can be
-- used). Called by RootResult (which waits for ONE ENTITY MAX)
NbItems (me; ent : Transient) returns Integer is deferred;
---Purpose : Returns count of Items in the list in the Entity <ent>
-- If <ent> has not required type, returned value must be Zero
SetRange (me : mutable; rankfrom, rankto : mutable IntParam);
---Purpose : Sets a Range for numbers, with a lower and a upper limits
SetOne (me : mutable; rank : mutable IntParam);
---Purpose : Sets a unique number (only one Entity will be sorted as True)
SetFrom (me : mutable; rankfrom : mutable IntParam);
---Purpose : Sets a Lower limit but no upper limit
SetUntil (me : mutable; rankto : mutable IntParam);
---Purpose : Sets an Upper limit but no lower limit (equivalent to lower 1)
HasLower (me) returns Boolean;
---Purpose : Returns True if a Lower limit is defined
Lower (me) returns mutable IntParam;
---Purpose : Returns Lower limit (if there is; else, value is senseless)
LowerValue (me) returns Integer;
---Purpose : Returns Integer Value of Lower Limit (0 if none)
HasUpper (me) returns Boolean;
---Purpose : Returns True if a Lower limit is defined
Upper (me) returns mutable IntParam;
---Purpose : Returns Upper limit (if there is; else, value is senseless)
UpperValue (me) returns Integer;
---Purpose : Returns Integer Value of Upper Limit (0 if none)
RootResult (me; G : Graph) returns EntityIterator raises InterfaceError;
---Purpose : Returns the list of selected entities (list of entities
-- complying with rank criterium)
-- Error if the input list has more than one Item
FillResult (me; n1,n2 : Integer; ent : Transient;
res : in out EntityIterator) is deferred;
---Purpose : Puts into <res>, the sub-entities of the list, from n1 to
-- n2 included. Remark that adequation with Entity's type and
-- length of list has already been made at this stage
-- Called by RootResult
Label (me) returns AsciiString from TCollection;
---Purpose : Returns a text defining the criterium : "Componants of List "
-- then Specific List Label, then, following cases :
-- " From .. Until .." or "From .." or "Until .." or "Rank no .."
-- Specific type is given by deferred method ListLabel
ListLabel (me) returns AsciiString from TCollection is deferred;
---Purpose : Returns the specific label for the list, which is included as
-- a part of Label
fields
thelower : IntParam;
theupper : IntParam;
end SelectAnyList;

View File

@@ -0,0 +1,92 @@
#include <IFSelect_SelectAnyList.ixx>
#include <Interface_InterfaceError.hxx>
#include <stdio.h>
// .... Definition de liste : methodes "deferred" NbItems & FillResult
void IFSelect_SelectAnyList::SetRange
(const Handle(IFSelect_IntParam)& rankfrom,
const Handle(IFSelect_IntParam)& rankto)
{ thelower = rankfrom; theupper = rankto; }
void IFSelect_SelectAnyList::SetOne (const Handle(IFSelect_IntParam)& rank)
{ thelower = theupper = rank; }
void IFSelect_SelectAnyList::SetFrom
(const Handle(IFSelect_IntParam)& rankfrom)
{ thelower = rankfrom; theupper.Nullify(); }
void IFSelect_SelectAnyList::SetUntil
(const Handle(IFSelect_IntParam)& rankto)
{ thelower.Nullify(); theupper = rankto; }
Standard_Boolean IFSelect_SelectAnyList::HasLower () const
{ return (!thelower.IsNull()); }
Handle(IFSelect_IntParam) IFSelect_SelectAnyList::Lower () const
{ return thelower; }
Standard_Integer IFSelect_SelectAnyList::LowerValue () const
{
if (thelower.IsNull()) return 0;
return thelower->Value();
}
Standard_Boolean IFSelect_SelectAnyList::HasUpper () const
{ return (!theupper.IsNull()); }
Handle(IFSelect_IntParam) IFSelect_SelectAnyList::Upper () const
{ return theupper; }
Standard_Integer IFSelect_SelectAnyList::UpperValue () const
{
if (theupper.IsNull()) return 0;
return theupper->Value();
}
// On prend les sous-entites de lower a upper (inclus)
Interface_EntityIterator IFSelect_SelectAnyList::RootResult
(const Interface_Graph& G) const
{
Interface_EntityIterator input = InputResult(G);
KeepInputEntity (input); // selon type voulu
if (input.NbEntities() > 1) Interface_InterfaceError::Raise
("SelectAnyList : more than ONE Entity in input");
if (input.NbEntities() == 0) return input;
Handle(Standard_Transient) ent;
for (input.Start(); input.More(); input.Next()) ent = input.Value();
Standard_Integer rankmax = NbItems(ent);
Standard_Integer rankfrom = 1;
if (!thelower.IsNull()) rankfrom = thelower->Value();
Standard_Integer rankto;
if (!theupper.IsNull()) rankto = theupper->Value();
else rankto = rankmax;
if (rankfrom < 1) rankfrom = 1;
if (rankto > rankmax) rankto = rankmax;
Interface_EntityIterator iter;
if (rankfrom <= rankto) FillResult(rankfrom,rankto,ent,iter);
return iter;
}
TCollection_AsciiString IFSelect_SelectAnyList::Label () const
{
char lab[30];
Standard_Integer rankfrom = 0;
if (HasLower()) rankfrom = LowerValue();
Standard_Integer rankto = 0;
if (HasUpper()) rankto = UpperValue();
if (rankfrom == rankto) sprintf(lab," (no %d)",rankfrom);
else if (rankfrom == 0) sprintf(lab," (-> %d)",rankfrom);
else if (rankto == 0) sprintf(lab," (%d ->)",rankto);
else sprintf(lab," (%d -> %d)",rankfrom,rankto);
TCollection_AsciiString labl("In List ");
labl.AssignCat(ListLabel());
labl.AssignCat(lab);
return labl;
}

View File

@@ -0,0 +1,27 @@
-- File: SelectAnyType.cdl
-- Created: Wed Nov 18 10:34:22 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
deferred class SelectAnyType from IFSelect inherits SelectExtract
---Purpose : A SelectAnyType sorts the Entities of which the Type is Kind
-- of a given Type : this Type for Match is specific of each
-- class of SelectAnyType
uses Type, InterfaceModel
is
TypeForMatch (me) returns Type is deferred;
---Purpose : Returns the Type which has to be matched for select
Sort (me; rank : Integer; ent : Transient; model : InterfaceModel)
returns Boolean;
---Purpose : Returns True for an Entity (model->Value(num)) which is kind
-- of the choosen type, given by the method TypeForMatch.
-- Criterium is IsKind.
end SelectAnyType;

View File

@@ -0,0 +1,7 @@
#include <IFSelect_SelectAnyType.ixx>
Standard_Boolean IFSelect_SelectAnyType::Sort
(const Standard_Integer , const Handle(Standard_Transient)& ent,
const Handle(Interface_InterfaceModel)& ) const
{ return ent->IsKind(TypeForMatch()); }

View File

@@ -0,0 +1,21 @@
-- File: SelectBase.cdl
-- Created: Tue Nov 17 18:47:13 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
deferred class SelectBase from IFSelect inherits Selection
---Purpose : SelectBase works directly from an InterfaceModel : it is the
-- first base for other Selections.
uses SelectionIterator
is
FillIterator (me; iter : in out SelectionIterator);
---Purpose : Puts in an Iterator the Selections from which "me" depends
-- This list is empty for all SelectBase type Selections
end SelectBase;

View File

@@ -0,0 +1,7 @@
#include <IFSelect_SelectBase.ixx>
void IFSelect_SelectBase::FillIterator
(IFSelect_SelectionIterator& ) const
{ } // rien a faire, une SelectBase ne depend d aucune autre Selection

View File

@@ -0,0 +1,63 @@
-- File: SelectCombine.cdl
-- Created: Tue Nov 17 19:02:56 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
deferred class SelectCombine from IFSelect inherits Selection
---Purpose : A SelectCombine type Selection defines algebraic operations
-- between results of several Selections
-- It is a deferred class : sub-classes will have to define
-- precise what operator is to be applied
uses AsciiString from TCollection, EntityIterator,
Graph, SelectionIterator, TSeqOfSelection
is
Initialize;
---Purpose : Defines an empty SelectCombine
NbInputs (me) returns Integer;
---Purpose : Returns the count of Input Selections
Input (me; num : Integer) returns mutable Selection;
---Purpose : Returns an Input Selection, given its rank in the list
InputRank (me; sel : Selection) returns Integer;
---Purpose : Returns the rank of an input Selection, 0 if not in the list.
-- Most generally, its value is meaningless, except for testing
-- the presence of an input Selection :
-- - == 0 if <sel> is not an input for <me>
-- - > 0 if <sel> is an input for <me>
Add (me : mutable; sel : mutable Selection; atnum : Integer = 0);
---Purpose : Adds a Selection to the filling list
-- By default, adds it to the end of the list
-- A Positive rank less then NbInputs gives an insertion rank
-- (InsertBefore : the new <atnum>th item of the list is <sel>)
Remove (me : mutable; sel : Selection) returns Boolean;
---Purpose : Removes an input Selection.
-- Returns True if Done, False, if <sel> is not an input for <me>
Remove (me : mutable; num : Integer) returns Boolean;
---Purpose : Removes an input Selection, given its rank in the list
-- Returns True if Done, False if <num> is out of range
HasUniqueResult (me) returns Boolean is redefined protected;
---Purpose : Returns always True, because RootResult gives a Unique list
FillIterator (me; iter : in out SelectionIterator);
---Purpose : Puts in an Iterator the Selections from which "me" depends
-- That is to say, the list of Input Selections
fields
thelist : TSeqOfSelection;
end SelectCombine;

View File

@@ -0,0 +1,50 @@
#include <IFSelect_SelectCombine.ixx>
#include <IFGraph_Cumulate.hxx>
IFSelect_SelectCombine::IFSelect_SelectCombine () { }
// { thelist = new IFSelect_SequenceOfSelection(); }
Standard_Integer IFSelect_SelectCombine::NbInputs () const
{ return thelist.Length(); }
Handle(IFSelect_Selection) IFSelect_SelectCombine::Input
(const Standard_Integer num) const
{ return thelist.Value(num); }
Standard_Integer IFSelect_SelectCombine::InputRank
(const Handle(IFSelect_Selection)& sel) const
{
if (sel.IsNull()) return 0;
Standard_Integer i, nb = thelist.Length();
for (i = 1; i <= nb; i ++)
if (sel == thelist.Value(i)) return i;
return 0;
}
void IFSelect_SelectCombine::Add
(const Handle(IFSelect_Selection)& sel, const Standard_Integer atnum)
{
if (atnum <= 0 || atnum > thelist.Length()) thelist.Append(sel);
else thelist.InsertBefore(atnum,sel);
}
Standard_Boolean IFSelect_SelectCombine::Remove
(const Handle(IFSelect_Selection)& sel)
{ return Remove (InputRank(sel)); }
Standard_Boolean IFSelect_SelectCombine::Remove
(const Standard_Integer num)
{
if (num <= 0 || num > thelist.Length()) return Standard_False;
thelist.Remove(num);
return Standard_True;
}
Standard_Boolean IFSelect_SelectCombine::HasUniqueResult () const
{ return Standard_True; }
void IFSelect_SelectCombine::FillIterator
(IFSelect_SelectionIterator& iter) const
{ iter.AddList(thelist); }

View File

@@ -0,0 +1,59 @@
-- File: IFSelect_SelectControl.cdl
-- Created: Wed Feb 16 10:07:01 1994
-- Author: Christian CAILLET
-- <cky@mastox>
---Copyright: Matra Datavision 1994
deferred class SelectControl from IFSelect inherits Selection
---Purpose : A SelectControl kind Selection works with two input Selections
-- in a dissymmetric way : the Main Input which gives an input
-- list of Entities, to be processed, and the Second Input which
-- gives another list, to be used to filter the main input.
--
-- e.g. : SelectDiff retains the items of the Main Input which
-- are not in the Control Input (which acts as Diff Input)
-- or a specific selection which retains Entities from the Main
-- Input if and only if they are concerned by an entity from
-- the Control Input (such as Views in IGES, etc...)
--
-- The way RootResult and Label are produced are at charge of
-- each sub-class
uses SelectionIterator
is
MainInput (me) returns mutable Selection;
---Purpose : Returns the Main Input Selection
HasSecondInput (me) returns Boolean;
---Purpose : Returns True if a Control Input is defined
-- Thus, Result can be computed differently if there is a
-- Control Input or if there is none
SecondInput (me) returns mutable Selection;
---Purpose : Returns the Control Input Selection, or a Null Handle
SetMainInput (me : mutable; sel : mutable Selection);
---Purpose : Sets a Selection to be the Main Input
SetSecondInput (me : mutable; sel : mutable Selection);
---Purpose : Sets a Selection to be the Control Input
-- RootResult,Label remain to be defined by each class of Selection
-- (also HasUniqueResult if it applies)
FillIterator (me; iter : in out SelectionIterator);
---Purpose : Puts in an Iterator the Selections from which "me" depends
-- That is to say, the list of Input Selections
fields
themain : Selection;
thesecond : Selection;
end SelectControl;

View File

@@ -0,0 +1,28 @@
#include <IFSelect_SelectControl.ixx>
Handle(IFSelect_Selection) IFSelect_SelectControl::MainInput () const
{ return themain; }
Handle(IFSelect_Selection) IFSelect_SelectControl::SecondInput () const
{ return thesecond; }
Standard_Boolean IFSelect_SelectControl::HasSecondInput () const
{ return (!thesecond.IsNull()); }
void IFSelect_SelectControl::SetMainInput
(const Handle(IFSelect_Selection)& sel)
{ themain = sel; }
void IFSelect_SelectControl::SetSecondInput
(const Handle(IFSelect_Selection)& sel)
{ thesecond = sel; }
void IFSelect_SelectControl::FillIterator
(IFSelect_SelectionIterator& iter) const
{
iter.AddItem(themain);
if (!thesecond.IsNull()) iter.AddItem(thesecond);
}

View File

@@ -0,0 +1,71 @@
-- File: SelectDeduct.cdl
-- Created: Tue Nov 17 19:13:08 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
deferred class SelectDeduct from IFSelect inherits Selection
---Purpose : A SelectDeduct determines a list of Entities from an Input
-- Selection, by a computation : Output list is not obliged to be
-- a sub-list of Input list
-- (for more specific, see SelectExtract for filtered sub-lists,
-- and SelectExplore for recurcive exploration)
--
-- A SelectDeduct may use an alternate input for one shot
-- This allows to use an already existing definition, by
-- overloading the input selection by an alternate list,
-- already defined, for one use :
-- If this alternate list is set, InputResult queries it instead
-- of calling the input selection, then clears it immediately
uses AsciiString from TCollection, EntityIterator, Graph,
SelectionIterator, SelectPointed
raises InterfaceError
is
SetInput (me : mutable; sel : mutable Selection);
---Purpose : Defines or Changes the Input Selection
Input (me) returns mutable Selection;
---Purpose : Returns the Input Selection
HasInput (me) returns Boolean;
---Purpose : Returns True if the Input Selection is defined, False else
HasAlternate (me) returns Boolean;
---Purpose : Tells if an Alternate List has been set, i.e. : the Alternate
-- Definition is present and set
Alternate (me : mutable) returns SelectPointed;
---Purpose : Returns the Alternate Definition
-- It is returned modifiable, hence an already defined
-- SelectPointed can be used
-- But if it was not yet defined, it is created the first time
--
-- It is exploited by InputResult
---C++ : return &
InputResult (me; G : Graph) returns EntityIterator;
---Purpose : Returns the Result determined by Input Selection, as Unique
-- if Input Selection is not defined, returns an empty list.
--
-- If Alternate is set, InputResult takes its definition instead
-- of calling the Input Selection, then clears it
-- RootResult remains to be defined by each class of Selection
FillIterator (me; iter : in out SelectionIterator);
---Purpose : Puts in an Iterator the Selections from which "me" depends
-- This list contains one Selection : the InputSelection
fields
thesel : Selection;
thealt : SelectPointed;
end SelectDeduct;

View File

@@ -0,0 +1,40 @@
#include <IFSelect_SelectDeduct.ixx>
void IFSelect_SelectDeduct::SetInput (const Handle(IFSelect_Selection)& sel)
{ thesel = sel; }
Handle(IFSelect_Selection) IFSelect_SelectDeduct::Input () const
{ return thesel; }
Standard_Boolean IFSelect_SelectDeduct::HasInput () const
{ return (!thesel.IsNull()); }
Standard_Boolean IFSelect_SelectDeduct::HasAlternate () const
{ if (!thealt.IsNull()) return thealt->IsSet(); return Standard_False; }
Handle(IFSelect_SelectPointed)& IFSelect_SelectDeduct::Alternate ()
{
if (thealt.IsNull()) thealt = new IFSelect_SelectPointed;
return thealt;
}
Interface_EntityIterator IFSelect_SelectDeduct::InputResult
(const Interface_Graph& G) const
{
Interface_EntityIterator res;
if (!thealt.IsNull()) {
if (thealt->IsSet()) {
res = thealt->UniqueResult (G);
thealt->Clear();
return res;
}
}
if (thesel.IsNull()) return res;
return thesel->UniqueResult(G);
}
void IFSelect_SelectDeduct::FillIterator
(IFSelect_SelectionIterator& iter) const
{ iter.AddItem(thesel); }

View File

@@ -0,0 +1,32 @@
-- File: SelectDiff.cdl
-- Created: Wed Nov 18 16:40:10 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
class SelectDiff from IFSelect inherits SelectControl
---Purpose : A SelectDiff keeps the entities from a Selection, the Main
-- Input, which are not listed by the Second Input
uses AsciiString from TCollection, EntityIterator, Graph
is
Create returns mutable SelectDiff;
---Purpose : Creates an empty SelectDiff
RootResult (me; G : Graph) returns EntityIterator;
---Purpose : Returns the list of selected entities : they are the Entities
-- gotten from the Main Input but not from the Diff Input
HasUniqueResult (me) returns Boolean is redefined protected;
---Purpose : Returns always True, because RootResult gives a Unique list
Label (me) returns AsciiString from TCollection;
---Purpose : Returns a text defining the criterium : "Difference"
end SelectDiff;

View File

@@ -0,0 +1,22 @@
#include <IFSelect_SelectDiff.ixx>
#include <IFGraph_Compare.hxx>
IFSelect_SelectDiff::IFSelect_SelectDiff () { }
Interface_EntityIterator IFSelect_SelectDiff::RootResult
(const Interface_Graph& G) const
{
IFGraph_Compare GC(G);
GC.GetFromIter(MainInput()->RootResult(G),Standard_True); // first
if (HasSecondInput())
GC.GetFromIter(SecondInput()->RootResult(G),Standard_False); // second
return GC.FirstOnly();
}
Standard_Boolean IFSelect_SelectDiff::HasUniqueResult () const
{ return Standard_True; } // naturellement unique
TCollection_AsciiString IFSelect_SelectDiff::Label () const
{ return TCollection_AsciiString("Differences"); }

View File

@@ -0,0 +1,40 @@
-- File: SelectEntityNumber.cdl
-- Created: Wed Nov 18 17:26:53 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
class SelectEntityNumber from IFSelect inherits SelectBase
---Purpose : A SelectEntityNumber gets in an InterfaceModel (through a
-- Graph), the Entity which has a specified Number (its rank of
-- adding into the Model) : there can be zero (if none) or one.
-- The Number is not directly defined as an Integer, but as a
-- Parameter, which can be externally controled
uses AsciiString from TCollection, EntityIterator, Graph, IntParam
is
Create returns mutable SelectEntityNumber;
---Purpose : Creates a SelectEntityNumber, initially with no specified Number
SetNumber (me : mutable; num : mutable IntParam);
---Purpose : Sets Entity Number to be taken (initially, none is set : 0)
Number (me) returns mutable IntParam;
---Purpose : Returns specified Number (as a Parameter)
RootResult (me; G : Graph) returns EntityIterator;
---Purpose : Returns the list of selected entities : the Entity having the
-- specified Number (this result assures naturally uniqueness)
Label (me) returns AsciiString from TCollection;
---Purpose : Returns a text defining the criterium : "Entity Number ..."
fields
thenum : IntParam;
end SelectEntityNumber;

View File

@@ -0,0 +1,32 @@
#include <IFSelect_SelectEntityNumber.ixx>
#include <Interface_InterfaceModel.hxx>
IFSelect_SelectEntityNumber::IFSelect_SelectEntityNumber () { }
void IFSelect_SelectEntityNumber::SetNumber
(const Handle(IFSelect_IntParam)& num)
{ thenum = num; }
Handle(IFSelect_IntParam) IFSelect_SelectEntityNumber::Number () const
{ return thenum; }
Interface_EntityIterator IFSelect_SelectEntityNumber::RootResult
(const Interface_Graph& G) const
{
Interface_EntityIterator iter;
Standard_Integer num = 0;
if (!thenum.IsNull()) num = thenum->Value();
if (num < 1) return iter; // vide si num < 1 ou num > NbEntities
if (num <= G.Size()) iter.GetOneItem(G.Entity(num));
return iter;
}
TCollection_AsciiString IFSelect_SelectEntityNumber::Label () const
{
Standard_Integer num = 0;
if (!thenum.IsNull()) num = thenum->Value();
TCollection_AsciiString labl(num);
labl.InsertBefore (1,"Entity Number ");
return labl;
}

View File

@@ -0,0 +1,32 @@
-- File: SelectErrorEntities.cdl
-- Created: Wed Nov 18 10:07:57 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
class SelectErrorEntities from IFSelect inherits SelectExtract
---Purpose : A SelectErrorEntities sorts the Entities which are qualified
-- as "Error" (their Type has not been recognized) during reading
-- a File. This does not concern Entities which are syntactically
-- correct, but with incorrect data (for integrity constraints).
uses AsciiString from TCollection, InterfaceModel
is
Create returns mutable SelectErrorEntities;
---Purpose : Creates a SelectErrorEntities
Sort (me; rank : Integer; ent : Transient; model : InterfaceModel)
returns Boolean;
---Purpose : Returns True for an Entity which is qualified as "Error", i.e.
-- if <model> explicitly knows <ent> (through its Number) as
-- Erroneous
ExtractLabel (me) returns AsciiString from TCollection;
---Purpose : Returns a text defining the criterium : "Error Entities"
end SelectErrorEntities;

View File

@@ -0,0 +1,13 @@
#include <IFSelect_SelectErrorEntities.ixx>
IFSelect_SelectErrorEntities::IFSelect_SelectErrorEntities () { }
Standard_Boolean IFSelect_SelectErrorEntities::Sort
(const Standard_Integer , const Handle(Standard_Transient)& ent,
const Handle(Interface_InterfaceModel)& model) const
//.. ne peut pas marcher, il faut aussi le modele ! ex. via le graphe ...
{ return model->IsErrorEntity (model->Number(ent)); }
TCollection_AsciiString IFSelect_SelectErrorEntities::ExtractLabel () const
{ return TCollection_AsciiString("Error Entities"); }

View File

@@ -0,0 +1,72 @@
-- File: IFSelect_SelectExplore.cdl
-- Created: Wed Sep 25 09:28:48 1996
-- Author: Christian CAILLET
-- <cky@fidox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
deferred class SelectExplore from IFSelect inherits SelectDeduct
---Purpose : A SelectExplore determines from an input list of Entities,
-- a list obtained by a way of exploration. This implies the
-- possibility of recursive exploration : the output list is
-- itself reused as input, etc...
-- Examples : Shared Entities, can be considered at one level
-- (immediate shared) or more, or max level
--
-- Then, for each input entity, if it is not rejected, it can be
-- either taken itself, or explored : it then produces a list.
-- According to a level, either the produced lists or taken
-- entities give the result (level one), or lists are themselves
-- considered and for each item, is it taken or explored.
--
-- Remark that rejection is just a safety : normally, an input
-- entity is, either taken itself, or explored
-- A maximum level can be specified. Else, the process continues
-- until all entities have been either taken or rejected
uses AsciiString from TCollection, InterfaceModel, EntityIterator, Graph
is
Initialize (level : Integer);
---Purpose : Initializes a SelectExplore : the level must be specified on
-- starting. 0 means all levels, 1 means level one only, etc...
Level (me) returns Integer;
---Purpose : Returns the required exploring level
RootResult (me; G : Graph) returns EntityIterator;
---Purpose : Returns the list of selected entities. Works by calling the
-- method Explore on each input entity : it can be rejected,
-- taken for output, or to explore. If the maximum level has not
-- yet been attained, or if no max level is specified, entities
-- to be explored are themselves used as if they were input
Explore (me; level : Integer; ent : Transient; G : Graph;
explored : in out EntityIterator)
returns Boolean is deferred;
---Purpose : Analyses and, if required, Explores an entity, as follows :
-- The explored list starts as empty, it has to be filled by this
-- method.
-- If it returns False, <ent> is rejected for result (this is to
-- be used only as safety)
-- If it returns True and <explored> remains empty, <ent> is
-- taken itself for result, not explored
-- If it returns True and <explored> is not empty, the content
-- of this list is considered :
-- If maximum level is attained, it is taken for result
-- Else (or no max), each of its entity will be itself explored
Label (me) returns AsciiString from TCollection;
---Purpose : Returns a text saying "(Recursive)" or "(Level nn)" plus
-- specific criterium returned by ExploreLabel (see below)
ExploreLabel (me) returns AsciiString from TCollection is deferred;
---Purpose : Returns a text defining the way of exploration
fields
thelevel : Integer;
end SelectExplore;

View File

@@ -0,0 +1,83 @@
#include <IFSelect_SelectExplore.ixx>
#include <TColStd_IndexedMapOfTransient.hxx>
#include <stdio.h>
IFSelect_SelectExplore::IFSelect_SelectExplore (const Standard_Integer level)
: thelevel (level) { }
Standard_Integer IFSelect_SelectExplore::Level () const
{ return thelevel; }
Interface_EntityIterator IFSelect_SelectExplore::RootResult
(const Interface_Graph& G) const
{
// Attention, voila comme on procede
// On a une IndexedMapOfTransient en entree (entites deja traitees/a traiter)
// Elle est initialisee par InputResult
// Et une map en sortie (resultats pris) -> le resultat sera unique
// En entree, un curseur d entite courante
// Pour chaque entite, on appelle Explore. 3 cas possibles :
// retour False, on passe
// retour True et liste vide, on prend cette entite sans aller plus loin
// retour True et liste non vide, on ne prend pas cette entite mais on
// considere son resultat.
// Si dernier niveau, on le prend en entier. Sinon, il alimente l entree
Standard_Integer nb = G.Size();
TColStd_IndexedMapOfTransient entrees (nb);
TColStd_IndexedMapOfTransient result (nb);
// Initialisation
Standard_Integer i, j, level = 1, ilev = 0;
Interface_EntityIterator input; input = InputResult(G);
for (input.Start(); input.More(); input.Next())
i = entrees.Add (input.Value());
ilev = entrees.Extent();
// Exploration
for (i = 1; i <= nb; i ++) {
if (i > entrees.Extent()) break;
if (i > ilev) {
level ++;
if (level > thelevel && thelevel > 0) break;
ilev = entrees.Extent();
}
Handle(Standard_Transient) ent = entrees.FindKey(i);
if (ent.IsNull()) continue;
Interface_EntityIterator exp;
if (!Explore (level,ent,G,exp)) continue;
// On prend en compte : entite a prendre directement ?
// reprendre liste en entree (niveau pas atteint) ou resultat (niveau atteint)
if (exp.NbEntities() == 0) {
j = result.Add (ent);
continue;
} else if (level == thelevel) {
for (exp.Start(); exp.More(); exp.Next()) j = result.Add (exp.Value());
} else {
for (exp.Start(); exp.More(); exp.Next()) j = entrees.Add (exp.Value());
}
}
// On recolte le resultat
Interface_EntityIterator res;
nb = result.Extent();
for (j = 1; j <= nb; j ++) res.AddItem (result.FindKey(j));
return res;
}
TCollection_AsciiString IFSelect_SelectExplore::Label () const
{
TCollection_AsciiString labl;
if (thelevel == 0) labl.AssignCat("(Recursive)");
else if (thelevel > 0) {
char lab[30];
sprintf (lab,"(Level %d)",thelevel);
labl.AssignCat(lab);
}
labl.AssignCat(ExploreLabel());
return labl;
}

View File

@@ -0,0 +1,70 @@
-- File: SelectExtract.cdl
-- Created: Tue Nov 17 19:19:26 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
deferred class SelectExtract from IFSelect inherits SelectDeduct
---Purpose : A SelectExtract determines a list of Entities from an Input
-- Selection, as a sub-list of the Input Result
-- It works by applying a sort criterium on each Entity of the
-- Input. This criterium can be applied Direct to Pick Items
-- (default case) or Reverse to Remove Item
--
-- Basic features (the unique Input) are inherited from SelectDeduct
uses AsciiString from TCollection, InterfaceModel, EntityIterator, Graph
is
Initialize;
---Purpose : Initializes a SelectExtract : enforces the sort to be Direct
IsDirect (me) returns Boolean;
---Purpose : Returns True if Sort criterium is Direct, False if Reverse
SetDirect (me : mutable; direct : Boolean);
---Purpose : Sets Sort criterium sense to a new value
-- (True : Direct , False : Reverse)
-- Input : see SelectDeduct
RootResult (me; G : Graph) returns EntityIterator is virtual;
---Purpose : Returns the list of selected entities. Works by calling the
-- method Sort on each input Entity : the Entity is kept as
-- output if Sort returns the same value as Direct status
Sort (me; rank : Integer; ent : Transient; model : InterfaceModel)
returns Boolean is deferred;
---Purpose : Returns True for an Entity if it satisfies the Sort criterium
-- It receives :
-- - <rank>, the rank of the Entity in the Iteration,
-- - <ent> , the Entity itself, and
-- - <model>, the Starting Model
-- Hence, the Entity to check is "model->Value(num)" (but an
-- InterfaceModel allows other checks)
-- This method is specific to each class of SelectExtract
SortInGraph (me; rank : Integer; ent : Transient; G : Graph)
returns Boolean is virtual;
---Purpose : Works as Sort but works on the Graph
-- Default directly calls Sort, but it can be redefined
-- If SortInGraph is redefined, Sort should be defined even if
-- not called (to avoid deferred methods in a final class)
Label (me) returns AsciiString from TCollection;
---Purpose : Returns a text saying "Picked" or "Removed", plus the
-- specific criterium returned by ExtractLabel (see below)
ExtractLabel (me) returns AsciiString from TCollection is deferred;
---Purpose : Returns a text defining the criterium for extraction
fields
thesort : Boolean;
end SelectExtract;

View File

@@ -0,0 +1,43 @@
#include <IFSelect_SelectExtract.ixx>
IFSelect_SelectExtract::IFSelect_SelectExtract ()
{ thesort = Standard_True; }
Standard_Boolean IFSelect_SelectExtract::IsDirect () const
{ return thesort; }
void IFSelect_SelectExtract::SetDirect (const Standard_Boolean direct)
{ thesort = direct; }
Interface_EntityIterator IFSelect_SelectExtract::RootResult
(const Interface_Graph& G) const
{
Interface_EntityIterator iter;
Interface_EntityIterator inputer = InputResult(G); // tient compte de tout
Handle(Interface_InterfaceModel) model = G.Model();
Standard_Integer rank = 0;
for (inputer.Start(); inputer.More(); inputer.Next()) {
Handle(Standard_Transient) ent = inputer.Value();
rank ++;
if (SortInGraph(rank,ent,G) == thesort) iter.GetOneItem(ent);
}
return iter;
}
Standard_Boolean IFSelect_SelectExtract::SortInGraph
(const Standard_Integer rank, const Handle(Standard_Transient)& ent,
const Interface_Graph& G) const
{ return Sort (rank, ent, G.Model()); }
TCollection_AsciiString IFSelect_SelectExtract::Label () const
{
TCollection_AsciiString labl;
if ( thesort) labl.AssignCat("Picked: ");
if (!thesort) labl.AssignCat("Removed: ");
labl.AssignCat(ExtractLabel());
return labl;
}

View File

@@ -0,0 +1,49 @@
-- File: IFSelect_SelectFlag.cdl
-- Created: Tue Sep 5 16:56:11 1995
-- Author: Christian CAILLET
-- <cky@fidox>
---Copyright: Matra Datavision 1995
class SelectFlag from IFSelect inherits SelectExtract
---Purpose : A SelectFlag queries a flag noted in the bitmap of the Graph.
-- The Flag is designated by its Name. Flag Names are defined
-- by Work Session and, as necessary, other functional objects
--
-- WorkSession from IFSelect defines flag "Incorrect"
-- Objects which control application running define some others
uses AsciiString from TCollection, InterfaceModel, Graph, EntityIterator
is
Create (flagname : CString) returns mutable SelectFlag;
---Purpose : Creates a Select Flag, to query a flag designated by its name
FlagName (me) returns CString;
---Purpose : Returns the name of the flag
RootResult (me; G : Graph) returns EntityIterator is redefined;
---Purpose : Returns the list of selected entities. It is redefined to
-- work on the graph itself (not queried by sort)
--
-- An entity is selected if its flag is True on Direct mode,
-- False on Reversed mode
--
-- If flag does not exist for the given name, returns an empty
-- result, whatever the Direct/Reversed sense
Sort (me; rank : Integer; ent : Transient; model : InterfaceModel)
returns Boolean;
---Purpose : Returns always False because RootResult has done the work
ExtractLabel (me) returns AsciiString from TCollection;
---Purpose : Returns a text defining the criterium, includes the flag name
fields
thename : AsciiString from TCollection;
end SelectFlag;

View File

@@ -0,0 +1,40 @@
#include <IFSelect_SelectFlag.ixx>
IFSelect_SelectFlag::IFSelect_SelectFlag (const Standard_CString flagname)
: thename (flagname) { }
Standard_CString IFSelect_SelectFlag::FlagName () const
{ return thename.ToCString(); }
Interface_EntityIterator IFSelect_SelectFlag::RootResult
(const Interface_Graph& G) const
{
Standard_Boolean direct = IsDirect();
Interface_EntityIterator res;
const Interface_BitMap& bm = G.BitMap();
Standard_Integer flag = bm.FlagNumber (thename.ToCString());
if (flag == 0) return res;
Interface_EntityIterator inp = InputResult(G);
for (inp.Start(); inp.More(); inp.Next()) {
Standard_Integer num = G.EntityNumber(inp.Value());
if (num == 0) continue;
if (direct == bm.Value(num,flag)) res.AddItem (G.Entity(num));
}
return res;
}
Standard_Boolean IFSelect_SelectFlag::Sort
(const Standard_Integer ,
const Handle(Standard_Transient)&,
const Handle(Interface_InterfaceModel)& ) const
{ return Standard_False; }
TCollection_AsciiString IFSelect_SelectFlag::ExtractLabel () const
{
TCollection_AsciiString lab ("Entities Flagged by ");
lab.AssignCat (thename);
return lab;
}

View File

@@ -0,0 +1,42 @@
-- File: IFSelect_SelectInList.cdl
-- Created: Thu Jan 7 16:45:30 1993
-- Author: Christian CAILLET
-- <cky@sdsun1>
---Copyright: Matra Datavision 1993
deferred class SelectInList from IFSelect inherits SelectAnyList
---Purpose : A SelectInList kind Selection selects a List of an Entity,
-- which is composed of single Entities
-- To know the list on which to work, SelectInList has two
-- deferred methods : NbItems (inherited from SelectAnyList) and
-- ListedEntity (which gives an item as an Entity) which must be
-- defined to get a List in an Entity of the required Type (and
-- consider that list is empty if Entity has not required Type)
--
-- As for SelectAnyList, if a type of Entity defines several
-- lists, a given sub-class of SelectInList is attached on one
uses AsciiString from TCollection, Transient, EntityIterator, Graph, IntParam
raises OutOfRange
is
-- NbItems (me; ent : Transient) returns Integer is deferred;
-- KeepInputEntity (me; iter : in out EntityIterator) is deferred;
-- these method are inherited as deferred and remain to be defined
ListedEntity (me; num : Integer; ent : Transient)
returns Transient raises OutOfRange is deferred;
---Purpose : Returns an Entity, given its rank in the list
FillResult (me; n1,n2 : Integer; ent : Transient;
result : in out EntityIterator);
---Purpose : Puts into the result, the sub-entities of the list, from n1 to
-- n2 included. Remark that adequation with Entity's type and
-- length of list has already been made at this stage
-- Called by RootResult; calls ListedEntity (see below)
end SelectInList;

View File

@@ -0,0 +1,14 @@
#include <IFSelect_SelectInList.ixx>
// .... Specialisation de SelectAnyList dans laquelle on traite une liste
// dont chaque item est une Entite
void IFSelect_SelectInList::FillResult
(const Standard_Integer n1, const Standard_Integer n2,
const Handle(Standard_Transient)& ent,
Interface_EntityIterator& result) const
{
for (Standard_Integer i = n1; i <= n2; i ++)
result.GetOneItem (ListedEntity(i,ent));
}

View File

@@ -0,0 +1,24 @@
-- File: IFSelect_SelectIncorrectEntities.cdl
-- Created: Fri Sep 2 11:03:13 1994
-- Author: Christian CAILLET
-- <cky@anion>
---Copyright: Matra Datavision 1994
class SelectIncorrectEntities from IFSelect inherits SelectFlag
---Purpose : A SelectIncorrectEntities sorts the Entities which have been
-- noted as Incorrect in the Graph of the Session
-- (flag "Incorrect")
-- It can find a result only if ComputeCheck has formerly been
-- called on the WorkSession. Else, its result will be empty.
uses AsciiString from TCollection, InterfaceModel, Graph, EntityIterator
is
Create returns mutable SelectIncorrectEntities;
---Purpose : Creates a SelectIncorrectEntities
-- i.e. a SelectFlag("Incorrect")
end SelectIncorrectEntities;

View File

@@ -0,0 +1,12 @@
// Copyright: Matra-Datavision 1994
// File: IFSelect_SelectIncorrectEntities.cxx
// Created: Fri Sep 2 11:15:01 1994
// Author: Christian CAILLET
// <cky>
#include <IFSelect_SelectIncorrectEntities.ixx>
IFSelect_SelectIncorrectEntities::IFSelect_SelectIncorrectEntities ()
: IFSelect_SelectFlag ("Incorrect") { }

View File

@@ -0,0 +1,27 @@
-- File: SelectIntersection.cdl
-- Created: Mon Jan 11 12:40:26 1993
-- Author: Christian CAILLET
-- <cky@sdsun1>
---Copyright: Matra Datavision 1993
class SelectIntersection from IFSelect inherits SelectCombine
---Purpose : A SelectIntersection filters the Entities issued from several
-- other Selections as Intersection of results : "AND" operator
uses AsciiString from TCollection, EntityIterator, Graph
is
Create returns mutable SelectIntersection;
---Purpose : Creates an empty SelectIntersection
RootResult (me; G : Graph) returns EntityIterator;
---Purpose : Returns the list of selected Entities, which is the common part
-- of results from all input selections. Uniqueness is guaranteed.
Label (me) returns AsciiString from TCollection;
---Purpose : Returns a text defining the criterium : "Intersection (AND)"
end SelectIntersection;

View File

@@ -0,0 +1,25 @@
#include <IFSelect_SelectIntersection.ixx>
#include <IFGraph_Compare.hxx>
IFSelect_SelectIntersection::IFSelect_SelectIntersection () { }
Interface_EntityIterator IFSelect_SelectIntersection::RootResult
(const Interface_Graph& G) const
{
IFGraph_Compare GC(G);
Standard_Integer nb = NbInputs();
for (Standard_Integer i = 1; i <= nb; i ++) {
GC.GetFromIter(Input(i)->RootResult(G), (i==1));
if (i > 1 && i < nb) {
Interface_EntityIterator comm = GC.Common();
GC.ResetData();
GC.GetFromIter (comm,Standard_True);
}
}
return GC.Common();
}
TCollection_AsciiString IFSelect_SelectIntersection::Label () const
{ return TCollection_AsciiString("Intersection (AND)"); }

View File

@@ -0,0 +1,58 @@
-- File: SelectList.cdl
-- Created: Wed Nov 18 17:36:22 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
generic class SelectList from IFSelect (Entity as Transient)
inherits SelectInList
---Purpose : A SelectList kind Selection selects a part of an Entity, as
-- well as this Entity can be described as an ordered List.
-- That is to say, it must have two methods :
--
-- NbEntities (me) returns Integer;
-- Entity (me; num : Integer) returns Transient;
--
-- For each class of Entity for which we want to define a
-- SelectList, we will instanciate this class with the
-- desired class of Entity as definition parameter : the deferred
-- methods NbEntities and ListedEntity are now defined to call
-- the required methods from <Entity>
--
-- SelectList works as SelectInList, beeing a sub-class of it
uses AsciiString from TCollection, Transient, EntityIterator, IntParam
raises OutOfRange
is
Create returns mutable SelectList;
---Purpose : Creates a SelectList (with no limit);
KeepInputEntity (me; iter : in out EntityIterator);
---Purpose : Keeps Input Entity, as having required type <Entity>
NbItems (me; ent : Transient) returns Integer;
---Purpose : Returns count of Entities in the list in the Entity <ent>
-- by calling method NbEntity from parameter class Entity
ListedEntity (me; num : Integer; ent : Transient)
returns Transient raises OutOfRange;
---Purpose : Returns an Entity of the list in the Entity <ent>, by calling
-- method Entity from parameter class Entity
-- Error if <ent> has not required type, or if <num> is not in
-- the right range (1,NbEntities),
ListLabel (me) returns AsciiString from TCollection;
---Purpose : Returns the specific label for the list
-- then, following cases :
-- " From .. Until .." or "From .." or "Until .." or "Rank no .."
-- Warning : it is not possible to give a character constant to instantiate
-- a generic class, thus "List From Entity" is not adapted :
-- redefine Label if judged necessary
end SelectList;

View File

@@ -0,0 +1,31 @@
//#include <IFSelect_SelectList.ixx>
// .... Instanciation avec "Handle(Entity)" qui offre ces deux methodes :
// nb = ent->NbEntities() et ent_i = ent->InterfaceEntity(i)
IFSelect_SelectList::IFSelect_SelectList () { }
void IFSelect_SelectType::KeepInputEntity (Interface_EntityIterator& iter)
{ iter.SelectType(STANDARD_TYPE(Entity)); }
Standard_Integer IFSelect_SelectList::NbItems
(const Handle(Standard_Transient)& ent)
{
Handle(Entity) anent = Handle(Entity)::DownCast(ent);
if (anent.IsNull()) return 0;
return anent->NbEntities();
}
Handle(Standard_Transient) IFSelect_SelectList::ListedEntity
(const Standard_Integer num, const Handle(Standard_Transient)& ent)
{
Handle(Entity) anent = Handle(Entity)::DownCast(ent);
if (anent.IsNull()) Standard_OutOfRange::Raise
("IFSelect SelectType : ListedEntity");
return anent->InterfacebEntity(num);
}
TCollection_AsciiString IFSelect_SelectList::ListLabel () const
{ return TCollection_AsciiString(STANDARD_TYPE(Entity)->Name()); }

View File

@@ -0,0 +1,31 @@
-- File: SelectModelEntities.cdl
-- Created: Tue Nov 17 19:00:03 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
class SelectModelEntities from IFSelect inherits SelectBase
---Purpose : A SelectModelEntities gets all the Entities of an
-- InterfaceModel.
uses AsciiString from TCollection, EntityIterator, Graph
is
Create returns mutable SelectModelEntities;
---Purpose : Creates a SelectModelRoot
RootResult (me; G : Graph) returns EntityIterator;
---Purpose : Returns the list of selected entities : the Entities of the
-- Model (note that this result assures naturally uniqueness)
CompleteResult (me; G : Graph) returns EntityIterator is redefined;
---Purpose : The complete list of Entities (including shared ones) ...
-- is exactly identical to RootResults in this case
Label (me) returns AsciiString from TCollection;
---Purpose : Returns a text defining the criterium : "Model Entities"
end SelectModelEntities;

View File

@@ -0,0 +1,16 @@
#include <IFSelect_SelectModelEntities.ixx>
#include <Interface_InterfaceModel.hxx>
IFSelect_SelectModelEntities::IFSelect_SelectModelEntities () { }
Interface_EntityIterator IFSelect_SelectModelEntities::RootResult
(const Interface_Graph& G) const
{ return G.Model()->Entities(); }
Interface_EntityIterator IFSelect_SelectModelEntities::CompleteResult
(const Interface_Graph& G) const
{ return G.Model()->Entities(); }
TCollection_AsciiString IFSelect_SelectModelEntities::Label () const
{ return TCollection_AsciiString("All Entities from Model"); }

View File

@@ -0,0 +1,29 @@
-- File: SelectModelRoots.cdl
-- Created: Tue Nov 17 18:52:56 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
class SelectModelRoots from IFSelect inherits SelectBase
---Purpose : A SelectModelRoots gets all the Root Entities of an
-- InterfaceModel. Remember that a "Root Entity" is defined as
-- having no Sharing Entity (if there is a Loop between Entities,
-- none of them can be a "Root").
uses AsciiString from TCollection, EntityIterator, Graph
is
Create returns mutable SelectModelRoots;
---Purpose : Creates a SelectModelRoot
RootResult (me; G : Graph) returns EntityIterator;
---Purpose : Returns the list of selected entities : the Roots of the Model
-- (note that this result assures naturally uniqueness)
Label (me) returns AsciiString from TCollection;
---Purpose : Returns a text defining the criterium : "Model Roots"
end SelectModelRoots;

View File

@@ -0,0 +1,11 @@
#include <IFSelect_SelectModelRoots.ixx>
IFSelect_SelectModelRoots::IFSelect_SelectModelRoots () { }
Interface_EntityIterator IFSelect_SelectModelRoots::RootResult
(const Interface_Graph& G) const
{ return G.RootEntities(); }
TCollection_AsciiString IFSelect_SelectModelRoots::Label () const
{ return TCollection_AsciiString("Root (not shared) Entities from Model"); }

View File

@@ -0,0 +1,108 @@
-- File: IFSelect_SelectPointed.cdl
-- Created: Mon May 30 17:11:41 1994
-- Author: Christian CAILLET
-- <cky@bravox>
---Copyright: Matra Datavision 1994
class SelectPointed from IFSelect inherits SelectBase
---Purpose : This type of Selection is intended to describe a direct
-- selection without an explicit criterium, for instance the
-- result of picking viewed entities on a graphic screen
--
-- It can also be used to provide a list as internal alternate
-- input : this use implies to clear the list once queried
uses AsciiString from TCollection, SequenceOfTransient, HSequenceOfTransient,
EntityIterator, Graph, CopyControl,
Transformer
raises InterfaceError
is
Create returns mutable SelectPointed;
---Purpose : Creates a SelectPointed
Clear (me : mutable);
---Purpose : Clears the list of selected items
-- Also says the list is unset
-- All Add* methods and SetList say the list is set
IsSet (me) returns Boolean;
---Purpose : Tells if the list has been set. Even if empty
SetEntity (me : mutable; item : any Transient);
---Purpose : As SetList but with only one entity
-- If <ent> is Null, the list is said as being set but is empty
SetList (me : mutable; list : HSequenceOfTransient);
---Purpose : Sets a given list to define the list of selected items
-- <list> can be empty or null : in this case, the list is said
-- as being set, but it is empty
--
-- To use it as an alternate input, one shot :
-- - SetList or SetEntity to define the input list
-- - RootResult to get it
-- - then Clear to drop it
Add (me : mutable; item : any Transient) returns Boolean;
---Purpose : Adds an item. Returns True if Done, False if <item> is already
-- in the selected list
Remove (me : mutable; item : any Transient) returns Boolean;
---Purpose : Removes an item. Returns True if Done, False if <item> was not
-- in the selected list
Toggle (me : mutable; item : any Transient) returns Boolean;
---Purpose : Toggles status of an item : adds it if not pointed or removes
-- it if already pointed. Returns the new status (Pointed or not)
AddList (me : mutable; list : HSequenceOfTransient) returns Boolean;
---Purpose : Adds all the items defined in a list. Returns True if at least
-- one item has been added, False else
RemoveList (me : mutable; list : HSequenceOfTransient) returns Boolean;
---Purpose : Removes all the items defined in a list. Returns True if at
-- least one item has been removed, False else
ToggleList (me : mutable; list : HSequenceOfTransient) returns Boolean;
---Purpose : Toggles status of all the items defined in a list : adds it if
-- not pointed or removes it if already pointed.
Rank (me; item : any Transient) returns Integer;
---Purpose : Returns the rank of an item in the selected list, or 0.
NbItems (me) returns Integer;
---Purpose : Returns the count of selected items
Item (me; num : Integer) returns any Transient;
---Purpose : Returns an item given its rank, or a Null Handle
Update (me : mutable; control : CopyControl);
---Purpose : Rebuilds the selected list. Any selected entity which has a
-- bound result is replaced by this result, else it is removed.
Update (me : mutable; trf : Transformer);
---Purpose : Rebuilds the selected list, by querying a Transformer
-- (same principle as from a CopyControl)
-- Services to provide --
RootResult (me; G : Graph) returns EntityIterator
raises InterfaceError;
---Purpose : Returns the list of selected items. Only the selected entities
-- which are present in the graph are given (this result assures
-- uniqueness).
Label (me) returns AsciiString from TCollection;
---Purpose : Returns a text which identifies the type of selection made.
-- It is "Pointed Entities"
fields
theset : Boolean;
theitems : SequenceOfTransient;
end SelectPointed;

View File

@@ -0,0 +1,167 @@
#include <IFSelect_SelectPointed.ixx>
#include <TColStd_MapOfTransient.hxx>
IFSelect_SelectPointed::IFSelect_SelectPointed ()
: theset (Standard_False) { }
void IFSelect_SelectPointed::Clear()
{ theitems.Clear(); theset = Standard_False; }
Standard_Boolean IFSelect_SelectPointed::IsSet () const
{ return theset; }
void IFSelect_SelectPointed::SetEntity
(const Handle(Standard_Transient)& ent)
{
theitems.Clear();
theset = Standard_True;
if (ent.IsNull()) return;
theitems.Append (ent);
}
void IFSelect_SelectPointed::SetList
(const Handle(TColStd_HSequenceOfTransient)& list)
{
theitems.Clear();
theset = Standard_True;
if (list.IsNull()) return;
Standard_Integer i,nb = list->Length();
for (i = 1; i <= nb; i ++) theitems.Append (list->Value(i));
}
// .... Editions
Standard_Boolean IFSelect_SelectPointed::Add
(const Handle(Standard_Transient)& item)
{
if (item.IsNull()) return Standard_False;
for (Standard_Integer i = theitems.Length(); i >= 1; i --)
if (item == theitems.Value(i)) return Standard_False;
theitems.Append(item);
theset = Standard_True;
return Standard_True;
}
Standard_Boolean IFSelect_SelectPointed::Remove
(const Handle(Standard_Transient)& item)
{
if (item.IsNull()) return Standard_False;
for (Standard_Integer i = theitems.Length(); i >= 1; i --)
if (item == theitems.Value(i)) { theitems.Remove(i); return Standard_True;}
return Standard_True;
}
Standard_Boolean IFSelect_SelectPointed::Toggle
(const Handle(Standard_Transient)& item)
{
if (item.IsNull()) return Standard_False;
Standard_Integer num = 0;
for (Standard_Integer i = theitems.Length(); i >= 1; i --)
if (item == theitems.Value(i)) num = i;
if (num == 0) theitems.Append(item);
else theitems.Remove(num);
return (num == 0);
}
Standard_Boolean IFSelect_SelectPointed::AddList
(const Handle(TColStd_HSequenceOfTransient)& list)
{
// Optimise avec une Map
Standard_Boolean res = Standard_False;
if (list.IsNull()) return res;
Standard_Integer i, nb = theitems.Length(), nl = list->Length();
TColStd_MapOfTransient deja (nb+nl+1);
for (i = 1; i <= nb; i ++) deja.Add (theitems.Value(i));
for (i = 1; i <= nl; i ++) {
if (!deja.Contains (list->Value(i)) ) theitems.Append (list->Value(i));
}
theset = Standard_True;
return res;
}
Standard_Boolean IFSelect_SelectPointed::RemoveList
(const Handle(TColStd_HSequenceOfTransient)& list)
{
Standard_Boolean res = Standard_False;
if (list.IsNull()) return res;
Standard_Integer i, nb = list->Length();
for (i = 1; i <= nb; i ++) res |= Remove (list->Value(i));
return res;
}
Standard_Boolean IFSelect_SelectPointed::ToggleList
(const Handle(TColStd_HSequenceOfTransient)& list)
{
Standard_Boolean res = Standard_True;
if (list.IsNull()) return res;
Standard_Integer i, nb = list->Length();
for (i = 1; i <= nb; i ++) res |= Toggle (list->Value(i));
return res;
}
// .... Consultations
Standard_Integer IFSelect_SelectPointed::Rank
(const Handle(Standard_Transient)& item) const
{
if (item.IsNull()) return 0;
for (Standard_Integer i = theitems.Length(); i >= 1; i --)
if (item == theitems.Value(i)) return i;
return 0;
}
Standard_Integer IFSelect_SelectPointed::NbItems () const
{ return theitems.Length(); }
Handle(Standard_Transient) IFSelect_SelectPointed::Item
(const Standard_Integer num) const
{
Handle(Standard_Transient) item;
if (num <= 0 || num > theitems.Length()) return item;
return theitems.Value(num);
}
void IFSelect_SelectPointed::Update
(const Handle(Interface_CopyControl)& control)
{
Standard_Integer nb = theitems.Length();
for (Standard_Integer i = nb; i > 0; i --) {
Handle(Standard_Transient) enfr, ento;
enfr = theitems.Value(i);
if (!control->Search(enfr,ento)) theitems.Remove(i);
else theitems.SetValue(i,ento);
}
}
void IFSelect_SelectPointed::Update
(const Handle(IFSelect_Transformer)& trf)
{
Standard_Integer nb = theitems.Length();
for (Standard_Integer i = nb; i > 0; i --) {
Handle(Standard_Transient) enfr, ento;
enfr = theitems.Value(i);
if (!trf->Updated(enfr,ento)) theitems.Remove(i);
else theitems.SetValue(i,ento);
}
}
// .... Actions Generales
Interface_EntityIterator IFSelect_SelectPointed::RootResult
(const Interface_Graph& G) const
{
Interface_EntityIterator result;
Standard_Integer nb = theitems.Length();
for (Standard_Integer i = 1; i <= nb; i ++) {
Handle(Standard_Transient) item = theitems.Value(i);
if (G.EntityNumber(item) > 0) result.GetOneItem(item);
}
return result;
}
TCollection_AsciiString IFSelect_SelectPointed::Label () const
{ return TCollection_AsciiString ("Pointed Entities"); }

View File

@@ -0,0 +1,70 @@
-- File: SelectRange.cdl
-- Created: Wed Nov 18 10:20:51 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
class SelectRange from IFSelect inherits SelectExtract
---Purpose : A SelectRange keeps or rejects a sub-set of the input set,
-- that is the Entities of which rank in the iteration list
-- is in a given range (for instance form 2nd to 6th, etc...)
uses AsciiString from TCollection, InterfaceModel, IntParam
raises DomainError
is
Create returns mutable SelectRange;
---Purpose : Creates a SelectRange. Default is Take all the input list
SetRange (me : mutable; rankfrom, rankto : mutable IntParam)
raises DomainError;
---Purpose : Sets a Range for numbers, with a lower and a upper limits
-- Error if rankto is lower then rankfrom
SetOne (me : mutable; rank : mutable IntParam);
---Purpose : Sets a unique number (only one Entity will be sorted as True)
SetFrom (me : mutable; rankfrom : mutable IntParam);
---Purpose : Sets a Lower limit but no upper limit
SetUntil (me : mutable; rankto : mutable IntParam);
---Purpose : Sets an Upper limit but no lower limit (equivalent to lower 1)
HasLower (me) returns Boolean;
---Purpose : Returns True if a Lower limit is defined
Lower (me) returns mutable IntParam;
---Purpose : Returns Lower limit (if there is; else, value is senseless)
LowerValue (me) returns Integer;
---Purpose : Returns Value of Lower Limit (0 if none is defined)
HasUpper (me) returns Boolean;
---Purpose : Returns True if a Lower limit is defined
Upper (me) returns mutable IntParam;
---Purpose : Returns Upper limit (if there is; else, value is senseless)
UpperValue (me) returns Integer;
---Purpose : Returns Value of Upper Limit (0 if none is defined)
Sort (me; rank : Integer; ent : Transient; model : InterfaceModel)
returns Boolean;
---Purpose : Returns True for an Entity of which occurence number in the
-- iteration is inside the selected Range (considers <rank>)
ExtractLabel (me) returns AsciiString from TCollection;
---Purpose : Returns a text defining the criterium : following cases,
-- " From .. Until .." or "From .." or "Until .." or "Rank no .."
fields
thelower : IntParam;
theupper : IntParam;
end SelectRange;

Some files were not shown because too many files have changed in this diff Show More