From 3611482e9913ca26e3d3becfb3b64f6e2f591d35 Mon Sep 17 00:00:00 2001 From: prascle Date: Fri, 12 Mar 2004 19:55:30 +0000 Subject: [PATCH] PR: merge from head (tag mergeto_ADAM_br1_12Mar04) --- INSTALL | 3 +- bin/VERSION | 2 +- bin/orbmodule.py | 7 +- bin/runSalome | 8 +- bin/runSalome.py | 25 +- doc/html/INPUT/doxyfile | 2 +- doc/html/INPUT/sources/static/tree.js | 2 +- doc/html/Makefile.in | 1 + idl/Makefile.in | 3 +- idl/SALOMEDS.idl | 394 ++++++++--- idl/SALOMEDS_Attributes.idl | 227 +++++-- idl/SALOME_Component.idl | 8 +- idl/SALOME_Exception.idl | 2 +- idl/SALOME_ModuleCatalog.idl | 27 +- idl/SALOME_Session.idl | 9 +- salome_adm/unix/config_files/check_pyqt.m4 | 39 +- salome_adm/unix/config_files/check_sip.m4 | 3 +- src/Container/Makefile.in | 2 +- src/Container/SALOME_Container.cxx | 290 ++++---- src/Container/SALOME_ContainerPy.py | 27 +- src/DataTypeCatalog/Makefile.in | 2 +- .../SALOME_DataTypeCatalog_Server.cxx | 196 +++--- src/LifeCycleCORBA/Makefile.in | 2 +- src/Loader/Makefile.in | 2 +- src/Loader/SALOME_Session_Loader.cxx | 1 + src/Logger/SALOME_Logger_Server.cxx | 83 ++- src/Logger/SALOME_Trace.cxx | 147 ++-- src/Logger/SALOME_Trace.hxx | 3 + src/Logger/SALOME_Trace.py | 58 +- src/Makefile.in | 15 +- src/ModuleCatalog/Makefile.in | 2 +- .../SALOME_ModuleCatalog_Server.cxx | 218 +++--- src/ModuleGenerator/IDLparser.py | 175 ++--- src/NamingService/SALOME_NamingServicePy.py | 4 +- src/Notification/Makefile.in | 2 +- src/OBJECT/SALOME_Actor.cxx | 117 +--- src/OBJECT/SALOME_Actor.h | 17 +- src/OCCViewer/OCCViewer_ViewFrame.cxx | 64 +- src/OCCViewer/OCCViewer_ViewFrame.h | 5 +- src/Plot2d/Plot2d_ViewFrame.h | 2 +- src/Registry/Makefile.in | 2 +- src/Registry/SALOME_Registry_Server.cxx | 308 +++++---- src/RegistryDisplay/RegWidget.cxx | 113 +++- src/RegistryDisplay/RegWidgetFactory.cxx | 2 +- src/RessourcesCatalog/Makefile.in | 2 +- .../SALOME_RessourcesCatalog_Server.cxx | 183 ++--- src/SALOMEDS/Makefile.in | 6 +- src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx | 5 + src/SALOMEDS/SALOMEDS_SObject_i.cxx | 24 + src/SALOMEDS/SALOMEDS_Server.cxx | 248 +++---- src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx | 116 +++- src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx | 2 + src/SALOMEDS/SALOMEDS_StudyManager_i.cxx | 153 ++++- src/SALOMEDS/SALOMEDS_Study_i.cxx | 160 ++++- src/SALOMEDS/SALOMEDS_Study_i.hxx | 20 + .../SALOMEDS_TableOfIntegerAttribute.cxx | 15 +- .../SALOMEDS_TableOfRealAttribute.cxx | 15 +- .../SALOMEDS_TableOfStringAttribute.cxx | 15 +- src/SALOMEGUI/CLIENT_msg_en.po | 6 +- src/SALOMEGUI/QAD_Application.cxx | 11 +- src/SALOMEGUI/QAD_Desktop.cxx | 305 ++++++++- src/SALOMEGUI/QAD_Desktop.h | 25 +- src/SALOMEGUI/QAD_FileDlg.cxx | 32 +- src/SALOMEGUI/QAD_HelpWindow.cxx | 42 +- src/SALOMEGUI/QAD_ObjectBrowser.cxx | 137 +++- src/SALOMEGUI/QAD_ObjectBrowser.h | 13 + src/SALOMEGUI/QAD_Study.cxx | 16 +- src/SALOMEGUI/QAD_Study.h | 1 + src/SALOMEGUI/QAD_StudyFrame.cxx | 1 - src/SALOMEGUI/QAD_StudyFrame.h | 1 - src/SALOMEGUI/QAD_Tools.cxx | 2 +- src/SALOMEGUI/QAD_ViewFrame.h | 4 +- src/SALOMEGUI/QAD_icons.po | 9 + src/SALOMEGUI/QAD_msg_en.po | 24 + src/SALOMEGUI/SALOMEGUI_Application.cxx | 2 +- src/SALOMEGUI/SALOMEGUI_SetValueDlg.cxx | 41 ++ src/SALOMEGUI/SALOMEGUI_SetValueDlg.h | 9 + src/SALOMEGUI/SALOMEGUI_msg_en.po | 2 +- src/SALOMEGUI/SALOMEGUI_msg_fr.po | 6 +- src/SALOME_PYQT/SalomePyQt.cxx | 4 + src/SALOME_PYQT/SalomePyQt.hxx | 1 + src/SALOME_PYQT/SalomePyQt.sip | 1 + src/SALOME_SWIG/salome_test.py | 7 + src/SUPERVGraph/SUPERVGraph_ViewFrame.cxx | 4 +- src/SUPERVGraph/SUPERVGraph_ViewFrame.h | 2 +- src/Session/Makefile.in | 2 +- src/Session/SALOME_Session_QThread.cxx | 16 + src/Session/SALOME_Session_QThread.hxx | 6 +- src/Session/SALOME_Session_Server.cxx | 181 ++--- src/Session/SALOME_Session_i.cxx | 4 +- src/TOOLSDS/Makefile.in | 2 +- src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx | 69 +- src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.h | 3 + src/TOOLSGUI/ToolsGUI_msg_en.po | 3 + src/TestContainer/Makefile.in | 2 +- src/TestContainer/TestContainer.cxx | 139 ++-- src/Utils/Makefile.in | 2 +- src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx | 1 + src/Utils/Utils_SALOME_Exception.cxx | 2 +- src/Utils/Utils_SINGLETON.hxx | 4 +- src/Utils/utilities.h | 130 ++-- src/VTKViewer/Makefile.in | 4 +- .../VTKViewer_InteractorStyleSALOME.cxx | 232 +++---- .../VTKViewer_InteractorStyleSALOME.h | 7 +- src/VTKViewer/VTKViewer_RenderWindow.cxx | 23 +- .../VTKViewer_RenderWindowInteractor.cxx | 116 ++-- .../VTKViewer_RenderWindowInteractor.h | 33 +- src/VTKViewer/VTKViewer_ViewFrame.cxx | 640 ++++-------------- src/VTKViewer/VTKViewer_ViewFrame.h | 19 +- 109 files changed, 3439 insertions(+), 2494 deletions(-) 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/orbmodule.py b/bin/orbmodule.py index bd8e73b78..1154b0101 100755 --- a/bin/orbmodule.py +++ b/bin/orbmodule.py @@ -21,7 +21,12 @@ class Server: class NamingServer(Server): XTERM="" - CMD="runNS.sh > /tmp/salomeNS.log 2>&1" + USER=os.getenv('USER') + if USER is None: + USER='anonymous' + LOGDIR="/tmp/logs/" + USER + os.system("mkdir -m 777 -p " + LOGDIR) + CMD="runNS.sh > " + LOGDIR + "/salomeNS.log 2>&1" # ----------------------------------------------------------------------------- diff --git a/bin/runSalome b/bin/runSalome index 7e15dd9f9..3a3d0e2d2 100755 --- a/bin/runSalome +++ b/bin/runSalome @@ -1,9 +1,9 @@ #!/bin/sh -python -i runSalome.py --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --xterm --containers=cpp,python --killall -#python -i runSalome.py --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --logger --xterm -#python -i runSalome.py --modules=GEOM,SMESH,VISU,SUPERV,MED -#python -i runSalome.py --help +python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --xterm --containers=cpp,python --killall +#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --logger --xterm +#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --modules=GEOM,SMESH,VISU,SUPERV,MED +#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --help # ----------------------------------------------------------------------------- # diff --git a/bin/runSalome.py b/bin/runSalome.py index d7c7a496c..b9ccbd48a 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -255,6 +255,22 @@ add_path(os.path.join(kernel_root_dir,"bin","salome")) 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") + libtraceln = os.path.join(libtracedir,"libSALOMELocalTrace.so") + aCommand = 'rm -rf ' + libtracedir + "; " + aCommand += 'mkdir ' + libtracedir + "; " + aCommand += 'ln -s ' + libtrace + " " + libtraceln + "; " + aCommand += 'ln -s ' + libtrace + " " + libtraceln + ".0; " + aCommand += 'ln -s ' + libtrace + " " + libtraceln + ".0.0.0; " + os.system(aCommand) + add_ld_library_path(libtracedir) + #print "LD_LIBRARY_PATH=",os.environ["LD_LIBRARY_PATH"] # @@ -376,6 +392,11 @@ def startSalome(): import SALOME session=clt.waitNS("/Kernel/Session",SALOME.Session) + + theComputer = os.getenv("HOSTNAME") + computerSplitName = theComputer.split('.') + theComputer = computerSplitName[0] + # # Lancement Container C++ local # @@ -386,10 +407,6 @@ def startSalome(): # Attente de la disponibilité du Container C++ local dans le Naming Service # - theComputer = os.getenv("HOSTNAME") - computerSplitName = theComputer.split('.') - theComputer = computerSplitName[0] - clt.waitNS("/Containers/" + theComputer + "/FactoryServer") # 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/doc/html/Makefile.in b/doc/html/Makefile.in index 1e8ae14d7..7b070ace2 100644 --- a/doc/html/Makefile.in +++ b/doc/html/Makefile.in @@ -35,6 +35,7 @@ distclean: clean rm -rf INPUT install: + $(INSTALL) -d $(docdir); \ cp -rf html $(docdir) uninstall: 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 b47f39bea..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,6 +297,49 @@ 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); + }; + + //========================================================================== +/*! \brief External File definition + + This attribute stores a path to an External File. +*/ + //========================================================================== + interface AttributeExternalFileDef: GenericAttribute + { +/*! + 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); + }; + + //========================================================================== +/*! \brief File Type definition + + This attribute stores an external File Type (see ExternalFileDef attribute). +*/ + //========================================================================== + interface AttributeFileType: GenericAttribute + { +/*! + Returns the value of this attribute
See also an example of this method usage in batchmode of %SALOME application. */ string Value(); @@ -283,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. */ @@ -314,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. */ @@ -338,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. */ @@ -363,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. */ @@ -385,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. */ @@ -407,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. */ @@ -427,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. */ @@ -450,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. */ @@ -457,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); /*! @@ -576,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); @@ -596,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); @@ -625,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(); /*! @@ -641,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. */ @@ -718,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/salome_adm/unix/config_files/check_pyqt.m4 b/salome_adm/unix/config_files/check_pyqt.m4 index 09d4e426c..e0d320185 100644 --- a/salome_adm/unix/config_files/check_pyqt.m4 +++ b/salome_adm/unix/config_files/check_pyqt.m4 @@ -72,46 +72,39 @@ if test -z $PYUIC; then PYUIC="/usr/bin/pyuic" fi -AC_CHECK_FILES("$PYQTDIR/qt.py","$PYQTDIR/qt/qt.py",pyqt_ok=yes,pyqt_ok=no) +PYQT_ROOT=$PYQTDIR +PYQT_INCLUDES="-I$PYQT_SIPS" +PYQT_LIBS="-L$PYQTDIR -lqtcmodule" + +AC_CHECK_FILES($PYQTDIR/qt.py $PYQTDIR/qt/qt.py $PYQTDIR/lib/qt.py,pyqt_ok=yes,pyqt_ok=no) if test "x$pyqt_ok" = xno ; then - AC_MSG_RESULT(no) - AC_MSG_WARN(pyqt not found) + AC_MSG_WARN(qt.py not found) else AC_CHECK_FILE("$PYQTDIR/libqtcmodule.so",pyqt_ok=yes,pyqt_ok=no) - if test "x$pyqt_ok" = xno ; then - AC_MSG_RESULT(no) - AC_MSG_WARN(pyqt not found) - else + if test "x$pyqt_ok" = xyes ; then PYQT_ROOT=$PYQTDIR PYQT_LIBS="-L$PYQTDIR -lqtcmodule" fi - AC_CHECK_FILE("$PYQT_SIPS/copying.sip",pyqt_ok=yes,pyqt_ok=no) if test "x$pyqt_ok" = xno ; then - AC_MSG_RESULT(no) - AC_MSG_WARN(pyqt not found) - else - PYQT_INCLUDES="-I$PYQT_SIPS" + AC_CHECK_FILE("$PYQTDIR/lib/libqtcmodule.so",pyqt_ok=yes,pyqt_ok=no) + if test "x$pyqt_ok" = xyes ; then + PYQT_ROOT=$PYQTDIR + PYQT_LIBS="-L$PYQTDIR/lib -lqtcmodule" + fi fi - AC_SUBST(PYQT_ROOT) - AC_SUBST(PYQT_INCLUDES) - AC_SUBST(PYQT_LIBS) - - AC_MSG_RESULT(yes) + AC_CHECK_FILE("$PYQT_SIPS/copying.sip",pyqt_ok=$pyqt_ok,pyqt_ok=no) + if test "x$pyqt_ok" = xyes ; then + PYQT_INCLUDES="-I$PYQT_SIPS" + fi fi -PYQT_ROOT=$PYQTDIR -PYQT_INCLUDES="-I$PYQT_SIPS" -PYQT_LIBS="-L$PYQTDIR -lqtcmodule" - AC_SUBST(PYQT_ROOT) AC_SUBST(PYQT_INCLUDES) AC_SUBST(PYUIC) AC_SUBST(PYQT_SIPS) AC_SUBST(PYQT_LIBS) - - AC_MSG_RESULT(for pyqt: $pyqt_ok) fi diff --git a/salome_adm/unix/config_files/check_sip.m4 b/salome_adm/unix/config_files/check_sip.m4 index d66f84e6e..feecb0dde 100644 --- a/salome_adm/unix/config_files/check_sip.m4 +++ b/salome_adm/unix/config_files/check_sip.m4 @@ -44,12 +44,13 @@ else if test "x$sip_vers" = "xnew" then - if test -z ${SIPDIR}/include ; then + if test -d ${SIPDIR}/include ; then sip_ok=yes SIP_ROOT="$SIPDIR" SIP_INCLUDES="${PYTHON_INCLUDES} -I${SIPDIR}/include" SIP_LIBS="-L${SIPDIR}/lib -lsip" else + sip_ok=yes SIP_ROOT="$SIPDIR" SIP_INCLUDES="-I${SIPDIR}" SIP_LIBS="-L${SIPDIR} -lsip" diff --git a/src/Container/Makefile.in b/src/Container/Makefile.in index fdf28da44..87f372867 100644 --- a/src/Container/Makefile.in +++ b/src/Container/Makefile.in @@ -53,7 +53,7 @@ BIN_SERVER_IDL = SALOME_Component.idl CPPFLAGS+= $(PYTHON_INCLUDES) -LDFLAGS+= -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification -lSalomeLoggerServer +LDFLAGS+= -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification -lSALOMELocalTrace LIBS += -Xlinker -export-dynamic $(PYTHON_LIBS) diff --git a/src/Container/SALOME_Container.cxx b/src/Container/SALOME_Container.cxx index ce8c05628..77a06b9de 100644 --- a/src/Container/SALOME_Container.cxx +++ b/src/Container/SALOME_Container.cxx @@ -26,194 +26,202 @@ // Module : SALOME // $Header$ -using namespace std; -using namespace std; #include -# include "Utils_ORB_INIT.hxx" -# include "Utils_SINGLETON.hxx" +#include "Utils_ORB_INIT.hxx" +#include "Utils_SINGLETON.hxx" #include "SALOME_NamingService.hxx" #include "SALOME_Container_i.hxx" #include #include #include "utilities.h" +using namespace std; -//#define CHECKTIME #ifdef CHECKTIME #include #endif #include -static PyMethodDef MethodPyVoidMethod[] = { - { NULL, NULL } -}; +static PyMethodDef MethodPyVoidMethod[] = + { + { NULL, NULL } + }; int main(int argc, char* argv[]) { INFOS_COMPILATION; BEGIN_OF(argv[0]) - Py_Initialize() ; + Py_Initialize() ; PySys_SetArgv( argc , argv ) ; Py_InitModule( "InitPyRunMethod" , MethodPyVoidMethod ) ; - try { + try + { - // Initialise the ORB. -// CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - CORBA::ORB_var &orb = init( argc , argv ) ; + // Initialise the ORB. + ORB_INIT &init = *SINGLETON_::Instance() ; + ASSERT(SINGLETON_::IsAlreadyExisting()) ; + CORBA::ORB_var &orb = init( argc , argv ) ; - // Obtain a reference to the root POA. - // obtain the root poa manager - // - 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; - PortableServer::POA_var root_poa; - CORBA::Object_var theObj; - CORBA::Object_var obj; - CORBA::Object_var object; - SALOME_Logger::Logger_var log; - SALOME_NamingService &naming = *SINGLETON_::Instance() ; - int CONTAINER=0; - const char * Env = getenv("USE_LOGGER"); - int EnvL =0; - if ((Env!=NULL) && (strlen(Env))) - EnvL=1; - - CosNaming::Name name; - name.length(1); - name[0].id=CORBA::string_dup("Logger"); - PortableServer::POAManager_var pman; - for (int i = 1; i<=NumberOfTries; i++){ - if (i!=1) - a=nanosleep(&ts_req,&ts_rem); - try{ - obj = orb->resolve_initial_references("RootPOA"); - if(!CORBA::is_nil(obj)) - root_poa = PortableServer::POA::_narrow(obj); - if(!CORBA::is_nil(root_poa)) - pman = root_poa->the_POAManager(); - 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& ) + // Obtain a reference to the root POA. + // obtain the root poa manager + // + 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; + PortableServer::POA_var root_poa; + CORBA::Object_var theObj; + CORBA::Object_var obj; + CORBA::Object_var object; + SALOME_NamingService &naming = *SINGLETON_::Instance() ; + int CONTAINER=0; + const char * Env = getenv("USE_LOGGER"); + int EnvL =0; + if ((Env!=NULL) && (strlen(Env))) + EnvL=1; + + CosNaming::Name name; + name.length(1); + name[0].id=CORBA::string_dup("Logger"); + PortableServer::POAManager_var pman; + for (int i = 1; i<=NumberOfTries; i++) { - MESSAGE( "Container: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ) + if (i!=1) + a=nanosleep(&ts_req,&ts_rem); + try + { + obj = orb->resolve_initial_references("RootPOA"); + if(!CORBA::is_nil(obj)) + root_poa = PortableServer::POA::_narrow(obj); + if(!CORBA::is_nil(root_poa)) + pman = root_poa->the_POAManager(); + 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& ) + { + MESSAGE( "Container: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); } - if(!CORBA::is_nil(inc)) { - MESSAGE( "Container: Naming Service was found" ) - if(EnvL==1){ - for(int j=1; j<=NumberOfTries; j++){ - if (j!=1) - a=nanosleep(&ts_req, &ts_rem); - try{ - object = inc->resolve(name); - } - catch(CosNaming::NamingContext::NotFound){ MESSAGE( "Container: Logger Server wasn't found" ) } - catch(...){ MESSAGE( "Container: Unknown exception" ) } - if (!CORBA::is_nil(object)) - log = SALOME_Logger::Logger::_narrow(object); - if (!CORBA::is_nil(log)){ - MESSAGE( "Container: Logger Server was found" ) - log->ping(); - CONTAINER=1; - break; - } - }} - } - if ((CONTAINER==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) + if(!CORBA::is_nil(inc)) + { + MESSAGE( "Container: Naming Service was found" ); + if(EnvL==1) + { + for(int j=1; j<=NumberOfTries; j++) + { + if (j!=1) + a=nanosleep(&ts_req, &ts_rem); + try + { + object = inc->resolve(name); + } + catch(CosNaming::NamingContext::NotFound) + { + MESSAGE( "Container: Logger Server wasn't found" ); + } + catch(...) + { + MESSAGE( "Container: Unknown exception" ); + } + if (!CORBA::is_nil(object)) + { + MESSAGE( "Container: Logger Server was found" ); + CONTAINER=1; + break; + } + } + } + } + if ((CONTAINER==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) break; - } + } - // - // define policy objects - PortableServer::ImplicitActivationPolicy_var implicitActivation = - root_poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION) ; + // define policy objects + PortableServer::ImplicitActivationPolicy_var implicitActivation = + root_poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION) ; - // default = NO_IMPLICIT_ACTIVATION - PortableServer::ThreadPolicy_var threadPolicy = - root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL) ; - // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL + // default = NO_IMPLICIT_ACTIVATION + PortableServer::ThreadPolicy_var threadPolicy = + root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL) ; + // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL - // create policy list - CORBA::PolicyList policyList; - policyList.length(2); - policyList[0] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitActivation) ; - policyList[1] = PortableServer::ThreadPolicy::_duplicate(threadPolicy) ; - - // create the child POA - PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil() ; - PortableServer::POA_var factory_poa = - root_poa->create_POA("factory_poa", pman, policyList) ; + // create policy list + CORBA::PolicyList policyList; + policyList.length(2); + policyList[0] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitActivation) ; + policyList[1] = PortableServer::ThreadPolicy::_duplicate(threadPolicy) ; + + // create the child POA + PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil() ; + PortableServer::POA_var factory_poa = + root_poa->create_POA("factory_poa", pman, policyList) ; //with nil_mgr instead of pman, a new POA manager is created with the new POA - // destroy policy objects - implicitActivation->destroy() ; - threadPolicy->destroy() ; + // destroy policy objects + implicitActivation->destroy() ; + threadPolicy->destroy() ; - char *containerName = ""; - if (argc >1) - { - containerName = argv[1] ; - } + char *containerName = ""; + if (argc >1) + { + containerName = argv[1] ; + } - Engines_Container_i * myContainer - = new Engines_Container_i(orb, factory_poa, containerName , argc , argv ); + Engines_Container_i * myContainer + = new Engines_Container_i(orb, factory_poa, containerName , argc , argv ); -// Engines_Container_i * myContainer -// = new Engines_Container_i(string(argv[1]),string(argv[2]), orb, factory_poa); + // Engines_Container_i * myContainer + // = new Engines_Container_i(string(argv[1]),string(argv[2]), orb, factory_poa); - // use naming service -// myContainer->_NS.init_orb(orb); -// Engines::Container_ptr pCont = Engines::Container::_narrow(myContainer->_this()); -// myContainer->_NS.Register(pCont, argv[2]); + // use naming service + // myContainer->_NS.init_orb(orb); + // Engines::Container_ptr pCont = Engines::Container::_narrow(myContainer->_this()); + // myContainer->_NS.Register(pCont, argv[2]); - pman->activate(); + pman->activate(); #ifdef CHECKTIME - Utils_Timer timer; - timer.Start(); - timer.Stop(); - MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); - timer.ShowAbsolute(); + Utils_Timer timer; + timer.Start(); + timer.Stop(); + MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); + timer.ShowAbsolute(); #endif - orb->run(); + orb->run(); - orb->destroy(); - } + orb->destroy(); + } catch(CORBA::SystemException&) - { - INFOS("Caught CORBA::SystemException.") - } + { + INFOS("Caught CORBA::SystemException.") + } catch(PortableServer::POA::WrongPolicy&) - { - INFOS("Caught CORBA::WrongPolicyException.") - } + { + INFOS("Caught CORBA::WrongPolicyException.") + } catch(PortableServer::POA::ServantAlreadyActive&) - { - INFOS("Caught CORBA::ServantAlreadyActiveException") - } + { + INFOS("Caught CORBA::ServantAlreadyActiveException") + } catch(CORBA::Exception&) - { - INFOS("Caught CORBA::Exception.") - } + { + INFOS("Caught CORBA::Exception.") + } catch(...) - { - INFOS("Caught unknown exception.") - } + { + INFOS("Caught unknown exception.") + } END_OF(argv[0]); } 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/DataTypeCatalog/Makefile.in b/src/DataTypeCatalog/Makefile.in index 1017cafe0..5759b3b46 100644 --- a/src/DataTypeCatalog/Makefile.in +++ b/src/DataTypeCatalog/Makefile.in @@ -54,6 +54,6 @@ BIN_SERVER_IDL = SALOME_DataTypeCatalog.idl CPPFLAGS+= $(QT_MT_INCLUDES) CXXFLAGS+= -LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSalomeLoggerServer +LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx index 95c4ce6a1..a29401c51 100644 --- a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx +++ b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx @@ -26,120 +26,132 @@ // Module : SALOME // $Header$ -using namespace std; #include #include "SALOME_NamingService.hxx" #include "SALOME_DataTypeCatalog_impl.hxx" #include "utilities.h" -# include "Utils_SINGLETON.hxx" +#include "Utils_SINGLETON.hxx" +using namespace std; + int main(int argc,char **argv) { - try { - CosNaming::NamingContext_var _rootContext, catalogContext; - // initialize the ORB - CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv); - // initialize POA - // - 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; - PortableServer::POA_var poa; - CORBA::Object_var theObj; - CORBA::Object_var obj; - CORBA::Object_var object; - SALOME_Logger::Logger_var log; - int DATA_TYPE_CATALOG=0; - const char * Env = getenv("USE_LOGGER"); - int EnvL =0; - if ((Env!=NULL) && (strlen(Env))) - EnvL=1; - CosNaming::Name name; - name.length(1); - name[0].id=CORBA::string_dup("Logger"); - PortableServer::POAManager_var mgr; + try + { + CosNaming::NamingContext_var _rootContext, catalogContext; + // initialize the ORB + CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv); + // initialize POA + // + 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; + PortableServer::POA_var poa; + CORBA::Object_var theObj; + CORBA::Object_var obj; + CORBA::Object_var object; + int DATA_TYPE_CATALOG=0; + const char * Env = getenv("USE_LOGGER"); + int EnvL =0; + if ((Env!=NULL) && (strlen(Env))) + EnvL=1; + CosNaming::Name name; + name.length(1); + name[0].id=CORBA::string_dup("Logger"); + PortableServer::POAManager_var mgr; - for (int i = 1; i<=NumberOfTries; i++){ - if (i!=1) - a=nanosleep(&ts_req,&ts_rem); - try{ - obj = orb->resolve_initial_references("RootPOA"); - if(!CORBA::is_nil(obj)) - poa = PortableServer::POA::_narrow(obj); - if(!CORBA::is_nil(poa)) - mgr = poa->the_POAManager(); - 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& ) - { - MESSAGE( "Data Type Catalog: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ) - } - if(!CORBA::is_nil(inc)) { - MESSAGE( "Data Type Catalog: Naming Service was found" ) - if(EnvL==1){ - CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ; - SALOME_NamingService &NS = *SINGLETON_::Instance() ; - NS.init_orb( orb1 ) ; - for(int j=1; j<=NumberOfTries; j++){ - if (j!=1) - a=nanosleep(&ts_req, &ts_rem); - try{ - object = inc->resolve(name);} - catch(CosNaming::NamingContext::NotFound){ MESSAGE( "Data Type Catalog: Logger Server wasn't found" ) } - catch(...){ MESSAGE( "Data Type Catalog: Unknown exception" ) } - if (!CORBA::is_nil(object)) - log = SALOME_Logger::Logger::_narrow(object); - if (!CORBA::is_nil(log)){ - MESSAGE( "Data Type Catalog: Logger Server was found" ) - log->ping(); - DATA_TYPE_CATALOG=1; - break; + for (int i = 1; i<=NumberOfTries; i++) + { + if (i!=1) + a=nanosleep(&ts_req,&ts_rem); + try + { + obj = orb->resolve_initial_references("RootPOA"); + if(!CORBA::is_nil(obj)) + poa = PortableServer::POA::_narrow(obj); + if(!CORBA::is_nil(poa)) + mgr = poa->the_POAManager(); + 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& ) + { + MESSAGE( "Data Type Catalog: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); } + if(!CORBA::is_nil(inc)) + { + MESSAGE( "Data Type Catalog: Naming Service was found" ); + if(EnvL==1) + { + CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ; + SALOME_NamingService &NS = *SINGLETON_::Instance() ; + NS.init_orb( orb1 ) ; + for(int j=1; j<=NumberOfTries; j++) + { + if (j!=1) + a=nanosleep(&ts_req, &ts_rem); + try + { + object = inc->resolve(name); + } + catch(CosNaming::NamingContext::NotFound) + { + MESSAGE( "Data Type Catalog: Logger Server wasn't found" ); + } + catch(...) + { + MESSAGE( "Data Type Catalog: Unknown exception" ); + } + if (!CORBA::is_nil(object)) + { + MESSAGE( "Data Type Catalog: Logger Server was found" ); + DATA_TYPE_CATALOG=1; + break; + } - }} - } - if ((DATA_TYPE_CATALOG==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) - break; + } + } } + if ((DATA_TYPE_CATALOG==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) + break; + } - // - // Active catalog + // Active catalog - SALOME_DataTypeCatalogImpl* Catalogue_i = new SALOME_DataTypeCatalogImpl(argc, argv); - poa->activate_object (Catalogue_i); + SALOME_DataTypeCatalogImpl* Catalogue_i = new SALOME_DataTypeCatalogImpl(argc, argv); + poa->activate_object (Catalogue_i); - mgr->activate(); + mgr->activate(); - CORBA::Object_ptr myCata = Catalogue_i->_this(); + CORBA::Object_ptr myCata = Catalogue_i->_this(); - // initialise Naming Service - SALOME_NamingService *_NS; - _NS = new SALOME_NamingService(orb); - // register Catalog in Naming Service - _NS->Register(myCata ,"/Kernel/DataTypeCatalog"); + // initialise Naming Service + SALOME_NamingService *_NS; + _NS = new SALOME_NamingService(orb); + // register Catalog in Naming Service + _NS->Register(myCata ,"/Kernel/DataTypeCatalog"); - MESSAGE("Running DataType Catalog Server.") + MESSAGE("Running DataType Catalog Server.") - orb->run(); + orb->run(); - poa->destroy(1,1); + poa->destroy(1,1); - } - catch(CORBA::SystemException&) { + } + catch(CORBA::SystemException&) { INFOS("Caught CORBA::SystemException.") - } - catch(CORBA::Exception&) { + } + catch(CORBA::Exception&) { INFOS("Caught CORBA::Exception.") - } + } return 0; } diff --git a/src/LifeCycleCORBA/Makefile.in b/src/LifeCycleCORBA/Makefile.in index 6f4a461ea..33ee1ac81 100644 --- a/src/LifeCycleCORBA/Makefile.in +++ b/src/LifeCycleCORBA/Makefile.in @@ -51,7 +51,7 @@ BIN_SRC = BIN_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl \ SALOME_ModuleCatalog.idl -LDFLAGS += -lSalomeNS -lOpUtil -lSalomeLoggerServer +LDFLAGS += -lSalomeNS -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/Loader/Makefile.in b/src/Loader/Makefile.in index dd736d4ed..6caf10e2c 100644 --- a/src/Loader/Makefile.in +++ b/src/Loader/Makefile.in @@ -31,7 +31,7 @@ BIN_CLIENT_IDL = SALOME_Session.idl \ CPPFLAGS+=$(QT_MT_INCLUDES) CXXFLAGS+=$(OCC_CXXFLAGS) -LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSalomeLoggerServer +LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/Loader/SALOME_Session_Loader.cxx b/src/Loader/SALOME_Session_Loader.cxx index acd0ea377..3aff04564 100644 --- a/src/Loader/SALOME_Session_Loader.cxx +++ b/src/Loader/SALOME_Session_Loader.cxx @@ -13,6 +13,7 @@ using namespace std; #include #include CORBA_CLIENT_HEADER(SALOME_Session) +#include CORBA_CLIENT_HEADER(Logger) #include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" 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 ed8d2f4ec..f35650e42 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -32,10 +32,17 @@ VPATH=.:@srcdir@ @COMMENCE@ -SUBDIRS = MSG2QM Logger Utils PatchQt NamingService Registry ModuleCatalog DataTypeCatalog \ - RessourcesCatalog Notification NOTIFICATION_SWIG Container TestContainer LifeCycleCORBA \ - HDFPersist VTKFilter OBJECT TOOLSDS SALOMEDS SALOMEGUI Plot2d VTKViewer OCCViewer SUPERVGraph \ - Session SALOME_SWIG TOOLSGUI SALOME_PY RegistryDisplay ModuleGenerator SALOME_PYQT Loader +SUBDIRS = MSG2QM SALOMELocalTrace Logger SALOMELogger Utils PatchQt \ + GenericObj NamingService Registry \ + ModuleCatalog DataTypeCatalog RessourcesCatalog \ + Notification NOTIFICATION_SWIG \ + Container TestContainer LifeCycleCORBA HDFPersist \ + VTKFilter OBJECT \ + TOOLSDS SALOMEDS \ + SALOMEGUI Plot2d VTKViewer OCCViewer \ + SUPERVGraph \ + Session SALOME_SWIG TOOLSGUI SALOME_PY \ + RegistryDisplay ModuleGenerator SALOME_PYQT Loader ifeq (@WITHMPICH@,yes) SUBDIRS+= MPIContainer diff --git a/src/ModuleCatalog/Makefile.in b/src/ModuleCatalog/Makefile.in index c61ad8487..97a1d9816 100644 --- a/src/ModuleCatalog/Makefile.in +++ b/src/ModuleCatalog/Makefile.in @@ -57,6 +57,6 @@ BIN_SERVER_IDL = SALOME_ModuleCatalog.idl CPPFLAGS+= $(QT_MT_INCLUDES) CXXFLAGS+= -ftemplate-depth-42 -LDFLAGS+= $(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSalomeLoggerServer +LDFLAGS+= $(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx index 65d7566b5..c206cc846 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx @@ -24,141 +24,147 @@ // File : SALOME_ModuleCatalog_Server.cxx // Module : SALOME -using namespace std; /* $Header$ */ + #include #include "SALOME_NamingService.hxx" #include "SALOME_ModuleCatalog_impl.hxx" #include "utilities.h" -# include "Utils_SINGLETON.hxx" +#include "Utils_SINGLETON.hxx" -//#define CHECKTIME -#ifdef CHECKTIME -#include -#endif - -//#define CHECKTIME #ifdef CHECKTIME #include #endif +using namespace std; int main(int argc,char **argv) { - try { - CosNaming::NamingContext_var _rootContext, catalogContext; + try + { + CosNaming::NamingContext_var _rootContext, catalogContext; - // initialize the ORB + // initialize the ORB - CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv); + CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv); - // initialize POA - // - 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; - PortableServer::POA_var poa; - CORBA::Object_var theObj; - CORBA::Object_var obj; - CORBA::Object_var object; - SALOME_Logger::Logger_var log; - int MODULE_CATALOG=0; - const char * Env = getenv("USE_LOGGER"); - int EnvL =0; - if ((Env!=NULL) && (strlen(Env))) - EnvL=1; - CosNaming::Name name; - name.length(1); - name[0].id=CORBA::string_dup("Logger"); - PortableServer::POAManager_var mgr; - for (int i = 1; i<=NumberOfTries; i++){ - if (i!=1) - a=nanosleep(&ts_req,&ts_rem); - try{ - obj = orb->resolve_initial_references("RootPOA"); - if(!CORBA::is_nil(obj)) - poa = PortableServer::POA::_narrow(obj); - if(!CORBA::is_nil(poa)) - mgr = poa->the_POAManager(); - if(!CORBA::is_nil(orb)) - theObj = orb->resolve_initial_references("NameService"); - } - catch( CORBA::COMM_FAILURE& ) - { - MESSAGE( "Module Catalog Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ) - } - if (!CORBA::is_nil(theObj)){ - inc = CosNaming::NamingContext::_narrow(theObj); - if(!CORBA::is_nil(inc)) { - MESSAGE( "Module Catalog Server: Naming Service was found" ) - if(EnvL==1){ - CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ; - SALOME_NamingService &NS = *SINGLETON_::Instance() ; - NS.init_orb( orb1 ) ; - for(int j=1; j<=NumberOfTries; j++){ - if (j!=1) - a=nanosleep(&ts_req, &ts_rem); - try{ - object = inc->resolve(name);} - catch(CosNaming::NamingContext::NotFound){ MESSAGE( "Logger Server wasn't found" ) } - catch(...){ MESSAGE( "Module Catalog Server: Unknown exception" ) } - if (!CORBA::is_nil(object)) - log = SALOME_Logger::Logger::_narrow(object); - if (!CORBA::is_nil(log)){ - MESSAGE( "Module Catalog Server: Logger Server was found" ) - log->ping(); - MODULE_CATALOG=1; - break; - } - }} - }} - if ((MODULE_CATALOG==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) - break; - } + // initialize POA + // + 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; + PortableServer::POA_var poa; + CORBA::Object_var theObj; + CORBA::Object_var obj; + CORBA::Object_var object; + int MODULE_CATALOG=0; + const char * Env = getenv("USE_LOGGER"); + int EnvL =0; + if ((Env!=NULL) && (strlen(Env))) + EnvL=1; + CosNaming::Name name; + name.length(1); + name[0].id=CORBA::string_dup("Logger"); + PortableServer::POAManager_var mgr; + for (int i = 1; i<=NumberOfTries; i++) + { + if (i!=1) + a=nanosleep(&ts_req,&ts_rem); + try + { + obj = orb->resolve_initial_references("RootPOA"); + if(!CORBA::is_nil(obj)) + poa = PortableServer::POA::_narrow(obj); + if(!CORBA::is_nil(poa)) + mgr = poa->the_POAManager(); + if(!CORBA::is_nil(orb)) + theObj = orb->resolve_initial_references("NameService"); + } + catch( CORBA::COMM_FAILURE& ) + { + MESSAGE( "Module Catalog Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); + } + if (!CORBA::is_nil(theObj)) + { + inc = CosNaming::NamingContext::_narrow(theObj); + if(!CORBA::is_nil(inc)) + { + MESSAGE( "Module Catalog Server: Naming Service was found" ); + if(EnvL==1) + { + CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ; + SALOME_NamingService &NS = *SINGLETON_::Instance() ; + NS.init_orb( orb1 ) ; + for(int j=1; j<=NumberOfTries; j++) + { + if (j!=1) + a=nanosleep(&ts_req, &ts_rem); + try{ + object = inc->resolve(name);} + catch(CosNaming::NamingContext::NotFound) + { + MESSAGE( "Logger Server wasn't found" ); + } + catch(...) + { + MESSAGE( "Module Catalog Server: Unknown exception" ) ; + } + if (!CORBA::is_nil(object)) + { + MESSAGE( "Module Catalog Server: Logger Server was found" ); + MODULE_CATALOG=1; + break; + } + } + } + } + } + if ((MODULE_CATALOG==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) + break; + } - // - // Active catalog + // Active catalog - SALOME_ModuleCatalogImpl* Catalogue_i = new SALOME_ModuleCatalogImpl(argc, argv); - poa->activate_object (Catalogue_i); + SALOME_ModuleCatalogImpl* Catalogue_i = new SALOME_ModuleCatalogImpl(argc, argv); + poa->activate_object (Catalogue_i); - mgr->activate(); + mgr->activate(); - CORBA::Object_ptr myCata = Catalogue_i->_this(); + CORBA::Object_ptr myCata = Catalogue_i->_this(); - // initialise Naming Service - SALOME_NamingService *_NS; - _NS = new SALOME_NamingService(orb); - // register Catalog in Naming Service - _NS->Register(myCata ,"/Kernel/ModulCatalog"); + // initialise Naming Service + SALOME_NamingService *_NS; + _NS = new SALOME_NamingService(orb); + // register Catalog in Naming Service + _NS->Register(myCata ,"/Kernel/ModulCatalog"); - MESSAGE("Running CatalogServer."); + MESSAGE("Running CatalogServer."); #ifdef CHECKTIME - Utils_Timer timer; - timer.Start(); - timer.Stop(); - MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); - timer.ShowAbsolute(); + Utils_Timer timer; + timer.Start(); + timer.Stop(); + MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); + timer.ShowAbsolute(); #endif - orb->run(); + orb->run(); - poa->destroy(1,1); + poa->destroy(1,1); - } - catch(CORBA::SystemException&) { + } + catch(CORBA::SystemException&) { INFOS("Caught CORBA::SystemException.") - } - catch(CORBA::Exception&) { + } + catch(CORBA::Exception&) { INFOS("Caught CORBA::Exception.") - } + } return 0; } diff --git a/src/ModuleGenerator/IDLparser.py b/src/ModuleGenerator/IDLparser.py index 44af77590..1743563c6 100644 --- a/src/ModuleGenerator/IDLparser.py +++ b/src/ModuleGenerator/IDLparser.py @@ -29,15 +29,37 @@ import pdb from xml.sax.handler import * from omniidl import idlast, idltype, idlvisitor, idlutil, output -#values of this map are used in some nodes defenition -common_data={"AUTHOR" : "", - "ICON" : "", - "VERSION" : "", - "COMP_TYPE": "", - "COMP_NAME": "", - "COMP_MULT": "1" +# parameters not found in IDL file, user's specified in optional parameters +common_data={"AUTHOR" : "", + "ICON" : "", + "VERSION" : "", + "COMP_TYPE" : "", + "COMP_NAME" : "", + "COMP_UNAME" : "", + "COMP_MULT" : "" } +nb_components = 0 + +#-------------------------------------------------- +# extract value of from list +# it's proposed that the matching item +# looks like =, for example, +# catalog=/tmp/myxml.xml +#-------------------------------------------------- +def getParamValue( param_name, default_value, args ): + pattern=param_name+"=" + + res = default_value #initial value + for opt in args: + s = re.compile(pattern).search(opt) + if s: + res = opt[s.end():] + break #found + + return res + + #-------------------------------------------------- # print error message #-------------------------------------------------- @@ -168,7 +190,7 @@ class Tree: #-------------------------------------------------- class inParameter(Tree): - def __init__(self, name=None, type='', comment=''): + def __init__(self, name=None, type='', comment='unknown'): Tree.__init__(self, 'inParameter') if name is None: return @@ -186,7 +208,7 @@ class inParameter(Tree): #-------------------------------------------------- class outParameter(Tree): - def __init__(self, name=None, type='', comment = ''): + def __init__(self, name=None, type='', comment = 'unknown'): Tree.__init__(self, 'outParameter') if name is None: return @@ -205,7 +227,7 @@ class outParameter(Tree): #-------------------------------------------------- class Service(Tree): - def __init__(self, name=None): + def __init__(self, name=None, comment = 'unknown'): Tree.__init__(self, 'component-service') if name is None: return @@ -213,7 +235,7 @@ class Service(Tree): self.addNamedChild('service-name', name) self.addNamedChild('service-author',common_data["AUTHOR"]) self.addNamedChild('service-version',common_data["VERSION"]) - self.addNamedChild('service-comment') + self.addNamedChild('service-comment', comment) self.addNamedChild('service-by-default', "0") self.addNamedChild('inParameter-list') self.addNamedChild('outParameter-list') @@ -304,14 +326,14 @@ class Service(Tree): #-------------------------------------------------- class Interface(Tree): - def __init__(self, name=None): + def __init__(self, name=None, comment='unknown'): Tree.__init__(self) if name is None: return self.addNamedChild('component-interface-name', name) - self.addNamedChild('component-interface-comment'); + self.addNamedChild('component-interface-comment', comment); self.addNamedChild('component-service-list') def createService(self, name): @@ -362,18 +384,17 @@ class Interface(Tree): # implements Component tree #-------------------------------------------------- class Component(Tree): - def __init__(self, name=None): + def __init__(self): Tree.__init__(self, 'component') - - if name is None: return - - self.addNamedChild('component-name', name) - self.addNamedChild('component-type',common_data["COMP_TYPE"]) - self.addNamedChild('component-author',common_data["AUTHOR"]) - self.addNamedChild('component-version',common_data["VERSION"]) - self.addNamedChild('component-comment') + + self.addNamedChild('component-name', common_data["COMP_NAME"]) + self.addNamedChild('component-username', common_data["COMP_UNAME"]) + self.addNamedChild('component-type', common_data["COMP_TYPE"]) + self.addNamedChild('component-author', common_data["AUTHOR"]) + self.addNamedChild('component-version', common_data["VERSION"]) + self.addNamedChild('component-comment', 'unknown') self.addNamedChild('component-multistudy', common_data["COMP_MULT"]) - self.addNamedChild('component-icone',common_data["ICON"]) + self.addNamedChild('component-icone', common_data["ICON"]) self.addNamedChild('constraint') self.addNamedChild('component-interface-list') @@ -387,41 +408,17 @@ class Component(Tree): return i def merge(self, C): - ext=C.getChild('component-author') - int=self.getChild('component-author') - if int is not None and ext is not None and len(ext.content): - int.content = ext.content - - ext=C.getChild('component-type') - int=self.getChild('component-type') - if int is not None and ext is not None and len(ext.content): - int.content = ext.content - - ext=C.getChild('component-icone') - int=self.getChild('component-icone') - if int is not None and ext is not None and len(ext.content): - int.content = ext.content - - ext=C.getChild('component-version') - int=self.getChild('component-version') - if int is not None and ext is not None and len(ext.content): - int.content = ext.content - - ext=C.getChild('component-comment') - int=self.getChild('component-comment') - if int is not None and ext is not None and len(ext.content): - int.content = ext.content - - ext=C.getChild('component-multistudy') - int=self.getChild('component-multistudy') - if int is not None and ext is not None and len(ext.content): - int.content = ext.content - - ext=C.getChild('constraint') - int=self.getChild('constraint') - if int is not None and ext is not None and len(ext.content): - int.content = ext.content - + + for i in ['component-username', 'component-author', + 'component-type', 'component-icone', 'component-version', + 'component-comment', 'component-multistudy', 'constraint']: + ext = C.getChild(i) + int = self.getChild(i) + if int is None: + int = ext + elif ext is not None and len(ext.content): + int.content = ext.content + L_ext = C.getChild('component-interface-list') L_int = self.getChild('component-interface-list') if L_ext is None or L_int is None: @@ -602,8 +599,7 @@ class ModuleCatalogVisitor (idlvisitor.AstVisitor): if ((s[0] == "Engines") & (s[1] == "Component")): self.EngineType = 1; break - if common_data["COMP_NAME"] : Comp = Component(common_data["COMP_NAME"]) - else : Comp = Component(node.identifier()) + Comp = Component() self.currentInterface = Comp.createInterface(node.identifier()) @@ -612,6 +608,8 @@ class ModuleCatalogVisitor (idlvisitor.AstVisitor): c.accept(self) if (self.EngineType): + global nb_components + nb_components = nb_components + 1 self.catalog.mergeComponent(Comp) self.EngineType = 0 @@ -648,52 +646,29 @@ class ModuleCatalogVisitor (idlvisitor.AstVisitor): self.currentService.createOutParameter \ (node.identifier(), self.currentType) -#-------------------------------------------------- -# extract value of from list -# it's proposed that the matching item -# looks like =, for example, -# catalog=/tmp/myxml.xml -#-------------------------------------------------- -def getParamValue( param_name, args ): - pattern="^"+param_name+"=" - - res = "" #initial value - for opt in args: - s = re.compile(pattern).search(opt) - if s: - res = opt[s.end():] - break #found - - return res - #-------------------------------------------------- # parse idl and store xml file #-------------------------------------------------- def run(tree, args): - CatalogFileName=getParamValue("catalog",args) - if CatalogFileName is None: - CatalogFileName = 'CatalogModulePersonnel.xml' + print args - if (re.compile(".*?.xml$").match(CatalogFileName, 1) is None): + CatalogFileName=getParamValue("catalog", "CatalogModulePersonnel.xml", args) + print CatalogFileName + if re.compile(".*?.xml$").match(CatalogFileName, 1) is None: CatalogFileName = CatalogFileName + '.xml' #========= Read parameters ====================== - common_data["ICON"] = getParamValue("icon",args) # get icon file - - common_data["AUTHOR"] = getParamValue("author",args) # get author name - if common_data["AUTHOR"] is None: common_data["AUTHOR"] = os.getenv("USER"); + common_data["ICON"] = getParamValue("icon", "", args) + common_data["AUTHOR"] = getParamValue("author", os.getenv("USER"), args) + common_data["VERSION"] = getParamValue("version", "1", args) + common_data["COMP_NAME"] = getParamValue("name", "", args) + common_data["COMP_UNAME"] = getParamValue("username", "", args) + common_data["COMP_TYPE"] = getParamValue("type", "OTHER", args) + common_data["COMP_MULT"] = getParamValue("multistudy", "1", args) + + print common_data - common_data["VERSION"] = getParamValue("version",args) # get version - - common_data["COMP_NAME"] = getParamValue("name",args) # get icon file - - val = getParamValue("type",args) # get icon file - if val: common_data["COMP_TYPE"] = val - - val = getParamValue("multistudy",args) # get icon file - if val : common_data["COMP_MULT"] = val - - remove_comp = getParamValue("remove", args) + remove_comp = getParamValue("remove", "", args) #================================================== @@ -701,9 +676,9 @@ def run(tree, args): print "Importing", CatalogFileName C = Catalog(CatalogFileName) else: - print "Warning : ",CatalogFileName, " was not found." + print "Creating ",CatalogFileName C = Catalog() - + print "Reading idl file" visitor = ModuleCatalogVisitor(C) @@ -735,5 +710,5 @@ def run(tree, args): if __name__ == "__main__": print - print "Usage : omniidl -bIDLparser -Wbcatalog=[,icon=][,version=][,author=][,name=][,multistudy=][,remove=component_name] " + print "Usage : omniidl -bIDLparser [-I]* -Wbcatalog=[,icon=][,version=][,author=][,name=][,username=][,multistudy=] " print 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/Notification/Makefile.in b/src/Notification/Makefile.in index 0da007a70..4d43c67a5 100644 --- a/src/Notification/Makefile.in +++ b/src/Notification/Makefile.in @@ -47,7 +47,7 @@ LIB_SRC = NOTIFICATION.cxx \ NOTIFICATION_Supplier.cxx \ NOTIFICATION_Consumer.cxx -LDFLAGS+= -lOpUtil +LDFLAGS+= -lOpUtil -lSALOMELocalTrace OMNIORB_IDLCXXFLAGS+= -Wbtp @CONCLUDE@ 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/Registry/Makefile.in b/src/Registry/Makefile.in index 823ac6241..5ff83cb1d 100644 --- a/src/Registry/Makefile.in +++ b/src/Registry/Makefile.in @@ -50,6 +50,6 @@ BIN = SALOME_Registry_Server BIN_SRC = RegistryService.cxx BIN_SERVER_IDL = SALOME_Registry.idl -LDFLAGS+= -lSalomeNS -lOpUtil -lSalomeLoggerServer +LDFLAGS+= -lSalomeNS -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/Registry/SALOME_Registry_Server.cxx b/src/Registry/SALOME_Registry_Server.cxx index e4aee0f7d..3e5a5b636 100644 --- a/src/Registry/SALOME_Registry_Server.cxx +++ b/src/Registry/SALOME_Registry_Server.cxx @@ -26,181 +26,189 @@ // Module : SALOME // $Header$ -using namespace std; -# include -# include -# include +#include +#include +#include extern "C" { # include } -# include "utilities.h" -# include "Utils_ORB_INIT.hxx" -# include "Utils_SINGLETON.hxx" -# include "Utils_SALOME_Exception.hxx" -# include "Utils_CommException.hxx" -# include "ServiceUnreachable.hxx" -# include "SALOME_NamingService.hxx" -# include "RegistryService.hxx" +#include "utilities.h" +#include "Utils_ORB_INIT.hxx" +#include "Utils_SINGLETON.hxx" +#include "Utils_SALOME_Exception.hxx" +#include "Utils_CommException.hxx" +#include "ServiceUnreachable.hxx" +#include "SALOME_NamingService.hxx" +#include "RegistryService.hxx" -//#define CHECKTIME #ifdef CHECKTIME #include #endif +using namespace std; int main( int argc , char **argv ) { - BEGIN_OF( argv[0] ) - INFOS_COMPILATION - SCRUTE(argc) - if( argc<3 ) + BEGIN_OF( argv[0] ) + INFOS_COMPILATION + SCRUTE(argc) + if( argc<3 ) + { + MESSAGE("you must provide the Salome session name when you call SALOME_Registry_Server") ; + throw CommException("you must provide the Salome session name when you call SALOME_Registry_Server") ; + } + const char *ptrSessionName=0 ; + + int k=0 ; + for ( k=1 ; k0) ; + const char *registryName = "Registry" ; + ORB_INIT &init = *SINGLETON_::Instance() ; + CORBA::ORB_var &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; + PortableServer::POA_var poa; + CORBA::Object_var theObj; + CORBA::Object_var obj; + CORBA::Object_var object; + SALOME_NamingService &naming = *SINGLETON_::Instance() ; + Registry::Components_var varComponents; + int REGISTRY=0; + const char * Env = getenv("USE_LOGGER"); + int EnvL =0; + if ((Env!=NULL) && (strlen(Env))) + EnvL=1; + CosNaming::Name name; + name.length(1); + name[0].id=CORBA::string_dup("Logger"); + PortableServer::POAManager_var manager; + for (int i = 1; i<=NumberOfTries; i++) + { + if (i!=1) + a=nanosleep(&ts_req,&ts_rem); + try + { + obj = orb->resolve_initial_references("RootPOA"); + if(!CORBA::is_nil(obj)) + poa = PortableServer::POA::_narrow(obj); + if(!CORBA::is_nil(poa)) + manager = poa->the_POAManager(); + 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& ) { - if( strcmp(argv[k],"--salome_session")==0 ) - { - ptrSessionName=argv[k+1] ; - break ; - } + MESSAGE( "Registry Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); } - ASSERT(ptrSessionName) ; - ASSERT(strlen( ptrSessionName )>0) ; - const char *registryName = "Registry" ; - ORB_INIT &init = *SINGLETON_::Instance() ; - CORBA::ORB_var &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; - PortableServer::POA_var poa; - CORBA::Object_var theObj; - CORBA::Object_var obj; - CORBA::Object_var object; - SALOME_Logger::Logger_var log; - SALOME_NamingService &naming = *SINGLETON_::Instance() ; - Registry::Components_var varComponents; - int REGISTRY=0; - const char * Env = getenv("USE_LOGGER"); - int EnvL =0; - if ((Env!=NULL) && (strlen(Env))) - EnvL=1; - CosNaming::Name name; - name.length(1); - name[0].id=CORBA::string_dup("Logger"); - PortableServer::POAManager_var manager; - for (int i = 1; i<=NumberOfTries; i++){ - if (i!=1) - a=nanosleep(&ts_req,&ts_rem); - try{ - obj = orb->resolve_initial_references("RootPOA"); - if(!CORBA::is_nil(obj)) - poa = PortableServer::POA::_narrow(obj); - if(!CORBA::is_nil(poa)) - manager = poa->the_POAManager(); - 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& ) + if(!CORBA::is_nil(inc)) + { + MESSAGE( "Registry Server: Naming Service was found" ); + if(EnvL==1) { - MESSAGE( "Registry Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ) - } - if(!CORBA::is_nil(inc)) { - MESSAGE( "Registry Server: Naming Service was found" ) - if(EnvL==1){ - for(int j=1; j<=NumberOfTries; j++){ + for(int j=1; j<=NumberOfTries; j++) + { if (j!=1) a=nanosleep(&ts_req, &ts_rem); - try{ - object = inc->resolve(name); - } - catch(CosNaming::NamingContext::NotFound){ MESSAGE( "Registry Server: Logger Server wasn't found" ) } - catch(...){ MESSAGE( "Registry Server: Unknown exception" ) } - + try + { + object = inc->resolve(name); + } + catch(CosNaming::NamingContext::NotFound) + { + MESSAGE( "Registry Server: Logger Server wasn't found" ); + } + catch(...) + { + MESSAGE( "Registry Server: Unknown exception" ); + } if (!CORBA::is_nil(object)) - log = SALOME_Logger::Logger::_narrow(object); - if (!CORBA::is_nil(log)){ - MESSAGE( "Registry Server: Logger Server was found" ) - log->ping(); - REGISTRY=1; - break; - } - }} - } - if ((REGISTRY==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) - break; - } - // - try - { - naming.init_orb( orb ) ; - RegistryService *ptrRegistry = SINGLETON_::Instance() ; - ptrRegistry->SessionName( ptrSessionName ) ; - varComponents = ptrRegistry->_this() ; - // The RegistryService must not already exist. + { + MESSAGE( "Module Catalog Server: Logger Server was found" ); + REGISTRY=1; + break; + } + } + } + } + if ((REGISTRY==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) + break; + } + + try + { + naming.init_orb( orb ) ; + RegistryService *ptrRegistry = SINGLETON_::Instance() ; + ptrRegistry->SessionName( ptrSessionName ) ; + varComponents = ptrRegistry->_this() ; + // The RegistryService must not already exist. - try - { - CORBA::Object_var pipo = naming.Resolve( registryName ) ; - if (CORBA::is_nil(pipo) ) throw ServiceUnreachable() ; - MESSAGE("RegistryService servant already existing" ) ; - exit( EXIT_FAILURE ) ; - } - catch( const ServiceUnreachable &ex ) - { - } - catch( const CORBA::Exception &exx ) - { - } - string absoluteName = string("/") + registryName; - naming.Register( varComponents , absoluteName.c_str() ) ; - MESSAGE("On attend les requetes des clients") ; - try - { - // Activation du POA - MESSAGE("Activation du POA") ; - manager->activate() ; + try + { + CORBA::Object_var pipo = naming.Resolve( registryName ) ; + if (CORBA::is_nil(pipo) ) throw ServiceUnreachable() ; + MESSAGE("RegistryService servant already existing" ) ; + exit( EXIT_FAILURE ) ; + } + catch( const ServiceUnreachable &ex ) + { + } + catch( const CORBA::Exception &exx ) + { + } + string absoluteName = string("/") + registryName; + naming.Register( varComponents , absoluteName.c_str() ) ; + MESSAGE("On attend les requetes des clients") ; + try + { + // Activation du POA + MESSAGE("Activation du POA") ; + manager->activate() ; - // Lancement de l'ORB - MESSAGE("Lancement de l'ORB") ; + // Lancement de l'ORB + MESSAGE("Lancement de l'ORB") ; #ifdef CHECKTIME - Utils_Timer timer; - timer.Start(); - timer.Stop(); - MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); - timer.ShowAbsolute(); + Utils_Timer timer; + timer.Start(); + timer.Stop(); + MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); + timer.ShowAbsolute(); #endif - orb->run() ; - } - catch( const CORBA::Exception &ex ) - { - MESSAGE("Erreur systeme") ; - return EXIT_FAILURE ; - } + orb->run() ; + } + catch( const CORBA::Exception &ex ) + { + MESSAGE("Erreur systeme") ; + return EXIT_FAILURE ; + } - } - catch( const SALOME_Exception &ex ) - { - MESSAGE( "Communication Error : " << ex.what() ) - return EXIT_FAILURE ; - } + } + catch( const SALOME_Exception &ex ) + { + MESSAGE( "Communication Error : " << ex.what() ) + return EXIT_FAILURE ; + } - END_OF( argv[0] ) ; - return 0 ; + END_OF( argv[0] ) ; + return 0 ; } 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/RessourcesCatalog/Makefile.in b/src/RessourcesCatalog/Makefile.in index a98eab8bf..c129dad04 100644 --- a/src/RessourcesCatalog/Makefile.in +++ b/src/RessourcesCatalog/Makefile.in @@ -54,7 +54,7 @@ BIN_SERVER_IDL = SALOME_RessourcesCatalog.idl CPPFLAGS+= $(QT_MT_INCLUDES) CXXFLAGS+= -LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSalomeLoggerServer +LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx index 827efd482..e9a16146c 100644 --- a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx @@ -26,117 +26,128 @@ // Module : SALOME // $Header$ -using namespace std; #include #include "SALOME_NamingService.hxx" #include "SALOME_RessourcesCatalog_impl.hxx" #include "utilities.h" -# include "Utils_SINGLETON.hxx" +#include "Utils_SINGLETON.hxx" +using namespace std; + int main(int argc,char **argv) { - try { - CosNaming::NamingContext_var _rootContext, catalogContext; + try + { + CosNaming::NamingContext_var _rootContext, catalogContext; - // initialize the ORB + // initialize the ORB - CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv); + CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv); - // initialize POA - // - 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; - PortableServer::POA_var poa; - CORBA::Object_var theObj; - CORBA::Object_var obj; - CORBA::Object_var object; - SALOME_Logger::Logger_var log; - SALOME_NamingService &naming = *SINGLETON_::Instance() ; - int RESSOURCES_CATALOG=0; - const char * Env = getenv("USE_LOGGER"); - int EnvL =0; - if ((Env!=NULL) && (strlen(Env))) - EnvL=1; - CosNaming::Name name; - name.length(1); - name[0].id=CORBA::string_dup("Logger"); - PortableServer::POAManager_var mgr; - for (int i = 1; i<=NumberOfTries; i++){ + // initialize POA + // + 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; + PortableServer::POA_var poa; + CORBA::Object_var theObj; + CORBA::Object_var obj; + CORBA::Object_var object; + SALOME_NamingService &naming = *SINGLETON_::Instance() ; + int RESSOURCES_CATALOG=0; + const char * Env = getenv("USE_LOGGER"); + int EnvL =0; + if ((Env!=NULL) && (strlen(Env))) + EnvL=1; + CosNaming::Name name; + name.length(1); + name[0].id=CORBA::string_dup("Logger"); + PortableServer::POAManager_var mgr; + for (int i = 1; i<=NumberOfTries; i++) + { if (i!=1) a=nanosleep(&ts_req,&ts_rem); - try{ - obj = orb->resolve_initial_references("RootPOA"); - if(!CORBA::is_nil(obj)) - poa = PortableServer::POA::_narrow(obj); - if(!CORBA::is_nil(poa)) - mgr = poa->the_POAManager(); - if(!CORBA::is_nil(orb)) - theObj = orb->resolve_initial_references("NameService"); - if (!CORBA::is_nil(theObj)) - inc = CosNaming::NamingContext::_narrow(theObj); + try + { + obj = orb->resolve_initial_references("RootPOA"); + if(!CORBA::is_nil(obj)) + poa = PortableServer::POA::_narrow(obj); + if(!CORBA::is_nil(poa)) + mgr = poa->the_POAManager(); + 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& ) { - MESSAGE( "Ressources Catalog: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ) + MESSAGE( "Ressources Catalog: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); + } + if(!CORBA::is_nil(inc)) + { + MESSAGE( "Ressources Catalog: Naming Service was found" ); + if(EnvL==1) + { + for(int j=1; j<=NumberOfTries; j++) + { + if (j!=1) + a=nanosleep(&ts_req, &ts_rem); + try{ + object = inc->resolve(name); + } + catch(CosNaming::NamingContext::NotFound) + { + MESSAGE( "Ressources Catalog: Logger Server wasn't found" ); + } + catch(...) + { + MESSAGE( "Ressources Catalog: Unknown exception" ); + } + if (!CORBA::is_nil(object)) + { + MESSAGE( "Ressources Catalog: Loger Server was found" ); + RESSOURCES_CATALOG=1; + break; + } + } } - if(!CORBA::is_nil(inc)) { - MESSAGE( "Ressources Catalog: Naming Service was found" ) - if(EnvL==1){ - for(int j=1; j<=NumberOfTries; j++){ - if (j!=1) - a=nanosleep(&ts_req, &ts_rem); - try{ - object = inc->resolve(name); - } - catch(CosNaming::NamingContext::NotFound){ MESSAGE( "Ressources Catalog: Logger Server wasn't found" ) } - catch(...){ MESSAGE( "Ressources Catalog: Unknown exception" ) } - if (!CORBA::is_nil(object)) - log = SALOME_Logger::Logger::_narrow(object); - if (!CORBA::is_nil(log)){ - MESSAGE( "Ressources Catalog: Loger Server was found" ) - log->ping(); - RESSOURCES_CATALOG=1; - break; - } - }} - } + } if ((RESSOURCES_CATALOG==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) break; - } - // - // Active catalog + } + + // Active catalog - SALOME_RessourcesCatalogImpl* Catalogue_i = new SALOME_RessourcesCatalogImpl(argc, argv); - poa->activate_object (Catalogue_i); - mgr->activate(); - CORBA::Object_ptr myCata = Catalogue_i->_this(); + SALOME_RessourcesCatalogImpl* Catalogue_i = new SALOME_RessourcesCatalogImpl(argc, argv); + poa->activate_object (Catalogue_i); + mgr->activate(); + CORBA::Object_ptr myCata = Catalogue_i->_this(); - // initialise Naming Service - SALOME_NamingService *_NS; - _NS = new SALOME_NamingService(orb); - // register Catalog in Naming Service - _NS->Register(myCata ,"/Kernel/RessourcesCatalog"); + // initialise Naming Service + SALOME_NamingService *_NS; + _NS = new SALOME_NamingService(orb); + // register Catalog in Naming Service + _NS->Register(myCata ,"/Kernel/RessourcesCatalog"); - MESSAGE("Running Ressources Catalog Server.") + MESSAGE("Running Ressources Catalog Server.") - orb->run(); + orb->run(); - poa->destroy(1,1); + poa->destroy(1,1); - } - catch(CORBA::SystemException&) { + } + catch(CORBA::SystemException&) { INFOS("Caught CORBA::SystemException.") - } - catch(CORBA::Exception&) { + } + catch(CORBA::Exception&) { INFOS("Caught CORBA::Exception.") - } + } return 0; } diff --git a/src/SALOMEDS/Makefile.in b/src/SALOMEDS/Makefile.in index 873929b80..84cb2949f 100644 --- a/src/SALOMEDS/Makefile.in +++ b/src/SALOMEDS/Makefile.in @@ -50,8 +50,12 @@ LIB_SRC = \ SALOMEDS_OCAFApplication.cxx \ SALOMEDS_GenericAttribute_i.cxx \ SALOMEDS_IORAttribute.cxx \ + SALOMEDS_ExternalFileDef.cxx \ + SALOMEDS_FileType.cxx \ SALOMEDS_PersRefAttribute.cxx \ SALOMEDS_AttributeComment_i.cxx \ + SALOMEDS_AttributeExternalFileDef_i.cxx \ + SALOMEDS_AttributeFileType_i.cxx \ SALOMEDS_AttributeIOR_i.cxx \ SALOMEDS_AttributeInteger_i.cxx \ SALOMEDS_AttributeName_i.cxx \ @@ -107,7 +111,7 @@ BIN_CLIENT_IDL = CPPFLAGS+=$(OCC_INCLUDES) $(HDF5_INCLUDES) CXXFLAGS+=$(OCC_CXXFLAGS) -LDFLAGS+= $(HDF5_LIBS) -lTOOLSDS -lSalomeNS -lSalomeHDFPersist -lOpUtil -lSalomeLoggerServer $(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_SObject_i.cxx b/src/SALOMEDS/SALOMEDS_SObject_i.cxx index f9c00984e..e10791ded 100644 --- a/src/SALOMEDS/SALOMEDS_SObject_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.cxx @@ -44,6 +44,8 @@ using namespace std; #include "SALOMEDS_AttributePersistentRef_i.hxx" #include "SALOMEDS_AttributeIOR_i.hxx" #include "SALOMEDS_AttributeComment_i.hxx" +#include "SALOMEDS_AttributeExternalFileDef_i.hxx" +#include "SALOMEDS_AttributeFileType_i.hxx" #include "SALOMEDS_AttributeName_i.hxx" #include "SALOMEDS_AttributeSequenceOfInteger_i.hxx" #include "SALOMEDS_AttributeSequenceOfReal_i.hxx" @@ -84,6 +86,8 @@ SALOMEDS_SObject_i::ReturnGUIDForAttribute(const char* aTypeOfAttribute) else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfInteger") == 0 ) return SALOMEDS_SequenceOfIntegerAttribute::GetID(); else if (strcmp(aTypeOfAttribute, "AttributeName") == 0 ) return TDataStd_Name::GetID(); else if (strcmp(aTypeOfAttribute, "AttributeComment") == 0 ) return TDataStd_Comment::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeExternalFileDef") == 0 ) return SALOMEDS_ExternalFileDef::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeFileType") == 0 ) return SALOMEDS_FileType::GetID(); else if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0 ) return SALOMEDS_IORAttribute::GetID(); else if (strcmp(aTypeOfAttribute, "AttributePersistentRef") == 0 ) return SALOMEDS_PersRefAttribute::GetID(); else if (strcmp(aTypeOfAttribute, "AttributeDrawable") == 0 ) return SALOMEDS_DrawableAttribute::GetID(); @@ -121,6 +125,8 @@ char* SALOMEDS_SObject_i::AttributeIDToType(Standard_GUID ID) { if (ID == TDataStd_Name::GetID()) return "AttributeName"; else if (ID == TDataStd_Comment::GetID()) return "AttributeComment"; + else if (ID == SALOMEDS_ExternalFileDef::GetID()) return "AttributeExternalFileDef"; + else if (ID == SALOMEDS_FileType::GetID()) return "AttributeFileType"; else if (ID == SALOMEDS_IORAttribute::GetID()) return "AttributeIOR"; else if (ID == SALOMEDS_PersRefAttribute::GetID()) return "AttributePersistentRef"; else if (ID == TDataStd_Real::GetID()) return "AttributeReal"; @@ -283,6 +289,16 @@ CORBA::Boolean SALOMEDS_SObject_i::FindAttribute (SALOMEDS::GenericAttribute_out anAttribute = Attr->AttributeComment::_this(); return Standard_True; } + else if (strcmp(aTypeOfAttribute, "AttributeExternalFileDef") == 0 ) { + SALOMEDS_AttributeExternalFileDef_i* Attr = new SALOMEDS_AttributeExternalFileDef_i(Handle(SALOMEDS_ExternalFileDef)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeExternalFileDef::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeFileType") == 0 ) { + SALOMEDS_AttributeFileType_i* Attr = new SALOMEDS_AttributeFileType_i(Handle(SALOMEDS_FileType)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeFileType::_this(); + return Standard_True; + } else if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0 ) { SALOMEDS_AttributeIOR_i* Attr = new SALOMEDS_AttributeIOR_i(Handle(SALOMEDS_IORAttribute)::DownCast(anAttr), _orb); anAttribute = Attr->AttributeIOR::_this(); @@ -416,6 +432,14 @@ SALOMEDS::ListOfAttributes* SALOMEDS_SObject_i::GetAllAttributes() SALOMEDS_AttributeComment_i* Attr= new SALOMEDS_AttributeComment_i(Handle(TDataStd_Comment)::DownCast(anAttr), _orb); anAttribute = Attr->AttributeComment::_this(); } + else if (ReturnGUIDForAttribute("AttributeExternalFileDef") == anAttr->ID()) { + SALOMEDS_AttributeExternalFileDef_i* Attr= new SALOMEDS_AttributeExternalFileDef_i(Handle(SALOMEDS_ExternalFileDef)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeExternalFileDef::_this(); + } + else if (ReturnGUIDForAttribute("AttributeFileType") == anAttr->ID()) { + SALOMEDS_AttributeFileType_i* Attr= new SALOMEDS_AttributeFileType_i(Handle(SALOMEDS_FileType)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeFileType::_this(); + } else if (ReturnGUIDForAttribute("AttributeIOR") == anAttr->ID()) { SALOMEDS_AttributeIOR_i* Attr= new SALOMEDS_AttributeIOR_i(Handle(SALOMEDS_IORAttribute)::DownCast(anAttr), _orb); anAttribute = Attr->AttributeIOR::_this(); diff --git a/src/SALOMEDS/SALOMEDS_Server.cxx b/src/SALOMEDS/SALOMEDS_Server.cxx index 7d1c61e80..9e7f39f30 100644 --- a/src/SALOMEDS/SALOMEDS_Server.cxx +++ b/src/SALOMEDS/SALOMEDS_Server.cxx @@ -26,17 +26,17 @@ // Module : SALOME // $Header$ -using namespace std; #include #include CORBA_SERVER_HEADER(SALOMEDS) #include "SALOMEDS_StudyManager_i.hxx" #include "utilities.h" -# include "Utils_SINGLETON.hxx" +#include "Utils_SINGLETON.hxx" #include "SALOME_NamingService.hxx" -//#define CHECKTIME + #ifdef CHECKTIME #include #endif +using namespace std; // extern "C" // { // for ccmalloc memory debug @@ -47,131 +47,147 @@ using namespace std; ////////////////////////////////////////////////////////////////////////// int main(int argc, char** argv) { -// ccmalloc_static_initialization(); + // ccmalloc_static_initialization(); MESSAGE("SALOMEDS_Server - main"); - try { - // Initialise the ORB. + try + { + // Initialise the ORB. #if OMNIORB_VERSION >= 4 - const char* options[][2] = { { "giopMaxMsgSize", "104857600" }, { 0, 0 } }; - CORBA::ORB_var orb = CORBA::ORB_init( argc , argv , "omniORB4", options) ; + const char* options[][2] = { { "giopMaxMsgSize", "104857600" }, { 0, 0 } }; + CORBA::ORB_var orb = CORBA::ORB_init( argc , argv , "omniORB4", options) ; #else - CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB3"); - omniORB::MaxMessageSize(100 * 1024 * 1024); + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB3"); + omniORB::MaxMessageSize(100 * 1024 * 1024); #endif - // Obtain a reference to the root POA. - // - 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; - PortableServer::POA_var poa; - CORBA::Object_var theObj; - CORBA::Object_var obj; - CORBA::Object_var object; - SALOME_Logger::Logger_var log; - int SALOMEDS=0; - const char * Env = getenv("USE_LOGGER"); - int EnvL =0; - if ((Env!=NULL) && (strlen(Env))) - EnvL=1; - CosNaming::Name name; - name.length(1); - name[0].id=CORBA::string_dup("Logger"); - PortableServer::POAManager_var pman; - for (int i = 1; i<=NumberOfTries; i++){ - if (i!=1) - a=nanosleep(&ts_req,&ts_rem); - try{ - obj = orb->resolve_initial_references("RootPOA"); - if(!CORBA::is_nil(obj)) - poa = PortableServer::POA::_narrow(obj); - if(!CORBA::is_nil(poa)) - pman = poa->the_POAManager(); - if(!CORBA::is_nil(orb)) - theObj = orb->resolve_initial_references("NameService"); - if (!CORBA::is_nil(theObj)){ - inc = CosNaming::NamingContext::_narrow(theObj); - if(!CORBA::is_nil(inc)) { - MESSAGE( "SalomeDS Server: Naming Service was found" ) - if(EnvL==1){ - CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ; - SALOME_NamingService &NS = *SINGLETON_::Instance() ; - NS.init_orb( orb1 ) ; - for(int j=1; j<=NumberOfTries; j++){ - if (j!=1) - a=nanosleep(&ts_req, &ts_rem); - try{ - object = inc->resolve(name);} - catch(CosNaming::NamingContext::NotFound){ MESSAGE( "SalomeDS Server: Logger Server wasn't found" ) } - catch(...){ MESSAGE( "SalomeDS Server: Unknown exception" ) } - if (!CORBA::is_nil(object)) - log = SALOME_Logger::Logger::_narrow(object); - if (!CORBA::is_nil(log)){ - MESSAGE( "SalomeDS Server: Logger Server was found" ) - log->ping(); - SALOMEDS=1; - break; - } - }} - }} - - } - catch( const SALOME_Exception &ex ) + // Obtain a reference to the root POA. + // + 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; + PortableServer::POA_var poa; + CORBA::Object_var theObj; + CORBA::Object_var obj; + CORBA::Object_var object; + int SALOMEDS=0; + const char * Env = getenv("USE_LOGGER"); + int EnvL =0; + if ((Env!=NULL) && (strlen(Env))) + EnvL=1; + CosNaming::Name name; + name.length(1); + name[0].id=CORBA::string_dup("Logger"); + PortableServer::POAManager_var pman; + for (int i = 1; i<=NumberOfTries; i++) { - MESSAGE( "Communication Error : " << ex.what() ) - return EXIT_FAILURE ; + if (i!=1) + a=nanosleep(&ts_req,&ts_rem); + try + { + obj = orb->resolve_initial_references("RootPOA"); + if(!CORBA::is_nil(obj)) + poa = PortableServer::POA::_narrow(obj); + if(!CORBA::is_nil(poa)) + pman = poa->the_POAManager(); + if(!CORBA::is_nil(orb)) + theObj = orb->resolve_initial_references("NameService"); + if (!CORBA::is_nil(theObj)){ + inc = CosNaming::NamingContext::_narrow(theObj); + if(!CORBA::is_nil(inc)) + { + MESSAGE( "SalomeDS Server: Naming Service was found" ); + if(EnvL==1) + { + CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ; + SALOME_NamingService &NS = *SINGLETON_::Instance() ; + NS.init_orb( orb1 ) ; + for(int j=1; j<=NumberOfTries; j++) + { + if (j!=1) + a=nanosleep(&ts_req, &ts_rem); + try + { + object = inc->resolve(name); + } + catch(CosNaming::NamingContext::NotFound) + { + MESSAGE( "SalomeDS Server: Logger Server wasn't found" ); } + + catch(...) + { + MESSAGE( "SalomeDS Server: Unknown exception" ); + } + if (!CORBA::is_nil(object)) + { + MESSAGE( "SalomeDS Server: Logger Server was found" ); + SALOMEDS=1; + break; + } + } + } + } + } + + } + catch( const SALOME_Exception &ex ) + { + MESSAGE( "Communication Error : " << ex.what() ); + return EXIT_FAILURE ; + } + if ((SALOMEDS==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) + break; } - if ((SALOMEDS==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) - break; - } - // - // We allocate the objects on the heap. Since these are reference - // counted objects, they will be deleted by the POA when they are no - // longer needed. - SALOMEDS_StudyManager_i * myStudyManager_i = new SALOMEDS_StudyManager_i(orb); + // We allocate the objects on the heap. Since these are reference + // counted objects, they will be deleted by the POA when they are no + // longer needed. + SALOMEDS_StudyManager_i * myStudyManager_i = new SALOMEDS_StudyManager_i(orb); - // Activate the objects. This tells the POA that the objects are - // ready to accept requests. - PortableServer::ObjectId_var myStudyManager_iid = poa->activate_object(myStudyManager_i); - myStudyManager_i->register_name("/myStudyManager"); + // Activate the objects. This tells the POA that the objects are + // ready to accept requests. + PortableServer::ObjectId_var myStudyManager_iid = poa->activate_object(myStudyManager_i); + myStudyManager_i->register_name("/myStudyManager"); - // Obtain a POAManager, and tell the POA to start accepting - // requests on its objects. - pman = poa->the_POAManager(); - pman->activate(); + // Obtain a POAManager, and tell the POA to start accepting + // requests on its objects. + pman = poa->the_POAManager(); + pman->activate(); #ifdef CHECKTIME - Utils_Timer timer; - timer.Start(); - timer.Stop(); - MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); - timer.ShowAbsolute(); + Utils_Timer timer; + timer.Start(); + timer.Stop(); + MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); + timer.ShowAbsolute(); #endif - orb->run(); - orb->destroy(); - } - catch(CORBA::SystemException&) { - MESSAGE( "Caught CORBA::SystemException." ) - } - catch(CORBA::Exception&) { - MESSAGE( "Caught CORBA::Exception." ) - } - catch(omniORB::fatalException& fe) { - MESSAGE( "Caught omniORB::fatalException:" ) - MESSAGE( " file: " << fe.file() ) - MESSAGE( " line: " << fe.line() ) - MESSAGE( " mesg: " << fe.errmsg() ) - } - catch(...) { - MESSAGE( "Caught unknown exception." ) - } + orb->run(); + orb->destroy(); + } + catch(CORBA::SystemException&) + { + MESSAGE( "Caught CORBA::SystemException." ); + } + catch(CORBA::Exception&) + { + MESSAGE( "Caught CORBA::Exception." ); + } + catch(omniORB::fatalException& fe) + { + MESSAGE( "Caught omniORB::fatalException:" ); + MESSAGE( " file: " << fe.file() ); + MESSAGE( " line: " << fe.line() ); + MESSAGE( " mesg: " << fe.errmsg() ); + } + catch(...) + { + MESSAGE( "Caught unknown exception." ); + } return 0; } diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx index 93eaa48bc..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" @@ -50,6 +51,8 @@ using namespace std; #include "SALOMEDS_AttributePersistentRef_i.hxx" #include "SALOMEDS_AttributeIOR_i.hxx" #include "SALOMEDS_AttributeComment_i.hxx" +#include "SALOMEDS_AttributeExternalFileDef_i.hxx" +#include "SALOMEDS_AttributeFileType_i.hxx" #include "SALOMEDS_AttributeName_i.hxx" #include "SALOMEDS_AttributeSequenceOfInteger_i.hxx" #include "SALOMEDS_AttributeSequenceOfReal_i.hxx" @@ -109,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(); @@ -142,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)); @@ -163,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); } @@ -175,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 @@ -211,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; @@ -235,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; @@ -248,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(); } @@ -258,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; @@ -270,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()) { @@ -279,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); @@ -544,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); } @@ -554,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); } @@ -564,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); } @@ -574,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); } @@ -584,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); } @@ -594,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); } @@ -601,9 +627,30 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA SALOMEDS::AttributeComment_var aCA = aCommentAttr->AttributeComment::_this(); return aCA._retn(); } + else if (strcmp(aTypeOfAttribute, "AttributeExternalFileDef") == 0 ) { + Handle(SALOMEDS_ExternalFileDef) anAttr; + if (!Lab.FindAttribute(SALOMEDS_ExternalFileDef::GetID(), anAttr)) { + anAttr = new SALOMEDS_ExternalFileDef; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributeExternalFileDef_i* anExternalFileDefAttr = new SALOMEDS_AttributeExternalFileDef_i(anAttr, _orb); + SALOMEDS::AttributeExternalFileDef_var aCA = anExternalFileDefAttr->AttributeExternalFileDef::_this(); + return aCA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributeFileType") == 0 ) { + Handle(SALOMEDS_FileType) anAttr; + if (!Lab.FindAttribute(SALOMEDS_FileType::GetID(), anAttr)) { + anAttr = new SALOMEDS_FileType; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributeFileType_i* anFileTypeAttr = new SALOMEDS_AttributeFileType_i(anAttr, _orb); + SALOMEDS::AttributeFileType_var aCA = anFileTypeAttr->AttributeFileType::_this(); + return aCA._retn(); + } 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); } @@ -664,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); } @@ -674,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); } @@ -684,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); } @@ -702,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(); @@ -719,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); } @@ -739,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); } @@ -749,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); } @@ -759,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); } @@ -769,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(); @@ -780,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); } @@ -836,6 +898,16 @@ CORBA::Boolean SALOMEDS_StudyBuilder_i::FindAttribute(SALOMEDS::SObject_ptr anOb anAttribute = Attr->AttributeComment::_this(); return Standard_True; } + else if (strcmp(aTypeOfAttribute, "AttributeExternalFileDef") == 0 ) { + SALOMEDS_AttributeExternalFileDef_i* Attr= new SALOMEDS_AttributeExternalFileDef_i(Handle(SALOMEDS_ExternalFileDef)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeExternalFileDef::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeFileType") == 0 ) { + SALOMEDS_AttributeFileType_i* Attr= new SALOMEDS_AttributeFileType_i(Handle(SALOMEDS_FileType)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeFileType::_this(); + return Standard_True; + } else if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0 ) { SALOMEDS_AttributeIOR_i* Attr= new SALOMEDS_AttributeIOR_i(Handle(SALOMEDS_IORAttribute)::DownCast(anAttr), _orb); anAttribute = Attr->AttributeIOR::_this(); @@ -936,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)); } @@ -954,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(); @@ -977,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; @@ -1043,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(); @@ -1100,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); @@ -1124,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(); } @@ -1143,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); } @@ -1166,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); } } @@ -1190,7 +1280,6 @@ CORBA::Boolean SALOMEDS_StudyBuilder_i::GetAvailableRedos() return _doc->GetAvailableRedos(); } - //============================================================================ /*! Function : UndoLimit * Purpose : @@ -1208,6 +1297,7 @@ CORBA::Long SALOMEDS_StudyBuilder_i::UndoLimit() //============================================================================ void SALOMEDS_StudyBuilder_i::UndoLimit(CORBA::Long n) { + CheckLocked(); _doc->SetUndoLimit (n); } @@ -1234,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..ba14acbf0 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,12 @@ 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 +1287,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 +1355,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 +1370,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 +1420,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 +1529,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 +1628,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 a0b08aa45..439362886 100644 --- a/src/SALOMEGUI/QAD_Application.cxx +++ b/src/SALOMEGUI/QAD_Application.cxx @@ -396,7 +396,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 )); } @@ -464,7 +464,7 @@ void QAD_Application::helpAbout() void QAD_Application::helpSearch() { /* just calls QAD_Desktop::helpSearch() but can have own implementation */ - // getDesktop()->helpSearch(); +// getDesktop()->helpSearch(); } /*! @@ -473,7 +473,7 @@ void QAD_Application::helpSearch() void QAD_Application::helpContents() { /* just calls QAD_Desktop::helpContents() but can have own implementation */ - // getDesktop()->helpContents(); +// getDesktop()->helpContents(); } /*! @@ -801,7 +801,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; @@ -914,8 +914,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..4b9634dfd 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"); @@ -2422,7 +2478,9 @@ void QAD_Desktop::onOpenWith() } else if ( list_type_composants->length() > 1 ) { SALOMEGUI_OpenWith* aDlg = new SALOMEGUI_OpenWith( this ); for (unsigned int ind = 0; ind < list_type_composants->length();ind++) { - aDlg->addComponent( strdup(list_type_composants[ind]) ); + QString compusername = getComponentUserName(strdup(list_type_composants[ind])); + if ( compusername.compare("") != 0 ) + aDlg->addComponent( compusername ); } int retVal = aDlg->exec(); @@ -2536,6 +2594,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 +2771,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 +3110,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 +3403,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 +3439,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 +3467,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 +3755,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 +3787,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..eb8435512 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 ] */ @@ -136,6 +150,8 @@ QAD_ObjectBrowser::QAD_ObjectBrowser( SALOMEDS::Study_var study, QWidget* parent myStudy = SALOMEDS::Study::_duplicate( study ); myListViewMap.clear(); myUseCaseMap.clear(); + myListView=0; // must be done before setupListView(): setCornerWidget() provoque call to eventFilter + myUseCaseView=0; // and test myUseCaseView->viewport() before initialisation setupListView(); } @@ -157,12 +173,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 +194,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 +203,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 +221,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 +247,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 +310,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 +336,13 @@ 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 (! myUseCaseView) return QTabWidget::eventFilter( o, e ); + 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 +720,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 +744,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 +878,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 +912,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 +972,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 +1139,7 @@ void QAD_ObjectBrowser::UpdateUCItem( SALOMEDS::SObject_var UCObject, QAD_Object void QAD_ObjectBrowser::unHighlightAll() { myListView->clearSelection(); - myUseCaseView->clearSelection(); + myUseCaseView->clearSelection(); } /*! @@ -1283,6 +1319,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 +1528,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 +1564,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 +1850,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 0e1796ab3..1be9aef0e 100644 --- a/src/SALOMEGUI/QAD_Study.cxx +++ b/src/SALOMEGUI/QAD_Study.cxx @@ -60,7 +60,6 @@ using namespace std; // QT Include #include -#define MAX_UNDO 10 /*! Constructor */ @@ -75,7 +74,7 @@ myPath( path ) { myStudy = aStudy; - myTitle = QAD_Tools::getFileNameFromPath( path, false ); + myTitle = QAD_Tools::getFileNameFromPath( path, true ); myIsActive = false; myIsSaved = false; @@ -104,7 +103,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); + } /*! @@ -169,7 +173,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 ); @@ -274,7 +281,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() ) @@ -380,6 +387,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/Makefile.in b/src/Session/Makefile.in index 9e95d0c62..36ba65dde 100644 --- a/src/Session/Makefile.in +++ b/src/Session/Makefile.in @@ -51,7 +51,7 @@ BIN_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Component.idl SALOM CPPFLAGS+=$(QT_MT_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) CXXFLAGS+=$(OCC_CXXFLAGS) -LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lSalomeGUI -lSalomeObject -lSalomeLifeCycleCORBA -lqsplitterP -lOpUtil -lSalomeLoggerServer -lPlot2d -lSalomeVTKFilter +LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lSalomeGUI -lSalomeObject -lSalomeLifeCycleCORBA -lqsplitterP -lOpUtil -lPlot2d -lSalomeVTKFilter -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/Session/SALOME_Session_QThread.cxx b/src/Session/SALOME_Session_QThread.cxx index 8531be10f..8c598f1da 100644 --- a/src/Session/SALOME_Session_QThread.cxx +++ b/src/Session/SALOME_Session_QThread.cxx @@ -48,6 +48,8 @@ using namespace std; #include #include CORBA_SERVER_HEADER(SALOMEDS) +SALOME_Session_QThread* SALOME_Session_QThread::_singleton = 0; + //============================================================================= /*! SALOME_Session_QThread * constructor @@ -56,6 +58,7 @@ using namespace std; SALOME_Session_QThread::SALOME_Session_QThread(int argc, char ** argv) : QThread() { + INFOS("Creation SALOME_Session_QThread"); _qappl = 0 ; _mw = 0 ; _argc = argc ; @@ -63,6 +66,19 @@ SALOME_Session_QThread::SALOME_Session_QThread(int argc, char ** argv) : QThread _NS = 0 ; } ; +//============================================================================= +/*! + * + */ +//============================================================================= + + SALOME_Session_QThread* SALOME_Session_QThread::Instance(int argc, char ** argv) +{ + if (_singleton == 0) _singleton = new SALOME_Session_QThread(argc, argv); + return _singleton; + +} + //============================================================================= /*! run * Creates one QApplication for the all the session life. diff --git a/src/Session/SALOME_Session_QThread.hxx b/src/Session/SALOME_Session_QThread.hxx index 9e9941bd7..eac1da8d6 100644 --- a/src/Session/SALOME_Session_QThread.hxx +++ b/src/Session/SALOME_Session_QThread.hxx @@ -41,7 +41,7 @@ class SALOME_Session_QThread: public QThread { public: - SALOME_Session_QThread(int argc, char ** argv) ; + static SALOME_Session_QThread* Instance(int argc, char ** argv); //! launch the Qt main window of the GUI on a separate thread virtual void run() ; @@ -57,6 +57,10 @@ protected: QApplication *_qappl ; SALOMEGUI_Application* _mw ; + SALOME_Session_QThread(int argc, char ** argv); + +private: + static SALOME_Session_QThread* _singleton; } ; #endif diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 99482aa36..2b00367c2 100644 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -26,9 +26,9 @@ // Module : SALOME // $Header$ -# include "Utils_ORB_INIT.hxx" -# include "Utils_SINGLETON.hxx" -# include "SALOME_NamingService.hxx" +#include "Utils_ORB_INIT.hxx" +#include "Utils_SINGLETON.hxx" +#include "SALOME_NamingService.hxx" #include #include using namespace std; @@ -57,110 +57,117 @@ int main(int argc, char **argv) try { - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - CORBA::ORB_var &orb = init( argc , argv ) ; + ORB_INIT &init = *SINGLETON_::Instance() ; + ASSERT(SINGLETON_::IsAlreadyExisting()) ; + CORBA::ORB_var &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; - PortableServer::POA_var poa; - CORBA::Object_var theObj; - CORBA::Object_var obj; - CORBA::Object_var object; - SALOME_Logger::Logger_var log; - SALOME_NamingService &naming = *SINGLETON_::Instance() ; - int SESSION=0; - const char * Env = getenv("USE_LOGGER"); - int EnvL =0; - if ((Env!=NULL) && (strlen(Env))) - EnvL=1; - CosNaming::Name name; - name.length(1); - name[0].id=CORBA::string_dup("Logger"); - PortableServer::POAManager_var pman; - for (int i = 1; i<=NumberOfTries; i++){ - if (i!=1) - a=nanosleep(&ts_req,&ts_rem); - try{ + // + 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; + PortableServer::POA_var poa; + CORBA::Object_var theObj; + CORBA::Object_var obj; + CORBA::Object_var object; + SALOME_NamingService &naming = *SINGLETON_::Instance() ; + int SESSION=0; + const char * Env = getenv("USE_LOGGER"); + int EnvL =0; + if ((Env!=NULL) && (strlen(Env))) + EnvL=1; + CosNaming::Name name; + name.length(1); + name[0].id=CORBA::string_dup("Logger"); + PortableServer::POAManager_var pman; + for (int i = 1; i<=NumberOfTries; i++){ + if (i!=1) + a=nanosleep(&ts_req,&ts_rem); + try + { obj = orb->resolve_initial_references("RootPOA"); if(!CORBA::is_nil(obj)) - poa = PortableServer::POA::_narrow(obj); + poa = PortableServer::POA::_narrow(obj); if(!CORBA::is_nil(poa)) - pman = poa->the_POAManager(); - if(!CORBA::is_nil(orb)) - theObj = orb->resolve_initial_references("NameService"); + pman = poa->the_POAManager(); + 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& ) - { - MESSAGE( "Session Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ) - } - if(!CORBA::is_nil(inc)) { - MESSAGE( "Session Server: Naming Service was found" ) - if(EnvL==1){ - for(int j=1; j<=NumberOfTries; j++){ - if (j!=1) - a=nanosleep(&ts_req, &ts_rem); - try{ - object = inc->resolve(name); - } - catch(CosNaming::NamingContext::NotFound){ MESSAGE( "Session Server: Logger Server wasn't found" ) } - catch(...){ MESSAGE( "Session Server: Unknown exception" ) } - if (!CORBA::is_nil(object)) - log = SALOME_Logger::Logger::_narrow(object); - if (!CORBA::is_nil(log)){ - MESSAGE( "Session Server: Loger Server was found" ) - log->ping(); - SESSION=1; - break; - } - }} } - if ((SESSION==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) - break; + catch( CORBA::COMM_FAILURE& ) + { + MESSAGE( "Session Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); + } + if(!CORBA::is_nil(inc)) + { + MESSAGE( "Session Server: Naming Service was found" ); + if(EnvL==1) + { + for(int j=1; j<=NumberOfTries; j++) + { + if (j!=1) + a=nanosleep(&ts_req, &ts_rem); + try + { + object = inc->resolve(name); + } + catch(CosNaming::NamingContext::NotFound) + { MESSAGE( "Session Server: Logger Server wasn't found" ); + } + catch(...) + { + MESSAGE( "Session Server: Unknown exception" ); + } + if (!CORBA::is_nil(object)) + { + MESSAGE( "Session Server: Loger Server was found" ); + SESSION=1; + break; + } + } } - // + } + if ((SESSION==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) + break; + } - // servant - SALOME_Session_i * mySALOME_Session = new SALOME_Session_i(argc, argv, orb, poa) ; - PortableServer::ObjectId_var mySALOME_Sessionid = poa->activate_object(mySALOME_Session) ; - MESSAGE("poa->activate_object(mySALOME_Session)") + // servant + SALOME_Session_i * mySALOME_Session = new SALOME_Session_i(argc, argv, orb, poa) ; + PortableServer::ObjectId_var mySALOME_Sessionid = poa->activate_object(mySALOME_Session) ; + MESSAGE("poa->activate_object(mySALOME_Session)") - obj = mySALOME_Session->_this() ; - CORBA::String_var sior(orb->object_to_string(obj)) ; + obj = mySALOME_Session->_this() ; + CORBA::String_var sior(orb->object_to_string(obj)) ; - mySALOME_Session->NSregister(); + mySALOME_Session->NSregister(); - mySALOME_Session->_remove_ref() ; + mySALOME_Session->_remove_ref() ; - //DECOMMENT PortableServer::POAManager_var pman = poa->the_POAManager() ; - pman->activate() ; - MESSAGE("pman->activate()") + //DECOMMENT PortableServer::POAManager_var pman = poa->the_POAManager() ; + pman->activate() ; + MESSAGE("pman->activate()") - orb->run() ; - orb->destroy() ; + orb->run() ; + orb->destroy() ; } - catch (CORBA::SystemException&) + catch (CORBA::SystemException&) { - INFOS("Caught CORBA::SystemException.") + INFOS("Caught CORBA::SystemException."); } - catch (CORBA::Exception&) + catch (CORBA::Exception&) { - INFOS("Caught CORBA::Exception.") + INFOS("Caught CORBA::Exception."); } - catch (...) + catch (...) { - INFOS("Caught unknown exception.") + INFOS("Caught unknown exception."); } return 0 ; } diff --git a/src/Session/SALOME_Session_i.cxx b/src/Session/SALOME_Session_i.cxx index 026584560..154848f21 100644 --- a/src/Session/SALOME_Session_i.cxx +++ b/src/Session/SALOME_Session_i.cxx @@ -52,7 +52,7 @@ SALOME_Session_i::SALOME_Session_i(int argc, char ** argv, CORBA::ORB_ptr orb, P { _argc = argc ; _argv = argv ; - _IAPPThread = new SALOME_Session_QThread(_argc, _argv) ; + _IAPPThread = SALOME_Session_QThread::Instance(_argc, _argv); _isGUI = FALSE ; _runningStudies= 0 ; _orb = CORBA::ORB::_duplicate(orb) ; @@ -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/TOOLSDS/Makefile.in b/src/TOOLSDS/Makefile.in index 41f346ded..a3d0a4fdc 100644 --- a/src/TOOLSDS/Makefile.in +++ b/src/TOOLSDS/Makefile.in @@ -29,7 +29,7 @@ BIN_CLIENT_IDL = CPPFLAGS+=$(OCC_INCLUDES) $(HDF5_INCLUDES) CXXFLAGS+=$(OCC_CXXFLAGS) -LDFLAGS+= -lOpUtil -lSalomeLoggerServer $(CAS_LDPATH) -lTKernel +LDFLAGS+= -lOpUtil $(CAS_LDPATH) -lTKernel @CONCLUDE@ diff --git a/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx b/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx index f117c1b60..5c774aa8e 100644 --- a/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx +++ b/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx @@ -23,6 +23,7 @@ // // File : ToolsGUI_CatalogGeneratorDlg.cxx // Author : Nicolas REJNERI +// Modified : Marc TAJCHMAN // Module : SALOME // $Header$ @@ -33,6 +34,7 @@ using namespace std; #include "QAD_Desktop.h" #include "QAD_FileDlg.h" #include "QAD_MessageBox.h" +#include "QAD_Tools.h" #include #include #include @@ -107,16 +109,18 @@ ToolsGUI_CatalogGeneratorDlg::ToolsGUI_CatalogGeneratorDlg( QWidget* parent, con supplGrpLayout->setSpacing( SPACING_SIZE ); supplGrpLayout->setMargin( MARGIN_SIZE ); + QSize myMinimumSize(int(MIN_EDIT_SIZE*0.3), 0); + myAuthorEdit = new QLineEdit( supplGrp , "myAuthorEdit" ); myAuthorEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myAuthorEdit->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 ); + myAuthorEdit->setMinimumSize( myMinimumSize ); OSD_Process aProcess; myAuthorEdit->setText(aProcess.UserName().ToCString()); myVersionEdit = new QLineEdit(supplGrp , "myVersion" ); myVersionEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myVersionEdit->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 ); + myVersionEdit->setMinimumSize( myMinimumSize ); QStringList aList = QStringList::split(QRegExp("\\s+"),tr( "INF_VERSION" )); myVersionEdit->setText(aList.last()); QDoubleValidator *validator = new QDoubleValidator(myVersionEdit); @@ -130,16 +134,20 @@ ToolsGUI_CatalogGeneratorDlg::ToolsGUI_CatalogGeneratorDlg( QWidget* parent, con myCompName = new QLineEdit(supplGrp , "myCompName"); myCompName->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myCompName->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 ); + myCompName->setMinimumSize( myMinimumSize ); + + myCompUserName = new QLineEdit(supplGrp , "myCompUserName"); + myCompUserName->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myCompUserName->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 ); myCompType = new QLineEdit(supplGrp , "myCompType"); myCompType->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myCompType->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 ); + myCompType->setMinimumSize( myMinimumSize ); myCompType->setText("OTHER"); myCompMultiStd = new QLineEdit(supplGrp , "myCompMultiStd"); myCompMultiStd->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myCompMultiStd->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 ); + myCompMultiStd->setMinimumSize( myMinimumSize ); myCompMultiStd->setText("1"); QIntValidator *ivalidator = new QIntValidator(myVersionEdit); myCompMultiStd->setValidator(ivalidator); @@ -148,12 +156,14 @@ ToolsGUI_CatalogGeneratorDlg::ToolsGUI_CatalogGeneratorDlg( QWidget* parent, con supplGrpLayout->addWidget( myAuthorEdit, 0, 1 ); supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_COMP_NAME" ), supplGrp ), 0, 2); supplGrpLayout->addWidget(myCompName,0,3); - supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_COMP_TYPE" ), supplGrp ), 0, 4); - supplGrpLayout->addWidget(myCompType,0,5); + supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_COMP_USERNAME" ), supplGrp ), 0, 4); + supplGrpLayout->addWidget(myCompUserName,0,5); supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_VERSION" ), supplGrp ), 1, 0); supplGrpLayout->addWidget( myVersionEdit, 1, 1); supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_COMP_MULTISTD" ), supplGrp ), 1, 2); supplGrpLayout->addWidget(myCompMultiStd,1,3); + supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_COMP_TYPE" ), supplGrp ), 1, 4); + supplGrpLayout->addWidget(myCompType,1,5); supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_PNG_FILE" ), supplGrp ), 2, 0); supplGrpLayout->addMultiCellWidget( myPngEdit, 2,2,1,4 ); supplGrpLayout->addWidget( myBrowsePngBtn, 2, 5 ); @@ -251,6 +261,15 @@ QString ToolsGUI_CatalogGeneratorDlg::getCompName() return myCompName->text().stripWhiteSpace(); } +//================================================================================= +// function : getCompUserName() +// purpose : gets username of the component +//================================================================================= +QString ToolsGUI_CatalogGeneratorDlg::getCompUserName() +{ + return myCompUserName->text().stripWhiteSpace(); +} + //================================================================================= // function : getCompType() // purpose : gets type of the component @@ -268,6 +287,36 @@ QString ToolsGUI_CatalogGeneratorDlg::getCompType() return myCompType->text().stripWhiteSpace(); } +//================================================================================= +// function : getIdlPath() +// purpose : gets IDL path of modules +//================================================================================= +QString ToolsGUI_CatalogGeneratorDlg::getIdlPath() +{ + SALOME_ModuleCatalog::ModuleCatalog_var aCatalog = + SALOME_ModuleCatalog::ModuleCatalog::_narrow( QAD_Application::getDesktop()->getCatalogue()); + + SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants = + aCatalog->GetComponentIconeList(); + + QString IDLpath = ""; + + for (unsigned int ind = 0; ind < list_composants->length();ind++) { + QString modulename = strdup(list_composants[ind].modulename) ; + + QCString dir; + if (dir = getenv( modulename + "_ROOT_DIR")) { + IDLpath = IDLpath + "-I" + QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + + QAD_Tools::addSlash("idl") + + QAD_Tools::addSlash("salome")) + " "; + } + } + + // MESSAGE ( " IDLpath = " << IDLpath); + + return IDLpath; +} + //================================================================================= // function : onBrowseBtnClicked() // purpose : <...> (Browse) buttons slot @@ -326,12 +375,14 @@ void ToolsGUI_CatalogGeneratorDlg::updateButtonState() //================================================================================= void ToolsGUI_CatalogGeneratorDlg::onApply() { + QString IDLpath = getIdlPath(); QString XmlFile = getXmlFile(); QString IdlFile = getIdlFile(); QString Author = getAuthor(); QString Version = getVersion(); QString PngFile = getPngFile(); QString CompName = getCompName(); //gets component name + QString CompUserName = getCompUserName(); //gets component username QString CompType = getCompType(); //gets component type QString CompMultiStd = getCompMultiStd(); @@ -345,13 +396,14 @@ void ToolsGUI_CatalogGeneratorDlg::onApply() else { QString command = ""; if ( getenv("KERNEL_ROOT_DIR") ) - command = QString( getenv( "KERNEL_ROOT_DIR" ) ) + "/bin/runIDLparser -Wbcatalog=" + XmlFile; + command = QString( getenv( "KERNEL_ROOT_DIR" ) ) + "/bin/salome/runIDLparser " + IDLpath + " -Wbcatalog=" + XmlFile; else { QAD_MessageBox::error1( this, tr("TOOLS_ERR_ERROR"), tr("KERNEL_ROOT_DIR variable is not defined"), tr("TOOLS_BUT_OK") ); } + if (!Author.isEmpty()) command += ",author=" + Author; if (!Version.isEmpty()) command += ",version=" + Version; if (!PngFile.isEmpty()) { @@ -360,6 +412,7 @@ void ToolsGUI_CatalogGeneratorDlg::onApply() command += QString(",icon=") + QString(aFile.ToCString()); } if (!CompName.isEmpty()) command += ",name=" + CompName; + if (!CompUserName.isEmpty()) command += ",username=" + CompUserName; if (!CompType.isEmpty()) command += ",type=" + CompType; if (!CompMultiStd.isEmpty()) command += ",multistudy=" + CompMultiStd; command += " " + IdlFile; diff --git a/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.h b/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.h index d0e593458..9d474ac67 100644 --- a/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.h +++ b/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.h @@ -46,12 +46,14 @@ public: ToolsGUI_CatalogGeneratorDlg( QWidget* parent = 0, const char* name = 0 ); ~ToolsGUI_CatalogGeneratorDlg(); + QString getIdlPath(); QString getIdlFile(); QString getXmlFile(); QString getPngFile(); QString getAuthor(); QString getVersion(); QString getCompName(); + QString getCompUserName(); QString getCompType(); QString getCompMultiStd(); @@ -67,6 +69,7 @@ private: QLineEdit* myVersionEdit; QLineEdit* myAuthorEdit; QLineEdit* myCompName; + QLineEdit* myCompUserName; QLineEdit* myCompType; QLineEdit* myCompMultiStd; QPushButton* myBrowseIdlBtn; diff --git a/src/TOOLSGUI/ToolsGUI_msg_en.po b/src/TOOLSGUI/ToolsGUI_msg_en.po index 7859d5e12..09ad7be89 100644 --- a/src/TOOLSGUI/ToolsGUI_msg_en.po +++ b/src/TOOLSGUI/ToolsGUI_msg_en.po @@ -76,6 +76,9 @@ msgstr "Version : " msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_COMP_NAME" msgstr "Name : " +msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_COMP_USERNAME" +msgstr "UserName : " + msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_COMP_TYPE" msgstr "Type : " diff --git a/src/TestContainer/Makefile.in b/src/TestContainer/Makefile.in index 8d2709d60..8ee409d99 100644 --- a/src/TestContainer/Makefile.in +++ b/src/TestContainer/Makefile.in @@ -45,7 +45,7 @@ LIB_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl BIN = TestContainer TestLogger BIN_SRC = -LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeContainer -lRegistry -lOpUtil -lSalomeLoggerServer +LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/TestContainer/TestContainer.cxx b/src/TestContainer/TestContainer.cxx index 9849ce584..d1f1c35bb 100644 --- a/src/TestContainer/TestContainer.cxx +++ b/src/TestContainer/TestContainer.cxx @@ -26,7 +26,6 @@ // Module : SALOME // $Header$ -using namespace std; #include "utilities.h" #include #include @@ -36,10 +35,12 @@ using namespace std; #include "SALOME_NamingService.hxx" #include "OpUtil.hxx" -# include "Utils_ORB_INIT.hxx" -# include "Utils_SINGLETON.hxx" -# include "Utils_SALOME_Exception.hxx" -# include "Utils_CommException.hxx" +#include "Utils_ORB_INIT.hxx" +#include "Utils_SINGLETON.hxx" +#include "Utils_SALOME_Exception.hxx" +#include "Utils_CommException.hxx" +using namespace std; + int main (int argc, char * argv[]) { @@ -55,74 +56,84 @@ int main (int argc, char * argv[]) // Obtain a reference to the root POA // - 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; - PortableServer::POA_var poa; - CORBA::Object_var theObj; - CORBA::Object_var obj; - CORBA::Object_var object; - SALOME_Logger::Logger_var log; - SALOME_NamingService &naming = *SINGLETON_::Instance() ; - int TEST_CONTAINER=0; - const char * Env = getenv("USE_LOGGER"); + 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; + PortableServer::POA_var poa; + CORBA::Object_var theObj; + CORBA::Object_var obj; + CORBA::Object_var object; + SALOME_NamingService &naming = *SINGLETON_::Instance() ; + int TEST_CONTAINER=0; + const char * Env = getenv("USE_LOGGER"); int EnvL =0; if ((Env!=NULL) && (strlen(Env))) EnvL=1; CosNaming::Name name; name.length(1); name[0].id=CORBA::string_dup("Logger"); - PortableServer::POAManager_var manager; - for (int i = 1; i<=NumberOfTries; i++){ - if (i!=1) - a=nanosleep(&ts_req,&ts_rem); - try{ - obj = orb->resolve_initial_references("RootPOA"); - if(!CORBA::is_nil(obj)) - poa = PortableServer::POA::_narrow(obj); - if(!CORBA::is_nil(poa)) - manager = poa->the_POAManager(); - 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& ) - { - MESSAGE( "Test Container: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ) - } - if(!CORBA::is_nil(inc)) { - MESSAGE( "Test Container: Naming Service was found" ) - if(EnvL==1){ - for(int j=1; j<=NumberOfTries; j++){ - if (j!=1) - a=nanosleep(&ts_req, &ts_rem); - try{ - object = inc->resolve(name); - } - catch(CosNaming::NamingContext::NotFound){ MESSAGE( "Test Container: Logger Server wasn't found" ) } - catch(...){ MESSAGE( "Test Container: Unknown exception" ) } - if (!CORBA::is_nil(object)) - log = SALOME_Logger::Logger::_narrow(object); - if (!CORBA::is_nil(log)){ - MESSAGE( "Test Container: Loger Server was found" ) - log->ping(); - TEST_CONTAINER=1; - break; + PortableServer::POAManager_var manager; + for (int i = 1; i<=NumberOfTries; i++) + { + if (i!=1) + a=nanosleep(&ts_req,&ts_rem); + try + { + obj = orb->resolve_initial_references("RootPOA"); + if(!CORBA::is_nil(obj)) + poa = PortableServer::POA::_narrow(obj); + if(!CORBA::is_nil(poa)) + manager = poa->the_POAManager(); + 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& ) + { + MESSAGE( "Test Container: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ) + } + if(!CORBA::is_nil(inc)) + { + MESSAGE( "Test Container: Naming Service was found" ) + if(EnvL==1) + { + for(int j=1; j<=NumberOfTries; j++) + { + if (j!=1) + a=nanosleep(&ts_req, &ts_rem); + try + { + object = inc->resolve(name); + } + catch(CosNaming::NamingContext::NotFound) + { + MESSAGE( "Test Container: Logger Server wasn't found" ); + } + catch(...) + { + MESSAGE( "Test Container: Unknown exception" ); + } + if (!CORBA::is_nil(object)) + { + MESSAGE( "Test Container: Loger Server was found" ); + TEST_CONTAINER=1; + break; + } + } } - }} - } + } if ((TEST_CONTAINER==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) break; - } - // + } + // Use Name Service to find container SALOME_NamingService _NS(orb) ; string containerName = "/Containers/" ; diff --git a/src/Utils/Makefile.in b/src/Utils/Makefile.in index aec4b20ab..86ebc70ef 100644 --- a/src/Utils/Makefile.in +++ b/src/Utils/Makefile.in @@ -57,7 +57,7 @@ LIB_SRC = OpUtil.cxx Utils_Timer.cxx duplicate.cxx \ Utils_Identity.cxx Utils_ORB_INIT.cxx \ Utils_DESTRUCTEUR_GENERIQUE.cxx -LDFLAGS+= -lSalomeLoggerServer +LDFLAGS+= @CONCLUDE@ diff --git a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx index 07b70adfe..50737af05 100644 --- a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx +++ b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx @@ -66,6 +66,7 @@ public : ATEXIT_( void ) { ASSERT (Destructeurs==0); + MESSAGE("Construction ATEXIT"); // message necessaire pour utiliser logger dans Nettoyage (cf.BUG KERNEL4561) Destructeurs = new list ; // Destructeurs alloué dynamiquement (cf. ci-dessous) , // il est utilisé puis détruit par la fonction Nettoyage int cr = atexit( Nettoyage ); // exécute Nettoyage lors de exit, après la destruction des données statiques ! diff --git a/src/Utils/Utils_SALOME_Exception.cxx b/src/Utils/Utils_SALOME_Exception.cxx index 59b79a764..06f4a26f4 100644 --- a/src/Utils/Utils_SALOME_Exception.cxx +++ b/src/Utils/Utils_SALOME_Exception.cxx @@ -42,7 +42,7 @@ const char* duplicate( const char *const str ) ; SALOME_Exception::SALOME_Exception( void ): exception() , _text(0) { - MESSAGE( "You must user the standard builder : SALOME_Exception::SALOME_Exception( const char *text )" ) ; + MESSAGE( "You must use the standard builder: SALOME_Exception::SALOME_Exception( const char *text )" ) ; INTERRUPTION(1) ; } 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/Utils/utilities.h b/src/Utils/utilities.h index 52256eae8..f396321e8 100644 --- a/src/Utils/utilities.h +++ b/src/Utils/utilities.h @@ -28,101 +28,67 @@ /* --- Definition macros file to print informations if _DEBUG_ is defined --- */ -# ifndef UTILITIES_H -# define UTILITIES_H +#ifndef UTILITIES_H +#define UTILITIES_H -# include -# include - - - -//VRV: T2.4 - replacement macro for using special CORBA server -#include "SALOME_Trace.hxx" -//VRV: T2.4 - replacement macro for using special CORBA server +#include +#include +#include "SALOME_Log.hxx" /* --- INFOS is always defined (without _DEBUG_): to be used for warnings, with release version --- */ -//VRV: T2.4 - replacement of these macros for using special CORBA server - -#define INFOS(msg) { GLogger.putMessage(GLogger << __FILE__<< " [" << __LINE__ << "] : " << msg<< endl << ends ); } -#define PYSCRIPT(msg) { GLogger.putMessage(GLogger<<"---PYSCRIPT--- "<putMessage(*SLog<<__FILE__<<" ["<<__LINE__<<"] : "<putMessage(*SLog<<"---PYSCRIPT--- "<putMessage(\ + *SLog<<__FILE__<<" ["<< __LINE__<<"] : "\ + << "COMPILED with " << COMPILER \ + << ", " << __DATE__ \ + << " at " << __TIME__ <putMessage( MYTRACE <putMessage( MYTRACE << #var << "=" << var < #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 -- 2.39.2