From: prascle Date: Sun, 1 Feb 2004 20:10:02 +0000 (+0000) Subject: PR: merge from trunk, tag mergefrom_trunk_01Feb04 X-Git-Tag: BR_multhr_20040212~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a05a1fdd22a5a8cb0d3d35734e2b5c8816d6f59f;p=modules%2Fkernel.git PR: merge from trunk, tag mergefrom_trunk_01Feb04 --- diff --git a/INSTALL b/INSTALL index 7879c9772..6334efe6a 100644 --- a/INSTALL +++ b/INSTALL @@ -1,4 +1,5 @@ -This is the version 1.3.0 of KERNEL +This is the version 1.4.0 of KERNEL Previous versions : + - 1.3.0 - 1.2.1 diff --git a/bin/VERSION b/bin/VERSION index 42b1f7f00..037ad6d66 100755 --- a/bin/VERSION +++ b/bin/VERSION @@ -1 +1 @@ -THIS IS SALOME - KERNEL VERSION: 1.3.0 +THIS IS SALOME - KERNEL VERSION: 1.4.0 diff --git a/bin/runSalome.py b/bin/runSalome.py index d4a702a52..b9ccbd48a 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -256,7 +256,9 @@ for module in liste_modules: module_root_dir=modules_root_dir[module] add_ld_library_path(os.path.join(module_root_dir,"lib","salome")) +os.environ["SALOME_trace"]="local" if with_logger: + os.environ["SALOME_trace"]="with_logger" locdir=os.environ['PWD'] libtracedir=os.path.join(locdir,"libSalomeTrace") libtrace = os.path.join(kernel_root_dir,"lib","salome","libSALOMELoggerClient.so.0.0.0") diff --git a/doc/html/INPUT/doxyfile b/doc/html/INPUT/doxyfile index 537e1c9df..61c8e7ea3 100755 --- a/doc/html/INPUT/doxyfile +++ b/doc/html/INPUT/doxyfile @@ -3,7 +3,7 @@ #--------------------------------------------------------------------------- # General configuration options #--------------------------------------------------------------------------- -PROJECT_NAME = "SALOME v.1.3.0" +PROJECT_NAME = "SALOME v.1.4.0" PROJECT_NUMBER = id#1.1 OUTPUT_DIRECTORY = ../ OUTPUT_LANGUAGE = English diff --git a/doc/html/INPUT/sources/static/tree.js b/doc/html/INPUT/sources/static/tree.js index b4a9a0d17..5e07feb1f 100755 --- a/doc/html/INPUT/sources/static/tree.js +++ b/doc/html/INPUT/sources/static/tree.js @@ -1,4 +1,4 @@ -foldersTree = gFld("SALOME v.1.3.0 ", "", "") +foldersTree = gFld("SALOME v.1.4.0 ", "", "") insDoc(foldersTree, gLnk("Main Page", "", "main.html")) aux1 = insFld(foldersTree, gFld("TUI Reference Guide", "")) diff --git a/idl/Makefile.in b/idl/Makefile.in index cda494641..8033ab2b0 100644 --- a/idl/Makefile.in +++ b/idl/Makefile.in @@ -24,7 +24,8 @@ IDL_FILES = \ TypeData.idl \ MPIObject.idl \ MPIContainer.idl \ - Logger.idl + Logger.idl \ + SALOME_GenericObj.idl PY_CLIENT_IDL = $(IDL_FILES) diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index ed5f15d54..686297a17 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -2,20 +2,20 @@ // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -23,8 +23,8 @@ // Author : Yves FRICAUD // $Header$ -/*! \mainpage - \image html Application-About.png +/*! \mainpage + \image html Application-About.png */ /*! @@ -62,20 +62,20 @@ module SALOMEDS typedef string SalomeReference; /*! List of the names of studies which are currently open in this %SALOME session. -Since %SALOME is a multi-study application, it allows to open a lot of studies +Since %SALOME is a multi-study application, it allows to open a lot of studies during each working session. */ typedef sequence ListOfOpenStudies; /*! List of file names */ typedef sequence ListOfFileNames; -/*! List of modification dates of the study +/*! List of modification dates of a study */ typedef sequence ListOfDates ; /*! An unbounded sequence of strings */ typedef sequence ListOfStrings ; -/*! A byte stream which is used for binary data transfer between components +/*! A byte stream which is used for binary data transfer between different components */ typedef sequence TMPFile; @@ -100,11 +100,11 @@ during each working session. interface UseCaseBuilder; interface Callback; -/*! List of attributes +/*! List of attributes of %SObjects */ typedef sequence ListOfAttributes; -/*! Exception indicating that this feature hasn't been implemented. +/*! Exception indicating that this feature hasn't been implemented in %SALOME PRO application. */ exception NotImplemented {}; @@ -127,6 +127,7 @@ during each working session. interface Study { + exception StudyInvalidContext {}; exception StudyInvalidComponent {}; /*! Invalid directory of the %study exception @@ -180,25 +181,40 @@ during each working session. SComponent FindComponentID(in ID aComponentID); /*! Allows to find a %SObject by the Name Attribute of this %SObject + + \param anObjectName String parameter defining the name of the object + \return The obtained %SObject +
See also an example of this method usage in batchmode of %SALOME application. */ SObject FindObject (in string anObjectName); /*! Allows to find a %SObject by its ID + \param aObjectID This parameter defines the ID of the required object + \return The obtained %SObject + */ SObject FindObjectID (in ID aObjectID); /*! Allows to find a %SObject by IOR of the object belonging to this %SObject. + \param anObjectName This parameter defines the IOR of the object + \return The obtained %SObject + */ SObject FindObjectIOR (in ID aObjectIOR); /*! - Returns a list of %SObjects belonging to this %Component. The Name Attribute - of these %SObjects should correspond to anObjectName. + Finds in the study all %SObjects produced by a given %Component. + \param anObjectName The Name Attribute of the searched %SObjects should correspond to anObjectName. + \param aComponentName The name of the component, which objects are searched for. */ ListOfSObject FindObjectByName(in string anObjectName, in string aComponentName); /*! Allows to find a %SObject by the path to it. + + \param thePath The path to the required %SObject. + \return The obtained %SObject. + */ SObject FindObjectByPath(in string thePath); /*! @@ -208,12 +224,15 @@ during each working session. /*! Sets the context of the %Study. + \param thePath String parameter defining the context of the study. +
See also an example of this method usage in batchmode of %SALOME application. */ void SetContext(in string thePath); /*! - Gets the context of the %Study + Gets the context of the %Study. +
See also an example of this method usage in batchmode of %SALOME application. */ @@ -238,19 +257,24 @@ during each working session. \note If the parameter theContext is empty, then the current context will be used. */ ListOfStrings GetComponentNames(in string theContext); -/*! \brief Creation of a new iterator of child levels - - Creates a new iterator of child levels of the %SObject +/*! + Creates a new iterator of child levels of the given %SObject. + \param aSO The given %SObject + \return A new iterator of child levels of the given %SObject. */ ChildIterator NewChildIterator(in SObject aSO); -/*! \brief Creation of a new iterator of the %SComponent +/*! - Creates a new iterator of the %SComponent. + Creates a new iterator of the %SComponents. + + \return A new iterator of the %SComponents. */ SComponentIterator NewComponentIterator(); -/*! \brief Creation of a %StudyBuilder - +/*! Creates a new %StudyBuilder to add or modify an object in the study. + + \return A new %StudyBuilder. +
See also an example of this method usage in batchmode of %SALOME application. */ @@ -264,6 +288,7 @@ during each working session. /*! \brief Getting properties of the study Returns the attriubte, which contains the properties of this study. +
See also an example of this method usage in batchmode of %SALOME application. */ @@ -324,6 +349,17 @@ during each working session. Enables(if isEnabled = True)/disables automatic addition of new %SObjects to the use case. */ void EnableUseCaseAutoFilling(in boolean isEnabled); + +/*! + Functions for internal usage only +*/ + void AddPostponed(in string theIOR); + + void AddCreatedPostponed(in string theIOR); + + void RemovePostponed(in long theUndoLimit); + + void UndoPostponed(in long theWay); }; //========================================================================== @@ -354,49 +390,66 @@ during each working session.
See also an example of this method usage in batchmode of %SALOME application. */ - SComponent NewComponent(in string ComponentDataType); + SComponent NewComponent(in string ComponentDataType) raises(LockProtection); /*! \brief Definition of the instance to the %SComponent Defines the instance to the %SComponent. */ - void DefineComponentInstance (in SComponent aComponent,in Object ComponentIOR); -/*! \brief Deletion of the %SComponent + void DefineComponentInstance (in SComponent aComponent,in Object ComponentIOR) raises(LockProtection); +/*! \brief Deletion of a %SComponent - Removes the %SComponent. + Removes a %SComponent. */ - void RemoveComponent(in SComponent aComponent); + void RemoveComponent(in SComponent aComponent) raises(LockProtection); /*! \brief Creation of a new %SObject - Creates a new %SObject. + Creates a new %SObject under a definite father %SObject. + + \param theFatherObject The father %SObject under which this one should be created. + \return New %SObject +
See also an example of this method usage in batchmode of %SALOME application. */ - SObject NewObject (in SObject theFatherObject); + + SObject NewObject (in SObject theFatherObject) raises(LockProtection); + /*! \brief Creation of a new %SObject with a definite %tag Creates a new %SObject with a definite %tag. + + \param atag Long value corresponding to the tag of the new %SObject. + \return New %SObject + */ - SObject NewObjectToTag (in SObject theFatherObject, in long atag); + SObject NewObjectToTag (in SObject theFatherObject, in long atag) raises(LockProtection); /*! \brief Deletion of the %SObject Removes a %SObject from the %StudyBuilder. + + \param anObject The %SObject to be deleted. */ - void RemoveObject (in SObject anObject); + void RemoveObject (in SObject anObject) raises(LockProtection); /*! \brief Deletion of the %SObject with all his child objects. Removes the %SObject with all his child objects. + + \param anObject The %SObject to be deleted with all child objects. */ - void RemoveObjectWithChildren(in SObject anObject); + void RemoveObjectWithChildren(in SObject anObject) raises(LockProtection); /*! Loads a %SComponent. +
See also an example of this method usage in batchmode of %SALOME application. */ void LoadWith (in SComponent sco, in Driver Engine) raises (SALOME::SALOME_Exception); /*! Loads a %SObject. + + \param sco %SObject to be loaded. */ void Load (in SObject sco); @@ -410,9 +463,9 @@ during each working session. */ GenericAttribute FindOrCreateAttribute(in SObject anObject, - in string aTypeOfAttribute); + in string aTypeOfAttribute) raises(LockProtection); -/*! \brief Looking for an attribute assigned to %SObject +/*! \brief Looking for an attribute assigned to a %SObject Allows to find an attribute of a specific type which is assigned to the object. \param anObject The %SObject corresponding to the attribute which is looked for. @@ -433,37 +486,46 @@ during each working session.
See also an example of this method usage in batchmode of %SALOME application. */ void RemoveAttribute(in SObject anObject, - in string aTypeOfAttribute); -/*! \brief Addition of a reference - + in string aTypeOfAttribute) raises(LockProtection); +/*! Adds a reference between %anObject and %theReferencedObject. + \param anObject The %SObject which will get a reference + \param theReferencedObject The %SObject having a reference */ void Addreference(in SObject anObject, in SObject theReferencedObject) ; /*! Adds a directory in the %Study. + \param theName String parameter defining the name of the directory. +
See also an example of this method usage in batchmode of %SALOME application. */ - void AddDirectory(in string theName); + void AddDirectory(in string theName) raises(LockProtection); /*! \brief Identification of the %SObject's substructure. Identification of the %SObject's substructure by GUID. - It has the following format "00000000-0000-0000-0000-000000000000" + + + \param anObject The %SObject which will be identified + \param theGUID GUID has the following format "00000000-0000-0000-0000-000000000000" */ - void SetGUID(in SObject anObject, in string theGUID); + void SetGUID(in SObject anObject, in string theGUID) raises(LockProtection); /*! +Searches for a definite %SObject with a definite GUID and returns True if it finds it. - Returns True if the %SObject has GUID. +\param anObject A definite %SObject which will be identified +\param theGUID GUID has the following format "00000000-0000-0000-0000-000000000000" */ boolean IsGUID(in SObject anObject, in string theGUID); /*! \brief Creation of a new command Creates a new command which can contain several different actions. +
See also an example of this method usage in batchmode of %SALOME application. */ @@ -471,6 +533,9 @@ during each working session. /*! \brief Execution of the command Commits all actions declared within this command. + + \exception LockProtection This exception is raised, when trying to perform this command a study, which is protected for modifications. +
See also an example of this method usage in batchmode of %SALOME application. */ @@ -482,6 +547,7 @@ during each working session. /*! \brief Cancelation of the command Cancels all actions declared within the command. +
See also an example of this method usage in batchmode of %SALOME application. */ void AbortCommand(); // command management @@ -493,6 +559,9 @@ during each working session. /*! \brief Undo method Cancels all actions of the last command. + + \exception LockProtection This exception is raised, when trying to perform this command a study, which is protected for modifications. +
See also an example of this method usage in batchmode of %SALOME application. */ @@ -500,28 +569,40 @@ during each working session. /*! \brief Redo method Redoes all actions of the last command. + +\exception LockProtection This exception is raised, when trying to perform this command a study, which is protected for modifications. +
See also an example of this method usage in batchmode of %SALOME application. */ void Redo() raises (LockProtection); /*! Returns True if at this moment there are any actions which can be canceled. +
See also an example of this method usage in batchmode of %SALOME application. */ boolean GetAvailableUndos(); /*! Returns True if at this moment there are any actions which can be redone. +
See also an example of this method usage in batchmode of %SALOME application. */ boolean GetAvailableRedos(); /*! - Sets the callback for addition of the given %SObject. Returns the previous callback. + This method is called when adding an object into study. + It sets the callback for addition of the given %SObject. + \param theCallback New assigned callback. + \return The previous callback. */ Callback SetOnAddSObject(in Callback theCallback); /*! - Sets the callback for removal of the given %SObject. Returns the previous callback. + This method is called when adding an object into study. + It sets the callback for removal of the given %SObject. + + \return The previous callback. + \param theCallback New assigned callback. */ Callback SetOnRemoveSObject(in Callback theCallback); @@ -545,9 +626,12 @@ during each working session. */ void ping(); -/*! \brief Creation of a new %Study +/*! \brief Creation of a new study + + Creates a new study with a definite name. + + \param study_name String parameter defining the name of the study - Creates a new %Study with a definite name.
See also an example of this method usage in batchmode of %SALOME application. */ @@ -556,33 +640,39 @@ during each working session. /*! \brief Open a study Reads and activates the structure of the study %Objects. + \param aStudyUrl The path to the study \warning This method doesn't activate the corba objects. Only a component can do it. +
See also an example of this method usage in batchmode of %SALOME application. */ Study Open (in URL aStudyUrl) raises (SALOME::SALOME_Exception); /*! \brief Closing the study - Closes the study. + Closes a study. */ void Close(in Study aStudy); /*! \brief Saving the study in a HDF file (or files). - Saves the study. + Saves a study. + \param theMultiFile If this parameter is True the study will be saved in several files. +
See also an example of this method usage in batchmode of %SALOME application. */ void Save(in Study aStudy, in boolean theMultiFile); -/*! \brief Saving the study in a ASCII file (or files). +/*! \brief Saving a study in a ASCII file (or files). - Saves the study in a ASCII format. + Saves a study in an ASCII format file (or files). \param theMultiFile If this parameter is True the study will be saved in several files. */ void SaveASCII(in Study aStudy, in boolean theMultiFile); /*! \brief Saving the study in a specified HDF file (or files). Saves the study in a specified file (or files). + \param aUrl The path to the definite file in whcih the study will be saved + \param aStudy The study which will be saved \param theMultiFile If this parameter is True the study will be saved in several files.
See also an example of this method usage in batchmode of %SALOME application. @@ -593,6 +683,9 @@ during each working session. /*! \brief Saving the study in a specified ASCII file (or files). Saves the study in a specified ASCII file (or files). + + \param aUrl The path to the definite file in whcih the study will be saved + \param aStudy The study which will be saved \param theMultiFile If this parameter is True the study will be saved in several files. */ void SaveAsASCII(in URL aUrl, // if the file already exists @@ -602,21 +695,25 @@ during each working session. /*! \brief List of open studies. - Returns the list of open studies in the current session. +Gets the list of open studies + + \return A list of open studies in the current session. */ ListOfOpenStudies GetOpenStudies(); /*! \brief Getting a particular %Study picked by name Activates a particular %Study - amongst the session collection picking it by name. + among the session collection picking it by name. + \param aStudyName The name of the study */ Study GetStudyByName (in string aStudyName); /*! \brief Getting a particular %Study picked by ID Activates a particular %Study - amongst the session collection picking it by ID. + among the session collection picking it by ID. + \param aStudyID The ID of the study */ Study GetStudyByID (in short aStudyID); @@ -628,14 +725,19 @@ during each working session. boolean CanCopy(in SObject theObject); /*! Returns True, if the given %SObject is copied to the clipboard. + \param theObject The %SObject which will be copied */ boolean Copy(in SObject theObject); /*! Returns True, if the object from the clipboard can be pasted to the given %SObject. + \param theObject The %SObject stored in the clipboard. */ boolean CanPaste(in SObject theObject); /*! Returns the %SObject in which the object from the clipboard was pasted to. + \param theObject The %SObject which will be pasted + \exception SALOMEDS::StudyBuilder::LockProtection This exception is raised, when trying to paste + an object into a study, which is protected for modifications. */ SObject Paste(in SObject theObject) raises (SALOMEDS::StudyBuilder::LockProtection); }; @@ -647,6 +749,7 @@ during each working session. The objects in the %study are built by the %StudyBuilder. The %SObject interface provides methods for elementary inquiries, like getting an object %ID or its attribuites. \note +
Tag of an item in %SALOME application is an integer value uniquely defining an item in the tree-type data structure.
ID of an item is a description of item's position in the tree-type data structure. @@ -659,54 +762,59 @@ during each working session. /*! Name of the %SObject */ attribute string Name; // equivalent to setName() & getName() -/*! \brief Getting an object %ID +/*! Gets an object %ID - Returns ID of the %SObject. + \return ID of the %SObject. */ ID GetID(); -/*! \brief Acquisition of the father %Component of the %SObject +/*! Acquisition of the father %Component of the %SObject - Returns the father %Component of the %SObject. + \return The father %Component of the %SObject. */ SComponent GetFatherComponent(); -/*! \brief Acquisition of the father %SObject of the %SObject +/*! Acquisition of the father %SObject of the %SObject - Returns the father %SObject of the given %SObject. + \return the father %SObject of the given %SObject. */ SObject GetFather(); -/*! \brief %Tag of %SObject +/*! Gets the %tag of a %SObject - Returns the %tag of the %SObject. + \return the %tag of a %SObject. */ short Tag(); -/*! \brief Looking for subobjects of an object. +/*! Looks for subobjects of a given %SObject. - Returns True if it finds a subobject of the %SObject with a definite tag. + \param atag Tag of the given %SObject + \return True if it finds a subobject of the %SObject with a definite tag as well as the required subobject. */ boolean FindSubObject (in long atag, out SObject obj); -/*! \brief Looking for attributes of the %SObject +/*! Looks for attributes of a given %SObject + + \param aTypeOfAttribute String value defining the type of the required attribute of the given %SObject. + \return True if it finds an attribute of a definite type of the given %SObject as well as the discovered attribute. - Returns True if it finds an attribute of a definite type of the %SObject.
See also an example of this method usage in batchmode of %SALOME application. */ boolean FindAttribute(out GenericAttribute anAttribute, in string aTypeOfAttribute); -/*! - Returns the object which this %SObject refers to. It also returns True if it finds +/*! Looks for a %SObject which the given %SObject refers to. + + \return The object which the given %SObject refers to as well as True if it finds this object. */ boolean ReferencedObject(out SObject obj); // A REVOIR -/*! \brief Getting all attributes of the %SObject +/*! Gets all attributes of a given %SObject + + \return The list of all attributes of the given %SObject. - Returns the list of all attributes of the %SObject.
See also an example of this method usage in batchmode of %SALOME application. */ ListOfAttributes GetAllAttributes(); -/*! \brief Returning the study +/*! Gets the study of a given %SObject. - Returns the study containing the given %SObject. + /return The study containing the given %SObject. */ Study GetStudy(); }; @@ -728,7 +836,8 @@ during each working session. /*! \brief Method CheckLocked Checks whether the %Study is protected for modifications. - \note
This exception is raised only outside the transaction. + + \note
This exception is raised only outside a transaction. */ void CheckLocked() raises (LockProtection); }; @@ -745,13 +854,14 @@ during each working session. //========================================================================== interface SComponent : SObject { -/*! \brief Data type of the %SComponent +/*! Gets the data type of the given %SComponent - Returns the data type of the %SComponent. + \return The data type of this %SComponent. */ string ComponentDataType(); -/*! - Returns IOR of the according component. +/*! Gets the IOR of the given component + + \return True (if there is an instance of the given component) and its IOR. */ boolean ComponentIOR (out ID theID); //returns True if there is an instance //In this case ID identifies this one @@ -767,23 +877,22 @@ during each working session. //========================================================================== interface SComponentIterator { -/*! \brief Initialization of the Iterator - +/*! Activates the %SComponentIterator. */ void Init(); -/*! \brief Method More +/*! Method More - Returns True if there is one more %SComponent in the list. + \return True if there is one more %SComponent in the list. */ boolean More(); -/*! \brief Moving the iterator to the next %SComponent - +/*! Moves the iterator to the next %SComponent in the list. */ void Next(); /*! Returns the %SComponent corresponding to the current %SComponent found by the iterator. +
See also an example of this method usage in batchmode of %SALOME application. */ @@ -799,19 +908,21 @@ Moves the iterator to the next %SComponent in the list. //========================================================================== interface ChildIterator { -/*! \brief Initialization of the Iterator. +/*! Activates the %ChildIterator. */ void Init(); -/*! \brief Initialization of the Iterator for all child levels. +/*! + +Activates the %ChildIterator for all child levels. -Activates the %ChildIterator (if True) for all child levels. +\param allLevels If this boolean parameter is True, the %ChildIterator will be activated for all child levels. */ void InitEx(in boolean allLevels); -/*! \brief Method More +/*! Method More - Returns True if the %ChildIterator finds one more child level. + \return True if there is one more %ChildIterator in the list. */ boolean More(); /*! @@ -832,14 +943,14 @@ Activates the %ChildIterator (if True) for all child levels. */ interface UseCaseIterator { -/*! \brief Initialization of the Iterator. - -Activates the %UseCaseIterator. If allLevels is True the Iterator is activated for all subobjects. +/*! +Activates the %UseCaseIterator. +\param allLevels If the value of this parameter is True the Iterator is activated for all subobjects. */ void Init(in boolean allLevels); -/*! \brief Method More +/*! Method More - Returns True if the %UseCaseIterator finds one more object. + \return True if the %UseCaseIterator finds one more object. */ boolean More(); /*! @@ -862,11 +973,17 @@ Activates the %UseCaseIterator. If allLevels is True the Iterator is interface UseCaseBuilder { /*! - Adds to the use case an object theObject as a child of the current object of the use case. + Adds to the use case an object as a child of the current object of the use case. + + \param theObject The added %SObject. + \return True if this %SObject has been added in the use case. */ boolean Append(in SObject theObject); /*! - Removes an object theObject from the use case. + Removes an object from the use case. + + \param theObject The deleted %SObject + \return True if this %SObject has been deleted from the use case. */ boolean Remove(in SObject theObject); /*! @@ -936,17 +1053,26 @@ Activates the %UseCaseIterator. If allLevels is True the Iterator is //========================================================================== /*! \brief %Driver interface - This interface contains a set of methods used for the management - of the object produced in the %study by a component. +This class represents a common tool for all components integrated into SALOME application, that allows them to communicate with the study. It contains a set of methods which +can be called by any component and which provide the following functionality: +
    +
  • publishing in the study of the objects created by a definite component +
  • saving/loading of the data created by a definite component. These methods are called by the StudyManager when loading/saving a study containing the data created by a definite component. +
  • transforming of the transient references into persistant references (or vice versa) of the SObjects when saving (or loading) a study +
  • copy/paste common functionality. These methods can be called by any component in order to copy/paste its object created in the study +
+ */ //========================================================================== interface Driver { - /*! \brief Saving the data. + /*! \brief Saving the data produced by a definite component. This method is called by the StudyManager when saving a study. \param theComponent %SComponent corresponding to this Component + \param theURL The path to the file in which the data will be saved. + \param isMultiFile If the value of this boolean parameter is True, the data will be saved in several files. \return A byte stream TMPFile that contains all saved data
See also an example of this method usage in batchmode of %SALOME application. @@ -956,6 +1082,17 @@ Activates the %UseCaseIterator. If allLevels is True the Iterator is TMPFile Save(in SComponent theComponent, in string theURL, in boolean isMultiFile); +/*! \brief Saving the data in ASCII format produced by a definite component. + + This method is called by the StudyManager when saving a study in ASCII format. + \param theComponent %SComponent corresponding to this Component + \param theURL The path to the file in which the data will be saved. + \param isMultiFile If the value of this boolean parameter is True, the data will be saved in several files. + \return A byte stream TMPFile that will contain all saved data + +
See also an example of this method usage in batchmode of %SALOME application. + + */ TMPFile SaveASCII(in SComponent theComponent, in string theURL, in boolean isMultiFile); /*! \brief Loading the data. @@ -963,32 +1100,53 @@ Activates the %UseCaseIterator. If allLevels is True the Iterator is This method is called by the StudyManager when opening a study. \param theComponent %SComponent corresponding to this Component \param theStream The file which contains all data saved by the component on Save method + \param isMultiFile If the value of this boolean parameter is True, the data will be loaded from several files + */ boolean Load(in SComponent theComponent, in TMPFile theStream, in string theURL, in boolean isMultiFile); + /*! \brief Loading the data from files in ASCII format. + + This method is called by the StudyManager when opening a study. + \param theComponent %SComponent corresponding to this Component + \param theStream The file which contains all data saved by the component on Save method + \param isMultiFile If the value of this boolean parameter is True, the data will be loaded from several files + + */ + boolean LoadASCII(in SComponent theComponent, in TMPFile theStream, in string theURL, in boolean isMultiFile); /*! \brief Closing of the study This method Close is called by the StudyManager when closing a study. - + \param aSComponent The according %SComponent */ void Close (in SComponent aSComponent); //void Close ( in string aIORSComponent); - /*! \brief The type of the data + /*! Gets the type of the data - Returns the type of data produced by the Component in the study. + \return The type of data produced by the Component in the study. */ string ComponentDataType(); // Driver Transient -> persistent called for each object in study /*! - Transforms IOR into PersistentID of the object. It is called for each + Transforms IOR of a given %SObject into PersistentID. It is called for each object in the %study. +\note
In %SALOME the objects which are present in an active study are identified by an IOR, when this +study is saved these references are transformed into persintent IDs. + + \param theSObject The given %SObject. + \param IORString The IOR of the given %SObject. + \param isMultiFile If this parameter is True the study containing the given %SObject is stored in several files. + \param isASCII If this parameter is True the study containing the given %SObject is stored in ASCII format. + + \return The persistent ID of the given %SObject + */ string IORToLocalPersistentID (in SObject theSObject, in string IORString, @@ -997,6 +1155,17 @@ Activates the %UseCaseIterator. If allLevels is True the Iterator is /*! Transforms PersistentID into IOR of the object. It is called for each object in the %study. + + \note
In %SALOME the objects which are present in an saved study (file) are identified by a persistent ID, when this +study is open, these references are transformed into persintent IORs. + + \param theSObject The given %SObject. + \param IORString The IOR of the given %SObject. + \param isMultiFile If this parameter is True the study containing the given %SObject is stored in several files. + \param isASCII If this parameter is True the study containing the given %SObject is stored in ASCII format. + + \return The IOR of the given %SObject + */ string LocalPersistentIDToIOR (in SObject theSObject, in string aLocalPersistentID, @@ -1005,9 +1174,10 @@ Activates the %UseCaseIterator. If allLevels is True the Iterator is raises (SALOME::SALOME_Exception); // Publishing in the study -/*! \brief Publishing in the study +/*! Publishing in the study - Returns True if the given %Component can publish the %object in the %study. + \return True if the given %Component can publish a definite object with a given IOR in the %study. + \param theIOR The IOR of a definite object */ boolean CanPublishInStudy(in Object theIOR) raises (SALOME::SALOME_Exception); /*! \brief Publishing in the study @@ -1019,6 +1189,8 @@ Activates the %UseCaseIterator. If allLevels is True the Iterator is \param theObject The object which is published \param theName The name of the published object. If this parameter is empty, the name is generated automatically by the component. + + \return The published %SObject. */ SObject PublishInStudy(in Study theStudy, in SObject theSObject, in Object theObject, in string theName); @@ -1026,6 +1198,8 @@ Activates the %UseCaseIterator. If allLevels is True the Iterator is /*! Returns True, if the given %SObject can be copied to the clipboard. + + \param theObject The given %SObject which should be copied. */ boolean CanCopy(in SObject theObject); /*! diff --git a/idl/SALOMEDS_Attributes.idl b/idl/SALOMEDS_Attributes.idl index fca28960a..27f1f6dbd 100644 --- a/idl/SALOMEDS_Attributes.idl +++ b/idl/SALOMEDS_Attributes.idl @@ -42,18 +42,19 @@ module SALOMEDS /*! Sequence of string values */ typedef sequence StringSeq; -/*! \struct Color - This structure stores a set of elements defining the color based on RGB. +/*! \struct Color + This structure stores a set of elements defining the color based on RGB palette. These elements are + used as input parameters for methods necessary for color definition of different items. */ struct Color { /*! Red color -*/ +*/ double R; /*! Green color -*/ +*/ double G; /*! Blue color -*/ +*/ double B; }; //========================================================================== @@ -66,11 +67,13 @@ module SALOMEDS { /*! Returns the value of this attribute. +
See also an example of this method usage in batchmode of %SALOME application. */ double Value(); /*! Sets the value of this attribute. +
See also an example of this method usage in batchmode of %SALOME application. */ void SetValue(in double value); @@ -85,11 +88,13 @@ module SALOMEDS { /*! Returns the value of this attribute +
See also an example of this method usage in batchmode of %SALOME application. */ long Value(); /*! Sets the value of this attribute +
See also an example of this method usage in batchmode of %SALOME application. */ void SetValue(in long value); @@ -113,6 +118,7 @@ module SALOMEDS DoubleSeq CorbaSequence(); /*! Adds to the end of the sequence a real number. + \param value A real number added to the sequence.
See also an example of this method usage in batchmode of %SALOME application. @@ -121,22 +127,30 @@ module SALOMEDS /*! Removes a real number with a definite index from the sequence of real numbers stored in the Attribute. + + \param index The index of the given real number */ void Remove(in long index); /*! - Substitutes a real number with a definite index for another real number. + Substitutes a given real number with a definite index for another real number. + \param index The index of the given real number. + \param value The value of another real number. +
See also an example of this method usage in batchmode of %SALOME application. */ void ChangeValue(in long index, in double value); /*! - Returns a real number with a definite index + Returns a given real number with a definite index in the sequence of real numbers stored in the Attribute. + \param index The index of the given real number. +
See also an example of this method usage in batchmode of %SALOME application. */ double Value(in short index); /*! Returns the length of the sequence of real numbers stored in the Attribute. +
See also an example of this method usage in batchmode of %SALOME application. */ @@ -151,7 +165,7 @@ module SALOMEDS interface AttributeSequenceOfInteger : GenericAttribute { /*! - Initialization of the attribute with initial data. + Initialisation of the attribute with initial data. \param other Initially assigned sequence of integer numbers. */ void Assign (in LongSeq other); @@ -170,22 +184,30 @@ module SALOMEDS /*! Removes an integer number with a definite index from the sequence of integer numbers stored in the Attribute. + \param index The index of the given integer number. +
See also an example of this method usage in batchmode of %SALOME application. */ void Remove(in long index); /*! Substitutes an integer number with a definite index for another integer number. + \param index The index of the given integer number. + \param value The value of another integer number. + */ void ChangeValue(in long index, in long value); /*! - Returns an integer number with a definite index + Returns a given integer number with a definite index in the sequence of integer numbers stored in the Attribute. + \param index The index of the given integer number. +
See also an example of this method usage in batchmode of %SALOME application. */ long Value(in short index); /*! Returns the length of the sequence of integer numbers stored in the Attribute. +
See also an example of this method usage in batchmode of %SALOME application. */ @@ -204,11 +226,15 @@ module SALOMEDS { /*! Returns the value of this attribute +
See also an example of this method usage in batchmode of %SALOME application. */ string Value(); /*! Sets the value of this attribute + + \param value This parameter defines the value of this attribute. +
See also an example of this method usage in batchmode of %SALOME application. */ void SetValue(in string value); @@ -225,11 +251,14 @@ module SALOMEDS { /*! Returns the value of this attribute +
See also an example of this method usage in batchmode of %SALOME application. */ string Value(); /*! Sets the value of this attribute + \param value This string parameter defines the value of this attribute - a description of a %SObject. +
See also an example of this method usage in batchmode of %SALOME application. */ void SetValue(in string value); @@ -245,11 +274,14 @@ module SALOMEDS { /*! Returns the value of this attribute +
See also an example of this method usage in batchmode of %SALOME application. */ string Value(); /*! Sets the value of this attribute + \param value This parameter defines the value of this attribute - IOR of a %SObject. +
See also an example of this method usage in batchmode of %SALOME application. */ void SetValue(in string value); @@ -265,11 +297,14 @@ module SALOMEDS { /*! Returns the value of this attribute +
See also an example of this method usage in batchmode of %SALOME application. */ string Value(); /*! Sets the value of this attribute + \param value This parameter defines the value of this attribute. +
See also an example of this method usage in batchmode of %SALOME application. */ void SetValue(in string value); @@ -323,20 +358,24 @@ module SALOMEDS //========================================================================== /*! \brief Drawable flag Attribute. - This is a presentation attribute necessary for display of the study tree in the browser. - The item associated to SObject is created/displayed if TRUE. + This is a presentation attribute necessary for display of a study tree in the browser. + The item associated to a %SObject is created/displayed if TRUE. */ //========================================================================== interface AttributeDrawable : GenericAttribute { /*! Returns TRUE if the item is drawable (as it is by default) and FALSE if it isn't. +
See also an example of this method usage in batchmode of %SALOME application. */ boolean IsDrawable(); /*! -Sets the items to be drawable if value is TRUE (the default) or not to be selectable if valueis FALSE. +Sets the item to be drawable. + +\param value If the value of this boolean parameter is TRUE (default) the item will be drawable. +
See also an example of this method usage in batchmode of %SALOME application. */ @@ -354,12 +393,17 @@ Sets the items to be drawable if value is TRUE (the default) or not t { /*! Returns TRUE if the item is selectable (as it is by default) and FALSE if it isn't. + +
See also an example of this method usage in batchmode of %SALOME application. */ boolean IsSelectable(); /*! -Sets the items to be selectable if value is TRUE (the default) or not to be selectable if valueis FALSE. +Sets the item to be selectable + +\param value If the value of this parameter is TRUE (the default) the item will be set as selectable. +
See also an example of this method usage in batchmode of %SALOME application. */ @@ -378,13 +422,15 @@ Sets the items to be selectable if value is TRUE (the default) or not { /*! Returns TRUE if this item is expandable even when it has no children. +
See also an example of this method usage in batchmode of %SALOME application. */ boolean IsExpandable(); -/*! - Sets this item to be expandable even if it has no children if value is TRUE, and to be - expandable only if it has children if value is FALSE (the default). +/*! Sets this item to be expandable even if it has no children. + + \param value If the value of this boolean parameter is TRUE, this item will be set as expandable. +
See also an example of this method usage in batchmode of %SALOME application. */ @@ -403,13 +449,17 @@ Sets the items to be selectable if value is TRUE (the default) or not { /*! Returns TRUE if this item is open (its children are visible) and FALSE if it isn't. +
See also an example of this method usage in batchmode of %SALOME application. */ boolean IsOpened(); /*! - Sets this item to be open (its children are visible) if value is TRUE, and to be closed -(its children are not visible) if value is FALSE. + Sets this item to be open (its children are visible) + + \param value If the value of this boolean parameter is TRUE this item will be set as open, + and as closed if FALSE. +
See also an example of this method usage in batchmode of %SALOME application. */ @@ -425,12 +475,16 @@ Sets the items to be selectable if value is TRUE (the default) or not { /*! Returns the color of an item. +
See also an example of this method usage in batchmode of %SALOME application. */ Color TextColor(); /*! Sets the color of an item. + + \param value This parameter defines the color of the item. +
See also an example of this method usage in batchmode of %SALOME application. */ @@ -447,12 +501,17 @@ Sets the items to be selectable if value is TRUE (the default) or not { /*! Returns the highlight color of an item. + + +
See also an example of this method usage in batchmode of %SALOME application. */ Color TextHighlightColor(); /*! Sets the highlight color of an item. + \param value This parameter defines the highlight color of the item. +
See also an example of this method usage in batchmode of %SALOME application. */ @@ -467,17 +526,20 @@ Sets the items to be selectable if value is TRUE (the default) or not interface AttributePixMap : GenericAttribute { /*! - Returns True if there is an icon before the name of the item. + Returns True if there is an icon before the name of the given item. */ boolean HasPixMap(); /*! - Returns the name of the icon. + Returns the name of the icon in the format of a string. +
See also an example of this method usage in batchmode of %SALOME application. */ string GetPixMap(); /*! Sets the name of the icon. + \param value This string parameter defines the name of the icon. +
See also an example of this method usage in batchmode of %SALOME application. */ @@ -490,6 +552,7 @@ Sets the items to be selectable if value is TRUE (the default) or not A set of these attributes on the %SObjects of the %study forms an inner auxiliary tree whith its own structure and identifier. The quantity of such trees with different identifiers can be arbitrary. +
See also an example of usage of the methods of this interface in batchmode of %SALOME application. */ @@ -497,108 +560,112 @@ Sets the items to be selectable if value is TRUE (the default) or not interface AttributeTreeNode : GenericAttribute { /*! - Sets the father TreeNode to this TreeNode. + Assigns the father tree node to this tree node. */ void SetFather(in AttributeTreeNode value); /*! - Returns True if there is the father TreeNode of this TreeNode. + Returns True if there is a father tree node of this tree node. */ boolean HasFather(); /*! - Returns the father Treenode of this TreeNode. + Returns the father tree node of this tree node. */ AttributeTreeNode GetFather(); /*! - Sets the previous brother TreeNode to this treeNode. + Assigns the previous brother tree node to the given tree node. */ void SetPrevious(in AttributeTreeNode value); /*! - Returns True if there is the previous brother TreeNode of this TreeNode. + Returns True if there is the previous brother tree node of this tree node. */ boolean HasPrevious(); /*! - Returns the previous brother TreeNode of this TreeNode. + Returns the previous brother tree node of this tree node. */ AttributeTreeNode GetPrevious(); /*! - Sets the next brother TreeNode to this treeNode. + Sets the next brother tree node to this tree node. */ void SetNext(in AttributeTreeNode value); /*! - Returns True if there is the next brother TreeNode of this TreeNode. + Returns True if there is the next brother tree node of this tree node. */ boolean HasNext(); /*! - Returns the previous brother TreeNode of this TreeNode. + Returns the previous brother tree node of this tree node. */ AttributeTreeNode GetNext(); /*! - Sets the first child TreeNode to this treeNode. + Sets the first child tree node to this tree node. */ void SetFirst(in AttributeTreeNode value); /*! - Returns True if there is the first child TreeNode of this TreeNode. + Returns True if there is the first child tree node of this tree node. */ boolean HasFirst(); /*! - Returns the first child TreeNode of this TreeNode. + Returns the first child tree node of this tree node. */ AttributeTreeNode GetFirst(); /*! - Sets ID of the tree. TreeNodes of one tree have the same ID. + Sets ID of a tree. + \param value String parameter defining the ID of a tree. + \note
Tree nodes of one tree have the same ID. */ void SetTreeID(in string value); /*! - Gets ID of the tree. + Gets ID of a tree. + \return An ID of a tree in the format of a string. */ string GetTreeID(); /*! - Adds a child TreeNode to the end of the list of children of this Treenode. + Adds a child tree node to the end of the list of children of this tree node. */ void Append(in AttributeTreeNode value); /*! - Adds a child TreeNode to the beginning of the list of children of this Treenode. + Adds a child tree node to the beginning of the list of children of this tree node. */ void Prepend(in AttributeTreeNode value); /*! - Adds a brother TreeNode before this Treenode. - In this case the both TreeNodes will belong to the same father. + Adds a brother tree node before this tree node. + In this case the both tree nodes will belong to the same father. */ void InsertBefore(in AttributeTreeNode value); /*! - Adds a brother TreeNode after this Treenode. - In this case the both TreeNodes will belong to the same father. + Adds a brother tree node after this tree node. + In this case the both tree nodes will belong to the same father. */ void InsertAfter(in AttributeTreeNode value); /*! - Deletes a TreeNode. + Deletes a tree node. +
See also an example of this method usage in batchmode of %SALOME application. */ void Remove(); /*! - Returns the depth of the TreeNode in the - structure, it means the number of fathers of the given TreeNode. - (i.e.: the depth of the root TreeNode is 0). + Returns the depth of the tree node in the + structure, it means the number of fathers of the given tree node. + (i.e.: the depth of the root tree node is 0). */ long Depth(); /*! - Returns True if it is a root TreeNode. + Returns True if it is a root tree node. */ boolean IsRoot(); /*! - Returns True if this TreeNode is a descendant of the TreeNode. + Returns True if this tree node is a descendant of the tree node. */ boolean IsDescendant(in AttributeTreeNode value); /*! - Returns True if this TreeNode is the father of the TreeNode. + Returns True if this tree node is the father of the tree node. */ boolean IsFather(in AttributeTreeNode value); /*! - Returns True if this TreeNode is a child of the TreeNode. + Returns True if this tree node is a child of the tree node. */ boolean IsChild(in AttributeTreeNode value); /*! @@ -616,11 +683,15 @@ Sets the items to be selectable if value is TRUE (the default) or not { /*! Returns the value of this attribute. +
See also an example of this method usage in batchmode of %SALOME application. */ long Value(); /*! Sets the value of this attribute. + + \param value This parameter defines the local ID which will be set. +
See also an example of this method usage in batchmode of %SALOME application. */ void SetValue(in long value); @@ -636,11 +707,13 @@ Sets the items to be selectable if value is TRUE (the default) or not { /*! Returns the value of this attribute +
See also an example of this method usage in batchmode of %SALOME application. */ string Value(); /*! Sets the value of this attribute +
See also an example of this method usage in batchmode of %SALOME application. */ void SetValue(in string value); @@ -665,7 +738,7 @@ Sets the items to be selectable if value is TRUE (the default) or not */ void Add(in SObject anObject); /*! - Returns the list of %SObjects which refer to this %SObject. + Returns a list of %SObjects which refer to this %SObject. */ SALOMEDS::Study::ListOfSObject Get(); /*! @@ -681,6 +754,7 @@ Sets the items to be selectable if value is TRUE (the default) or not This attribute allows to store a table of integers (indexing from 1 like in CASCADE) and string titles of this table, of each row, of each column. +
See also an example of usage of these methods in batchmode of %SALOME application. */ @@ -758,24 +832,35 @@ Sets the items to be selectable if value is TRUE (the default) or not // operations with rows /*! Adds a row to the end of the table. + \param theData A sequence of long values which will be set as elements of the added row. */ void AddRow(in LongSeq theData) raises(IncorrectArgumentLength); /*! - Sets the values of all elements of the row. + Sets the elements of a definite row. + \param theRow The number of the row. + \param theData A sequence of long values which will be set as elements of this row. + */ void SetRow(in long theRow, in LongSeq theData) raises(IncorrectArgumentLength, IncorrectIndex); /*! - Returns the row of the table. + Gets the row of the table. + + \param theRow The number of the row. + \return A sequence of long values which are set as elements of this row. */ LongSeq GetRow(in long theRow) raises(IncorrectIndex); // operations with columns /*! Adds a column to the end of the table. + + \param theData A sequence of long values which will be set as elements of this column. */ void AddColumn(in LongSeq theData) raises(IncorrectArgumentLength); /*! Sets the values of all elements of the column. + + \param theData A sequence of long values which will be set as elements of this column. */ void SetColumn(in long theColumn, in LongSeq theData) raises(IncorrectArgumentLength, IncorrectIndex); /*! diff --git a/idl/SALOME_Component.idl b/idl/SALOME_Component.idl index 391112dfd..ad9be3b06 100644 --- a/idl/SALOME_Component.idl +++ b/idl/SALOME_Component.idl @@ -43,6 +43,8 @@ module Engines { /*! Initializes the %container with a definite name. + \param ContainerName Name of the container + \return an initialized container */ Container start_impl( in string ContainerName ) ; @@ -50,11 +52,13 @@ module Engines Loads into the container a new component, registers it and starts it's CORBA servant. \param nameToRegister Name of the component which will be registered in Registry (or Name Service) \param componentName Name of the constructed library of the %component + \return a loaded component */ Component load_impl(in string nameToRegister, in string componentName); /*! - Stops the component servant, and deletes all related objects + Stops the component servant, and deletes all related objects + \param component_i Component to be removed */ void remove_impl(in Component component_i); @@ -109,6 +113,8 @@ module Engines Container GetContainerRef() ; /*! This method is used by the %SUPERVISOR component. It sets the names of the graph and of the node. + \param aGraphName Name of graph + \param aNodeName Name of node */ void Names( in string aGraphName , in string aNodeName ) ; /*! diff --git a/idl/SALOME_Exception.idl b/idl/SALOME_Exception.idl index c310e9de4..fd6a224c4 100644 --- a/idl/SALOME_Exception.idl +++ b/idl/SALOME_Exception.idl @@ -65,7 +65,7 @@ The main exception in %SALOME application. */ exception SALOME_Exception { - ExceptionStruct details; + ExceptionStruct details; /*! ListOfServicesParameter; + /*! This struct contains fields completely defining each service. */ @@ -65,7 +72,7 @@ This struct contains fields completely defining each service. { string ServiceName; /*! ListOfDefInterface ; /*! -List of interfaces. +List of names of interfaces. */ typedef sequence ListOfInterfaces ; /*! @@ -123,12 +130,16 @@ List of pair GUI elements (component name, component icone) string what ; /*!If the specified interface doesn't exist, Notfound exception is thrown. \param interfacename Name of the interface \return List of services of the required interface @@ -199,13 +210,13 @@ Sets/gets the name of the component */ readonly attribute string componentname; -/*! +/*! Sets/gets the user name of the component */ readonly attribute string componentusername; /*! -Defines whether the component can be multistudy or not +Defines whether the component is multistudy or not */ readonly attribute boolean multistudy; diff --git a/idl/SALOME_Session.idl b/idl/SALOME_Session.idl index 9cce222ff..f42ccde7e 100644 --- a/idl/SALOME_Session.idl +++ b/idl/SALOME_Session.idl @@ -35,7 +35,9 @@ module SALOME This enumeration contains values defining the state of the session */ - enum SessionState {asleep, running} ; + enum SessionState {asleep, /*! Session is inactive */ + running /*! Session is running */ + } ; /*! \brief %Session State and Statistics @@ -80,7 +82,10 @@ module SALOME Launches GUI in the session */ void GetInterface(); - //***// VISU::VISU_Gen GetVisuGen(); + +/*! + Returns the Visu component +*/ Engines::Component GetVisuComponent(); /*! diff --git a/src/Container/SALOME_ContainerPy.py b/src/Container/SALOME_ContainerPy.py index 4d906f84d..6444ef148 100755 --- a/src/Container/SALOME_ContainerPy.py +++ b/src/Container/SALOME_ContainerPy.py @@ -85,12 +85,29 @@ class SALOME_ContainerPy_i (Engines__POA.Container): else : MESSAGE( "SALOME_ContainerPy_i::start_impl " + str(ContainerName) + ".object found without runSession" ) return container - shstr = os.getenv( "PWD" ) + "/" - shstr += "runSession ./SALOME_ContainerPy.py " + #shstr = os.getenv( "PWD" ) + "/" + #shstr += "runSession ./SALOME_ContainerPy.py " + shstr = "runSession SALOME_ContainerPy.py " shstr += ContainerName - shstr += " > /tmp/" - shstr += ContainerName - shstr += ".log 2>&1 &" + + # mpv: fix for SAL4731 - allways create new file to write log of server + num = 1 + fileName = "" + while 1: + fileName = "/tmp/"+ContainerName+"_%i.log"%num + if not os.path.exists(fileName): + break + num += 1 + pass + + shstr += " > " + shstr += fileName + shstr += " 2>&1 &" + + #shstr += " > /tmp/" + #shstr += ContainerName + #shstr += ".log 2>&1 &" + MESSAGE( "SALOME_ContainerPy_i::start_impl " + "os.system(" + str(shstr) + ")" ) os.system( shstr ) count = 21 diff --git a/src/Logger/SALOME_Logger_Server.cxx b/src/Logger/SALOME_Logger_Server.cxx index c3f7acce1..5d1b3a4a7 100644 --- a/src/Logger/SALOME_Logger_Server.cxx +++ b/src/Logger/SALOME_Logger_Server.cxx @@ -53,7 +53,7 @@ void Logger::putMessage(const char* message) void Logger::ping() { - cout<<" Logger::ping() pid "<< getpid()<resolve_initial_references("RootPOA") ; - if(!CORBA::is_nil(obj)) - poa = PortableServer::POA::_narrow(obj) ; - pman = poa->the_POAManager(); - // NB. You can activate the POA before or after - // activating objects in that POA. - - // This activates the object in the root POA (by default), and - // returns a reference to it. - //NB. You can't use SALOME_NamingService class because it uses MESSAGE macro - //Otherwise, you will get segmentation fault. - //Get initial naming context - try{ - if(!CORBA::is_nil(orb)) - theObj = orb->resolve_initial_references("NameService"); - //Narrow to NamingContext - if (!CORBA::is_nil(theObj)){ - inc = CosNaming::NamingContext::_narrow(theObj); - } - }catch(CORBA::COMM_FAILURE&) - { - cout<<"Logger Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service"<resolve_initial_references("RootPOA") ; + if(!CORBA::is_nil(obj)) + poa = PortableServer::POA::_narrow(obj) ; + pman = poa->the_POAManager(); + // NB. You can activate the POA before or after + // activating objects in that POA. + + // This activates the object in the root POA (by default), and + // returns a reference to it. + //NB. You can't use SALOME_NamingService class because it uses MESSAGE macro + //Otherwise, you will get segmentation fault. + //Get initial naming context + if(!CORBA::is_nil(orb)) + theObj = orb->resolve_initial_references("NameService"); + //Narrow to NamingContext + if (!CORBA::is_nil(theObj)) + inc = CosNaming::NamingContext::_narrow(theObj); + } catch(CORBA::COMM_FAILURE&) { + //cout<<"Logger Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service"<_this(); CosNaming::Name name; name.length(1); diff --git a/src/Logger/SALOME_Trace.cxx b/src/Logger/SALOME_Trace.cxx index e3185daf6..d139476c1 100644 --- a/src/Logger/SALOME_Trace.cxx +++ b/src/Logger/SALOME_Trace.cxx @@ -22,80 +22,7 @@ using namespace std; SALOME_Trace::SALOME_Trace() { - //get reference on object reference from NS - //and initialize m_pInterfaceLogger - - int argc = 1; - char* argv[1] = {"application"}; - try - { - //NB. You can't use SALOME_NamingService class because it uses MESSAGE macro - //Otherwise, you will get segmentation fault. - - //Initialize the ORB - CORBA::ORB_var orb = CORBA::ORB_init(argc,argv) ; - long TIMESleep = 250000000; - int NumberOfTries = 40; - int a; - timespec ts_req; - ts_req.tv_nsec=TIMESleep; - ts_req.tv_sec=0; - timespec ts_rem; - ts_rem.tv_nsec=0; - ts_rem.tv_sec=0; - CosNaming::NamingContext_var inc; - CORBA::Object_var theObj; - CORBA::Object_var obj; - CosNaming::Name name; - name.length(1); - name[0].id = CORBA::string_dup("Logger"); - for (int i = 1; i<=NumberOfTries; i++){ - if (i!=1) - a=nanosleep(&ts_req,&ts_rem); - try{ - if(!CORBA::is_nil(orb)) - theObj = orb->resolve_initial_references("NameService"); - if (!CORBA::is_nil(theObj)) - inc = CosNaming::NamingContext::_narrow(theObj); - } - catch( CORBA::COMM_FAILURE& ) - { - cout<<"SALOME_TRACE: CORBA::COMM_FAILURE: Unable to contact the Naming Service" <resolve(name); - m_pInterfaceLogger = SALOME_Logger::Logger::_narrow(obj); - if (!CORBA::is_nil(m_pInterfaceLogger)) - cout<<"SALOME_TRACE: Logger Server was found"<resolve_initial_references("RootPOA"); + if(CORBA::is_nil(theObj)) + theObj = theOrb->resolve_initial_references("NameService"); + if (!CORBA::is_nil(theObj)) + inc = CosNaming::NamingContext::_narrow(theObj); + if (!CORBA::is_nil(inc)) break; + } catch( CORBA::COMM_FAILURE& ) { + } catch (...) { + } + } + + if (CORBA::is_nil(inc)) { + cout<<"SALOME_Trace can not find NameService"<resolve(name); + if (!CORBA::is_nil(obj)) m_pInterfaceLogger = SALOME_Logger::Logger::_narrow(obj); + } catch(CosNaming::NamingContext::NotFound) { + } catch(...) { + } + if (!CORBA::is_nil(m_pInterfaceLogger)) { + //cout<<"SALOME_Trace : Logger Server was found"<ping(); + break; + } + } + if (CORBA::is_nil(m_pInterfaceLogger)) { + cout<<"SALOME_Trace can not find Logger"< 0 and ok == 0: + + try: + orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID) + theObj = orb.resolve_initial_references("NameService") + inc = theObj._narrow(CosNaming.NamingContext) + name = [CosNaming.NameComponent("Logger","")] + obj = inc.resolve(name); + + self.m_pInterfaceLogger = obj._narrow(SALOME_Logger.Logger) + + if not self.m_pInterfaceLogger is None: + ok = 1 + + except CosNaming.NamingContext.NotFound, e : + if steps == 1: print "Caught exception: Naming Service can't found Logger" + except CORBA.COMM_FAILURE, e: + if steps == 1: print "Caught CORBA::SystemException CommFailure" + except CORBA.SystemException, e: + if steps == 1: print "Caught CORBA::SystemException." + except CORBA.Exception, e: + if steps == 1: print "Caught CORBA::Exception." + except Exception, e: + if steps == 1: print "Caught unknown exception." + time.sleep(0.25) + steps = steps - 1 + + def putMessage ( self, LogMsg ) : if (CORBA.is_nil(self.m_pInterfaceLogger)): diff --git a/src/Makefile.in b/src/Makefile.in index 89f82d775..f35650e42 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -33,7 +33,7 @@ VPATH=.:@srcdir@ @COMMENCE@ SUBDIRS = MSG2QM SALOMELocalTrace Logger SALOMELogger Utils PatchQt \ - NamingService Registry \ + GenericObj NamingService Registry \ ModuleCatalog DataTypeCatalog RessourcesCatalog \ Notification NOTIFICATION_SWIG \ Container TestContainer LifeCycleCORBA HDFPersist \ diff --git a/src/NamingService/SALOME_NamingServicePy.py b/src/NamingService/SALOME_NamingServicePy.py index 8b41f25be..2bc3c553c 100644 --- a/src/NamingService/SALOME_NamingServicePy.py +++ b/src/NamingService/SALOME_NamingServicePy.py @@ -46,7 +46,7 @@ class SALOME_NamingServicePy_i: #------------------------------------------------------------------------- def __init__(self, orb): - MESSAGE ( "SALOME_NamingServicePy_i::__init__" ) + #MESSAGE ( "SALOME_NamingServicePy_i::__init__" ) self._orb = orb # initialize root context and current context ok = 0 @@ -138,7 +138,7 @@ class SALOME_NamingServicePy_i: #------------------------------------------------------------------------- def Resolve(self, Path): - MESSAGE ( "SALOME_NamingServicePy_i::Resolve" ) + #MESSAGE ( "SALOME_NamingServicePy_i::Resolve" ) path_list = list(Path) if path_list[0]=='/': self._current_context = self._root_context diff --git a/src/OBJECT/SALOME_Actor.cxx b/src/OBJECT/SALOME_Actor.cxx index 8029335eb..db7a30cf2 100644 --- a/src/OBJECT/SALOME_Actor.cxx +++ b/src/OBJECT/SALOME_Actor.cxx @@ -46,88 +46,16 @@ #include #include +// For test +#include +#include "vtkTimerLog.h" + using namespace std; int SALOME_POINT_SIZE = 3; -void SALOME_Actor::Render(vtkRenderer *ren, vtkMapper *Mapper ) -{ - if (this->Mapper == NULL) { - MESSAGE ("No mapper for actor.") - return; - } - - vtkMapper *bestMapper; - bestMapper = this->Mapper; - - /* render the property */ - if (!this->Property) { - // force creation of a property - this->GetProperty(); - } - - this->Property->Render(this, ren); - if (this->BackfaceProperty) { - this->BackfaceProperty->BackfaceRender(this, ren); - this->Device->SetBackfaceProperty(this->BackfaceProperty); - } - this->Device->SetProperty(this->Property); - - - /* render the texture */ - if (this->Texture) { - this->Texture->Render(ren); - } - - - // Store information on time it takes to render. - // We might want to estimate time from the number of polygons in mapper. - this->Device->Render(ren,bestMapper); - this->EstimatedRenderTime = bestMapper->GetTimeToDraw(); -} - -int SALOME_Actor::RenderOpaqueGeometry(vtkViewport *vp) -{ - int renderedSomething = 0; - vtkRenderer *ren = (vtkRenderer *)vp; - - if ( ! this->Mapper ) { - return 0; - } - - // make sure we have a property - if (!this->Property) { - // force creation of a property - this->GetProperty(); - } - - // is this actor opaque ? - if (this->GetIsOpaque()) { - this->Property->Render(this, ren); - - // render the backface property - if (this->BackfaceProperty) { - this->BackfaceProperty->BackfaceRender(this, ren); - } - - // render the texture - if (this->Texture) { - this->Texture->Render(ren); - } - this->Render(ren,this->Mapper); - - renderedSomething = 1; - } - - return renderedSomething; -} - -void SALOME_Actor::ReleaseGraphicsResources(vtkWindow *renWin) -{ - vtkActor::ReleaseGraphicsResources(renWin); - this->Mapper->ReleaseGraphicsResources(renWin); -} +vtkStandardNewMacro(SALOME_Actor); void SALOME_Actor::AddToRender(vtkRenderer* theRenderer){ theRenderer->AddActor(this); @@ -158,12 +86,33 @@ void SALOME_Actor::SetMapper(vtkMapper* theMapper){ void SALOME_Actor::SetTransform(SALOME_Transform* theTransform){ myTransformFilter->SetTransform(theTransform); - myTransformFilter->Modified(); +} + + +unsigned long int SALOME_Actor::GetMTime(){ + unsigned long mTime = this->Superclass::GetMTime(); + unsigned long time = myTransformFilter->GetMTime(); + mTime = ( time > mTime ? time : mTime ); + return mTime; } void SALOME_Actor::SetRepresentation(int theMode) { - myRepresentation = theMode; + switch(myRepresentation){ + case 0 : + case 2 : + myProperty->DeepCopy(GetProperty()); + } + switch(theMode){ + case 0 : + case 2 : + GetProperty()->DeepCopy(myProperty); + break; + default: + GetProperty()->SetAmbient(1.0); + GetProperty()->SetDiffuse(0.0); + GetProperty()->SetSpecular(0.0); + } switch(theMode){ case 3 : myPassFilter[0]->SetInside(true); @@ -172,9 +121,10 @@ void SALOME_Actor::SetRepresentation(int theMode) { case 0 : GetProperty()->SetPointSize(SALOME_POINT_SIZE); default : - GetProperty()->SetRepresentation(myRepresentation); + GetProperty()->SetRepresentation(theMode); myPassFilter[0]->SetInside(false); } + myRepresentation = theMode; } int SALOME_Actor::GetRepresentation(){ return myRepresentation; @@ -183,6 +133,8 @@ int SALOME_Actor::GetRepresentation(){ SALOME_Actor::SALOME_Actor(){ PreviewProperty = NULL; + ispreselected = Standard_False; + myProperty = vtkProperty::New(); myRepresentation = 2; myTransformFilter = SALOME_TransformFilter::New(); myPassFilter.push_back(SALOME_PassThroughFilter::New()); @@ -195,6 +147,9 @@ SALOME_Actor::~SALOME_Actor(){ myTransformFilter->Delete(); SetPreviewProperty(NULL); for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++) - if(myPassFilter[i] != NULL) + if(myPassFilter[i] != NULL){ + myPassFilter[i]->UnRegisterAllOutputs(); myPassFilter[i]->Delete(); + } + myProperty->Delete(); } diff --git a/src/OBJECT/SALOME_Actor.h b/src/OBJECT/SALOME_Actor.h index ea35d47ef..03758fee9 100644 --- a/src/OBJECT/SALOME_Actor.h +++ b/src/OBJECT/SALOME_Actor.h @@ -50,23 +50,25 @@ class SALOME_Actor : public vtkLODActor{ SALOME_Actor(); ~SALOME_Actor(); public: - vtkTypeMacro(SALOME_Actor,vtkActor); + static SALOME_Actor* New(); + + vtkTypeMacro(SALOME_Actor,vtkLODActor); // Description: // This causes the actor to be rendered. It, in turn, will render the actor`s // property and then mapper. - virtual void Render(vtkRenderer *, vtkMapper *); + //virtual void Render(vtkRenderer *, vtkMapper *); // Description: // This method is used internally by the rendering process. // We overide the superclass method to properly set the estimated render time. - virtual int RenderOpaqueGeometry(vtkViewport *viewport); + //virtual int RenderOpaqueGeometry(vtkViewport *viewport); // Description: // Release any graphics resources that are being consumed by this actor. // The parameter window could be used to determine which graphic // resources to release. - virtual void ReleaseGraphicsResources(vtkWindow *); + //virtual void ReleaseGraphicsResources(vtkWindow *); virtual Standard_Boolean hasIO() { return !myIO.IsNull(); } virtual Handle_SALOME_InteractiveObject getIO() { return myIO; } @@ -105,8 +107,14 @@ class SALOME_Actor : public vtkLODActor{ virtual void SetMapper(vtkMapper* theMapper); virtual void SetTransform(SALOME_Transform* theTransform); + virtual unsigned long int GetMTime(); + virtual void SetRepresentation(int theMode); virtual int GetRepresentation(); + + // Infinitive means actor without size (point for example + // which is not taken into account in calculation of boundaries of the scene + virtual bool IsInfinitive() { return false; } protected: vtkProperty *PreviewProperty; @@ -122,6 +130,7 @@ class SALOME_Actor : public vtkLODActor{ SALOME_Transform *myTransform; std::vector myPassFilter; SALOME_TransformFilter *myTransformFilter; + vtkProperty *myProperty; int myRepresentation; }; diff --git a/src/OCCViewer/OCCViewer_ViewFrame.cxx b/src/OCCViewer/OCCViewer_ViewFrame.cxx index c15abf390..2ddc4325f 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.cxx +++ b/src/OCCViewer/OCCViewer_ViewFrame.cxx @@ -40,6 +40,8 @@ using namespace std; #include "QAD_Application.h" #include "utilities.h" +#include "QAD_Config.h" +#include "QAD_Settings.h" #include "SALOME_Selection.h" #include "SALOME_AISShape.hxx" @@ -49,7 +51,7 @@ using namespace std; // Open CASCADE Include #include #include - +#include /*! Constructor @@ -380,6 +382,7 @@ void OCCViewer_ViewFrame::onViewTrihedron() myViewer->getAISContext()->Display( myViewer->getTrihedron() ); else myViewer->getAISContext()->Erase( myViewer->getTrihedron() ); + onAdjustTrihedron(); } void OCCViewer_ViewFrame::rename( const Handle(SALOME_InteractiveObject)& IObject, QString newName ) @@ -499,11 +502,6 @@ void OCCViewer_ViewFrame::redo(SALOMEDS::Study_var aStudy, Repaint(); } -void OCCViewer_ViewFrame::SetTrihedronSize( int dim ) -{ - myViewer->setTrihedronSize( dim ); -} - /* selection */ Handle(SALOME_InteractiveObject) OCCViewer_ViewFrame::FindIObject(const char* Entry) { @@ -658,6 +656,58 @@ void OCCViewer_ViewFrame::EraseAll() -void OCCViewer_ViewFrame::Repaint(){ +void OCCViewer_ViewFrame::Repaint() +{ + onAdjustTrihedron(); myViewer->getViewer3d()->Update(); } + +void OCCViewer_ViewFrame::onAdjustTrihedron() +{ + Handle (AIS_InteractiveContext) ic = myViewer->getAISContext(); + + if (!ic->IsDisplayed(myViewer->getTrihedron())) + return; + else + { + AIS_ListOfInteractive List; + ic->Erase( myViewer->getTrihedron() ); + ic->DisplayedObjects(List); + ic->Display( myViewer->getTrihedron() ); + if (List.IsEmpty()) + { + myViewer->setTrihedronSize(100); + return; + } + } + + Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)myViewPort)->getView(); + + if (!view3d.IsNull()) + { + double Xmin=0, Ymin=0, Zmin=0, Xmax=0, Ymax=0, Zmax=0; + double aMaxSide; + double aPercents; + + view3d->View()->MinMaxValues(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax); + + if (Xmin==RealFirst() || Ymin==RealFirst() || Zmin==RealFirst() || + Xmax==RealLast() || Ymax==RealLast() || Zmax==RealLast()) + return; + + aMaxSide = Xmax - Xmin; + if (aMaxSide < Ymax -Ymin) aMaxSide = Ymax -Ymin; + if (aMaxSide < Zmax -Zmin) aMaxSide = Zmax -Zmin; + + static float aSizeInPercents = 105; + QString aSetting = QAD_CONFIG->getSetting("Viewer:TrihedronSize"); + if (!aSetting.isEmpty()) aSizeInPercents = aSetting.toFloat(); + + static float EPS = 5.0E-3; + float aSize = myViewer->getTrihedron()->Size(); + float aNewSize = aMaxSide*aSizeInPercents/100.0; + // if the new trihedron size have sufficient difference, then apply the value + if(fabs(aNewSize-aSize) > aSize*EPS || fabs(aNewSize-aSize) > aNewSize*EPS) + myViewer->setTrihedronSize(aNewSize); + } +} diff --git a/src/OCCViewer/OCCViewer_ViewFrame.h b/src/OCCViewer/OCCViewer_ViewFrame.h index 918c9e117..61125300f 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.h +++ b/src/OCCViewer/OCCViewer_ViewFrame.h @@ -65,9 +65,7 @@ class QAD_EXPORT OCCViewer_ViewFrame : public QAD_ViewFrame QCursor cursor() const; void SetSelectionMode( int mode ) {}; - - void SetTrihedronSize( int dim ); - + /* popup management */ void setPopupServer( QAD_Application* ); @@ -134,6 +132,7 @@ class QAD_EXPORT OCCViewer_ViewFrame : public QAD_ViewFrame void onViewBottom(); void onViewTop(); void onViewTrihedron(); + void onAdjustTrihedron(); protected: OCCViewer_Viewer3d* myViewer; // my owner diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index 5dddcc5df..ee92ee7ba 100644 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -45,7 +45,7 @@ public: ViewType getTypeView() const { return VIEW_PLOT2D; } QWidget* getViewWidget(); void SetSelectionMode( int mode ) {} - void SetTrihedronSize( int dim ) {} + void onAdjustTrihedron( ) {} /* popup management */ void setPopupServer( QAD_Application* ); diff --git a/src/RegistryDisplay/RegWidget.cxx b/src/RegistryDisplay/RegWidget.cxx index 9110ca423..afc79eac9 100644 --- a/src/RegistryDisplay/RegWidget.cxx +++ b/src/RegistryDisplay/RegWidget.cxx @@ -50,15 +50,17 @@ using namespace std; # include "HelpWindow.hxx" # include "IntervalWindow.hxx" -static QString addSlash( const QString& path ); - typedef int PIXELS; RegWidget* RegWidget::myRegWidgetPtr = 0; +QString addSlash( const QString& ); +QString findFile( QString filename ); #define BOLD( text ) ( QString( "" ) + QString( text ) + QString( "" ) ) + /*! Creates components list */ + Registry::Components_var MakeRegistry( CORBA::ORB_var &orb ) { @@ -112,32 +114,14 @@ RegWidget::RegWidget(CORBA::ORB_var &orb, QWidget *parent, const char *name ) _tabWidget(0), _refresh(0), _interval(0), myInfoWindow(0), myHelpWindow(0), myIntervalWindow(0) { - + QString aFile = findFile("default.png"); + /* char* dir = getenv( "CSF_ResourcesDefaults" ); QString path( "" ); - QString dir; - char* cenv; - cenv = getenv( "KERNEL_ROOT_DIR" ); - if ( cenv ) { - dir.sprintf( "%s", cenv ); - if ( !dir.isEmpty() ) { - dir = addSlash(dir) ; - dir = dir + "share" ; - dir = addSlash(dir) ; - dir = dir + "salome" ; - dir = addSlash(dir) ; - dir = dir + "resources" ; - dir = addSlash(dir) ; - QDir qDir( dir ); - path = qDir.filePath( "default.png" ); - } - } -// char* dir = getenv( "CSF_ResourcesDefaults" ); -// QString path( "" ); -// if ( dir ) { -// QDir qDir( dir ); -// path = qDir.filePath( "default.png" ); -// } - QPixmap pm ( path ); + if ( dir ) { + QDir qDir( dir ); + path = qDir.filePath( "default.png" ); + }*/ + QPixmap pm ( aFile ); if ( !pm.isNull() ) setIcon( pm ); @@ -466,7 +450,7 @@ void RegWidget::slotSelectRefresh() myIntervalWindow->installEventFilter( this ); myIntervalWindow->setValue(myRefreshInterval); myIntervalWindow->show(); - connect( myIntervalWindow->Cancel(), SIGNAL( clicked() ), myIntervalWindow, SLOT( reject() ) ); + connect( myIntervalWindow->Cancel(), SIGNAL( clicked() ), myIntervalWindow, SLOT( close() ) ); connect( myIntervalWindow->Ok(), SIGNAL( clicked() ), this, SLOT( slotIntervalOk() ) ); END_OF("slotSelectRefresh"); } @@ -596,6 +580,79 @@ void InfoWindow::setText( const QString& text ) myTextView->setText( text ); } +static const char* SEPARATOR = ":"; + +QString findFile( QString filename ) +{ + QString dir; + char* cenv; + + // Try ${HOME}/.salome/resources directory + cenv = getenv( "HOME" ); + if ( cenv ) { + dir.sprintf( "%s", cenv ); + if ( !dir.isEmpty() ) { + dir = addSlash(dir) ; + dir = dir + ".salome" ; + dir = addSlash(dir) ; + dir = dir + "resources" ; + dir = addSlash(dir) ; + QFileInfo fileInfo( dir + filename ); + if ( fileInfo.isFile() && fileInfo.exists() ) + return fileInfo.filePath(); + } + } + // Try ${SALOME_SITE_DIR}/share/salome/resources directory + cenv = getenv( "SALOME_SITE_DIR" ); + if ( cenv ) { + dir.sprintf( "%s", cenv ); + if ( !dir.isEmpty() ) { + dir = addSlash(dir) ; + dir = dir + "share" ; + dir = addSlash(dir) ; + cenv = getenv("SALOME_SITE_NAME"); + if (cenv) dir = dir + cenv; + else dir = dir + "salome" ; + dir = addSlash(dir) ; + dir = dir + "resources" ; + dir = addSlash(dir) ; + QFileInfo fileInfo( dir + filename ); + if ( fileInfo.isFile() && fileInfo.exists() ) + return fileInfo.filePath(); + } + } + // Try ${SALOME_ROOT_DIR}/share/salome/resources directory + cenv = getenv( "SALOME_ROOT_DIR" ); + if ( cenv ) { + dir.sprintf( "%s", cenv ); + if ( !dir.isEmpty() ) { + dir = addSlash(dir) ; + dir = dir + "share" ; + dir = addSlash(dir) ; + dir = dir + "salome" ; + dir = addSlash(dir) ; + dir = dir + "resources" ; + dir = addSlash(dir) ; + QFileInfo fileInfo( dir + filename ); + if ( fileInfo.isFile() && fileInfo.exists() ) + return fileInfo.filePath(); + } + } + // Try CSF_SaloameResources env.var directory ( or directory list ) + cenv = getenv( "CSF_SalomeResources" ); + if ( cenv ) { + dir.sprintf( "%s", cenv ); + if ( !dir.isEmpty() ) { + QStringList dirList = QStringList::split( SEPARATOR, dir, false ); // skip empty entries + for ( int i = 0; i < dirList.count(); i++ ) { + QFileInfo fileInfo( addSlash( dirList[ i ] ) + filename ); + if ( fileInfo.isFile() && fileInfo.exists() ) + return fileInfo.filePath(); + } + } + } + return filename; +} QString addSlash( const QString& path ) { if (!path.isNull()) { diff --git a/src/RegistryDisplay/RegWidgetFactory.cxx b/src/RegistryDisplay/RegWidgetFactory.cxx index dcd0a2759..341e60d54 100644 --- a/src/RegistryDisplay/RegWidgetFactory.cxx +++ b/src/RegistryDisplay/RegWidgetFactory.cxx @@ -37,7 +37,7 @@ void OnGUIEvent( CORBA::ORB_var &orb, QWidget *parent, const char *name ) { // N.B. parent can be 0 RegWidget* ptrRegWidget = RegWidget::GetRegWidget( orb, parent, name ); - ASSERT ( !ptrRegWidget ); + //ASSERT ( !ptrRegWidget ); ptrRegWidget->show(); ptrRegWidget->raise(); ptrRegWidget->setActiveWindow(); diff --git a/src/SALOMEDS/Makefile.in b/src/SALOMEDS/Makefile.in index 394cd98d9..84cb2949f 100644 --- a/src/SALOMEDS/Makefile.in +++ b/src/SALOMEDS/Makefile.in @@ -111,7 +111,7 @@ BIN_CLIENT_IDL = CPPFLAGS+=$(OCC_INCLUDES) $(HDF5_INCLUDES) CXXFLAGS+=$(OCC_CXXFLAGS) -LDFLAGS+= $(HDF5_LIBS) -lTOOLSDS -lSalomeNS -lSalomeHDFPersist -lOpUtil -lSALOMELocalTrace $(CAS_LDPATH) -lTKCAF +LDFLAGS+= $(HDF5_LIBS) -lTOOLSDS -lSalomeNS -lSalomeHDFPersist -lOpUtil -lSALOMELocalTrace $(CAS_LDPATH) -lTKCAF -lSalomeGenericObj -lSalomeLifeCycleCORBA @CONCLUDE@ diff --git a/src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx index fd338ac71..b1ec78bf0 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx @@ -44,6 +44,11 @@ char* SALOMEDS_AttributeIOR_i::Value() void SALOMEDS_AttributeIOR_i::SetValue(const char* value) { CheckLocked(); + + SALOMEDS::Study_var aStudy = SALOMEDS_Study_i::GetStudy(_myAttr->Label(), _myOrb); + aStudy->AddCreatedPostponed(value); + aStudy->AddPostponed(Value()); + CORBA::String_var Str = CORBA::string_dup(value); Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str)); SALOMEDS_Study_i::IORUpdated(Handle(SALOMEDS_IORAttribute)::DownCast(_myAttr),_myOrb); diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx index a0afc4e53..d3cb87809 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx @@ -28,7 +28,8 @@ using namespace std; #include "utilities.h" -#include "SALOMEDS_StudyBuilder_i.hxx" +#include "SALOMEDS_Study_i.hxx" +//#include "SALOMEDS_StudyBuilder_i.hxx" #include "SALOMEDS_SObject_i.hxx" #include "SALOMEDS_SComponent_i.hxx" @@ -111,6 +112,7 @@ SALOMEDS_StudyBuilder_i::~SALOMEDS_StudyBuilder_i() SALOMEDS::SComponent_ptr SALOMEDS_StudyBuilder_i::NewComponent(const char* DataType) { + CheckLocked(); //Always create component under main label. TDF_Label L = _doc->Main(); @@ -144,6 +146,7 @@ SALOMEDS_StudyBuilder_i::NewComponent(const char* DataType) void SALOMEDS_StudyBuilder_i::DefineComponentInstance(SALOMEDS::SComponent_ptr aComponent, CORBA::Object_ptr IOR) { + CheckLocked(); //Find label TDF_Label Lab; ASSERT(!CORBA::is_nil(aComponent)); @@ -165,6 +168,7 @@ void SALOMEDS_StudyBuilder_i::DefineComponentInstance(SALOMEDS::SComponent_ptr a void SALOMEDS_StudyBuilder_i::RemoveComponent(SALOMEDS::SComponent_ptr aComponent) { + CheckLocked(); ASSERT(!CORBA::is_nil(aComponent)); RemoveObject(aComponent); } @@ -177,6 +181,7 @@ SALOMEDS_StudyBuilder_i::RemoveComponent(SALOMEDS::SComponent_ptr aComponent) SALOMEDS::SObject_ptr SALOMEDS_StudyBuilder_i::NewObject(SALOMEDS::SObject_ptr theFatherObject) { + CheckLocked(); TCollection_AsciiString anEntry; //Find label of father @@ -213,6 +218,7 @@ SALOMEDS::SObject_ptr SALOMEDS_StudyBuilder_i::NewObjectToTag(SALOMEDS::SObject_ptr theFatherObject, CORBA::Long atag) { + CheckLocked(); //Find label of father TDF_Label Lab; @@ -237,6 +243,7 @@ SALOMEDS_StudyBuilder_i::NewObjectToTag(SALOMEDS::SObject_ptr theFatherObject, //============================================================================ void SALOMEDS_StudyBuilder_i::RemoveObject(SALOMEDS::SObject_ptr anObject) { + CheckLocked(); if(!CORBA::is_nil(_callbackOnRemove)) _callbackOnRemove->OnRemoveSObject(anObject); TDF_Label Lab; @@ -250,6 +257,10 @@ void SALOMEDS_StudyBuilder_i::RemoveObject(SALOMEDS::SObject_ptr anObject) aTarget->Remove(Lab); } + Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects + if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)) + SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(strdup(TCollection_AsciiString(anAttr->Get()).ToCString())); + Lab.ForgetAllAttributes(); } @@ -260,6 +271,7 @@ void SALOMEDS_StudyBuilder_i::RemoveObject(SALOMEDS::SObject_ptr anObject) //============================================================================ void SALOMEDS_StudyBuilder_i::RemoveObjectWithChildren(SALOMEDS::SObject_ptr anObject) { + CheckLocked(); if(!CORBA::is_nil(_callbackOnRemove)) _callbackOnRemove->OnRemoveSObject(anObject); TDF_Label Lab; @@ -272,6 +284,9 @@ void SALOMEDS_StudyBuilder_i::RemoveObjectWithChildren(SALOMEDS::SObject_ptr anO if (aReference->Get().FindAttribute(SALOMEDS_TargetAttribute::GetID(),aTarget)) aTarget->Remove(Lab); } + Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects + if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)) + SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(strdup(TCollection_AsciiString(anAttr->Get()).ToCString())); TDF_ChildIterator it(Lab); for(;it.More();it.Next()) { @@ -281,6 +296,9 @@ void SALOMEDS_StudyBuilder_i::RemoveObjectWithChildren(SALOMEDS::SObject_ptr anO if (aReference->Get().FindAttribute(SALOMEDS_TargetAttribute::GetID(),aTarget)) aTarget->Remove(aLabel); } + Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects + if (aLabel.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)) + SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(strdup(TCollection_AsciiString(anAttr->Get()).ToCString())); } Lab.ForgetAllAttributes(Standard_True); @@ -546,6 +564,7 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA if (strcmp(aTypeOfAttribute, "AttributeReal") == 0 ) { Handle(TDataStd_Real) anAttr; if (!Lab.FindAttribute(TDataStd_Real::GetID(), anAttr)) { + CheckLocked(); anAttr = new TDataStd_Real; Lab.AddAttribute(anAttr); } @@ -556,6 +575,7 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA else if (strcmp(aTypeOfAttribute, "AttributeInteger") == 0 ) { Handle(TDataStd_Integer) anAttr; if (!Lab.FindAttribute(TDataStd_Integer::GetID(), anAttr)) { + CheckLocked(); anAttr = new TDataStd_Integer; Lab.AddAttribute(anAttr); } @@ -566,6 +586,7 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfReal") == 0 ) { Handle(SALOMEDS_SequenceOfRealAttribute) anAttr; if (!Lab.FindAttribute(SALOMEDS_SequenceOfRealAttribute::GetID(), anAttr)) { + CheckLocked(); anAttr = new SALOMEDS_SequenceOfRealAttribute; Lab.AddAttribute(anAttr); } @@ -576,6 +597,7 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfInteger") == 0 ) { Handle(SALOMEDS_SequenceOfIntegerAttribute) anAttr; if (!Lab.FindAttribute(SALOMEDS_SequenceOfIntegerAttribute::GetID(), anAttr)) { + CheckLocked(); anAttr = new SALOMEDS_SequenceOfIntegerAttribute; Lab.AddAttribute(anAttr); } @@ -586,6 +608,7 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA else if (strcmp(aTypeOfAttribute, "AttributeName") == 0 ) { Handle(TDataStd_Name) anAttr; if (!Lab.FindAttribute(TDataStd_Name::GetID(), anAttr)) { + CheckLocked(); anAttr = new TDataStd_Name; Lab.AddAttribute(anAttr); } @@ -596,6 +619,7 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA else if (strcmp(aTypeOfAttribute, "AttributeComment") == 0 ) { Handle(TDataStd_Comment) anAttr; if (!Lab.FindAttribute(TDataStd_Comment::GetID(), anAttr)) { + CheckLocked(); anAttr = new TDataStd_Comment; Lab.AddAttribute(anAttr); } @@ -626,6 +650,7 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA else if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0 ) { Handle(SALOMEDS_IORAttribute) anAttr; if (!Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)) { + CheckLocked(); anAttr = new SALOMEDS_IORAttribute; Lab.AddAttribute(anAttr); } @@ -686,6 +711,7 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA else if (strcmp(aTypeOfAttribute, "AttributeTextColor") == 0 ) { Handle(SALOMEDS_TextColorAttribute) anAttr; if (!Lab.FindAttribute(SALOMEDS_TextColorAttribute::GetID(), anAttr)) { + CheckLocked(); anAttr = new SALOMEDS_TextColorAttribute; Lab.AddAttribute(anAttr); } @@ -696,6 +722,7 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA else if (strcmp(aTypeOfAttribute, "AttributeTextHighlightColor") == 0 ) { Handle(SALOMEDS_TextHighlightColorAttribute) anAttr; if (!Lab.FindAttribute(SALOMEDS_TextHighlightColorAttribute::GetID(), anAttr)) { + CheckLocked(); anAttr = new SALOMEDS_TextHighlightColorAttribute; Lab.AddAttribute(anAttr); } @@ -706,6 +733,7 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA else if (strcmp(aTypeOfAttribute, "AttributePixMap") == 0 ) { Handle(SALOMEDS_PixMapAttribute) anAttr; if (!Lab.FindAttribute(SALOMEDS_PixMapAttribute::GetID(), anAttr)) { + CheckLocked(); anAttr = new SALOMEDS_PixMapAttribute; Lab.AddAttribute(anAttr); } @@ -724,16 +752,20 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA delete(aGUIDString); } Handle(TDataStd_TreeNode) anAttr; - if (!Lab.FindAttribute(aTreeNodeGUID, anAttr)) + if (!Lab.FindAttribute(aTreeNodeGUID, anAttr)) { + CheckLocked(); anAttr = TDataStd_TreeNode::Set(Lab, aTreeNodeGUID); + } SALOMEDS_AttributeTreeNode_i* aTreeNodeAttr = new SALOMEDS_AttributeTreeNode_i(anAttr, _orb); SALOMEDS::AttributeTreeNode_var aTNA = aTreeNodeAttr->AttributeTreeNode::_this(); return aTNA._retn(); } else if (strncmp(aTypeOfAttribute, "AttributeUserID",15) == 0 ) { Handle(TDataStd_UAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_AttributeUserID_i::DefaultID(), anAttr)) + if (!Lab.FindAttribute(SALOMEDS_AttributeUserID_i::DefaultID(), anAttr)) { + CheckLocked(); anAttr = TDataStd_UAttribute::Set(Lab, SALOMEDS_AttributeUserID_i::DefaultID()); + } SALOMEDS_AttributeUserID_i* aUAttr = new SALOMEDS_AttributeUserID_i(anAttr, _orb); SALOMEDS::AttributeUserID_var aUA = aUAttr->AttributeUserID::_this(); return aUA._retn(); @@ -741,6 +773,7 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA else if (strcmp(aTypeOfAttribute, "AttributeLocalID") == 0 ) { Handle(SALOMEDS_LocalIDAttribute) anAttr; if (!Lab.FindAttribute(SALOMEDS_LocalIDAttribute::GetID(), anAttr)) { + CheckLocked(); anAttr = new SALOMEDS_LocalIDAttribute; Lab.AddAttribute(anAttr); } @@ -761,6 +794,7 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA else if (strcmp(aTypeOfAttribute, "AttributeTableOfInteger") == 0 ) { Handle(SALOMEDS_TableOfIntegerAttribute) anAttr; if (!Lab.FindAttribute(SALOMEDS_TableOfIntegerAttribute::GetID(), anAttr)) { + CheckLocked(); anAttr = new SALOMEDS_TableOfIntegerAttribute; Lab.AddAttribute(anAttr); } @@ -771,6 +805,7 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA else if (strcmp(aTypeOfAttribute, "AttributeTableOfReal") == 0 ) { Handle(SALOMEDS_TableOfRealAttribute) anAttr; if (!Lab.FindAttribute(SALOMEDS_TableOfRealAttribute::GetID(), anAttr)) { + CheckLocked(); anAttr = new SALOMEDS_TableOfRealAttribute; Lab.AddAttribute(anAttr); } @@ -781,6 +816,7 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA else if (strcmp(aTypeOfAttribute, "AttributeTableOfString") == 0 ) { Handle(SALOMEDS_TableOfStringAttribute) anAttr; if (!Lab.FindAttribute(SALOMEDS_TableOfStringAttribute::GetID(), anAttr)) { + CheckLocked(); anAttr = new SALOMEDS_TableOfStringAttribute; Lab.AddAttribute(anAttr); } @@ -791,9 +827,12 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA else if (strcmp(aTypeOfAttribute, "AttributeStudyProperties") == 0 ) { Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; if (!Lab.FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { - anAttr = new SALOMEDS_StudyPropertiesAttribute; - Lab.AddAttribute(anAttr); - anAttr->SetModified(0); + CheckLocked(); + if (!Lab.FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_StudyPropertiesAttribute; + Lab.AddAttribute(anAttr); + anAttr->SetModified(0); + } } SALOMEDS_AttributeStudyProperties_i* aStPropAttr = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb); SALOMEDS::AttributeStudyProperties_var aSPA = aStPropAttr->AttributeStudyProperties::_this(); @@ -802,6 +841,7 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA else if (strcmp(aTypeOfAttribute, "AttributePythonObject") == 0 ) { Handle(SALOMEDS_PythonObjectAttribute) anAttr; if (!Lab.FindAttribute(SALOMEDS_PythonObjectAttribute::GetID(), anAttr)) { + CheckLocked(); anAttr = new SALOMEDS_PythonObjectAttribute; Lab.AddAttribute(anAttr); } @@ -968,12 +1008,21 @@ CORBA::Boolean SALOMEDS_StudyBuilder_i::FindAttribute(SALOMEDS::SObject_ptr anOb //============================================================================ void SALOMEDS_StudyBuilder_i::RemoveAttribute(SALOMEDS::SObject_ptr anObject, - const char* aTypeOfAttribute) + const char* aTypeOfAttribute) { + CheckLocked(); TDF_Label Lab; ASSERT(!CORBA::is_nil(anObject)); CORBA::String_var anobid = anObject->GetID(); TDF_Tool::Label(_doc->GetData(),strdup(anobid),Lab); + + if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0) { // postponed removing of CORBA objects + Handle(SALOMEDS_IORAttribute) anAttr; + if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)) + SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(strdup(TCollection_AsciiString(anAttr->Get()).ToCString())); + else return; + } + Lab.ForgetAttribute (SALOMEDS_SObject_i::ReturnGUIDForAttribute(aTypeOfAttribute)); } @@ -986,6 +1035,7 @@ void SALOMEDS_StudyBuilder_i::Addreference(SALOMEDS::SObject_ptr me, SALOMEDS::SObject_ptr theReferencedObject) { + CheckLocked(); TDF_Label Lab; ASSERT(!CORBA::is_nil(me)); CORBA::String_var meid = me->GetID(); @@ -1009,6 +1059,7 @@ SALOMEDS_StudyBuilder_i::Addreference(SALOMEDS::SObject_ptr me, //============================================================================ void SALOMEDS_StudyBuilder_i::AddDirectory(const char* thePath) { + CheckLocked(); if(thePath == NULL || strlen(thePath) == 0) throw SALOMEDS::Study::StudyInvalidDirectory(); TCollection_AsciiString aPath(CORBA::string_dup(thePath)), aContext(""), aFatherPath; @@ -1075,6 +1126,7 @@ void SALOMEDS_StudyBuilder_i::AddDirectory(const char* thePath) //============================================================================ void SALOMEDS_StudyBuilder_i::SetGUID(SALOMEDS::SObject_ptr anObject, const char* theGUID) { + CheckLocked(); TDF_Label aLabel; ASSERT(!CORBA::is_nil(anObject)); CORBA::String_var anEntry = anObject->GetID(); @@ -1132,6 +1184,8 @@ void SALOMEDS_StudyBuilder_i::CommitCommand() throw (SALOMEDS::StudyBuilder::Loc AbortCommand(); throw SALOMEDS::StudyBuilder::LockProtection(); } else { + SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->RemovePostponed(_doc->GetUndoLimit()); + int aModif = anAttr->GetModified(); if (aModif < 0) aModif = 1000; // if user make undo and then - new transaction "modify" will never be zero anAttr->SetModified(aModif+1); @@ -1156,6 +1210,8 @@ CORBA::Boolean SALOMEDS_StudyBuilder_i::HasOpenCommand() //============================================================================ void SALOMEDS_StudyBuilder_i::AbortCommand() { + SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->UndoPostponed(0); + _doc->AbortCommand(); } @@ -1175,6 +1231,7 @@ void SALOMEDS_StudyBuilder_i::Undo() throw (SALOMEDS::StudyBuilder::LockProtecti INFOS("Locked document modification !!!"); throw SALOMEDS::StudyBuilder::LockProtection(); } else { + SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->UndoPostponed(1); _doc->Undo(); anAttr->SetModified(anAttr->GetModified()-1); } @@ -1198,6 +1255,7 @@ void SALOMEDS_StudyBuilder_i::Redo() throw (SALOMEDS::StudyBuilder::LockProtecti throw SALOMEDS::StudyBuilder::LockProtection(); } else { _doc->Redo(); + SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->UndoPostponed(-1); anAttr->SetModified(anAttr->GetModified()+1); } } @@ -1222,7 +1280,6 @@ CORBA::Boolean SALOMEDS_StudyBuilder_i::GetAvailableRedos() return _doc->GetAvailableRedos(); } - //============================================================================ /*! Function : UndoLimit * Purpose : @@ -1240,6 +1297,7 @@ CORBA::Long SALOMEDS_StudyBuilder_i::UndoLimit() //============================================================================ void SALOMEDS_StudyBuilder_i::UndoLimit(CORBA::Long n) { + CheckLocked(); _doc->SetUndoLimit (n); } @@ -1266,3 +1324,13 @@ SALOMEDS::Callback_ptr SALOMEDS_StudyBuilder_i::SetOnRemoveSObject(SALOMEDS::Cal _callbackOnRemove = SALOMEDS::Callback::_duplicate(theCallback); return aRet; } + +void SALOMEDS_StudyBuilder_i::CheckLocked() throw (SALOMEDS::StudyBuilder::LockProtection) { + if (_doc->HasOpenCommand()) return; + Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; + if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_StudyPropertiesAttribute; + _doc->Main().AddAttribute(anAttr); + } + if (anAttr->IsLocked()) throw SALOMEDS::StudyBuilder::LockProtection(); +} diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx index 14313fac6..f282e4e97 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx @@ -138,6 +138,8 @@ public: virtual CORBA::Long UndoLimit(); virtual void UndoLimit(CORBA::Long); + void CheckLocked() throw (SALOMEDS::StudyBuilder::LockProtection); + virtual SALOMEDS::Callback_ptr SetOnAddSObject(SALOMEDS::Callback_ptr theCallback); virtual SALOMEDS::Callback_ptr SetOnRemoveSObject(SALOMEDS::Callback_ptr theCallback); }; diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index 4d12d2379..f488490f2 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -28,6 +28,7 @@ using namespace std; #include "utilities.h" +#include "SALOME_LifeCycleCORBA.hxx" #include "SALOMEDS_StudyManager_i.hxx" #include "SALOMEDS_Study_i.hxx" #include "SALOMEDS_SComponent_i.hxx" @@ -75,8 +76,12 @@ using namespace std; #include -#define USE_CASE_LABEL_ID "0:2" +#include +#define USE_CASE_LABEL_ID "0:2" +#define AUTO_SAVE_GUID "128268A3-71C9-4036-89B1-F81BD6A4FCF2" +#define AUTO_SAVE_TAG "0:8" +#define AUTO_SAVE_TIME_OUT_IN_SECONDS 1200 //=========================================================================== //Function : LoadAttributes //=========================================================================== @@ -583,35 +588,15 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* aUrl) _IDcounter++; Study->StudyId( _IDcounter ); - // Register study in the naming service - // Path to acces the study - if(!_name_service->Change_Directory("/Study")) - MESSAGE( "Unable to access the study directory" ) - else - { - char* aPath = CORBA::string_dup(aUrl); - char *aName = NULL; - char *adr = strtok(aPath, "/"); - while (adr) - { - aName = adr; - adr = strtok(NULL, "/"); - } - adr = aName; - aName = strtok(adr, "."); - SCRUTE(aName); - _name_service->Register(Study, CORBA::string_dup(aName)); - CORBA::string_free(aPath); - } + // Assign the value of the URL in the study object + Study->URL (aUrl); + SCRUTE(aUrl); // Assign the value of the IOR in the study->root CORBA::String_var IORStudy = _orb->object_to_string(Study); SALOMEDS_IORAttribute::Set(Doc->Main().Root(), TCollection_ExtendedString(CORBA::string_dup(IORStudy)),_orb); - // Assign the value of the URL in the study object - Study->URL (aUrl); - SCRUTE(aUrl); SALOMEDS_PersRefAttribute::Set(Doc->Main(),strdup(aUrl)); if (!hdf_file->ExistInternalObject("STUDY_STRUCTURE")) { @@ -640,6 +625,12 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* aUrl) hdf_file->CloseOnDisk(); + // Register study in the naming service + // Path to acces the study + if(!_name_service->Change_Directory("/Study")) MESSAGE( "Unable to access the study directory" ) + else _name_service->Register(Study, CORBA::string_dup(Study->Name())); + + if (isASCII) { SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames; aFilesToRemove->length(1); @@ -663,7 +654,9 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* aUrl) void SALOMEDS_StudyManager_i::Close(SALOMEDS::Study_ptr aStudy) { if(aStudy->_is_nil()) return; - + + aStudy->RemovePostponed(-1); + // Destroy study name in the naming service if(_name_service->Change_Directory("/Study")) _name_service->Destroy_Name(aStudy->Name()); @@ -705,18 +698,11 @@ void SALOMEDS_StudyManager_i::SaveASCII(SALOMEDS::Study_ptr aStudy, CORBA::Boole //============================================================================ void SALOMEDS_StudyManager_i::SaveAs(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile) { - // Save the URL of the Study => to be used with the function "Save" - aStudy->URL(aUrl); - _SaveAs(aUrl,aStudy,theMultiFile, false); - } void SALOMEDS_StudyManager_i::SaveAsASCII(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile) { - // Save the URL of the Study => to be used with the function "Save" - aStudy->URL(aUrl); - _SaveAs(aUrl,aStudy,theMultiFile, true); } @@ -1300,11 +1286,61 @@ void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl, SALOMEDS::StudyBuilder_var SB= aStudy->NewBuilder(); - aStudy->URL(aUrl); - ASSERT(!CORBA::is_nil(aStudy)); try { + // mpv 15.12.2003: for saving components we have to load all data from all modules + + SALOMEDS::SComponentIterator_var itcomponent1 = aStudy->NewComponentIterator(); + for (; itcomponent1->More(); itcomponent1->Next()) + { + SALOMEDS::SComponent_var sco = itcomponent1->Value(); + // if there is an associated Engine call its method for saving + CORBA::String_var IOREngine; + try { + + if (!sco->ComponentIOR(IOREngine)) { + SALOMEDS::GenericAttribute_var aGeneric; + SALOMEDS::AttributeName_var aName; + if(sco->FindAttribute(aGeneric, "AttributeName")) + aName = SALOMEDS::AttributeName::_narrow(aGeneric); + + if (!aName->_is_nil()) { + + CORBA::String_var aCompType = aName->Value(); + + + CORBA::String_var aFactoryType; + if (strcmp(aCompType, "SUPERV") == 0) aFactoryType = "SuperVisionContainer"; + else aFactoryType = "FactoryServer"; + + Engines::Component_var aComp = + SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component(aFactoryType, aCompType); + + if (aComp->_is_nil()) { + Engines::Component_var aComp = + SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component("FactoryServerPy", aCompType); + } + + if (!aComp->_is_nil()) { + SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aComp); + if (!CORBA::is_nil(aDriver)) { + SB->LoadWith(sco, aDriver); + } + } + } + } + } catch(...) { + MESSAGE("Can not restore information to resave it"); + return; + } + } + + + + CORBA::String_var anOldName = aStudy->Name(); + aStudy->URL(aUrl); + // To change for Save // Do not have to do a new file but just a Open??? Rewrite all informations after erasing evrything?? hdf_file = new HDFfile((char *)aUrl); @@ -1318,6 +1354,10 @@ void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl, hdf_group_datacomponent->CreateOnDisk(); SALOMEDS::SComponentIterator_var itcomponent = aStudy->NewComponentIterator(); + + //SRN: Added 17 Nov, 2003 + SALOMEDS::SObject_var anAutoSaveSO = aStudy->FindObjectID(AUTO_SAVE_TAG); + //SRN: End for (; itcomponent->More(); itcomponent->Next()) { @@ -1329,7 +1369,42 @@ void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl, CORBA::String_var componentDataType = sco->ComponentDataType(); MESSAGE ( "Look for an engine for data type :"<< componentDataType); - // if there is an associated Engine call its method for saving + + //SRN: Added 17 Nov 2003: If there is a specified attribute, the component peforms a special save + if(!CORBA::is_nil(anAutoSaveSO) && SB->IsGUID(sco, AUTO_SAVE_GUID)) { + + SALOMEDS::GenericAttribute_var aGeneric; + SALOMEDS::AttributeTableOfString_var aTable; + if(anAutoSaveSO->FindAttribute(aGeneric, "AttributeTableOfString")) { + aTable = SALOMEDS::AttributeTableOfString::_narrow(aGeneric); + Standard_Integer nbRows = aTable->GetNbRows(), k, aTimeOut = 0; + if(nbRows > 0 && aTable->GetNbColumns() > 1) { + + SALOMEDS::StringSeq_var aRow; + for(k=1; k<=nbRows; k++) { + aRow = aTable->GetRow(k); + if (strcmp(aRow[0], componentDataType) == 0) { + CORBA::String_var anEntry = CORBA::string_dup(aRow[1]); + SALOMEDS::SObject_var aCompSpecificSO = aStudy->FindObjectID(anEntry); + if(!CORBA::is_nil(aCompSpecificSO)) { + SALOMEDS::AttributeInteger_var anInteger; + if(aCompSpecificSO->FindAttribute(aGeneric, "AttributeInteger")) { + anInteger = SALOMEDS::AttributeInteger::_narrow(aGeneric); + anInteger->SetValue(-1); + while(anInteger->Value() < 0) { sleep(2); if(++aTimeOut > AUTO_SAVE_TIME_OUT_IN_SECONDS) break; } + } // if(aCompSpecificSO->FindAttribute(anInteger, "AttributeInteger")) + } // if(!CORBA::is_nil(aCompSpecificSO)) + } // if (strcmp(aRow[0], componentDataType) == 0) + } // for + + } // if(nbRows > 0 && aTable->GetNbColumns() > 1) + + } // if(anAutoSaveSO->FindAttribute(aTable, "AttributeTableOfString") + + } // if(SB->IsGUID(AUTO_SAVE_GUID) + + //SRN: End + CORBA::String_var IOREngine; if (sco->ComponentIOR(IOREngine)) { @@ -1344,6 +1419,7 @@ void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl, MESSAGE("Engine :"<ComponentDataType()); SALOMEDS::TMPFile_var aStream; + if (theASCII) aStream = Engine->SaveASCII(sco,SALOMEDS_Tool::GetDirFromPath(aUrl),theMultiFile); else aStream = Engine->Save(sco,SALOMEDS_Tool::GetDirFromPath(aUrl),theMultiFile); @@ -1452,6 +1528,11 @@ void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl, hdf_group_study_structure->CloseOnDisk(); hdf_file->CloseOnDisk(); + + _name_service->Change_Directory("/Study"); + _name_service->Destroy_Name(anOldName); + _name_service->Register(aStudy, aStudy->Name()); + aStudy->IsSaved(true); hdf_group_study_structure =0; // will be deleted by hdf_file destructor delete hdf_file; // recursively deletes all hdf objects... @@ -1546,7 +1627,8 @@ CORBA::Boolean SALOMEDS_StudyManager_i::CanCopy(SALOMEDS::SObject_ptr theObject) CORBA::Object_var obj = _orb->string_to_object(IOREngine); SALOMEDS::Driver_var Engine = SALOMEDS::Driver::_narrow(obj) ; if (CORBA::is_nil(Engine)) return false; - return Engine->CanCopy(theObject); + Standard_Boolean a = Engine->CanCopy(theObject); + return a; } //============================================================================ diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index c282ab096..ed98968e8 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -39,6 +39,8 @@ using namespace std; #include #include #include +#include +#include #include "SALOMEDS_LocalIDAttribute.hxx" #include "SALOMEDS_PersRefAttribute.hxx" #include "SALOMEDS_UseCaseIterator_i.hxx" @@ -65,6 +67,8 @@ SALOMEDS_Study_i::SALOMEDS_Study_i(const Handle(TDocStd_Document) doc, _URL = NULL; _StudyId = -1; _autoFill = true; + myNbPostponed.Append(0); + myNbUndos = 0; } //============================================================================ @@ -766,9 +770,20 @@ char* SALOMEDS_Study_i::URL() //============================================================================ void SALOMEDS_Study_i::URL(const char* url) { + if (_URL) delete [] _URL; _URL = new char[strlen(url) +1]; strcpy(_URL,url); SCRUTE(_URL); + + char *aName = _URL; + char *adr = strtok(aName, "/"); + while (adr) + { + aName = adr; + adr = strtok(NULL, "/"); + } + strcpy(_URL,url); + Name(aName); } @@ -863,22 +878,25 @@ void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR,const char* anEntry) myIORLabels.Bind(TCollection_ExtendedString(IOR), aLabel); } -void SALOMEDS_Study_i::IORUpdated(const Handle(SALOMEDS_IORAttribute) theAttribute, CORBA::ORB_ptr orb) { - // get accorded study first +SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const TDF_Label theLabel, CORBA::ORB_ptr orb) { Handle(SALOMEDS_IORAttribute) Att; - if (theAttribute->Label().Root().FindAttribute(SALOMEDS_IORAttribute::GetID(),Att)){ - TCollection_AsciiString ch(Att->Get()); - char* IOR = CORBA::string_dup(ch.ToCString()); + if (theLabel.Root().FindAttribute(SALOMEDS_IORAttribute::GetID(),Att)){ + char* IOR = CORBA::string_dup(TCollection_AsciiString(Att->Get()).ToCString()); CORBA::Object_var obj = orb->string_to_object(IOR); SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ; ASSERT(!CORBA::is_nil(aStudy)); - TCollection_AsciiString aString; - TDF_Tool::Entry(theAttribute->Label(),aString); - aStudy->UpdateIORLabelMap(TCollection_AsciiString(theAttribute->Get()).ToCString(), aString.ToCString()); + return SALOMEDS::Study::_duplicate(aStudy); } else { - INFOS("IORUpdated: Problem to get study"); - return; + INFOS("GetStudy: Problem to get study"); } + return SALOMEDS::Study::_nil(); +} + +void SALOMEDS_Study_i::IORUpdated(const Handle(SALOMEDS_IORAttribute) theAttribute, CORBA::ORB_ptr orb) { + TCollection_AsciiString aString; + TDF_Tool::Entry(theAttribute->Label(), aString); + GetStudy(theAttribute->Label(), orb)->UpdateIORLabelMap(TCollection_AsciiString(theAttribute->Get()).ToCString(), + aString.ToCString()); } SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject) { @@ -964,10 +982,12 @@ void SALOMEDS_Study_i::Close() // we have found the associated engine to write the data MESSAGE ( "We have found an engine for data type :"<< sco->ComponentDataType()); CORBA::Object_var obj = _orb->string_to_object(IOREngine); - SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ; - - if (!anEngine->_is_nil()) - anEngine->Close(sco); + if (!CORBA::is_nil(obj)) { + SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ; + + if (!anEngine->_is_nil()) + anEngine->Close(sco); + } } } @@ -980,3 +1000,115 @@ void SALOMEDS_Study_i::Close() if(!anApp.IsNull()) anApp->Close(_doc); _doc.Nullify(); } + +//============================================================================ +/*! Function : AddPostponed + * Purpose : + */ + //============================================================================ +void SALOMEDS_Study_i::AddPostponed(const char* theIOR) { + if (!NewBuilder()->HasOpenCommand()) return; + try { + CORBA::Object_var obj = _orb->string_to_object(theIOR); + if (!CORBA::is_nil(obj)) { + SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj) ; + if (!CORBA::is_nil(aGeneric)) { + TCollection_AsciiString anIOR(strdup(theIOR)); + anIOR.Prepend("d"); + myPostponedIORs.Append(anIOR); // add prefix: deleted + myNbPostponed.SetValue(myNbPostponed.Length(), myNbPostponed.Last() + 1); + } + } + } catch(...) {} +} + +void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR) { + if (!NewBuilder()->HasOpenCommand()) return; + try { + CORBA::Object_var obj = _orb->string_to_object(theIOR); + if (!CORBA::is_nil(obj)) { + SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj) ; + if (!CORBA::is_nil(aGeneric)) { + TCollection_AsciiString anIOR(strdup(theIOR)); + anIOR.Prepend("c"); + myPostponedIORs.Append(anIOR); // add prefix: created + myNbPostponed.SetValue(myNbPostponed.Length(), myNbPostponed.Last() + 1); + } + } + } catch(...) {} +} + +//============================================================================ +/*! Function : RemovePostponed + * Purpose : + */ +//============================================================================ +void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long theUndoLimit) { + int anIndex; + int anOld; + + int aUndoLimit = theUndoLimit; + if (theUndoLimit < 0) aUndoLimit = 0; + + if (myNbUndos > 0) { // remove undone + anOld = 0; + for(anIndex = 1; anIndex < myNbPostponed.Length() - myNbUndos; anIndex++) + anOld += myNbPostponed(anIndex); + int aNew = myPostponedIORs.Length() - myNbPostponed.Last(); + + for(anIndex = anOld + 1; anIndex <= aNew; anIndex++) { + TCollection_AsciiString anIOR = myPostponedIORs(anIndex); + if (anIOR.Value(1) == 'c') { + CORBA::Object_var obj = _orb->string_to_object(strdup(anIOR.Split(1).ToCString())); + SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj); + if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy(); + } + } + if (anOld < aNew) myPostponedIORs.Remove(anOld + 1, aNew); + if (myNbPostponed.Length() > 0) myNbPostponed.Remove(myNbPostponed.Length() - myNbUndos, myNbPostponed.Length() - 1); + + myNbUndos = 0; + } + + if (myNbPostponed.Length() > aUndoLimit) { // remove objects, that can not be undone + anOld = 0; + for(anIndex = myNbPostponed.Length() - aUndoLimit; anIndex >= 1; anIndex--) + anOld += myNbPostponed(anIndex); + for(anIndex = 1; anIndex <= anOld; anIndex++) { + TCollection_AsciiString anIOR = myPostponedIORs(anIndex); + if (anIOR.Value(1) == 'd') { + CORBA::Object_var obj = _orb->string_to_object(strdup(anIOR.Split(1).ToCString())); + SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj); + if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy(); + } + } + if (anOld > 0) myPostponedIORs.Remove(1, anOld); + myNbPostponed.Remove(1, myNbPostponed.Length() - aUndoLimit); + } + + if (theUndoLimit == -1) { // remove all IORs from the study on the study close + TDF_ChildIDIterator anIter(_doc->GetData()->Root(), SALOMEDS_IORAttribute::GetID(), Standard_True); + for(; anIter.More(); anIter.Next()) { + Handle(SALOMEDS_IORAttribute) anAttr = Handle(SALOMEDS_IORAttribute)::DownCast(anIter.Value()); + CORBA::String_var anIOR = strdup(TCollection_AsciiString(anAttr->Get()).ToCString()); + try { + CORBA::Object_var obj = _orb->string_to_object(anIOR); + SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj); + if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy(); + } catch (...) {} + } + } else myNbPostponed.Append(0); +} + +//============================================================================ +/*! Function : UndoPostponed + * Purpose : + */ +//============================================================================ +void SALOMEDS_Study_i::UndoPostponed(const CORBA::Long theWay) { + myNbUndos += theWay; + // remove current postponed + if (myNbPostponed.Last() > 0) + myPostponedIORs.Remove(myPostponedIORs.Length() - myNbPostponed.Last() + 1, myPostponedIORs.Length()); + myNbPostponed(myNbPostponed.Length()) = 0; +} diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index fa5cffaba..be93b95f9 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -42,6 +42,8 @@ #include #include #include +#include +#include //SALOMEDS headers #include "SALOMEDS_SComponentIterator_i.hxx" @@ -70,6 +72,12 @@ private: CORBA::Short _StudyId; SALOMEDS_DataMapStringLabel myIORLabels; + + // data structures for postponed destroying of CORBA object functionality + TColStd_SequenceOfAsciiString myPostponedIORs; // ordered set of IORs + TColStd_SequenceOfInteger myNbPostponed; // number of IOR in the each transaction + int myNbUndos; // number of current Undos, made by user + TDF_Label _current; bool _autoFill; @@ -257,6 +265,8 @@ public: virtual CORBA::Short StudyId(); virtual void StudyId(CORBA::Short id); + static SALOMEDS::Study_ptr GetStudy(const TDF_Label theLabel, CORBA::ORB_ptr orb); + static void IORUpdated(const Handle(SALOMEDS_IORAttribute) theAttribute, CORBA::ORB_ptr orb); virtual void UpdateIORLabelMap(const char* anIOR, const char* aLabel); @@ -277,5 +287,15 @@ public: virtual void Close(); void EnableUseCaseAutoFilling(CORBA::Boolean isEnabled) { _autoFill = isEnabled; } + + // postponed destroying of CORBA object functionality + virtual void AddPostponed(const char* theIOR); + + virtual void AddCreatedPostponed(const char* theIOR); + + virtual void RemovePostponed(const CORBA::Long theUndoLimit); // removes postponed IORs of old transaction + // if theUndoLimit==0, removes all + virtual void UndoPostponed(const CORBA::Long theWay); // theWay = 1: resurrect objects, + // theWay = -1: get back to the list of postponed }; #endif diff --git a/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.cxx b/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.cxx index 7eb9b5545..a5134a76f 100644 --- a/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.cxx @@ -231,11 +231,11 @@ void SALOMEDS_TableOfIntegerAttribute::Restore(const Handle(TDF_Attribute)& with myNbColumns = aTable->myNbColumns; myTitle = aTable->myTitle; - for(anIndex = 1; anIndex <= aTable->GetNbRows();anIndex++) { - SetRowTitle(anIndex,aTable->GetRowTitle(anIndex)); - } + for(anIndex = 1; anIndex <= aTable->GetNbRows();anIndex++) + myRows->Append(aTable->GetRowTitle(anIndex)); + for(anIndex = 1; anIndex <= aTable->GetNbColumns(); anIndex++) - SetColumnTitle(anIndex, aTable->GetColumnTitle(anIndex)); + myCols->Append(aTable->GetColumnTitle(anIndex)); } Handle(TDF_Attribute) SALOMEDS_TableOfIntegerAttribute::NewEmpty() const @@ -258,11 +258,10 @@ void SALOMEDS_TableOfIntegerAttribute::Paste(const Handle(TDF_Attribute)& into, aTable->myNbRows = myNbRows; aTable->myNbColumns = myNbColumns; - for(anIndex = 1; anIndex <= GetNbRows();anIndex++) { - aTable->SetRowTitle(anIndex,GetRowTitle(anIndex)); - } + for(anIndex = 1; anIndex <= GetNbRows();anIndex++) + aTable->myRows->Append(GetRowTitle(anIndex)); for(anIndex = 1; anIndex <= GetNbColumns(); anIndex++) - aTable->SetColumnTitle(anIndex, GetColumnTitle(anIndex)); + aTable->myCols->Append(GetColumnTitle(anIndex)); } diff --git a/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.cxx b/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.cxx index 4d6ae31c1..d12b58bb2 100644 --- a/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.cxx @@ -232,11 +232,11 @@ void SALOMEDS_TableOfRealAttribute::Restore(const Handle(TDF_Attribute)& with) myNbColumns = aTable->myNbColumns; myTitle = aTable->myTitle; - for(anIndex = 1; anIndex <= aTable->GetNbRows();anIndex++) { - SetRowTitle(anIndex,aTable->GetRowTitle(anIndex)); - } + for(anIndex = 1; anIndex <= aTable->GetNbRows();anIndex++) + myRows->Append(aTable->GetRowTitle(anIndex)); + for(anIndex = 1; anIndex <= aTable->GetNbColumns(); anIndex++) - SetColumnTitle(anIndex, aTable->GetColumnTitle(anIndex)); + myCols->Append(aTable->GetColumnTitle(anIndex)); } Handle(TDF_Attribute) SALOMEDS_TableOfRealAttribute::NewEmpty() const @@ -259,11 +259,10 @@ void SALOMEDS_TableOfRealAttribute::Paste(const Handle(TDF_Attribute)& into, aTable->myNbRows = myNbRows; aTable->myNbColumns = myNbColumns; - for(anIndex = 1; anIndex <= GetNbRows();anIndex++) { - aTable->SetRowTitle(anIndex,GetRowTitle(anIndex)); - } + for(anIndex = 1; anIndex <= GetNbRows();anIndex++) + aTable->myRows->Append(GetRowTitle(anIndex)); for(anIndex = 1; anIndex <= GetNbColumns(); anIndex++) - aTable->SetColumnTitle(anIndex, GetColumnTitle(anIndex)); + aTable->myCols->Append(GetColumnTitle(anIndex)); } diff --git a/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.cxx b/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.cxx index 486cee192..737f1f752 100644 --- a/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.cxx @@ -231,11 +231,11 @@ void SALOMEDS_TableOfStringAttribute::Restore(const Handle(TDF_Attribute)& with) myNbColumns = aTable->myNbColumns; myTitle = aTable->myTitle; - for(anIndex = 1; anIndex <= aTable->GetNbRows();anIndex++) { - SetRowTitle(anIndex,aTable->GetRowTitle(anIndex)); - } + for(anIndex = 1; anIndex <= aTable->GetNbRows();anIndex++) + myRows->Append(aTable->GetRowTitle(anIndex)); + for(anIndex = 1; anIndex <= aTable->GetNbColumns(); anIndex++) - SetColumnTitle(anIndex, aTable->GetColumnTitle(anIndex)); + myCols->Append(aTable->GetColumnTitle(anIndex)); } Handle(TDF_Attribute) SALOMEDS_TableOfStringAttribute::NewEmpty() const @@ -258,11 +258,10 @@ void SALOMEDS_TableOfStringAttribute::Paste(const Handle(TDF_Attribute)& into, aTable->myNbRows = myNbRows; aTable->myNbColumns = myNbColumns; - for(anIndex = 1; anIndex <= GetNbRows();anIndex++) { - aTable->SetRowTitle(anIndex,GetRowTitle(anIndex)); - } + for(anIndex = 1; anIndex <= GetNbRows();anIndex++) + aTable->myRows->Append(GetRowTitle(anIndex)); for(anIndex = 1; anIndex <= GetNbColumns(); anIndex++) - aTable->SetColumnTitle(anIndex, GetColumnTitle(anIndex)); + aTable->myCols->Append(GetColumnTitle(anIndex)); } diff --git a/src/SALOMEGUI/CLIENT_msg_en.po b/src/SALOMEGUI/CLIENT_msg_en.po index e20546601..c39094a02 100644 --- a/src/SALOMEGUI/CLIENT_msg_en.po +++ b/src/SALOMEGUI/CLIENT_msg_en.po @@ -20,7 +20,7 @@ msgstr "" #--------------- msgid "INF_VERSION" -msgstr "Version 1.3.0" +msgstr "Version 1.4.0" msgid "INF_COPYRIGHT" msgstr " " @@ -38,8 +38,8 @@ msgstr "salome" #: QAD_Application.cxx:133 msgid "QAD_Application::APP_DEFAULTTITLE" -msgstr "SALOME 1.3.0" +msgstr "SALOME 1.4.0" #: QAD_Desktop.cxx:424 msgid "QAD_Desktop::DESK_DEFAULTTITLE" -msgstr "SALOME 1.3.0" +msgstr "SALOME 1.4.0" diff --git a/src/SALOMEGUI/QAD_Application.cxx b/src/SALOMEGUI/QAD_Application.cxx index 909714d0c..b18a84a78 100644 --- a/src/SALOMEGUI/QAD_Application.cxx +++ b/src/SALOMEGUI/QAD_Application.cxx @@ -415,7 +415,7 @@ const QString& QAD_Application::getStudyExtension() const */ bool QAD_Application::isStudyOpened( const QString& studyName ) { - QString Name = QAD_Tools::getFileNameFromPath( studyName, false ); + QString Name = QAD_Tools::getFileNameFromPath( studyName, true ); return (( getStudyByName( studyName ) != NULL ) || (getStudyByName( Name ) != NULL )); } @@ -483,7 +483,7 @@ void QAD_Application::helpAbout() void QAD_Application::helpSearch() { /* just calls QAD_Desktop::helpSearch() but can have own implementation */ - // getDesktop()->helpSearch(); +// getDesktop()->helpSearch(); } /*! @@ -492,7 +492,7 @@ void QAD_Application::helpSearch() void QAD_Application::helpContents() { /* just calls QAD_Desktop::helpContents() but can have own implementation */ - // getDesktop()->helpContents(); +// getDesktop()->helpContents(); } /*! @@ -820,7 +820,7 @@ QAD_Study* QAD_Application::newStudy() while ( exist ) { exist = false; for (unsigned int ind = 0; ind < List->length();ind++) { - QString NameS = QAD_Tools::getFileNameFromPath( QString( List[ind] ), false ); + QString NameS = QAD_Tools::getFileNameFromPath( QString( List[ind] ), true ); if ( NameS.compare( StudyName ) == 0 ) { StudyName = getDesktop()->getNewStudyName(); exist = true; @@ -933,8 +933,9 @@ QAD_Study* QAD_Application::openStudy( const QString& fileName ) /* open StudyDS */ SALOMEDS::Study_var aStudy = myStudyMgr->Open((char*) name.latin1()); + //MPV: name of the study is set in the study manager now //NRI DEBUG : 11/02/2002 - aStudy->Name( QAD_Tools::getFileNameFromPath(name,false) ); + //aStudy->Name( QAD_Tools::getFileNameFromPath(name,true) ); /* create QAD study */ openStudy = new QAD_Study( this, aStudy, fileName ); diff --git a/src/SALOMEGUI/QAD_Desktop.cxx b/src/SALOMEGUI/QAD_Desktop.cxx index 89a1bf2b8..2c9111917 100644 --- a/src/SALOMEGUI/QAD_Desktop.cxx +++ b/src/SALOMEGUI/QAD_Desktop.cxx @@ -53,7 +53,7 @@ using namespace std; #include "QAD_ObjectBrowser.h" #include "QAD_Resource.h" #include "QAD_FileDlg.h" -//NRI#include "QAD_HelpWindow.h" +//NRI #include "QAD_HelpWindow.h" #include "QAD_DirListDlg.h" #include "QAD_WaitCursor.h" #include "SALOMEGUI_OpenWith.h" @@ -66,6 +66,7 @@ using namespace std; #include "SALOME_ListIteratorOfListIO.hxx" #include "SALOMEGUI_AboutDlg.h" #include "SALOMEGUI_ViewChoiceDlg.h" +#include "SALOMEGUI_SetValueDlg.h" #include "utilities.h" #include "SALOMEGUI_CloseDlg.h" @@ -113,6 +114,18 @@ extern "C" QAD_ResourceMgr* QAD_Desktop::resourceMgr = 0; QPalette* QAD_Desktop::palette = 0; +static QString createString( int theItemId, int thePosId ) +{ + QString aRetString = QString("item-id="); + QString aString; + QString aItemId = aString.setNum(theItemId); + QString aPosId = aString.setNum(thePosId); + aRetString = aRetString + '"'; aRetString = aRetString + aItemId; aRetString = aRetString + '"'; + aRetString = aRetString + " pos-id="; aRetString = aRetString + '"'; + aRetString = aRetString + aPosId; + aRetString = aRetString + '"'; aRetString = aRetString + ">"; + return aRetString; +} /*! Creates the resource manager [ static ] @@ -457,7 +470,7 @@ void QAD_Desktop::createActions() myMainMenu->insertItem ( tr("MEN_DESK_VIEW"), &myViewPopup, 2 ); /* add popup VIEW */ myMainMenu->insertItem ( tr("MEN_DESK_TOOLS"), &myToolsPopup, 5 ); /* add popup TOOLS */ myMainMenu->insertItem ( tr("MEN_DESK_PREF"), &myPrefPopup, 4 ); /* add popup PREF */ - myMainMenu->insertItem ( tr("MEN_DESK_WINDOW"), &myWindowPopup, 6 );/* add popup WINDOW */ + myMainMenu->insertItem ( tr("MEN_DESK_WINDOW"), &myWindowPopup, 6 ); /* add popup WINDOW */ myMainMenu->insertItem ( tr("MEN_DESK_HELP"), &myHelpPopup, 7 ); /* add popup HELP */ /* Applications will insert their items after 'File' 'Edit' and 'View' @@ -728,6 +741,8 @@ void QAD_Desktop::createActions() QAD_ASSERT(connect( myQAG, SIGNAL(selected(QActionP * )), this, SLOT(onDefaultViewer(QActionP *) ))); //VRV: T2.5 - add default viewer + myPrefPopup.insertSeparator(); + QActionP* viewerTrihedronAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_TRIHEDRON"), 0, this ); QAD_ASSERT(connect( viewerTrihedronAction, SIGNAL(activated()), this, SLOT(onViewerTrihedron() ))); viewerTrihedronAction->addTo( &myPrefPopup ); @@ -756,6 +771,12 @@ void QAD_Desktop::createActions() ASCIISaveAction->addTo( &myPrefPopup ); myStdActions.insert( PrefASCIISave, ASCIISaveAction ); + /* Undo level */ + QActionP* UndoLevelAction = new QActionP( "", tr("MEN_DESK_PREF_UNDO_LEVEL"), 0, this ); + QAD_ASSERT(connect( UndoLevelAction, SIGNAL(activated()), this, SLOT(onUndoLevel() ))); + UndoLevelAction->addTo( &myPrefPopup ); + myStdActions.insert( PrefUndoLevelId, UndoLevelAction ); + myPrefPopup.insertSeparator(); /* External Browser */ @@ -811,7 +832,7 @@ void QAD_Desktop::createActions() QActionP* objectBrowserCHRONO_SORTAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_CHRONO_SORT"), 0, this, 0, true ); QAD_ASSERT(connect( objectBrowserCHRONO_SORTAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() ))); objectBrowserCHRONO_SORTAction->setToggleAction(true); - QString showSORT = QAD_CONFIG->getSetting("ObjectBrowser:CHRONO_SORT"); + QString showSORT = QAD_CONFIG->getSetting("ObjectBrowser:ChronologicalSort"); if ( showSORT.compare( aTrueQString ) == 0 ) objectBrowserCHRONO_SORTAction->setOn(true) ; @@ -821,6 +842,34 @@ void QAD_Desktop::createActions() objectBrowserCHRONO_SORTAction->addTo( &myObjBrowserPopup ); myStdActions.insert( PrefObjectBrowserCHRONO_SORTId, objectBrowserCHRONO_SORTAction ) ; + /* Show or don't Show UseCase browser */ + QActionP* objectBrowserShowUseCaseAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_SHOW_USECASE"), 0, this, 0, true ); + QAD_ASSERT(connect( objectBrowserShowUseCaseAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() ))); + objectBrowserShowUseCaseAction->setToggleAction(true); + QString showUseCase = QAD_CONFIG->getSetting("ObjectBrowser:ShowUseCaseBrowser"); + + if ( showUseCase.compare( aTrueQString ) == 0 ) + objectBrowserShowUseCaseAction->setOn(true) ; + else + objectBrowserShowUseCaseAction->setOn(false) ; + + objectBrowserShowUseCaseAction->addTo( &myObjBrowserPopup ); + myStdActions.insert( PrefObjectBrowserShowUseCaseId, objectBrowserShowUseCaseAction ) ; + + /* Resize or don't resize columns automatically */ + QActionP* objectBrowserNoAutoSizeAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_NO_AUTOSIZE"), 0, this, 0, true ); + QAD_ASSERT(connect( objectBrowserNoAutoSizeAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() ))); + objectBrowserNoAutoSizeAction->setToggleAction(true); + QString noAutoSize = QAD_CONFIG->getSetting("ObjectBrowser:NoAutoSizeColumns"); + + if ( noAutoSize.compare( aTrueQString ) == 0 ) + objectBrowserNoAutoSizeAction->setOn(true) ; + else + objectBrowserNoAutoSizeAction->setOn(false) ; + + objectBrowserNoAutoSizeAction->addTo( &myObjBrowserPopup ); + myStdActions.insert( PrefObjectBrowserNoAutoSizeColumnsId, objectBrowserNoAutoSizeAction ) ; + myPrefPopup.insertSeparator(); QActionP* dirAction = new QActionP( "", tr("MEN_DESK_PREF_DIRICTORIES"), ALT+Key_D, this ); @@ -1169,6 +1218,18 @@ QAD_Study* QAD_Desktop::findStudy( SALOMEDS::Study_ptr theStudy ) return 0; } +/*! + Gets value of max undo level for SALOMEDS::Study's from preferences +*/ +int QAD_Desktop::getUndoLevel() +{ + static int MAX_UNDO = 10; + int anUndoLevel = MAX_UNDO; + QString aLevel = QAD_CONFIG->getSetting("Desktop:UndoLevel"); + if(!aLevel.isEmpty()) anUndoLevel = aLevel.toInt(); + return anUndoLevel; +} + /*! Returns current active application */ @@ -1436,8 +1497,8 @@ void QAD_Desktop::onLoadStudy() //don't ask user to remove study permanently if (app->getStudyByName ( name ) != NULL) onCloseStudy ( app->getStudyByName ( name ), false ); - else if (app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, false )) != NULL) - onCloseStudy ( app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, false )), false ); + else if (app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, true )) != NULL) + onCloseStudy ( app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, true )), false ); } appFound = true; @@ -1525,8 +1586,7 @@ void QAD_Desktop::onOpenStudy() SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies(); for (unsigned int ind = 0; ind < List->length();ind++) { QString NameExistingStudy(List[ind]); - QString NameOpeningStudy = QAD_Tools::getFileNameFromPath( name, false ); - + QString NameOpeningStudy = QAD_Tools::getFileNameFromPath( name, true ); if ( NameExistingStudy.compare( NameOpeningStudy ) == 0 ) { if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"), tr("QUE_DOC_ALREADYEXIST").arg( name ), @@ -1571,8 +1631,8 @@ void QAD_Desktop::onOpenStudy() //don't ask user to remove study permanently if (app->getStudyByName ( name ) != NULL) onCloseStudy ( app->getStudyByName ( name ), false ); - else if (app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, false )) != NULL) - onCloseStudy ( app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, false )), false ); + else if (app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, true )) != NULL) + onCloseStudy ( app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, true )), false ); } appFound = true; @@ -1634,10 +1694,10 @@ bool QAD_Desktop::loadComponentData( const QString& compName ) if (!CORBA::is_nil(driver)) { SALOMEDS::StudyBuilder_var B = aStudy->NewBuilder(); if (!CORBA::is_nil(B)) { - QAD_Operation* op = new QAD_Operation( myActiveStudy ); - op->start(); +// QAD_Operation* op = new QAD_Operation( myActiveStudy ); +// op->start(); B->LoadWith(SCO,driver); - op->finish(); +// op->finish(); } else { return false; } @@ -2029,8 +2089,8 @@ void QAD_Desktop::onNewWindow3d() class RunBrowser: public QThread { public: - RunBrowser(QString theApp, QString theParams, QString theHelpFile): - myApp(theApp), myParams(theParams), myHelpFile(theHelpFile), myStatus(0) {}; + RunBrowser(QString theApp, QString theParams, QString theHelpFile, QString theContext=NULL): + myApp(theApp), myParams(theParams), myHelpFile("file:" + theHelpFile + theContext), myStatus(0) {}; virtual void run() { @@ -2088,9 +2148,8 @@ void QAD_Desktop::onHelpContents() return; } } - - QString helpFile = QFileInfo( homeDir + "index.html" ).absFilePath(); - + + QString helpFile = QFileInfo( homeDir + "index.html" ).absFilePath(); QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application"); QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters"); @@ -2103,7 +2162,6 @@ void QAD_Desktop::onHelpContents() */ void QAD_Desktop::onHelpContentsGUI() { - // QCString dir; // QString root; // QString homeDir; @@ -2123,9 +2181,7 @@ void QAD_Desktop::onHelpContentsGUI() // } // if ( root.isEmpty() ) // root = "./doc/"; - // QString helpFile = QFileInfo( homeDir + "salomedoc.html" ).absFilePath(); - // QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application"); // QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters"); @@ -2155,7 +2211,7 @@ void QAD_Desktop::onHelpContentsTUI() return; } } - + QString helpFile = QFileInfo( homeDir + "index.html" ).absFilePath(); QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application"); @@ -2536,6 +2592,14 @@ bool QAD_Desktop::loadComponent(QString Component) QXmlSimpleReader reader; reader.setContentHandler( myXmlHandler ); reader.setErrorHandler( myXmlHandler ); + + bool IsMaxActStudy = myActiveStudy->getActiveStudyFrame()->isMaximized(); + if (IsMaxActStudy) { + QString aSourceData = source.data(); + aSourceData = changeXmlInputSourceData( aSourceData, Component ); + source.setData(aSourceData); + } + bool ok = reader.parse( source ); file.close(); if ( !ok ) { @@ -2705,6 +2769,119 @@ bool QAD_Desktop::loadComponent(QString Component) return true; } +QString QAD_Desktop::changeXmlInputSourceData(QString theData, QString theComponent) +{ + if ( theComponent=="Supervision" ) { + //Supervision main menu item + int aItemId = 300; + int aPosId = 3; + QString aStrOld = createString( aItemId, aPosId ); + QString aStrNew = createString( aItemId, aPosId+1 ); + theData = theData.replace( QRegExp(aStrOld), aStrNew ); + } + + if ( theComponent == "Visu" ) { + //Visualization main menu item + int aItemId = 401; + int aPosId = 3; + QString aStrOld = createString( aItemId, aPosId ); + QString aStrNew = createString( aItemId, aPosId+1 ); + theData = theData.replace( QRegExp(aStrOld), aStrNew ); + + //Selection main menu item + aItemId = 41; + aPosId = 4; + aStrOld = createString( aItemId, aPosId ); + aStrNew = createString( aItemId, aPosId+1 ); + theData = theData.replace( QRegExp(aStrOld), aStrNew ); + + //Representation main menu item + aItemId = 42; + aPosId = 5; + aStrOld = createString( aItemId, aPosId ); + aStrNew = createString( aItemId, aPosId+1 ); + theData = theData.replace( QRegExp(aStrOld), aStrNew ); + } + + if ( theComponent == "SMESH" ) { + //Hypotheses main menu item + int aItemId = 50; + int aPosId = 3; + QString aStrOld = createString( aItemId, aPosId ); + QString aStrNew = createString( aItemId, aPosId+1 ); + theData = theData.replace( QRegExp(aStrOld), aStrNew ); + + //Mesh main menu item + aItemId = 70; + aPosId = 4; + aStrOld = createString( aItemId, aPosId ); + aStrNew = createString( aItemId, aPosId+1 ); + theData = theData.replace( QRegExp(aStrOld), aStrNew ); + + //Controls main menu item + aItemId = 60; + aPosId = 5; + aStrOld = createString( aItemId, aPosId ); + aStrNew = createString( aItemId, aPosId+1 ); + theData = theData.replace( QRegExp(aStrOld), aStrNew ); + + //Modification main menu item + aItemId = 40; + aPosId = 6; + aStrOld = createString( aItemId, aPosId ); + aStrNew = createString( aItemId, aPosId+1 ); + theData = theData.replace( QRegExp(aStrOld), aStrNew ); + + //Numbering main menu item + aItemId = 80; + aPosId = 7; + aStrOld = createString( aItemId, aPosId ); + aStrNew = createString( aItemId, aPosId+1 ); + theData = theData.replace( QRegExp(aStrOld), aStrNew ); + } + + if ( theComponent == "Geometry" ) { + //New Entity main menu item + int aItemId = 70; + int aPosId = 3; + QString aStrOld = createString( aItemId, aPosId ); + QString aStrNew = createString( aItemId, aPosId+1 ); + theData = theData.replace( QRegExp(aStrOld), aStrNew ); + + //Operations main menu item + aItemId = 40; + aPosId = 4; + aStrOld = createString( aItemId, aPosId ); + aStrNew = createString( aItemId, aPosId+1 ); + theData = theData.replace( QRegExp(aStrOld), aStrNew ); + + //Repair main menu item + aItemId = 50; + aPosId = 5; + aStrOld = createString( aItemId, aPosId ); + aStrNew = createString( aItemId, aPosId+1 ); + theData = theData.replace( QRegExp(aStrOld), aStrNew ); + + //Measures main menu item + aItemId = 60; + aPosId = 6; + aStrOld = createString( aItemId, aPosId ); + aStrNew = createString( aItemId, aPosId+1 ); + theData = theData.replace( QRegExp(aStrOld), aStrNew ); + } + + if ( theComponent == "Med" ) { + //MED main menu item + int aItemId = 90; + int aPosId = 3; + QString aStrOld = createString( aItemId, aPosId ); + QString aStrNew = createString( aItemId, aPosId+1 ); + theData = theData.replace( QRegExp(aStrOld), aStrNew ); + } + + return theData; +} + typedef bool OneDim(int, QAD_Desktop*); typedef void (*PTR_FACTORY_FUNCTION)( CORBA::ORB_var &orb, QWidget *parent, const char *name ) ; @@ -2931,6 +3108,7 @@ void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoad /*! */ void QAD_Desktop::activateComponent(const QString& theName, bool isLoadData){ + int nbItem = myCombo->count(); int Index = 0; @@ -3223,10 +3401,30 @@ void QAD_Desktop::onObjectBrowser() bool showCHRONO_SORT ; if ( myStdActions.at( PrefObjectBrowserCHRONO_SORTId )->isOn() ) { showCHRONO_SORT = true; - QAD_CONFIG->addSetting( "ObjectBrowser:CHRONO_SORT", "true"); + QAD_CONFIG->addSetting( "ObjectBrowser:ChronologicalSort", "true"); } else { showCHRONO_SORT = false; - QAD_CONFIG->addSetting( "ObjectBrowser:CHRONO_SORT", "false"); + QAD_CONFIG->addSetting( "ObjectBrowser:ChronologicalSort", "false"); + } + + /* To show or not to show UseCase browser */ + bool showUseCase; + if ( myStdActions.at( PrefObjectBrowserShowUseCaseId )->isOn() ) { + showUseCase = true; + QAD_CONFIG->addSetting( "ObjectBrowser:ShowUseCaseBrowser", "true"); + } else { + showUseCase = false; + QAD_CONFIG->addSetting( "ObjectBrowser:ShowUseCaseBrowser", "false"); + } + + /* Resize or don't resize columns automatically */ + bool autoSize; + if ( myStdActions.at( PrefObjectBrowserNoAutoSizeColumnsId )->isOn() ) { + autoSize = false; + QAD_CONFIG->addSetting( "ObjectBrowser:NoAutoSizeColumns", "true"); + } else { + autoSize = true; + QAD_CONFIG->addSetting( "ObjectBrowser:NoAutoSizeColumns", "false"); } if ( myActiveApp ) { @@ -3239,6 +3437,8 @@ void QAD_Desktop::onObjectBrowser() sf->getLeftFrame()->getObjectBrowser()->setShowValueColumn( showValue ); sf->getLeftFrame()->getObjectBrowser()->setEnableChronoSort( showCHRONO_SORT ); // sf->getLeftFrame()->getObjectBrowser()->setShowIAPP( showIAPP ); // this is done by below updateObjBrowser() call + sf->getLeftFrame()->getObjectBrowser()->showUseCaseBrowser( showUseCase ); + sf->getLeftFrame()->getObjectBrowser()->autoSizeColumns( autoSize ); } study->updateObjBrowser(true); } @@ -3265,7 +3465,7 @@ void QAD_Desktop::onViewerTrihedron() for ( QAD_Study* study = studies.first(); study; study = studies.next() ) { int nbSf = study->getStudyFramesCount(); for ( int i = 0; i < nbSf; i++ ) { - study->getStudyFrame(i)->getRightFrame()->getViewFrame()->SetTrihedronSize((int)dim); + study->getStudyFrame(i)->getRightFrame()->getViewFrame()->onAdjustTrihedron(); } } } @@ -3553,13 +3753,19 @@ void QAD_Desktop::helpAbout() // } /* Help Context */ -// void QAD_Desktop::helpContext(const QString& source, const QString& context) -// { -// // getHelpWindow()->context(source, context); -// // getHelpWindow()->show(); -// // getHelpWindow()->raise(); -// // getHelpWindow()->setActiveWindow(); -// } +//void QAD_Desktop::helpContext(const QString& source, const QString& context) +//{ +// //getHelpWindow()->context(source, context); //implemented in QAD_HelpWindow::context( const QString& _source, const QString& _context) +// //getHelpWindow()->show(); //from QMainWindow class +// //getHelpWindow()->raise(); //from QMainWindow class +// //getHelpWindow()->setActiveWindow(); //from QMainWindow class + +// QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application"); +// QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters"); + +// RunBrowser* rs = new RunBrowser(anApp, aParams, source, context); +// rs->start(); +//} /* Preferences/MultiFile Save */ void QAD_Desktop::onMultiFileSave() @@ -3579,6 +3785,39 @@ void QAD_Desktop::onASCIISave() QAD_CONFIG->addSetting( "Desktop:ASCIISave", "false"); } +/* Preferences / Undo Level */ +void QAD_Desktop::onUndoLevel() +{ + static int MAX_UNDO_LEVEL = 1000; + bool isAccepted = false; + static QString aLabel = QString("Level value (%1 ... %2) : "). + arg(1).arg(MAX_UNDO_LEVEL); + int anUndoLevel = + SALOMEGUI_SetValueDlg::getInteger("Undo Level",aLabel, + 1,MAX_UNDO_LEVEL,getUndoLevel(), + &isAccepted); + if(!isAccepted) return; + QAD_CONFIG->addSetting("Desktop:UndoLevel", anUndoLevel); + if(!myActiveApp) return; + QList& studies = myActiveApp->getStudies(); + int aWasWarning = 0; + for(QAD_Study* study = studies.first(); study; study = studies.next()){ + SALOMEDS::Study_var aStudyDoc = study->getStudyDocument(); + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudyDoc->NewBuilder(); + if (!aStudyDoc->GetProperties()->IsLocked()) { + aStudyBuilder->UndoLimit(anUndoLevel); + } else { + if (!aWasWarning) { + QAD_MessageBox::warn1 ((QWidget*)QAD_Application::getDesktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK")); + aWasWarning = 1; + } + } + } +} + /********************************************************************* ** Class: AppSelectionDlg ** Descr: Dialog for the selection of the application when several diff --git a/src/SALOMEGUI/QAD_Desktop.h b/src/SALOMEGUI/QAD_Desktop.h index c8743a3c2..56f8a7907 100644 --- a/src/SALOMEGUI/QAD_Desktop.h +++ b/src/SALOMEGUI/QAD_Desktop.h @@ -34,7 +34,7 @@ #include "QAD_Application.h" #include "QAD_OperatorMenus.h" #include "QAD_Menus.h" -//NRI #include "QAD_HelpWindow.h" +//NRI#include "QAD_HelpWindow.h" #include "QAD_Action.h" #include "SALOME_NamingService.hxx" @@ -79,8 +79,9 @@ protected: DefaultViewerOCCId, DefaultViewerVTKId, DefaultGraphSupervisorId, DefaultPlot2dId, //VRV: T2.5 - add default viewer PrefViewerTrihedronId, PrefConsoleFontId, PrefObjectBrowserEntryId, - PrefObjectBrowserIAPPId, PrefObjectBrowserValueId, PrefObjectBrowserCHRONO_SORTId, - PrefDirsId, PrefMultiFileSave, PrefASCIISave, PrefExternalBrowserId, PrefSaveId, + PrefObjectBrowserIAPPId, PrefObjectBrowserValueId, PrefObjectBrowserCHRONO_SORTId,PrefObjectBrowserShowUseCaseId, + PrefObjectBrowserNoAutoSizeColumnsId, + PrefDirsId, PrefMultiFileSave, PrefASCIISave, PrefUndoLevelId, PrefExternalBrowserId, PrefSaveId, //NRI : SAL2214 WindowNew3dId, ViewOCCId, ViewVTKId, ViewPlot2dId, //NRI : SAL2214 @@ -144,14 +145,15 @@ public: QWorkspaceP* getMainFrame() const; QString getNewStudyName(); QAD_Study* findStudy( SALOMEDS::Study_ptr theStudy ); - + static int getUndoLevel(); /* help actions */ virtual void helpAbout(); -/* virtual void helpSearch(); */ -/* virtual void helpContents(); */ -/* virtual void helpContext(const QString& path, const QString& dir = QString::null); */ - +/* virtual void helpSearch(); + virtual void helpContents(); + virtual void helpContext(const QString& path, const QString& dir = QString::null); +*/ bool loadComponent(QString); + QString changeXmlInputSourceData(QString theData, QString theComponent); void activateComponent(const QString& theName, bool isLoadData = true); void createStudy(); @@ -236,6 +238,7 @@ protected slots: void onObjectBrowser(); void onMultiFileSave(); void onASCIISave(); + void onUndoLevel(); void onExternalBrowser(); void onActivateApp(QAD_Application* app); @@ -244,7 +247,7 @@ protected slots: void onHelpContents(); void onHelpContentsGUI(); void onHelpContentsTUI(); -/* void onHelpSearch(); */ +/* void onHelpSearch(); */ void onHelpAbout(); void onNewWindow3d(); @@ -260,7 +263,7 @@ protected slots: void onComboActiveComponent( const QString & , bool isLoadData); void onCascade(); - //NRI void onHelpWindowClosed(); +/* NRI void onHelpWindowClosed(); */ protected: QMenuBar* myMainMenu; /* the main menu bar */ @@ -308,7 +311,7 @@ protected: QList myMenusList; QAD_Menus* myActiveMenus; - //NRI QAD_HelpWindow* myHelpWindow; + //NRI QAD_HelpWindow* myHelpWindow; QList myComponentButton; diff --git a/src/SALOMEGUI/QAD_FileDlg.cxx b/src/SALOMEGUI/QAD_FileDlg.cxx index 2d626eb96..df22e1e21 100644 --- a/src/SALOMEGUI/QAD_FileDlg.cxx +++ b/src/SALOMEGUI/QAD_FileDlg.cxx @@ -227,10 +227,11 @@ void QAD_FileDlg::addExtension() // if ( mySelectedFile.isEmpty() )//VSR- 06/12/02 if ( mySelectedFile.stripWhiteSpace().isEmpty() )//VSR+ 06/12/02 return; - + // if ( QAD_Tools::getFileExtensionFromPath( mySelectedFile ).isEmpty() ) //VSR- 06/12/02 - if ( QAD_Tools::getFileExtensionFromPath( mySelectedFile ).isEmpty() && !mySelectedFile.contains(".") ) //VSR+ 06/12/02 - { +//ota : 16/12/03 if ( QAD_Tools::getFileExtensionFromPath( mySelectedFile ).isEmpty() ) //VSR+ 06/12/02 +// { + #if QT_VERSION < 0x030000 QRegExp r( QString::fromLatin1("([a-zA-Z0-9.*? +;#]*)$") ); int len, index = r.match( selectedFilter(), 0, &len ); @@ -247,11 +248,28 @@ void QAD_FileDlg::addExtension() // QString wildcard = selectedFilter().mid( index + 1, r.matchedLength()-2 ); //VSR- 06/12/02 QString wildcard = selectedFilter().mid( index + 1, r.matchedLength()-2 ).stripWhiteSpace(); //VSR+ 06/12/02 #endif - index = wildcard.findRev( '.' ); - if ( index >= 0 ) - mySelectedFile += wildcard.mid( index ); + if ( mySelectedFile[mySelectedFile.length() - 1] == '.') + //if the file name ends with the point remove it + mySelectedFile.truncate(mySelectedFile.length() - 1); + QString anExt = "." + QAD_Tools::getFileExtensionFromPath( mySelectedFile ).stripWhiteSpace(); + // From the filters list make a pattern to validate a file extension + // Due to transformations from the filter list (*.txt *.*xx *.c++ QAD*.* ) we + // will have the pattern (\.txt|\..*xx|\.c\+\+|\..*) (as we validate extension only we remove + // stay extension mask only in the pattern + QString aPattern(wildcard); + QRegExp anExtRExp("("+aPattern.replace(QRegExp("(^| )[0-9a-zA-Z*_?]*\\."), " \\."). + stripWhiteSpace().replace(QRegExp("\\s+"), "|"). + replace(QRegExp("[*]"),".*").replace(QRegExp("[+]"),"\\+") + ")"); + + if ( anExtRExp.match(anExt) == -1 ) //if a selected file extension does not match to filter's list + { //remove a point if it is at the word end + if (anExt[ anExt.length() - 1 ] == '.') anExt.truncate( anExt.length() - 1 ); + index = wildcard.findRev( '.' ); + if ( index >= 0 ) + mySelectedFile += wildcard.mid( index ); //add the extension + } } - } + // } } /*! diff --git a/src/SALOMEGUI/QAD_HelpWindow.cxx b/src/SALOMEGUI/QAD_HelpWindow.cxx index 8cb020a7e..d715bf5df 100644 --- a/src/SALOMEGUI/QAD_HelpWindow.cxx +++ b/src/SALOMEGUI/QAD_HelpWindow.cxx @@ -119,31 +119,31 @@ QAD_HelpWindow::QAD_HelpWindow() QCString dir; QString root; if ( (dir = getenv("KERNEL_ROOT_DIR")) ) { - root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + "doc" ); - if ( QFileInfo( root + "index.html" ).exists() ) { - homeDir = root; - } - else { - root = QAD_Tools::addSlash( root + "html" ); - if ( QFileInfo( root + "index.html" ).exists() ) { - homeDir = root; - } - else { - root = QAD_Tools::addSlash( root + "html" ); - if ( QFileInfo( root + "index.html" ).exists() ) { - homeDir = root; - } - } - } + root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + "doc" ); + if ( QFileInfo( root + "index.html" ).exists() ) { + homeDir = root; + } + else { + root = QAD_Tools::addSlash( root + "html" ); + if ( QFileInfo( root + "index.html" ).exists() ) { + homeDir = root; + } + else { + root = QAD_Tools::addSlash( root + "html" ); + if ( QFileInfo( root + "index.html" ).exists() ) { + homeDir = root; + } + } + } } if ( root.isEmpty() ) { - if ( QFileInfo( "/usr/local/doc/html/index.html" ).exists() ) { - homeDir = "/usr/local/doc/html/"; - } + if ( QFileInfo( "/usr/local/doc/html/index.html" ).exists() ) { + homeDir = "/usr/local/doc/html/"; + } } if ( root.isEmpty() ) - root = "./doc/"; - + root = "./doc/"; + browser->setSource( QFileInfo( homeDir + "index.html" ).absFilePath() ); */ browser->setFocus(); diff --git a/src/SALOMEGUI/QAD_ObjectBrowser.cxx b/src/SALOMEGUI/QAD_ObjectBrowser.cxx index 7bea424c0..d72f4c9d3 100644 --- a/src/SALOMEGUI/QAD_ObjectBrowser.cxx +++ b/src/SALOMEGUI/QAD_ObjectBrowser.cxx @@ -36,6 +36,7 @@ using namespace std; #include "QAD_Settings.h" #include "QAD_Tools.h" #include "QAD_RightFrame.h" +#include "QAD_LeftFrame.h" #include "SALOME_Selection.h" #include "SALOME_InteractiveObject.hxx" #include "SALOME_ListIteratorOfListIO.hxx" @@ -72,6 +73,19 @@ using namespace std; #define UC_CLEAR_ID 1000014 #define UC_SET_CURRENT_ID 1000016 +/*! + Small button which updates Object Browser's contents +*/ +Btn::Btn ( QWidget * parent, const char * name ) : QToolButton( parent, name ) +{ + connect( this, SIGNAL(clicked()), this, SLOT(onClicked()) ); +} +void Btn::onClicked() +{ + QAD_ObjectBrowser* OB = QAD_Application::getDesktop()->getActiveApp()->getActiveStudy()->getActiveStudyFrame()->getLeftFrame()->getObjectBrowser(); + OB->Update(); +} + /*! Gets selected top-level items (i.e. not including sub-items) [ static ] */ @@ -157,12 +171,14 @@ void QAD_ObjectBrowser::setupListView() QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); this->setTabPosition( QTabWidget::Bottom ); - + /* Reading setting : Columns for Value, OCAF Doc entry, object IOR, OCAF Doc ref entry and Chrono sorting */ QString AddColumn = QAD_CONFIG->getSetting( "ObjectBrowser:AddColumn" ); QString ValueColumn = QAD_CONFIG->getSetting( "ObjectBrowser:ValueColumn" ); - QString ShowCHRONO_SORT = QAD_CONFIG->getSetting( "ObjectBrowser:CHRONO_SORT" ); - + QString ShowCHRONO_SORT = QAD_CONFIG->getSetting( "ObjectBrowser:ChronologicalSort" ); + QString showUseCase = QAD_CONFIG->getSetting("ObjectBrowser:ShowUseCaseBrowser"); + QString noAutoSizeColumns = QAD_CONFIG->getSetting( "ObjectBrowser:NoAutoSizeColumns" ); + /* create and setup Object Browser ================================= */ myListView = new QListView( this, "Object Browser"); myListView->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); @@ -176,7 +192,7 @@ void QAD_ObjectBrowser::setupListView() myListView->addColumn( tr( "OBJECT_BROWSER_IOR" ) ); /* Adding Object IOR column */ myListView->addColumn( tr( "OBJECT_BROWSER_REFENTRY" ) ); /* Adding OCAF Doc ref entry column */ myListView->header()->setMovingEnabled( false ); - + /* Properties */ myListView->header()->setClickEnabled( TRUE ); /* Enable clicking on the header */ myListView->setShowSortIndicator( TRUE ) ; /* Add user arrows to indicate the sort order : LPN */ @@ -185,6 +201,7 @@ void QAD_ObjectBrowser::setupListView() myListView->setVScrollBarMode( QScrollView::AlwaysOn ); /* Set scrollbars always visible */ myListView->setHScrollBarMode( QScrollView::AlwaysOn ); /* ... */ + myListView->setCornerWidget( new Btn( this ) ); /* Connect section */ //VRV: porting on Qt 3.0.5 #if QT_VERSION < 0x030005 @@ -202,12 +219,12 @@ void QAD_ObjectBrowser::setupListView() this, SLOT( onExpanded( QListViewItem* ) ) ); connect( myListView, SIGNAL( collapsed( QListViewItem* ) ), this, SLOT( onCollapsed( QListViewItem* ) ) ); - + /* create and setup UseCase Browser ================================ */ - QWidget* vBox = new QWidget( this ); - QVBoxLayout* vBoxLayout = new QVBoxLayout( vBox ); + myVBox = new QWidget( this ); + QVBoxLayout* vBoxLayout = new QVBoxLayout( myVBox ); - myUseCaseView = new QListView( vBox, "UseCase Browser"); + myUseCaseView = new QListView( myVBox, "UseCase Browser"); myUseCaseView->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); myUseCaseView->setMinimumSize( 1, 1 ); myUseCaseView->setPalette( QAD_Application::getPalette( true ) ); @@ -228,23 +245,25 @@ void QAD_ObjectBrowser::setupListView() myUseCaseView->setSorting( -1 ) ; vBoxLayout->addWidget( myUseCaseView ); - myNewBtn = new QToolButton( vBox ); + myUseCaseView->setCornerWidget( new Btn( this ) ); + + myNewBtn = new QToolButton( myVBox ); myNewBtn->setIconSet( resMgr->loadPixmap( "QAD", tr("ICON_UC_NEW") ) ); myNewBtn->setAutoRaise( true ); QToolTip::add( myNewBtn, tr( "UC_NEW_ID" ), QAD_Application::getDesktop()->toolTipGroup(), tr( "UC_NEW_TIP" ) ); - myAddBtn = new QToolButton( vBox ); + myAddBtn = new QToolButton( myVBox ); myAddBtn->setIconSet( resMgr->loadPixmap( "QAD", tr("ICON_UC_ADD") ) ); myAddBtn->setAutoRaise( true ); QToolTip::add( myAddBtn, tr( "UC_APPEND_ID" ), QAD_Application::getDesktop()->toolTipGroup(), tr( "UC_APPEND_TIP" ) ); - myDelBtn = new QToolButton( vBox ); + myDelBtn = new QToolButton( myVBox ); myDelBtn->setIconSet( resMgr->loadPixmap( "QAD", tr("ICON_UC_REMOVE") ) ); myDelBtn->setAutoRaise( true ); QToolTip::add( myDelBtn, tr( "UC_REMOVE_ID" ), QAD_Application::getDesktop()->toolTipGroup(), tr( "UC_REMOVE_TIP" ) ); - myClearBtn = new QToolButton( vBox ); + myClearBtn = new QToolButton( myVBox ); myClearBtn->setIconSet( resMgr->loadPixmap( "QAD", tr("ICON_UC_CLEAR") ) ); myClearBtn->setAutoRaise( true ); QToolTip::add( myClearBtn, tr( "UC_CLEAR_ID" ), QAD_Application::getDesktop()->toolTipGroup(), tr( "UC_CLEAR_TIP" ) ); - myCurrentBtn = new QToolButton( vBox ); + myCurrentBtn = new QToolButton( myVBox ); myCurrentBtn->setIconSet( resMgr->loadPixmap( "QAD", tr("ICON_UC_SET_CURRENT") ) ); myCurrentBtn->setAutoRaise( true ); QToolTip::add( myCurrentBtn, tr( "UC_SET_CURRENT_ID" ), QAD_Application::getDesktop()->toolTipGroup(), tr( "UC_SET_CURRENT_TIP" ) ); @@ -289,12 +308,21 @@ void QAD_ObjectBrowser::setupListView() /* add Object Browser and UseCase Browser as pages ================= */ this->addTab( myListView, tr( "TLT_OBJECT_BROWSER" ) ); - this->addTab( vBox, tr( "TLT_USECASE_BROWSER" ) ); - + this->addTab( myVBox, tr( "TLT_USECASE_BROWSER" ) ); + + if ( showUseCase != "true") + this->removePage(myVBox); + setShowInfoColumns( AddColumn == "true" ); setShowValueColumn( ValueColumn == "true" ); setEnableChronoSort( ShowCHRONO_SORT == "true" ); + if ( noAutoSizeColumns == "true" ) + { + for (int i = 0; i < myListView->header()->count(); i++ ) + myListView->setColumnWidthMode(i, QListView::Manual); + } + resize( QSize( 100, 400 ) ); } @@ -306,11 +334,12 @@ bool QAD_ObjectBrowser::eventFilter( QObject* o, QEvent* e ) { QAD_Desktop* Desktop = (QAD_Desktop*) QAD_Application::getDesktop(); QAD_Study* myActiveStudy = Desktop->getActiveStudy(); + if ( myStudy->_is_nil() ) return QTabWidget::eventFilter( o, e ); SALOMEDS::UseCaseBuilder_var UCBuilder = myStudy->GetUseCaseBuilder(); - if ( o == myUseCaseView->viewport() ) { + if (o == myUseCaseView->viewport()) { if ( e->type() == QEvent::MouseButtonPress ) { // Test if clicked on selection and start drag if necessary QMouseEvent* me = ( QMouseEvent* )e; @@ -688,8 +717,8 @@ void QAD_ObjectBrowser::Update( SALOMEDS::SObject_ptr SO, QString msg; QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); if ( resMgr ) { - if(resMgr->loadResources( QAD_Application::getDesktop()->getComponentName(QString(aFatherName->Value())), msg )) { - QPixmap icon ( resMgr->loadPixmap( QAD_Application::getDesktop()->getComponentName(QString(aFatherName->Value())), + if(resMgr->loadResources( QString(aFatherName->Value()) + "GUI", msg )) { + QPixmap icon ( resMgr->loadPixmap( QString(aFatherName->Value()) + "GUI", tr(aPixmap->GetPixMap()) /*tr( "ICON_OBJBROWSER_" + theComponent )*/ )); Item->setPixmap( 0, icon ); } @@ -712,9 +741,10 @@ void QAD_ObjectBrowser::Update( SALOMEDS::SObject_ptr SO, */ void QAD_ObjectBrowser::Update() { - int x = myListView->contentsX(); - int y = myListView->contentsY(); - + int xc = myListView->contentsX(); + int yc = myListView->contentsY(); + myListView->viewport()->setUpdatesEnabled( false ); + myListView->clear(); myListViewMap.clear(); @@ -845,11 +875,14 @@ void QAD_ObjectBrowser::Update() Update (SC, Item); } } - /* Updating UseCase Browser ============================================= */ - UpdateUseCaseBrowser(); + myListView->setContentsPos(xc,yc); - myListView->setContentsPos(x,y); -} + myListView->viewport()->setUpdatesEnabled( true ); + myListView->viewport()->repaint( false ); + /* Updating UseCase Browser ============================================= */ + if ( this->count() > 1 ) + UpdateUseCaseBrowser(); +} /*! Removes item with all childs from the map - used to optimize UseCase browser update @@ -876,7 +909,7 @@ void removeFromMap( ItemMap& theMap, QAD_ObjectBrowserItem* item ) */ void QAD_ObjectBrowser::UpdateUseCaseBrowser() { // myUseCaseView->clear(); myUseCaseMap.clear(); - if ( myStudy->_is_nil() ) { + if ( myStudy->_is_nil() || this->count()<2 ) { return; } myUseCaseView->blockSignals( true ); @@ -936,7 +969,7 @@ void QAD_ObjectBrowser::UpdateUseCaseBrowser() { */ void QAD_ObjectBrowser::UpdateUCItem( SALOMEDS::SObject_var UCObject, QAD_ObjectBrowserItem* UCItem ) { - if ( myStudy->_is_nil() || !UCItem ) + if ( myStudy->_is_nil() || !UCItem ) return; /* Creating SObjects item */ @@ -1103,7 +1136,7 @@ void QAD_ObjectBrowser::UpdateUCItem( SALOMEDS::SObject_var UCObject, QAD_Object void QAD_ObjectBrowser::unHighlightAll() { myListView->clearSelection(); - myUseCaseView->clearSelection(); + myUseCaseView->clearSelection(); } /*! @@ -1283,6 +1316,9 @@ void QAD_ObjectBrowser::showUseCasePopupMenu(QListViewItem* theItem) */ void QAD_ObjectBrowser::onSelectedItem() { + if (currentPage()==myListView) + myUseCaseView->clearSelection(); + QListView* whoIs; if ( sender()->inherits("QListView") ) whoIs = (QListView*)sender(); @@ -1489,6 +1525,7 @@ void QAD_ObjectBrowser::setShowIAPP( bool show ) void QAD_ObjectBrowser::setShowInfoColumns( bool show ) { bool shown = myListView->header()->isResizeEnabled( 2 ); + if ( show != shown ) { if ( show ) { myListView->header()->setResizeEnabled( true, 2 ); @@ -1524,6 +1561,7 @@ void QAD_ObjectBrowser::setShowInfoColumns( bool show ) void QAD_ObjectBrowser::setShowValueColumn( bool show ) { bool shown = myListView->header()->isResizeEnabled( 1 ); + if ( show != shown ) { if ( show ) { myListView->header()->setResizeEnabled( true, 1 ); @@ -1809,3 +1847,43 @@ void QAD_ObjectBrowser::onUseCaseBtn() if ( sender() == myCurrentBtn ) onUseCasePopupMenu( UC_SET_CURRENT_ID ); } + +/* + Show/remove UseCase Browser +*/ + +void QAD_ObjectBrowser::showUseCaseBrowser ( bool show ) +{ + bool shown = (this->count() > 1); + + if (show != shown) + { + if (show) + { + this->addTab( myVBox, tr( "TLT_USECASE_BROWSER" ) ); + UpdateUseCaseBrowser(); + unHighlightAll(); + } + else + this->removePage(myVBox); + } +} + +/*! + Switch between auto resizing of columns and manual mode +*/ +void QAD_ObjectBrowser::autoSizeColumns( bool autosize ) +{ + if (autosize) + { + for (int i = 0; i < myListView->header()->count(); i++ ) + if (myListView->header()->isResizeEnabled(i)) + myListView->setColumnWidthMode(i, QListView::Maximum); + + } + else + { + for (int i = 0; i < myListView->header()->count(); i++ ) + myListView->setColumnWidthMode(i, QListView::Manual); + } +} diff --git a/src/SALOMEGUI/QAD_ObjectBrowser.h b/src/SALOMEGUI/QAD_ObjectBrowser.h index a03afac0a..ef5f94099 100644 --- a/src/SALOMEGUI/QAD_ObjectBrowser.h +++ b/src/SALOMEGUI/QAD_ObjectBrowser.h @@ -89,6 +89,8 @@ public: void setShowInfoColumns( bool show ); void setShowValueColumn( bool show ); void setEnableChronoSort( bool enable ); + void showUseCaseBrowser ( bool show ); + void autoSizeColumns ( bool autosize ); protected: void Update( SALOMEDS::SObject_ptr SO, @@ -132,6 +134,7 @@ private: ItemMap myListViewMap; ItemMap myUseCaseMap; QListView* myListView; + QWidget* myVBox; QListView* myUseCaseView; QPopupMenu* myPopupMenu; SALOMEDS::Study_ptr myStudy; @@ -143,4 +146,14 @@ private: QToolButton* myClearBtn; }; + +class Btn : public QToolButton +{ + Q_OBJECT +public: + Btn ( QWidget * parent, const char * name = 0 ); +public slots: + void onClicked(); +}; + #endif diff --git a/src/SALOMEGUI/QAD_Study.cxx b/src/SALOMEGUI/QAD_Study.cxx index eb686a5e0..f35e5bf73 100644 --- a/src/SALOMEGUI/QAD_Study.cxx +++ b/src/SALOMEGUI/QAD_Study.cxx @@ -61,7 +61,6 @@ using namespace std; // QT Include #include -#define MAX_UNDO 10 /*! Constructor */ @@ -76,7 +75,7 @@ myPath( path ) { myStudy = aStudy; - myTitle = QAD_Tools::getFileNameFromPath( path, false ); + myTitle = QAD_Tools::getFileNameFromPath( path, true ); myIsActive = false; myIsSaved = false; @@ -105,7 +104,12 @@ myPath( path ) /* set default Undo/Redo limit */ QAD_ASSERT_DEBUG_ONLY( !myStudy->_is_nil() ); SALOMEDS::StudyBuilder_var SB = myStudy->NewBuilder(); - SB->UndoLimit( MAX_UNDO ); + + int aLocked = myStudy->GetProperties()->IsLocked(); + if (aLocked) myStudy->GetProperties()->SetLocked(false); + SB->UndoLimit(QAD_Desktop::getUndoLevel()); + if (aLocked) myStudy->GetProperties()->SetLocked(true); + } /*! @@ -170,7 +174,10 @@ void QAD_Study::removeStudyFrame( QAD_StudyFrame* sf ) SALOMEDS::SObject_var fatherSF = myStudy->FindObjectID(sf->entry()); if (!fatherSF->_is_nil()) { SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + int aLocked = myStudy->GetProperties()->IsLocked(); + if (aLocked) myStudy->GetProperties()->SetLocked(false); aStudyBuilder->RemoveObject(fatherSF); + if (aLocked) myStudy->GetProperties()->SetLocked(true); } updateObjBrowser( true ); @@ -275,7 +282,7 @@ void QAD_Study::setTitle( const QString& path ) { myPath = path; - QString title = QAD_Tools::getFileNameFromPath( path, false ); + QString title = QAD_Tools::getFileNameFromPath( path, true ); QAD_ASSERT_DEBUG_ONLY ( !title.isNull() ); for ( QAD_StudyFrame* sf = myStudyFrames.first(); sf ; sf = myStudyFrames.next() ) @@ -381,6 +388,7 @@ void QAD_Study::onStudyDeactivated() */ void QAD_Study::close() { + emit closed(); if ( !myStudy->_is_nil() ) abortAllOperations(); /* clear each study frame */ diff --git a/src/SALOMEGUI/QAD_Study.h b/src/SALOMEGUI/QAD_Study.h index 2d650058d..94fe80305 100644 --- a/src/SALOMEGUI/QAD_Study.h +++ b/src/SALOMEGUI/QAD_Study.h @@ -154,6 +154,7 @@ public: signals: void docClosing( QAD_Study* ); void docOperationTerminated( bool ); + void closed(); public slots: void onStudyFrameActivated( QAD_StudyFrame* ); diff --git a/src/SALOMEGUI/QAD_StudyFrame.cxx b/src/SALOMEGUI/QAD_StudyFrame.cxx index 194aaa516..29bde65b1 100644 --- a/src/SALOMEGUI/QAD_StudyFrame.cxx +++ b/src/SALOMEGUI/QAD_StudyFrame.cxx @@ -124,7 +124,6 @@ void QAD_StudyFrame::setVisible( bool visible ) */ void QAD_StudyFrame::closeEvent(QCloseEvent* e) { - emit sfBeforeStudyFrameClosing(this); emit sfStudyFrameClosing(this); } diff --git a/src/SALOMEGUI/QAD_StudyFrame.h b/src/SALOMEGUI/QAD_StudyFrame.h index b16822dac..e8b393b44 100644 --- a/src/SALOMEGUI/QAD_StudyFrame.h +++ b/src/SALOMEGUI/QAD_StudyFrame.h @@ -87,7 +87,6 @@ class QAD_EXPORT QAD_StudyFrame: public QMainWindow signals: void sfStudyFrameActivated( QAD_StudyFrame* ); void sfStudyFrameClosing( QAD_StudyFrame*); - void sfBeforeStudyFrameClosing( QAD_StudyFrame*); public slots: void onStudyFrameActivated ( QWidget* ); diff --git a/src/SALOMEGUI/QAD_Tools.cxx b/src/SALOMEGUI/QAD_Tools.cxx index 0b9ab52d3..e2e85bf53 100644 --- a/src/SALOMEGUI/QAD_Tools.cxx +++ b/src/SALOMEGUI/QAD_Tools.cxx @@ -276,7 +276,7 @@ TCollection_AsciiString QAD_Tools::toAsciiString( const QString& qString) QFont QAD_Tools::stringToFont( const QString& fontDescription ) { QFont font; - if ( !font.fromString( fontDescription ) ) + if ( fontDescription.stripWhiteSpace().isEmpty() || !font.fromString( fontDescription ) ) font = QFont( "Courier", 11 ); return font; } diff --git a/src/SALOMEGUI/QAD_ViewFrame.h b/src/SALOMEGUI/QAD_ViewFrame.h index 04a78ddcd..b894bb703 100644 --- a/src/SALOMEGUI/QAD_ViewFrame.h +++ b/src/SALOMEGUI/QAD_ViewFrame.h @@ -58,8 +58,8 @@ public: virtual QColor backgroundColor() const = 0; virtual void SetSelectionMode( int mode ) = 0; - - virtual void SetTrihedronSize( int dim ) = 0; + + virtual void onAdjustTrihedron() = 0; /* popup management */ virtual void setPopupServer( QAD_Application* ) = 0; diff --git a/src/SALOMEGUI/QAD_icons.po b/src/SALOMEGUI/QAD_icons.po index f30ce6918..5b1e636f7 100644 --- a/src/SALOMEGUI/QAD_icons.po +++ b/src/SALOMEGUI/QAD_icons.po @@ -68,6 +68,15 @@ msgstr "close.png" msgid "ICON_HELP" msgstr "help.png" +msgid "QAD_HelpWindow::ICON_APP_HELP_BACK" +msgstr "back.xpm" + +msgid "QAD_HelpWindow::ICON_APP_HELP_FORWARD" +msgstr "forward.xpm" + +msgid "QAD_HelpWindow::ICON_APP_HELP_HOME" +msgstr "home.xpm" + #-------------- # VIEW #-------------- diff --git a/src/SALOMEGUI/QAD_msg_en.po b/src/SALOMEGUI/QAD_msg_en.po index 39dededad..e845d78e4 100644 --- a/src/SALOMEGUI/QAD_msg_en.po +++ b/src/SALOMEGUI/QAD_msg_en.po @@ -259,6 +259,12 @@ msgstr "Interface Applicative" msgid "MEN_DESK_PREF_OBJECTBROWSER_CHRONO_SORT" msgstr "Chronological sort of objects" +msgid "MEN_DESK_PREF_OBJECTBROWSER_SHOW_USECASE" +msgstr "Show UseCase Browser" + +msgid "MEN_DESK_PREF_OBJECTBROWSER_NO_AUTOSIZE" +msgstr "No autosize columns" + msgid "QAD_Desktop::MEN_DESK_SELECTION_MODE" msgstr "Selection Mode" @@ -435,6 +441,21 @@ msgstr "Sketch a rectangular area to fit the view" # TOOL TIP #--------------- +#: QAD_HelpWindow.cxx:57 +msgid "QAD_HelpWindow::TOT_HELPWINDOW_BACKWARD" +msgstr "Backward" + +#: QAD_HelpWindow.cxx:60 +msgid "QAD_HelpWindow::TOT_HELPWINDOW_FORWARD" +msgstr "Forward" + +#: QAD_HelpWindow.cxx:63 +msgid "QAD_HelpWindow::TOT_HELPWINDOW_HOME" +msgstr "Home" + +msgid "QAD_HelpWindow::QAD_HELP_CONTENTS" +msgstr "Contents" + #: QAD_Application.cxx:173 msgid "QAD_Application::TOT_APP_EDIT_REDO" msgstr "Redo last operation" @@ -752,6 +773,9 @@ msgstr "ASCII Save" msgid "TOT_APP_EDIT_COPY" msgstr "Copy" +msgid "MEN_DESK_PREF_UNDO_LEVEL" +msgstr "Undo Level" + msgid "MEN_APP_EDIT_COPY" msgstr "&Copy" diff --git a/src/SALOMEGUI/SALOMEGUI_Application.cxx b/src/SALOMEGUI/SALOMEGUI_Application.cxx index d9b5ad9b1..fa67befd6 100644 --- a/src/SALOMEGUI/SALOMEGUI_Application.cxx +++ b/src/SALOMEGUI/SALOMEGUI_Application.cxx @@ -615,7 +615,7 @@ void SALOMEGUI_Application::onDisplay(int id) viewFrame->Repaint(); if (isForeignGUIUsed) - foreignGUI.DlClose(); + ;//foreignGUI.DlClose(); // VSR: Fix crash on Display objects from non-parent components myActiveStudy->updateObjBrowser(true); } diff --git a/src/SALOMEGUI/SALOMEGUI_SetValueDlg.cxx b/src/SALOMEGUI/SALOMEGUI_SetValueDlg.cxx index 2573f3ff9..3a8eb70f2 100644 --- a/src/SALOMEGUI/SALOMEGUI_SetValueDlg.cxx +++ b/src/SALOMEGUI/SALOMEGUI_SetValueDlg.cxx @@ -119,6 +119,21 @@ void SALOMEGUI_SetValueDlg::setLabel( const QString& label ) myLabel->setText( label ); } +void SALOMEGUI_SetValueDlg::accept() +{ + const QValidator* v = myLineEdit->validator(); + if ( v ) { + if ( v->inherits( "QIntValidator" ) ) { + bool b; + int val = myLineEdit->text().toInt( &b ); + const QIntValidator* iv = dynamic_cast(v); + if ( !b || val < iv->bottom() || val > iv->top()) + return; + } + } + QDialog::accept(); +} + /*! Gets string value */ @@ -167,6 +182,32 @@ int SALOMEGUI_SetValueDlg::getInteger( const QString& caption, return v; } +/*! + Gets integer value +*/ +int SALOMEGUI_SetValueDlg::getInteger( const QString& caption, + const QString& label, + int bottom, + int top, + const int oldValue, + bool* ok, + QWidget* parent ) +{ + int v = 0; + SALOMEGUI_SetValueDlg* dlg = new SALOMEGUI_SetValueDlg( parent ); + dlg->setCaption( caption ); + dlg->setLabel( label ); + dlg->setValidator( new QIntValidator( bottom, top, dlg ) ); + dlg->setValue( QString::number( oldValue ) ); + int result = dlg->exec(); + if ( result == QDialog::Accepted ) + v = dlg->value().toInt(); + if ( ok ) + *ok = result == QDialog::Accepted; + delete dlg; + return v; +} + /*! Gets double value */ diff --git a/src/SALOMEGUI/SALOMEGUI_SetValueDlg.h b/src/SALOMEGUI/SALOMEGUI_SetValueDlg.h index bcd845838..3b5bd02b9 100644 --- a/src/SALOMEGUI/SALOMEGUI_SetValueDlg.h +++ b/src/SALOMEGUI/SALOMEGUI_SetValueDlg.h @@ -36,11 +36,20 @@ public: const int oldValue = 0, bool* ok = 0, QWidget* parent = 0 ); + static int getInteger( const QString& caption, + const QString& label, + int bottom, + int top, + const int oldValue = 0, + bool* ok = 0, + QWidget* parent = 0 ); static double getDouble ( const QString& caption, const QString& label, const double oldValue = 0.0, bool* ok = 0, QWidget* parent = 0 ); +public slots: + void accept(); private: SALOMEGUI_SetValueDlg( QWidget* parent = 0 ); diff --git a/src/SALOMEGUI/SALOMEGUI_msg_en.po b/src/SALOMEGUI/SALOMEGUI_msg_en.po index af0785398..311b6075f 100644 --- a/src/SALOMEGUI/SALOMEGUI_msg_en.po +++ b/src/SALOMEGUI/SALOMEGUI_msg_en.po @@ -67,7 +67,7 @@ msgstr "Appropriate view must be created to display selected object(s)" #: SALOMEGUI_TrihedronSizeDlg.cxx:77 msgid "SALOMEGUI_TrihedronSizeDlg::MEN_TRIHEDRON_SIZE" -msgstr "Size :" +msgstr "Size (% of bounding box) :" #: SALOMEGUI_TrihedronSizeDlg.cxx:36 msgid "SALOMEGUI_TrihedronSizeDlg::MEN_TRIHEDRON" diff --git a/src/SALOMEGUI/SALOMEGUI_msg_fr.po b/src/SALOMEGUI/SALOMEGUI_msg_fr.po index b595f87c2..6ffd95262 100644 --- a/src/SALOMEGUI/SALOMEGUI_msg_fr.po +++ b/src/SALOMEGUI/SALOMEGUI_msg_fr.po @@ -66,7 +66,7 @@ msgstr "La vue appropri #--------------- msgid "INF_VERSION" -msgstr "Version 1.1a" +msgstr "" msgid "INF_COPYRIGHT" msgstr "" @@ -81,7 +81,7 @@ msgstr "" #: SALOMEGUI_TrihedronSizeDlg.cxx:77 msgid "SALOMEGUI_TrihedronSizeDlg::MEN_TRIHEDRON_SIZE" -msgstr "Size :" +msgstr "Size (% of bounding box) :" #: SALOMEGUI_TrihedronSizeDlg.cxx:36 msgid "SALOMEGUI_TrihedronSizeDlg::MEN_TRIHEDRON" @@ -316,7 +316,7 @@ msgstr "VTK Viewer" #: SALOMEGUI_AboutDlg.cxx:42 msgid "ABOUT_SALOME_TLT" -msgstr "About SALOME " +msgstr "About SALOME Professional" msgid "SALOMEGUI_OpenWith::OPEN_WITH_TLT" msgstr "Open With" diff --git a/src/SALOME_PYQT/SalomePyQt.cxx b/src/SALOME_PYQT/SalomePyQt.cxx index 9f7c1afa2..11d2fe9ce 100644 --- a/src/SALOME_PYQT/SalomePyQt.cxx +++ b/src/SALOME_PYQT/SalomePyQt.cxx @@ -107,3 +107,7 @@ QString SalomePyQt::getExistingDirectory(QWidget* parent, { return QAD_FileDlg::getExistingDirectory(parent, initial, caption); } + +void SalomePyQt::helpContext(const QString& source, const QString& context) { + //QAD_Application::getDesktop()->helpContext(source, context); +} diff --git a/src/SALOME_PYQT/SalomePyQt.hxx b/src/SALOME_PYQT/SalomePyQt.hxx index c79a1d97e..b3f5101a6 100644 --- a/src/SALOME_PYQT/SalomePyQt.hxx +++ b/src/SALOME_PYQT/SalomePyQt.hxx @@ -44,6 +44,7 @@ public: static QString getExistingDirectory(QWidget* parent, const QString& initial, const QString& caption); + static void helpContext(const QString& source, const QString& context); }; #endif diff --git a/src/SALOME_PYQT/SalomePyQt.sip b/src/SALOME_PYQT/SalomePyQt.sip index 51ab6d772..3f593d0af 100644 --- a/src/SALOME_PYQT/SalomePyQt.sip +++ b/src/SALOME_PYQT/SalomePyQt.sip @@ -45,4 +45,5 @@ public: static QString getFileName(QWidget*, const QString&, const QStringList&, const QString&, bool); static QString getExistingDirectory(QWidget*, const QString&, const QString&); + static void helpContext(const QString&, const QString&); }; diff --git a/src/SALOME_SWIG/salome_test.py b/src/SALOME_SWIG/salome_test.py index 0ebc15156..31b7f308f 100644 --- a/src/SALOME_SWIG/salome_test.py +++ b/src/SALOME_SWIG/salome_test.py @@ -471,6 +471,13 @@ myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") try: if os.access(medFile, os.R_OK) : + if not os.access(medFile, os.W_OK) : + import random + medFileNew = "/tmp/" + str(random.randint(0,1000000)) + "_" + medfile + print " -- Copy " + medFile + " to " + medFileNew + os.system("cp "+ medFile + " " + medFileNew) + medFile = medFileNew + if os.access(medFile, os.W_OK) : med_comp.readStructFileWithFieldType(medFile,studyCurrent) med_obj = visu_gui.visu.getMedObjectFromStudy() diff --git a/src/SUPERVGraph/SUPERVGraph_ViewFrame.cxx b/src/SUPERVGraph/SUPERVGraph_ViewFrame.cxx index 2fa21f447..01fa60ce2 100644 --- a/src/SUPERVGraph/SUPERVGraph_ViewFrame.cxx +++ b/src/SUPERVGraph/SUPERVGraph_ViewFrame.cxx @@ -254,9 +254,9 @@ void SUPERVGraph_ViewFrame::SetSelectionMode( int mode ) MESSAGE ( "SUPERVGraph_ViewFrame::SetSelectionMode" ) } -void SUPERVGraph_ViewFrame::SetTrihedronSize( int dim ) +void SUPERVGraph_ViewFrame::onAdjustTrihedron( ) { - MESSAGE ( "SUPERVGraph_ViewFrame::SetTrihedronSize" ) + MESSAGE ( "SUPERVGraph_ViewFrame::onAdjustTrihedron" ) } void SUPERVGraph_ViewFrame::rename( const Handle(SALOME_InteractiveObject)& IObject, diff --git a/src/SUPERVGraph/SUPERVGraph_ViewFrame.h b/src/SUPERVGraph/SUPERVGraph_ViewFrame.h index 49c297a7a..8c62cc436 100644 --- a/src/SUPERVGraph/SUPERVGraph_ViewFrame.h +++ b/src/SUPERVGraph/SUPERVGraph_ViewFrame.h @@ -64,7 +64,7 @@ class QAD_EXPORT SUPERVGraph_ViewFrame : public QAD_ViewFrame { void SetSelectionMode( int mode ); - void SetTrihedronSize( int dim ); + void onAdjustTrihedron( ); /* popup management */ void setPopupServer( QAD_Application* ); diff --git a/src/Session/SALOME_Session_i.cxx b/src/Session/SALOME_Session_i.cxx index a55bf4d46..ba179e763 100644 --- a/src/Session/SALOME_Session_i.cxx +++ b/src/Session/SALOME_Session_i.cxx @@ -172,6 +172,7 @@ void SALOME_Session_i::StopSession() SALOME::StatSession SALOME_Session_i::GetStatSession() { // update Session state + //qApp->lock(); // rollback bug _GUIMutex.lock(); _isGUI = _IAPPThread->running(); _runningStudies = 0; @@ -182,6 +183,7 @@ SALOME::StatSession SALOME_Session_i::GetStatSession() qApp->unlock(); } _GUIMutex.unlock(); + //qApp->unlock(); // getting stat info SALOME::StatSession_var myStats = new SALOME::StatSession ; if (_runningStudies) diff --git a/src/Utils/Utils_SINGLETON.hxx b/src/Utils/Utils_SINGLETON.hxx index 3d2e58cd3..4e06560a0 100644 --- a/src/Utils/Utils_SINGLETON.hxx +++ b/src/Utils/Utils_SINGLETON.hxx @@ -107,7 +107,7 @@ template TYPE *SINGLETON_::Instance( void ) { if ( ! PtrSingleton ) { - MESSAGE("SINGLETON_::Instance( void )") ; + //MESSAGE("SINGLETON_::Instance( void )") ; PtrSingleton = new SINGLETON_ ; new DESTRUCTEUR_DE_( PtrSingleton->_Instance ) ; } @@ -125,7 +125,7 @@ template bool SINGLETON_::IsAlreadyExisting( void ) template SINGLETON_::SINGLETON_( void ) { - MESSAGE("CREATION d'un SINGLETON_") ; + //MESSAGE("CREATION d'un SINGLETON_") ; } diff --git a/src/VTKViewer/Makefile.in b/src/VTKViewer/Makefile.in index 3d562442d..0733c58b9 100644 --- a/src/VTKViewer/Makefile.in +++ b/src/VTKViewer/Makefile.in @@ -47,7 +47,9 @@ LIB_SRC= VTKViewer.cxx \ VTKViewer_RenderWindow.cxx \ VTKViewer_RenderWindowInteractor.cxx \ VTKViewer_InteractorStyleSALOME.cxx \ - VTKViewer_VectorText.cxx + VTKViewer_Trihedron.cxx \ + VTKViewer_VectorText.cxx \ + VTKViewer_Utilities.cxx LIB_MOC = \ VTKViewer.h \ diff --git a/src/VTKViewer/VTKViewer_InteractorStyleSALOME.cxx b/src/VTKViewer/VTKViewer_InteractorStyleSALOME.cxx index b0cfe0abb..329e055ac 100644 --- a/src/VTKViewer/VTKViewer_InteractorStyleSALOME.cxx +++ b/src/VTKViewer/VTKViewer_InteractorStyleSALOME.cxx @@ -26,11 +26,11 @@ // Module : SALOME // $Header$ -using namespace std; #include "VTKViewer_InteractorStyleSALOME.h" #include "VTKViewer_RenderWindow.h" +#include "VTKViewer_Utilities.h" +#include "VTKViewer_Trihedron.h" -#include #include "QAD_Config.h" #include "QAD_Application.h" #include "QAD_Desktop.h" @@ -54,31 +54,25 @@ using namespace std; #include #include - +#include //VRV: porting on Qt 3.0.5 #if QT_VERSION >= 0x030005 #include #endif //VRV: porting on Qt 3.0.5 -//---------------------------------------------------------------------------- -VTKViewer_InteractorStyleSALOME *VTKViewer_InteractorStyleSALOME::New() -{ - // First try to create the object from the vtkObjectFactory - vtkObject* ret = vtkObjectFactory::CreateInstance("VTKViewer_InteractorStyleSALOME"); - if(ret) - { - return (VTKViewer_InteractorStyleSALOME*)ret; - } - // If the factory was unable to create the object, then create it here. - return new VTKViewer_InteractorStyleSALOME; -} +using namespace std; +extern int SetVisibility(vtkActorCollection* theCollection, int theParam); +extern int GetVisibility(vtkActorCollection* theCollection); //---------------------------------------------------------------------------- +vtkStandardNewMacro(VTKViewer_InteractorStyleSALOME); +//---------------------------------------------------------------------------- + VTKViewer_InteractorStyleSALOME::VTKViewer_InteractorStyleSALOME() { - m_Triedron = 0; + m_Trihedron = 0; this->MotionFactor = 10.0; this->State = VTK_INTERACTOR_STYLE_CAMERA_NONE; this->RadianToDegree = 180.0 / vtkMath::Pi(); @@ -92,9 +86,8 @@ VTKViewer_InteractorStyleSALOME::~VTKViewer_InteractorStyleSALOME() } //---------------------------------------------------------------------------- -void VTKViewer_InteractorStyleSALOME::setTriedron( vtkActorCollection* triedron ) -{ - m_Triedron = triedron; +void VTKViewer_InteractorStyleSALOME::setTriedron(VTKViewer_Trihedron* theTrihedron){ + m_Trihedron = theTrihedron; } //---------------------------------------------------------------------------- @@ -120,15 +113,8 @@ void VTKViewer_InteractorStyleSALOME::RotateXY(int dx, int dy) cam->Azimuth(rxf); cam->Elevation(ryf); cam->OrthogonalizeViewUp(); - this->CurrentRenderer->ResetCameraClippingRange(); - vtkRenderWindowInteractor *rwi = this->Interactor; - /* VSV Light follows camera: if (this->CurrentLight) - { - // get the first light - this->CurrentLight->SetPosition(cam->GetPosition()); - this->CurrentLight->SetFocalPoint(cam->GetFocalPoint()); - } */ - rwi->Render(); + ::ResetCameraClippingRange(this->CurrentRenderer); + this->Interactor->Render(); } //---------------------------------------------------------------------------- @@ -148,98 +134,26 @@ void VTKViewer_InteractorStyleSALOME::PanXY(int x, int y, int oldX, int oldY) //---------------------------------------------------------------------------- void VTKViewer_InteractorStyleSALOME::ControlLblSize(double aOldScale, double aNewScale) { - m_Triedron->InitTraversal(); - vtkActor *ac = m_Triedron->GetNextActor(); - bool IsConeActor = true; - while(!(ac==NULL)) { - float aMaxXRange; - float aMaxYRange; - float aMaxZRange; - if(ac->IsA("vtkFollower")) { - float aScale[3]; - ac->GetScale(aScale); - - float aPosition[3]; - ac->GetPosition(aPosition); - - float aPercent = (aOldScale-aNewScale)/aOldScale; - ac->SetScale(aScale[0]*(1-aPercent),aScale[1]*(1-aPercent),aScale[2]*(1-aPercent)); - - //Set new position - float aLength = ac->GetLength(); - if (aPosition[0]!=0) { - //x - aPosition[0] = aMaxXRange; - } else if (aPosition[1]!=0) { - //y - aPosition[1] = aMaxYRange; - } else if (aPosition[2]!=0) { - //z - aPosition[2] = aMaxZRange; - } - ac->SetPosition(aPosition); - - IsConeActor = true; - } - else { - if (IsConeActor) { - //coneActor is the first in the list (see m_Triedron->AddItem(...) in VTKViewer_ViewFrame::AddVector(...)) - IsConeActor = false; - - float aPosition[3]; - ac->GetPosition(aPosition); - - if (aPosition[0]!=0) { - //x - float* aXRange = ac->GetXRange(); - if (aXRange[0] < aXRange[1]) aMaxXRange = aXRange[1]; - else aMaxXRange = aXRange[0]; - } else if (aPosition[1]!=0) { - //y - float* aYRange = ac->GetYRange(); - if (aYRange[0] < aYRange[1]) aMaxYRange = aYRange[1]; - else aMaxYRange = aYRange[0]; - } else if (aPosition[2]!=0) { - //z - float* aZRange = ac->GetZRange(); - if (aZRange[0] < aZRange[1]) aMaxZRange = aZRange[1]; - else aMaxZRange = aZRange[0]; - } - } - } - ac = m_Triedron->GetNextActor(); - } + return; } //---------------------------------------------------------------------------- void VTKViewer_InteractorStyleSALOME::DollyXY(int dx, int dy) { - vtkCamera *cam; + if (this->CurrentRenderer == NULL) return; + double dxf = this->MotionFactor * (double)(dx) / (double)(this->CurrentRenderer->GetCenter()[1]); double dyf = this->MotionFactor * (double)(dy) / (double)(this->CurrentRenderer->GetCenter()[1]); double zoomFactor = pow((double)1.1, dxf + dyf); - if (this->CurrentRenderer == NULL) - { - return; - } - - cam = this->CurrentRenderer->GetActiveCamera(); - if (cam->GetParallelProjection()) - { - double aOldScale = cam->GetParallelScale(); - cam->SetParallelScale(cam->GetParallelScale()/zoomFactor); - double aNewScale = cam->GetParallelScale(); - - // for controlling label size - ControlLblSize(aOldScale,aNewScale); - } - else - { - cam->Dolly(zoomFactor); - this->CurrentRenderer->ResetCameraClippingRange(); - } + vtkCamera *aCam = this->CurrentRenderer->GetActiveCamera(); + if (aCam->GetParallelProjection()) + aCam->SetParallelScale(aCam->GetParallelScale()/zoomFactor); + else{ + aCam->Dolly(zoomFactor); + ::ResetCameraClippingRange(this->CurrentRenderer); + } /* VSV Light follows camera: if (this->CurrentLight) { @@ -597,6 +511,27 @@ void VTKViewer_InteractorStyleSALOME::startFitArea() qApp->installEventFilter(this); } + +void VTKViewer_InteractorStyleSALOME::ViewFitAll() { + int aTriedronWasVisible = false; + if(m_Trihedron){ + aTriedronWasVisible = + m_Trihedron->GetVisibility() == VTKViewer_Trihedron::eOn; + if(aTriedronWasVisible) m_Trihedron->VisibilityOff(); + } + + if(m_Trihedron->GetVisibleActorCount(CurrentRenderer)){ + m_Trihedron->VisibilityOff(); + ::ResetCamera(CurrentRenderer); + }else{ + m_Trihedron->SetVisibility(VTKViewer_Trihedron::eOnlyLineOn); + ::ResetCamera(CurrentRenderer,true); + } + if(aTriedronWasVisible) m_Trihedron->VisibilityOn(); + else m_Trihedron->VisibilityOff(); +} + + // starts Global Panning operation (e.g. through menu command) void VTKViewer_InteractorStyleSALOME::startGlobalPan() { @@ -612,29 +547,21 @@ void VTKViewer_InteractorStyleSALOME::startGlobalPan() vtkCamera *cam = this->CurrentRenderer->GetActiveCamera(); myScale = cam->GetParallelScale(); + ViewFitAll(); // make fit all - Standard_Boolean TriedronWasVisible = false; - if ( m_Triedron ) { - m_Triedron->InitTraversal(); - vtkActor *ac = m_Triedron->GetNextActor(); - while(!(ac==NULL)) { - if(ac->GetVisibility()) { - TriedronWasVisible = true; - ac->VisibilityOff(); - } - ac = m_Triedron->GetNextActor(); - } - } - this->CurrentRenderer->ResetCamera(); - this->CurrentRenderer->ResetCameraClippingRange(); - if( m_Triedron && TriedronWasVisible ) { - m_Triedron->InitTraversal(); - vtkActor *ac = m_Triedron->GetNextActor(); - while(!(ac==NULL)) { - ac->VisibilityOn(); - ac = m_Triedron->GetNextActor(); - } - } +// int TriedronWasVisible = false; +// if(m_Trihedron){ +// TriedronWasVisible = +// m_Trihedron->GetVisibility() == VTKViewer_Trihedron::eOn; +// if(TriedronWasVisible) m_Trihedron->VisibilityOff(); +// } + +// ::ResetCamera(this->CurrentRenderer); + +// if(m_Trihedron) +// if(TriedronWasVisible) +// m_Trihedron->VisibilityOn(); + //VTKViewer_RenderWindow* aRW = dynamic_cast(this->Interactor->GetRenderWindow()); if (myGUIWindow) myGUIWindow->update(); @@ -657,10 +584,7 @@ void VTKViewer_InteractorStyleSALOME::fitRect(const int left, const int right, const int bottom) { - if (this->CurrentRenderer == NULL) { - return; - } - vtkCamera *cam = this->CurrentRenderer->GetActiveCamera(); + if (this->CurrentRenderer == NULL) return; // move camera int x = (left + right)/2; @@ -670,17 +594,17 @@ void VTKViewer_InteractorStyleSALOME::fitRect(const int left, int oldY = aSize[1]/2; TranslateView(oldX, oldY, x, y); - // zoom camera double dxf = (double)(aSize[0]) / (double)(abs(right - left)); double dyf = (double)(aSize[1]) / (double)(abs(bottom - top)); double zoomFactor = (dxf + dyf)/2 ; - if (cam->GetParallelProjection()) { - cam->SetParallelScale(cam->GetParallelScale()/zoomFactor); - } else { - cam->Dolly(zoomFactor); - this->CurrentRenderer->ResetCameraClippingRange(); + vtkCamera *aCam = this->CurrentRenderer->GetActiveCamera(); + if(aCam->GetParallelProjection()) + aCam->SetParallelScale(aCam->GetParallelScale()/zoomFactor); + else{ + aCam->Dolly(zoomFactor); + ::ResetCameraClippingRange(this->CurrentRenderer); } //vtkRenderWindowInteractor *rwi = this->Interactor; @@ -765,6 +689,8 @@ void VTKViewer_InteractorStyleSALOME::setCursor(const int operation) void VTKViewer_InteractorStyleSALOME::onStartOperation() { if (!myGUIWindow) return; + // VSV: LOD actor activisation + // this->Interactor->GetRenderWindow()->SetDesiredUpdateRate(this->Interactor->GetDesiredUpdateRate()); switch (State) { case VTK_INTERACTOR_STYLE_CAMERA_SELECT: case VTK_INTERACTOR_STYLE_CAMERA_FIT: @@ -789,14 +715,16 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() { if (!myGUIWindow) return; + QAD_Study* aActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); SALOME_Selection* aSel = SALOME_Selection::Selection( aActiveStudy->getSelection() ); vtkRenderWindowInteractor *rwi = this->Interactor; + // VSV: LOD actor activisation + // rwi->GetRenderWindow()->SetDesiredUpdateRate(rwi->GetStillUpdateRate()); + int aSelectionMode = aSel->SelectionMode(); bool aSelActiveCompOnly = aSel->IsSelectActiveCompOnly(); - SALOMEDS::SComponent_var aActiveComponent = SALOMEDS::SComponent::_narrow( - aActiveStudy->getStudyDocument()->FindObject(QAD_Application::getDesktop()->getActiveComponent())); switch (State) { case VTK_INTERACTOR_STYLE_CAMERA_SELECT: @@ -829,6 +757,11 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() vtkActorCollection* listactors = NULL; this->FindPokedRenderer(x, y); rwi->StartPickCallback(); + +// vtkPicker* aPicker = vtkPicker::SafeDownCast(rwi->GetPicker()); +// if (aPicker) +// aPicker->SetTolerance(0.01); + rwi->GetPicker()->Pick(x, y, 0.0, this->CurrentRenderer); if ( rwi->GetPicker()->IsA("vtkCellPicker") ) { @@ -1020,6 +953,10 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() } } else { //processing rectangle selection + SALOMEDS::SComponent_var aActiveComponent = SALOMEDS::SComponent:: + _narrow(aActiveStudy->getStudyDocument()-> + FindObject(QAD_Application::getDesktop()->getActiveComponent())); + if(aSelActiveCompOnly && aActiveComponent->_is_nil()) return; rwi->StartPickCallback(); if (!myShiftState) { @@ -1117,9 +1054,10 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() if(SActor->hasIO()) { Handle(SALOME_InteractiveObject) IO = SActor->getIO(); if(IO.IsNull()) continue; - if(aSelActiveCompOnly) + if(aSelActiveCompOnly) { if(strcmp(aActiveComponent->ComponentDataType(),IO->getComponentDataType()) != 0) continue; + } if(vtkDataSet* aDataSet = SActor->GetMapper()->GetInput()){ for(int i = 0, iEnd = aDataSet->GetNumberOfCells(); i < iEnd; i++){ if(vtkCell* aCell = aDataSet->GetCell(i)){ @@ -1218,6 +1156,8 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() } break; } + if (myGUIWindow) myGUIWindow->update(); + } // called during viewer operation when user moves mouse (!put necessary processing here!) @@ -1382,7 +1322,7 @@ void VTKViewer_InteractorStyleSALOME::Place(const int theX, const int theY) // restore zoom scale vtkCamera *cam = this->CurrentRenderer->GetActiveCamera(); cam->SetParallelScale(myScale); - this->CurrentRenderer->ResetCameraClippingRange(); + ::ResetCameraClippingRange(this->CurrentRenderer); /* VSV Light follows camera: if (this->CurrentLight) { this->CurrentLight->SetPosition(cam->GetPosition()); diff --git a/src/VTKViewer/VTKViewer_InteractorStyleSALOME.h b/src/VTKViewer/VTKViewer_InteractorStyleSALOME.h index a8a9aa206..62438e91e 100644 --- a/src/VTKViewer/VTKViewer_InteractorStyleSALOME.h +++ b/src/VTKViewer/VTKViewer_InteractorStyleSALOME.h @@ -34,6 +34,7 @@ #include #include "SALOME_Actor.h" +class VTKViewer_Trihedron; #define VTK_INTERACTOR_STYLE_CAMERA_NONE 0 #define VTK_INTERACTOR_STYLE_CAMERA_ROTATE 1 @@ -53,7 +54,7 @@ class VTKViewer_InteractorStyleSALOME : public QObject, public vtkInteractorStyl // programmers. static VTKViewer_InteractorStyleSALOME *New(); - void setTriedron( vtkActorCollection* triedron ); + void setTriedron(VTKViewer_Trihedron* theTrihedron); vtkTypeMacro(VTKViewer_InteractorStyleSALOME, vtkObject); void PrintSelf(ostream& os, vtkIndent indent); @@ -67,6 +68,8 @@ class VTKViewer_InteractorStyleSALOME : public QObject, public vtkInteractorStyl void OnRightButtonDown(int ctrl, int shift, int x, int y); void OnRightButtonUp (int ctrl, int shift, int x, int y); + void ViewFitAll(); + protected: VTKViewer_InteractorStyleSALOME(); ~VTKViewer_InteractorStyleSALOME(); @@ -132,7 +135,7 @@ protected: bool myCursorState; bool myShiftState; int ForcedState; - vtkActorCollection* m_Triedron; + VTKViewer_Trihedron* m_Trihedron; QWidget* myGUIWindow; diff --git a/src/VTKViewer/VTKViewer_RenderWindow.cxx b/src/VTKViewer/VTKViewer_RenderWindow.cxx index 6072e344b..7712ec01e 100644 --- a/src/VTKViewer/VTKViewer_RenderWindow.cxx +++ b/src/VTKViewer/VTKViewer_RenderWindow.cxx @@ -45,6 +45,7 @@ using namespace std; #include #include #include +#include //#include //#include @@ -64,6 +65,7 @@ VTKViewer_RenderWindow::VTKViewer_RenderWindow(QWidget *parent, const char *name myRW->SetDisplayId((void*)x11Display()); myRW->SetWindowId((void*)winId()); myRW->DoubleBufferOn(); + setMouseTracking(true); } VTKViewer_RenderWindow::~VTKViewer_RenderWindow() { @@ -76,10 +78,23 @@ void VTKViewer_RenderWindow::paintEvent(QPaintEvent* theEvent) { } void VTKViewer_RenderWindow::resizeEvent(QResizeEvent* theEvent) { - vtkRenderWindowInteractor* aRWI = myRW->GetInteractor(); - if (aRWI != NULL) - aRWI->SetSize(width(), height()); - myRW->SetSize(width(), height()); + int aWidth = myRW->GetSize()[0], aHeight = myRW->GetSize()[1]; + if(vtkRenderWindowInteractor* aRWI = myRW->GetInteractor()) + aRWI->UpdateSize(width(), height()); + if(aWidth != width() || aHeight != height()){ + vtkRendererCollection * aRenderers = myRW->GetRenderers(); + aRenderers->InitTraversal(); + double aCoeff = 1.0; + if(vtkRenderer *aRenderer = aRenderers->GetNextItem()){ + vtkCamera *aCamera = aRenderer->GetActiveCamera(); + double aScale = aCamera->GetParallelScale(); + if((aWidth - width())*(aHeight - height()) > 0) + aCoeff = sqrt(double(aWidth)/double(width())*double(height())/double(aHeight)); + else + aCoeff = double(aWidth)/double(width()); + aCamera->SetParallelScale(aScale*aCoeff); + } + } } diff --git a/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx b/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx index 4099a3fcd..2e4ce4b96 100644 --- a/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx +++ b/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx @@ -26,7 +26,6 @@ // Module : SALOME // $Header$ -using namespace std; #include "VTKViewer_RenderWindowInteractor.h" #include "VTKViewer_RenderWindow.h" #include "VTKViewer_InteractorStyleSALOME.h" @@ -59,10 +58,11 @@ using namespace std; #include #include - // QT Includes #include +using namespace std; + VTKViewer_RenderWindowInteractor* VTKViewer_RenderWindowInteractor::New() { vtkObject *ret = vtkObjectFactory::CreateInstance("VTKViewer_RenderWindowInteractor") ; if( ret ) { @@ -168,6 +168,13 @@ void VTKViewer_RenderWindowInteractor::Initialize() { return ; } + +void VTKViewer_RenderWindowInteractor::SetInteractorStyle(vtkInteractorObserver *theInteractor){ + myInteractorStyle = dynamic_cast(theInteractor); + vtkRenderWindowInteractor::SetInteractorStyle(theInteractor); +} + + void VTKViewer_RenderWindowInteractor::SetSelectionMode(int mode) { Cell_Actor->VisibilityOff(); @@ -759,55 +766,38 @@ bool VTKViewer_RenderWindowInteractor::highlight( const Handle(SALOME_Interactiv bool hilight, bool update) { - VTKViewer_InteractorStyleSALOME* aStyle = VTKViewer_InteractorStyleSALOME::SafeDownCast(this->InteractorStyle); - if (!aStyle) return false; - - vtkRenderer* aren; - for (this->RenderWindow->GetRenderers()->InitTraversal(); - (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) { - vtkActorCollection* theActors = aren->GetActors(); - theActors->InitTraversal(); - vtkActor *ac = theActors->GetNextActor(); - while(!(ac==NULL)) { - if ( ac->IsA("SALOME_Actor") ) { - SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ); - if ( anActor->hasIO() ) { - if ( IObject->isSame( anActor->getIO() ) ) { - if ( anActor->GetMapper() == NULL ) { - return false; - } - //highlight or unhilight actors - if ( anActor->hasHighlight() ) { - anActor->highlight(hilight); - } else { - if ( anActor->GetVisibility() == 1 ) { - if (hilight) { - vtkActor2D *actor2D; - vtkProp3D *prop3D; - if ( (prop3D=vtkProp3D::SafeDownCast(anActor)) != NULL ) { - aStyle->HighlightProp3D(prop3D); - } else if ( (actor2D=vtkActor2D::SafeDownCast(anActor)) != NULL ) { - aStyle->HighlightActor2D(actor2D); - } - //this->InteractorStyle->HighlightProp(anActor); - } else { - aStyle->HighlightProp3D(NULL); - aStyle->HighlightActor2D(NULL); - //this->InteractorStyle->HighlightProp(NULL); - } + VTKViewer_InteractorStyleSALOME* aStyle = + VTKViewer_InteractorStyleSALOME::SafeDownCast(this->InteractorStyle); + if(!aStyle) return false; + vtkRendererCollection* aRenColl = this->RenderWindow->GetRenderers(); + aRenColl->InitTraversal(); + while(vtkRenderer* aRen = this->RenderWindow->GetRenderers()->GetNextItem()){ + vtkActorCollection* theActors = aRen->GetActors(); + theActors->InitTraversal(); + while(vtkActor *anAct = theActors->GetNextActor()) { + if(SALOME_Actor* anActor = SALOME_Actor::SafeDownCast(anAct)){ + if(anActor->hasIO()){ + if(IObject->isSame(anActor->getIO())){ + if(anActor->GetMapper() == NULL) + return false; + //highlight or unhilight actors + if(anActor->hasHighlight()) + anActor->highlight(hilight); + else{ + if(anActor->GetVisibility() == 1 && hilight) + aStyle->HighlightProp(anActor); + else if(!hilight) + aStyle->HighlightProp(NULL); } } } } } - ac = theActors->GetNextActor(); } - } - if (update) { + if(update){ Render(); emit RenderWindowModified(); } - return false; } @@ -830,36 +820,32 @@ void VTKViewer_RenderWindowInteractor::Update() { } -bool VTKViewer_RenderWindowInteractor::unHighlightAll() -{ - vtkRenderer* aren; - for (this->RenderWindow->GetRenderers()->InitTraversal(); - (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) { - vtkActorCollection* theActors = aren->GetActors(); +bool VTKViewer_RenderWindowInteractor::unHighlightAll(){ + VTKViewer_InteractorStyleSALOME* aStyle = + VTKViewer_InteractorStyleSALOME::SafeDownCast(this->InteractorStyle); + if(aStyle) aStyle->HighlightProp(NULL); + vtkRendererCollection* aRenColl = this->RenderWindow->GetRenderers(); + aRenColl->InitTraversal(); + while(vtkRenderer* aRen = this->RenderWindow->GetRenderers()->GetNextItem()){ + vtkActorCollection* theActors = aRen->GetActors(); theActors->InitTraversal(); - - if ( theActors->IsItemPresent(Point_Actor) != 0 ) - aren->RemoveActor( Point_Actor ); - if ( theActors->IsItemPresent( Edge_Actor ) != 0 ) - aren->RemoveActor( Edge_Actor ); - if ( theActors->IsItemPresent( Cell_Actor ) != 0 ) - aren->RemoveActor( Cell_Actor ); - - vtkActor *ac = theActors->GetNextActor(); - - while(!(ac==NULL)) { - if ( ac->IsA("SALOME_Actor") ) { - SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ); - if ( anActor->hasIO() ) { + if(theActors->IsItemPresent(Point_Actor)) + aRen->RemoveActor(Point_Actor); + if(theActors->IsItemPresent(Edge_Actor)) + aRen->RemoveActor(Edge_Actor); + if(theActors->IsItemPresent(Cell_Actor)) + aRen->RemoveActor(Cell_Actor); + vtkActor *anActor = theActors->GetNextActor(); + while(vtkActor *anAct = theActors->GetNextActor()) { + if(SALOME_Actor* anActor = SALOME_Actor::SafeDownCast(anAct)){ + if(anActor->hasIO()){ //highlight or unhilight actors - if ( anActor->hasHighlight() ) + if(anActor->hasHighlight()) anActor->highlight(false); } } - ac = theActors->GetNextActor(); } } - emit RenderWindowModified() ; return false; } diff --git a/src/VTKViewer/VTKViewer_RenderWindowInteractor.h b/src/VTKViewer/VTKViewer_RenderWindowInteractor.h index 24f7dd622..e5fa40885 100644 --- a/src/VTKViewer/VTKViewer_RenderWindowInteractor.h +++ b/src/VTKViewer/VTKViewer_RenderWindowInteractor.h @@ -47,10 +47,12 @@ #include #include -class VTKViewer_RenderWindow; class vtkPolyData; class vtkPolyDataMapper; +class VTKViewer_RenderWindow; +class VTKViewer_InteractorStyleSALOME; + // ------------------------------------------------------------ // :TRICKY: Fri Apr 21 22:19:27 2000 Pagey // The Signal/Slot mechanism used by Qt requires that QObject @@ -66,7 +68,7 @@ public: static VTKViewer_RenderWindowInteractor *New() ; - vtkTypeMacro(vtkRenderWindowInteractor,vtkObject); + vtkTypeMacro(VTKViewer_RenderWindowInteractor,vtkRenderWindowInteractor); void PrintSelf(ostream& os, vtkIndent indent); @@ -76,6 +78,11 @@ public: // want to have mouse interaction. virtual void Initialize(); + virtual void SetInteractorStyle(vtkInteractorObserver *); + VTKViewer_InteractorStyleSALOME* GetInteractorStyleSALOME(){ + return myInteractorStyle; + } + // Description: // This will start up the X event loop and never return. If you // call this method it will loop processing X events until the @@ -174,23 +181,24 @@ public: vtkRenderer* GetRenderer(); QWidget* getGUIWindow() {return myGUIWindow;} - void setGUIWindow(QWidget* theWin) { myGUIWindow = theWin;} - + void setGUIWindow(QWidget* theWin) {myGUIWindow = theWin;} + typedef void (*TCreateMapperFun)(vtkPolyData *theSourcePolyData, - vtkPolyDataMapper* theMapper, - const TColStd_MapOfInteger& theMapIndex); + vtkPolyDataMapper* theMapper, + const TColStd_MapOfInteger& theMapIndex); protected: VTKViewer_RenderWindowInteractor(); ~VTKViewer_RenderWindowInteractor(); + VTKViewer_InteractorStyleSALOME* myInteractorStyle; + bool highlight(const Handle(SALOME_InteractiveObject)& IObject, const TColStd_MapOfInteger& MapIndex, TCreateMapperFun theFun, vtkActor *theActor, bool hilight, bool update ); - // + // Timer used during various mouse events to figure // out mouse movements. - // QTimer *mTimer ; //CAI: Display mode @@ -202,14 +210,11 @@ public: vtkActor* Edge_Actor; //NB vtkActor* Cell_Actor; - // // User for switching to stereo mode. - // int PositionBeforeStereo[2]; - // + // Connect/disconnect all slots which allow events on the // render window to be passed to the interactor. - // void ConnectSlots() ; void DisconnectSlots() ; void ProcessSlotConnections(bool conn) ; @@ -227,13 +232,12 @@ public: void KeyPressed(QKeyEvent *event) ; private slots: - // // Not all of these slots are needed in VTK_MAJOR_VERSION=3, // but moc does not understand "#if VTK_MAJOR_VERSION". Hence, // we have to include all of these for the time being. Once, // this bug in MOC is fixed, we can separate these. - // void TimerFunc() ; + signals: void RenderWindowModified() ; @@ -243,3 +247,4 @@ public: #endif + diff --git a/src/VTKViewer/VTKViewer_ViewFrame.cxx b/src/VTKViewer/VTKViewer_ViewFrame.cxx index b54107cd5..8f9e8e286 100644 --- a/src/VTKViewer/VTKViewer_ViewFrame.cxx +++ b/src/VTKViewer/VTKViewer_ViewFrame.cxx @@ -27,7 +27,10 @@ // $Header$ #include "VTKViewer_ViewFrame.h" +#include "VTKViewer_Utilities.h" +#include "VTKViewer_Trihedron.h" #include "VTKViewer_RenderWindow.h" +#include "VTKViewer_InteractorStyleSALOME.h" #include "SALOME_Transform.h" #include "SALOME_TransformFilter.h" @@ -40,8 +43,6 @@ #include "QAD_Desktop.h" #include "SALOME_Selection.h" #include "SALOME_InteractiveObject.hxx" -#include "VTKViewer_InteractorStyleSALOME.h" -#include "VTKViewer_VectorText.h" #include "utilities.h" @@ -54,14 +55,10 @@ // VTK Includes #include #include -#include - -#include -#include -#include -#include +#include using namespace std; + /*! Constructor */ @@ -70,186 +67,16 @@ VTKViewer_ViewFrame::VTKViewer_ViewFrame(QWidget* parent, const char* name) { m_ViewUp[0] = 0; m_ViewUp[1] = 0; m_ViewUp[2] = -1; m_ViewNormal[0] = 0; m_ViewNormal[1] = 0; m_ViewNormal[2] = 1; + m_Triedron = VTKViewer_Trihedron::New(); m_Transform = SALOME_Transform::New(); + //m_Renderer = VTKViewer_Renderer::New() ; + m_Renderer = vtkRenderer::New() ; - // m_InitialSetupDone = false ; + m_Triedron->AddToRender(m_Renderer); InitialSetup(); -} - - -vtkFollower* CreateTextActor(char *text, float aSize) { - VTKViewer_VectorText* aTxt = VTKViewer_VectorText::New(); - aTxt->SetText(text); - vtkPolyDataMapper* textMapper = vtkPolyDataMapper::New(); - textMapper->SetInput(aTxt->GetOutput()); - vtkFollower* textActor = vtkFollower::New(); - textActor->SetMapper(textMapper); - float aScale = 17 * aSize/100; - textActor->SetScale(aScale, aScale, aScale); - return textActor; -} - -void VTKViewer_ViewFrame::AddVector(float* o,float* p,vtkRenderer* renderer, float aSize) { - vtkPoints* myPoints = vtkPoints::New(); - vtkLine* myLine = vtkLine::New(); - - myPoints->InsertNextPoint(o); - myPoints->InsertNextPoint(p); - - (myLine->GetPointIds())->InsertNextId(0); - (myLine->GetPointIds())->InsertNextId(1); - - vtkActor* lineActor = vtkActor::New(); - - vtkCellArray* cell = vtkCellArray::New(); - - cell->InsertNextCell(myLine); - - vtkPolyData* output = vtkPolyData::New(); - - output->SetPoints(myPoints); - output->SetLines(cell); - - vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); - - mapper->SetInput(output); - - lineActor->SetMapper(mapper); - - // Create CONE - - vtkConeSource* acone = vtkConeSource::New(); - - float dim = aSize; - - acone->SetResolution(2); - // acone->SetAngle(70); - acone->SetRadius(0.02*dim); - acone->SetHeight(0.08*dim); - - vtkActor* coneActor = vtkActor::New(); - - vtkPolyDataMapper* coneMapper = vtkPolyDataMapper::New(); - coneMapper->SetInput(acone->GetOutput()); - - coneActor->SetMapper(coneMapper); - float rot[3]; - rot[0]=0; rot[1]=0; rot[2]=0; - - vtkFollower* aTextActor; - - coneActor->AddPosition(p); - if(p[0]!=0) { - // x - aTextActor = CreateTextActor("X", dim); - } else if(p[1]!=0) { - // y - rot[2]=90; - coneActor->AddOrientation(rot); - aTextActor = CreateTextActor("Y", dim); - } else if(p[2]!=0) { - // z - rot[1]=-90; - coneActor->AddOrientation(rot); - aTextActor = CreateTextActor("Z", dim); - } - aTextActor->AddPosition(p); - aTextActor->SetCamera(renderer->GetActiveCamera()); - - coneActor->GetProperty()->SetInterpolation(1); - coneActor->GetProperty()->SetRepresentationToSurface(); - coneActor->GetProperty()->SetAmbient(1); - coneActor->GetProperty()->SetAmbientColor(1,1,1); - coneActor->GetProperty()->SetDiffuseColor(0.7,0.7,0.7); - coneActor->GetProperty()->SetSpecularColor(0.7,0.7,0.7); - - lineActor->GetProperty()->SetInterpolation(1); - lineActor->GetProperty()->SetRepresentationToSurface(); - lineActor->GetProperty()->SetAmbient(1); - lineActor->GetProperty()->SetAmbientColor(1,1,1); - lineActor->GetProperty()->SetDiffuseColor(0.7,0.7,0.7); - lineActor->GetProperty()->SetSpecularColor(0.7,0.7,0.7); - - aTextActor->GetProperty()->SetAmbient(1); - aTextActor->GetProperty()->SetAmbientColor(1,1,1); - aTextActor->GetProperty()->SetDiffuseColor(0.7,0.7,0.7); - aTextActor->GetProperty()->SetSpecularColor(0.7,0.7,0.7); - - coneActor->PickableOff(); - lineActor->PickableOff(); - aTextActor->PickableOff(); - - m_Triedron->AddItem(coneActor); - m_Triedron->AddItem(lineActor); - m_Triedron->AddItem(aTextActor); - - renderer->AddActor(coneActor); - renderer->AddActor(lineActor); - renderer->AddActor(aTextActor); } -bool VTKViewer_ViewFrame::isTrihedronDisplayed() { - m_Triedron->InitTraversal(); - vtkActor *ac = m_Triedron->GetNextActor(); - while(!(ac==NULL)) { - if(ac->GetVisibility()) return true; - ac = m_Triedron->GetNextActor(); - } - return false; -} - -void VTKViewer_ViewFrame::SetTrihedronSize(int size) -{ - m_Triedron->InitTraversal(); - vtkActor* anActor = m_Triedron->GetNextActor(); - while(!(anActor==NULL)) { - m_Renderer->RemoveActor( anActor ); - anActor = m_Triedron->GetNextActor(); - } - - m_Triedron->RemoveAllItems(); - AddAxis(m_Renderer); - m_RW->update(); -} - - -void VTKViewer_ViewFrame::AddAxis(vtkRenderer* renderer) { - float origine[3]; - float X[3]; - float Y[3]; - float Z[3]; - float dim; - - QString Size = QAD_CONFIG->getSetting("Viewer:TrihedronSize"); - if( Size.isEmpty() ){ - dim = 100; - } else { - dim = Size.toFloat(); - } - - origine[0]=0; origine[1]=0; origine[2]=0; - X[0]=origine[0]+dim; X[1]=origine[0]; X[2]=origine[0]; - Y[0]=origine[0]; Y[1]=origine[0]+dim; Y[2]=origine[0]; - Z[0]=origine[0]; Z[1]=origine[0]; Z[2]=origine[0]+dim; - - AddVector(origine,X,renderer, dim); - AddVector(origine,Y,renderer, dim); - AddVector(origine,Z,renderer, dim); - -} - -/*! - Returns widget containing 3D-Viewer -*/ -QWidget* VTKViewer_ViewFrame::getViewWidget() -{ - return m_RW; -} - - void VTKViewer_ViewFrame::InitialSetup() { - m_Renderer = vtkRenderer::New() ; - m_RW = new VTKViewer_RenderWindow(this, "RenderWindow"); m_RW->getRenderWindow()->AddRenderer(m_Renderer); @@ -266,11 +93,7 @@ void VTKViewer_ViewFrame::InitialSetup() { m_Renderer->SetBackground( BgrColorRed.toInt()/255., BgrColorGreen.toInt()/255., BgrColorBlue.toInt()/255. ); else m_Renderer->SetBackground( 0, 0, 0 ); - - // CREATE AXIS - m_Triedron = vtkActorCollection::New(); - AddAxis(m_Renderer); - + // Create an interactor. m_RWInteractor = VTKViewer_RenderWindowInteractor::New(); m_RWInteractor->setGUIWindow(m_RW); @@ -281,7 +104,7 @@ void VTKViewer_ViewFrame::InitialSetup() { m_RWInteractor->SetInteractorStyle(RWS); m_RWInteractor->Initialize(); - RWS->setTriedron( m_Triedron ); + RWS->setTriedron(m_Triedron); //SRN: additional initialization, to init CurrentRenderer of vtkInteractorStyle RWS->FindPokedRenderer(0, 0); @@ -290,414 +113,218 @@ void VTKViewer_ViewFrame::InitialSetup() { } VTKViewer_ViewFrame::~VTKViewer_ViewFrame() { - // + m_Transform->Delete() ; // In order to ensure that the interactor unregisters // this RenderWindow, we assign a NULL RenderWindow to // it before deleting it. - // - m_Transform->Delete() ; - m_RWInteractor->SetRenderWindow(NULL) ; m_RWInteractor->Delete() ; //m_RW->Delete() ; - + m_Renderer->RemoveAllProps(); // NRI : BugID 1137: m_Renderer->Delete() ; + m_Triedron->Delete(); + MESSAGE("VTKViewer_ViewFrame::~VTKViewer_ViewFrame()"); } +/*! + Returns widget containing 3D-Viewer +*/ +QWidget* VTKViewer_ViewFrame::getViewWidget(){ + return m_RW; +} + +bool VTKViewer_ViewFrame::isTrihedronDisplayed(){ + return m_Triedron->GetVisibility() == VTKViewer_Trihedron::eOn; +} + +void VTKViewer_ViewFrame::onAdjustTrihedron(){ + if(!isTrihedronDisplayed()) + return; + int aVisibleNum = m_Triedron->GetVisibleActorCount(m_Renderer); + if(aVisibleNum){ + // calculating diagonal of visible props of the renderer + float bnd[6]; + m_Triedron->VisibilityOff(); + ::ComputeVisiblePropBounds(m_Renderer,bnd); + m_Triedron->VisibilityOn(); + float aLength = 0; + static bool CalcByDiag = false; + if(CalcByDiag){ + aLength = sqrt((bnd[1]-bnd[0])*(bnd[1]-bnd[0])+ + (bnd[3]-bnd[2])*(bnd[3]-bnd[2])+ + (bnd[5]-bnd[4])*(bnd[5]-bnd[4])); + }else{ + aLength = bnd[1]-bnd[0]; + aLength = max((bnd[3]-bnd[2]),aLength); + aLength = max((bnd[5]-bnd[4]),aLength); + } + + static float aSizeInPercents = 105; + QString aSetting = QAD_CONFIG->getSetting("Viewer:TrihedronSize"); + if(!aSetting.isEmpty()) aSizeInPercents = aSetting.toFloat(); + + static float EPS_SIZE = 5.0E-3; + float aSize = m_Triedron->GetSize(); + float aNewSize = aLength*aSizeInPercents/100.0; + // if the new trihedron size have sufficient difference, then apply the value + if(fabs(aNewSize-aSize) > aSize*EPS_SIZE || fabs(aNewSize-aSize) > aNewSize*EPS_SIZE) + m_Triedron->SetSize(aNewSize); + } + m_Triedron->Render(m_Renderer); + ::ResetCameraClippingRange(m_Renderer); +} /*! Display/hide Trihedron */ -void VTKViewer_ViewFrame::onViewTrihedron() -{ - if (isTrihedronDisplayed()) { - m_Triedron->InitTraversal(); - vtkActor *ac = m_Triedron->GetNextActor(); - while(!(ac==NULL)) { - ac->VisibilityOff(); - ac = m_Triedron->GetNextActor(); - } +void VTKViewer_ViewFrame::onViewTrihedron(){ + if(!m_Triedron) return; + if(isTrihedronDisplayed()) + m_Triedron->VisibilityOff(); + else{ + m_Triedron->VisibilityOn(); } - else { - m_Triedron->InitTraversal(); - vtkActor *ac = m_Triedron->GetNextActor(); - while(!(ac==NULL)) { - ac->VisibilityOn(); - ac = m_Triedron->GetNextActor(); - } - m_TriedronVisible = true; - } - m_RW->update(); + Repaint(); } /*! Provides top projection of the active view */ -void VTKViewer_ViewFrame::onViewTop() { +void VTKViewer_ViewFrame::onViewTop(){ vtkCamera* camera = m_Renderer->GetActiveCamera(); - camera->SetFocalPoint(0,0,0); camera->SetPosition(0,0,1); camera->SetViewUp(0,1,0); - m_Renderer->ResetCamera(); + camera->SetFocalPoint(0,0,0); onViewFitAll(); - m_RW->update(); } /*! Provides bottom projection of the active view */ -void VTKViewer_ViewFrame::onViewBottom() -{ +void VTKViewer_ViewFrame::onViewBottom(){ vtkCamera* camera = m_Renderer->GetActiveCamera(); - camera->SetFocalPoint(0,0,0); camera->SetPosition(0,0,-1); camera->SetViewUp(0,1,0); - m_Renderer->ResetCamera(); + camera->SetFocalPoint(0,0,0); onViewFitAll(); - m_RW->update(); } /*! Provides left projection of the active view */ -void VTKViewer_ViewFrame::onViewLeft() -{ +void VTKViewer_ViewFrame::onViewLeft(){ vtkCamera* camera = m_Renderer->GetActiveCamera(); - camera->SetFocalPoint(0,0,0); camera->SetPosition(0,1,0); camera->SetViewUp(0,0,1); - m_Renderer->ResetCamera(); + camera->SetFocalPoint(0,0,0); onViewFitAll(); - m_RW->update(); } /*! Provides right projection of the active view */ -void VTKViewer_ViewFrame::onViewRight() -{ +void VTKViewer_ViewFrame::onViewRight(){ vtkCamera* camera = m_Renderer->GetActiveCamera(); - camera->SetFocalPoint(0,0,0); camera->SetPosition(0,-1,0); camera->SetViewUp(0,0,1); - m_Renderer->ResetCamera(); + camera->SetFocalPoint(0,0,0); onViewFitAll(); - m_RW->update(); } /*! Provides back projection of the active view */ -void VTKViewer_ViewFrame::onViewBack() -{ +void VTKViewer_ViewFrame::onViewBack(){ vtkCamera* camera = m_Renderer->GetActiveCamera(); camera->SetPosition(-1,0,0); - camera->SetFocalPoint(0,0,0); camera->SetViewUp(0,0,1); - m_Renderer->ResetCamera(); + camera->SetFocalPoint(0,0,0); onViewFitAll(); - m_RW->update(); } /*! Provides front projection of the active view */ -void VTKViewer_ViewFrame::onViewFront() -{ +void VTKViewer_ViewFrame::onViewFront(){ vtkCamera* camera = m_Renderer->GetActiveCamera(); camera->SetPosition(1,0,0); - camera->SetFocalPoint(0,0,0); camera->SetViewUp(0,0,1); - m_Renderer->ResetCamera(); + camera->SetFocalPoint(0,0,0); onViewFitAll(); - m_RW->update(); } /*! - Reset the active view + Fits all objects in the active view */ -void VTKViewer_ViewFrame::onViewReset() -{ - vtkCamera* camera = m_Renderer->GetActiveCamera(); - camera->SetPosition(1,-1,1); - camera->SetFocalPoint(0,0,0); - camera->SetViewUp(0,0,1); - m_Renderer->ResetCamera(); - - double aOldScale = camera->GetParallelScale(); - camera->SetParallelScale(500); - double aNewScale = camera->GetParallelScale(); - - //for controlling labels scale after reset - float dim; - QString Size = QAD_CONFIG->getSetting("Viewer:TrihedronSize"); - if( Size.isEmpty() ){ - dim = 100; - } else { - dim = Size.toFloat(); - } - float aScale = 17 * dim/100; +void VTKViewer_ViewFrame::onViewFitAll(){ + m_RWInteractor->GetInteractorStyleSALOME()->ViewFitAll(); +// int aTriedronWasVisible = isTrihedronDisplayed(); +// if(m_Triedron->GetVisibleActorCount(m_Renderer)){ +// m_Triedron->VisibilityOff(); +// ::ResetCamera(m_Renderer); +// }else{ +// m_Triedron->SetVisibility(VTKViewer_Trihedron::eOnlyLineOn); +// ::ResetCamera(m_Renderer,true); +// } +// if(aTriedronWasVisible) m_Triedron->VisibilityOn(); +// else m_Triedron->VisibilityOff(); - m_Triedron->InitTraversal(); - vtkActor *ac = m_Triedron->GetNextActor(); - bool IsConeActor = true; - while(!(ac==NULL)) { - if(ac->IsA("vtkFollower")) { - ac->SetScale(aScale, aScale, aScale); - IsConeActor = true; - } - else { - if (IsConeActor) { - //coneActor is the first in the list (see m_Triedron->AddItem(...) in VTKViewer_ViewFrame::AddVector(...)) - IsConeActor = false; - } - } - ac = m_Triedron->GetNextActor(); - } + Repaint(); +} - m_Renderer->ResetCameraClippingRange(); - m_RW->update(); +/*! + Reset the active view +*/ +void VTKViewer_ViewFrame::onViewReset(){ + int aTriedronIsVisible = isTrihedronDisplayed(); + m_Triedron->SetVisibility(VTKViewer_Trihedron::eOnlyLineOn); + ::ResetCamera(m_Renderer,true); + vtkCamera* aCamera = m_Renderer->GetActiveCamera(); + aCamera->SetPosition(1,-1,1); + aCamera->SetViewUp(0,0,1); + ::ResetCamera(m_Renderer,true); + if(aTriedronIsVisible) m_Triedron->VisibilityOn(); + else m_Triedron->VisibilityOff(); + static float aCoeff = 3.0; + aCamera->SetParallelScale(aCoeff*aCamera->GetParallelScale()); + Repaint(); } /*! Rotates the active view */ -void VTKViewer_ViewFrame::onViewRotate() -{ - VTKViewer_InteractorStyleSALOME* RWS = dynamic_cast(getRWInteractor()->GetInteractorStyle()); - if (RWS) - RWS->startRotate(); +void VTKViewer_ViewFrame::onViewRotate(){ + m_RWInteractor->GetInteractorStyleSALOME()->startRotate(); } /*! Sets a new center of the active view */ -void VTKViewer_ViewFrame::onViewGlobalPan() -{ - VTKViewer_InteractorStyleSALOME* RWS = dynamic_cast(getRWInteractor()->GetInteractorStyle()); - if (RWS) - RWS->startGlobalPan(); +void VTKViewer_ViewFrame::onViewGlobalPan(){ + if(m_Triedron->GetVisibleActorCount(m_Renderer)) + m_RWInteractor->GetInteractorStyleSALOME()->startGlobalPan(); } /*! Zooms the active view */ -void VTKViewer_ViewFrame::onViewZoom() -{ - VTKViewer_InteractorStyleSALOME* RWS = dynamic_cast(getRWInteractor()->GetInteractorStyle()); - if (RWS) - RWS->startZoom(); +void VTKViewer_ViewFrame::onViewZoom(){ + m_RWInteractor->GetInteractorStyleSALOME()->startZoom(); } /*! Moves the active view */ -void VTKViewer_ViewFrame::onViewPan() -{ - VTKViewer_InteractorStyleSALOME* RWS = dynamic_cast(getRWInteractor()->GetInteractorStyle()); - if (RWS) - RWS->startPan(); +void VTKViewer_ViewFrame::onViewPan(){ + m_RWInteractor->GetInteractorStyleSALOME()->startPan(); } /*! Fits all obejcts within a rectangular area of the active view */ -void VTKViewer_ViewFrame::onViewFitArea() -{ - VTKViewer_InteractorStyleSALOME* RWS = dynamic_cast(getRWInteractor()->GetInteractorStyle()); - if (RWS) - RWS->startFitArea(); -} - -/*! - Fits all objects in the active view -*/ -// Reset the camera clipping range to include this entire bounding box -static void ResetCameraClippingRange(vtkRenderer* theRenderer, float bounds[6] ) -{ - //see vtkRenderer::ResetCameraClippingRange(float bounds[6]) method - double vn[3], position[3], a, b, c, d; - double range[2], dist; - int i, j, k; - float center[3]; - float distance; - float width; - - vtkCamera* anActiveCamera = theRenderer->GetActiveCamera(); - if ( anActiveCamera == NULL ) - { - //vtkErrorMacro(<< "Trying to reset clipping range of non-existant camera"); - return; - } - - // Find the plane equation for the camera view plane - anActiveCamera->GetViewPlaneNormal(vn); - anActiveCamera->GetPosition(position); -// a = -vn[0]; -// b = -vn[1]; -// c = -vn[2]; -// d = -(a*position[0] + b*position[1] + c*position[2]); - - // Set the max near clipping plane and the min far clipping plane -// range[0] = a*bounds[0] + b*bounds[2] + c*bounds[4] + d; -// range[1] = 1e-18; - - // Find the closest / farthest bounding box vertex -// for ( k = 0; k < 2; k++ ) -// { -// for ( j = 0; j < 2; j++ ) -// { -// for ( i = 0; i < 2; i++ ) -// { -// dist = a*bounds[i] + b*bounds[2+j] + c*bounds[4+k] + d; -// range[0] = (distrange[1])?(dist):(range[1]); -// } -// } -// } - - center[0] = (bounds[0] + bounds[1])/2.0; - center[1] = (bounds[2] + bounds[3])/2.0; - center[2] = (bounds[4] + bounds[5])/2.0; - width = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) + - (bounds[3]-bounds[2])*(bounds[3]-bounds[2]) + - (bounds[5]-bounds[4])*(bounds[5]-bounds[4])); - distance = sqrt((position[0]-center[0])*(position[0]-center[0]) + - (position[1]-center[1])*(position[1]-center[1]) + - (position[2]-center[2])*(position[2]-center[2])); - range[0] = distance - width/2.0; - range[1] = distance + width/2.0; - - // Give ourselves a little breathing room - range[0] = 0.99*range[0] - (range[1] - range[0])*0.5; - range[1] = 1.01*range[1] + (range[1] - range[0])*0.5; - - // Make sure near is not bigger than far - range[0] = (range[0] >= range[1])?(0.01*range[1]):(range[0]); - - // Make sure near is at least some fraction of far - this prevents near - // from being behind the camera or too close in front. How close is too - // close depends on the resolution of the depth buffer - int ZBufferDepth = 16; - vtkRenderWindow* aRenderWindow = theRenderer->GetRenderWindow(); - if (aRenderWindow) - { - ZBufferDepth = aRenderWindow->GetDepthBufferSize(); - } - // - if ( ZBufferDepth <= 16 ) - { - range[0] = (range[0] < 0.01*range[1])?(0.01*range[1]):(range[0]); - } - else if ( ZBufferDepth <= 24 ) - { - range[0] = (range[0] < 0.01*range[1])?(0.01*range[1]):(range[0]); - } - else - { - range[0] = (range[0] < 0.01*range[1])?(0.01*range[1]):(range[0]); - } - anActiveCamera->SetClippingRange( range ); -} - -static void ResetCamera(vtkRenderer* theRenderer, vtkActorCollection* theTriedron, VTKViewer_RenderWindowInteractor* theRWInteractor){ - //see vtkRenderer::ResetCamera(float bounds[6]) method - float bounds[6]; - if(!theRenderer) return; - theRenderer->ComputeVisiblePropBounds( bounds ); - - float center[3]; - float distance; - float width; - double vn[3], *vup; - int* winsize; - - if ( theRenderer->GetActiveCamera() != NULL ) - { - theRenderer->GetActiveCamera()->GetViewPlaneNormal(vn); - } - else - { - MESSAGE("Trying to reset non-existant camera"); - return; - } - - center[0] = (bounds[0] + bounds[1])/2.0; - center[1] = (bounds[2] + bounds[3])/2.0; - center[2] = (bounds[4] + bounds[5])/2.0; - width = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) + - (bounds[3]-bounds[2])*(bounds[3]-bounds[2]) + - (bounds[5]-bounds[4])*(bounds[5]-bounds[4])); - double ang = theRenderer->GetActiveCamera()->GetViewAngle(); - distance = 2.0*width/tan(ang*vtkMath::Pi()/360.0); - - // find size of the window - winsize = theRenderer->GetSize(); - - // check view-up vector against view plane normal - vup = theRenderer->GetActiveCamera()->GetViewUp(); - if ( fabs(vtkMath::Dot(vup,vn)) > 0.999 ) - { - MESSAGE("Resetting view-up since view plane normal is parallel"); - theRenderer->GetActiveCamera()->SetViewUp(-vup[2], vup[0], vup[1]); - } - - // update the camera - theRenderer->GetActiveCamera()->SetFocalPoint(center[0],center[1],center[2]); - theRenderer->GetActiveCamera()->SetPosition(center[0]+distance*vn[0], - center[1]+distance*vn[1], - center[2]+distance*vn[2]); - // setup default parallel scale - double aOldScale = theRenderer->GetActiveCamera()->GetParallelScale(); - - if(winsize[0]GetActiveCamera()->SetParallelScale(width/2.0); - double aNewScale = theRenderer->GetActiveCamera()->GetParallelScale(); - - // for controlling label size - VTKViewer_InteractorStyleSALOME* Style = 0; - if (theRWInteractor->GetInteractorStyle()->IsA("VTKViewer_InteractorStyleSALOME")) { - Style = VTKViewer_InteractorStyleSALOME::SafeDownCast(theRWInteractor->GetInteractorStyle()); - Style->ControlLblSize(aOldScale,aNewScale); - } - - //workaround on VTK - //theRenderer->ResetCameraClippingRange(bounds); - ResetCameraClippingRange(theRenderer,bounds); -} - -void VTKViewer_ViewFrame::onViewFitAll() -{ - Standard_Boolean TriedronWasVisible = false; - if (isTrihedronDisplayed()) { - m_Triedron->InitTraversal(); - vtkActor *ac = m_Triedron->GetNextActor(); - while(!(ac==NULL)) { - ac->VisibilityOff(); - ac = m_Triedron->GetNextActor(); - } - TriedronWasVisible = true; - } - bool hasVisibleActors = m_Renderer->VisibleActorCount() > 0; - if ( hasVisibleActors ) { // if there are visible actors, not to take into account Trihedron - ResetCamera(m_Renderer,m_Triedron,m_RWInteractor); - } - if(TriedronWasVisible) { - m_Triedron->InitTraversal(); - vtkActor *ac = m_Triedron->GetNextActor(); - while(!(ac==NULL)) { - ac->VisibilityOn(); - ac = m_Triedron->GetNextActor(); - } - if ( !hasVisibleActors ) { // if there are NO visible actors, fit view to see only Trihedron - ResetCamera(m_Renderer,m_Triedron,m_RWInteractor); - } - } - //m_Renderer->ResetCameraClippingRange(); - m_RW->update(); +void VTKViewer_ViewFrame::onViewFitArea(){ + m_RWInteractor->GetInteractorStyleSALOME()->startFitArea(); } /*! @@ -967,9 +594,9 @@ void VTKViewer_ViewFrame::EraseAll() } -void VTKViewer_ViewFrame::Repaint() +void VTKViewer_ViewFrame::Repaint(bool theUpdateTrihedron) { - // m_RWInteractor->Render(); + if (theUpdateTrihedron) onAdjustTrihedron(); m_RW->update(); } @@ -979,12 +606,7 @@ void VTKViewer_ViewFrame::GetScale(double theScale[3]){ void VTKViewer_ViewFrame::SetScale(double theScale[3]){ m_Transform->SetScale(theScale[0], theScale[1], theScale[2]); - m_Transform->Modified(); - vtkActorCollection* theActors = m_Renderer->GetActors(); - theActors->InitTraversal(); - vtkActor *anActor; - while(anActor = theActors->GetNextActor()) - anActor->GetMapper()->Update(); + m_RWInteractor->Render(); Repaint(); } @@ -992,18 +614,12 @@ void VTKViewer_ViewFrame::AddActor( SALOME_Actor* theActor, bool update /*=false theActor->SetVisibility(true); theActor->AddToRender(m_Renderer); theActor->SetTransform(m_Transform); - if(update){ - m_Renderer->ResetCameraClippingRange(); - m_RWInteractor->Render(); - } + if(update) Repaint(); } void VTKViewer_ViewFrame::RemoveActor( SALOME_Actor* theActor, bool update /*=false*/ ){ theActor->RemoveFromRender(m_Renderer); - if(update){ - m_Renderer->ResetCameraClippingRange(); - m_RWInteractor->Render(); - } + if(update) Repaint(); } diff --git a/src/VTKViewer/VTKViewer_ViewFrame.h b/src/VTKViewer/VTKViewer_ViewFrame.h index 64467faa6..83fc35ab1 100644 --- a/src/VTKViewer/VTKViewer_ViewFrame.h +++ b/src/VTKViewer/VTKViewer_ViewFrame.h @@ -37,8 +37,8 @@ // VTK Includes class vtkRenderer; -class vtkActorCollection; class vtkTransform; +class VTKViewer_Trihedron; class QAD_EXPORT VTKViewer_ViewFrame : public QAD_ViewFrame{ Q_OBJECT; @@ -54,8 +54,7 @@ class QAD_EXPORT VTKViewer_ViewFrame : public QAD_ViewFrame{ VTKViewer_RenderWindowInteractor* getRWInteractor() {return m_RWInteractor;} bool isTrihedronDisplayed(); - void SetTrihedronSize( int dim ); - + void setBackgroundColor( const QColor& ); QColor backgroundColor() const; @@ -89,7 +88,8 @@ class QAD_EXPORT VTKViewer_ViewFrame : public QAD_ViewFrame{ void Erase(const Handle(SALOME_InteractiveObject)& IObject, bool immediatly = true); void DisplayAll(); void EraseAll(); - void Repaint(); + void Repaint(bool theUpdateTrihedron); + void Repaint() { Repaint(true); } //apply existing transformation on adding SALOME_Actor void SetScale(double theScale[3]); @@ -97,10 +97,6 @@ class QAD_EXPORT VTKViewer_ViewFrame : public QAD_ViewFrame{ void AddActor(SALOME_Actor*, bool update = false); void RemoveActor(SALOME_Actor*, bool update = false); - private: - void AddVector(float* o,float* p,vtkRenderer* renderer, float aSize); - void AddAxis(vtkRenderer* renderer); - public slots: void onViewPan(); void onViewZoom(); @@ -116,20 +112,19 @@ class QAD_EXPORT VTKViewer_ViewFrame : public QAD_ViewFrame{ void onViewBottom(); void onViewTop(); void onViewTrihedron(); + void onAdjustTrihedron(); private: double m_ViewUp[3]; double m_ViewNormal[3]; - + void InitialSetup(); vtkRenderer* m_Renderer; VTKViewer_RenderWindow* m_RW; VTKViewer_RenderWindowInteractor* m_RWInteractor; - Standard_Boolean m_TriedronVisible; - vtkActorCollection* m_Triedron; - + VTKViewer_Trihedron *m_Triedron; SALOME_Transform *m_Transform; }; #endif