From: yfr Date: Thu, 17 Jun 2004 10:04:06 +0000 (+0000) Subject: DCQ : Merge with Ecole_ete_a6. X-Git-Tag: V2_0_0b1~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1f742af859d50d34c63f9dc02f9a705089bf060e;p=modules%2Fkernel.git DCQ : Merge with Ecole_ete_a6. --- diff --git a/idl/MPIContainer.idl b/idl/MPIContainer.idl new file mode 100644 index 000000000..6aab3355d --- /dev/null +++ b/idl/MPIContainer.idl @@ -0,0 +1,38 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// 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 +// 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 +// +// +// +// File : MPIContainer.idl + +#ifndef _SALOME_MPICONTAINER_IDL_ +#define _SALOME_MPICONTAINER_IDL_ + +#include "SALOME_Component.idl" +#include "MPIObject.idl" + +module Engines +{ + interface MPIContainer:Container,MPIObject + { + } ; +} ; + +#endif + diff --git a/idl/MPIObject.idl b/idl/MPIObject.idl new file mode 100644 index 000000000..a480f51f1 --- /dev/null +++ b/idl/MPIObject.idl @@ -0,0 +1,36 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// 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 +// 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 +// +// +// +// File : MPIObject.idl + +#ifndef _SALOME_MPIOBJECT_IDL_ +#define _SALOME_MPIOBJECT_IDL_ + +module Engines +{ + typedef sequence IORTab; + interface MPIObject + { + attribute IORTab tior; + } ; +} ; + +#endif diff --git a/idl/Makefile.in b/idl/Makefile.in index 2615b1f63..2c96c9b5f 100644 --- a/idl/Makefile.in +++ b/idl/Makefile.in @@ -6,7 +6,7 @@ top_srcdir=@top_srcdir@ top_builddir=.. srcdir=@srcdir@ -VPATH=.:$(srcdir) +VPATH=. @COMMENCE@ @@ -21,20 +21,24 @@ IDL_FILES = \ SALOME_Component.idl \ SALOME_TestComponent.idl \ SALOME_Registry.idl \ - SALOME_MPIObject.idl \ - SALOME_MPIContainer.idl \ - SALOME_TestMPIComponent.idl \ + TypeData.idl \ + MPIObject.idl \ + MPIContainer.idl \ Logger.idl \ - SALOME_GenericObj.idl + SALOME_GenericObj.idl \ + SALOME_TestModuleCatalog.idl PY_CLIENT_IDL = $(IDL_FILES) # we copy all idl file in $(top_builddir)/idl -inc: $(IDL_FILES:%=$(top_builddir)/idl/%) +inc: $(top_builddir)/idl/salome $(IDL_FILES:%=$(top_builddir)/idl/salome/%) -$(IDL_FILES:%=$(top_builddir)/idl/%):$(top_builddir)/idl/%:% +$(top_builddir)/idl/salome: + mkdir $@ + +$(IDL_FILES:%=$(top_builddir)/idl/salome/%):$(IDL_FILES:%=$(top_srcdir)/idl/%) # $(CP) $< $@ - cp -f $< $@ + cp -f $^ $(top_builddir)/idl/salome lib: pyidl @@ -46,7 +50,7 @@ pyidl: $(PYTHON_BUILD_SITE) $(IDL_FILES:%.idl=$(PYTHON_BUILD_SITE)/%_idl.py) $(PYTHON_BUILD_SITE): $(INSTALL) -d $@ -$(PYTHON_BUILD_SITE)/%_idl.py: %.idl +$(PYTHON_BUILD_SITE)/%_idl.py: $(top_builddir)/idl/salome/%.idl $(OMNIORB_IDL) $(OMNIORB_IDLPYFLAGS) -C$(PYTHON_BUILD_SITE) $< @@ -54,12 +58,12 @@ $(PYTHON_BUILD_SITE)/%_idl.py: %.idl install: install-pyidl install-idl # create directory $(idldir) and copy idl files into it -install-idl: $(IDL_FILES) +install-idl: $(IDL_FILES:%=$(top_builddir)/idl/salome/%) $(INSTALL) -d $(idldir) - cp -p $^ $(idldir) + cp -p -f $^ $(idldir) -install-pyidl: $(IDL_FILES) +install-pyidl: $(IDL_FILES:%=$(top_builddir)/idl/salome/%) $(INSTALL) -d $(PYTHON_SITE_INSTALL) @for file in $^ dummy; do \ if [ $$file != "dummy" ]; then \ @@ -74,6 +78,6 @@ cleandep: distclean: -$(RM) *.py - -$(RM) $(IDL_FILES:%=$(top_builddir)/idl/%) + -$(RM) $(IDL_FILES:%=$(top_builddir)/idl/salome/%) -$(RM) Makefile diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index 686297a17..f019faf31 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -196,6 +196,13 @@ during each working session. */ SObject FindObjectID (in ID aObjectID); +/*! + Allows to create a %SObject by its ID + \param aObjectID This parameter defines the ID of the required object + \return The created %SObject + +*/ + SObject CreateObjectID (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 @@ -495,6 +502,14 @@ during each working session. void Addreference(in SObject anObject, in SObject theReferencedObject) ; + +/*! + Removes a reference from %anObject to another object. + \param anObject The %SObject which contains a reference +*/ + + void RemoveReference(in SObject anObject) ; + /*! Adds a directory in the %Study. \param theName String parameter defining the name of the directory. @@ -606,6 +621,29 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin */ Callback SetOnRemoveSObject(in Callback theCallback); +/*! + Puts name attribute with the given string value to the given %SObject + + \param theSO Existing SObject to set name attribute. + \param theValue The value to be set to the name attribute. +*/ + void SetName(in SObject theSO, in string theValue) raises (LockProtection); + +/*! + Puts comment attribute with the given string value to the given %SObject + + \param theSO Existing SObject to set comment attribute. + \param theValue The value to be set to the comment attribute. +*/ + void SetComment(in SObject theSO, in string theValue) raises (LockProtection); + +/*! + Puts IOR attribute with the given string value to the given %SObject + + \param theSO Existing SObject to set IOR attribute. + \param theValue The value to be set to the IOR attribute. +*/ + void SetIOR(in SObject theSO, in string theValue) raises (LockProtection); }; //========================================================================== @@ -817,6 +855,31 @@ Gets the list of open studies /return The study containing the given %SObject. */ Study GetStudy(); + +/*! Gets the CORBA object by its own IOR attribute. + Returns nil, if can't. + + /return The CORBA object of the %SObject. +*/ + Object GetObject(); + +/*! + Returns the name attribute value of this SObject. + Returns empty string if there is no name attribute. +*/ + string GetName(); + +/*! + Returns the comment attribute value of this SObject. + Returns empty string if there is no comment attribute. +*/ + string GetComment(); + +/*! + Returns the IOR attribute value of this SObject. + Returns empty string if there is no IOR attribute. +*/ + string GetIOR(); }; @@ -840,6 +903,14 @@ Gets the list of open studies \note
This exception is raised only outside a transaction. */ void CheckLocked() raises (LockProtection); + + string Store(); + + void Restore(in string theData); + + string Type(); + + SObject GetSObject(); }; diff --git a/idl/SALOMEDS_Attributes.idl b/idl/SALOMEDS_Attributes.idl index 27f1f6dbd..42310794f 100644 --- a/idl/SALOMEDS_Attributes.idl +++ b/idl/SALOMEDS_Attributes.idl @@ -63,6 +63,7 @@ module SALOMEDS Attribute allowing to store a real value */ //========================================================================== + interface AttributeReal : GenericAttribute { /*! @@ -77,6 +78,7 @@ module SALOMEDS
See also an example of this method usage in batchmode of %SALOME application. */ void SetValue(in double value); + }; //========================================================================== /*! \brief Attribute allowing to store an integer value diff --git a/idl/SALOME_Component.idl b/idl/SALOME_Component.idl index a18580fe7..ecad1fa41 100644 --- a/idl/SALOME_Component.idl +++ b/idl/SALOME_Component.idl @@ -32,6 +32,17 @@ for management of %MED component in %SALOME application. */ module Engines { +/*! + General Key Value Structure to set or get properties, for component +*/ + struct KeyValuePair + { + string key; + any value; + }; + + typedef sequence FieldsDict; + interface Component ; /*! \brief Interface of the %Container @@ -119,6 +130,18 @@ module Engines Returns the container that the %Component refers to. */ Container GetContainerRef() ; +/*! + Gives a sequence of (key=string,value=any) to the component. + Base class component stores the sequence in a map. + The map is cleared before. + This map is for use by derived classes. +*/ + void setProperties(in FieldsDict dico); +/*! + returns a previously stored map (key=string,value=any) as a sequence. + See setProperties(in FieldsDict dico). +*/ + FieldsDict getProperties(); /*! This method is used by the %SUPERVISOR component. It sets the names of the graph and of the node. \param aGraphName Name of graph diff --git a/idl/SALOME_ModuleCatalog.idl b/idl/SALOME_ModuleCatalog.idl index 227c6b7e0..1bac5ce71 100644 --- a/idl/SALOME_ModuleCatalog.idl +++ b/idl/SALOME_ModuleCatalog.idl @@ -58,11 +58,34 @@ This struct contains fields defining the parameter of the service. string Parametername; /*! ListOfServicesParameter; + typedef sequence ListOfServicesDataStreamParameter; /*! This struct contains fields completely defining each service. @@ -70,10 +93,13 @@ This struct contains fields completely defining each service. struct Service { - string ServiceName; /*! ListOfInterfaces ; + +/*! +PathPrefix : association of a machine name and +a path to a component +*/ + struct PathPrefix { + string machine; + string path; + }; + +/*! +List of path prefixes +*/ + typedef sequence PathPrefixes; + +/*! +Description of a component +*/ + struct Component + { + ComponentType type; + string name; + string username; + boolean multistudy; + boolean implementationType; + string icon; + string constraint; + ListOfDefInterface interfaces; + PathPrefixes paths; + }; + /*! List of names of components. */ @@ -200,36 +257,42 @@ List of pair GUI elements (component name, component icone) string GetPathPrefix(in string machinename) raises(NotFound); /*! - Sets/gets the constraint affected to the component + Get the constraint affected to the component (to be resolved by LifeCycle for the computer choice) */ readonly attribute string constraint ; /*! -Sets/gets the name of the component +Get the name of the component */ readonly attribute string componentname; /*! -Sets/gets the user name of the component +Get the user name of the component */ readonly attribute string componentusername; /*! -Defines whether the component is multistudy or not +Ask whether the component is multistudy or not */ readonly attribute boolean multistudy; /*! -Defines the type of the component +Ask the type of the component */ readonly attribute ComponentType component_type ; /*! -Sets/gets the icone of the component (for IAPP) +Gets the icone of the component (for IAPP) */ readonly attribute string component_icone; + +/*! +Gets the implementation type of the component : C++ or Python (for IAPP) +*/ + readonly attribute boolean implementation_type; } ; + /*! \brief %Module catalog interface This interface is used for creation of the module catalog in %SALOME application. @@ -268,5 +331,18 @@ Gets a list of names of components of a particular type, which belong to this ca Gets one component of the catalog. */ Acomponent GetComponent(in string componentname) raises(NotFound); + +/*! +Gets the description of a component of the catalog. +*/ + Component GetComponentInfo(in string componentName) raises(NotFound); + +/*! +Reads a xml file and imports new components from this file. +New components replace existing components with the same name. +*/ + void ImportXmlCatalogFile(in string filename) raises(NotFound); + + void shutdown(); } ; }; diff --git a/idl/SALOME_TestComponent.idl b/idl/SALOME_TestComponent.idl index 96de5a0d6..c580d65b0 100644 --- a/idl/SALOME_TestComponent.idl +++ b/idl/SALOME_TestComponent.idl @@ -31,6 +31,7 @@ module Engines interface TestComponent : Component { string Coucou(in long L); + void Setenv(); }; }; diff --git a/idl/SALOME_TestModuleCatalog.idl b/idl/SALOME_TestModuleCatalog.idl new file mode 100644 index 000000000..80f5be229 --- /dev/null +++ b/idl/SALOME_TestModuleCatalog.idl @@ -0,0 +1,54 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// 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 +// 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 +// +// +// +// File : SALOME_TestModuleCatalog.idl +// Author : + +#ifndef _TestModuleCatalog_IDL +#define _TestModuleCatalog_IDL + +#include "SALOME_Component.idl" + +module SuperVisionTest { + + interface Adder ; + + interface AddComponent : Engines::Component { + +// DataStreamPorts Addition istream(INTEGER, in, T), ostream(STRING, out, I) +// DataStreamPorts Addition Ostream(FLOAT, out, T) + Adder Addition() ; + double Add( in double x , in double y , out double z ) ; + long Sigma( in long n ) ; + double LastResult() ; + }; + + interface Adder : Engines::Component { + double Add( in double x , in double y , out double z ) ; + double AddAndCompare( in double x , in double y , in Adder anOtherAdder, + out double z ) ; + void SetLastResult( in double z ) ; + void LastResult( out double z ) ; + }; + +} ; + +#endif diff --git a/idl/TypeData.idl b/idl/TypeData.idl new file mode 100644 index 000000000..c3d99e29f --- /dev/null +++ b/idl/TypeData.idl @@ -0,0 +1,44 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// 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 +// 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 +// +// +// +// File : TypeData.idl + +#ifndef _SALOME_TYPEDATA_IDL_ +#define _SALOME_TYPEDATA_IDL_ + +module Engines +{ + + typedef sequence DoubleVec ; + typedef sequence IntVec; + + typedef struct CSR { + unsigned long nbpos; + unsigned long nbval; + IntVec pos; + IntVec col; + DoubleVec data; + } CSRMatStruct; + +} ; + +#endif + diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx index 3d31862b7..cad8ba99c 100644 --- a/src/Container/Component_i.cxx +++ b/src/Container/Component_i.cxx @@ -26,13 +26,14 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOME_Component_i.hxx" #include "RegistryConnexion.hxx" #include "OpUtil.hxx" #include #include +#include #include "utilities.h" -using namespace std; extern bool _Sleeping ; static Engines_Component_i * theEngines_Component ; @@ -134,6 +135,31 @@ PortableServer::ObjectId * Engines_Component_i::getId() return _id ; } +void Engines_Component_i::setProperties(const Engines::FieldsDict& dico) +{ + _fieldsDict.clear(); + for (CORBA::ULong i=0; ilength(_fieldsDict.size()); + map::iterator it; + CORBA::ULong i = 0; + for (it = _fieldsDict.begin(); it != _fieldsDict.end(); it++, i++) + { + std::string cle((*it).first); + copie[i].key = CORBA::string_dup(cle.c_str()); + copie[i].value = _fieldsDict[cle]; + } + return copie._retn(); +} + void Engines_Component_i::beginService(const char *serviceName) { MESSAGE(pthread_self() << "Send BeginService notification for " << serviceName << endl @@ -155,6 +181,22 @@ void Engines_Component_i::beginService(const char *serviceName) // MESSAGE(pthread_self() << " Return from BeginService for " << serviceName // << " ThreadId " << _ThreadId << " StartUsed " << _StartUsed // << " _graphName " << _graphName << " _nodeName " << _nodeName ); + + // --- for supervisor : all strings given with setProperties + // are set in environment + bool overwrite = true; + map::iterator it; + for (it = _fieldsDict.begin(); it != _fieldsDict.end(); it++) + { + std::string cle((*it).first); + if ((*it).second.type()->kind() == CORBA::tk_string) + { + const char* value; + (*it).second >>= value; + int ret = setenv(cle.c_str(), value, overwrite); + MESSAGE("--- setenv: "< 0 ) { diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index e16c47ad7..9c68bb2a1 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -120,7 +120,6 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, // Pour les containers paralleles: il ne faut pas enregistrer le container generique, mais le container specialise if(regist){ - // _NS = new SALOME_NamingService(_orb); _NS = SINGLETON_::Instance() ; ASSERT(SINGLETON_::IsAlreadyExisting()) ; @@ -131,7 +130,6 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, SCRUTE(_containerName); _NS->Register(pCont, _containerName.c_str()); } - } Engines_Container_i::~Engines_Container_i() @@ -156,7 +154,7 @@ void Engines_Container_i::ping() MESSAGE("Engines_Container_i::ping() pid "<< getpid()); } - // Kill current container +//! Kill current container bool Engines_Container_i::Kill_impl() { MESSAGE("Engines_Container_i::Kill() pid "<< getpid() << " containerName " << _containerName.c_str() << " machineName " @@ -164,7 +162,7 @@ bool Engines_Container_i::Kill_impl() { exit( 0 ) ; } -// Launch a new container from the current container +//! Launch a new container from the current container Engines::Container_ptr Engines_Container_i::start_impl( const char* ContainerName ) { MESSAGE("start_impl argc " << _argc << " ContainerName " << ContainerName @@ -354,7 +352,7 @@ Engines::Component_ptr Engines_Container_i::load_impl( const char* nameToRegiste } } catch (...) { - MESSAGE( "Container_i::load_impl catched" ) ; + INFOS( "Container_i::load_impl catched" ) ; } //Jr _numInstanceMutex.lock() ; // lock on the add on handle_map (necessary ?) @@ -426,7 +424,6 @@ void SigIntHandler(int what , siginfo_t * siginfo , << " si_pid " << siginfo->si_pid) ; if ( _Sleeping ) { _Sleeping = false ; - INFOS("SigIntHandler END sleeping.") MESSAGE("SigIntHandler END sleeping.") ; return ; } @@ -437,14 +434,12 @@ void SigIntHandler(int what , siginfo_t * siginfo , } else { _Sleeping = true ; - INFOS("SigIntHandler BEGIN sleeping.") MESSAGE("SigIntHandler BEGIN sleeping.") ; int count = 0 ; while( _Sleeping ) { sleep( 1 ) ; count += 1 ; } - INFOS("SigIntHandler LEAVE sleeping after " << count << " s.") MESSAGE("SigIntHandler LEAVE sleeping after " << count << " s.") ; } return ; diff --git a/src/Container/Makefile.in b/src/Container/Makefile.in index 23f857fe7..87f372867 100644 --- a/src/Container/Makefile.in +++ b/src/Container/Makefile.in @@ -55,6 +55,6 @@ CPPFLAGS+= $(PYTHON_INCLUDES) LDFLAGS+= -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification -lSALOMELocalTrace -LIBS += @LDEXPDYNFLAGS@ $(PYTHON_LIBS) +LIBS += -Xlinker -export-dynamic $(PYTHON_LIBS) @CONCLUDE@ diff --git a/src/Container/SALOME_ComponentPy.py b/src/Container/SALOME_ComponentPy.py index 004d6eded..2c2a5d0f1 100755 --- a/src/Container/SALOME_ComponentPy.py +++ b/src/Container/SALOME_ComponentPy.py @@ -49,6 +49,7 @@ from thread import * class SALOME_ComponentPy_i (Engines__POA.Component): _orb = None _poa = None + _fieldsDict = [] #------------------------------------------------------------------------- @@ -118,6 +119,16 @@ class SALOME_ComponentPy_i (Engines__POA.Component): #------------------------------------------------------------------------- + def setProperties(self, dico): + self._fieldsDict = dico + + #------------------------------------------------------------------------- + + def getProperties(self): + return self._fieldsDict + + #------------------------------------------------------------------------- + def destroy(self): MESSAGE( "SALOME_ComponentPy_i::destroy" ) poa.deactivate_object(self) diff --git a/src/Container/SALOME_Component_i.hxx b/src/Container/SALOME_Component_i.hxx index 07c56bcb7..4b93ef5b5 100644 --- a/src/Container/SALOME_Component_i.hxx +++ b/src/Container/SALOME_Component_i.hxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include CORBA_SERVER_HEADER(SALOME_Component) #include "NOTIFICATION.hxx" @@ -72,6 +73,9 @@ public: Engines::Container_ptr GetContainerRef(); PortableServer::ObjectId * getId(); + void setProperties(const Engines::FieldsDict& dico); + Engines::FieldsDict* getProperties(); + void beginService(const char *serviceName); void endService(const char *serviceName); void sendMessage(const char *event_type, const char *message); @@ -79,14 +83,14 @@ public: void Names( const char * graphName , const char * nodeName ) ; char * graphName() ; char * nodeName() ; - bool Killer( pthread_t ThreadId , int signum ); + bool Killer( int ThreadId , int signum ); bool Kill_impl(); bool Stop_impl(); bool Suspend_impl(); bool Resume_impl(); void SetCurCpu() ; long CpuUsed() ; - CORBA::Long CpuUsed_impl() ; + long CpuUsed_impl() ; protected: string _instanceName ; @@ -101,6 +105,7 @@ protected: Engines_Component_i * _thisObj ; RegistryConnexion *_myConnexionToRegistry; NOTIFICATION_Supplier* _notifSupplier; + map_fieldsDict; private: pthread_t _ThreadId ; diff --git a/src/Container/SALOME_Container.cxx b/src/Container/SALOME_Container.cxx index 77a06b9de..921c3ce26 100644 --- a/src/Container/SALOME_Container.cxx +++ b/src/Container/SALOME_Container.cxx @@ -35,6 +35,7 @@ #include #include #include "utilities.h" +#include "Utils_CatchSignals.h" using namespace std; #ifdef CHECKTIME @@ -198,8 +199,12 @@ int main(int argc, char* argv[]) MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); timer.ShowAbsolute(); #endif + Utils_CatchSignals aCatch; + aCatch.Activate(); + orb->run(); + aCatch.Deactivate(); orb->destroy(); } catch(CORBA::SystemException&) diff --git a/src/Container/SALOME_ContainerPy.py b/src/Container/SALOME_ContainerPy.py index 6444ef148..d3d54ae13 100755 --- a/src/Container/SALOME_ContainerPy.py +++ b/src/Container/SALOME_ContainerPy.py @@ -83,11 +83,12 @@ class SALOME_ContainerPy_i (Engines__POA.Container): if container is None: MESSAGE( "SALOME_ContainerPy_i::start_impl " + str(containerName) + ".object exists but is not a Container" ) else : - MESSAGE( "SALOME_ContainerPy_i::start_impl " + str(ContainerName) + ".object found without runSession" ) + MESSAGE( "SALOME_ContainerPy_i::start_impl " + str(ContainerName) + ".object found without new launch" ) return container #shstr = os.getenv( "PWD" ) + "/" #shstr += "runSession ./SALOME_ContainerPy.py " - shstr = "runSession SALOME_ContainerPy.py " + shstr = os.getenv("KERNEL_ROOT_DIR") + "/bin/salome/SALOME_ContainerPy.py "; + #shstr = "runSession SALOME_ContainerPy.py " shstr += ContainerName # mpv: fix for SAL4731 - allways create new file to write log of server diff --git a/src/Container/SALOME_Container_i.hxx b/src/Container/SALOME_Container_i.hxx index 613f3ecf7..4e83c867b 100644 --- a/src/Container/SALOME_Container_i.hxx +++ b/src/Container/SALOME_Container_i.hxx @@ -55,14 +55,15 @@ public: bool activ = true); virtual ~Engines_Container_i(); - // Launch a new container from the current container + + //! Launch a new container from the current container Engines::Container_ptr start_impl(const char* ContainerName); - // Load component in current container + //! Load component in current container Engines::Component_ptr load_impl(const char* nameToRegister, const char* componentName); - // Unload component from current container + //! Unload component from current container void remove_impl(Engines::Component_ptr component_i); void finalize_removal(); @@ -70,8 +71,9 @@ public: char* machineName(); void ping(); - // Kill current container + //! Kill current container bool Kill_impl() ; + char* getHostName(); long getPID(); @@ -88,7 +90,7 @@ protected: std::map remove_map ; omni_mutex _numInstanceMutex ; // if several threads on the same object - //private: +private: int _argc ; char** _argv ; diff --git a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Client.cxx b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Client.cxx index 81008bcc6..083cc4b14 100644 --- a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Client.cxx +++ b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Client.cxx @@ -24,14 +24,14 @@ // File : SALOME_DataTypeCatalog_Client.cxx // Module : SALOME +using namespace std; /* $Header$ */ -#include +#include #include "SALOME_NamingService.hxx" #include "SALOME_DataTypeCatalog.hh" #include #include "utilities.h" -using namespace std; int main(int argc,char **argv) { diff --git a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Handler.cxx b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Handler.cxx index 2721fe1bf..55217510a 100644 --- a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Handler.cxx +++ b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Handler.cxx @@ -26,9 +26,9 @@ // Module : SALOME // $Header$ +using namespace std; #define WRITE_CATA_DATA_TYPE #include "SALOME_DataTypeCatalog_Handler.hxx" -using namespace std; //---------------------------------------------------------------------- // Function : SALOME_DataTypeCatalog_Handler diff --git a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx index 2d3eb86b3..a29401c51 100644 --- a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx +++ b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx @@ -26,7 +26,7 @@ // Module : SALOME // $Header$ -#include +#include #include "SALOME_NamingService.hxx" #include "SALOME_DataTypeCatalog_impl.hxx" #include "utilities.h" diff --git a/src/DataTypeCatalog/SALOME_DataTypeCatalog_impl.cxx b/src/DataTypeCatalog/SALOME_DataTypeCatalog_impl.cxx index 72b51ce38..1fb5f45e1 100644 --- a/src/DataTypeCatalog/SALOME_DataTypeCatalog_impl.cxx +++ b/src/DataTypeCatalog/SALOME_DataTypeCatalog_impl.cxx @@ -26,9 +26,12 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOME_DataTypeCatalog_impl.hxx" +#include "Utils_ExceptHandlers.hxx" #include -using namespace std; + +UNEXPECT_CATCH(DTC_NotFound, SALOME_DataTypeCatalog::NotFound); //---------------------------------------------------------------------- // Function : SALOME_DataTypeCatalogImpl @@ -103,7 +106,7 @@ SALOME_DataTypeCatalogImpl::isDerivedFrom(const char* type_in, const char* type_out) throw(SALOME_DataTypeCatalog::NotFound) { - + Unexpect aCatch(DTC_NotFound); CORBA::Boolean _return_value = false ; bool _found_in = false; bool _found_out = false; @@ -143,6 +146,7 @@ char* SALOME_DataTypeCatalogImpl::GetDataInterfaceRead(const char* type) throw(SALOME_DataTypeCatalog::NotFound) { + Unexpect aCatch(DTC_NotFound); char* return_value = NULL; bool _find = false; for (unsigned int ind=0; ind < _datatype_list.size();ind++) @@ -172,6 +176,7 @@ char* SALOME_DataTypeCatalogImpl::GetDataInterfaceWrite(const char* type) throw(SALOME_DataTypeCatalog::NotFound) { + Unexpect aCatch(DTC_NotFound); char* return_value = NULL; bool _find = false; for (unsigned int ind=0; ind < _datatype_list.size();ind++) @@ -199,6 +204,8 @@ SALOME_DataTypeCatalogImpl::GetDataInterfaceWrite(const char* type) SALOME_DataTypeCatalog::ListOfDataTypeName* SALOME_DataTypeCatalogImpl::GetDataTypeParents(const char* type) throw(SALOME_DataTypeCatalog::NotFound) { + Unexpect aCatch(DTC_NotFound); + bool _find = false ; SALOME_DataTypeCatalog::ListOfDataTypeName_var _list_data = @@ -347,7 +354,7 @@ SALOME_DataTypeCatalogImpl::_parseArguments(int argc, char **argv, if (strcmp(argv[ind],"-help") == 0) { - INFOS( "Usage: " << argv[0] << " -common 'path to data type catalog' -ORBInitRef NameService=corbaname::localhost"); + MESSAGE( "Usage: " << argv[0] << " -common 'path to data type catalog' -ORBInitRef NameService=corbaname::localhost"); _return_value = false ; } if (strcmp(argv[ind],"-common") == 0) diff --git a/src/GenericObj/SALOME_GenericObj_i.cc b/src/GenericObj/SALOME_GenericObj_i.cc index 93aaa9d8e..f0fdad6e0 100644 --- a/src/GenericObj/SALOME_GenericObj_i.cc +++ b/src/GenericObj/SALOME_GenericObj_i.cc @@ -30,7 +30,7 @@ using namespace SALOME; GenericObj_i::GenericObj_i(PortableServer::POA_ptr thePOA): myRefCounter(1){ - INFOS("GenericObj_i::GenericObj_i() - this = "<CreateOnDisk(); @@ -98,7 +98,5 @@ int HDFConvert::FromAscii(const string& file, const HDFcontainerObject & hdf_con perror("HDFConvert::FromAscii"); return -1; }; - - return 0; }; diff --git a/src/HDFPersist/HDFconvert.hxx b/src/HDFPersist/HDFconvert.hxx index dcc0552d4..c19e67965 100644 --- a/src/HDFPersist/HDFconvert.hxx +++ b/src/HDFPersist/HDFconvert.hxx @@ -43,6 +43,8 @@ extern "C" #include "HDFfile.hxx" #include +using namespace std; + class HDFConvert { private: @@ -52,7 +54,7 @@ private: public: -static int FromAscii(const std::string& file, const HDFcontainerObject& hdf_container, const std::string& nomdataset); +static int FromAscii(const string& file, const HDFcontainerObject& hdf_container, const string& nomdataset); }; diff --git a/src/HDFPersist/HDFdataset.cc b/src/HDFPersist/HDFdataset.cc index fcd8375b4..07d75e11c 100644 --- a/src/HDFPersist/HDFdataset.cc +++ b/src/HDFPersist/HDFdataset.cc @@ -24,17 +24,17 @@ // File : HDFdataset.cc // Module : SALOME +using namespace std; extern "C" { #include "hdfi.h" +#include } -#include #include "HDFdataset.hxx" #include "HDFcontainerObject.hxx" #include "HDFexception.hxx" -#include -using namespace std; +#include herr_t dataset_attr(hid_t loc_id, const char *attr_name, void *operator_data) { @@ -157,7 +157,7 @@ void HDFdataset::GetDim(hdf_size dim[]) else ndim = _ndim; _dim = new hdf_size[ndim]; - if ((ret = HDFdatasetGetDim(_id,_dim)) < 0) + if ((ret == HDFdatasetGetDim(_id,_dim)) < 0) throw HDFexception("Can't determine the size dimensions of the dataset "); } diff --git a/src/HDFPersist/HDFexception.hxx b/src/HDFPersist/HDFexception.hxx index a913f62e1..5395341a8 100644 --- a/src/HDFPersist/HDFexception.hxx +++ b/src/HDFPersist/HDFexception.hxx @@ -27,10 +27,12 @@ /* Exception */ #include +using namespace std; + class HDFexception { public : HDFexception(const char *message) { - std::cerr << message << std::endl; + cerr << message << endl; } }; diff --git a/src/HDFPersist/HDFexplorer.cc b/src/HDFPersist/HDFexplorer.cc index 114732d48..2e86f820e 100644 --- a/src/HDFPersist/HDFexplorer.cc +++ b/src/HDFPersist/HDFexplorer.cc @@ -24,11 +24,11 @@ // File : HDFexplorer.cc // Module : SALOME +using namespace std; #include "HDFcontainerObject.hxx" #include "HDFexception.hxx" #include "HDFinternalObject.hxx" #include "HDFexplorer.hxx" -using namespace std; HDFexplorer::HDFexplorer(HDFcontainerObject *container) { diff --git a/src/HDFPersist/HDFfile.cc b/src/HDFPersist/HDFfile.cc index c43a33320..469430a34 100644 --- a/src/HDFPersist/HDFfile.cc +++ b/src/HDFPersist/HDFfile.cc @@ -24,16 +24,16 @@ // File : HDFfile.cc // Module : SALOME +using namespace std; extern "C" { #include "hdfi.h" #include +#include } -#include -#include +#include #include "HDFfile.hxx" #include "HDFexception.hxx" -using namespace std; herr_t file_attr(hid_t loc_id, const char *attr_name, void *operator_data) { diff --git a/src/HDFPersist/HDFgroup.cc b/src/HDFPersist/HDFgroup.cc index ebeba2992..b08f4de6e 100644 --- a/src/HDFPersist/HDFgroup.cc +++ b/src/HDFPersist/HDFgroup.cc @@ -24,14 +24,14 @@ // File : HDFgroup.cc // Module : SALOME +using namespace std; extern "C" { #include "hdfi.h" +#include } -#include #include "HDFgroup.hxx" #include "HDFexception.hxx" -using namespace std; herr_t group_attr(hid_t loc_id, const char *attr_name, void *operator_data) { diff --git a/src/HDFPersist/HDFinternalObject.cc b/src/HDFPersist/HDFinternalObject.cc index 7ef6fb8e7..2cf6ed011 100644 --- a/src/HDFPersist/HDFinternalObject.cc +++ b/src/HDFPersist/HDFinternalObject.cc @@ -24,12 +24,12 @@ // File : HDFinternalObject.cc // Module : SALOME +using namespace std; extern "C" { #include "hdfi.h" } #include "HDFinternalObject.hxx" -using namespace std; HDFinternalObject::HDFinternalObject(char *name) : HDFobject(name) diff --git a/src/HDFPersist/HDFobject.cc b/src/HDFPersist/HDFobject.cc index eed36fdab..81fc689c8 100644 --- a/src/HDFPersist/HDFobject.cc +++ b/src/HDFPersist/HDFobject.cc @@ -24,14 +24,14 @@ // File : HDFobject.cc // Module : SALOME +using namespace std; #include "HDFobject.hxx" extern "C" { #include "hdfi.h" +#include } -#include #include "utilities.h" -using namespace std; HDFobject::HDFobject(char *name) { diff --git a/src/LifeCycleCORBA/LifeCycleCORBA.py b/src/LifeCycleCORBA/LifeCycleCORBA.py index 550a88ff9..fe19bfdff 100644 --- a/src/LifeCycleCORBA/LifeCycleCORBA.py +++ b/src/LifeCycleCORBA/LifeCycleCORBA.py @@ -97,10 +97,6 @@ class LifeCycleCORBA: #------------------------------------------------------------------------- def ComputerPath(self, ComputerName ): - # Modification provisoire B. Secher en attendant - # le gestionnaire de ressources 21/10/2003 - # Le KERNEL_ROOT_DIR sera a lire dans le catalogue de machines - # en attendant on suppose qu'il est identique au KERNEL_ROOT_DIR local try: #path = self._catalog.GetPathPrefix( ComputerName ) path = os.getenv("KERNEL_ROOT_DIR") + "/bin/salome/" diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index 6e48df6b9..e86b0c0a1 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -26,11 +26,11 @@ // Module : SALOME // $Header$ +using namespace std; #include #include #include #include -using namespace std; #include "OpUtil.hxx" #include "utilities.h" @@ -91,24 +91,19 @@ string SALOME_LifeCycleCORBA::ContainerName( string SALOME_LifeCycleCORBA::ComputerPath( const char * theComputer ) { -// CORBA::String_var path; -// CORBA::Object_var obj = _NS->Resolve("/Kernel/ModulCatalog"); -// SALOME_ModuleCatalog::ModuleCatalog_var Catalog = -// SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ; -// try { -// path = Catalog->GetPathPrefix( theComputer ); -// } -// catch (SALOME_ModuleCatalog::NotFound&) { -// MESSAGE("GetPathPrefix(" << theComputer << ") not found!"); -// path = "" ; -// } -// Modification provisoire B. Secher en attendant le gestionnaire de ressources -// 21/10/2003 -// Le KERNEL_ROOT_DIR sera a lire dans le catalogue de machines -// en attendant on suppose qu'il est identique au KERNEL_ROOT_DIR local - string path = string(getenv("KERNEL_ROOT_DIR")) + "/bin/salome/"; + CORBA::String_var path; + CORBA::Object_var obj = _NS->Resolve("/Kernel/ModulCatalog"); + SALOME_ModuleCatalog::ModuleCatalog_var Catalog = + SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ; + try { + path = Catalog->GetPathPrefix( theComputer ); + } + catch (SALOME_ModuleCatalog::NotFound&) { + INFOS("GetPathPrefix(" << theComputer << ") not found!"); + path = "" ; + } SCRUTE( path ) ; - return path; + return CORBA::string_dup( path ) ; } Engines::Container_var SALOME_LifeCycleCORBA::FindContainer(const char *containerName ) { @@ -167,7 +162,7 @@ Engines::Container_var SALOME_LifeCycleCORBA::FindOrStartContainer( } aFactoryServer = FindContainer( FactoryServer.c_str() ) ; if ( CORBA::is_nil( aFactoryServer ) ) { -// rsh -n machine_name ${KERNEL_ROOT_DIR}/bin/salome SALOME_Container -ORBInitRef NameService=corbaname::localhost:1515 & +// rsh -n ikkyo /export/home/rahuel/SALOME_ROOT/bin/runSession SALOME_Container -ORBInitRef NameService=corbaname::dm2s0017:1515 & string rsh( "" ) ; if ( theComputer!= GetHostname() ) { rsh += "rsh -n " ; @@ -176,8 +171,11 @@ Engines::Container_var SALOME_LifeCycleCORBA::FindOrStartContainer( } string path = ComputerPath( theComputer.c_str() ) ; SCRUTE( path ) ; - rsh += path; -// rsh += "runSession " ; + if ( path[0] != '\0' ) { + rsh += path ; + rsh += "/../bin/" ; + } + rsh += "runSession " ; if ( pyCont ) { rsh += "SALOME_ContainerPy.py " ; rsh += "FactoryServerPy -" ; @@ -211,10 +209,10 @@ Engines::Container_var SALOME_LifeCycleCORBA::FindOrStartContainer( SCRUTE( rsh ); int status = system( rsh.c_str() ) ; if (status == -1) { - INFOS("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status -1)") ; + MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status -1)") ; } else if (status == 217) { - INFOS("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status 217)") ; + MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status 217)") ; } else { int count = 21 ; @@ -226,7 +224,7 @@ Engines::Container_var SALOME_LifeCycleCORBA::FindOrStartContainer( aFactoryServer = FindContainer( FactoryServer.c_str() ) ; } if ( CORBA::is_nil( aFactoryServer ) ) { - INFOS("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed") ; + MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed") ; } else if ( strcmp( theComputer.c_str() , GetHostname().c_str() ) ) { _FactoryServer = aFactoryServer ; @@ -369,14 +367,14 @@ Engines::Component_var SALOME_LifeCycleCORBA::FindOrLoad_Component } catch (SALOME_ModuleCatalog::NotFound&) { - MESSAGE("GetPathPrefix(" << machine << ") not found!" + INFOS("GetPathPrefix(" << machine << ") not found!" << "trying localhost"); try { path = compoInfo->GetPathPrefix("localhost") ; path += "/" ; } catch (SALOME_ModuleCatalog::NotFound&) { - MESSAGE("GetPathPrefix(localhost) not found!") ; + INFOS("GetPathPrefix(localhost) not found!") ; path = "" ; } } diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx index d562f43f3..2338fe34c 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx @@ -54,12 +54,12 @@ public: protected: SALOME_NamingService *_NS; Engines::Container_var _FactoryServer ; - std::string ComputerPath( const char * theComputer ) ; + +private: std::string ContainerName( const char * aComputerContainer , std::string * theComputer , std::string * theContainer ) ; - -private: + std::string ComputerPath( const char * theComputer ) ; Engines::Container_var FindOrStartContainer(const std::string aComputerContainer , const std::string theComputer , const std::string theContainer ) ; diff --git a/src/LifeCycleCORBA/TestLifeCycleCORBA.cxx b/src/LifeCycleCORBA/TestLifeCycleCORBA.cxx index 603c32814..b67b988b6 100644 --- a/src/LifeCycleCORBA/TestLifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/TestLifeCycleCORBA.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "utilities.h" #include #include @@ -35,7 +36,6 @@ #include "SALOME_NamingService.hxx" #include "SALOME_LifeCycleCORBA.hxx" #include -using namespace std; int main (int argc, char * argv[]) { diff --git a/src/Loader/InquireServersQThread.cxx b/src/Loader/InquireServersQThread.cxx index cd77e0a8b..812a04e8d 100644 --- a/src/Loader/InquireServersQThread.cxx +++ b/src/Loader/InquireServersQThread.cxx @@ -7,6 +7,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "InquireServersQThread.h" #include @@ -35,7 +36,6 @@ #include "SALOME_NamingService.hxx" #include "utilities.h" #include "OpUtil.hxx" -using namespace std; #include CORBA_CLIENT_HEADER(SALOME_Session) #include CORBA_CLIENT_HEADER(SALOME_Registry) @@ -50,7 +50,7 @@ static QString findFile( QString filename ); static QString addSlash( const QString& path ); InquireServersGUI::InquireServersGUI() - : QVBox(0, "SFA splash", Qt::WDestructiveClose | Qt::WStyle_Customize | Qt::WStyle_NoBorder ) + : QVBox(0, "SFA splash", Qt::WDestructiveClose | Qt::WStyle_Customize | Qt::WStyle_NoBorder | WType_TopLevel | WStyle_StaysOnTop | WX11BypassWM ) { myGUI = false; myThread = new InquireServersQThread(this); @@ -193,7 +193,6 @@ void InquireServersGUI::customEvent( QCustomEvent* pe ) int InquireServersGUI::getExitStatus() { myThread->getExitStatus(); - return 0; } InquireServersQThread::InquireServersQThread( InquireServersGUI* r ) diff --git a/src/Loader/SALOME_Session_Loader.cxx b/src/Loader/SALOME_Session_Loader.cxx index c15bf1162..3aff04564 100644 --- a/src/Loader/SALOME_Session_Loader.cxx +++ b/src/Loader/SALOME_Session_Loader.cxx @@ -7,6 +7,7 @@ // Module : SALOME // $Header$ +using namespace std; /*! \file SALOME_Session_loader.cxx */ @@ -18,7 +19,6 @@ #include "Utils_SINGLETON.hxx" #include "SALOME_NamingService.hxx" #include "utilities.h" -using namespace std; //! CORBA client for SALOME Session server : launch GUI /*! diff --git a/src/Logger/SALOME_Logger_Server.cxx b/src/Logger/SALOME_Logger_Server.cxx index bb772db84..5d1b3a4a7 100644 --- a/src/Logger/SALOME_Logger_Server.cxx +++ b/src/Logger/SALOME_Logger_Server.cxx @@ -8,13 +8,12 @@ // Author : Vasily Rusyaev // Module : SALOME +using namespace std; #include - #include "SALOME_Logger_Server.hxx" #include #include #include -using namespace std; omni_mutex Logger::myLock; ///////////////////////////////////////////////////////////////////// diff --git a/src/Logger/SALOME_Trace.cxx b/src/Logger/SALOME_Trace.cxx index 2fb550990..d139476c1 100644 --- a/src/Logger/SALOME_Trace.cxx +++ b/src/Logger/SALOME_Trace.cxx @@ -8,15 +8,14 @@ // Author : Vasily Rusyaev // Module : SALOME +using namespace std; #include "SALOME_Trace.hxx" #include #include +//#include #include #include -#include "SALOME_Trace.hxx" -using namespace std; - ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// diff --git a/src/Logger/SALOME_Trace.hxx b/src/Logger/SALOME_Trace.hxx index 0a8e0f625..90fbfd06f 100644 --- a/src/Logger/SALOME_Trace.hxx +++ b/src/Logger/SALOME_Trace.hxx @@ -42,10 +42,10 @@ # endif /* WNT */ -#include +using namespace std; +#include #include "Logger.hh" -using namespace std; class SALOME_Trace : public ostrstream { diff --git a/src/Logger/SALOME_Trace.py b/src/Logger/SALOME_Trace.py index 900693e41..fd507c7c7 100644 --- a/src/Logger/SALOME_Trace.py +++ b/src/Logger/SALOME_Trace.py @@ -16,8 +16,8 @@ import os trace="local" if (os.environ.has_key("SALOME_trace")): - if (os.environ["SALOME_trace"] == "with_logger"): - trace="logger" + if (os.environ["SALOME_trace"] == "with_logger"): + trace="logger" class SALOME_Trace : def __init__(self): diff --git a/src/MPIContainer/MPIContainer_i.cxx b/src/MPIContainer/MPIContainer_i.cxx index ad729c45a..22ba51053 100644 --- a/src/MPIContainer/MPIContainer_i.cxx +++ b/src/MPIContainer/MPIContainer_i.cxx @@ -24,38 +24,30 @@ // File : MPIContainer_i.cxx // Module : SALOME +using namespace std; #include #include #include #include "MPIContainer_i.hxx" -#include "SALOME_NamingService.hxx" -#include "Utils_SINGLETON.hxx" -#include "OpUtil.hxx" #include "utilities.h" -using namespace std; -// L'appel au registry SALOME ne se fait que pour le process 0 -Engines_MPIContainer_i::Engines_MPIContainer_i(int nbproc, int numproc, - CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - char * containerName, - int argc, char *argv[]) - : Engines_Container_i(orb,poa,containerName,argc,argv,false,false), MPIObject_i(nbproc,numproc) +MPIContainer_i::MPIContainer_i(int nbproc, int numproc, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + char * containerName) + : Engines_Container_i(orb,poa,containerName,0), MPIObject_i(nbproc,numproc) { - MESSAGE("[" << numproc << "] activate object"); _id = _poa->activate_object(this); - if(numproc==0){ - - // _NS = new SALOME_NamingService(_orb); + MESSAGE("[" << _numproc << "] containerName=" << _containerName); + if( _numproc == 0 ){ _NS = SINGLETON_::Instance() ; ASSERT(SINGLETON_::IsAlreadyExisting()) ; _NS->init_orb( orb ) ; Engines::Container_ptr pCont = Engines::Container::_narrow(POA_Engines::MPIContainer::_this()); - SCRUTE(_containerName); - _NS->Register(pCont, _containerName.c_str()); + _NS->Register(pCont, _containerName.c_str()); } // Root recupere les ior des container des autre process @@ -63,176 +55,52 @@ Engines_MPIContainer_i::Engines_MPIContainer_i(int nbproc, int numproc, BCastIOR(_orb,pobj,true); } -Engines_MPIContainer_i::Engines_MPIContainer_i(int nbproc, int numproc) - : Engines_Container_i(), MPIObject_i(nbproc,numproc) -{ -} - -Engines_MPIContainer_i::~Engines_MPIContainer_i(void) +MPIContainer_i::~MPIContainer_i(void) { - MESSAGE("[" << _numproc << "] Engines_MPIContainer_i::~Engines_MPIContainer_i()"); if( !handle_map.empty() ){ - MESSAGE("[" << _numproc << "] Engines_MPIContainer_i::~Engines_MPIContainer_i: warning destroy a not empty container"); + MESSAGE("[" << _numproc << "] MPIContainer_i::~MPIContainer_i: warning destroy a not empty container"); } } -// Start MPI Container -Engines::MPIContainer_ptr Engines_MPIContainer_i::start_MPIimpl( - const char* ContainerName, - CORBA::Short nbproc ) -{ - - char nbp[1024]; - - MESSAGE("[" << _numproc << "] start_impl argc " << _argc << " ContainerName " << ContainerName - << hex << this << dec) ; - _numInstanceMutex.lock() ; // lock on the instance number - - CORBA::Object_var obj = Engines::MPIContainer::_nil() ; - bool nilvar = true ; - try { - string cont("/Containers/"); - cont += machineName() ; - cont += "/" ; - cont += ContainerName; - INFOS("[" << _numproc << "] " << machineName() << " start_impl unknown container " << cont.c_str() - << " try to Resolve" ); - obj = _NS->Resolve( cont.c_str() ); - nilvar = CORBA::is_nil( obj ) ; - if ( nilvar ) { - INFOS("[" << _numproc << "] " << machineName() << " start_impl unknown container " - << ContainerName); - } - } - catch (ServiceUnreachable&) { - INFOS("[" << _numproc << "] " << machineName() << "Caught exception: Naming Service Unreachable"); - } - catch (...) { - INFOS("[" << _numproc << "] " << machineName() << "Caught unknown exception."); - } - if ( !nilvar ) { - _numInstanceMutex.unlock() ; - MESSAGE("[" << _numproc << "] start_impl container found without new launch") ; - return Engines::MPIContainer::_narrow(obj); - } - int i = 0 ; - while ( _argv[ i ] ) { - MESSAGE("[" << _numproc << "] argv" << i << " " << _argv[ i ]) ; - i++ ; - } - sprintf(nbp,"mpirun -np %d SALOME_MPIContainer ",nbproc); - string shstr(nbp); - shstr += ContainerName ; - if ( _argc == 4 ) { - shstr += " " ; - shstr += _argv[ 2 ] ; - shstr += " " ; - shstr += _argv[ 3 ] ; - } - shstr += " > /tmp/" ; - shstr += ContainerName ; - shstr += ".log 2>&1 &" ; - MESSAGE("system(" << shstr << ")") ; - int status = system( shstr.c_str() ) ; - if (status == -1) { - INFOS("[" << _numproc << "] Engines_MPIContainer_i::start_impl SALOME_MPIContainer failed (system command status -1)") ; - } - else if (status == 217) { - INFOS("[" << _numproc << "] Engines_MPIContainer_i::start_impl SALOME_MPIContainer failed (system command status 217)") ; - } - INFOS("[" << _numproc << "] " << machineName() << " Engines_MPIContainer_i::start_impl SALOME_MPIContainer launch done"); - - obj = Engines::MPIContainer::_nil() ; - try { - string cont("/Containers/"); - cont += machineName() ; - cont += "/" ; - cont += ContainerName; - nilvar = true ; - int count = 20 ; - while ( nilvar && count >= 0) { - sleep( 1 ) ; - obj = _NS->Resolve(cont.c_str()); - nilvar = CORBA::is_nil( obj ) ; - if ( nilvar ) { - INFOS("[" << _numproc << "] " << count << ". " << machineName() - << " start_impl unknown container " << cont.c_str()); - count -= 1 ; - } - } - _numInstanceMutex.unlock() ; - if ( !nilvar ) { - MESSAGE("[" << _numproc << "] start_impl container found after new launch of SALOME_MPIContainer") ; - } - return Engines::MPIContainer::_narrow(obj); - } - catch (ServiceUnreachable&) { - INFOS("[" << _numproc << "] " << machineName() << "Caught exception: Naming Service Unreachable"); - } - catch (...) { - INFOS("[" << _numproc << "] " << machineName() << "Caught unknown exception."); - } - _numInstanceMutex.unlock() ; - MESSAGE("[" << _numproc << "] start_impl MPI container not found after new launch of SALOME_MPIContainer") ; - return Engines::MPIContainer::_nil() ; -} - // Load component -Engines::Component_ptr Engines_MPIContainer_i::load_impl(const char* nameToRegister, +Engines::Component_ptr MPIContainer_i::load_impl(const char* nameToRegister, const char* componentName) { int ip; + Engines::Component_var iobject; + Engines::MPIObject_var pobj; + char cproc[4]; if( _numproc == 0 ){ // Invocation du chargement du composant dans les autres process for(ip= 1;ip<_nbproc;ip++) - (Engines::MPIContainer::_narrow((*_tior)[ip]))->SPload_impl(nameToRegister, + (Engines::MPIContainer::_narrow((*_tior)[ip]))->load_impl(nameToRegister, componentName); } - return Lload_impl(nameToRegister,componentName); - -} - -// Load component -void Engines_MPIContainer_i::SPload_impl(const char* nameToRegister, - const char* componentName) -{ - Lload_impl(nameToRegister,componentName); -} - -Engines::Component_ptr Engines_MPIContainer_i::Lload_impl( - const char* nameToRegister, - const char* componentName) -{ - Engines::Component_var iobject; - Engines::MPIObject_var pobj; - char cproc[4]; - sprintf(cproc,"_%d",_numproc); - BEGIN_OF("[" << _numproc << "] MPIContainer_i::Lload_impl"); + BEGIN_OF("[" << _numproc << "] MPIContainer_i::load_impl"); _numInstanceMutex.lock() ; // lock on the instance number _numInstance++ ; char _aNumI[12]; sprintf(_aNumI,"%d",_numInstance) ; + _numInstanceMutex.unlock() ; string _impl_name = componentName; - string _nameToRegister = nameToRegister; - string instanceName = _nameToRegister + "_inst_" + _aNumI + cproc; - MESSAGE("[" << _numproc << "] instanceName=" << instanceName); + string instanceName = string(nameToRegister) + "_inst_" + _aNumI + cproc; string absolute_impl_name(_impl_name); MESSAGE("[" << _numproc << "] absolute_impl_name=" << absolute_impl_name); void * handle = dlopen(absolute_impl_name.c_str(), RTLD_LAZY); if(!handle){ - INFOS("[" << _numproc << "] Can't load shared library : " << absolute_impl_name); - INFOS("[" << _numproc << "] error dlopen: " << dlerror()); + MESSAGE("[" << _numproc << "] Can't load shared library : " << absolute_impl_name); + MESSAGE("[" << _numproc << "] error dlopen: " << dlerror()); return Engines::Component::_nil() ; } - string factory_name = _nameToRegister + string("Engine_factory"); + string factory_name = string(nameToRegister) + string("Engine_factory"); MESSAGE("[" << _numproc << "] factory_name=" << factory_name) ; PortableServer::ObjectId * (*MPIComponent_factory) (int,int, @@ -253,7 +121,6 @@ Engines::Component_ptr Engines_MPIContainer_i::Lload_impl( if ((error = dlerror()) != NULL){ // Try to load a sequential component MESSAGE("[" << _numproc << "] Try to load a sequential component"); - _numInstanceMutex.unlock() ; iobject = Engines_Container_i::load_impl(nameToRegister,componentName); if( CORBA::is_nil(iobject) ) return Engines::Component::_duplicate(iobject); } @@ -261,32 +128,32 @@ Engines::Component_ptr Engines_MPIContainer_i::Lload_impl( // Instanciation du composant parallele MESSAGE("[" << _numproc << "] Try to load a parallel component"); PortableServer::ObjectId * id = (MPIComponent_factory) - (_nbproc,_numproc,_orb, _poa, _id, instanceName.c_str(), _nameToRegister.c_str()); + (_nbproc,_numproc,_orb, _poa, _id, instanceName.c_str(), nameToRegister); // get reference from id CORBA::Object_var o = _poa->id_to_reference(*id); pobj = Engines::MPIObject::_narrow(o) ; - iobject = Engines::Component::_narrow(o) ; + iobject = Engines::Component::_narrow(pobj) ; } + // Root recupere les ior des composants des autre process + BCastIOR(_orb,pobj,false); + if( _numproc == 0 ){ // utiliser + tard le registry ici : // register the engine under the name containerName.dir/nameToRegister.object - string component_registerName = _containerName + "/" + _nameToRegister; + string component_registerName = _containerName + "/" + nameToRegister; _NS->Register(iobject, component_registerName.c_str()) ; } + _numInstanceMutex.lock() ; // lock on the add on handle_map (necessary ?) handle_map[instanceName] = handle; _numInstanceMutex.unlock() ; - - // Root recupere les ior des composants des autre process - BCastIOR(_orb,pobj,false); - - END_OF("[" <<_numproc << "] MPIContainer_i::Lload_impl"); + END_OF("[" <<_numproc << "] MPIContainer_i::load_impl"); return Engines::Component::_duplicate(iobject); } -void Engines_MPIContainer_i::remove_impl(Engines::Component_ptr component_i) +void MPIContainer_i::remove_impl(Engines::Component_ptr component_i) { int ip; Engines::Component_ptr cptr; @@ -301,29 +168,10 @@ void Engines_MPIContainer_i::remove_impl(Engines::Component_ptr component_i) for(ip= 1;ip<_nbproc;ip++){ spcptr = Engines::MPIObject::_narrow((*(pcptr->tior()))[ip]); cptr = (Engines::Component_ptr)spcptr; - (Engines::MPIContainer::_narrow((*_tior)[ip]))->SPremove_impl(cptr); + (Engines::MPIContainer::_narrow((*_tior)[ip]))->remove_impl(cptr); } } - Lremove_impl(component_i); -} - -void Engines_MPIContainer_i::SPremove_impl(Engines::Component_ptr component_i) -{ - Lremove_impl(component_i); -} - -void Engines_MPIContainer_i::Lremove_impl(Engines::Component_ptr component_i) -{ - int ip; - Engines::Component_ptr cptr; - Engines::MPIObject_ptr pcptr; - Engines::MPIObject_ptr spcptr; - - BEGIN_OF("[" << _numproc << "] MPIContainer_i::Lremove_impl"); - - ASSERT(! CORBA::is_nil(component_i)); - string instanceName = component_i->instanceName() ; MESSAGE("[" << _numproc << "] unload component " << instanceName); component_i->destroy() ; @@ -342,45 +190,29 @@ void Engines_MPIContainer_i::Lremove_impl(Engines::Component_ptr component_i) { MESSAGE("[" << _numproc << "] stay " << (*im).first); } - - END_OF("[" << _numproc << "] MPIContainer_i::Lremove_impl"); - } -void Engines_MPIContainer_i::finalize_removal() +void MPIContainer_i::finalize_removal() { int ip; + MESSAGE("[" << _numproc << "] finalize unload : dlclose"); + if( _numproc == 0 ){ // Invocation de la destruction du composant dans les autres process for(ip= 1;ip<_nbproc;ip++) - (Engines::MPIContainer::_narrow((*_tior)[ip]))->SPfinalize_removal(); + (Engines::MPIContainer::_narrow((*_tior)[ip]))->finalize_removal(); } - Lfinalize_removal(); -} - -void Engines_MPIContainer_i::SPfinalize_removal() -{ - Lfinalize_removal(); -} - -void Engines_MPIContainer_i::Lfinalize_removal() -{ - BEGIN_OF("[" << _numproc << "] MPIContainer_i::Lfinalize_removal"); - map::iterator im ; - // lock on the explore remove_map & dlclose - _numInstanceMutex.lock() ; + _numInstanceMutex.lock() ; // lock on the explore remove_map & dlclose for (im = remove_map.begin() ; im != remove_map.end() ; im ++) { void * handle = (*im).second ; - MESSAGE("[" << _numproc << "] dlclose " << (*im).first); dlclose(handle) ; + MESSAGE("[" << _numproc << "] dlclose " << (*im).first); } - MESSAGE("[" << _numproc << "] remove_map.clear()"); remove_map.clear() ; _numInstanceMutex.unlock() ; - - END_OF("[" << _numproc << "] MPIContainer_i::Lfinalize_removal"); + MESSAGE("[" << _numproc << "] remove_map.clear()"); } diff --git a/src/MPIContainer/MPIContainer_i.hxx b/src/MPIContainer/MPIContainer_i.hxx index 7d9ddc9a2..390f6ce73 100644 --- a/src/MPIContainer/MPIContainer_i.hxx +++ b/src/MPIContainer/MPIContainer_i.hxx @@ -28,55 +28,34 @@ #define _SALOME_PCONTAINER_ #include -#include CORBA_SERVER_HEADER(SALOME_MPIContainer) +#include CORBA_SERVER_HEADER(MPIContainer) #include "SALOME_Container_i.hxx" +#include "SALOME_NamingService.hxx" +#include "Utils_SINGLETON.hxx" +#include "OpUtil.hxx" #include "MPIObject_i.hxx" -class Engines_MPIContainer_i : public POA_Engines::MPIContainer, - public Engines_Container_i, - public MPIObject_i +class MPIContainer_i : public POA_Engines::MPIContainer, + public Engines_Container_i, + public MPIObject_i { public: // Constructor - Engines_MPIContainer_i( int nbproc, int numproc, - CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - char * containerName, - int argc, char *argv[]); - Engines_MPIContainer_i(int nbproc, int numproc); + MPIContainer_i( int nbproc, int numproc, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + char * containerName); // Destructor - ~Engines_MPIContainer_i(); + ~MPIContainer_i(); - // Launch a new MPI container from the current container - Engines::MPIContainer_ptr start_MPIimpl(const char* ContainerName, - CORBA::Short nbproc); - - // Load a component in current MPI container - // synchronous version for process 0 + // Load a component Engines::Component_ptr load_impl(const char* nameToRegister, const char* componentName); - // asynchronous version for other process - void SPload_impl(const char* nameToRegister, const char* componentName); - // Unload a component from current MPI container - // synchronous version for process 0 + // Unload a component void remove_impl(Engines::Component_ptr component_i); - // asynchronous version for other process - void SPremove_impl(Engines::Component_ptr component_i); - - // synchronous version for process 0 void finalize_removal(); - // asynchronous version for other process - void SPfinalize_removal(); - - private: - // local version to not duplicate code - // called by synchronous and asynchronous version - Engines::Component_ptr Lload_impl(const char* nameToRegister, - const char* componentName); - void Lremove_impl(Engines::Component_ptr component_i); - void Lfinalize_removal(); }; #endif diff --git a/src/MPIContainer/MPIObject_i.cxx b/src/MPIContainer/MPIObject_i.cxx index 177a61ffb..218c01c9d 100644 --- a/src/MPIContainer/MPIObject_i.cxx +++ b/src/MPIContainer/MPIObject_i.cxx @@ -24,10 +24,10 @@ // File : MPIObject_i.cxx // Module : SALOME +using namespace std; #include "MPIObject_i.hxx" #include "utilities.h" #include -using namespace std; MPIObject_i::MPIObject_i() { @@ -109,21 +109,18 @@ void MPIObject_i::BCastIOR(CORBA::ORB_ptr orb, Engines::MPIObject_var pobj, } else{ // On envoie l'IOR au process 0 - ior = sior._retn(); - n = strlen(ior) + 1; + n = strlen((char*)sior); err = MPI_Send(&n,1,MPI_INTEGER,0,_numproc,MPI_COMM_WORLD); if(err){ MESSAGE("[" << _numproc << "] MPI_SEND error"); exit(1); } - err = MPI_Send(ior,n,MPI_CHARACTER,0,2*_numproc,MPI_COMM_WORLD); + err = MPI_Send((char*)sior,n,MPI_CHARACTER,0,2*_numproc,MPI_COMM_WORLD); if(err){ MESSAGE("[" << _numproc << "] MPI_SEND error"); exit(1); } } - MPI_Barrier(MPI_COMM_WORLD); - } diff --git a/src/MPIContainer/MPIObject_i.hxx b/src/MPIContainer/MPIObject_i.hxx index 47243a19b..e504bb829 100644 --- a/src/MPIContainer/MPIObject_i.hxx +++ b/src/MPIContainer/MPIObject_i.hxx @@ -28,7 +28,7 @@ #define _SALOME_POBJECT_I_H_ #include -#include CORBA_SERVER_HEADER(SALOME_MPIObject) +#include CORBA_SERVER_HEADER(MPIObject) class MPIObject_i: public POA_Engines::MPIObject { diff --git a/src/MPIContainer/Makefile.in b/src/MPIContainer/Makefile.in index c8af02841..da4e295d9 100644 --- a/src/MPIContainer/Makefile.in +++ b/src/MPIContainer/Makefile.in @@ -44,24 +44,15 @@ EXPORT_HEADERS = \ LIB = libSalomeMPIContainer.la LIB_SRC = MPIObject_i.cxx MPIContainer_i.cxx -LIB_SERVER_IDL = SALOME_MPIObject.idl SALOME_MPIContainer.idl +LIB_SERVER_IDL = TypeData.idl MPIObject.idl MPIContainer.idl # Executables targets BIN = SALOME_MPIContainer BIN_SRC = -BIN_SERVER_IDL = SALOME_MPIObject.idl SALOME_MPIContainer.idl +BIN_SERVER_IDL = TypeData.idl MPIObject.idl MPIContainer.idl -LDFLAGS+= -lSalomeContainer -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification -lSALOMELocalTrace -ifeq (@WITHMPICH@,yes) - CXXFLAGS+=${MPICH_INCLUDES} - CXX_DEPEND_FLAG+=${MPICH_INCLUDES} - LDFLAGS+= ${MPICH_LIBS} -endif - -ifeq (@WITHMPI@,yes) - CXXFLAGS+=${MPI_INCLUDES} - CXX_DEPEND_FLAG+=${MPI_INCLUDES} - LDFLAGS+= ${MPI_LIBS} -endif +CXXFLAGS+=${MPICH_INCLUDES} +CXX_DEPEND_FLAG+=${MPICH_INCLUDES} +LDFLAGS+= -lSalomeContainer -lSalomeNS -lRegistry -lOpUtil ${MPICH_LIBS} @CONCLUDE@ diff --git a/src/MPIContainer/SALOME_MPIContainer.cxx b/src/MPIContainer/SALOME_MPIContainer.cxx index d6fb4474f..f11dbb26d 100644 --- a/src/MPIContainer/SALOME_MPIContainer.cxx +++ b/src/MPIContainer/SALOME_MPIContainer.cxx @@ -1,31 +1,52 @@ +// SALOME MPIContainer : implemenation of container based on MPI libraries +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// 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 +// 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 +// +// +// +// File : SALOME_MPIContainer.cxx +// Module : SALOME + +using namespace std; #include #include "MPIContainer_i.hxx" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" #include "utilities.h" #include -using namespace std; int main(int argc, char* argv[]) { int nbproc, numproc; - int flag; - Engines_MPIContainer_i * myContainer=NULL; + MPIContainer_i * myContainer; BEGIN_OF(argv[0]) try { MESSAGE("Connection MPI"); + MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD,&nbproc); MPI_Comm_rank(MPI_COMM_WORLD,&numproc); - MESSAGE("[" << numproc << "] Initialisation CORBA"); + MESSAGE("Initialisation CORBA"); // 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 ) ; + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); // Obtain a reference to the root POA. CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); @@ -65,37 +86,35 @@ int main(int argc, char* argv[]) containerName = argv[1] ; } - MESSAGE("[" << numproc << "] Chargement container"); - myContainer = new Engines_MPIContainer_i(nbproc,numproc,orb,factory_poa, containerName,argc,argv); + MESSAGE("Chargement container sur proc: " << numproc); + myContainer = new MPIContainer_i(nbproc,numproc,orb,factory_poa, containerName); + MESSAGE("Fin chargement container"); pman->activate(); orb->run(); orb->destroy(); + delete myContainer; + MPI_Finalize(); } - catch(CORBA::SystemException&){ - INFOS("Caught CORBA::SystemException."); - } - catch(PortableServer::POA::WrongPolicy&){ - INFOS("Caught CORBA::WrongPolicyException."); + catch(CORBA::SystemException&) { + INFOS("Caught CORBA::SystemException.") } - catch(PortableServer::POA::ServantAlreadyActive&){ - INFOS("Caught CORBA::ServantAlreadyActiveException"); + catch(PortableServer::POA::WrongPolicy&) + { + INFOS("Caught CORBA::WrongPolicyException.") } - catch(CORBA::Exception&){ - INFOS("Caught CORBA::Exception."); + catch(PortableServer::POA::ServantAlreadyActive&) + { + INFOS("Caught CORBA::ServantAlreadyActiveException") } - catch(...){ - INFOS("Caught unknown exception."); + catch(CORBA::Exception&) { + INFOS("Caught CORBA::Exception.") } - - if(myContainer) - delete myContainer; - MPI_Initialized(&flag); - if(flag) - MPI_Finalize(); - + catch(...) { + INFOS("Caught unknown exception.") + } END_OF(argv[0]); } diff --git a/src/MSG2QM/msg2qm.cxx b/src/MSG2QM/msg2qm.cxx index 5322a33fc..097947db2 100644 --- a/src/MSG2QM/msg2qm.cxx +++ b/src/MSG2QM/msg2qm.cxx @@ -24,6 +24,7 @@ // File : msg2qm.cxx // Module : SALOME +using namespace std; /**************************************************************************** ** $Id$ ** @@ -41,7 +42,6 @@ #include #include -using namespace std; static QString* defaultScope = 0; diff --git a/src/Makefile.in b/src/Makefile.in index 47a5d356e..5c3530e4b 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -33,23 +33,19 @@ VPATH=.:@srcdir@ @COMMENCE@ SUBDIRS = MSG2QM SALOMELocalTrace Logger SALOMELogger Utils PatchQt \ - GenericObj NamingService Registry \ + GenericObj MEDWrapper NamingService Registry \ ModuleCatalog DataTypeCatalog RessourcesCatalog \ Notification NOTIFICATION_SWIG \ Container TestContainer LifeCycleCORBA HDFPersist \ VTKFilter OBJECT \ - TOOLSDS SALOMEDS \ + TOOLSDS SALOMEDS Event \ SALOMEGUI Plot2d VTKViewer OCCViewer \ SUPERVGraph \ Session SALOME_SWIG TOOLSGUI SALOME_PY \ RegistryDisplay ModuleGenerator SALOME_PYQT Loader -ifeq (@WITHMPI@,yes) - SUBDIRS+= MPIContainer MPILifeCycleCORBA TestMPIContainer -endif - ifeq (@WITHMPICH@,yes) - SUBDIRS+= MPIContainer MPILifeCycleCORBA TestMPIContainer + SUBDIRS+= MPIContainer endif @MODULE@ diff --git a/src/ModuleCatalog/Makefile.in b/src/ModuleCatalog/Makefile.in index 475f86e06..e6b0cc72d 100644 --- a/src/ModuleCatalog/Makefile.in +++ b/src/ModuleCatalog/Makefile.in @@ -34,20 +34,25 @@ VPATH=.:@srcdir@:@top_srcdir@/idl @COMMENCE@ +EXPORT_PYSCRIPTS = SALOME_TestModuleCatalog.py EXPORT_HEADERS = \ SALOME_ModuleCatalog_impl.hxx \ SALOME_ModuleCatalog_Acomponent_impl.hxx \ PathPrefix.hxx \ SALOME_ModuleCatalog_Parser.hxx \ + SALOME_ModuleCatalog_Parser_IO.hxx \ SALOME_ModuleCatalog_Handler.hxx # Libraries targets LIB = libSalomeCatalog.la LIB_SRC = \ SALOME_ModuleCatalog_Handler.cxx \ + SALOME_ModuleCatalog_Parser_IO.cxx \ SALOME_ModuleCatalog_impl.cxx \ SALOME_ModuleCatalog_Acomponent_impl.cxx +CXXFLAGS+=-ftemplate-depth-32 + # Executables targets # trouble we have client and serveur and build don't known about this with rule # in fact client is a test ! So it may go away BIN ! @@ -56,7 +61,6 @@ BIN_SRC = BIN_SERVER_IDL = SALOME_ModuleCatalog.idl CPPFLAGS+= $(QT_MT_INCLUDES) -CXXFLAGS+= @CXXTMPDPTHFLAGS@ LDFLAGS+= $(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/ModuleCatalog/PathPrefix.hxx b/src/ModuleCatalog/PathPrefix.hxx index fb6346afa..5bdb9756c 100644 --- a/src/ModuleCatalog/PathPrefix.hxx +++ b/src/ModuleCatalog/PathPrefix.hxx @@ -25,6 +25,7 @@ // Author : Estelle Deville // Module : SALOME // $Header$ +// #ifndef PATH_PREFIX_H #define PATH_PREFIX_H @@ -35,7 +36,7 @@ struct PathPrefix { string path ; - vector ListOfComputer ; + vector listOfComputer ; } ; typedef vector ListOfPathPrefix ; diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx index 034014eee..4cf8e579a 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx @@ -26,8 +26,11 @@ // Module : SALOME // $Header$ -#include "SALOME_ModuleCatalog_Acomponent_impl.hxx" using namespace std; +#include "SALOME_ModuleCatalog_Acomponent_impl.hxx" + +#include "Utils_ExceptHandlers.hxx" +UNEXPECT_CATCH(MC_NotFound, SALOME_ModuleCatalog::NotFound); //---------------------------------------------------------------------- // Function : SALOME_ModuleCatalog_AcomponentImpl @@ -37,46 +40,12 @@ using namespace std; // Affect too the constraint and the interfaces of the component // and the pathes prefixes for all computers //---------------------------------------------------------------------- -SALOME_ModuleCatalog_AcomponentImpl::SALOME_ModuleCatalog_AcomponentImpl( - const char* name, - const char* username, - const char* constraint, - SALOME_ModuleCatalog::ComponentType componenttype, - CORBA::Boolean componentmultistudy, - const char* icone, - SALOME_ModuleCatalog::ListOfDefInterface list_interfaces, - ListOfPathPrefix pathes) +SALOME_ModuleCatalog_AcomponentImpl::SALOME_ModuleCatalog_AcomponentImpl +(SALOME_ModuleCatalog::Component &C) : _Component(C) { - MESSAGE("Component creation") - // Affect component name - _component_name = new char[strlen(name)+1]; - strcpy(_component_name, name); - - // Affect component user name - _component_user_name = new char[strlen(username)+1]; - strcpy(_component_user_name, username); - - // Affect constraint - _constraint =new char[strlen(constraint)+1]; - strcpy(_constraint, constraint); - - // Affect component type - _componenttype = componenttype; - - // Affect component multistudy - _componentmultistudy = componentmultistudy; - - // Affect icone - _icone =new char[strlen(icone)+1]; - strcpy(_icone, icone); - - //Affect interfaces - _list_interfaces.length(list_interfaces.length()); - _list_interfaces = list_interfaces; - - // affect path prefixes - _pathes.resize(pathes.size()); - _pathes = pathes ; + BEGIN_OF("SALOME_ModuleCatalog_AcomponentImpl"); + + END_OF("SALOME_ModuleCatalog_AcomponentImpl"); } //---------------------------------------------------------------------- @@ -85,11 +54,10 @@ SALOME_ModuleCatalog_AcomponentImpl::SALOME_ModuleCatalog_AcomponentImpl( //---------------------------------------------------------------------- SALOME_ModuleCatalog_AcomponentImpl::~SALOME_ModuleCatalog_AcomponentImpl() { - MESSAGE("Component destruction") - // empty memory - delete [] _component_name; - delete [] _component_user_name; - delete [] _constraint; + BEGIN_OF("~SALOME_ModuleCatalog_AcomponentImpl"); + + + END_OF("~SALOME_ModuleCatalog_AcomponentImpl"); } //---------------------------------------------------------------------- @@ -99,21 +67,26 @@ SALOME_ModuleCatalog_AcomponentImpl::~SALOME_ModuleCatalog_AcomponentImpl() SALOME_ModuleCatalog::ListOfInterfaces* SALOME_ModuleCatalog_AcomponentImpl::GetInterfaceList() { - SALOME_ModuleCatalog::ListOfInterfaces_var _list = new SALOME_ModuleCatalog::ListOfInterfaces; + BEGIN_OF("GetInterfaceList"); + + SALOME_ModuleCatalog::ListOfInterfaces_var _list + = new SALOME_ModuleCatalog::ListOfInterfaces; // All the interfaces are defined in _list_interfaces affected at the // component creation - unsigned int _length_interfaces =_list_interfaces.length(); + unsigned int _length_interfaces = _Component.interfaces.length(); _list->length(_length_interfaces); // Parse all the interfaces to get their name for (unsigned int ind = 0; ind < _length_interfaces; ind++) { - _list[ind] = CORBA::string_dup(_list_interfaces[ind].interfacename); - MESSAGE("The component " << _component_name << " contains " << _list[ind] << " as interface") + _list[ind] = CORBA::string_dup(_Component.interfaces[ind].interfacename); + MESSAGE("The component " << _Component.name + << " contains " << _list[ind] << " as interface"); } + END_OF("GetInterfaceList"); return _list._retn(); } @@ -125,52 +98,44 @@ SALOME_ModuleCatalog::DefinitionInterface* SALOME_ModuleCatalog_AcomponentImpl::GetInterface(const char* interfacename) throw(SALOME_ModuleCatalog::NotFound) { - SALOME_ModuleCatalog::DefinitionInterface_var _interface = new SALOME_ModuleCatalog::DefinitionInterface; - SALOME_ModuleCatalog::Service_var _service = new SALOME_ModuleCatalog::Service; - // Variables initialisation - _interface->interfaceservicelist.length(0); - int _length = 0; + BEGIN_OF("GetInterface"); + SCRUTE(interfacename); + + SALOME_ModuleCatalog::DefinitionInterface *_interface = + new SALOME_ModuleCatalog::DefinitionInterface; + bool _find = false ; // looking for the specified interface - for (unsigned int ind = 0; ind < _list_interfaces.length(); ind++) + for (unsigned int ind = 0; ind < _Component.interfaces.length(); ind++) { - if (strcmp(interfacename, _list_interfaces[ind].interfacename) == 0) + SALOME_ModuleCatalog::DefinitionInterface &I + = _Component.interfaces[ind]; + + if (strcmp(interfacename, I.interfacename) == 0) { // wanted interface _find = true ; - - // Affect the name of the interface - _interface->interfacename = interfacename; - - // Affect each service of the wanted interface - for (unsigned int ind1 = 0; ind1 < _list_interfaces[ind].interfaceservicelist.length() ; ind1++) - { - _interface->interfaceservicelist.length(_length+1); - _service = _duplicate_service(_list_interfaces[ind].interfaceservicelist[ind1]); - _interface->interfaceservicelist[_length] = _service; - - _length++; - } - + duplicate(*_interface, I); } } - + + SCRUTE(_find); if (!_find) { // The interface was not found, the exception should be thrown - char * message = new char[100]; - strcpy(message, "The interface "); - strcat(message,interfacename); - strcat(message, " of the component "); - strcat(message,_component_name); - strcat(message, " was not found") ; - MESSAGE("The interface " << interfacename << " of the component " << _component_name << " was not found") - throw SALOME_ModuleCatalog::NotFound(message); - delete [] message; + string message = "The interface"; + message += interfacename; + message += " of the component "; + message += _Component.name; + message += " was not found"; + MESSAGE(message) + throw SALOME_ModuleCatalog::NotFound(message.c_str()); } - return _interface._retn(); + END_OF("GetInterface"); + + return _interface; } @@ -184,26 +149,32 @@ SALOME_ModuleCatalog::ListOfServices* SALOME_ModuleCatalog_AcomponentImpl::GetServiceList(const char* interfacename) throw(SALOME_ModuleCatalog::NotFound) { - SALOME_ModuleCatalog::ListOfServices_var _list = new SALOME_ModuleCatalog::ListOfServices; + BEGIN_OF("GetServiceList"); + SCRUTE(interfacename); + + SALOME_ModuleCatalog::ListOfServices_var _list + = new SALOME_ModuleCatalog::ListOfServices; // Variables initialisation - _list->length(0); bool _find = false ; // looking for the specified interface - for (unsigned int ind = 0; ind < _list_interfaces.length(); ind++) + for (unsigned int ind = 0; ind < _Component.interfaces.length(); ind++) { - if (strcmp(interfacename, _list_interfaces[ind].interfacename) == 0) + SALOME_ModuleCatalog::DefinitionInterface & I = _Component.interfaces[ind]; + + if (strcmp(interfacename, I.interfacename) == 0) { _find = true ; // wanted interface // Get the list of services name for this interface - unsigned int _length_services = _list_interfaces[ind].interfaceservicelist.length(); + unsigned int _length_services = I.interfaceservicelist.length(); _list->length(_length_services); for (unsigned int ind1 = 0; ind1 < _length_services ; ind1++) { - _list[ind1] = CORBA::string_dup(_list_interfaces[ind].interfaceservicelist[ind1].ServiceName); - MESSAGE("The interface " << interfacename << " of the component " << _component_name << " contains " << _list[ind1] << " as a service") + _list[ind1] = CORBA::string_dup(I.interfaceservicelist[ind1].ServiceName); + MESSAGE("The interface " << interfacename << " of the component " + << _Component.name << " contains " << _list[ind1] << " as a service") } } } @@ -211,17 +182,16 @@ SALOME_ModuleCatalog_AcomponentImpl::GetServiceList(const char* interfacename) if (!_find) { // The interface was not found, the exception should be thrown - char * message = new char[100]; - strcpy(message, "The interface "); - strcat(message,interfacename); - strcat(message, " of the component "); - strcat(message,_component_name); - strcat(message, " was not found") ; - MESSAGE("The interface " << interfacename << " of the component " << _component_name << " was not found") - throw SALOME_ModuleCatalog::NotFound(message); - delete [] message; + string message = "The interface"; + message += interfacename; + message += " of the component "; + message += _Component.name; + message += " was not found"; + MESSAGE(message) + throw SALOME_ModuleCatalog::NotFound(message.c_str()); } + END_OF("GetServiceList"); return _list._retn(); } @@ -235,48 +205,63 @@ SALOME_ModuleCatalog_AcomponentImpl::GetService(const char* interfacename, const char* servicename) throw(SALOME_ModuleCatalog::NotFound) { - SALOME_ModuleCatalog::Service_var _service = new SALOME_ModuleCatalog::Service; - // Varaibles initialisation + BEGIN_OF("GetService"); + SCRUTE(interfacename); + SCRUTE(servicename); + + Unexpect aCatch( MC_NotFound ); + SALOME_ModuleCatalog::Service *service = new SALOME_ModuleCatalog::Service; + + // Variables initialization bool _find = false ; + // looking for the specified interface - for (unsigned int ind = 0; ind < _list_interfaces.length(); ind++) + for (unsigned int ind = 0; ind < _Component.interfaces.length(); ind++) { - if (strcmp(interfacename, _list_interfaces[ind].interfacename) == 0) + SCRUTE(ind); + SCRUTE(_Component.interfaces[ind].interfacename); + + SALOME_ModuleCatalog::DefinitionInterface &I = _Component.interfaces[ind]; + if (strcmp(interfacename, I.interfacename) == 0) { // wanted interface // looking for the specified service - for (unsigned int ind1 = 0; ind1 < _list_interfaces[ind].interfaceservicelist.length() ; ind1++) + for (unsigned int ind1 = 0; ind1 < I.interfaceservicelist.length() ; ind1++) { - if (strcmp(servicename, _list_interfaces[ind].interfaceservicelist[ind1].ServiceName) == 0) + SALOME_ModuleCatalog::Service &S = I.interfaceservicelist[ind1]; + SCRUTE(ind1); + SCRUTE(S.ServiceName); + + if (strcmp(servicename, S.ServiceName) == 0) { // Wanted Service // Affect the service to be returned _find = true ; - _service = _duplicate_service(_list_interfaces[ind].interfaceservicelist[ind1]); + duplicate(*service, S); } } } } + SCRUTE(_find); if (!_find) { - // The service was not found, the exception should be thrown - char * message = new char[100]; - strcpy(message, "The service "); - strcat(message, servicename); - strcat(message," of the interface "); - strcat(message,interfacename); - strcat(message, " of the component "); - strcat(message,_component_name); - strcat(message, " was not found") ; - MESSAGE("The service " << servicename << " of the interface " << interfacename << " of the component " << _component_name << " was not found") - throw SALOME_ModuleCatalog::NotFound(message); - delete [] message; + // The interface was not found, the exception should be thrown + string message = "The service"; + message += servicename; + message += " of the interface "; + message += interfacename; + message += " of the component "; + message += _Component.name; + message += " was not found"; + MESSAGE(message) + throw SALOME_ModuleCatalog::NotFound(message.c_str()); } - return _service._retn(); + END_OF("GetService"); + return service; } //---------------------------------------------------------------------- @@ -287,26 +272,30 @@ SALOME_ModuleCatalog::Service* SALOME_ModuleCatalog_AcomponentImpl::GetDefaultService(const char* interfacename) throw(SALOME_ModuleCatalog::NotFound) { - SALOME_ModuleCatalog::Service_var _service = new SALOME_ModuleCatalog::Service; + BEGIN_OF("GetDefaultService"); + SCRUTE(interfacename); + + Unexpect aCatch( MC_NotFound ); + SALOME_ModuleCatalog::Service *_service = new SALOME_ModuleCatalog::Service; // Variables initialisation bool _find = false ; // looking for the specified interface - for (unsigned int ind = 0; ind < _list_interfaces.length(); ind++) + for (unsigned int ind = 0; ind < _Component.interfaces.length(); ind++) { - if (strcmp(interfacename, _list_interfaces[ind].interfacename) == 0) + if (strcmp(interfacename, _Component.interfaces[ind].interfacename) == 0) { // wanted interface // looking for the defautl service of the wanted interface - for (unsigned int ind1 = 0; ind1 < _list_interfaces[ind].interfaceservicelist.length() ; ind1++) + for (unsigned int ind1 = 0; ind1 < _Component.interfaces[ind].interfaceservicelist.length() ; ind1++) { - if (_list_interfaces[ind].interfaceservicelist[ind1].Servicebydefault) + if (_Component.interfaces[ind].interfaceservicelist[ind1].Servicebydefault) { // Default Service // affect the service to be returned _find = true ; - _service = _duplicate_service(_list_interfaces[ind].interfaceservicelist[ind1]); + duplicate(*_service, _Component.interfaces[ind].interfaceservicelist[ind1]); } } @@ -316,18 +305,17 @@ SALOME_ModuleCatalog_AcomponentImpl::GetDefaultService(const char* interfacename if (!_find) { // The service was not found, the exception should be thrown - char * message = new char[100]; - strcpy(message, "The default service of the interface "); - strcat(message,interfacename); - strcat(message, " of the component "); - strcat(message,_component_name); - strcat(message, " was not found") ; - MESSAGE("The default service of the interface " << interfacename << " of the component " << _component_name << " was not found") - throw SALOME_ModuleCatalog::NotFound(message); - delete [] message; + string message = "The default service of the interface "; + message += interfacename; + message += " of the component "; + message += _Component.name; + message += " was not found"; + MESSAGE(message) + throw SALOME_ModuleCatalog::NotFound(message.c_str()); } - return _service._retn(); + END_OF("GetDefaultService"); + return _service; } //---------------------------------------------------------------------- @@ -338,42 +326,42 @@ char* SALOME_ModuleCatalog_AcomponentImpl::GetPathPrefix(const char* machinename) throw(SALOME_ModuleCatalog::NotFound) { - MESSAGE("Begin of GetPathPrefix") - // Variables initialisation + BEGIN_OF("GetPathPrefix"); + SCRUTE(machinename); + Unexpect aCatch( MC_NotFound ); + + // Variables initialisation char* _path = NULL; bool _find = false ; // Parse all the path prefixes // looking for the wanted computer - for (unsigned int ind = 0 ; ind < _pathes.size() ; ind++) - { - for (unsigned int ind1 = 0 ; ind1 < _pathes[ind].ListOfComputer.size() ; ind1++) - { - if (strcmp(machinename, _pathes[ind].ListOfComputer[ind1].c_str()) == 0) - { - _find = true ; - // Wanted computer - // affect the path to be returned - const char* _temp = _pathes[ind].path.c_str() ; - _path = new char[strlen(_temp)+1]; - strcpy(_path,_temp); - } - } - } - - if (!_find) + for (unsigned int ind = 0 ; ind < _Component.paths.length() ; ind++) { - // The computer was not found, the exception should be thrown - char * message = new char[100]; - strcpy(message, "The computer "); - strcat(message,machinename); - strcat(message, " was not found in the catalog associated to the component ") ; - strcat(message,_component_name); - MESSAGE("The computer " << machinename << " was not found in the catalog associated to the component " << _component_name) - throw SALOME_ModuleCatalog::NotFound(message); - delete [] message; - } - + if (strcmp(machinename, _Component.paths[ind].machine) == 0) + { + _find = true ; + // Wanted computer + // affect the path to be returned + const char* _temp = _Component.paths[ind].path ; + _path = new char[strlen(_temp)+1]; + strcpy(_path,_temp); + } + } + + SCRUTE(_find); + if (!_find) + { + // The computer was not found, the exception should be thrown + string message = "The computer "; + message += machinename; + message += " was not found in the catalog associated to the component "; + message += _Component.name; + MESSAGE(message) + throw SALOME_ModuleCatalog::NotFound(message.c_str()); + } + + END_OF("GetPathPrefix"); return _path; } @@ -383,7 +371,7 @@ SALOME_ModuleCatalog_AcomponentImpl::GetPathPrefix(const char* machinename) //---------------------------------------------------------------------- char* SALOME_ModuleCatalog_AcomponentImpl::constraint() { - return CORBA::string_dup(_constraint); + return CORBA::string_dup(_Component.constraint); } //---------------------------------------------------------------------- @@ -392,7 +380,7 @@ char* SALOME_ModuleCatalog_AcomponentImpl::constraint() //---------------------------------------------------------------------- char* SALOME_ModuleCatalog_AcomponentImpl::componentname() { - return CORBA::string_dup(_component_name); + return CORBA::string_dup(_Component.name); } //---------------------------------------------------------------------- @@ -401,7 +389,7 @@ char* SALOME_ModuleCatalog_AcomponentImpl::componentname() //---------------------------------------------------------------------- char* SALOME_ModuleCatalog_AcomponentImpl::componentusername() { - return CORBA::string_dup(_component_user_name); + return CORBA::string_dup(_Component.username); } //---------------------------------------------------------------------- @@ -410,7 +398,17 @@ char* SALOME_ModuleCatalog_AcomponentImpl::componentusername() //---------------------------------------------------------------------- CORBA::Boolean SALOME_ModuleCatalog_AcomponentImpl::multistudy() { - return _componentmultistudy ; + return _Component.multistudy ; +} + + +//---------------------------------------------------------------------- +// Function : implementation type +// Purpose : define if a component is implemented in C++ or Python +//---------------------------------------------------------------------- +CORBA::Boolean SALOME_ModuleCatalog_AcomponentImpl::implementation_type() +{ + return _Component.implementationType ; } //---------------------------------------------------------------------- @@ -420,7 +418,7 @@ CORBA::Boolean SALOME_ModuleCatalog_AcomponentImpl::multistudy() SALOME_ModuleCatalog::ComponentType SALOME_ModuleCatalog_AcomponentImpl::component_type() { - return _componenttype; + return _Component.type; } //---------------------------------------------------------------------- @@ -429,44 +427,102 @@ SALOME_ModuleCatalog_AcomponentImpl::component_type() //---------------------------------------------------------------------- char* SALOME_ModuleCatalog_AcomponentImpl::component_icone() { - return CORBA::string_dup(_icone); + return CORBA::string_dup(_Component.icon); } -//---------------------------------------------------------------------- -// Function : _duplicate_service -// Purpose : duplicate a service -//---------------------------------------------------------------------- -SALOME_ModuleCatalog::Service_var -SALOME_ModuleCatalog_AcomponentImpl::_duplicate_service(SALOME_ModuleCatalog::Service service) + +void SALOME_ModuleCatalog_AcomponentImpl::duplicate +(SALOME_ModuleCatalog::ServicesParameter & P_out, + const SALOME_ModuleCatalog::ServicesParameter &P_in) { - SALOME_ModuleCatalog::Service_var _service = new SALOME_ModuleCatalog::Service; + // duplicate parameter name + P_out.Parametername = CORBA::string_dup(P_in.Parametername); + + // duplicate parameter type + P_out.Parametertype = CORBA::string_dup(P_in.Parametertype); +} - // service name - _service->ServiceName = CORBA::string_dup(service.ServiceName); - // service by default - _service->Servicebydefault = service.Servicebydefault; - // in Parameters service - unsigned int _length_in_param = service.ServiceinParameter.length(); - for(unsigned int ind = 0; ind < _length_in_param; ind++) - { - _service->ServiceinParameter.length(_length_in_param); - // in Parameter type - _service->ServiceinParameter[ind].Parametertype = CORBA::string_dup(service.ServiceinParameter[ind].Parametertype); - // in Parameter name - _service->ServiceinParameter[ind].Parametername = CORBA::string_dup(service.ServiceinParameter[ind].Parametername); - } +void SALOME_ModuleCatalog_AcomponentImpl::duplicate +(SALOME_ModuleCatalog::ServicesDataStreamParameter & P_out, + const SALOME_ModuleCatalog::ServicesDataStreamParameter &P_in) +{ + // duplicate parameter name + P_out.Parametername = CORBA::string_dup(P_in.Parametername); + + // duplicate parameter type + P_out.Parametertype = P_in.Parametertype; - // out Parameters service - unsigned int _length_out_param = service.ServiceoutParameter.length(); - for(unsigned int ind = 0; ind < _length_out_param; ind++) - { - _service->ServiceoutParameter.length(_length_out_param); - // out Parameter type - _service->ServiceoutParameter[ind].Parametertype = CORBA::string_dup(service.ServiceoutParameter[ind].Parametertype); - // out Parameter name - _service->ServiceoutParameter[ind].Parametername = CORBA::string_dup(service.ServiceoutParameter[ind].Parametername); - } + // duplicate parameter dependency + P_out.Parameterdependency = P_in.Parameterdependency; - return _service; } + +void SALOME_ModuleCatalog_AcomponentImpl::duplicate +(SALOME_ModuleCatalog::Service & S_out, + const SALOME_ModuleCatalog::Service &S_in) +{ + // type of node + S_out.TypeOfNode = S_in.TypeOfNode; + + // duplicate service name + S_out.ServiceName = CORBA::string_dup(S_in.ServiceName); + + // duplicate service by default + S_out.Servicebydefault = S_in.Servicebydefault; + + unsigned int _length; + + // duplicate in Parameters + _length = S_in.ServiceinParameter.length(); + S_out.ServiceinParameter.length(_length); + + for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) + duplicate(S_out.ServiceinParameter[ind2], + S_in.ServiceinParameter[ind2]); + + // duplicate out Parameters + _length = S_in.ServiceoutParameter.length(); + S_out.ServiceoutParameter.length(_length); + + for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) + duplicate(S_out.ServiceoutParameter[ind2], + S_in.ServiceoutParameter[ind2]); + + // duplicate in DataStreamParameters + _length = S_in.ServiceinDataStreamParameter.length(); + S_out.ServiceinDataStreamParameter.length(_length); + + for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) + duplicate(S_out.ServiceinDataStreamParameter[ind2], + S_in.ServiceinDataStreamParameter[ind2]); + + // duplicate out DataStreamParameters + _length = S_in.ServiceoutDataStreamParameter.length(); + SCRUTE(_length); + S_out.ServiceoutDataStreamParameter.length(_length); + + for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) + duplicate(S_out.ServiceoutDataStreamParameter[ind2], + S_in.ServiceoutDataStreamParameter[ind2]); +} + + +void SALOME_ModuleCatalog_AcomponentImpl::duplicate +(SALOME_ModuleCatalog::DefinitionInterface & I_out, + const SALOME_ModuleCatalog::DefinitionInterface & I_in) +{ + //duplicate interface name + I_out.interfacename = CORBA::string_dup(I_in.interfacename); + + // duplicate service list + unsigned int _length = I_in.interfaceservicelist.length(); + SCRUTE(_length); + I_out.interfaceservicelist.length(_length); + + for (unsigned int ind1 = 0; ind1 < _length ; ind1 ++) + duplicate(I_out.interfaceservicelist[ind1], + I_in.interfaceservicelist[ind1]); +} + + diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx index 0a7c715d5..b7718b169 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx @@ -30,8 +30,9 @@ #define ACOMPONENT_IMPL_H #include "utilities.h" -#include "PathPrefix.hxx" +#include "SALOME_ModuleCatalog_Parser.hxx" #include + #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog) class SALOME_ModuleCatalog_AcomponentImpl: public POA_SALOME_ModuleCatalog::Acomponent, @@ -39,14 +40,7 @@ class SALOME_ModuleCatalog_AcomponentImpl: public POA_SALOME_ModuleCatalog::Acom { public: //! standard constructor - SALOME_ModuleCatalog_AcomponentImpl(const char* name, - const char* username, - const char* constraint, - SALOME_ModuleCatalog::ComponentType componenttype, - CORBA::Boolean componentmultistudy, - const char* icone, - SALOME_ModuleCatalog::ListOfDefInterface list_interfaces, - ListOfPathPrefix pathes); + SALOME_ModuleCatalog_AcomponentImpl(SALOME_ModuleCatalog::Component &C); //! standard destructor virtual ~SALOME_ModuleCatalog_AcomponentImpl(); @@ -137,27 +131,53 @@ public: //! method to obtain the component icone (for IAPP) /*! - \return the component icone + \return the component icon */ virtual char* component_icone(); + //! method to define if a component is implemented in C++ or Python + /*! + \return true if it's a C++ component + */ + virtual CORBA::Boolean implementation_type(); + private : - char* _component_name ; - char* _component_user_name ; - char* _constraint; - char* _icone; - SALOME_ModuleCatalog::ComponentType _componenttype; - CORBA::Boolean _componentmultistudy; - SALOME_ModuleCatalog::ListOfDefInterface _list_interfaces; - ListOfPathPrefix _pathes ; - + + SALOME_ModuleCatalog::Component _Component; + + //! method to duplicate an interface + /*! + \param service SALOME_ModuleCatalog::DefinitionInterface arguments + \return the interface + */ + void duplicate(SALOME_ModuleCatalog::DefinitionInterface &I_out, + const SALOME_ModuleCatalog::DefinitionInterface &I_in); //! method to duplicate a service /*! \param service SALOME_ModuleCatalog::Service arguments \return the service */ - virtual SALOME_ModuleCatalog::Service_var _duplicate_service(SALOME_ModuleCatalog::Service service); + void duplicate(SALOME_ModuleCatalog::Service & S_out, + const SALOME_ModuleCatalog::Service &S_in); + + //! method to duplicate a parameter + /*! + \param parameter SALOME_ModuleCatalog::ServicesParameter arguments + \return the parameter + */ + void duplicate(SALOME_ModuleCatalog::ServicesParameter & P_out, + const SALOME_ModuleCatalog::ServicesParameter & P_in); + + //! method to duplicate a parameter + /*! + \param parameter SALOME_ModuleCatalog::ServicesDataStreamParameter arguments + \return the parameter + */ + void duplicate(SALOME_ModuleCatalog::ServicesDataStreamParameter & P_out, + const SALOME_ModuleCatalog::ServicesDataStreamParameter &P_in); + }; + #endif // ACOMPONENT_IMPL_H diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Client.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Client.cxx index e930301d1..ee3da570e 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Client.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Client.cxx @@ -33,9 +33,17 @@ #include "utilities.h" using namespace std; +void PrintService(SALOME_ModuleCatalog::Acomponent_ptr C, + const string & InterfaceName, + const string & ServiceName); + +void PrintInterface(SALOME_ModuleCatalog::Acomponent_ptr C, + const string & InterfaceName); + +void PrintComponent(SALOME_ModuleCatalog::Acomponent_ptr C); + int main(int argc,char **argv) { - char* name_to_find = "Geometry"; CORBA::ORB_var orb; CosNaming::NamingContext_var _rootContext; @@ -51,26 +59,31 @@ int main(int argc,char **argv) SALOME_NamingService NS(orb); CORBA::Object_var objVarN = NS.Resolve("/Kernel/ModulCatalog"); - SALOME_ModuleCatalog::ModuleCatalog_var Catalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN); + SALOME_ModuleCatalog::ModuleCatalog_var Catalogue + = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN); MESSAGE("Distant catalog of component found") // Get component list - SALOME_ModuleCatalog::ListOfComponents_var list_composants = Catalogue->GetComponentList(); + SALOME_ModuleCatalog::ListOfComponents_var list_composants + = Catalogue->GetComponentList(); // Typed component list MESSAGE("Get Typed Component list (GEOM Type)"); - SALOME_ModuleCatalog::ListOfComponents_var list_typed_composants = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::GEOM); + SALOME_ModuleCatalog::ListOfComponents_var list_typed_composants + = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::GEOM); for (unsigned int ind = 0; ind < list_typed_composants->length();ind++) MESSAGE("Component GEOM list : " << list_typed_composants[ind]); MESSAGE("Get Typed Component list (SUPERV Type)"); - SALOME_ModuleCatalog::ListOfComponents_var list_styped_composants = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::SUPERV); - for (unsigned int ind = 0; ind < list_styped_composants->length();ind++) - MESSAGE("Component SUPERV list : " << list_styped_composants[ind]); + list_typed_composants + = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::SUPERV); + for (unsigned int ind = 0; ind < list_typed_composants->length();ind++) + MESSAGE("Component SUPERV list : " << list_typed_composants[ind]); // Get list of couple (component name, component icone) - SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants_icone = Catalogue->GetComponentIconeList(); + SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants_icone + = Catalogue->GetComponentIconeList(); for (unsigned int ind = 0; ind < list_composants_icone->length();ind++) { MESSAGE("Component name: " << list_composants_icone[ind].modulename); @@ -85,10 +98,7 @@ int main(int argc,char **argv) exit (-1); } - MESSAGE("Component of name : " << Geom->componentname() << " created "); - MESSAGE("Component type : " << Geom->component_type() << " multistudy : " <multistudy()); - MESSAGE("Component constraint : " << Geom->constraint()); - MESSAGE("Component icone : " << Geom->component_icone()); + PrintComponent(Geom); // Obtain another component SALOME_ModuleCatalog::Acomponent_ptr Superv = Catalogue->GetComponent("Supervision"); @@ -97,11 +107,7 @@ int main(int argc,char **argv) INFOS("Catalog Error : Component Supervision not found in the catalog") exit (-1); } - - MESSAGE("Component of name : " << Superv->componentname() << " created "); - MESSAGE("Component type : " << Superv->component_type() << " multistudy : " <multistudy()); - MESSAGE("Component constraint : " << Superv->constraint()); - MESSAGE("Component icone : " << Superv->component_icone()); + PrintComponent(Superv); // obtain prefix path for a computer char* path; @@ -112,93 +118,6 @@ int main(int argc,char **argv) path =Geom->GetPathPrefix("eri"); MESSAGE("Path prefix pour eri : " << path); - // obtain interfaces list of the component - SALOME_ModuleCatalog::ListOfInterfaces_var _list = new SALOME_ModuleCatalog::ListOfInterfaces; - _list = Geom->GetInterfaceList(); - for (unsigned int ind = 0; ind < _list->length();ind++) - MESSAGE("Interface name : " << _list[ind]); - - // obtain interfaces list of the component - SALOME_ModuleCatalog::ListOfInterfaces_var _list1 = new SALOME_ModuleCatalog::ListOfInterfaces; - _list1 = Superv->GetInterfaceList(); - for (unsigned int ind = 0; ind < _list1->length();ind++) - MESSAGE("Interface name : " << _list1[ind]) - - - // Obtain one interface of a component - SALOME_ModuleCatalog::DefinitionInterface_var _interf = new SALOME_ModuleCatalog::DefinitionInterface; - _interf = Geom->GetInterface("Geometry"); - MESSAGE ("Interface " << _interf->interfacename << " getted") - for (unsigned int ind = 0; ind < _interf->interfaceservicelist.length();ind++) - MESSAGE("Service name : " << _interf->interfaceservicelist[ind].ServiceName) - - - // obtain services list of the component - - SALOME_ModuleCatalog::ListOfServices_var list_services_component = new SALOME_ModuleCatalog::ListOfServices; - list_services_component = Geom->GetServiceList("Geometry"); - for (unsigned int ind = 0; ind < list_services_component->length();ind++) - MESSAGE("Service name : " << list_services_component[ind]) - - - // Get a service of the component - - SALOME_ModuleCatalog::Service_var second_service = new SALOME_ModuleCatalog::Service; - second_service = Geom->GetDefaultService("Geometry"); - - MESSAGE("Default Service name: " << second_service->ServiceName) - for (unsigned int ind1 = 0; ind1 ServiceinParameter.length();ind1++) - { - MESSAGE("Type of the in Parameter of this service : " << second_service->ServiceinParameter[ind1].Parametertype) - MESSAGE("Name of the in Parameter of this service : " << second_service->ServiceinParameter[ind1].Parametername) - } - for (unsigned int ind1 = 0; ind1 ServiceoutParameter.length();ind1++) - { - MESSAGE("Type of the out Parameter of this service : " << second_service->ServiceoutParameter[ind1].Parametertype) - MESSAGE("Name of the out Parameter of this service : " << second_service->ServiceoutParameter[ind1].Parametername) - } - - - - second_service = Geom->GetDefaultService("Geometry"); - - MESSAGE("Default Service name: " << second_service->ServiceName) - for (unsigned int ind1 = 0; ind1 ServiceinParameter.length();ind1++) - { - MESSAGE("Type of the in Parameter of this service : " << second_service->ServiceinParameter[ind1].Parametertype) - MESSAGE("Name of the in Parameter of this service : " << second_service->ServiceinParameter[ind1].Parametername) - } - for (unsigned int ind1 = 0; ind1 ServiceoutParameter.length();ind1++) - { - MESSAGE("Type of the out Parameter of this service : " << second_service->ServiceoutParameter[ind1].Parametertype) - MESSAGE("Name of the out Parameter of this service : " << second_service->ServiceoutParameter[ind1].Parametername) - } - - - - // Get service of the component - - SALOME_ModuleCatalog::Service_var service_1 = new SALOME_ModuleCatalog::Service; - - service_1 = Geom->GetService("Geometry","MakeSphere") ; - - MESSAGE("Service name: " << service_1->ServiceName) - for (unsigned int ind1 = 0; ind1 ServiceinParameter.length();ind1++) - { - MESSAGE("Type of the in Parameter of this service : " << service_1->ServiceinParameter[ind1].Parametertype) - MESSAGE("Name of the in Parameter of this service : " << service_1->ServiceinParameter[ind1].Parametername) - } - - for (unsigned int ind1 = 0; ind1 ServiceoutParameter.length();ind1++) - { - MESSAGE("Type of the out Parameter of this service : " << service_1->ServiceoutParameter[ind1].Parametertype) - MESSAGE("Name of the out Parameter of this service : " << service_1->ServiceoutParameter[ind1].Parametername) - } - - // Test levée exception - service_1 = Geom->GetService("BOX","makeBox") ; - - } catch(SALOME_ModuleCatalog::NotFound &ex){ INFOS("SALOME_ModuleCatalog::NotFound") @@ -231,16 +150,101 @@ int main(int argc,char **argv) return 0; } +void PrintComponent(SALOME_ModuleCatalog::Acomponent_ptr C) +{ + const char *_name = C->componentname(); + MESSAGE("Name : " << C->componentname()); + MESSAGE("Type : " << C->component_type() << " multistudy : " << C->multistudy()); + MESSAGE("Constraint : " << C->constraint()); + MESSAGE("Icon : " << C->component_icone()); + // obtain interfaces list of the component + SALOME_ModuleCatalog::ListOfInterfaces_var _list = C->GetInterfaceList(); + for (unsigned int i = 0; i < _list->length();i++) { + const char * s = _list[i]; + PrintInterface(C, s); + } +} +void PrintInterface(SALOME_ModuleCatalog::Acomponent_ptr C, + const string & InterfaceName) +{ + unsigned int i, n; + + SALOME_ModuleCatalog::DefinitionInterface_var _interf + = C->GetInterface(InterfaceName.c_str()); + MESSAGE ("Interface : " << _interf->interfacename); + + SALOME_ModuleCatalog::ListOfInterfaceService S = _interf->interfaceservicelist; + n = S.length(); + for (i = 0; i < n; i++) { + const char * _S = S[i].ServiceName; + PrintService(C, InterfaceName, _S); + } +} +void PrintService(SALOME_ModuleCatalog::Acomponent_ptr C, + const string & InterfaceName, + const string & ServiceName) +{ + int i, n; + + SALOME_ModuleCatalog::Service_var Service + = (ServiceName.compare("") == 0) + ? C->GetDefaultService(InterfaceName.c_str()) + : C->GetService(InterfaceName.c_str(), ServiceName.c_str()); + + MESSAGE("Service : " << Service->ServiceName); + + MESSAGE("In Parameter(s):"); + n = Service->ServiceinParameter.length(); + for (i = 0; iServiceinParameter[i].Parametername); + MESSAGE(" Type : " + << Service->ServiceinParameter[i].Parametertype); + } + + MESSAGE("Out Parameter(s):"); + n = Service->ServiceoutParameter.length(); + for (i = 0; iServiceoutParameter[i].Parametername); + MESSAGE(" Type : " + << Service->ServiceoutParameter[i].Parametertype); + } + + MESSAGE("In DataStreamParameter(s):"); + n = Service->ServiceinDataStreamParameter.length(); + for (i = 0; iServiceinDataStreamParameter[i].Parametername); + MESSAGE(" Type : " + << Service->ServiceinDataStreamParameter[i].Parametertype); + MESSAGE(" Dependency : " + << Service->ServiceinDataStreamParameter[i].Parametertype); + } + + MESSAGE("Out DataStreamParameter(s):"); + n = Service->ServiceoutDataStreamParameter.length(); + for (i = 0; iServiceoutDataStreamParameter[i].Parametername); + MESSAGE(" Type : " + << Service->ServiceoutDataStreamParameter[i].Parametertype); + MESSAGE(" Dependency : " + << Service->ServiceoutDataStreamParameter[i].Parametertype); + } + - - - +} diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx index 878828358..5af547b2e 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx @@ -24,11 +24,13 @@ // File : SALOME_ModuleCatalog_Handler.cxx // Author : Estelle Deville // Module : SALOME -// $Header$ +// $Header$ #define WRITE_CATA_COMPONENT #include "SALOME_ModuleCatalog_Handler.hxx" +#include "SALOME_ModuleCatalog_Parser_IO.hxx" using namespace std; +#include //---------------------------------------------------------------------- // Function : SALOME_ModuleCatalog_Handler @@ -36,41 +38,59 @@ using namespace std; //---------------------------------------------------------------------- SALOME_ModuleCatalog_Handler::SALOME_ModuleCatalog_Handler() { - MESSAGE("SALOME_ModuleCatalog_Handler creation") + BEGIN_OF("SALOME_ModuleCatalog_Handler"); + // XML Tags initialisation // Used in the function endElement - test_path_prefix_name = "path-prefix-name"; - test_computer_name = "computer-name" ; - test_path_prefix = "path-prefix" ; + test_path_prefix_name = "path-prefix-name"; + test_computer_name = "computer-name" ; + test_path_prefix = "path-prefix" ; + + test_component_name = "component-name"; + test_component_username = "component-username"; + test_component_type = "component-type" ; + test_component_multistudy = "component-multistudy"; + test_component_icon = "component-icone" ; + test_component_impltype = "component-impltype"; + + test_interface_name = "component-interface-name" ; + + test_service_name = "service-name"; + test_defaultservice = "service-by-default"; - test_component_name = "component-name"; - test_component_username = "component-username"; - test_component_type = "component-type" ; - test_component_multistudy="component-multistudy"; - test_component_icone="component-icone" ; + test_typeofnode = "type-of-node"; - test_interface_name = "component-interface-name" ; - - test_service_name = "service-name"; - test_defaultservice = "service-by-default"; + test_inParameter_type = "inParameter-type"; + test_inParameter_name = "inParameter-name"; + test_inParameter = "inParameter"; + test_inParameter_list = "inParameter-list"; + + test_outParameter_type = "outParameter-type"; + test_outParameter_name = "outParameter-name"; + test_outParameter = "outParameter"; + test_outParameter_list = "outParameter-list"; - test_inParameter_type="inParameter-type"; - test_inParameter_name="inParameter-name"; - test_inParameter="inParameter"; - test_inParameter_list="inParameter-list"; + test_inDataStreamParameter_type = "inParameter-type"; + test_inDataStreamParameter_name = "inParameter-name"; + test_inDataStreamParameter_dependency = "inParameter-dependency"; + test_inDataStreamParameter = "inParameter"; + test_inDataStreamParameter_list = "DataStream-list"; - test_outParameter_type="outParameter-type"; - test_outParameter_name="outParameter-name"; - test_outParameter="outParameter"; - test_outParameter_list="outParameter-list"; + test_outDataStreamParameter_type = "outParameter-type"; + test_outDataStreamParameter_name = "outParameter-name"; + test_outDataStreamParameter_dependency = "outParameter-dependency"; + test_outDataStreamParameter = "outParameter"; + test_outDataStreamParameter_list = "DataStream-list"; - test_service= "component-service"; - test_service_list="component-service-list"; - test_interface_list="component-interface-list"; + test_service = "component-service"; + test_service_list = "component-service-list"; + test_interface_list = "component-interface-list"; - test_constraint="constraint"; + test_constraint = "constraint"; test_component="component"; + + END_OF("SALOME_ModuleCatalog_Handler"); } //---------------------------------------------------------------------- @@ -79,7 +99,8 @@ SALOME_ModuleCatalog_Handler::SALOME_ModuleCatalog_Handler() //---------------------------------------------------------------------- SALOME_ModuleCatalog_Handler::~SALOME_ModuleCatalog_Handler() { - MESSAGE("SALOME_ModuleCatalog_Handler destruction") + BEGIN_OF("~SALOME_ModuleCatalog_Handler()") + END_OF("~SALOME_ModuleCatalog_Handler()") } //---------------------------------------------------------------------- @@ -90,13 +111,15 @@ bool SALOME_ModuleCatalog_Handler::startDocument() { MESSAGE("Begin parse document") // Empty the private elements - _pathlist.resize(0); - _path_prefix.ListOfComputer.resize(0); - _servicelist.resize(0); - _interfacelist.resize(0); - _modulelist.resize(0); - _inparamlist.resize(0); - _outparamlist.resize(0); + _pathList.resize(0); + _pathPrefix.listOfComputer.resize(0); + _serviceList.resize(0); + _interfaceList.resize(0); + _moduleList.resize(0); + _inDataStreamParamList.resize(0); + _outDataStreamParamList.resize(0); + _inParamList.resize(0); + _outParamList.resize(0); return true; } @@ -109,6 +132,8 @@ bool SALOME_ModuleCatalog_Handler::startElement(const QString&, const QString& qName, const QXmlAttributes& atts) { + _xml_pile.push(qName); + return true; } @@ -120,192 +145,360 @@ bool SALOME_ModuleCatalog_Handler::endElement(const QString&, const QString &, const QString& qName) { + QString parent, grandparent; + _xml_pile.pop(); + if (!_xml_pile.empty()) { + parent = _xml_pile.top(); + _xml_pile.pop(); + if (!_xml_pile.empty()) grandparent = _xml_pile.top(); + _xml_pile.push(parent); + } + // Path prefix // tag test_path_prefix_name - if((qName.compare(QString(test_path_prefix_name))==0)) - _path_prefix.path = content; + if((qName.compare(test_path_prefix_name)==0)) { + _pathPrefix.path = content; + return true; + } + // tag test_computer_name - if((qName.compare(QString(test_computer_name))==0)) - _path_prefix.ListOfComputer.push_back(content); + if((qName.compare(test_computer_name)==0)) { + _pathPrefix.listOfComputer.push_back(content); + return true; + } // tag test_path_prefix - if((qName.compare(QString(test_path_prefix))==0)) - { - _pathlist.push_back(_path_prefix); - _path_prefix.ListOfComputer.resize(0); - } + if((qName.compare(test_path_prefix)==0)) { + _pathList.push_back(_pathPrefix); + _pathPrefix.listOfComputer.resize(0); + return true; + } // Component identification // tag test_component_name - if((qName.compare(QString(test_component_name))==0)) - _amodule.Parsercomponentname = content ; + if((qName.compare(test_component_name)==0)) { + _aModule.name = content ; + return true; + } + // tag test_component_username - if((qName.compare(QString(test_component_username))==0)) - _amodule.Parsercomponentusername = content ; + if((qName.compare(test_component_username)==0)) { + _aModule.username = content ; + return true; + } + // tag test_component_type - if((qName.compare(QString(test_component_type))==0)) + if((qName.compare(test_component_type)==0)) { if ((content.compare("MESH") == 0) || (content.compare("Mesh") == 0) || (content.compare("mesh") == 0)) - _amodule.Parsercomponenttype = MESH ; + _aModule.type = MESH ; else if((content.compare("MED") == 0) || (content.compare("Med") == 0) || (content.compare("med") == 0)) - _amodule.Parsercomponenttype = Med ; + _aModule.type = Med ; else if((content.compare("GEOM") == 0) || (content.compare("Geom") == 0) || (content.compare("geom") == 0)) - _amodule.Parsercomponenttype = GEOM ; + _aModule.type = GEOM ; else if((content.compare("SOLVER") == 0) || (content.compare("Solver") == 0) || (content.compare("solver") == 0)) - _amodule.Parsercomponenttype = SOLVER ; + _aModule.type = SOLVER ; else if((content.compare("SUPERV") == 0) || (content.compare("Superv") == 0) || (content.compare("Supervision") == 0) || (content.compare("superv") == 0)) - _amodule.Parsercomponenttype = SUPERV ; + _aModule.type = SUPERV ; else if((content.compare("DATA") == 0) || (content.compare("Data") == 0) || (content.compare("data") == 0)) - _amodule.Parsercomponenttype = DATA ; + _aModule.type = DATA ; else if((content.compare("VISU") == 0) || (content.compare("Visu") == 0) || (content.compare("visu") == 0)) - _amodule.Parsercomponenttype = VISU ; + _aModule.type = VISU ; else if((content.compare("OTHER") == 0) || (content.compare("Other") == 0) || (content.compare("other") == 0)) - _amodule.Parsercomponenttype = OTHER ; + _aModule.type = OTHER ; else // If it'not in all theses cases, the type is affected to OTHER - _amodule.Parsercomponenttype = OTHER ; + _aModule.type = OTHER ; + return true; } // tag test_component_multistudy - if((qName.compare(QString(test_component_multistudy))==0)) - _amodule.Parsercomponentmultistudy = atoi(content.c_str()) ; + if((qName.compare(test_component_multistudy)==0)) { + _aModule.multistudy = atoi(content.c_str()) ; + return true; + } - // tag test_component_icone - if((qName.compare(QString(test_component_icone))==0)) - _amodule.Parsercomponenticone = content ; + // tag test_component_impltype + if((qName.compare(QString(test_component_impltype))==0)) + _aModule.implementationType = atoi(content.c_str()) ; + + // tag test_component_icon + if((qName.compare(test_component_icon)==0)) { + _aModule.icon = content ; + return true; + } // interface identification // tag test_interface_name - if((qName.compare(QString(test_interface_name))==0)) - _aInterface.Parserinterfacename = content ; + if ((qName.compare(test_interface_name)==0)) { + _aInterface.name = content ; + return true; + } // Service identification // tag test_service_name - if((qName.compare(QString(test_service_name))==0)) - _aService.ParserServiceName = content ; - + if ((qName.compare(test_service_name)==0)) { + _aService.name = content ; + return true; + } + //tag test_defaultservice - if((qName.compare(QString(test_defaultservice))==0)) - _aService.ParserServicebydefault = atoi(content.c_str()) ; + if ((qName.compare(test_defaultservice)==0)) { + _aService.byDefault = atoi(content.c_str()) ; + return true; + } + + //tag test_typeofnode + if((qName.compare(QString(test_typeofnode))==0)) + _aService.typeOfNode = atoi(content.c_str()) ; // Parameter in + // tag test_inDataStreamParameter_type + if ((qName.compare(test_inDataStreamParameter_type)==0)) { + if (grandparent.compare(test_inDataStreamParameter_list) == 0) + _inDataStreamParam.type = content ; + else + _inParam.type = content ; + return true; + } + // tag test_inParameter_type - if((qName.compare(QString(test_inParameter_type))==0)) - _inparam.ParserParamtype = content ; + if ((qName.compare(test_inParameter_type)==0)) { + if (grandparent.compare(test_inDataStreamParameter_list) == 0) + _inDataStreamParam.type = content ; + else + _inParam.type = content ; + return true; + } + + //tag test_inDataStreamParameter_name + if ((qName.compare(test_inDataStreamParameter_name)==0)) { + if (grandparent.compare(test_inDataStreamParameter_list) == 0) + _inDataStreamParam.name = content ; + else + _inParam.name = content ; + return true; + } + //tag test_inParameter_name - if((qName.compare(QString(test_inParameter_name))==0)) - _inparam.ParserParamname = content ; + if ((qName.compare(test_inParameter_name)==0)) { + SCRUTE(parent); + SCRUTE(grandparent); + if (grandparent.compare(test_inDataStreamParameter_list) == 0) + _inDataStreamParam.name = content ; + else + _inParam.name = content ; + return true; + } + + //tag test_inDataStreamParameter_dependency + if ((qName.compare(test_inDataStreamParameter_dependency)==0)) { + _inDataStreamParam.dependency = content ; + return true; + } //tag test_inParameter - if((qName.compare(QString(test_inParameter))==0)) + if ((qName.compare(test_inParameter)==0)) { - _inparamlist.push_back(_inparam) ; - - // Empty temporary structures - _inparam.ParserParamtype = ""; - _inparam.ParserParamname = ""; + if (parent.compare(test_inParameter_list)==0) { + + MESSAGE("add inParameter : " << _inParam.name); + _inParamList.push_back(_inParam) ; + + // Empty temporary structures + _inParam.type = ""; + _inParam.name = ""; + } + else if ((qName.compare(test_inDataStreamParameter)==0)) { + + MESSAGE("add inDataStreamParameter : " << _inDataStreamParam.name); + _inDataStreamParamList.push_back(_inDataStreamParam) ; + + // Empty temporary structures + _inDataStreamParam.type = ""; + _inDataStreamParam.name = ""; + _inDataStreamParam.dependency = ""; + } + return true; } //tag test_inParameter_list - if((qName.compare(QString(test_inParameter_list))==0)) + if((qName.compare(test_inParameter_list)==0)) + { + SCRUTE(_inParamList.size()); + _aService.inParameters = _inParamList; + _inParamList.resize(0); + return true; + } + + //tag test_inDataStreamParameter_list + if((qName.compare(test_inDataStreamParameter_list)==0)) + { + SCRUTE(_inDataStreamParamList.size()); + _aService.inDataStreamParameters = _inDataStreamParamList; + _inDataStreamParamList.resize(0); + } + //tag test_outDataStreamParameter_list + if((qName.compare(test_outDataStreamParameter_list)==0)) { - _aService.ParserServiceinParameter = _inparamlist; - _inparamlist.resize(0); + SCRUTE(_outDataStreamParamList.size()); + _aService.outDataStreamParameters = _outDataStreamParamList; + _outDataStreamParamList.resize(0); + return true; } + // Parameter out + SCRUTE(qName); // tag test_outParameter_type - if((qName.compare(QString(test_outParameter_type))==0)) - _outparam.ParserParamtype = content ; + if ((qName.compare(test_outParameter_type)==0)) { + if (grandparent.compare(test_outDataStreamParameter_list) == 0) + _outDataStreamParam.type = content ; + else + _outParam.type = content ; + return true; + } + + // tag test_outDataStreamParameter_type + if ((qName.compare(test_outDataStreamParameter_type)==0)) { + if (grandparent.compare(test_outDataStreamParameter_list) == 0) + _outDataStreamParam.type = content ; + else + _outParam.type = content ; + return true; + } + //tag test_outParameter_name - if((qName.compare(QString(test_outParameter_name))==0)) - _outparam.ParserParamname = content ; - + if ((qName.compare(test_outParameter_name)==0)) { + if (grandparent.compare(test_outDataStreamParameter_list) == 0) + _outDataStreamParam.name = content ; + else + _outParam.name = content ; + return true; + } + + //tag test_outDataStreamParameter_name + if ((qName.compare(test_outDataStreamParameter_name)==0)) { + SCRUTE(grandparent); + SCRUTE(test_outDataStreamParameter_list); + if (grandparent.compare(test_outDataStreamParameter_list) == 0) + _outDataStreamParam.name = content ; + else + _outParam.name = content ; + return true; + } + + //tag test_outParameter_dependency + if ((qName.compare(test_outDataStreamParameter_dependency)==0)) { + _outDataStreamParam.dependency = content ; + return true; + } + //tag test_outParameter - if((qName.compare(QString(test_outParameter))==0)) + if ((qName.compare(test_outParameter)==0)) { - _outparamlist.push_back(_outparam) ; - - // Empty temporary structures - _outparam.ParserParamtype = ""; - _outparam.ParserParamname = ""; + if (parent.compare(test_outParameter_list)==0) { + + MESSAGE("add outParameter : " << _outParam.name); + _outParamList.push_back(_outParam) ; + + // Empty temporary structures + _outParam.type = ""; + _outParam.name = ""; + } + else if ((qName.compare(test_outDataStreamParameter)==0)) { + + MESSAGE("add outDataStreamParameter : " << _outDataStreamParam.name); + _outDataStreamParamList.push_back(_outDataStreamParam) ; + + // Empty temporary structures + _outDataStreamParam.type = ""; + _outDataStreamParam.name = ""; + _outDataStreamParam.dependency = ""; + } + return true; } + //tag test_outParameter_list - if((qName.compare(QString(test_outParameter_list))==0)) + if((qName.compare(test_outParameter_list)==0)) { - _aService.ParserServiceoutParameter=_outparamlist; - _outparamlist.resize(0); + SCRUTE(_outParamList.size()); + _aService.outParameters = _outParamList; + _outParamList.resize(0); + return true; } - - + // tag test_service - if((qName.compare(QString(test_service))==0)) + if((qName.compare(test_service)==0)) { - _servicelist.push_back(_aService); + _serviceList.push_back(_aService); // Empty temporary structures - _aService.ParserServiceName = ""; - _aService.ParserServiceinParameter.resize(0); - _aService.ParserServiceoutParameter.resize(0); + _aService.name = ""; + _aService.typeOfNode = 1; + _aService.inParameters.resize(0); + _aService.outParameters.resize(0); + _aService.inDataStreamParameters.resize(0); + _aService.outDataStreamParameters.resize(0); } // tag test_service_list - if((qName.compare(QString(test_service_list))==0)) + if((qName.compare(test_service_list)==0)) { - _aInterface.Parserinterfaceservicelist = _servicelist ; + _aInterface.services = _serviceList ; // Empty temporary structures - _servicelist.resize(0); - _interfacelist.push_back(_aInterface); - _aInterface.Parserinterfacename =""; - _aInterface.Parserinterfaceservicelist.resize(0); + _serviceList.resize(0); + _interfaceList.push_back(_aInterface); + _aInterface.name =""; + _aInterface.services.resize(0); } //tag test_interface_list - if((qName.compare(QString(test_interface_list))==0)) + if((qName.compare(test_interface_list)==0)) { - _amodule.ParserListInterface = _interfacelist ; - _interfacelist.resize(0); + _aModule.interfaces = _interfaceList ; + _interfaceList.resize(0); } //tag test_constraint - if((qName.compare(QString(test_constraint))==0)) - _amodule.Parserconstraint = content ; + if((qName.compare(test_constraint)==0)) + _aModule.constraint = content ; // tag test_component - if((qName.compare(QString(test_component))==0)) + if((qName.compare(test_component)==0)) { - _modulelist.push_back(_amodule) ; + _moduleList.push_back(_aModule) ; // Empty temporary structures - _amodule.Parsercomponentname = ""; - _amodule.Parserconstraint = ""; - _amodule.Parsercomponenticone=""; - _amodule.ParserListInterface.resize(0); + _aModule.name = ""; + _aModule.constraint = ""; + _aModule.icon=""; + _aModule.interfaces.resize(0); } return true; @@ -327,44 +520,29 @@ bool SALOME_ModuleCatalog_Handler::characters(const QString& chars) // Print all informations find in the catalog // (only in DEBUG mode!!) //---------------------------------------------------------------------- +#include bool SALOME_ModuleCatalog_Handler::endDocument() { + ofstream f("/tmp/logs/xxx.log", std::ofstream::app); + f << "---------------------------------------------------------" << std::endl; + BEGIN_OF("endDocument"); //_pathlist - for (unsigned int ind = 0; ind < _pathlist.size(); ind++) + for (unsigned int ind = 0; ind < _pathList.size(); ind++) { - MESSAGE("Path :"<<_pathlist[ind].path) - for (unsigned int i = 0; i < _pathlist[ind].ListOfComputer.size(); i++) - MESSAGE("Computer name :" << _pathlist[ind].ListOfComputer[i]) + MESSAGE("Path :"<<_pathList[ind].path) + for (unsigned int i = 0; i < _pathList[ind].listOfComputer.size(); i++) + MESSAGE("Computer name :" << _pathList[ind].listOfComputer[i]) } - // _modulelist - for (unsigned int ind = 0; ind < _modulelist.size(); ind++) + // _moduleList +// SCRUTE(_moduleList.size()); + for (unsigned int ind = 0; ind < _moduleList.size(); ind++) { - MESSAGE("Component name : " << _modulelist[ind].Parsercomponentname); - // MESSAGE("Component type : " <<_modulelist[ind].Parsercomponenttype); -// MESSAGE("Component constraint : " << _modulelist[ind].Parserconstraint); -// MESSAGE("Component icone : " << _modulelist[ind].Parsercomponenticone); -// for (unsigned int i = 0; i < _modulelist[ind].ParserListInterface.size(); i++) -// { -// MESSAGE("Component interface name : " << _modulelist[ind].ParserListInterface[i].Parserinterfacename); -// for (unsigned int j=0; j< _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist.size(); j++) -// { -// MESSAGE("Service name : " << _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceName); -// MESSAGE("Service default : " << _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServicebydefault); -// for (unsigned int k=0; k< _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceinParameter.size() ; k++) -// { -// MESSAGE("Service Parameter in name : " <<_modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceinParameter[k].ParserParamname); -// MESSAGE("Service Parameter in type : " << _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceinParameter[k].ParserParamtype); -// } -// for (unsigned int k=0; k< _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceoutParameter.size() ; k++) -// { -// MESSAGE("Service Parameter out name : " << _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceoutParameter[k].ParserParamname); -// MESSAGE("Service Parameter out type : " << _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceoutParameter[k].ParserParamtype); -// } -// } - } -// } - //MESSAGE("Document parsed"); + f << _moduleList[ind] << std::endl; + } + + MESSAGE("Document parsed"); + END_OF("endDocument"); return true; } diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx index c12c49cef..3509d1423 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx @@ -33,7 +33,8 @@ #include "SALOME_ModuleCatalog_Parser.hxx" #include #include -#include +#include +#include class SALOME_ModuleCatalog_Handler : public QXmlDefaultHandler { @@ -54,9 +55,9 @@ public: //! method to overload handler function startElement /*! - \param Qstring argument by value - \param Qstring argument by value - \param Qstring argument by value + \param QString argument by value + \param QString argument by value + \param QString argument by value \param QXmlAttributes argument by value \return true if no error was detected */ @@ -65,9 +66,9 @@ public: //! method to overload handler function endElement /*! - \param Qstring argument by value - \param Qstring argument by value - \param Qstring argument by value + \param QString argument by value + \param QString argument by value + \param QString argument by value \return true if no error was detected \sa _Find */ @@ -77,7 +78,7 @@ public: //! method to overload handler function characters /*! - \param Qstring argument by value + \param QString argument by value \return true if no error was detected */ virtual bool characters(const QString& chars); @@ -106,50 +107,76 @@ private: string content; - const char* test_path_prefix_name ; - const char* test_computer_name ; - const char* test_path_prefix ; - - const char* test_component_name; - const char* test_component_username; - const char* test_component_type ; - const char* test_component_multistudy ; - const char* test_component_icone ; - - const char* test_interface_name; - - const char* test_service_name; - const char* test_defaultservice; - - const char* test_inParameter_type; - const char* test_inParameter_name; - const char* test_inParameter; - const char* test_inParameter_list; - const char* test_outParameter_type; - const char* test_outParameter_name; - const char* test_outParameter; - const char* test_outParameter_list; - - const char* test_service; - const char* test_service_list; - const char* test_interface_list; - const char* test_constraint; + QString test_path_prefix_name ; + QString test_computer_name ; + QString test_path_prefix ; + + QString test_component_name; + QString test_component_username; + QString test_component_type ; + QString test_component_multistudy ; + QString test_component_icon ; + QString test_component_impltype; + + QString test_interface_name; + + QString test_service_name; + QString test_defaultservice; + QString test_typeofnode; + + QString test_inParameter_type; + QString test_inParameter_name; + QString test_inParameter; + QString test_inParameter_list; + + QString test_outParameter_type; + QString test_outParameter_name; + QString test_outParameter; + QString test_outParameter_list; + + QString test_inDataStreamParameter_type; + QString test_inDataStreamParameter_name; + QString test_inDataStreamParameter_dependency; + QString test_inDataStreamParameter; + QString test_inDataStreamParameter_list; + + QString test_outDataStreamParameter_type; + QString test_outDataStreamParameter_name; + QString test_outDataStreamParameter_dependency; + QString test_outDataStreamParameter; + QString test_outDataStreamParameter_list; + + QString test_service; + QString test_service_list; + QString test_interface_list; + QString test_constraint; - const char* test_component; + QString test_component; - ParserPathPrefix _path_prefix; + ParserPathPrefix _pathPrefix; - ParserComponent _amodule; + ParserComponent _aModule; - ListOfDefinitionInterface _interfacelist; - ParserDefInterface _aInterface; - ListOfParserServices _servicelist; - ParserService _aService; - ParserServParam _inparam; - ParserServParam _outparam; - ListOfParserServicesParameter _inparamlist; - ListOfParserServicesParameter _outparamlist; + ParserInterfaces _interfaceList; + ParserInterface _aInterface; + + ParserServices _serviceList; + ParserService _aService; + + ParserParameters _inParamList; + ParserParameter _inParam; + + ParserParameters _outParamList; + ParserParameter _outParam; + + ParserDataStreamParameters _inDataStreamParamList; + ParserDataStreamParameter _inDataStreamParam; + + ParserDataStreamParameters _outDataStreamParamList; + ParserDataStreamParameter _outDataStreamParam; + + std::stack _xml_pile; }; #endif // SALOME_CATALOG_HANDLER_H diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx index 236763abb..2fac49367 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx @@ -25,7 +25,7 @@ // Author : Estelle Deville // Module : SALOME // $Header$ - +// #ifndef SALOME_CATALOG_PARSER_H #define SALOME_CATALOG_PARSER_H @@ -35,64 +35,81 @@ // Type Definitions struct ParserPathPrefix { - string path; - vector ListOfComputer ; + std::string path; + std::vector listOfComputer ; }; -typedef vector ListOfParserPathPrefix ; +typedef std::vector ParserPathPrefixes ; enum ParserComponentType {GEOM, MESH, Med, SOLVER, DATA, VISU, SUPERV, OTHER} ; -struct ParserServParam +struct ParserParameter { - string ParserParamtype; - string ParserParamname; + std::string type; + std::string name; } ; -typedef vector ListOfParserServicesParameter; + +struct ParserDataStreamParameter +{ + std::string type; + std::string name; + std::string dependency; +} ; + +typedef std::vector ParserParameters; +typedef std::vector ParserDataStreamParameters; struct ParserService { - string ParserServiceName; - ListOfParserServicesParameter ParserServiceinParameter; - ListOfParserServicesParameter ParserServiceoutParameter; - bool ParserServicebydefault; + ParserService() { + typeOfNode = 1; + byDefault = 1; + } + std::string name; + ParserParameters inParameters; + ParserParameters outParameters; + ParserDataStreamParameters inDataStreamParameters; + ParserDataStreamParameters outDataStreamParameters; + bool byDefault; + bool typeOfNode; } ; -typedef vector ListOfParserServices ; +typedef std::vector ParserServices ; -struct ParserDefInterface +struct ParserInterface { - string Parserinterfacename ; - ListOfParserServices Parserinterfaceservicelist ; + std::string name ; + ParserServices services ; } ; -typedef vector ListOfDefinitionInterface; +typedef std::vector ParserInterfaces; struct ParserComponent { - string Parsercomponentname; - string Parsercomponentusername; - ParserComponentType Parsercomponenttype; - bool Parsercomponentmultistudy ; - string Parsercomponenticone; - ListOfDefinitionInterface ParserListInterface; - string Parserconstraint ; + std::string name; + std::string username; + ParserComponentType type; + bool multistudy; + std::string icon; + std::string constraint; + ParserInterfaces interfaces; + ParserPathPrefixes prefixes; + bool implementationType; }; -typedef vector ListOfParserComponent ; +typedef std::vector ParserComponents ; #ifdef WRITE_CATA_COMPONENT -// contains all the paths and the computers defined in the catalog -ListOfParserPathPrefix _pathlist; +// contains all the paths and the computers defined in the catalog + ParserPathPrefixes _pathList; // contains all the modules defined in the catalog -ListOfParserComponent _modulelist; + ParserComponents _moduleList; #else -extern ListOfParserPathPrefix _pathlist; -extern ListOfParserComponent _modulelist; +extern ParserPathPrefixes _pathList; +extern ParserComponents _moduleList; #endif - #endif // SALOME_CATALOG_PARSER_H diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Parser_IO.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Parser_IO.cxx new file mode 100644 index 000000000..4864f32a4 --- /dev/null +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Parser_IO.cxx @@ -0,0 +1,141 @@ + +// SALOME ModuleCatalog : implementation of ModuleCatalog server which parsers xml description of modules +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// 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 +// 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 +// +// +// +// File : SALOME_ModuleCatalog_Parser_IO.cxx +// Author : Estelle Deville +// Module : SALOME +// $Header$ + +#include "SALOME_ModuleCatalog_Parser_IO.hxx" +#include +#include "utilities.h" + +std::ostream & operator<< (std::ostream & f, const ParserParameter & P) +{ + f << " name : " << P.name << std::endl; + f << " type : " << P.type << std::endl; + return f; +} + +std::ostream & operator<< (std::ostream & f, + const ParserDataStreamParameter & P) +{ + f << " name : " << P.name << std::endl; + f << " type : " << P.type << std::endl; + f << " dependency : " << P.dependency << std::endl; + return f; +} + +std::ostream & operator<< (std::ostream & f, + const ParserService & S) +{ + int i, n; + f << " name : " << S.name << std::endl; + f << " default : " << (S.byDefault ? "yes" : "no") + << std::endl; + + n = S.inParameters.size(); + f << " in parameters : " << n << std::endl; + for (i=0; i + +std::ostream & operator<< (std::ostream & f, + const ParserParameter & P); +std::ostream & operator<< (std::ostream & f, + const ParserDataStreamParameter & P); + +std::ostream & operator<< (std::ostream & f, + const ParserService & S); + +std::ostream & operator<< (std::ostream & f, + const ParserInterface & I); + +std::ostream & operator<< (std::ostream & f, + const ParserComponent & C); + +std::ostream & operator<< (std::ostream & f, + const ParserComponentType & T); + +#endif + diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx index d777b1128..a15d54759 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx @@ -23,8 +23,8 @@ // // File : SALOME_ModuleCatalog_Server.cxx // Module : SALOME - /* $Header$ */ + #include #include "SALOME_NamingService.hxx" #include "SALOME_ModuleCatalog_impl.hxx" @@ -87,14 +87,14 @@ int main(int argc,char **argv) } catch( CORBA::COMM_FAILURE& ) { - MESSAGE( "Module Catalog Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); + INFOS( "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" ); + INFOS( "Module Catalog Server: Naming Service was found" ); if(EnvL==1) { CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ; @@ -108,15 +108,15 @@ int main(int argc,char **argv) object = inc->resolve(name);} catch(CosNaming::NamingContext::NotFound) { - MESSAGE( "Logger Server wasn't found" ); + INFOS( "Logger Server wasn't found" ); } catch(...) { - MESSAGE( "Module Catalog Server: Unknown exception" ) ; + INFOS( "Module Catalog Server: Unknown exception" ) ; } if (!CORBA::is_nil(object)) { - MESSAGE( "Module Catalog Server: Logger Server was found" ); + INFOS( "Module Catalog Server: Logger Server was found" ); MODULE_CATALOG=1; break; } @@ -130,13 +130,13 @@ int main(int argc,char **argv) // Active catalog - SALOME_ModuleCatalogImpl* Catalogue_i = new SALOME_ModuleCatalogImpl(argc, argv); - poa->activate_object (Catalogue_i); + SALOME_ModuleCatalogImpl Catalogue_i(argc, argv, orb); + poa->activate_object (&Catalogue_i); mgr->activate(); - CORBA::Object_ptr myCata = Catalogue_i->_this(); + CORBA::Object_ptr myCata = Catalogue_i._this(); // initialise Naming Service SALOME_NamingService *_NS; @@ -155,8 +155,9 @@ int main(int argc,char **argv) #endif orb->run(); + mgr->deactivate(true,true); poa->destroy(1,1); - + } catch(CORBA::SystemException&) { INFOS("Caught CORBA::SystemException.") diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx index 8598599ed..7ba1b29f9 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx @@ -25,10 +25,11 @@ // Author : Estelle Deville // Module : SALOME // $Header$ - +// #include "SALOME_ModuleCatalog_impl.hxx" #include "SALOME_ModuleCatalog_Acomponent_impl.hxx" #include +#include #include #include @@ -40,10 +41,49 @@ static const char* SEPARATOR = ":"; // Function : SALOME_ModuleCatalogImpl // Purpose : Constructor //---------------------------------------------------------------------- -SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv) +SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA::ORB_ptr orb) : _orb(orb) { MESSAGE("Catalog creation"); + // Conversion rules for component types + ComponentTypeConvert[GEOM] + = SALOME_ModuleCatalog::GEOM; + ComponentTypeConvert[MESH] + = SALOME_ModuleCatalog::MESH; + ComponentTypeConvert[Med] + = SALOME_ModuleCatalog::Med; + ComponentTypeConvert[SOLVER] + = SALOME_ModuleCatalog::SOLVER; + ComponentTypeConvert[DATA] + = SALOME_ModuleCatalog::DATA; + ComponentTypeConvert[VISU] + = SALOME_ModuleCatalog::VISU; + ComponentTypeConvert[SUPERV] + = SALOME_ModuleCatalog::SUPERV; + ComponentTypeConvert[OTHER] + = SALOME_ModuleCatalog::OTHER; + + // Conversion rules for datastream parameters type and dependency + DataStreamTypeConvert["UNKNOWN"] + = SALOME_ModuleCatalog::DATASTREAM_UNKNOWN; + DataStreamTypeConvert["INTEGER"] + = SALOME_ModuleCatalog::DATASTREAM_INTEGER; + DataStreamTypeConvert["FLOAT"] + = SALOME_ModuleCatalog::DATASTREAM_FLOAT; + DataStreamTypeConvert["DOUBLE"] + = SALOME_ModuleCatalog::DATASTREAM_DOUBLE; + DataStreamTypeConvert["STRING"] + = SALOME_ModuleCatalog::DATASTREAM_STRING; + DataStreamTypeConvert["BOOLEAN"] + = SALOME_ModuleCatalog::DATASTREAM_BOOLEAN; + + DataStreamDepConvert["UNDEFINED"] + = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED; + DataStreamDepConvert["T"] + = SALOME_ModuleCatalog::DATASTREAM_TEMPORAL; + DataStreamDepConvert["I"] + = SALOME_ModuleCatalog::DATASTREAM_ITERATIVE; + // Empty used variables _general_module_list.resize(0); _general_path_list.resize(0); @@ -53,43 +93,56 @@ SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv) // Parse the arguments given at server run if (!_parseArguments(argc, argv,&_general_path,&_personal_path)) - MESSAGE( "Error while argument parsing" ) + MESSAGE( "Error while argument parsing" ); // Test existency of files if (_general_path == NULL) MESSAGE( "Error the general catalog should be indicated" ) else { - //MESSAGE("Parse general catalog"); - // Affect the variables _general_module_list and _general_path_list + // Affect the _general_module_list and _general_path_list members // with the common catalog - QStringList dirList = QStringList::split( SEPARATOR, _general_path, false ); // skip empty entries + QStringList dirList + = QStringList::split( SEPARATOR, _general_path, + false ); // skip empty entries + for ( int i = 0; i < dirList.count(); i++ ) { QFileInfo fileInfo( dirList[ i ] ); if ( fileInfo.isFile() && fileInfo.exists() ) { - _parse_xml_file(fileInfo.filePath(),_general_module_list, _general_path_list); + _parse_xml_file(fileInfo.filePath(), + _general_module_list, + _general_path_list); } } // Verification of _general_path_list content if(!_verify_path_prefix(_general_path_list)) - MESSAGE( "Error while parsing the general path list, differents pathes are associated to one computer, the first will be choosen" ) - else MESSAGE("General path list OK"); + MESSAGE( "Error while parsing the general path list, " + "differents paths are associated to the same computer," + "the first one will be choosen") + else + MESSAGE("General path list OK"); if(_personal_path != NULL) { - //MESSAGE("Parse personal catalog"); - // Affect the variables _personal_module_list and _personal_path_list - // with the personal catalog - _parse_xml_file(_personal_path,_personal_module_list, _personal_path_list); + // Initialize the _personal_module_list and + // _personal_path_list members with the personal catalog files + _parse_xml_file(_personal_path, + _personal_module_list, + _personal_path_list); // Verification of _general_path_list content if(!_verify_path_prefix(_personal_path_list)) - MESSAGE("Error while parsing the personal path list, differents pathes are associated to one computer, the first will be choosen" ) - else MESSAGE("Personal path list OK"); + MESSAGE("Error while parsing the personal path list, " + "differents paths are associated to the same computer, " + "the first one will be choosen" ) + else + MESSAGE("Personal path list OK"); } - else MESSAGE("No personal catalog indicated or error while opening the personal catalog"); + else + MESSAGE("No personal catalog indicated or error while " + "opening the personal catalog"); } } @@ -119,7 +172,7 @@ SALOME_ModuleCatalogImpl::GetComputerList() // Function : GetPathPrefix // Purpose : get the PathPrefix of a computer //---------------------------------------------------------------------- -char* +char * SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) { MESSAGE("Begin of GetPathPrefix") // Variables initialisation @@ -130,9 +183,9 @@ SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) { // looking for the wanted computer for (unsigned int ind = 0 ; ind < _personal_path_list.size() ; ind++) { - for (unsigned int ind1 = 0 ; ind1 < _personal_path_list[ind].ListOfComputer.size() ; ind1++) + for (unsigned int ind1 = 0 ; ind1 < _personal_path_list[ind].listOfComputer.size() ; ind1++) { - if (strcmp(machinename, _personal_path_list[ind].ListOfComputer[ind1].c_str()) == 0) + if (strcmp(machinename, _personal_path_list[ind].listOfComputer[ind1].c_str()) == 0) { _find = true ; // Wanted computer @@ -148,9 +201,9 @@ SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) { { for (unsigned int ind = 0 ; ind < _general_path_list.size() ; ind++) { - for (unsigned int ind1 = 0 ; ind1 < _general_path_list[ind].ListOfComputer.size() ; ind1++) + for (unsigned int ind1 = 0 ; ind1 < _general_path_list[ind].listOfComputer.size() ; ind1++) { - if (strcmp(machinename, _general_path_list[ind].ListOfComputer[ind1].c_str()) == 0) + if (strcmp(machinename, _general_path_list[ind].listOfComputer[ind1].c_str()) == 0) { _find = true ; // Wanted computer @@ -185,7 +238,7 @@ SALOME_ModuleCatalogImpl::GetComponentList() // All the components defined in the personal catalog are taken for (unsigned int ind=0; ind < _personal_module_list.size();ind++) { - _list_components[ind]=(_personal_module_list[ind].Parsercomponentname).c_str(); + _list_components[ind]=(_personal_module_list[ind].name).c_str(); SCRUTE(_list_components[ind]) ; } @@ -201,21 +254,23 @@ SALOME_ModuleCatalogImpl::GetComponentList() { // searching if the component is already defined in // the personal catalog - if ((_general_module_list[ind].Parsercomponentname.compare(_personal_module_list[ind1].Parsercomponentname)) == 0) + if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0) _find = true; } if (!_find) { - MESSAGE("A new component " << _general_module_list[ind].Parsercomponentname << " has to be to added in the list"); + MESSAGE("A new component " << _general_module_list[ind].name + << " has to be to added in the list"); _list_components->length(indice+1); // The component is not already defined => has to be taken - _list_components[indice]=(_general_module_list[ind].Parsercomponentname).c_str(); + _list_components[indice]=(_general_module_list[ind].name).c_str(); SCRUTE(_list_components[indice]) ; indice++; } else - MESSAGE("The component " <<_general_module_list[ind].Parsercomponentname << " was already defined in the personal catalog") ; + MESSAGE("The component " <<_general_module_list[ind].name + << " was already defined in the personal catalog") ; } MESSAGE ( "End of GetComponentList" ) @@ -243,9 +298,9 @@ SALOME_ModuleCatalogImpl::GetComponentIconeList() // All the components defined in the personal catalog are taken for (unsigned int ind=0; ind < _personal_module_list.size();ind++) { - _list_components_icone[ind].modulename=(_personal_module_list[ind].Parsercomponentname).c_str(); - _list_components_icone[ind].moduleusername=(_personal_module_list[ind].Parsercomponentusername).c_str(); - _list_components_icone[ind].moduleicone=(_personal_module_list[ind].Parsercomponenticone).c_str(); + _list_components_icone[ind].modulename=(_personal_module_list[ind].name).c_str(); + _list_components_icone[ind].moduleusername=(_personal_module_list[ind].username).c_str(); + _list_components_icone[ind].moduleicone=(_personal_module_list[ind].icon).c_str(); //SCRUTE(_list_components_icone[ind].modulename); //SCRUTE(_list_components_icone[ind].moduleicone); } @@ -262,24 +317,24 @@ SALOME_ModuleCatalogImpl::GetComponentIconeList() { // searching if the component is aleready defined in // the personal catalog - if ((_general_module_list[ind].Parsercomponentname.compare(_personal_module_list[ind1].Parsercomponentname)) == 0) + if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0) _find = true; } if (!_find) { - // MESSAGE("A new component " << _general_module_list[ind].Parsercomponentname << " has to be to added in the list"); + // MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list"); _list_components_icone->length(indice+1); // The component is not already defined => has to be taken - _list_components_icone[indice].modulename=(_general_module_list[ind].Parsercomponentname).c_str(); - _list_components_icone[indice].moduleusername=(_general_module_list[ind].Parsercomponentusername).c_str(); - _list_components_icone[indice].moduleicone=(_general_module_list[ind].Parsercomponenticone).c_str(); + _list_components_icone[indice].modulename=_general_module_list[ind].name.c_str(); + _list_components_icone[indice].moduleusername=_general_module_list[ind].username.c_str(); + _list_components_icone[indice].moduleicone=_general_module_list[ind].icon.c_str(); //SCRUTE(_list_components_icone[indice].modulename) ; //SCRUTE(_list_components_icone[indice].moduleicone); indice++; } // else - //MESSAGE("The component " <<_general_module_list[ind].Parsercomponentname << " was already defined in the personal catalog"); + //MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog"); } return _list_components_icone._retn() ; @@ -333,10 +388,10 @@ SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentT // All the components in the personal catalog are taken for (unsigned int ind=0; ind < _personal_module_list.size();ind++) { - if (_personal_module_list[ind].Parsercomponenttype == _temp_component_type) + if (_personal_module_list[ind].type == _temp_component_type) { _list_typed_component->length(_j + 1); - _list_typed_component[_j] = (_modulelist[ind].Parsercomponentname).c_str(); + _list_typed_component[_j] = (_moduleList[ind].name).c_str(); //SCRUTE(_list_typed_component[_j]) _j++; } @@ -351,27 +406,27 @@ SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentT { _find = false; - if(_general_module_list[ind].Parsercomponenttype == _temp_component_type) + if(_general_module_list[ind].type == _temp_component_type) { for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++) { // searching if the component is aleready defined in // the personal catalog - if ((_general_module_list[ind].Parsercomponentname.compare(_personal_module_list[ind1].Parsercomponentname)) == 0) + if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0) _find = true; } if (!_find) { - //MESSAGE("A new component " << _general_module_list[ind].Parsercomponentname << " has to be to added in the list"); + //MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list"); _list_typed_component->length(indice+1); // The component is not already defined => has to be taken - _list_typed_component[indice]=(_general_module_list[ind].Parsercomponentname).c_str(); + _list_typed_component[indice]=(_general_module_list[ind].name).c_str(); //SCRUTE(_list_typed_component[indice]) ; indice++; } //else - //MESSAGE("The component " <<_general_module_list[ind].Parsercomponentname << " was already defined in the personal catalog") ; + //MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog") ; } } @@ -387,22 +442,8 @@ SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentT // in the personal catalog is used //---------------------------------------------------------------------- SALOME_ModuleCatalog::Acomponent_ptr -SALOME_ModuleCatalogImpl::GetComponent(const char* componentname) +SALOME_ModuleCatalogImpl::GetComponent(const char* name) { - SALOME_ModuleCatalog::Acomponent_ptr compo; - SALOME_ModuleCatalog::ListOfDefInterface _list_interfaces; - _list_interfaces.length(0); - char* _constraint = NULL; - char* _icone = NULL; - char* _componentusername = NULL; - SALOME_ModuleCatalog::ComponentType _componenttype = SALOME_ModuleCatalog::OTHER; // default initialisation - CORBA::Boolean _componentmultistudy = false ; // default initialisation - ListOfPathPrefix _pathes ; - _pathes.resize(0); - - - bool find = false ; - // Looking for component named "componentname" in the personal catalog // If found, get name, interfaces and constraint // If not found, looking for component named "componentname" in @@ -410,161 +451,83 @@ SALOME_ModuleCatalogImpl::GetComponent(const char* componentname) // If found, get name, interfaces and constraint // If not found, NULL pointer is returned - for (unsigned int ind=0; ind < _personal_module_list.size();ind++) - { - if (strcmp((_personal_module_list[ind].Parsercomponentname).c_str(),componentname) == 0) - { - //MESSAGE("Component named " << componentname << " found in the personal catalog"); - find = true; - - // get constraint - _constraint = new char[strlen(_personal_module_list[ind].Parserconstraint.c_str()) + 1]; - _constraint = CORBA::string_dup(_personal_module_list[ind].Parserconstraint.c_str()); - - // get component type - switch(_personal_module_list[ind].Parsercomponenttype){ - case GEOM: - _componenttype = SALOME_ModuleCatalog::GEOM; - break; - case MESH: - _componenttype = SALOME_ModuleCatalog::MESH; - break; - case Med: - _componenttype = SALOME_ModuleCatalog::Med; - break; - case SOLVER: - _componenttype = SALOME_ModuleCatalog::SOLVER; - break; - case DATA: - _componenttype = SALOME_ModuleCatalog::DATA; - break; - case VISU: - _componenttype = SALOME_ModuleCatalog::VISU; - break; - case SUPERV: - _componenttype = SALOME_ModuleCatalog::SUPERV; - break; - case OTHER: - _componenttype = SALOME_ModuleCatalog::OTHER; - break; - } - - // get component multistudy - _componentmultistudy = _personal_module_list[ind].Parsercomponentmultistudy ; + std::string s(name); + ParserComponent *C_parser = NULL; + ParserPathPrefixes *pp = NULL; - // get component icone - _icone = CORBA::string_dup(_personal_module_list[ind].Parsercomponenticone.c_str()); + SALOME_ModuleCatalog::Acomponent_ptr compo = NULL; + + C_parser = findComponent(s); + if (C_parser) { + +// DebugParserComponent(*C_parser); - // get component user name - _componentusername = CORBA::string_dup(_personal_module_list[ind].Parsercomponentusername.c_str()); + SALOME_ModuleCatalog::Component C_corba; + duplicate(C_corba, *C_parser); - // get component interfaces - _list_interfaces = duplicate_interfaces(_personal_module_list[ind].ParserListInterface); + + SALOME_ModuleCatalog_AcomponentImpl * aComponentImpl = + new SALOME_ModuleCatalog_AcomponentImpl(C_corba); + + compo = aComponentImpl->_this(); + } + else { + // Not found in the personal catalog and in the general catalog + // return NULL object + MESSAGE("Component with name " << name + << " not found in catalog"); + compo = NULL; + } + + return compo; +} - // get pathes prefix - _pathes = duplicate_pathes(_personal_path_list); +SALOME_ModuleCatalog::Component * +SALOME_ModuleCatalogImpl::GetComponentInfo(const char *name) +{ + std::string s(name); - } - } + ParserComponent * C_parser = findComponent(s); - if (find) - { - SALOME_ModuleCatalog_AcomponentImpl* aComponentImpl = - new SALOME_ModuleCatalog_AcomponentImpl(componentname, - _componentusername, - _constraint, - _componenttype, - _componentmultistudy, - _icone, - _list_interfaces, - _pathes); - - compo = aComponentImpl->_this(); - } - else - // Not found in the personal catalog => searching in the general catalog - { - for (unsigned int ind=0; ind < _general_module_list.size();ind++) - { - if (strcmp((_general_module_list[ind].Parsercomponentname).c_str(),componentname) == 0) - { - //MESSAGE("Component named " << componentname << " found in the general catalog"); - find = true; - - // get constraint - _constraint = new char[strlen(_general_module_list[ind].Parserconstraint.c_str()) + 1]; - _constraint = CORBA::string_dup(_general_module_list[ind].Parserconstraint.c_str()); - - - // get component type - switch(_general_module_list[ind].Parsercomponenttype){ - case GEOM: - _componenttype = SALOME_ModuleCatalog::GEOM; - break; - case MESH: - _componenttype = SALOME_ModuleCatalog::MESH; - break; - case Med: - _componenttype = SALOME_ModuleCatalog::Med; - break; - case SOLVER: - _componenttype = SALOME_ModuleCatalog::SOLVER; - break; - case DATA: - _componenttype = SALOME_ModuleCatalog::DATA; - break; - case VISU: - _componenttype = SALOME_ModuleCatalog::VISU; - break; - case SUPERV: - _componenttype = SALOME_ModuleCatalog::SUPERV; - break; - case OTHER: - _componenttype = SALOME_ModuleCatalog::OTHER; - break; - } - + if (C_parser) { + + SALOME_ModuleCatalog::Component * C_corba + = new SALOME_ModuleCatalog::Component; + duplicate(*C_corba, *C_parser); + return C_corba; + } - // get component multistudy - _componentmultistudy = _general_module_list[ind].Parsercomponentmultistudy ; + return NULL; +} - // get component icone - _icone = CORBA::string_dup(_general_module_list[ind].Parsercomponenticone.c_str()); +ParserComponent * +SALOME_ModuleCatalogImpl::findComponent(const string & name) +{ + ParserComponent * C_parser = NULL; - // get component user name - _componentusername = CORBA::string_dup(_general_module_list[ind].Parsercomponentusername.c_str()); + if (!C_parser) + for (unsigned int ind=0; ind < _personal_module_list.size();ind++) + if (name.compare(_personal_module_list[ind].name) == 0) + { + MESSAGE("Component named " << name + << " found in the personal catalog"); + C_parser = &(_personal_module_list[ind]); + break; + } - // get component interfaces - _list_interfaces = duplicate_interfaces(_general_module_list[ind].ParserListInterface); + if (!C_parser) + for (unsigned int ind=0; ind < _general_module_list.size();ind++) + { + if (name.compare(_general_module_list[ind].name) == 0) + { + MESSAGE("Component named " << name + << " found in the general catalog"); + C_parser = &(_general_module_list[ind]); + break; + } + } - // get pathes prefix - _pathes = duplicate_pathes(_general_path_list); - } - } - - if (find) - { - SALOME_ModuleCatalog_AcomponentImpl* aComponentImpl = - new SALOME_ModuleCatalog_AcomponentImpl(componentname, - _componentusername, - _constraint, - _componenttype, - _componentmultistudy, - _icone, - _list_interfaces, - _pathes); - - compo = aComponentImpl->_this(); - } - else - // Not found in the personal catalog and in the general catalog - // return NULL object - { - MESSAGE("Component with name " << componentname << " not found in catalog"); - compo = NULL; - } - } - return compo; + return C_parser; } //---------------------------------------------------------------------- @@ -573,9 +536,12 @@ SALOME_ModuleCatalogImpl::GetComponent(const char* componentname) //---------------------------------------------------------------------- void SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file, - ListOfParserComponent& modulelist, - ListOfParserPathPrefix& pathlist) + ParserComponents& modulelist, + ParserPathPrefixes& pathList) { + BEGIN_OF("_parse_xml_file"); + SCRUTE(file); + SALOME_ModuleCatalog_Handler* handler = new SALOME_ModuleCatalog_Handler(); QFile xmlFile(file); @@ -586,102 +552,218 @@ SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file, reader.setErrorHandler( handler ); reader.parse( source ); xmlFile.close(); - unsigned int ind; - for ( ind = 0; ind < _modulelist.size(); ind++) - modulelist.push_back(_modulelist[ind]) ; - for ( ind = 0; ind < _pathlist.size(); ind++) - pathlist.push_back(_pathlist[ind]) ; + + unsigned int i, j; + + for ( i = 0; i < _moduleList.size(); i++) { + for (j=0; j::const_iterator it_type; - unsigned int _length = pathes.size() ; - _pathes.resize(_length); - unsigned int _length_comput = 0; + std::map < std::string, + SALOME_ModuleCatalog::DataStreamDependency >::const_iterator it_dep; + + // duplicate parameter name + P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str()); - for (unsigned int ind = 0; ind < _length ; ind++) - { - // duplicate path - _pathes[ind].path = CORBA::string_dup(pathes[ind].path.c_str()) ; - //MESSAGE("Prefix : " << _pathes[ind].path); + // doesn't work ??? + // it_type = DataStreamTypeConvert.find(P_parser.type); + // P_corba.Parametertype + // = (it_type == DataStreamTypeConvert.end()) + // ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN; + + SCRUTE(P_parser.type); + P_corba.Parametertype = SALOME_ModuleCatalog::DATASTREAM_UNKNOWN; + for (it_type = DataStreamTypeConvert.begin(); + it_type != DataStreamTypeConvert.end(); + it_type++) + if (P_parser.type.compare(it_type->first) == 0) { + P_corba.Parametertype = it_type->second; + break; + } + SCRUTE(P_corba.Parametertype); - _length_comput = pathes[ind].ListOfComputer.size() ; - _pathes[ind].ListOfComputer.resize(_length_comput); - for (unsigned int ind1 = 0; ind1 <_length_comput ; ind1++) - { - // duplicate computer name - _pathes[ind].ListOfComputer[ind1] = CORBA::string_dup(pathes[ind].ListOfComputer[ind1].c_str()); - //MESSAGE("Computer associated to the prefix : " <<_pathes[ind].ListOfComputer[ind1]); - } - } - return _pathes ; + // duplicate parameter type + + // doesn't work ??? + // it_type = DataStreamTypeConvert.find(P_parser.type); + // P_corba.Parametertype + // = (it_type == DataStreamTypeConvert.end()) + // ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN; + + SCRUTE(P_parser.dependency); + P_corba.Parameterdependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED; + for (it_dep = DataStreamDepConvert.begin(); + it_dep != DataStreamDepConvert.end(); + it_dep++) + if (P_parser.dependency.compare(it_dep->first) == 0) { + P_corba.Parameterdependency = it_dep->second; + break; + } + + SCRUTE(P_corba.Parameterdependency); +} + +//---------------------------------------------------------------------- +// Function : duplicate +// Purpose : create the path prefix structures from the catalog parsing +//---------------------------------------------------------------------- +void +SALOME_ModuleCatalogImpl::duplicate(ParserPathPrefixes &L_out, + const ParserPathPrefixes &L_in) +{ + L_out = L_in; } @@ -692,18 +774,17 @@ SALOME_ModuleCatalogImpl::duplicate_pathes(ListOfParserPathPrefix pathes) // particular computer //---------------------------------------------------------------------- bool -SALOME_ModuleCatalogImpl::_verify_path_prefix(ListOfParserPathPrefix pathlist) +SALOME_ModuleCatalogImpl::_verify_path_prefix(ParserPathPrefixes & pathList) { bool _return_value = true; vector _machine_list; - _machine_list.resize(0); // Fill a list of all computers indicated in the path list - for (unsigned int ind = 0; ind < pathlist.size(); ind++) + for (unsigned int ind = 0; ind < pathList.size(); ind++) { - for (unsigned int ind1 = 0 ; ind1 < pathlist[ind].ListOfComputer.size(); ind1++) + for (unsigned int ind1 = 0 ; ind1 < pathList[ind].listOfComputer.size(); ind1++) { - _machine_list.push_back(pathlist[ind].ListOfComputer[ind1]); + _machine_list.push_back(pathList[ind].listOfComputer[ind1]); } } @@ -740,23 +821,19 @@ SALOME_ModuleCatalogImpl::_parseArguments(int argc, char **argv, if (strcmp(argv[ind],"-help") == 0) { - INFOS( "Usage: " << argv[0] << " -common 'path to general catalog' -personal 'path to personal catalog' -ORBInitRef NameService=corbaname::localhost"); + INFOS( "Usage: " << argv[0] + << " -common 'path to general catalog' " + " -personal 'path to personal catalog' " + " -ORBInitRef NameService=corbaname::localhost"); _return_value = false ; } + if (strcmp(argv[ind],"-common") == 0) { if (ind + 1 < argc) { // General catalog file *_general = argv[ind + 1] ; -/* ifstream _general_file(*_general); - if (!_general_file) - { - MESSAGE( "Sorry the file " << *_general << " can't be open" ) - *_general = NULL; - _return_value = false; - } -*/ } } else if (strcmp(argv[ind],"-personal") == 0) @@ -765,14 +842,6 @@ SALOME_ModuleCatalogImpl::_parseArguments(int argc, char **argv, { // Personal catalog file *_personal = argv[ind + 1] ; -/* ifstream _personal_file(*_personal); - if (!_personal_file) - { - MESSAGE("Sorry the file " << *_personal << " can't be open" ) - *_personal = NULL; - _return_value = false; - } -*/ } } } diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx index 91938842b..a878c2f49 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx @@ -26,12 +26,16 @@ // Module : SALOME // $Header$ + #ifndef MODULECATALOG_IMPL_H #define MODULECATALOG_IMPL_H #include "utilities.h" +#include +#include + #include "SALOME_ModuleCatalog_Handler.hxx" -#include "PathPrefix.hxx" + #include #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog) @@ -40,7 +44,7 @@ class SALOME_ModuleCatalogImpl: public POA_SALOME_ModuleCatalog::ModuleCatalog, { public: //! standard constructor - SALOME_ModuleCatalogImpl(int artgc, char** argv); + SALOME_ModuleCatalogImpl(int artgc, char** argv, CORBA::ORB_ptr orb = NULL); //! standard destructor virtual ~SALOME_ModuleCatalogImpl(); @@ -58,6 +62,12 @@ public: */ virtual char* GetPathPrefix(const char* machinename); + //! method to read a XML file and import new components into the component list + /*! If the XML file doesn't exist or is not readable, the Notfound exception is thrown + \param const char* xmlFileName + */ + virtual void ImportXmlCatalogFile(const char* xmlFileName); + //! method to get a component list /*! \return a component list @@ -84,41 +94,90 @@ public: */ virtual SALOME_ModuleCatalog::Acomponent_ptr GetComponent(const char* componentname); + + //! method to get a component description + /*! + \param componentname const char* arguments + \return the wanted component description + */ + virtual SALOME_ModuleCatalog::Component * + GetComponentInfo(const char *name); void ping(){}; + void shutdown() { if (_orb) _orb->shutdown(1); }; + private: //! method to parse one module catalog /*! \param file const char* arguments - \param modulelist ListOfParserComponent arguments - \param pathlist ListOfParserPathPrefix arguments + \param modulelist ParserComponents arguments + \param pathlist ParserPathPrefixes arguments */ virtual void _parse_xml_file(const char* file, - ListOfParserComponent& modulelist, - ListOfParserPathPrefix& pathlist); + ParserComponents & modulelist, + ParserPathPrefixes & pathlist); + + //! method to find component in the parser list + /*! + \param name string argument + \return pointer on a component, NULL if not found + */ + ParserComponent *findComponent(const string & name); - //! method to create a list of interfaces from the parsing of the catalog + //! method to create a CORBA component description from parser /*! - \param list_interface ListOfDefinitionInterface arguments - \return the interfaces list + \param C_corba Component argument + \param C_parser const ParserComponent argument */ - virtual SALOME_ModuleCatalog::ListOfDefInterface - duplicate_interfaces(ListOfDefinitionInterface list_interface); + void duplicate(SALOME_ModuleCatalog::Component & C_corba, + const ParserComponent & C_parser); + + //! method to create a CORBA interface description from parser + /*! + \param I_corba DefinitionInterface argument + \param I_parser const ParserInterface argument + */ + void duplicate(SALOME_ModuleCatalog::DefinitionInterface & I_corba, + const ParserInterface & I_parser); + + //! method to create a CORBA service description from parser + /*! + \param S_corba Service argument + \param S_parser const ParserService argument + */ + void duplicate(SALOME_ModuleCatalog::Service & S_corba, + const ParserService & service); + + //! method to create a CORBA parameter description from parser + /*! + \param P_corba ServicesParameter argument + \param P_parser const ParserParameter argument + */ + void duplicate(SALOME_ModuleCatalog::ServicesParameter & P_corba, + const ParserParameter & P_parser); + + //! method to create a CORBA datastream parameter description from parser + /*! + \param P_corba ServicesDataStreamParameter argument + \param P_parser const ParserDataStreamParameter argument + */ + void duplicate(SALOME_ModuleCatalog::ServicesDataStreamParameter & P_corba, + const ParserDataStreamParameter & P_parser); - //! method to create the path prefix structures from the catalog parsing + //! method to create the path prefix structures from the catalog parsing /*! - \param pathes ListOfParserPathPrefix arguments + \param pathes ParserPathPrefixes arguments \return the pathes */ - virtual ListOfPathPrefix duplicate_pathes(ListOfParserPathPrefix pathes); + void duplicate(ParserPathPrefixes & p_out, const ParserPathPrefixes & P_in); //! method to verify path prefix content /*! \param pathlist ListOfParserPathPrefix arguments \return true if verfication is OK */ - virtual bool _verify_path_prefix(ListOfParserPathPrefix pathlist); + virtual bool _verify_path_prefix(ParserPathPrefixes & pathlist); //! method to parse arguments to get general and personal catalog files @@ -138,13 +197,23 @@ private: // These variables will contain the informations on the general common catalog - ListOfParserComponent _general_module_list ; - ListOfParserPathPrefix _general_path_list ; + ParserComponents _general_module_list ; + ParserPathPrefixes _general_path_list ; // These variables will contain the informations on the personal catalog - ListOfParserComponent _personal_module_list ; - ListOfParserPathPrefix _personal_path_list ; + ParserComponents _personal_module_list ; + ParserPathPrefixes _personal_path_list ; + + std::map + DataStreamTypeConvert; + + std::map + DataStreamDepConvert; + + std::map + ComponentTypeConvert; + CORBA::ORB_ptr _orb; }; #endif // MODULECATALOG_IMPL_H diff --git a/src/ModuleCatalog/SALOME_TestModuleCatalog.py b/src/ModuleCatalog/SALOME_TestModuleCatalog.py new file mode 100644 index 000000000..036fe5d2e --- /dev/null +++ b/src/ModuleCatalog/SALOME_TestModuleCatalog.py @@ -0,0 +1,64 @@ +import batchmode_salome +import SALOME_ModuleCatalog + +print +print "======================================================================" +print " XML Catalog file generation from idl file" +print "======================================================================" + +import os +os.system('runIDLparser -Wbcatalog=x \ + ${KERNEL_ROOT_DIR}/idl/salome/SALOME_TestModuleCatalog.idl') + +print "======================================================================" +print " Get Catalog " +print "======================================================================" +obj = batchmode_salome.naming_service.Resolve('Kernel/ModulCatalog') +catalog = obj._narrow(SALOME_ModuleCatalog.ModuleCatalog) +catalog.GetComponentList() + +print +print "======================================================================" +print " Import xml file " +print "======================================================================" +catalog.ImportXmlCatalogFile("x.xml") + +name = "AddComponent" +print +print "======================================================================" +print " Dump component <", name, "> " +print "======================================================================" +C = catalog.GetComponent(name) + +print "name : ", C._get_componentname() +print "username : ", C._get_componentusername() +print "type : ", C._get_component_type() +print "constraint : ", C._get_constraint() +print "icon : ", C._get_component_icone() + +for iL in C.GetInterfaceList(): + I = C.GetInterface(iL) + print "interface : ", I.interfacename + for S in I.interfaceservicelist: + print " service : ", S.ServiceName + print " ", len(S.ServiceinParameter), "in params : " + for iP in S.ServiceinParameter: + print ' ' + iP.Parametername + '(' + iP.Parametertype + ')' + pass + print " ", len(S.ServiceoutParameter), "out params : " + for iP in S.ServiceoutParameter: + print ' ' + iP.Parametername + '(' + iP.Parametertype + ')' + pass + print " ", len(S.ServiceinDataStreamParameter), "in datastream params : " + for iP in S.ServiceinDataStreamParameter: + print ' ' + iP.Parametername + '(' + str(iP.Parametertype) + ', ' + \ + str(iP.Parameterdependency) + ')' + pass + print " ", len(S.ServiceoutDataStreamParameter), "out datastream params : " + for iP in S.ServiceoutDataStreamParameter: + print ' ' + iP.Parametername + '(' + str(iP.Parametertype) + ', ' + \ + str(iP.Parameterdependency) + ')' + pass + pass + pass + diff --git a/src/ModuleGenerator/IDLparser.py b/src/ModuleGenerator/IDLparser.py index 1743563c6..a653da09e 100644 --- a/src/ModuleGenerator/IDLparser.py +++ b/src/ModuleGenerator/IDLparser.py @@ -36,7 +36,8 @@ common_data={"AUTHOR" : "", "COMP_TYPE" : "", "COMP_NAME" : "", "COMP_UNAME" : "", - "COMP_MULT" : "" + "COMP_MULT" : "", + "COMP_IMPL" : "" } nb_components = 0 @@ -72,11 +73,13 @@ def error (message): #-------------------------------------------------- class Tree: - def __init__(self, name = '', content = ''): + def __init__(self, name = '', content = '', key = None): self.name = name self.content = content + self.key = key self.parent = None self.childs = [] + self.comments = [] def addChild(self, tree): if tree is not None: @@ -91,7 +94,7 @@ class Tree: if tree is not None: pos = 0 for i in self.childs: - if i.name == tree.name: + if (i.name == tree.name) & ((i.key is None) | (i.key == tree.key)): self.childs.pop(pos) self.childs.insert(pos, tree) return tree @@ -150,8 +153,8 @@ class Tree: return l def getChild(self, name, content=None): - - # content == None, don't compare content + # return child node with a given name + # if content == None, don't compare contents for i in self.childs: if (i.name == name): if (content is None) | (i.content == content): @@ -159,8 +162,7 @@ class Tree: return None def getNode(self, name, content='', depth=-1): - - # recursive search + # recursive search of a node with a given name # content == None, don't compare content if (self.name == name): if (content is None) | (self.content == content): @@ -169,7 +171,7 @@ class Tree: if (depth != 0): for i in self.childs: n = i.getNode(name, content, depth-1) - if n: return n #return a value + if n: return n return None @@ -184,44 +186,114 @@ class Tree: def merge(self, t): pass + + def mergeChilds(self, t, list): + L_ext = t.getChild(list) + L_int = self.getChild(list) + + L_merge = Tree(list) + + for i_ext in L_ext.childs: + k_ext = i_ext.key + if k_ext is None: continue + present = 0 + + for i_int in L_int.childs: + k_int = i_int.key + if k_int is None: continue + + if (k_int == k_ext): + present = 1 + break; + + if present : + i_int.merge(i_ext) + L_merge.addChild(i_int) + else: + L_merge.addChild(i_ext) + + self.replaceChild(L_merge) + + #-------------------------------------------------- -# implements inParameter tree +# implements parameter tree #-------------------------------------------------- -class inParameter(Tree): +class parameter(Tree): - def __init__(self, name=None, type='', comment='unknown'): - Tree.__init__(self, 'inParameter') + def __init__(self, name=None, mode = 'in', type='', comment='unknown'): + Tree.__init__(self, mode + 'Parameter', key=name) + self.mode = mode if name is None: return - self.addNamedChild('inParameter-type', type) - self.addNamedChild('inParameter-name', name) - self.addNamedChild('inParameter-comment', comment) - + self.addNamedChild(mode + 'Parameter-name', name) + self.addNamedChild(mode + 'Parameter-type', type) + self.addNamedChild(mode + 'Parameter-comment', comment) + def merge(self, P): - T = P.getChild('inParameter-type') - self.replaceChild(T) + self.mode = P.mode + self.replaceChild(P.getChild(P.mode + 'Parameter-name')) + self.replaceChild(P.getChild(P.mode + 'Parameter-type')) + C = P.getChild(P.mode + 'Parameter-comment') + if C.content != 'unkonwn': + self.replaceChild(C) #-------------------------------------------------- -# implements outParameter tree +# implements dataStreamParameter tree #-------------------------------------------------- -class outParameter(Tree): +class dataStreamParameter(parameter): - def __init__(self, name=None, type='', comment = 'unknown'): - - Tree.__init__(self, 'outParameter') + def __init__(self, name=None, mode='in', type='', dependency='', comment='unknown'): + parameter.__init__(self, name, mode, type, comment) if name is None: return - self.addNamedChild('outParameter-type', type) - self.addNamedChild('outParameter-name', name) - self.addNamedChild('outParameter-comment', comment) + self.addNamedChild(mode + 'Parameter-dependency', dependency) + self.mode = mode def merge(self, P): - T = P.getChild('outParameter-type') - self.replaceChild(T) + parameter.merge(self, P) + self.replaceChild(P.getChild(mode + 'Parameter-dependency')) + + +def parseComment(comment): + + spaces = '[\t\n ]*' + word = spaces + '([a-zA-Z][a-zA-Z0-9_]*)' + spaces + + result = [] + type = None + key = None + ## match : // followed by a 'DataStreamPorts' string, + ## the service name, and a list of ports + pattern = '// *DataStreamPorts{,1}' + word + m = re.match(pattern, comment) + + ## if there is a match, parse remaining part of comment + if m: + ## service + type = 'DataStreamPorts' + key = m.group(1) + + sPorts = comment[m.end():] + pattern = word + '\('+word+','+word +','+word+'\)' \ + + spaces + ',{,1}' + spaces + while len(sPorts) > 0: + ## process next DataStreamPort + ## match a definition like xx(a,b,c) with a possible trailing , + ## returns a tuple (xx, a, b, c) and + ## the remaining part of input string + m = re.match(pattern, sPorts) + if m is None: + raise LookupError, \ + 'format error in DataStreamPort definition : '+sPorts + sPorts = sPorts[m.end():] + result.append(m.groups()) + + return type, key, result; + #-------------------------------------------------- # implements service tree #-------------------------------------------------- @@ -229,7 +301,7 @@ class Service(Tree): def __init__(self, name=None, comment = 'unknown'): - Tree.__init__(self, 'component-service') + Tree.__init__(self, 'component-service', key=name) if name is None: return self.addNamedChild('service-name', name) @@ -239,86 +311,38 @@ class Service(Tree): self.addNamedChild('service-by-default', "0") self.addNamedChild('inParameter-list') self.addNamedChild('outParameter-list') + self.addNamedChild('DataStream-list') def createInParameter(self, name, type): L = self.getChild('inParameter-list') - if L is None: - error ("Service.createInParameter() : 'inParameter-list' is not found"); return None; - p = inParameter(name, type) - L.addChild(p) + p = parameter(name, 'in', type) + L.replaceChild(p) return p def createOutParameter(self, name, type): L = self.getChild('outParameter-list') - if L is None: - error ("Service.createOutParameter() : 'outParameter-list' is not found"); return None; - p = outParameter(name, type) - L.addChild(p) + p = parameter(name, 'out', type) + L.replaceChild(p) return p - + def createDataStreamParameter(self, p): + L = self.getChild('DataStream-list') + p = dataStreamParameter(p[0], p[2], p[1], p[3]) + L.replaceChild(p) + return p + def merge(self, S): - - L_ext = S.getChild('inParameter-list') - L_int = self.getChild('inParameter-list') - if L_ext is not None and L_int is not None: - - L_merge = Tree('inParameter-list') - - for i_ext in L_ext.childs: - # i_ext = - n_ext = i_ext.getChild('inParameter-name') - if n_ext is None: continue - present = 0 - - for i_int in L_int.childs: - # i_int = - n_int = i_int.getChild('inParameter-name') - - if n_int is None: continue - - if (n_int.content == n_ext.content): - present = 1 - break; - - if present : - i_int.merge(i_ext) - L_merge.addChild(i_int) - else: - L_merge.addChild(i_ext) - - self.replaceChild(L_merge) + self.replaceChild(S.getChild('service-author')) + self.replaceChild(S.getChild('service-version')) + self.replaceChild(S.getChild('service-by-default')) + C = S.getChild('service-comment') + if C.content != 'unkonwn': + self.replaceChild(C) - else : error("Service.merge(): 'inParameter-list' is not found") #either L_ext or L_int is None + for L in ['inParameter-list', 'outParameter-list', 'DataStream-list']: + self.mergeChilds(S, L) - L_ext = S.getChild('outParameter-list') - L_int = self.getChild('outParameter-list') - - if L_ext is None or L_int is None: - error ("Service.merge() : 'outParameter-list' is not found") - - L_merge = Tree('outParameter-list') - - for i_ext in L_ext.childs: - #i_ext = - present = 0 - n_ext = i_ext.getChild('outParameter-name') - if n_ext is None: continue - for i_int in L_int.childs: - n_int = i_int.getChild('outParameter-name') - if n_int is None: continue - if (n_int.content == n_ext.content): - present = 1 - break; - - if present : - i_int.merge(i_ext) - L_merge.addChild(i_int) - else: - L_merge.addChild(i_ext) - - self.replaceChild(L_merge) #-------------------------------------------------- @@ -328,7 +352,7 @@ class Interface(Tree): def __init__(self, name=None, comment='unknown'): - Tree.__init__(self) + Tree.__init__(self, key=name) if name is None: return @@ -347,48 +371,52 @@ class Interface(Tree): L.addChild(s) return s + def findService(self, key): + L = self.getChild('component-service-list') + for S in L.childs: + if S.key == key: + return S + return None + def merge(self, I): - L_ext = I.getChild('component-service-list') - L_int = self.getChild('component-service-list') - - if L_ext is None or L_int is None: - error("Interface.merge() : 'component-service-list' is not found!") - return - - L_merge = Tree('component-service-list') - - for i_ext in L_ext.childs: - - present = 0 - n_ext = i_ext.getChild('service-name') - if n_ext is None: continue - - for i_int in L_int.childs: - n_int = i_int.getChild('service-name') - if n_int is None: continue - if (n_int.content == n_ext.content): - present = 1 - break; - - if present == 0: - i_int.merge(i_ext) - L_merge.addChild(i_int) - else: - L_merge.addChild(i_ext) - - self.replaceChild(L_merge) + C = S.getChild('component-interface-comment') + if C.content != 'unkonwn': + self.replaceChild(C) + + self.mergeChilds(I, 'component-service-list') + + def processDataStreams(self): + for sComment in self.comments: + + type, key, result = parseComment(sComment) + + if type == 'DataStreamPorts': + Service = self.findService(key) + if Service is None: + raise LookupError, \ + 'service ' + key + \ + ' not found in interface : ' + self.key + for p in result: + ## process next DataStreamPort + Service.createDataStreamParameter(p) #-------------------------------------------------- # implements Component tree #-------------------------------------------------- class Component(Tree): - def __init__(self): - Tree.__init__(self, 'component') + def __init__(self, name=None): + Tree.__init__(self, 'component', key=name) + if name is None: return - self.addNamedChild('component-name', common_data["COMP_NAME"]) - self.addNamedChild('component-username', common_data["COMP_UNAME"]) + self.addNamedChild('component-name', name) + + if common_data["COMP_UNAME"] != '': + self.addNamedChild('component-username', common_data["COMP_UNAME"]) + else: + self.addNamedChild('component-username', name) + self.addNamedChild('component-type', common_data["COMP_TYPE"]) self.addNamedChild('component-author', common_data["AUTHOR"]) self.addNamedChild('component-version', common_data["VERSION"]) @@ -411,7 +439,7 @@ class Component(Tree): for i in ['component-username', 'component-author', 'component-type', 'component-icone', 'component-version', - 'component-comment', 'component-multistudy', 'constraint']: + 'component-multistudy', 'constraint']: ext = C.getChild(i) int = self.getChild(i) if int is None: @@ -419,33 +447,11 @@ class Component(Tree): 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: - error("Component.merge : No component-interface-list is found") - return - L_merge = Tree('component-interface-list') - - for i_ext in L_ext.childs: - present = 0 - n_ext = i_ext.getChild('component-interface-name') - - if n_ext is None: continue - - for i_int in L_int.childs: - n_int = i_int.getChild('component-interface-name') - if n_int is None: continue - if (n_int.content == n_ext.content): - present = 1 - break; + Cc = C.getChild('component-comment') + if Cc.content != 'unkonwn': + self.replaceChild(Cc) - if present : - i_int.merge(i_ext) - L_merge.addChild(i_int) - else: - L_merge.addChild(i_ext) - - self.replaceChild(L_merge) + self.mergeChilds(C, 'component-interface-list') #-------------------------------------------------- # implements document tree @@ -491,7 +497,6 @@ class Catalog(ContentHandler, Tree): def startElement(self, name, attrs): p = self.list[len(self.list)-1] - if name == 'component': e = p.addChild(Component()) elif name == 'component-interface-name': @@ -499,9 +504,9 @@ class Catalog(ContentHandler, Tree): elif name == 'component-service': e = p.addChild(Service()) elif name == 'inParameter': - e = p.addChild(inParameter()) + e = p.addChild(parameter(mode='in')) elif name == 'outParameter': - e = p.addChild(outParameter()) + e = p.addChild(parameter(mode='out')) else: e = p.addNamedChild(name) self.list.append(e) @@ -511,9 +516,10 @@ class Catalog(ContentHandler, Tree): self.buffer = string.join(string.split(self.buffer), ' ') p = self.list[len(self.list)-1] p.content = self.buffer + if name == 'component': + p.key = p.getChild('component-name').content self.buffer = '' e = self.list.pop() - def characters(self, ch): self.buffer += ch @@ -527,23 +533,17 @@ class Catalog(ContentHandler, Tree): i_ext = comp present = 0 - n_ext = i_ext.getChild('component-name') - if n_ext is None: - error("Catalog.mergeComponent : 'component-name' is not found") - return + n_ext = i_ext.key for i_int in L_int.childs: - n_int = i_int.getChild('component-name') - if n_int is None: continue - - if (n_int.content == n_ext.content): + if (i_int.key == n_ext): present = 1 break; if present == 0: - print ' add component', n_ext.content + print ' add component', i_ext.getChild('component-name').content L_int.addChild(i_ext) else: - print ' replace component', n_ext.content + print ' replace component', i_ext.getChild('component-name').content i_int.merge(i_ext) @@ -590,6 +590,7 @@ class ModuleCatalogVisitor (idlvisitor.AstVisitor): n.accept(self) def visitInterface(self, node): + if node.mainFile(): self.EngineType = 0 @@ -599,7 +600,7 @@ class ModuleCatalogVisitor (idlvisitor.AstVisitor): if ((s[0] == "Engines") & (s[1] == "Component")): self.EngineType = 1; break - Comp = Component() + Comp = Component(node.identifier()) self.currentInterface = Comp.createInterface(node.identifier()) @@ -607,18 +608,28 @@ class ModuleCatalogVisitor (idlvisitor.AstVisitor): if isinstance(c, idlast.Operation): c.accept(self) - if (self.EngineType): + for c in node.declarations(): + if isinstance(c, idlast.Struct): + c.accept(self) + + for i in node.comments(): + self.currentInterface.comments.append(str(i)) + + self.currentInterface.processDataStreams() + + if (self.EngineType): global nb_components nb_components = nb_components + 1 self.catalog.mergeComponent(Comp) self.EngineType = 0 + def visitOperation(self, node): self.currentService = self.currentInterface.createService \ (node.identifier()) - + for c in node.parameters(): c.accept(self) @@ -626,6 +637,9 @@ class ModuleCatalogVisitor (idlvisitor.AstVisitor): if (self.currentType != "void"): self.currentService.createOutParameter \ ("return", self.currentType) + + for i in node.comments(): + self.currentInterface.comments.append(str(i)) def visitDeclaredType(self, type): @@ -650,10 +664,8 @@ class ModuleCatalogVisitor (idlvisitor.AstVisitor): # parse idl and store xml file #-------------------------------------------------- def run(tree, args): - print args CatalogFileName=getParamValue("catalog", "CatalogModulePersonnel.xml", args) - print CatalogFileName if re.compile(".*?.xml$").match(CatalogFileName, 1) is None: CatalogFileName = CatalogFileName + '.xml' @@ -665,6 +677,7 @@ def run(tree, args): common_data["COMP_UNAME"] = getParamValue("username", "", args) common_data["COMP_TYPE"] = getParamValue("type", "OTHER", args) common_data["COMP_MULT"] = getParamValue("multistudy", "1", args) + common_data["COMP_IMPL"] = getParamValue("impltype", "1", args) print common_data @@ -678,12 +691,14 @@ def run(tree, args): else: print "Creating ",CatalogFileName C = Catalog() - + print "Reading idl file" visitor = ModuleCatalogVisitor(C) tree.accept(visitor) +## C.Dump() + if remove_comp : C.removeComponent(remove_comp) @@ -712,3 +727,5 @@ if __name__ == "__main__": print print "Usage : omniidl -bIDLparser [-I]* -Wbcatalog=[,icon=][,version=][,author=][,name=][,username=][,multistudy=] " print + + diff --git a/src/ModuleGenerator/README b/src/ModuleGenerator/README index c5b46c91f..34c4a62da 100644 --- a/src/ModuleGenerator/README +++ b/src/ModuleGenerator/README @@ -70,8 +70,8 @@ ou vaut 1, 1b, 2, 3, 4, 5 Les scripts de test se trouvent dans le repertoire - /SALOME/src/ModuleGenerator/tests + /src/ModuleGenerator/tests Les fichiers idl servant aux tests se trouvent dans les repertoires - /idl - /SALOME/src/ModuleGenerator/tests + /idl + /src/ModuleGenerator/tests diff --git a/src/NOTIFICATION_SWIG/NOTIFICATION_Swig.cxx b/src/NOTIFICATION_SWIG/NOTIFICATION_Swig.cxx index 40bc4a12a..6e36d52a9 100644 --- a/src/NOTIFICATION_SWIG/NOTIFICATION_Swig.cxx +++ b/src/NOTIFICATION_SWIG/NOTIFICATION_Swig.cxx @@ -25,8 +25,8 @@ // Author : Francis KLOSS // Module : SALOME -#include "NOTIFICATION_Swig.hxx" using namespace std; +#include "NOTIFICATION_Swig.hxx" // Swig notification supplier // -------------------------- diff --git a/src/NOTIFICATION_SWIG/NOTIFICATION_Swig.hxx b/src/NOTIFICATION_SWIG/NOTIFICATION_Swig.hxx index 746f8e9ec..f2361808c 100644 --- a/src/NOTIFICATION_SWIG/NOTIFICATION_Swig.hxx +++ b/src/NOTIFICATION_SWIG/NOTIFICATION_Swig.hxx @@ -25,8 +25,8 @@ // Author : Francis KLOSS // Module : SALOME -#include "NOTIFICATION.hxx" using namespace std; +#include "NOTIFICATION.hxx" class NOTIFICATION_Supplier_Swig { public: diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx index 6c71e5f49..6fe58e93c 100644 --- a/src/NamingService/SALOME_NamingService.cxx +++ b/src/NamingService/SALOME_NamingService.cxx @@ -26,11 +26,11 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOME_NamingService.hxx" #include "ServiceUnreachable.hxx" #include #include -using namespace std; //---------------------------------------------------------------------- /*! Function : SALOME_NamingService @@ -183,7 +183,7 @@ void SALOME_NamingService::Register(CORBA::Object_ptr ObjRef, _temp_context = _current_context->bind_new_context(_context_name); _current_context = _temp_context; - //MESSAGE("This context was'nt created, it's now done"); + //INFOS("This context was'nt created, it's now done"); } } } @@ -456,7 +456,7 @@ bool SALOME_NamingService::Create_Directory(const char* Path) _temp_context = _current_context->bind_new_context(_context_name); _current_context = _temp_context; - MESSAGE("This context was'nt created, it's now done"); + INFOS("This context was'nt created, it's now done"); } } } @@ -563,31 +563,31 @@ bool SALOME_NamingService::Change_Directory(const char* Path) _return_code = false; CosNaming::Name n = ex.rest_of_name; if (ex.why == CosNaming::NamingContext::missing_node) - MESSAGE( "Change_Directory() : " << (char *) n[0].id + INFOS( "Change_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") not found") if (ex.why == CosNaming::NamingContext::not_context) - MESSAGE("Change_Directory() : " << (char *) n[0].id + INFOS("Change_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not a context" ) if (ex.why == CosNaming::NamingContext::not_object) - MESSAGE( "Change_Directory() : " << (char *) n[0].id + INFOS( "Change_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not an object" ) } catch(CosNaming::NamingContext::CannotProceed&) { _return_code = false; - MESSAGE( "!!!Change_Directory() : CosNaming::NamingContext::CannotProceed" ) + INFOS( "!!!Change_Directory() : CosNaming::NamingContext::CannotProceed" ) } catch(CosNaming::NamingContext::InvalidName&) { _return_code = false; - MESSAGE( "!!!Change_Directory() : CosNaming::NamingContext::InvalidName" ) + INFOS( "!!!Change_Directory() : CosNaming::NamingContext::InvalidName" ) } catch(CORBA::COMM_FAILURE&) { _return_code = false; - MESSAGE( "!!!Change_Directory() :CORBA::COMM_FAILURE : unable to contact" + INFOS( "!!!Change_Directory() :CORBA::COMM_FAILURE : unable to contact" << "the naming service") throw ServiceUnreachable(); } @@ -631,7 +631,7 @@ char* SALOME_NamingService::Current_Directory() } catch(CORBA::COMM_FAILURE&) { - MESSAGE("!!!Current_Directory(): CORBA::COMM_FAILURE : unable to contact" + INFOS("!!!Current_Directory(): CORBA::COMM_FAILURE : unable to contact" << " the naming service" ) throw ServiceUnreachable(); } @@ -685,7 +685,7 @@ void SALOME_NamingService::list() } catch (ServiceUnreachable&) { - MESSAGE( "!!!list(): ServiceUnreachable" ) + INFOS( "!!!list(): ServiceUnreachable" ) throw ServiceUnreachable(); } @@ -777,28 +777,28 @@ void SALOME_NamingService::Destroy_Name(const char* Path) { CosNaming::Name n = ex.rest_of_name; if (ex.why == CosNaming::NamingContext::missing_node) - MESSAGE( "Destroy_Name() : " << (char *) n[0].id + INFOS( "Destroy_Name() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") not found" ) if (ex.why == CosNaming::NamingContext::not_context) - MESSAGE( "Destroy_Name() : " << (char *) n[0].id + INFOS( "Destroy_Name() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not a context" ) if (ex.why == CosNaming::NamingContext::not_object) - MESSAGE( "Destroy_Name() : " << (char *) n[0].id + INFOS( "Destroy_Name() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not an object" ) } catch (CosNaming::NamingContext::InvalidName &) { - MESSAGE( "!!!Destroy_Name() : CosNaming::NamingContext::InvalidName" ) + INFOS( "!!!Destroy_Name() : CosNaming::NamingContext::InvalidName" ) } catch (CosNaming::NamingContext::CannotProceed &) { - MESSAGE( "!!!Destroy_Name(): CosNaming::NamingContext::CannotProceed" ) + INFOS( "!!!Destroy_Name(): CosNaming::NamingContext::CannotProceed" ) } catch(CORBA::COMM_FAILURE&) { - MESSAGE( "!!!Destroy_Name() : CORBA::COMM_FAILURE : unable to contact" + INFOS( "!!!Destroy_Name() : CORBA::COMM_FAILURE : unable to contact" << " the naming service") throw ServiceUnreachable(); } @@ -821,28 +821,28 @@ void SALOME_NamingService::Destroy_Name(const char* Path) { CosNaming::Name n = ex.rest_of_name; if (ex.why == CosNaming::NamingContext::missing_node) - MESSAGE( "Destroy_Name() : " << (char *) n[0].id + INFOS( "Destroy_Name() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") not found" ) if (ex.why == CosNaming::NamingContext::not_context) - MESSAGE( "Destroy_Name() : " << (char *) n[0].id + INFOS( "Destroy_Name() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not a context" ) if (ex.why == CosNaming::NamingContext::not_object) - MESSAGE( "Destroy_Name() : " << (char *) n[0].id + INFOS( "Destroy_Name() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not an object" ) } catch(CosNaming::NamingContext::CannotProceed&) { - MESSAGE( "!!!Destroy_Name() : CosNaming::NamingContext::CannotProceed") + INFOS( "!!!Destroy_Name() : CosNaming::NamingContext::CannotProceed") } catch(CosNaming::NamingContext::InvalidName&) { - MESSAGE( "!!!Destroy_Name() : CosNaming::NamingContext::InvalidName") + INFOS( "!!!Destroy_Name() : CosNaming::NamingContext::InvalidName") } catch(CORBA::COMM_FAILURE&) { - MESSAGE( "!!!Destroy_Name() :CORBA::COMM_FAILURE : unable to contact" + INFOS( "!!!Destroy_Name() :CORBA::COMM_FAILURE : unable to contact" << " the naming service") throw ServiceUnreachable(); } @@ -900,28 +900,28 @@ void SALOME_NamingService::Destroy_Directory(const char* Path) { CosNaming::Name n = ex.rest_of_name; if (ex.why == CosNaming::NamingContext::missing_node) - MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + INFOS( "Destroy_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") not found") if (ex.why == CosNaming::NamingContext::not_context) - MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + INFOS( "Destroy_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not a context" ) if (ex.why == CosNaming::NamingContext::not_object) - MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + INFOS( "Destroy_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not an object" ) } catch (CosNaming::NamingContext::InvalidName &) { - MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName" ) + INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName" ) } catch (CosNaming::NamingContext::CannotProceed &) { - MESSAGE("!!!Destroy_Directory(): CosNaming::NamingContext::CannotProceed" ) + INFOS("!!!Destroy_Directory(): CosNaming::NamingContext::CannotProceed" ) } catch(CORBA::COMM_FAILURE&) { - MESSAGE( "!!!Destroy_Directory() : CORBA::COMM_FAILURE : unable to contact" + INFOS( "!!!Destroy_Directory() : CORBA::COMM_FAILURE : unable to contact" << " the naming service" ) throw ServiceUnreachable(); } @@ -944,28 +944,28 @@ void SALOME_NamingService::Destroy_Directory(const char* Path) { CosNaming::Name n = ex.rest_of_name; if (ex.why == CosNaming::NamingContext::missing_node) - MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + INFOS( "Destroy_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") not found" ) if (ex.why == CosNaming::NamingContext::not_context) - MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + INFOS( "Destroy_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not a context" ) if (ex.why == CosNaming::NamingContext::not_object) - MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + INFOS( "Destroy_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not an object" ) } catch (CosNaming::NamingContext::InvalidName &) { - MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName" ) + INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName" ) } catch (CosNaming::NamingContext::CannotProceed &) { - MESSAGE( "!!!Destroy_Directory(): CosNaming::NamingContext::CannotProceed" ) + INFOS( "!!!Destroy_Directory(): CosNaming::NamingContext::CannotProceed" ) } catch(CORBA::COMM_FAILURE&) { - MESSAGE( "!!!Destroy_Directory() : CORBA::COMM_FAILURE : unable to contact" + INFOS( "!!!Destroy_Directory() : CORBA::COMM_FAILURE : unable to contact" << " the naming service" ) throw ServiceUnreachable(); } @@ -979,12 +979,12 @@ void SALOME_NamingService::Destroy_Directory(const char* Path) } catch(CosNaming::NamingContext::NotEmpty&) { - MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::NoEmpty " + INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::NoEmpty " << Path << " is not empty" ) } catch(CORBA::COMM_FAILURE&) { - MESSAGE( "!!!Destroy_Directory() :CORBA::COMM_FAILURE : " + INFOS( "!!!Destroy_Directory() :CORBA::COMM_FAILURE : " << "unable to contact the naming service") throw ServiceUnreachable(); } @@ -999,28 +999,28 @@ void SALOME_NamingService::Destroy_Directory(const char* Path) { CosNaming::Name n = ex.rest_of_name; if (ex.why == CosNaming::NamingContext::missing_node) - MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + INFOS( "Destroy_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") not found" ) if (ex.why == CosNaming::NamingContext::not_context) - MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + INFOS( "Destroy_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not a context" ) if (ex.why == CosNaming::NamingContext::not_object) - MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + INFOS( "Destroy_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not an object" ) } catch(CosNaming::NamingContext::CannotProceed&) { - MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::CannotProceed") + INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::CannotProceed") } catch(CosNaming::NamingContext::InvalidName&) { - MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName") + INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName") } catch(CORBA::COMM_FAILURE&) { - MESSAGE( "!!!Destroy_Directory() :CORBA::COMM_FAILURE : unable to contact" + INFOS( "!!!Destroy_Directory() :CORBA::COMM_FAILURE : unable to contact" << " the naming service") throw ServiceUnreachable(); } diff --git a/src/NamingService/SALOME_NamingService.hxx b/src/NamingService/SALOME_NamingService.hxx index dde326138..cd4683155 100644 --- a/src/NamingService/SALOME_NamingService.hxx +++ b/src/NamingService/SALOME_NamingService.hxx @@ -30,8 +30,6 @@ #define SALOME_NAMINGSERVICE_H #include "utilities.h" -//#include -//##include #include #include #include diff --git a/src/NamingService/ServiceUnreachable.cxx b/src/NamingService/ServiceUnreachable.cxx index 607c64710..4b03e8d16 100644 --- a/src/NamingService/ServiceUnreachable.cxx +++ b/src/NamingService/ServiceUnreachable.cxx @@ -24,6 +24,7 @@ // File : ServiceUnreachable.cxx // Module : SALOME +using namespace std; #include "ServiceUnreachable.hxx" ServiceUnreachable::ServiceUnreachable( void ): SALOME_Exception( "ServiceUnreachable" ) diff --git a/src/Notification/NOTIFICATION.cxx b/src/Notification/NOTIFICATION.cxx index bbbb92294..1058d706e 100644 --- a/src/Notification/NOTIFICATION.cxx +++ b/src/Notification/NOTIFICATION.cxx @@ -25,11 +25,12 @@ // Author : Laurent DADA / Francis KLOSS // Module : SALOME +using namespace std; #include "NOTIFICATION.hxx" +using namespace std; #include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" -using namespace std; CosNA_EventChannel_ptr NOTIFICATION_channel() { ORB_INIT& init = *SINGLETON_::Instance(); ASSERT(SINGLETON_::IsAlreadyExisting()); diff --git a/src/Notification/NOTIFICATION_Consumer.cxx b/src/Notification/NOTIFICATION_Consumer.cxx index e502a01d0..809d328ec 100644 --- a/src/Notification/NOTIFICATION_Consumer.cxx +++ b/src/Notification/NOTIFICATION_Consumer.cxx @@ -25,8 +25,8 @@ // Author : Laurent DADA / Francis KLOSS // Module : SALOME -#include "NOTIFICATION.hxx" using namespace std; +#include "NOTIFICATION.hxx" NOTIFICATION_Consumer::NOTIFICATION_Consumer(): proxy_supplier(0), diff --git a/src/Notification/NOTIFICATION_Supplier.cxx b/src/Notification/NOTIFICATION_Supplier.cxx index 83d3787a6..b572539a4 100644 --- a/src/Notification/NOTIFICATION_Supplier.cxx +++ b/src/Notification/NOTIFICATION_Supplier.cxx @@ -25,8 +25,8 @@ // Author : Laurent DADA / Francis KLOSS // Module : SALOME -#include "NOTIFICATION.hxx" using namespace std; +#include "NOTIFICATION.hxx" long NOTIFICATION_Supplier::_stamp = 0; diff --git a/src/OBJECT/SALOME_AISObject.cxx b/src/OBJECT/SALOME_AISObject.cxx index 46abdd1d6..2d34b31a2 100644 --- a/src/OBJECT/SALOME_AISObject.cxx +++ b/src/OBJECT/SALOME_AISObject.cxx @@ -26,5 +26,5 @@ // Module : SALOME // $Header$ -#include "SALOME_AISObject.ixx" using namespace std; +#include "SALOME_AISObject.ixx" diff --git a/src/OBJECT/SALOME_AISShape.cxx b/src/OBJECT/SALOME_AISShape.cxx index b439aef2b..117738ffa 100644 --- a/src/OBJECT/SALOME_AISShape.cxx +++ b/src/OBJECT/SALOME_AISShape.cxx @@ -26,8 +26,8 @@ // Module : SALOME // $Header$ -#include "SALOME_AISShape.ixx" using namespace std; +#include "SALOME_AISShape.ixx" SALOME_AISShape::SALOME_AISShape(const TopoDS_Shape& shape): AIS_Shape(shape) { } diff --git a/src/OBJECT/SALOME_Actor.cxx b/src/OBJECT/SALOME_Actor.cxx index db7a30cf2..43a88b901 100644 --- a/src/OBJECT/SALOME_Actor.cxx +++ b/src/OBJECT/SALOME_Actor.cxx @@ -33,9 +33,9 @@ #include "SALOME_Actor.h" #include "SALOME_Transform.h" +#include "SALOME_GeometryFilter.h" #include "SALOME_TransformFilter.h" #include "SALOME_PassThroughFilter.h" -#include "SALOME_GeometryFilter.h" // SALOME Includes #include "utilities.h" @@ -44,48 +44,140 @@ #include #include #include -#include - -// For test -#include -#include "vtkTimerLog.h" using namespace std; +#if defined __GNUC__ + #if __GNUC__ == 2 + #define __GNUC_2__ + #endif +#endif + int SALOME_POINT_SIZE = 3; vtkStandardNewMacro(SALOME_Actor); + +SALOME_Actor::SALOME_Actor(){ + PreviewProperty = NULL; + ispreselected = Standard_False; + myProperty = vtkProperty::New(); + + myRepresentation = 2; + + myIsInfinite = false; + + myStoreMapping = false; + myGeomFilter = SALOME_GeometryFilter::New(); + + myTransformFilter = SALOME_TransformFilter::New(); + + for(int i = 0; i < 6; i++) + myPassFilter.push_back(SALOME_PassThroughFilter::New()); +} + + +SALOME_Actor::~SALOME_Actor(){ + SetPreviewProperty(NULL); + + myGeomFilter->UnRegisterAllOutputs(); + myGeomFilter->Delete(); + + myTransformFilter->UnRegisterAllOutputs(); + myTransformFilter->Delete(); + + for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++){ + if(myPassFilter[i]){ + myPassFilter[i]->UnRegisterAllOutputs(); + myPassFilter[i]->Delete(); + } + } + + myProperty->Delete(); +} + + void SALOME_Actor::AddToRender(vtkRenderer* theRenderer){ theRenderer->AddActor(this); } + void SALOME_Actor::RemoveFromRender(vtkRenderer* theRenderer){ theRenderer->RemoveActor(this); } -vtkPolyData* SALOME_Actor::GetPolyDataInput(){ - return myPassFilter[3]->GetPolyDataOutput(); +void SALOME_Actor::SetTransform(SALOME_Transform* theTransform){ + myTransformFilter->SetTransform(theTransform); } void SALOME_Actor::SetMapper(vtkMapper* theMapper){ if(theMapper){ - myPassFilter[0]->SetInput(theMapper->GetInput()); - myPassFilter[1]->SetInput(myPassFilter[0]->GetPolyDataOutput()); - myTransformFilter->SetInput(myPassFilter[1]->GetPolyDataOutput()); - myPassFilter[2]->SetInput(myTransformFilter->GetOutput()); - myPassFilter[3]->SetInput(myPassFilter[2]->GetPolyDataOutput()); + int anId = 0; +#if defined __GNUC_2__ + myPassFilter[anId]->SetInput(theMapper->GetInput()); +#else + myPassFilter.at(anId)->SetInput(theMapper->GetInput()); +#endif + myGeomFilter->SetStoreMapping(myStoreMapping); +#if defined __GNUC_2__ + myGeomFilter->SetInput(myPassFilter[anId]->GetOutput()); +#else + myGeomFilter->SetInput(myPassFilter.at(anId)->GetOutput()); +#endif + + anId++; + +#if defined __GNUC_2__ + myPassFilter[anId]->SetInput(myGeomFilter->GetOutput()); + myPassFilter[anId+1]->SetInput(myPassFilter[anId]->GetOutput()); +#else + myPassFilter.at(anId)->SetInput(myGeomFilter->GetOutput()); + myPassFilter.at(anId+1)->SetInput(myPassFilter.at(anId)->GetOutput()); +#endif + + anId++; +#if defined __GNUC_2__ + myPassFilter[anId+1]->SetInput(myPassFilter[anId]->GetOutput()); +#else + myPassFilter.at(anId+1)->SetInput(myPassFilter.at(anId)->GetOutput()); +#endif + + anId++; +#if defined __GNUC_2__ + myTransformFilter->SetInput(myPassFilter[anId]->GetPolyDataOutput()); +#else + myTransformFilter->SetInput(myPassFilter.at(anId)->GetPolyDataOutput()); +#endif + + anId++; +#if defined __GNUC_2__ + myPassFilter[anId]->SetInput(myTransformFilter->GetOutput()); + myPassFilter[anId+1]->SetInput(myPassFilter[anId]->GetOutput()); +#else + myPassFilter.at(anId)->SetInput(myTransformFilter->GetOutput()); + myPassFilter.at(anId+1)->SetInput(myPassFilter.at(anId)->GetOutput()); +#endif + + anId++; if(vtkDataSetMapper* aMapper = dynamic_cast(theMapper)) - aMapper->SetInput(myPassFilter[3]->GetPolyDataOutput()); +#if defined __GNUC_2__ + aMapper->SetInput(myPassFilter[anId]->GetOutput()); +#else + aMapper->SetInput(myPassFilter.at(anId)->GetOutput()); +#endif else if(vtkPolyDataMapper* aMapper = dynamic_cast(theMapper)) - aMapper->SetInput(myPassFilter[3]->GetPolyDataOutput()); +#if defined __GNUC_2__ + aMapper->SetInput(myPassFilter[anId]->GetPolyDataOutput()); +#else + aMapper->SetInput(myPassFilter.at(anId)->GetPolyDataOutput()); +#endif } vtkLODActor::SetMapper(theMapper); } -void SALOME_Actor::SetTransform(SALOME_Transform* theTransform){ - myTransformFilter->SetTransform(theTransform); +vtkPolyData* SALOME_Actor::GetPolyDataInput(){ + return myPassFilter.back()->GetPolyDataOutput(); } @@ -93,6 +185,10 @@ unsigned long int SALOME_Actor::GetMTime(){ unsigned long mTime = this->Superclass::GetMTime(); unsigned long time = myTransformFilter->GetMTime(); mTime = ( time > mTime ? time : mTime ); + if(vtkDataSet *aDataSet = myPassFilter[0]->GetInput()){ + time = aDataSet->GetMTime(); + mTime = ( time > mTime ? time : mTime ); + } return mTime; } @@ -109,47 +205,71 @@ void SALOME_Actor::SetRepresentation(int theMode) { GetProperty()->DeepCopy(myProperty); break; default: + break; GetProperty()->SetAmbient(1.0); GetProperty()->SetDiffuse(0.0); GetProperty()->SetSpecular(0.0); } switch(theMode){ case 3 : - myPassFilter[0]->SetInside(true); + myGeomFilter->SetInside(true); GetProperty()->SetRepresentation(1); break; case 0 : GetProperty()->SetPointSize(SALOME_POINT_SIZE); default : GetProperty()->SetRepresentation(theMode); - myPassFilter[0]->SetInside(false); + myGeomFilter->SetInside(false); } myRepresentation = theMode; } + int SALOME_Actor::GetRepresentation(){ return myRepresentation; } - -SALOME_Actor::SALOME_Actor(){ - PreviewProperty = NULL; - ispreselected = Standard_False; - myProperty = vtkProperty::New(); - myRepresentation = 2; - myTransformFilter = SALOME_TransformFilter::New(); - myPassFilter.push_back(SALOME_PassThroughFilter::New()); - myPassFilter.push_back(SALOME_PassThroughFilter::New()); - myPassFilter.push_back(SALOME_PassThroughFilter::New()); - myPassFilter.push_back(SALOME_PassThroughFilter::New()); -} - -SALOME_Actor::~SALOME_Actor(){ - myTransformFilter->Delete(); - SetPreviewProperty(NULL); - for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++) - if(myPassFilter[i] != NULL){ - myPassFilter[i]->UnRegisterAllOutputs(); - myPassFilter[i]->Delete(); +//================================================================================= +// function : GetObjDimension +// purpose : Return object dimension. +// Virtual method shoulb be redifined by derived classes +//================================================================================= +int SALOME_Actor::GetObjDimension( const int theObjId ) +{ + if ( theObjId < 0 ) + return 0; + + std::vector aVtkList = GetVtkId( theObjId ); + int nbVtk = aVtkList.size(); + + if ( nbVtk == 0 ) + return 0; + else if ( nbVtk > 1 ) + return 3; + else // nbVtk = 1 + { + if ( vtkDataSet* aGrid = GetMapper()->GetInput() ) + { + if ( vtkCell* aCell = aGrid->GetCell( aVtkList.front() ) ) + return aCell->GetCellDimension(); } - myProperty->Delete(); + } + return 0; } + + + + + + + + + + + + + + + + + + diff --git a/src/OBJECT/SALOME_Actor.h b/src/OBJECT/SALOME_Actor.h index 492c4e6a8..08a15bd4e 100644 --- a/src/OBJECT/SALOME_Actor.h +++ b/src/OBJECT/SALOME_Actor.h @@ -32,12 +32,11 @@ // SALOME Includes #include "VTKViewer_Common.h" #include "SALOME_InteractiveObject.hxx" -#ifndef _Handle_SALOME_InteractiveObject_HeaderFile -#include "Handle_SALOME_InteractiveObject.hxx" -#endif + #include class SALOME_Transform; +class SALOME_GeometryFilter; class SALOME_TransformFilter; class SALOME_PassThroughFilter; @@ -54,22 +53,6 @@ class SALOME_Actor : public vtkLODActor{ 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 *); - - // 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); - - // 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 Standard_Boolean hasIO() { return !myIO.IsNull(); } virtual Handle_SALOME_InteractiveObject getIO() { return myIO; } virtual void setIO(const Handle(SALOME_InteractiveObject)& io) { myIO = io; } @@ -103,10 +86,16 @@ class SALOME_Actor : public vtkLODActor{ virtual void AddToRender(vtkRenderer* theRenderer); virtual void RemoveFromRender(vtkRenderer* theRenderer); - virtual vtkPolyData* GetPolyDataInput(); + typedef std::vector TVectorId; + virtual int GetObjId(int theVtkID) { return -1;} + virtual TVectorId GetVtkId(int theObjID) { return TVectorId();} + + virtual int GetObjDimension( const int theObjId ); + virtual void SetMapper(vtkMapper* theMapper); - virtual void SetTransform(SALOME_Transform* theTransform); + virtual vtkPolyData* GetPolyDataInput(); + virtual void SetTransform(SALOME_Transform* theTransform); virtual unsigned long int GetMTime(); virtual void SetRepresentation(int theMode); @@ -114,24 +103,27 @@ class SALOME_Actor : public vtkLODActor{ // 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; } + virtual bool IsInfinitive() { return myIsInfinite; } protected: vtkProperty *PreviewProperty; Standard_Boolean ispreselected; - Handle_SALOME_InteractiveObject myIO; + Handle(SALOME_InteractiveObject) myIO; Standard_CString myName; float m_opacity; Standard_Boolean ishighlighted; int myDisplayMode; + bool myIsInfinite; - SALOME_Transform *myTransform; - std::vector myPassFilter; + bool myStoreMapping; + SALOME_GeometryFilter *myGeomFilter; SALOME_TransformFilter *myTransformFilter; - vtkProperty *myProperty; + std::vector myPassFilter; + int myRepresentation; + vtkProperty *myProperty; }; #endif // SALOME_ACTOR_H diff --git a/src/OBJECT/SALOME_InteractiveObject.cxx b/src/OBJECT/SALOME_InteractiveObject.cxx index c361fca8f..36a977af6 100644 --- a/src/OBJECT/SALOME_InteractiveObject.cxx +++ b/src/OBJECT/SALOME_InteractiveObject.cxx @@ -26,13 +26,13 @@ // Module : SALOME // $Header$ +using namespace std; /*! \class SALOME_InteractiveObject SALOME_InteractiveObject.hxx \brief ... */ #include "SALOME_InteractiveObject.ixx" -using namespace std; SALOME_InteractiveObject::SALOME_InteractiveObject() { diff --git a/src/OCCViewer/OCCViewer.cxx b/src/OCCViewer/OCCViewer.cxx index 70a92624c..d98bb2b1f 100644 --- a/src/OCCViewer/OCCViewer.cxx +++ b/src/OCCViewer/OCCViewer.cxx @@ -26,9 +26,9 @@ // Module : SALOME // $Header$ +using namespace std; #include "OCCViewer.h" #include "OCCViewer_ViewFrame.h" -using namespace std; QAD_ViewFrame* OCCViewer::createView(QAD_RightFrame* parent) { diff --git a/src/OCCViewer/OCCViewer_AISSelector.cxx b/src/OCCViewer/OCCViewer_AISSelector.cxx index 0b95ac18d..6310f51c6 100644 --- a/src/OCCViewer/OCCViewer_AISSelector.cxx +++ b/src/OCCViewer/OCCViewer_AISSelector.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; /*! \class OCCViewer_AISSelector OCCViewer_AISSelector.h \brief Selector for AIS interactive context. @@ -34,7 +35,6 @@ */ #include "OCCViewer_AISSelector.h" -using namespace std; /*! Constructor diff --git a/src/OCCViewer/OCCViewer_Selector.cxx b/src/OCCViewer/OCCViewer_Selector.cxx index 41df5163a..e037b6b35 100644 --- a/src/OCCViewer/OCCViewer_Selector.cxx +++ b/src/OCCViewer/OCCViewer_Selector.cxx @@ -26,13 +26,13 @@ // Module : SALOME // $Header$ +using namespace std; /*! \class OCCViewer_Selector OCCViewer_Selector.h \brief Base class for object selection in Open CASCADE Viewer. */ #include "OCCViewer_Selector.h" -using namespace std; /*! Constructor diff --git a/src/OCCViewer/OCCViewer_VService.cxx b/src/OCCViewer/OCCViewer_VService.cxx index eca0fbbb8..e0ed072a6 100644 --- a/src/OCCViewer/OCCViewer_VService.cxx +++ b/src/OCCViewer/OCCViewer_VService.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "OCCViewer_VService.h" // Open CASCADE Includes @@ -50,7 +51,6 @@ #include #include #endif -using namespace std; // For 2d #define LOPTIM diff --git a/src/OCCViewer/OCCViewer_ViewFrame.cxx b/src/OCCViewer/OCCViewer_ViewFrame.cxx index 2da9e1475..2ddc4325f 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.cxx +++ b/src/OCCViewer/OCCViewer_ViewFrame.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "OCCViewer_ViewFrame.h" #include "OCCViewer_Viewer3d.h" #include "OCCViewer_ViewPort.h" @@ -51,7 +52,6 @@ #include #include #include -using namespace std; /*! Constructor diff --git a/src/OCCViewer/OCCViewer_ViewFrame.h b/src/OCCViewer/OCCViewer_ViewFrame.h index 61125300f..46bdb4af7 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.h +++ b/src/OCCViewer/OCCViewer_ViewFrame.h @@ -31,6 +31,7 @@ #include "OCCViewer_ViewPort.h" #include "QAD_ViewFrame.h" +#include "SALOME_Selection.h" class OCCViewer_Viewer3d; class QAD_EXPORT OCCViewer_ViewFrame : public QAD_ViewFrame @@ -64,7 +65,7 @@ class QAD_EXPORT OCCViewer_ViewFrame : public QAD_ViewFrame void setCursor( const QCursor& ); QCursor cursor() const; - void SetSelectionMode( int mode ) {}; + void SetSelectionMode( Selection_Mode mode ) {}; /* popup management */ void setPopupServer( QAD_Application* ); diff --git a/src/OCCViewer/OCCViewer_ViewPort.cxx b/src/OCCViewer/OCCViewer_ViewPort.cxx index 69b061812..1d6d410ba 100644 --- a/src/OCCViewer/OCCViewer_ViewPort.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; #include #if !defined WNT @@ -51,7 +52,6 @@ #include #include -using namespace std; /* XPM */ const char* imageZoomCursor[] = { diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx index 6a5d747a8..1782f8785 100644 --- a/src/OCCViewer/OCCViewer_ViewPort3d.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort3d.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "OCCViewer_ViewPort3d.h" #include "QAD.h" @@ -45,7 +46,6 @@ #if !defined WNT #include #endif -using namespace std; /*! Constructor @@ -295,10 +295,11 @@ void OCCViewer_ViewPort3d::setBackgroundColor( const QColor& color) myActiveView->SetBackgroundColor( Quantity_TOC_RGB, color.red()/255., color.green()/255., color.blue()/255.); + /* VSR : PAL5420 --------------------------------------------------- QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorRed", color.red() ); QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorGreen", color.green() ); QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorBlue", color.blue() ); - + VSR : PAL5420 --------------------------------------------------- */ myActiveView->Update(); } } diff --git a/src/OCCViewer/OCCViewer_Viewer3d.cxx b/src/OCCViewer/OCCViewer_Viewer3d.cxx index ffe52f775..8d4a1331a 100644 --- a/src/OCCViewer/OCCViewer_Viewer3d.cxx +++ b/src/OCCViewer/OCCViewer_Viewer3d.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; /*! \class OCCViewer_Viewer3d OCCViewer_Viewer3d.h \brief Open CASCADE Viewer 3D with viewport 3D and selection. @@ -55,7 +56,6 @@ #include #include #include -using namespace std; /*! Constructor diff --git a/src/PatchQt/qsplitterP.cxx b/src/PatchQt/qsplitterP.cxx index f44990ee3..4b8268af9 100644 --- a/src/PatchQt/qsplitterP.cxx +++ b/src/PatchQt/qsplitterP.cxx @@ -24,6 +24,7 @@ // File : qsplitterP.cxx // Module : SALOME +using namespace std; /**************************************************************************** ** $Id$ ** @@ -79,7 +80,6 @@ #include #include //sendPostedEvents -using namespace std; #define SPLITTER_ICON_WIDTH 10 #define SPLITTER_ICON_HEIGHT 12 diff --git a/src/PatchQt/qworkspaceP.cxx b/src/PatchQt/qworkspaceP.cxx index 483149bb6..0d4d618f7 100644 --- a/src/PatchQt/qworkspaceP.cxx +++ b/src/PatchQt/qworkspaceP.cxx @@ -9,6 +9,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "qworkspaceP.h" #include @@ -40,7 +41,6 @@ #include #include -using namespace std; #define BUTTON_WIDTH 16 #define BUTTON_HEIGHT 14 diff --git a/src/Plot2d/Plot2d_Curve.cxx b/src/Plot2d/Plot2d_Curve.cxx index e32f477e0..8d15c56ae 100644 --- a/src/Plot2d/Plot2d_Curve.cxx +++ b/src/Plot2d/Plot2d_Curve.cxx @@ -7,9 +7,9 @@ // Module : SALOME // $Header$ +using namespace std; #include "Plot2d_Curve.h" #include "utilities.h" -using namespace std; /*! Constructor diff --git a/src/Plot2d/Plot2d_CurveContainer.cxx b/src/Plot2d/Plot2d_CurveContainer.cxx index f9021db1e..f55104645 100644 --- a/src/Plot2d/Plot2d_CurveContainer.cxx +++ b/src/Plot2d/Plot2d_CurveContainer.cxx @@ -7,8 +7,8 @@ // Module : SALOME // $Header$ -#include "Plot2d_CurveContainer.h" using namespace std; +#include "Plot2d_CurveContainer.h" /*! Constructor diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index b5d094b9f..a2a03544d 100644 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -233,6 +234,13 @@ void Plot2d_ViewFrame::createActions() fitDataAction->setStatusTip ( tr( "PRP_PLOT2D_FITDATA" ) ); myActions.insert( FitDataId, fitDataAction ); connect( fitDataAction, SIGNAL( activated() ), this, SLOT( onFitData() ) ); + + // Change background + QActionP* changeBGAction = new QActionP ( tr( "TOT_PLOT2D_CHANGE_BACKGROUND"), + tr( "MEN_PLOT2D_CHANGE_BACKGROUND" ), 0, this ); + fitDataAction->setStatusTip ( tr( "PRP_PLOT2D_CHANGE_BACKGROUND" ) ); + myActions.insert( ChangeBackgroundId, changeBGAction ); + connect( changeBGAction, SIGNAL( activated() ), this, SLOT( onChangeBackground() ) ); } /*! Gets window's central widget @@ -274,6 +282,9 @@ void Plot2d_ViewFrame::onCreatePopup() // settings myPopup->insertSeparator(); myActions[ SettingsId ]->addTo( myPopup ); + // Change background + myPopup->insertSeparator(); + myActions[ ChangeBackgroundId ]->addTo( myPopup ); } } /*! @@ -523,11 +534,59 @@ void Plot2d_ViewFrame::writePreferences() */ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt ) { - QString info; - info.sprintf( "X : %g\tY : %g", - myPlot->invTransform( QwtPlot::xBottom, pnt.x() ), - myPlot->invTransform( QwtPlot::yLeft, pnt.y() ) ); - info = tr( "INF_COORDINATES" ) + " : " + info; + bool xFound = false, yFound = false; + double xCoord, yCoord; + const QwtScaleDiv* aXscale = myPlot->axisScale( QwtPlot::xBottom ); + for ( int i = 0; i < aXscale->majCnt(); i++ ) { + double majXmark = aXscale->majMark( i ); + int xmark = myPlot->transform( QwtPlot::xBottom, majXmark ); + if ( xmark-2 == pnt.x() ) { + xCoord = majXmark; + xFound = true; + MESSAGE("Plot2d_ViewFrame::getInfo : close maj X mark("<minCnt(); i++ ) { + double minXmark = aXscale->minMark( i ); + int xmark = myPlot->transform( QwtPlot::xBottom, minXmark ); + if ( xmark-2 == pnt.x() ) { + xCoord = minXmark; + xFound = true; + MESSAGE("Plot2d_ViewFrame::getInfo : close min X mark("<axisScale( QwtPlot::yLeft ); + for ( int i = 0; i < aYscale->majCnt(); i++ ) { + double majYmark = aYscale->majMark( i ); + int ymark = myPlot->transform( QwtPlot::yLeft, majYmark ); + if ( ymark-2 == pnt.y() ) { + yCoord = majYmark; + yFound = true; + break; + } + } + if ( !yFound ) { + for ( int i = 0; i < aYscale->minCnt(); i++ ) { + double minYmark = aYscale->minMark( i ); + int ymark = myPlot->transform( QwtPlot::yLeft, minYmark ); + if ( ymark-2 == pnt.y() ) { + yCoord = minYmark; + yFound = true; + break; + } + } + } + QString strX = QString::number( xFound ? xCoord : myPlot->invTransform( QwtPlot::xBottom, pnt.x() ) ).stripWhiteSpace(); + if ( strX == "-0" ) + strX = "0"; + QString strY = QString::number( yFound ? yCoord : myPlot->invTransform( QwtPlot::yLeft, pnt.y() ) ).stripWhiteSpace(); + if ( strY == "-0" ) + strY = "0"; + QString info = tr("INF_COORDINATES").arg( strX ).arg( strY ); return info; } /*! @@ -1082,6 +1141,16 @@ void Plot2d_ViewFrame::onFitData() } delete dlg; } +/*! + Change background color +*/ +void Plot2d_ViewFrame::onChangeBackground() +{ + QColor selColor = QColorDialog::getColor ( backgroundColor(), this ); + if ( selColor.isValid() ) { + setBackgroundColor( selColor ); + } +} /*! Sets curve type */ diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index ee92ee7ba..40e41b357 100644 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -15,6 +15,7 @@ #include "QAD_Action.h" #include "Plot2d_Curve.h" #include "Plot2d_CurveContainer.h" +#include "SALOME_Selection.h" #include #include #include @@ -34,7 +35,7 @@ class QAD_EXPORT Plot2d_ViewFrame : public QAD_ViewFrame, public QAD_PopupClient enum { NoOpId, FitAllId, FitAreaId, ZoomId, PanId, DumpId, ModeXLinearId, ModeXLogarithmicId, ModeYLinearId, ModeYLogarithmicId, - LegendId, CurvePointsId, CurveLinesId, CurveSplinesId, SettingsId, FitDataId }; + LegendId, CurvePointsId, CurveLinesId, CurveSplinesId, SettingsId, FitDataId, ChangeBackgroundId }; public: /* Construction/destruction */ Plot2d_ViewFrame( QWidget* parent, const QString& title = "" ); @@ -44,7 +45,7 @@ public: /* inherited */ ViewType getTypeView() const { return VIEW_PLOT2D; } QWidget* getViewWidget(); - void SetSelectionMode( int mode ) {} + void SetSelectionMode( Selection_Mode mode ) {} void onAdjustTrihedron( ) {} /* popup management */ @@ -145,6 +146,7 @@ public slots: void onCurves(); void onSettings(); void onFitData(); + void onChangeBackground(); protected slots: void onLegendClicked( long key ); diff --git a/src/Registry/Makefile.in b/src/Registry/Makefile.in index 5ff83cb1d..2219e4235 100644 --- a/src/Registry/Makefile.in +++ b/src/Registry/Makefile.in @@ -37,17 +37,20 @@ VPATH=.:@srcdir@:@top_srcdir@/idl EXPORT_PYSCRIPTS = EXPORT_HEADERS = \ - RegistryConnexion.hxx + RegistryConnexion.hxx \ + RegistryService.hxx # Libraries targets LIB = libRegistry.la -LIB_SRC = RegistryConnexion.cxx +LIB_SRC = \ + RegistryConnexion.cxx \ + RegistryService.cxx LIB_CLIENT_IDL = SALOME_Registry.idl # Executables targets BIN = SALOME_Registry_Server -BIN_SRC = RegistryService.cxx +BIN_SRC = BIN_SERVER_IDL = SALOME_Registry.idl LDFLAGS+= -lSalomeNS -lOpUtil -lSALOMELocalTrace diff --git a/src/Registry/RegistryConnexion.cxx b/src/Registry/RegistryConnexion.cxx index 018ea5fbf..e11f5a221 100644 --- a/src/Registry/RegistryConnexion.cxx +++ b/src/Registry/RegistryConnexion.cxx @@ -26,6 +26,8 @@ // Module : SALOME // $Header$ +using namespace std; +using namespace std; # include "Utils_ORB_INIT.hxx" # include "RegistryConnexion.hxx" # include "SALOME_NamingService.hxx" diff --git a/src/Registry/RegistryService.cxx b/src/Registry/RegistryService.cxx index 018d9cb87..94dfa3034 100644 --- a/src/Registry/RegistryService.cxx +++ b/src/Registry/RegistryService.cxx @@ -26,10 +26,11 @@ // Module : SALOME // $Header$ +using namespace std; +using namespace std; # include "RegistryService.hxx" # include "OpUtil.hxx" # include "utilities.h" -using namespace std; extern "C" { diff --git a/src/Registry/RegistryService.hxx b/src/Registry/RegistryService.hxx index 63f7d57e4..3c26d92b7 100644 --- a/src/Registry/RegistryService.hxx +++ b/src/Registry/RegistryService.hxx @@ -34,6 +34,7 @@ # include +using namespace std; class RegistryService : public POA_Registry::Components //, public PortableServer::RefCountServantBase { @@ -87,10 +88,10 @@ protected : const char *_SessionName ; int _Compteur ; - std::map _reg ; - std::map _fin ; + map _reg ; + map _fin ; - Registry::AllInfos* makeseq(std::map &mymap ); + Registry::AllInfos* makeseq(map &mymap ); } ; diff --git a/src/Registry/SALOME_Registry_Server.cxx b/src/Registry/SALOME_Registry_Server.cxx index 9feaf1567..3e5a5b636 100644 --- a/src/Registry/SALOME_Registry_Server.cxx +++ b/src/Registry/SALOME_Registry_Server.cxx @@ -26,9 +26,9 @@ // Module : SALOME // $Header$ -# include -# include -# include +#include +#include +#include extern "C" { @@ -49,11 +49,6 @@ extern "C" #endif using namespace std; -//#define CHECKTIME -#ifdef CHECKTIME -#include -#endif - int main( int argc , char **argv ) { BEGIN_OF( argv[0] ) diff --git a/src/RegistryDisplay/HelpWindow.cxx b/src/RegistryDisplay/HelpWindow.cxx index 40889fe28..3d8b682cc 100644 --- a/src/RegistryDisplay/HelpWindow.cxx +++ b/src/RegistryDisplay/HelpWindow.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; # include "HelpWindow.hxx" # include "utilities.h" @@ -33,7 +34,6 @@ # include # include # include -using namespace std; HelpWindow::HelpWindow(QWidget* parent, const char* name ) : QMainWindow( parent, name, WType_TopLevel | WDestructiveClose ) diff --git a/src/RegistryDisplay/RegWidget.cxx b/src/RegistryDisplay/RegWidget.cxx index 22797cc2a..c7a16048f 100644 --- a/src/RegistryDisplay/RegWidget.cxx +++ b/src/RegistryDisplay/RegWidget.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; # include # include # include @@ -48,7 +49,6 @@ # include "RegWidget.hxx" # include "HelpWindow.hxx" # include "IntervalWindow.hxx" -using namespace std; typedef int PIXELS; RegWidget* RegWidget::myRegWidgetPtr = 0; @@ -621,8 +621,8 @@ QString findFile( QString filename ) return fileInfo.filePath(); } } - // Try ${SALOME_ROOT_DIR}/share/salome/resources directory - cenv = getenv( "SALOME_ROOT_DIR" ); + // Try ${KERNEL_ROOT_DIR}/share/salome/resources directory + cenv = getenv( "KERNEL_ROOT_DIR" ); if ( cenv ) { dir.sprintf( "%s", cenv ); if ( !dir.isEmpty() ) { diff --git a/src/RegistryDisplay/RegWidgetFactory.cxx b/src/RegistryDisplay/RegWidgetFactory.cxx index ffef14c4d..341e60d54 100644 --- a/src/RegistryDisplay/RegWidgetFactory.cxx +++ b/src/RegistryDisplay/RegWidgetFactory.cxx @@ -26,9 +26,9 @@ // Module : SALOME // $Header$ +using namespace std; # include "RegWidget.hxx" # include "utilities.h" -using namespace std; extern "C" { diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Client.cxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Client.cxx index 05f13bc10..c6a524cde 100644 --- a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Client.cxx +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Client.cxx @@ -24,15 +24,15 @@ // File : SALOME_RessourcesCatalog_Client.cxx // Module : SALOME +using namespace std; /* $Header$ */ -#include +#include #include "SALOME_NamingService.hxx" #include #include CORBA_SERVER_HEADER(SALOME_RessourcesCatalog) #include #include "utilities.h" -using namespace std; int main(int argc,char **argv) { diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Handler.cxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Handler.cxx index 67cd843d3..e82e54a23 100755 --- a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Handler.cxx +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Handler.cxx @@ -26,9 +26,9 @@ // Module : SALOME //$Header$ +using namespace std; #define WRITE_RESSOURCES_TYPE #include "SALOME_RessourcesCatalog_Handler.hxx" -using namespace std; //---------------------------------------------------------------------- //Function : SALOME_RessourcesCatalog_Handler diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx index e9a16146c..4275a4924 100644 --- a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx @@ -87,7 +87,7 @@ int main(int argc,char **argv) } catch( CORBA::COMM_FAILURE& ) { - MESSAGE( "Ressources Catalog: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); + INFOS( "Ressources Catalog: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); } if(!CORBA::is_nil(inc)) { @@ -103,11 +103,11 @@ int main(int argc,char **argv) } catch(CosNaming::NamingContext::NotFound) { - MESSAGE( "Ressources Catalog: Logger Server wasn't found" ); + INFOS( "Ressources Catalog: Logger Server wasn't found" ); } catch(...) { - MESSAGE( "Ressources Catalog: Unknown exception" ); + INFOS( "Ressources Catalog: Unknown exception" ); } if (!CORBA::is_nil(object)) { diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_impl.cxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_impl.cxx index 0557289d8..cc819e495 100644 --- a/src/RessourcesCatalog/SALOME_RessourcesCatalog_impl.cxx +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_impl.cxx @@ -25,9 +25,12 @@ // Author : Estelle Deville // Module : SALOME +using namespace std; #include "SALOME_RessourcesCatalog_impl.hxx" #include -using namespace std; + +#include "Utils_ExceptHandlers.hxx" +UNEXPECT_CATCH(RC_NotFound, SALOME_RessourcesCatalog::NotFound); //---------------------------------------------------------------------- // Function : SALOME_RessourcesCatalogImpl @@ -95,6 +98,7 @@ SALOME_RessourcesCatalog::ListOfContainerType* SALOME_RessourcesCatalogImpl::GetContainerTypeList(const char* computer) throw(SALOME_RessourcesCatalog::NotFound) { + Unexpect aCatch(RC_NotFound); MESSAGE("Begin of GetContainerTypeList"); SALOME_RessourcesCatalog::ListOfContainerType_var _list = new SALOME_RessourcesCatalog::ListOfContainerType; @@ -149,6 +153,7 @@ SALOME_RessourcesCatalogImpl::GetComputerInfo(const char* computer) throw(SALOME_RessourcesCatalog::NotFound) { MESSAGE("Begin of GetComputerInfo"); + Unexpect aCatch(RC_NotFound); SALOME_RessourcesCatalog::computer_info_var _computer_info = new SALOME_RessourcesCatalog::computer_info; @@ -253,7 +258,7 @@ SALOME_RessourcesCatalogImpl::_parseArguments(int argc, char **argv, if (strcmp(argv[ind],"-help") == 0) { - INFOS( "Usage: " << argv[0] << " -common 'path to ressources catalog' -ORBInitRef NameService=corbaname::localhost"); + MESSAGE( "Usage: " << argv[0] << " -common 'path to ressources catalog' -ORBInitRef NameService=corbaname::localhost"); _return_value = false ; } if (strcmp(argv[ind],"-common") == 0) diff --git a/src/SALOMEDS/Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx b/src/SALOMEDS/Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx index 911d848a2..5da8aeccb 100644 --- a/src/SALOMEDS/Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx +++ b/src/SALOMEDS/Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx @@ -24,7 +24,7 @@ // File : Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef _Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile #define _Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile diff --git a/src/SALOMEDS/Handle_SALOMEDS_LocalIDAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_LocalIDAttribute.hxx index dd2c6f14a..dbb2c1c0c 100644 --- a/src/SALOMEDS/Handle_SALOMEDS_LocalIDAttribute.hxx +++ b/src/SALOMEDS/Handle_SALOMEDS_LocalIDAttribute.hxx @@ -24,7 +24,7 @@ // File : Handle_SALOMEDS_LocalIDAttribute.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef _Handle_SALOMEDS_LocalIDAttribute_HeaderFile #define _Handle_SALOMEDS_LocalIDAttribute_HeaderFile diff --git a/src/SALOMEDS/Handle_SALOMEDS_TargetAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_TargetAttribute.hxx index 0c6eee09e..bab384766 100644 --- a/src/SALOMEDS/Handle_SALOMEDS_TargetAttribute.hxx +++ b/src/SALOMEDS/Handle_SALOMEDS_TargetAttribute.hxx @@ -24,7 +24,7 @@ // File : Handle_SALOMEDS_TargetAttribute.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef _Handle_SALOMEDS_TargetAttribute_HeaderFile #define _Handle_SALOMEDS_TargetAttribute_HeaderFile diff --git a/src/SALOMEDS/Makefile.in b/src/SALOMEDS/Makefile.in index 84cb2949f..7c2273ccd 100644 --- a/src/SALOMEDS/Makefile.in +++ b/src/SALOMEDS/Makefile.in @@ -33,6 +33,10 @@ VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_srcdir)/idl @COMMENCE@ +EXPORT_HEADERS= \ + SALOMEDS_StudyManager_i.hxx \ + SALOMEDS_OCAFApplication.hxx \ + Handle_SALOMEDS_OCAFApplication.hxx # Libraries targets diff --git a/src/SALOMEDS/SALOMEDS_AttributeComment_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeComment_i.cxx index 72babf8e1..3bf3299f2 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeComment_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeComment_i.cxx @@ -26,11 +26,11 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributeComment_i.hxx" #include #include "SALOMEDS_SObject_i.hxx" -using namespace std; char* SALOMEDS_AttributeComment_i::Value() { @@ -45,3 +45,11 @@ void SALOMEDS_AttributeComment_i::SetValue(const char* value) CORBA::String_var Str = CORBA::string_dup(value); Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str)); } + +char* SALOMEDS_AttributeComment_i::Store() { + return Value(); +} + +void SALOMEDS_AttributeComment_i::Restore(const char* value) { + SetValue(value); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeComment_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeComment_i.hxx index 9ebeb45fd..0171acb75 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeComment_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeComment_i.hxx @@ -48,7 +48,10 @@ public: char* Value(); void SetValue(const char* value); - + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx index 8fa4ea145..f21ae9b3b 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx @@ -26,9 +26,9 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributeDrawable_i.hxx" #include "SALOMEDS_SObject_i.hxx" -using namespace std; CORBA::Boolean SALOMEDS_AttributeDrawable_i::IsDrawable() { return (Handle(SALOMEDS_DrawableAttribute)::DownCast(_myAttr)->Get() == 1); @@ -40,3 +40,11 @@ void SALOMEDS_AttributeDrawable_i::SetDrawable(CORBA::Boolean value) { if (value != 0) val = 1; Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val); } + +char* SALOMEDS_AttributeDrawable_i::Store() { + return strdup(IsDrawable()?"1":"0"); +} + +void SALOMEDS_AttributeDrawable_i::Restore(const char* value) { + SetDrawable(value[0] == '1'); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.hxx index 80c71284f..6f41440e5 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.hxx @@ -48,6 +48,10 @@ public: ~SALOMEDS_AttributeDrawable_i() {}; CORBA::Boolean IsDrawable(); void SetDrawable(CORBA::Boolean value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx index 6fe877c50..98a0720cf 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx @@ -26,9 +26,9 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributeExpandable_i.hxx" #include "SALOMEDS_SObject_i.hxx" -using namespace std; CORBA::Boolean SALOMEDS_AttributeExpandable_i::IsExpandable() { return (Handle(SALOMEDS_ExpandableAttribute)::DownCast(_myAttr)->Get() == 1); @@ -39,3 +39,11 @@ void SALOMEDS_AttributeExpandable_i::SetExpandable(CORBA::Boolean value) { if (value != 0) val = 1; Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val); } + +char* SALOMEDS_AttributeExpandable_i::Store() { + return strdup(IsExpandable()?"1":"0"); +} + +void SALOMEDS_AttributeExpandable_i::Restore(const char* value) { + SetExpandable(value[0] == '1'); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.hxx index 4ac190956..0c18dd2eb 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.hxx @@ -48,6 +48,10 @@ public: ~SALOMEDS_AttributeExpandable_i() {}; CORBA::Boolean IsExpandable(); void SetExpandable(CORBA::Boolean value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeExternalFileDef_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeExternalFileDef_i.cxx index a6c424c17..94e2a313d 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeExternalFileDef_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeExternalFileDef_i.cxx @@ -26,11 +26,11 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributeExternalFileDef_i.hxx" #include #include "SALOMEDS_SObject_i.hxx" -using namespace std; char* SALOMEDS_AttributeExternalFileDef_i::Value() { diff --git a/src/SALOMEDS/SALOMEDS_AttributeFileType_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeFileType_i.cxx index 9411fbb67..d40a53f43 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeFileType_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeFileType_i.cxx @@ -26,11 +26,11 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributeFileType_i.hxx" #include #include "SALOMEDS_SObject_i.hxx" -using namespace std; char* SALOMEDS_AttributeFileType_i::Value() { diff --git a/src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx index 6cf5e3374..b1ec78bf0 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx @@ -26,13 +26,13 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributeIOR_i.hxx" #include #include "SALOMEDS_SObject_i.hxx" #include "SALOMEDS_Study_i.hxx" -using namespace std; char* SALOMEDS_AttributeIOR_i::Value() { diff --git a/src/SALOMEDS/SALOMEDS_AttributeInteger_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeInteger_i.cxx index 07920efb6..8d3484709 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeInteger_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeInteger_i.cxx @@ -26,9 +26,9 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributeInteger_i.hxx" #include "SALOMEDS_SObject_i.hxx" -using namespace std; CORBA::Long SALOMEDS_AttributeInteger_i::Value() { @@ -39,3 +39,15 @@ void SALOMEDS_AttributeInteger_i::SetValue(CORBA::Long value) { CheckLocked(); Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(value); } + +char* SALOMEDS_AttributeInteger_i::Store() { + char* IntVal = new char[25]; + sprintf(IntVal, "%d", Value()); + return IntVal; +} + +void SALOMEDS_AttributeInteger_i::Restore(const char* value) { + char *err = NULL; + CORBA::Long l = atol(value); + SetValue(l); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeInteger_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeInteger_i.hxx index 8e2a12f84..be877a735 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeInteger_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeInteger_i.hxx @@ -49,6 +49,10 @@ public: CORBA::Long Value(); void SetValue(CORBA::Long value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.cxx index 3c1b124fd..d55ea0d99 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.cxx @@ -24,11 +24,11 @@ // File : SALOMEDS_AttributeLocalID_i.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ +using namespace std; #include "SALOMEDS_AttributeLocalID_i.hxx" #include "SALOMEDS_SObject_i.hxx" -using namespace std; CORBA::Long SALOMEDS_AttributeLocalID_i::Value() { return Handle(SALOMEDS_LocalIDAttribute)::DownCast(_myAttr)->Get(); @@ -38,3 +38,15 @@ void SALOMEDS_AttributeLocalID_i::SetValue(CORBA::Long value) { CheckLocked(); Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(value); } + +char* SALOMEDS_AttributeLocalID_i::Store() { + char* IntVal = new char[25]; + sprintf(IntVal, "%d", Value()); + return IntVal; +} + +void SALOMEDS_AttributeLocalID_i::Restore(const char* value) { + char *err = NULL; + CORBA::Long l = atol(value); + SetValue(l); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.hxx index 6340696db..7b0d5c148 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.hxx @@ -48,6 +48,10 @@ public: ~SALOMEDS_AttributeLocalID_i() {}; CORBA::Long Value(); void SetValue(CORBA::Long value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeName_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeName_i.cxx index 975e6439d..e9ce976d4 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeName_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeName_i.cxx @@ -26,10 +26,10 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributeName_i.hxx" #include #include "SALOMEDS_SObject_i.hxx" -using namespace std; char* SALOMEDS_AttributeName_i::Value() { TCollection_ExtendedString S = Handle(TDataStd_Name)::DownCast(_myAttr)->Get(); @@ -42,3 +42,11 @@ void SALOMEDS_AttributeName_i::SetValue(const char* value) { CORBA::String_var Str = CORBA::string_dup(value); Handle(TDataStd_Name)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str)); } + +char* SALOMEDS_AttributeName_i::Store() { + return Value(); +} + +void SALOMEDS_AttributeName_i::Restore(const char* value) { + SetValue(value); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeName_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeName_i.hxx index c4c46509d..d2a149258 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeName_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeName_i.hxx @@ -49,6 +49,10 @@ public: char* Value(); void SetValue(const char* value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeOpened_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeOpened_i.cxx index fd9c6bfd1..cd4e87f17 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeOpened_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeOpened_i.cxx @@ -26,9 +26,9 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributeOpened_i.hxx" #include "SALOMEDS_SObject_i.hxx" -using namespace std; CORBA::Boolean SALOMEDS_AttributeOpened_i::IsOpened() { return (Handle(SALOMEDS_OpenedAttribute)::DownCast(_myAttr)->Get() == 1); @@ -39,3 +39,11 @@ void SALOMEDS_AttributeOpened_i::SetOpened(CORBA::Boolean value) { if (value != 0) val = 1; Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val); } + +char* SALOMEDS_AttributeOpened_i::Store() { + return strdup(IsOpened()?"1":"0"); +} + +void SALOMEDS_AttributeOpened_i::Restore(const char* value) { + SetOpened(value[0] == '1'); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeOpened_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeOpened_i.hxx index a5b08df3e..ea75a4990 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeOpened_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeOpened_i.hxx @@ -48,6 +48,10 @@ public: ~SALOMEDS_AttributeOpened_i() {}; CORBA::Boolean IsOpened(); void SetOpened(CORBA::Boolean value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.cxx b/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.cxx index 3a867f0ea..c8e72e102 100644 --- a/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.cxx @@ -26,10 +26,10 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributePersistentRef_i.hxx" #include #include "SALOMEDS_SObject_i.hxx" -using namespace std; char* SALOMEDS_AttributePersistentRef_i::Value() { @@ -44,3 +44,11 @@ void SALOMEDS_AttributePersistentRef_i::SetValue(const char* value) CORBA::String_var Str = CORBA::string_dup(value); Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str)); } + +char* SALOMEDS_AttributePersistentRef_i::Store() { + return Value(); +} + +void SALOMEDS_AttributePersistentRef_i::Restore(const char* value) { + SetValue(value); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.hxx b/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.hxx index 0173a5e46..5d986a15e 100644 --- a/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.hxx @@ -24,7 +24,7 @@ // File : SALOMEDS_AttributePersistentRef_i.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef SALOMEDS_AttributePersistentRef_i_HeaderFile #define SALOMEDS_AttributePersistentRef_i_HeaderFile @@ -47,6 +47,9 @@ public: char* Value(); void SetValue(const char* value); + + char* Store(); + void Restore(const char*); }; diff --git a/src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx b/src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx index 1d8498c3f..a34de4967 100644 --- a/src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx @@ -26,10 +26,10 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributePixMap_i.hxx" #include "SALOMEDS_SObject_i.hxx" #include -using namespace std; CORBA::Boolean SALOMEDS_AttributePixMap_i::HasPixMap() { TCollection_ExtendedString S = Handle(SALOMEDS_PixMapAttribute)::DownCast(_myAttr)->Get(); @@ -47,3 +47,11 @@ void SALOMEDS_AttributePixMap_i::SetPixMap(const char* value) { CORBA::String_var Str = CORBA::string_dup(value); Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str)); } + +char* SALOMEDS_AttributePixMap_i::Store() { + return GetPixMap(); +} + +void SALOMEDS_AttributePixMap_i::Restore(const char* value) { + SetPixMap(value); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributePixMap_i.hxx b/src/SALOMEDS/SALOMEDS_AttributePixMap_i.hxx index 3058b356a..16696a4a5 100644 --- a/src/SALOMEDS/SALOMEDS_AttributePixMap_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributePixMap_i.hxx @@ -24,7 +24,7 @@ // File : SALOMEDS_AttributePixMap_i.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef SALOMEDS_AttributePixMap_i_HeaderFile #define SALOMEDS_AttributePixMap_i_HeaderFile @@ -48,6 +48,10 @@ public: CORBA::Boolean HasPixMap(); char* GetPixMap(); void SetPixMap(const char* value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.cxx b/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.cxx index ca3f7d731..a02fa874e 100644 --- a/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.cxx @@ -9,11 +9,11 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributePythonObject_i.hxx" #include #include #include "SALOMEDS_SObject_i.hxx" -using namespace std; void SALOMEDS_AttributePythonObject_i::SetObject(const char* theSequence, CORBA::Boolean IsScript) { CheckLocked(); @@ -30,3 +30,16 @@ char* SALOMEDS_AttributePythonObject_i::GetObject() { CORBA::Boolean SALOMEDS_AttributePythonObject_i::IsScript() { return Handle(SALOMEDS_PythonObjectAttribute)::DownCast(_myAttr)->IsScript(); } + +char* SALOMEDS_AttributePythonObject_i::Store() { + CORBA::String_var aString = GetObject(); + char* aResult = new char[strlen(aString) + 2]; + aResult[0] = IsScript()?'s':'n'; + strcpy(aResult+1, aString); + return aResult; +} + +void SALOMEDS_AttributePythonObject_i::Restore(const char* value) { + char* aString = strdup(value); + SetObject(aString + 1, aString[0]=='s'); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.hxx b/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.hxx index d15d36649..1db4b14ea 100644 --- a/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.hxx @@ -34,6 +34,9 @@ public: virtual char* GetObject(); virtual CORBA::Boolean IsScript(); + virtual char* Store(); + virtual void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeReal_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeReal_i.cxx index 62960aa9c..c87b60486 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeReal_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeReal_i.cxx @@ -26,9 +26,9 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributeReal_i.hxx" #include "SALOMEDS_SObject_i.hxx" -using namespace std; CORBA::Double SALOMEDS_AttributeReal_i::Value() { return Handle(TDataStd_Real)::DownCast(_myAttr)->Get(); @@ -38,3 +38,15 @@ void SALOMEDS_AttributeReal_i::SetValue(CORBA::Double value) { CheckLocked(); Handle(TDataStd_Real)::DownCast(_myAttr)->Set(value); } + +char* SALOMEDS_AttributeReal_i::Store() { + char* RealVal = new char[25]; + sprintf(RealVal, "%f", Value()); + return RealVal; +} + +void SALOMEDS_AttributeReal_i::Restore(const char* value) { + char *err = NULL; + CORBA::Double r = strtod(value, &err); + if (err != value) SetValue(r); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeReal_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeReal_i.hxx index a4399c9f7..42263a161 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeReal_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeReal_i.hxx @@ -24,7 +24,7 @@ // File : SALOMEDS_AttributeReal_i.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef SALOMEDS_AttributeReal_i_HeaderFile #define SALOMEDS_AttributeReal_i_HeaderFile @@ -48,6 +48,10 @@ public: CORBA::Double Value(); void SetValue(CORBA::Double value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.cxx index e208ad6a9..fd9fa7ad2 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.cxx @@ -26,9 +26,9 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributeSelectable_i.hxx" #include "SALOMEDS_SObject_i.hxx" -using namespace std; CORBA::Boolean SALOMEDS_AttributeSelectable_i::IsSelectable() { return (Handle(SALOMEDS_SelectableAttribute)::DownCast(_myAttr)->Get() == 1); @@ -39,3 +39,11 @@ void SALOMEDS_AttributeSelectable_i::SetSelectable(CORBA::Boolean value) { if (value != 0) val = 1; Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val); } + +char* SALOMEDS_AttributeSelectable_i::Store() { + return strdup(IsSelectable()?"1":"0"); +} + +void SALOMEDS_AttributeSelectable_i::Restore(const char* value) { + SetSelectable(value[0] == '1'); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.hxx index b9936d47b..c844f03bf 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.hxx @@ -48,6 +48,10 @@ public: ~SALOMEDS_AttributeSelectable_i() {}; CORBA::Boolean IsSelectable(); void SetSelectable(CORBA::Boolean value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.cxx index cd142de25..703810bc5 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.cxx @@ -26,10 +26,11 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributeSequenceOfInteger_i.hxx" #include "SALOMEDS_SObject_i.hxx" #include -using namespace std; + void SALOMEDS_AttributeSequenceOfInteger_i::Assign(const SALOMEDS::LongSeq& other) { @@ -79,3 +80,30 @@ CORBA::Long SALOMEDS_AttributeSequenceOfInteger_i::Length() { return Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Length(); } + +char* SALOMEDS_AttributeSequenceOfInteger_i::Store() { + Handle(SALOMEDS_SequenceOfIntegerAttribute) CasCadeSeq = Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr); + Standard_Integer aLength = CasCadeSeq->Length(); + char* aResult = new char[aLength * 25]; + aResult[0] = 0; + Standard_Integer aPosition = 0; + for (int i = 1; i <= aLength; i++) { + sprintf(aResult + aPosition , "%d ", CasCadeSeq->Value(i)); + aPosition += strlen(aResult + aPosition); + } + return aResult; +} + +void SALOMEDS_AttributeSequenceOfInteger_i::Restore(const char* value) { + Handle(TColStd_HSequenceOfInteger) CasCadeSeq = new TColStd_HSequenceOfInteger; + + char* aCopy = strdup(value); + char* adr = strtok(aCopy, " "); + while (adr) { + CORBA::Long l = atol(adr); + CasCadeSeq->Append(l); + adr = strtok(NULL, " "); + } + delete(aCopy); + Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Assign(CasCadeSeq); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.hxx index ee0b71eef..06b24a7c5 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.hxx @@ -55,6 +55,10 @@ public: void ChangeValue(CORBA::Long index, CORBA::Long value); CORBA::Long Value(CORBA::Short index); CORBA::Long Length(); + + char* Store(); + void Restore(const char*); + }; #endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.cxx index 6c5c18589..d7f480a16 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.cxx @@ -26,10 +26,10 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributeSequenceOfReal_i.hxx" #include "SALOMEDS_SObject_i.hxx" #include -using namespace std; void SALOMEDS_AttributeSequenceOfReal_i::Assign(const SALOMEDS::DoubleSeq& other) { @@ -79,3 +79,32 @@ CORBA::Long SALOMEDS_AttributeSequenceOfReal_i::Length() { return Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Length(); } + +char* SALOMEDS_AttributeSequenceOfReal_i::Store() { + Handle(SALOMEDS_SequenceOfRealAttribute) CasCadeSeq = Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr); + Standard_Integer aLength = CasCadeSeq->Length(); + char* aResult = new char[aLength * 25]; + aResult[0] = 0; + Standard_Integer aPosition = 0; + for (int i = 1; i <= aLength; i++) { + sprintf(aResult + aPosition , "%f ", CasCadeSeq->Value(i)); + aPosition += strlen(aResult + aPosition); + } + return aResult; +} + +void SALOMEDS_AttributeSequenceOfReal_i::Restore(const char* value) { + Handle(TColStd_HSequenceOfReal) CasCadeSeq = new TColStd_HSequenceOfReal; + + char* aCopy = strdup(value); + char* adr = strtok(aCopy, " "); + char *err = NULL; + while (adr) { + CORBA::Double r = strtod(adr, &err); + if (err == adr) break; + else CasCadeSeq->Append(r); + adr = strtok(NULL, " "); + } + delete(aCopy); + Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Assign(CasCadeSeq); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.hxx index ded1a3584..044fbc460 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.hxx @@ -54,6 +54,9 @@ public: void ChangeValue(CORBA::Long index, CORBA::Double value); CORBA::Double Value(CORBA::Short index); CORBA::Long Length(); + + char* Store(); + void Restore(const char*); }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx index dce1ad372..9b2b8912c 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx @@ -9,11 +9,11 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributeStudyProperties_i.hxx" #include "SALOMEDS_SObject_i.hxx" #include #include -using namespace std; #define CREATION_MODE_NOTDEFINED 0 #define CREATION_MODE_SCRATCH 1 @@ -22,8 +22,7 @@ using namespace std; void SALOMEDS_AttributeStudyProperties_i::SetUserName(const char* theName) { CheckLocked(); Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr); - CORBA::String_var Str = CORBA::string_dup(theName); - aProp->SetFirstName(TCollection_ExtendedString(Str)); + aProp->SetFirstName(TCollection_ExtendedString(strdup(theName))); } char* SALOMEDS_AttributeStudyProperties_i::GetUserName() { @@ -112,7 +111,7 @@ void SALOMEDS_AttributeStudyProperties_i::SetModification(const char* theName, CORBA::Long theYear) { CheckLocked(); Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr); - aProp->SetUserName(CORBA::string_dup(theName)); + aProp->SetUserName(strdup(theName)); aProp->SetModificationDate((int)theMinute, (int)theHour, (int)theDay, (int)theMonth, (int)theYear); } void SALOMEDS_AttributeStudyProperties_i::GetModificationsList(SALOMEDS::StringSeq_out theNames, @@ -153,3 +152,80 @@ void SALOMEDS_AttributeStudyProperties_i::GetModificationsList(SALOMEDS::StringS (*theYears)[a] = aYears->Value(a + 1 + ((theWithCreator)?0:1)); } } + +char* SALOMEDS_AttributeStudyProperties_i::Store() { + Handle(TColStd_HSequenceOfExtendedString) aNames; + Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears; + Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr); + aNames = aProp->GetUserNames(); + aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears); + + int aLength, anIndex; + for(aLength = 0, anIndex = aNames->Length(); anIndex > 0; anIndex--) aLength += aNames->Value(anIndex).Length() + 1; + + char* aProperty = new char[3 + aLength + 12 * aNames->Length()]; + + sprintf(aProperty,"%c%c", strlen(GetCreationMode())?GetCreationMode()[0]:'0', IsLocked()?'l':'u'); + + aLength = aNames->Length(); + int a = 2; + for(anIndex = 1; anIndex <= aLength; anIndex++) { + sprintf(&(aProperty[a]),"%2d%2d%2d%2d%4d%s", + (int)(aMinutes->Value(anIndex)), + (int)(aHours->Value(anIndex)), + (int)(aDays->Value(anIndex)), + (int)(aMonths->Value(anIndex)), + (int)(aYears->Value(anIndex)), + (char*)(TCollection_AsciiString(aNames->Value(anIndex)).ToCString())); + a = strlen(aProperty); + aProperty[a++] = 1; + } + aProperty[a] = 0; + return aProperty; +} + +void SALOMEDS_AttributeStudyProperties_i::Restore(const char* value) { + char* aCopy = strdup(value); + if (aCopy[0] == 'f') SetCreationMode("from scratch"); + else if (aCopy[0] == 'c') SetCreationMode("copy from"); + else SetCreationMode("none"); + + int anIndex; + for(anIndex = 2; anIndex + 2 < strlen(value) ;) { + char str[10]; + Standard_Integer aMinute, aHour, aDay, aMonth, aYear; + str[0] = aCopy[anIndex++]; + str[1] = aCopy[anIndex++]; + str[2] = 0; + aMinute = atoi(str); + str[0] = aCopy[anIndex++]; + str[1] = aCopy[anIndex++]; + aHour = atoi(str); + str[0] = aCopy[anIndex++]; + str[1] = aCopy[anIndex++]; + aDay = atoi(str); + str[0] = aCopy[anIndex++]; + str[1] = aCopy[anIndex++]; + aMonth = atoi(str); + str[0] = aCopy[anIndex++]; + str[1] = aCopy[anIndex++]; + str[2] = aCopy[anIndex++]; + str[3] = aCopy[anIndex++]; + str[4] = 0; + aYear = atoi(str); + + int aNameSize; + for(aNameSize = 0; aCopy[anIndex+aNameSize]!=1; aNameSize++); + char *aName = new char[aNameSize+1]; + strncpy(aName, &(aCopy[anIndex]), aNameSize); + aName[aNameSize] = 0; + SetModification(aName, aMinute,aHour,aDay,aMonth,aYear); + delete(aName); + anIndex += aNameSize + 1; + } + if (aCopy[1] == 'l') { + SetLocked(Standard_True); + } + SetModified(0); + delete(aCopy); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.hxx index 95d30cb65..2d7ebeb3b 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.hxx @@ -53,6 +53,10 @@ public: SALOMEDS::LongSeq_out theMonths, SALOMEDS::LongSeq_out theYears, CORBA::Boolean theWithCreator); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.cxx index 1542471bf..df037e525 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.cxx @@ -9,18 +9,23 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributeTableOfInteger_i.hxx" #include "SALOMEDS_SObject_i.hxx" #include #include #include +#include "Utils_ExceptHandlers.hxx" +#include #include #include -using namespace std; #define SEPARATOR '\1' +UNEXPECT_CATCH(ATI_IncorrectIndex, SALOMEDS::AttributeTableOfInteger::IncorrectIndex); +UNEXPECT_CATCH(ATI_IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength); + static TCollection_ExtendedString getUnit(TCollection_ExtendedString theString) { TCollection_ExtendedString aString(theString); @@ -57,6 +62,7 @@ char* SALOMEDS_AttributeTableOfInteger_i::GetTitle() { void SALOMEDS_AttributeTableOfInteger_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + Unexpect aCatch (ATI_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); @@ -74,6 +80,7 @@ void SALOMEDS_AttributeTableOfInteger_i::SetRowTitle(CORBA::Long theIndex, const void SALOMEDS_AttributeTableOfInteger_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength) { + Unexpect aCatch (ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength(); @@ -94,6 +101,7 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowTitles() { void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + Unexpect aCatch (ATI_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); @@ -104,6 +112,7 @@ void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitle(CORBA::Long theIndex, co void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength) { + Unexpect aCatch(ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength(); @@ -125,6 +134,7 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumnTitles() { void SALOMEDS_AttributeTableOfInteger_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + Unexpect aCatch (ATI_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); @@ -139,6 +149,7 @@ void SALOMEDS_AttributeTableOfInteger_i::SetRowUnit(CORBA::Long theIndex, const void SALOMEDS_AttributeTableOfInteger_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength) { + Unexpect aCatch (ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength(); @@ -166,6 +177,7 @@ CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetNbColumns() { void SALOMEDS_AttributeTableOfInteger_i::AddRow(const SALOMEDS::LongSeq& theData) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength) { + Unexpect aCatch(ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); @@ -182,6 +194,7 @@ void SALOMEDS_AttributeTableOfInteger_i::AddRow(const SALOMEDS::LongSeq& theData void SALOMEDS_AttributeTableOfInteger_i::SetRow(CORBA::Long theRow, const SALOMEDS::LongSeq& theData) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + Unexpect aCatch(ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); @@ -198,6 +211,7 @@ void SALOMEDS_AttributeTableOfInteger_i::SetRow(CORBA::Long theRow, const SALOME SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetRow(CORBA::Long theRow) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + Unexpect aCatch(ATI_IncorrectIndex); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); @@ -213,6 +227,7 @@ SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetRow(CORBA::Long theRow void SALOMEDS_AttributeTableOfInteger_i::AddColumn(const SALOMEDS::LongSeq& theData) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength) { + Unexpect aCatch(ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); @@ -229,6 +244,7 @@ void SALOMEDS_AttributeTableOfInteger_i::AddColumn(const SALOMEDS::LongSeq& theD void SALOMEDS_AttributeTableOfInteger_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::LongSeq& theData) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + Unexpect aCatch(ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); @@ -245,6 +261,7 @@ void SALOMEDS_AttributeTableOfInteger_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumn(CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + Unexpect aCatch(ATI_IncorrectIndex); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); @@ -260,6 +277,7 @@ SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumn(CORBA::Long the void SALOMEDS_AttributeTableOfInteger_i::PutValue(CORBA::Long theValue, CORBA::Long theRow, CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + Unexpect aCatch(ATI_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); @@ -278,6 +296,7 @@ CORBA::Boolean SALOMEDS_AttributeTableOfInteger_i::HasValue(CORBA::Long theRow, CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + Unexpect aCatch(ATI_IncorrectIndex); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); @@ -341,3 +360,20 @@ SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfInteger_i::SaveToFile() return aStreamFile._retn(); } +char* SALOMEDS_AttributeTableOfInteger_i::Store() { + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + + ostrstream ostr; + aTable->ConvertToString(ostr); + string aString = ostr.rdbuf()->str(); + + CORBA::String_var aBuffer = CORBA::string_dup(aString.c_str()); + return aBuffer._retn(); +} + +void SALOMEDS_AttributeTableOfInteger_i::Restore(const char* value) { + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + + istrstream aStream(value, strlen(value)); + aTable->RestoreFromString(aStream); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.hxx index c26bf5d9f..6b3ca5238 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.hxx @@ -75,6 +75,10 @@ public: virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream); virtual SALOMEDS::TMPFile* SaveToFile(); + + virtual char* Store(); + virtual void Restore(const char*); + }; #endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx index a684dc8df..cb06a664f 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx @@ -9,6 +9,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributeTableOfReal_i.hxx" #include "SALOMEDS_SObject_i.hxx" #include @@ -17,7 +18,10 @@ #include #include -using namespace std; + +#include "Utils_ExceptHandlers.hxx" +UNEXPECT_CATCH(ATR_IncorrectIndex, SALOMEDS::AttributeTableOfReal::IncorrectIndex); +UNEXPECT_CATCH(ATR_IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength); #define SEPARATOR '\1' @@ -57,6 +61,7 @@ char* SALOMEDS_AttributeTableOfReal_i::GetTitle() { void SALOMEDS_AttributeTableOfReal_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + Unexpect aCatch (ATR_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); @@ -74,6 +79,7 @@ void SALOMEDS_AttributeTableOfReal_i::SetRowTitle(CORBA::Long theIndex, const ch void SALOMEDS_AttributeTableOfReal_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) { + Unexpect aCatch (ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength(); @@ -94,6 +100,7 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetRowTitles() { void SALOMEDS_AttributeTableOfReal_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + Unexpect aCatch (ATR_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); @@ -104,6 +111,7 @@ void SALOMEDS_AttributeTableOfReal_i::SetColumnTitle(CORBA::Long theIndex, const void SALOMEDS_AttributeTableOfReal_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) { + Unexpect aCatch(ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength(); @@ -125,6 +133,7 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetColumnTitles() { void SALOMEDS_AttributeTableOfReal_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + Unexpect aCatch (ATR_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); @@ -139,6 +148,7 @@ void SALOMEDS_AttributeTableOfReal_i::SetRowUnit(CORBA::Long theIndex, const cha void SALOMEDS_AttributeTableOfReal_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) { + Unexpect aCatch (ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength(); @@ -167,6 +177,7 @@ CORBA::Long SALOMEDS_AttributeTableOfReal_i::GetNbColumns() { void SALOMEDS_AttributeTableOfReal_i::AddRow(const SALOMEDS::DoubleSeq& theData) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) { + Unexpect aCatch(ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -178,6 +189,7 @@ void SALOMEDS_AttributeTableOfReal_i::AddRow(const SALOMEDS::DoubleSeq& theData) void SALOMEDS_AttributeTableOfReal_i::SetRow(CORBA::Long theRow, const SALOMEDS::DoubleSeq& theData) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + Unexpect aCatch(ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -189,6 +201,7 @@ void SALOMEDS_AttributeTableOfReal_i::SetRow(CORBA::Long theRow, const SALOMEDS: SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetRow(CORBA::Long theRow) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + Unexpect aCatch(ATR_IncorrectIndex); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); @@ -204,6 +217,7 @@ SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetRow(CORBA::Long theRow) void SALOMEDS_AttributeTableOfReal_i::AddColumn(const SALOMEDS::DoubleSeq& theData) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) { + Unexpect aCatch(ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -215,6 +229,7 @@ void SALOMEDS_AttributeTableOfReal_i::AddColumn(const SALOMEDS::DoubleSeq& theDa void SALOMEDS_AttributeTableOfReal_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::DoubleSeq& theData) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + Unexpect aCatch(ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -226,6 +241,7 @@ void SALOMEDS_AttributeTableOfReal_i::SetColumn(CORBA::Long theColumn, const SAL SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetColumn(CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + Unexpect aCatch(ATR_IncorrectIndex); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); @@ -241,6 +257,7 @@ SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetColumn(CORBA::Long theC void SALOMEDS_AttributeTableOfReal_i::PutValue(CORBA::Double theValue, CORBA::Long theRow, CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + Unexpect aCatch(ATR_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -254,6 +271,7 @@ CORBA::Boolean SALOMEDS_AttributeTableOfReal_i::HasValue(CORBA::Long theRow, COR CORBA::Double SALOMEDS_AttributeTableOfReal_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + Unexpect aCatch(ATR_IncorrectIndex); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); @@ -320,3 +338,20 @@ SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfReal_i::SaveToFile() return aStreamFile._retn(); } +char* SALOMEDS_AttributeTableOfReal_i::Store() { + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + + ostrstream ostr; + aTable->ConvertToString(ostr); + string aString = ostr.rdbuf()->str(); + + CORBA::String_var aBuffer = CORBA::string_dup(aString.c_str()); + return aBuffer._retn(); +} + +void SALOMEDS_AttributeTableOfReal_i::Restore(const char* value) { + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + + istrstream aStream(value, strlen(value)); + aTable->RestoreFromString(aStream); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.hxx index 63ba28ccb..a3e8056b8 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.hxx @@ -75,6 +75,10 @@ public: virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream); virtual SALOMEDS::TMPFile* SaveToFile(); + + virtual char* Store(); + virtual void Restore(const char*); + }; #endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.cxx index c88ce6d21..b77322d31 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.cxx @@ -8,6 +8,7 @@ // Author : Sergey Ruin // Module : SALOME +using namespace std; #include #include @@ -20,7 +21,10 @@ #include #include -using namespace std; + +#include "Utils_ExceptHandlers.hxx" +UNEXPECT_CATCH(ATS_IncorrectIndex, SALOMEDS::AttributeTableOfString::IncorrectIndex); +UNEXPECT_CATCH(ATS_IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectArgumentLength); #define SEPARATOR '\1' @@ -60,6 +64,7 @@ char* SALOMEDS_AttributeTableOfString_i::GetTitle() { void SALOMEDS_AttributeTableOfString_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + Unexpect aCatch(ATS_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); @@ -77,6 +82,7 @@ void SALOMEDS_AttributeTableOfString_i::SetRowTitle(CORBA::Long theIndex, const void SALOMEDS_AttributeTableOfString_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength) { + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength(); @@ -97,6 +103,7 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRowTitles() { void SALOMEDS_AttributeTableOfString_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + Unexpect aCatch(ATS_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); @@ -107,6 +114,7 @@ void SALOMEDS_AttributeTableOfString_i::SetColumnTitle(CORBA::Long theIndex, con void SALOMEDS_AttributeTableOfString_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength) { + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength(); @@ -128,6 +136,7 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetColumnTitles() { void SALOMEDS_AttributeTableOfString_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + Unexpect aCatch(ATS_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); @@ -142,6 +151,7 @@ void SALOMEDS_AttributeTableOfString_i::SetRowUnit(CORBA::Long theIndex, const c void SALOMEDS_AttributeTableOfString_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength) { + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength(); @@ -170,6 +180,7 @@ CORBA::Long SALOMEDS_AttributeTableOfString_i::GetNbColumns() { void SALOMEDS_AttributeTableOfString_i::AddRow(const SALOMEDS::StringSeq& theData) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength) { + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); @@ -181,6 +192,7 @@ void SALOMEDS_AttributeTableOfString_i::AddRow(const SALOMEDS::StringSeq& theDat void SALOMEDS_AttributeTableOfString_i::SetRow(CORBA::Long theRow, const SALOMEDS::StringSeq& theData) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectIndex) { + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); @@ -192,6 +204,7 @@ void SALOMEDS_AttributeTableOfString_i::SetRow(CORBA::Long theRow, const SALOMED SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRow(CORBA::Long theRow) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + Unexpect aCatch(ATS_IncorrectIndex); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); @@ -207,6 +220,7 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRow(CORBA::Long theRo void SALOMEDS_AttributeTableOfString_i::AddColumn(const SALOMEDS::StringSeq& theData) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength) { + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); @@ -218,6 +232,7 @@ void SALOMEDS_AttributeTableOfString_i::AddColumn(const SALOMEDS::StringSeq& the void SALOMEDS_AttributeTableOfString_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::StringSeq& theData) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectIndex) { + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); @@ -229,6 +244,7 @@ void SALOMEDS_AttributeTableOfString_i::SetColumn(CORBA::Long theColumn, const S SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetColumn(CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + Unexpect aCatch(ATS_IncorrectIndex); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); @@ -244,6 +260,7 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetColumn(CORBA::Long th void SALOMEDS_AttributeTableOfString_i::PutValue(const char* theValue, CORBA::Long theRow, CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + Unexpect aCatch(ATS_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); char* aValue = CORBA::string_dup(theValue); @@ -258,6 +275,7 @@ CORBA::Boolean SALOMEDS_AttributeTableOfString_i::HasValue(CORBA::Long theRow, C char* SALOMEDS_AttributeTableOfString_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + Unexpect aCatch(ATS_IncorrectIndex); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); @@ -316,3 +334,20 @@ SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfString_i::SaveToFile() return aStreamFile._retn(); } +char* SALOMEDS_AttributeTableOfString_i::Store() { + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + + ostrstream ostr; + aTable->ConvertToString(ostr); + string aString = ostr.rdbuf()->str(); + + CORBA::String_var aBuffer = CORBA::string_dup(aString.c_str()); + return aBuffer._retn(); +} + +void SALOMEDS_AttributeTableOfString_i::Restore(const char* value) { + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + + istrstream aStream(value, strlen(value)); + aTable->RestoreFromString(aStream); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.hxx index 0368c59c5..f3a87deea 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.hxx @@ -74,6 +74,10 @@ public: virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream); virtual SALOMEDS::TMPFile* SaveToFile(); + + char* Store(); + void Restore(const char*); + }; #endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx index b431af96a..1d14121c1 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx @@ -24,13 +24,13 @@ // File : SALOMEDS_AttributeTarget_i.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ +using namespace std; #include "SALOMEDS_AttributeTarget_i.hxx" #include "SALOMEDS_SObject_i.hxx" #include #include -using namespace std; void SALOMEDS_AttributeTarget_i::Add(SALOMEDS::SObject_ptr anObject) { TDF_Label aLabel; diff --git a/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.cxx index 45d1b8f52..cf63ff0d9 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.cxx @@ -26,10 +26,10 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributeTextColor_i.hxx" #include "SALOMEDS_SObject_i.hxx" #include -using namespace std; SALOMEDS::Color SALOMEDS_AttributeTextColor_i::TextColor() { SALOMEDS::Color TextColor; @@ -55,3 +55,20 @@ void SALOMEDS_AttributeTextColor_i::SetTextColor(const SALOMEDS::Color& value) { anArray->SetValue(3, value.B); Handle(SALOMEDS_TextColorAttribute)::DownCast(_myAttr)->ChangeArray(anArray); } + +char* SALOMEDS_AttributeTextColor_i::Store() { + SALOMEDS::Color aColor = TextColor(); + char *Val = new char[75]; + sprintf(Val, "%f %f %f", (float)aColor.R, (float)aColor.G, (float)aColor.B); + return Val; +} + +void SALOMEDS_AttributeTextColor_i::Restore(const char* value) { + SALOMEDS::Color aColor; + float r, g, b; + sscanf(value, "%f %f %f", &r, &g, &b); + aColor.R = r; + aColor.G = g; + aColor.B = b; + SetTextColor(aColor); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.hxx index f03c98b9e..46b50ff12 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.hxx @@ -24,7 +24,7 @@ // File : SALOMEDS_AttributeTextColor_i.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef SALOMEDS_AttributeTextColor_i_HeaderFile #define SALOMEDS_AttributeTextColor_i_HeaderFile @@ -48,6 +48,10 @@ public: SALOMEDS::Color TextColor(); void SetTextColor(const SALOMEDS::Color& value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.cxx index cc6ff475b..0995ac90a 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.cxx @@ -26,10 +26,10 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_AttributeTextHighlightColor_i.hxx" #include "SALOMEDS_SObject_i.hxx" #include -using namespace std; SALOMEDS::Color SALOMEDS_AttributeTextHighlightColor_i::TextHighlightColor() { SALOMEDS::Color TextHighlightColor; @@ -55,3 +55,20 @@ void SALOMEDS_AttributeTextHighlightColor_i::SetTextHighlightColor(const SALOMED anArray->SetValue(3, value.B); Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(_myAttr)->ChangeArray(anArray); } + +char* SALOMEDS_AttributeTextHighlightColor_i::Store() { + SALOMEDS::Color aColor = TextHighlightColor(); + char *Val = new char[75]; + sprintf(Val, "%f %f %f", (float)aColor.R, (float)aColor.G, (float)aColor.B); + return Val; +} + +void SALOMEDS_AttributeTextHighlightColor_i::Restore(const char* value) { + SALOMEDS::Color aColor; + float r, g, b; + sscanf(value, "%f %f %f", &r, &g, &b); + aColor.R = r; + aColor.G = g; + aColor.B = b; + SetTextHighlightColor(aColor); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.hxx index 2b7e487dc..2ca180ffe 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.hxx @@ -24,7 +24,7 @@ // File : SALOMEDS_AttributeTextHighlightColor_i.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef SALOMEDS_AttributeTextHighlightColor_i_HeaderFile #define SALOMEDS_AttributeTextHighlightColor_i_HeaderFile @@ -48,6 +48,10 @@ public: SALOMEDS::Color TextHighlightColor(); void SetTextHighlightColor(const SALOMEDS::Color& value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx index aaf7ddc25..6e575f131 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx @@ -24,12 +24,14 @@ // File : SALOMEDS_AttributeTreeNode_i.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ +using namespace std; #include "SALOMEDS_AttributeTreeNode_i.hxx" #include "SALOMEDS_SObject_i.hxx" #include "utilities.h" -using namespace std; +#include +#include static Handle(TDataStd_TreeNode) GetNode(SALOMEDS::AttributeTreeNode_ptr value, const Handle(TDataStd_TreeNode)& aNode) { @@ -182,3 +184,56 @@ char* SALOMEDS_AttributeTreeNode_i::Label() { TDF_Tool::Entry(_myAttr->Label(),aLabelName); return CORBA::String_var(CORBA::string_dup(aLabelName.ToCString()))._retn(); } + +char* SALOMEDS_AttributeTreeNode_i::Store() { + char* aStr[4]; + + if (HasFather()) aStr[0] = GetFather()->Label(); else aStr[0] = "!"; + if (HasPrevious()) aStr[1] = GetPrevious()->Label(); else aStr[1] = "!"; + if (HasNext()) aStr[2] = GetNext()->Label(); else aStr[2] = "!"; + if (HasFirst()) aStr[3] = GetFirst()->Label(); else aStr[3] = "!"; + + int aLength = 4; + aLength += strlen(aStr[0]) + strlen(aStr[1]) + strlen(aStr[2]) + strlen(aStr[3]); + CORBA::String_var aResult = new char[aLength]; + sprintf(aResult, "%s %s %s %s", aStr[0], aStr[1], aStr[2], aStr[3]); + return aResult._retn(); +} + +void SALOMEDS_AttributeTreeNode_i::Restore(const char* value) { + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); + Handle(TDF_Data) DF = TDocStd_Document::Get(_myAttr->Label())->GetData(); + + char* aCopy = strdup(value); + char* adr = strtok(aCopy, " "); + + TDF_Label aLabel; + Handle(TDataStd_TreeNode) aDepNode; + + if (adr && adr[0] != '!') { + TDF_Tool::Label(DF, adr, aLabel, 1); + if (!aLabel.FindAttribute(aNode->ID(), aDepNode)) aDepNode = TDataStd_TreeNode::Set(aLabel, aNode->ID()); + aNode->SetFather(aDepNode); + } + + adr = strtok(NULL, " "); + if (adr && adr[0] != '!') { + TDF_Tool::Label(DF, adr, aLabel, 1); + if (!aLabel.FindAttribute(aNode->ID(), aDepNode)) aDepNode = TDataStd_TreeNode::Set(aLabel, aNode->ID()); + aNode->SetPrevious(aDepNode); + } + + adr = strtok(NULL, " "); + if (adr && adr[0] != '!') { + TDF_Tool::Label(DF, adr, aLabel, 1); + if (!aLabel.FindAttribute(aNode->ID(), aDepNode)) aDepNode = TDataStd_TreeNode::Set(aLabel, aNode->ID()); + aNode->SetNext(aDepNode); + } + + adr = strtok(NULL, " "); + if (adr && adr[0] != '!') { + TDF_Tool::Label(DF, adr, aLabel, 1); + if (!aLabel.FindAttribute(aNode->ID(), aDepNode)) aDepNode = TDataStd_TreeNode::Set(aLabel, aNode->ID()); + aNode->SetFirst(aDepNode); + } +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.hxx index c8bda02dc..14e134b27 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.hxx @@ -71,6 +71,10 @@ public: CORBA::Boolean IsFather(SALOMEDS::AttributeTreeNode_ptr value); CORBA::Boolean IsChild(SALOMEDS::AttributeTreeNode_ptr value); char* Label(); + + char* Store(); + void Restore(const char*); + }; #endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeUserID_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeUserID_i.cxx index 021879481..b7fa64a41 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeUserID_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeUserID_i.cxx @@ -24,12 +24,12 @@ // File : SALOMEDS_AttributeName_i.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ +using namespace std; #include "SALOMEDS_AttributeUserID_i.hxx" #include #include "SALOMEDS_SObject_i.hxx" -using namespace std; char* SALOMEDS_AttributeUserID_i::Value() { char aGUID[40]; @@ -43,3 +43,10 @@ void SALOMEDS_AttributeUserID_i::SetValue(const char* value) { CORBA::String_var Str = CORBA::string_dup(value); Handle(TDataStd_UAttribute)::DownCast(_myAttr)->SetID(Standard_GUID(Standard_CString(Str))); } + +char* SALOMEDS_AttributeUserID_i::Store() { + return ""; +} + +void SALOMEDS_AttributeUserID_i::Restore(const char* value) { +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeUserID_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeUserID_i.hxx index 662d21eca..e080658af 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeUserID_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeUserID_i.hxx @@ -54,6 +54,10 @@ public: static Standard_GUID SALOMEDS_DefaultUserAttributeID ("FFFFFFFF-D9CD-11d6-945D-1050DA506788"); return SALOMEDS_DefaultUserAttributeID; } + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_BasicAttributeFactory.cxx b/src/SALOMEDS/SALOMEDS_BasicAttributeFactory.cxx index bd83af147..707c40e10 100644 --- a/src/SALOMEDS/SALOMEDS_BasicAttributeFactory.cxx +++ b/src/SALOMEDS/SALOMEDS_BasicAttributeFactory.cxx @@ -38,16 +38,17 @@ using namespace std; SALOMEDS_BasicAttribute_i* BasicAttributeFactory::Create(const char* type) throw (SALOME_Exception) { - if (!strcmp(type,"AttReal")) - { - SALOMEDS_AttReal_i *A = new SALOMEDS_AttReal_i(); - return A; - } - else if(!strcmp(type,"AttLong")) - { - SALOMEDS_AttLong_i *A = new SALOMEDS_AttLong_i(); - return A; - } - else throw(SALOME_Exception(LOCALIZED("bad attribute type name"))); - + try { + if (!strcmp(type,"AttReal")) + { + SALOMEDS_AttReal_i *A = new SALOMEDS_AttReal_i(); + return A; + } + else if(!strcmp(type,"AttLong")) + { + SALOMEDS_AttLong_i *A = new SALOMEDS_AttLong_i(); + return A; + } + else throw(SALOME_Exception(LOCALIZED("bad attribute type name"))); + } catch (...) {throw(SALOME_Exception(LOCALIZED("Unexpected exception was caught")));} } diff --git a/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx b/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx index ada9ea7c4..947579721 100644 --- a/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx +++ b/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx @@ -26,10 +26,12 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_ChildIterator_i.hxx" #include "SALOMEDS_SObject_i.hxx" #include "utilities.h" -using namespace std; + + //============================================================================ /*! Function : constructor diff --git a/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx b/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx index 216055253..98c011e27 100644 --- a/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx +++ b/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx @@ -24,7 +24,7 @@ // File : SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef _SALOMEDS_DataMapIteratorOfDataMapStringLabel_HeaderFile #define _SALOMEDS_DataMapIteratorOfDataMapStringLabel_HeaderFile diff --git a/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel_0.cxx b/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel_0.cxx index ce782eae0..1473d66c5 100644 --- a/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel_0.cxx +++ b/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel_0.cxx @@ -24,8 +24,9 @@ // File : SALOMEDS_DataMapIteratorOfDataMapStringLabel_0.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ +using namespace std; #include "SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx" #ifndef _Standard_NoSuchObject_HeaderFile @@ -43,7 +44,6 @@ #ifndef _SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile #include "SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx" #endif -using namespace std; #define TheKey TCollection_ExtendedString diff --git a/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx b/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx index 175205a6e..5fa7a9f17 100644 --- a/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx +++ b/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx @@ -24,7 +24,7 @@ // File : SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef _SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile #define _SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile diff --git a/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel_0.cxx b/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel_0.cxx index 4faa54bac..401a2b77e 100644 --- a/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel_0.cxx +++ b/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel_0.cxx @@ -24,8 +24,9 @@ // File : Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel_0.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ +using namespace std; #include "SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx" #ifndef _Standard_TypeMismatch_HeaderFile @@ -44,7 +45,6 @@ #ifndef _SALOMEDS_DataMapIteratorOfDataMapStringLabel_HeaderFile #include "SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx" #endif -using namespace std; SALOMEDS_DataMapNodeOfDataMapStringLabel::~SALOMEDS_DataMapNodeOfDataMapStringLabel() {} diff --git a/src/SALOMEDS/SALOMEDS_DataMapStringLabel.hxx b/src/SALOMEDS/SALOMEDS_DataMapStringLabel.hxx index ef2ddbdff..7de27e8e1 100644 --- a/src/SALOMEDS/SALOMEDS_DataMapStringLabel.hxx +++ b/src/SALOMEDS/SALOMEDS_DataMapStringLabel.hxx @@ -24,7 +24,7 @@ // File : SALOMEDS_DataMapStringLabel.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef _SALOMEDS_DataMapStringLabel_HeaderFile #define _SALOMEDS_DataMapStringLabel_HeaderFile diff --git a/src/SALOMEDS/SALOMEDS_DataMapStringLabel_0.cxx b/src/SALOMEDS/SALOMEDS_DataMapStringLabel_0.cxx index a670a6f57..76dab0d3b 100644 --- a/src/SALOMEDS/SALOMEDS_DataMapStringLabel_0.cxx +++ b/src/SALOMEDS/SALOMEDS_DataMapStringLabel_0.cxx @@ -24,8 +24,9 @@ // File : SALOMEDS_DataMapStringLabel_0.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ +using namespace std; #include "SALOMEDS_DataMapStringLabel.hxx" #ifndef _Standard_DomainError_HeaderFile @@ -46,7 +47,6 @@ #ifndef _SALOMEDS_DataMapIteratorOfDataMapStringLabel_HeaderFile #include "SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx" #endif -using namespace std; #define TheKey TCollection_ExtendedString diff --git a/src/SALOMEDS/SALOMEDS_DrawableAttribute.cxx b/src/SALOMEDS/SALOMEDS_DrawableAttribute.cxx index 0245efc1d..8d72f6a6a 100644 --- a/src/SALOMEDS/SALOMEDS_DrawableAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_DrawableAttribute.cxx @@ -24,11 +24,11 @@ // File : SALOMEDS_DrawableAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ +using namespace std; #include "SALOMEDS_DrawableAttribute.ixx" #include -using namespace std; //======================================================================= //function : GetID diff --git a/src/SALOMEDS/SALOMEDS_ExpandableAttribute.cxx b/src/SALOMEDS/SALOMEDS_ExpandableAttribute.cxx index db17601b4..b20dd9c10 100644 --- a/src/SALOMEDS/SALOMEDS_ExpandableAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_ExpandableAttribute.cxx @@ -24,11 +24,11 @@ // File : SALOMEDS_ExpandableAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ +using namespace std; #include "SALOMEDS_ExpandableAttribute.ixx" #include -using namespace std; //======================================================================= //function : GetID diff --git a/src/SALOMEDS/SALOMEDS_ExternalFileDef.cxx b/src/SALOMEDS/SALOMEDS_ExternalFileDef.cxx index 2e07b0106..3b5af8399 100644 --- a/src/SALOMEDS/SALOMEDS_ExternalFileDef.cxx +++ b/src/SALOMEDS/SALOMEDS_ExternalFileDef.cxx @@ -24,7 +24,7 @@ // File : SALOMEDS_ExternalFileDef.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #include "SALOMEDS_ExternalFileDef.ixx" #include diff --git a/src/SALOMEDS/SALOMEDS_FileType.cxx b/src/SALOMEDS/SALOMEDS_FileType.cxx index 515bbc551..a26ebe3f4 100644 --- a/src/SALOMEDS/SALOMEDS_FileType.cxx +++ b/src/SALOMEDS/SALOMEDS_FileType.cxx @@ -24,7 +24,7 @@ // File : SALOMEDS_FileType.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #include "SALOMEDS_FileType.ixx" #include diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx index 053b51438..7311b29c0 100644 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx @@ -9,10 +9,92 @@ // Module : SALOME // $Header$ -#include "SALOMEDS_StudyBuilder_i.hxx" using namespace std; +#include +#include + +#include "SALOMEDS_AttributeDrawable_i.hxx" +#include "SALOMEDS_AttributeSelectable_i.hxx" +#include "SALOMEDS_AttributeOpened_i.hxx" +#include "SALOMEDS_AttributeTextColor_i.hxx" +#include "SALOMEDS_AttributeTextHighlightColor_i.hxx" +#include "SALOMEDS_AttributePixMap_i.hxx" +#include "SALOMEDS_AttributeExpandable_i.hxx" +#include "SALOMEDS_AttributeLocalID_i.hxx" +#include "SALOMEDS_AttributeTarget_i.hxx" +#include "SALOMEDS_AttributeTableOfInteger_i.hxx" +#include "SALOMEDS_AttributeTableOfReal_i.hxx" +#include "SALOMEDS_AttributeTableOfString_i.hxx" +#include "SALOMEDS_AttributeStudyProperties_i.hxx" +#include "SALOMEDS_AttributePythonObject_i.hxx" +#include "SALOMEDS_AttributeTreeNode_i.hxx" +#include "SALOMEDS_AttributeUserID_i.hxx" +#include "SALOMEDS_AttributeExternalFileDef_i.hxx" +#include "SALOMEDS_AttributeFileType_i.hxx" +#include "SALOMEDS_StudyBuilder_i.hxx" + +#include "SALOMEDS_SequenceOfRealAttribute.hxx" +#include "SALOMEDS_SequenceOfIntegerAttribute.hxx" +#include "SALOMEDS_IORAttribute.hxx" +#include "SALOMEDS_PersRefAttribute.hxx" +#include "SALOMEDS_DrawableAttribute.hxx" +#include "SALOMEDS_SelectableAttribute.hxx" +#include "SALOMEDS_ExpandableAttribute.hxx" +#include "SALOMEDS_OpenedAttribute.hxx" +#include "SALOMEDS_TextColorAttribute.hxx" +#include "SALOMEDS_TextHighlightColorAttribute.hxx" +#include "SALOMEDS_PixMapAttribute.hxx" +#include "SALOMEDS_LocalIDAttribute.hxx" +#include "SALOMEDS_PythonObjectAttribute.hxx" +#include "SALOMEDS_TargetAttribute.hxx" +#include "SALOMEDS_StudyPropertiesAttribute.hxx" +#include "SALOMEDS_TableOfIntegerAttribute.hxx" +#include "SALOMEDS_TableOfRealAttribute.hxx" +#include "SALOMEDS_TableOfStringAttribute.hxx" +#include "SALOMEDS_ExternalFileDef.hxx" +#include "SALOMEDS_FileType.hxx" +#include "Utils_ExceptHandlers.hxx" +#define RegisteredAttributes 26 + +UNEXPECT_CATCH(GALockProtection, SALOMEDS::GenericAttribute::LockProtection); + +const char AttributesTypeNames[RegisteredAttributes][30] = { + "AttributeReal", "AttributeInteger", + "AttributeSequenceOfReal", "AttributeSequenceOfInteger", + "AttributeName", "AttributeComment", + "AttributeIOR", "AttributePersistentRef", + "AttributeDrawable", "AttributeSelectable", + "AttributeExpandable", "AttributeOpened", + "AttributeTextColor", "AttributeTextHighlightColor", "AttributePixMap", + "AttributeTreeNode", "AttributeLocalID", + "AttributeTarget", + "AttributeTableOfInteger", "AttributeTableOfReal", "AttributeTableOfString", + "AttributeStudyProperties", + "AttributePythonObject", + "AttributeUserID", + "AttributeExternalFileDef", "AttributeFileType" +}; + +const Standard_GUID AttributesGUIDs[RegisteredAttributes] = { + TDataStd_Real::GetID(), TDataStd_Integer::GetID(), + SALOMEDS_SequenceOfRealAttribute::GetID(), SALOMEDS_SequenceOfIntegerAttribute::GetID(), + TDataStd_Name::GetID(), TDataStd_Comment::GetID(), + SALOMEDS_IORAttribute::GetID(), SALOMEDS_PersRefAttribute::GetID(), + SALOMEDS_DrawableAttribute::GetID(), SALOMEDS_SelectableAttribute::GetID(), + SALOMEDS_ExpandableAttribute::GetID(), SALOMEDS_OpenedAttribute::GetID(), + SALOMEDS_TextColorAttribute::GetID(), SALOMEDS_TextHighlightColorAttribute::GetID(), SALOMEDS_PixMapAttribute::GetID(), + TDataStd_TreeNode::GetDefaultTreeID(), SALOMEDS_LocalIDAttribute::GetID(), + SALOMEDS_TargetAttribute::GetID(), + SALOMEDS_TableOfIntegerAttribute::GetID(), SALOMEDS_TableOfRealAttribute::GetID(), SALOMEDS_TableOfStringAttribute::GetID(), + SALOMEDS_StudyPropertiesAttribute::GetID(), + SALOMEDS_PythonObjectAttribute::GetID(), + Standard_GUID("FFFFFFFF-D9CD-11d6-945D-1050DA506788"), + SALOMEDS_ExternalFileDef::GetID(), SALOMEDS_FileType::GetID() +}; + void SALOMEDS_GenericAttribute_i::CheckLocked() throw (SALOMEDS::GenericAttribute::LockProtection) { + Unexpect aCatch(GALockProtection); if (!_myAttr.IsNull() && _myAttr->IsValid() && !CORBA::is_nil(_myOrb)) { Handle(SALOMEDS_IORAttribute) Att; if (_myAttr->Label().Root().FindAttribute(SALOMEDS_IORAttribute::GetID(),Att)){ @@ -20,12 +102,107 @@ void SALOMEDS_GenericAttribute_i::CheckLocked() throw (SALOMEDS::GenericAttribut char* IOR = CORBA::string_dup(ch.ToCString()); CORBA::Object_var obj = _myOrb->string_to_object(IOR); SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj); - // ASSERT(!CORBA::is_nil(aStudy)); +// ASSERT(!CORBA::is_nil(aStudy)); if (aStudy->NewBuilder()->HasOpenCommand()) return; if (aStudy->GetProperties()->IsLocked()) { - // INFOS("Locked document modification !!!"); +// MESSAGE("Locked document modification !!!"); throw SALOMEDS::GenericAttribute::LockProtection(); } } } } + +SALOMEDS::SObject_ptr SALOMEDS_GenericAttribute_i::GetSObject() { + if (_myAttr.IsNull() || _myAttr->Label().IsNull()) return SALOMEDS::SObject::_nil(); + SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (_myAttr->Label(),_myOrb); + SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + return so._retn(); +} + +Standard_GUID SALOMEDS_GenericAttribute_i::GetGUID(const char* theType) { + Standard_Integer i; + for(i = 0; i < RegisteredAttributes; i++) { + if (strcmp(AttributesTypeNames[i], theType) == 0) return AttributesGUIDs[i]; + } + + if (strncmp(theType, "AttributeTreeNodeGUID",21) == 0) { + char* aGUIDString = new char[40]; + sprintf(aGUIDString, &(theType[21])); + Standard_GUID aGUID = Standard_GUID(aGUIDString); // create tree node GUID by name + delete(aGUIDString); + return aGUID; + } + return Standard_GUID(); +} + +char* SALOMEDS_GenericAttribute_i::Type() { + if (_myAttr.IsNull()) return ""; + int i; + for(i = 0; i < RegisteredAttributes; i++) { + if (_myAttr->ID() == AttributesGUIDs[i]) { + CORBA::String_var aString(AttributesTypeNames[i]); + return aString._retn(); + } + } + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); + if (!aNode.IsNull()) { + char* aNodeName = new char[60]; + char aGUID[40]; + aNode->ID().ToCString(aGUID); + sprintf(aNodeName, "AttributeTreeNodeGUID%s",aGUID); + return aNodeName; + } + + Handle(TDataStd_UAttribute) aUAttr = Handle(TDataStd_UAttribute)::DownCast(_myAttr); + if (!aUAttr.IsNull()) { + char* aUAttrName = new char[60]; + char aGUID[40]; + aUAttr->ID().ToCString(aGUID); + sprintf(aUAttrName, "AttributeUserID_%s",aGUID); + return aUAttrName; + } + + return ""; +} + +SALOMEDS::GenericAttribute_ptr SALOMEDS_GenericAttribute_i::CreateAttribute(CORBA::ORB_ptr theOrb, + const Handle(TDF_Attribute)& theAttr) { + + __ReturnCORBAAttribute(TDataStd_Real, AttributeReal); + __ReturnCORBAAttribute(TDataStd_Integer, AttributeInteger); + __ReturnCORBAAttribute(SALOMEDS_SequenceOfRealAttribute, AttributeSequenceOfReal); + __ReturnCORBAAttribute(SALOMEDS_SequenceOfIntegerAttribute, AttributeSequenceOfInteger); + __ReturnCORBAAttribute(TDataStd_Name, AttributeName); + __ReturnCORBAAttribute(TDataStd_Comment, AttributeComment); + __ReturnCORBAAttribute(SALOMEDS_IORAttribute, AttributeIOR); + __ReturnCORBAAttribute(SALOMEDS_PersRefAttribute, AttributePersistentRef); + __ReturnCORBAAttribute(SALOMEDS_DrawableAttribute, AttributeDrawable); + __ReturnCORBAAttribute(SALOMEDS_SelectableAttribute, AttributeSelectable); + __ReturnCORBAAttribute(SALOMEDS_ExpandableAttribute, AttributeExpandable); + __ReturnCORBAAttribute(SALOMEDS_OpenedAttribute, AttributeOpened); + __ReturnCORBAAttribute(SALOMEDS_TextColorAttribute, AttributeTextColor); + __ReturnCORBAAttribute(SALOMEDS_TextHighlightColorAttribute, AttributeTextHighlightColor); + __ReturnCORBAAttribute(SALOMEDS_PixMapAttribute, AttributePixMap); + __ReturnCORBAAttribute(SALOMEDS_LocalIDAttribute, AttributeLocalID); + __ReturnCORBAAttribute(SALOMEDS_TargetAttribute, AttributeTarget); + __ReturnCORBAAttribute(SALOMEDS_TableOfIntegerAttribute, AttributeTableOfInteger); + __ReturnCORBAAttribute(SALOMEDS_TableOfRealAttribute, AttributeTableOfReal); + __ReturnCORBAAttribute(SALOMEDS_TableOfStringAttribute, AttributeTableOfString); + __ReturnCORBAAttribute(SALOMEDS_StudyPropertiesAttribute, AttributeStudyProperties); + __ReturnCORBAAttribute(SALOMEDS_PythonObjectAttribute, AttributePythonObject); + __ReturnCORBAAttribute(SALOMEDS_ExternalFileDef, AttributeExternalFileDef); + __ReturnCORBAAttribute(SALOMEDS_FileType, AttributeFileType); + + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(theAttr); + if (!aNode.IsNull()) { + SALOMEDS_AttributeTreeNode_i* Attr = new SALOMEDS_AttributeTreeNode_i(aNode, theOrb); \ + return Attr->AttributeTreeNode::_this(); \ + } + + Handle(TDataStd_UAttribute) aUAttr = Handle(TDataStd_UAttribute)::DownCast(theAttr); + if (!aUAttr.IsNull()) { + SALOMEDS_AttributeUserID_i* Attr = new SALOMEDS_AttributeUserID_i(aUAttr, theOrb); \ + return Attr->AttributeUserID::_this(); \ + } + return SALOMEDS::GenericAttribute::_nil(); +} diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx index 6d404b719..2ea8c97fe 100644 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx @@ -34,7 +34,6 @@ #include CORBA_SERVER_HEADER(SALOMEDS) #include #include "SALOMEDS_SObject_i.hxx" -#include "SALOMEDS_IORAttribute.hxx" class SALOMEDS_GenericAttribute_i: public POA_SALOMEDS::GenericAttribute, public PortableServer::RefCountServantBase { @@ -45,16 +44,51 @@ public: SALOMEDS_GenericAttribute_i() {}; void CheckLocked() throw (SALOMEDS::GenericAttribute::LockProtection); + + char* Store() {return "";}; + + void Restore(const char*) {}; - ~SALOMEDS_GenericAttribute_i() {}; + char* Type(); -// CORBA::Boolean GetPtr(SALOMEDS::SObject_out so) { -// SALOMEDS_SObject_i* sob_impl = new SALOMEDS_SObject_i(_myAttr->Label(), _myOrb); -// SALOMEDS::SObject_var sob = sob_impl->_this(); -// return sob._retn(); -// }; + SALOMEDS::SObject_ptr GetSObject(); + + ~SALOMEDS_GenericAttribute_i() {}; + static Standard_GUID GetGUID(const char* theType); + static SALOMEDS::GenericAttribute_ptr CreateAttribute(CORBA::ORB_ptr theOrb, const Handle(TDF_Attribute)& theAttr); }; +// defines for creation attributes objects + +//cout<<"*** Create new CORBA attribute for "<<#CORBA_Name<ID() == OCAF_Name::GetID()) { \ + SALOMEDS_##CORBA_Name##_i* Attr = new SALOMEDS_##CORBA_Name##_i(Handle(OCAF_Name)::DownCast(theAttr), theOrb); \ + return Attr->CORBA_Name::_this(); \ + } + +//cout<<"Create New Attribute "<<#CORBA_Name<CORBA_Name::_this(); \ + } + +//cout<<"Create New Attribute "<<#CORBA_Name<CORBA_Name::_this(); \ + } + #endif diff --git a/src/SALOMEDS/SALOMEDS_IORAttribute.cxx b/src/SALOMEDS/SALOMEDS_IORAttribute.cxx index f71b538fd..c305641a4 100644 --- a/src/SALOMEDS/SALOMEDS_IORAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_IORAttribute.cxx @@ -26,11 +26,11 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_IORAttribute.ixx" #include #include #include "SALOMEDS_Study_i.hxx" -using namespace std; //======================================================================= //function : GetID diff --git a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.cxx b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.cxx index 623ce7c50..f38360b4a 100644 --- a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.cxx @@ -24,11 +24,11 @@ // File : SALOMEDS_LocalIDAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ +using namespace std; #include "SALOMEDS_LocalIDAttribute.ixx" #include -using namespace std; //======================================================================= //function : GetID diff --git a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.hxx b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.hxx index 6729106ed..0e930f04f 100644 --- a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.hxx +++ b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.hxx @@ -24,7 +24,7 @@ // File : SALOMEDS_LocalIDAttribute.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef _SALOMEDS_LocalIDAttribute_HeaderFile #define _SALOMEDS_LocalIDAttribute_HeaderFile diff --git a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.ixx b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.ixx index f50e7b9c3..56d6d331b 100644 --- a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.ixx +++ b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.ixx @@ -24,7 +24,7 @@ // File : SALOMEDS_LocalIDAttribute.ixx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #include "SALOMEDS_LocalIDAttribute.jxx" diff --git a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.jxx b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.jxx index aa12fd108..fc43ec07d 100644 --- a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.jxx +++ b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.jxx @@ -24,7 +24,7 @@ // File : SALOMEDS_LocalIDAttribute.jxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef _Standard_GUID_HeaderFile #include diff --git a/src/SALOMEDS/SALOMEDS_OCAFApplication.cxx b/src/SALOMEDS/SALOMEDS_OCAFApplication.cxx index 5913c6842..e0c7ad35f 100644 --- a/src/SALOMEDS/SALOMEDS_OCAFApplication.cxx +++ b/src/SALOMEDS/SALOMEDS_OCAFApplication.cxx @@ -26,8 +26,8 @@ // Module : SALOME // $Header$ -#include "SALOMEDS_OCAFApplication.ixx" using namespace std; +#include "SALOMEDS_OCAFApplication.ixx" //======================================================================= //function : SALOMEDS_OCAFApplication diff --git a/src/SALOMEDS/SALOMEDS_OpenedAttribute.cxx b/src/SALOMEDS/SALOMEDS_OpenedAttribute.cxx index 4704436ff..fc074bf13 100644 --- a/src/SALOMEDS/SALOMEDS_OpenedAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_OpenedAttribute.cxx @@ -24,11 +24,11 @@ // File : SALOMEDS_OpenedAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ +using namespace std; #include "SALOMEDS_OpenedAttribute.ixx" #include -using namespace std; //======================================================================= //function : GetID diff --git a/src/SALOMEDS/SALOMEDS_PersRefAttribute.cxx b/src/SALOMEDS/SALOMEDS_PersRefAttribute.cxx index 8d57af837..8e313831c 100644 --- a/src/SALOMEDS/SALOMEDS_PersRefAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_PersRefAttribute.cxx @@ -26,10 +26,10 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_PersRefAttribute.ixx" #include #include -using namespace std; //======================================================================= //function : GetID diff --git a/src/SALOMEDS/SALOMEDS_PixMapAttribute.cxx b/src/SALOMEDS/SALOMEDS_PixMapAttribute.cxx index 1799c035f..fa84b6180 100644 --- a/src/SALOMEDS/SALOMEDS_PixMapAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_PixMapAttribute.cxx @@ -24,12 +24,12 @@ // File : SALOMEDS_PixMapAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ +using namespace std; #include "SALOMEDS_PixMapAttribute.ixx" #include #include -using namespace std; //======================================================================= //function : GetID diff --git a/src/SALOMEDS/SALOMEDS_PythonObjectAttribute.cxx b/src/SALOMEDS/SALOMEDS_PythonObjectAttribute.cxx index f8c8d9de4..fd0538e0e 100644 --- a/src/SALOMEDS/SALOMEDS_PythonObjectAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_PythonObjectAttribute.cxx @@ -9,9 +9,9 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_PythonObjectAttribute.ixx" #include -using namespace std; const Standard_GUID& SALOMEDS_PythonObjectAttribute::GetID() { diff --git a/src/SALOMEDS/SALOMEDS_SComponentIterator_i.cxx b/src/SALOMEDS/SALOMEDS_SComponentIterator_i.cxx index c8ae7c4c5..77b0b4655 100644 --- a/src/SALOMEDS/SALOMEDS_SComponentIterator_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SComponentIterator_i.cxx @@ -26,8 +26,9 @@ // Module : SALOME // $Header$ -#include "SALOMEDS_SComponentIterator_i.hxx" using namespace std; +#include "SALOMEDS_SComponentIterator_i.hxx" + //============================================================================ /*! Function : constructor diff --git a/src/SALOMEDS/SALOMEDS_SComponent_i.cxx b/src/SALOMEDS/SALOMEDS_SComponent_i.cxx index 66264fd5b..896859cca 100644 --- a/src/SALOMEDS/SALOMEDS_SComponent_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SComponent_i.cxx @@ -26,9 +26,10 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEDS_SComponent_i.hxx" #include "utilities.h" -using namespace std; + //============================================================================ /*! Function : constructor diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.cxx b/src/SALOMEDS/SALOMEDS_SObject_i.cxx index 1f8851466..25cb25ac7 100644 --- a/src/SALOMEDS/SALOMEDS_SObject_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.cxx @@ -26,133 +26,14 @@ // Module : SALOME // $Header$ +using namespace std; #include "utilities.h" #include "SALOMEDS_SObject_i.hxx" //SALOMEDS Headers #include "SALOMEDS_SComponent_i.hxx" +#include "SALOMEDS_GenericAttribute_i.hxx" #include "SALOMEDS_IORAttribute.hxx" -#include "SALOMEDS_PersRefAttribute.hxx" -#include "SALOMEDS_SequenceOfRealAttribute.hxx" -#include "SALOMEDS_SequenceOfIntegerAttribute.hxx" -#include "SALOMEDS_TableOfRealAttribute.hxx" -#include "SALOMEDS_TableOfIntegerAttribute.hxx" -#include "SALOMEDS_IORAttribute.hxx" -#include "SALOMEDS_PersRefAttribute.hxx" -#include "SALOMEDS_StudyPropertiesAttribute.hxx" -#include "SALOMEDS_PythonObjectAttribute.hxx" -#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" -#include "SALOMEDS_AttributeInteger_i.hxx" -#include "SALOMEDS_AttributeReal_i.hxx" -#include "SALOMEDS_AttributeDrawable_i.hxx" -#include "SALOMEDS_AttributeSelectable_i.hxx" -#include "SALOMEDS_AttributeExpandable_i.hxx" -#include "SALOMEDS_AttributeOpened_i.hxx" -#include "SALOMEDS_AttributeTextColor_i.hxx" -#include "SALOMEDS_AttributeTextHighlightColor_i.hxx" -#include "SALOMEDS_AttributePixMap_i.hxx" -#include "SALOMEDS_AttributeTreeNode_i.hxx" -#include "SALOMEDS_AttributeLocalID_i.hxx" -#include "SALOMEDS_AttributeUserID_i.hxx" -#include "SALOMEDS_AttributeTarget_i.hxx" -#include "SALOMEDS_AttributeTableOfInteger_i.hxx" -#include "SALOMEDS_AttributeTableOfReal_i.hxx" -#include "SALOMEDS_AttributeTableOfString_i.hxx" -#include "SALOMEDS_AttributeStudyProperties_i.hxx" -#include "SALOMEDS_AttributePythonObject_i.hxx" #include -using namespace std; - -//============================================================================ -/*! Function : ReturnGUIDForAttribute - * Purpose : - */ -//============================================================================ - -Standard_GUID -SALOMEDS_SObject_i::ReturnGUIDForAttribute(const char* aTypeOfAttribute) -{ - Standard_GUID TypeID; - - if (strcmp(aTypeOfAttribute, "AttributeReal") == 0 ) return TDataStd_Real::GetID(); - else if (strcmp(aTypeOfAttribute, "AttributeInteger") == 0 ) return TDataStd_Integer::GetID(); - else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfReal") == 0 ) return SALOMEDS_SequenceOfRealAttribute::GetID(); - 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(); - else if (strcmp(aTypeOfAttribute, "AttributeSelectable") == 0 ) return SALOMEDS_SelectableAttribute::GetID(); - else if (strcmp(aTypeOfAttribute, "AttributeExpandable") == 0 ) return SALOMEDS_ExpandableAttribute::GetID(); - else if (strcmp(aTypeOfAttribute, "AttributeOpened") == 0 ) return SALOMEDS_OpenedAttribute::GetID(); - else if (strcmp(aTypeOfAttribute, "AttributeTextColor") == 0 ) return SALOMEDS_TextColorAttribute::GetID(); - else if (strcmp(aTypeOfAttribute, "AttributeTextHighlightColor") == 0 ) return SALOMEDS_TextHighlightColorAttribute::GetID(); - else if (strcmp(aTypeOfAttribute, "AttributePixMap") == 0 ) return SALOMEDS_PixMapAttribute::GetID(); - else if (strcmp(aTypeOfAttribute, "AttributeTreeNode") == 0 ) return TDataStd_TreeNode::GetDefaultTreeID(); - else if (strcmp(aTypeOfAttribute, "AttributeLocalID") == 0 ) return SALOMEDS_LocalIDAttribute::GetID(); - else if (strcmp(aTypeOfAttribute, "AttributeTarget") == 0 ) return SALOMEDS_TargetAttribute::GetID(); - else if (strcmp(aTypeOfAttribute, "AttributeTableOfInteger") == 0 ) return SALOMEDS_TableOfIntegerAttribute::GetID(); - else if (strcmp(aTypeOfAttribute, "AttributeTableOfReal") == 0 ) return SALOMEDS_TableOfRealAttribute::GetID(); - else if (strcmp(aTypeOfAttribute, "AttributeTableOfString") == 0 ) return SALOMEDS_TableOfStringAttribute::GetID(); - else if (strcmp(aTypeOfAttribute, "AttributeStudyProperties") == 0 ) return SALOMEDS_StudyPropertiesAttribute::GetID(); - else if (strcmp(aTypeOfAttribute, "AttributePythonObject") == 0 ) return SALOMEDS_PythonObjectAttribute::GetID(); - else if (strcmp(aTypeOfAttribute, "AttributeUserID") == 0 ) return SALOMEDS_AttributeUserID_i::DefaultID(); - else if (strncmp(aTypeOfAttribute,"AttributeTreeNodeGUID",21) == 0) { - char* aGUIDString = new char[40]; - sprintf(aGUIDString, &(aTypeOfAttribute[21])); - Standard_GUID aGUID = Standard_GUID(aGUIDString); // create tree node GUID by name - delete(aGUIDString); - return aGUID; - } - else Standard_NoSuchObject::Raise("SALOMEDS_SObject_i::ReturnGUIDForAttribute"); -} - -//============================================================================ -/*! Function : AttributeIDToType - * Purpose : - */ -//============================================================================ -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"; - else if (ID == TDataStd_Integer::GetID()) return "AttributeInteger"; - else if (ID == SALOMEDS_SequenceOfRealAttribute::GetID()) return "AttributeSequenceOfReal"; - else if (ID == SALOMEDS_SequenceOfIntegerAttribute::GetID()) return "AttributeSequenceOfInteger"; - else if (ID == SALOMEDS_DrawableAttribute::GetID()) return "AttributeDrawable"; - else if (ID == SALOMEDS_SelectableAttribute::GetID()) return "AttributeSelectable"; - else if (ID == SALOMEDS_ExpandableAttribute::GetID()) return "AttributeExpandable"; - else if (ID == SALOMEDS_OpenedAttribute::GetID()) return "AttributeOpened"; - else if (ID == SALOMEDS_TextColorAttribute::GetID()) return "AttributeTextColor"; - else if (ID == SALOMEDS_TextHighlightColorAttribute::GetID()) return "AttributeTextHighlightColor"; - else if (ID == SALOMEDS_PixMapAttribute::GetID()) return "AttributePixMap"; - else if (ID == TDataStd_TreeNode::GetDefaultTreeID()) return "AttributeTreeNode"; - else if (ID == SALOMEDS_LocalIDAttribute::GetID()) return "AttributeLocalID"; - else if (ID == SALOMEDS_TargetAttribute::GetID()) return "AttributeTarget"; - else if (ID == SALOMEDS_TableOfIntegerAttribute::GetID()) return "AttributeTableOfInteger"; - else if (ID == SALOMEDS_TableOfRealAttribute::GetID()) return "AttributeTableOfReal"; - else if (ID == SALOMEDS_TableOfStringAttribute::GetID()) return "AttributeTableOfString"; - else if (ID == SALOMEDS_StudyPropertiesAttribute::GetID()) return "AttributeStudyProperties"; - else if (ID == SALOMEDS_PythonObjectAttribute::GetID()) return "AttributePythonObject"; - else if (ID == SALOMEDS_AttributeUserID_i::DefaultID()) return "AttributeUserID"; - // 08.01.2003 mpv: this method must be called only for attributes with constant GUID - else Standard_NoSuchObject::Raise("SALOMEDS_SObject_i::AttributeIDToType"); -} - //============================================================================ /*! Function : constructor @@ -244,7 +125,7 @@ SALOMEDS::Study_ptr SALOMEDS_SObject_i::GetStudy() ASSERT(!CORBA::is_nil(Study)); return SALOMEDS::Study::_duplicate(Study); //return Study = abort... } - INFOS("Problem GetStudy"); + MESSAGE("Problem GetStudy"); return SALOMEDS::Study::_nil(); } @@ -257,139 +138,11 @@ CORBA::Boolean SALOMEDS_SObject_i::FindAttribute (SALOMEDS::GenericAttribute_out const char* aTypeOfAttribute) { Handle(TDF_Attribute) anAttr; - Standard_Boolean found = _lab.FindAttribute(SALOMEDS_SObject_i::ReturnGUIDForAttribute(aTypeOfAttribute), anAttr); - if (found) { - if (strcmp(aTypeOfAttribute, "AttributeReal") == 0 ) { - SALOMEDS_AttributeReal_i* Attr = new SALOMEDS_AttributeReal_i(Handle(TDataStd_Real)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeReal::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeInteger") == 0 ) { - SALOMEDS_AttributeInteger_i* Attr = new SALOMEDS_AttributeInteger_i(Handle(TDataStd_Integer)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeInteger::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfReal") == 0 ) { - SALOMEDS_AttributeSequenceOfReal_i* Attr = new SALOMEDS_AttributeSequenceOfReal_i(Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeSequenceOfReal::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfInteger") == 0 ) { - SALOMEDS_AttributeSequenceOfInteger_i* Attr = new SALOMEDS_AttributeSequenceOfInteger_i(Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeSequenceOfInteger::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeName") == 0 ) { - SALOMEDS_AttributeName_i* Attr = new SALOMEDS_AttributeName_i(Handle(TDataStd_Name)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeName::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeComment") == 0 ) { - SALOMEDS_AttributeComment_i* Attr = new SALOMEDS_AttributeComment_i(Handle(TDataStd_Comment)::DownCast(anAttr), _orb); - 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(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributePersistentRef") == 0 ) { - SALOMEDS_AttributePersistentRef_i* Attr = new SALOMEDS_AttributePersistentRef_i(Handle(SALOMEDS_PersRefAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributePersistentRef::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeDrawable") == 0 ) { - SALOMEDS_AttributeDrawable_i* Attr = new SALOMEDS_AttributeDrawable_i(Handle(SALOMEDS_DrawableAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeDrawable::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeSelectable") == 0 ) { - SALOMEDS_AttributeSelectable_i* Attr= new SALOMEDS_AttributeSelectable_i(Handle(SALOMEDS_SelectableAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeSelectable::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeExpandable") == 0 ) { - SALOMEDS_AttributeExpandable_i* Attr = new SALOMEDS_AttributeExpandable_i(Handle(SALOMEDS_ExpandableAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeExpandable::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeOpened") == 0 ) { - SALOMEDS_AttributeOpened_i* Attr= new SALOMEDS_AttributeOpened_i(Handle(SALOMEDS_OpenedAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeOpened::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTextColor") == 0 ) { - SALOMEDS_AttributeTextColor_i* Attr= new SALOMEDS_AttributeTextColor_i(Handle(SALOMEDS_TextColorAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTextColor::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTextHighlightColor") == 0 ) { - SALOMEDS_AttributeTextHighlightColor_i* Attr= new SALOMEDS_AttributeTextHighlightColor_i(Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTextHighlightColor::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributePixMap") == 0 ) { - SALOMEDS_AttributePixMap_i* Attr= new SALOMEDS_AttributePixMap_i(Handle(SALOMEDS_PixMapAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributePixMap::_this(); - return Standard_True; - } - else if (strncmp(aTypeOfAttribute, "AttributeTreeNode",17) == 0 ) { - SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTreeNode::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeLocalID") == 0 ) { - SALOMEDS_AttributeLocalID_i* Attr= new SALOMEDS_AttributeLocalID_i(Handle(SALOMEDS_LocalIDAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeLocalID::_this(); - return Standard_True; - } - else if (strncmp(aTypeOfAttribute, "AttributeUserID",15) == 0 ) { - SALOMEDS_AttributeUserID_i* Attr= new SALOMEDS_AttributeUserID_i(Handle(TDataStd_UAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeUserID::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTarget") == 0 ) { - SALOMEDS_AttributeTarget_i* Attr= new SALOMEDS_AttributeTarget_i(Handle(SALOMEDS_TargetAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTarget::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTableOfInteger") == 0 ) { - SALOMEDS_AttributeTableOfInteger_i* Attr = new SALOMEDS_AttributeTableOfInteger_i(Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTableOfInteger::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTableOfReal") == 0 ) { - SALOMEDS_AttributeTableOfReal_i* Attr = new SALOMEDS_AttributeTableOfReal_i(Handle(SALOMEDS_TableOfRealAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTableOfReal::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTableOfString") == 0 ) { - SALOMEDS_AttributeTableOfString_i* Attr = new SALOMEDS_AttributeTableOfString_i(Handle(SALOMEDS_TableOfStringAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTableOfString::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeStudyProperties") == 0 ) { - SALOMEDS_AttributeStudyProperties_i* Attr = new SALOMEDS_AttributeStudyProperties_i(Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeStudyProperties::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributePythonObject") == 0 ) { - SALOMEDS_AttributePythonObject_i* Attr = new SALOMEDS_AttributePythonObject_i(Handle(SALOMEDS_PythonObjectAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributePythonObject::_this(); - return Standard_True; - } - } else return Standard_False; + if (_lab.FindAttribute(SALOMEDS_GenericAttribute_i::GetGUID(aTypeOfAttribute), anAttr)) { + anAttribute = SALOMEDS::GenericAttribute::_duplicate(SALOMEDS_GenericAttribute_i::CreateAttribute(_orb, anAttr)); + return Standard_True; + } + return Standard_False; } //============================================================================ @@ -402,126 +155,16 @@ SALOMEDS::ListOfAttributes* SALOMEDS_SObject_i::GetAllAttributes() { Standard_Integer NumAttr = _lab.NbAttributes(); SALOMEDS::ListOfAttributes_var SeqOfAttr = new SALOMEDS::ListOfAttributes; - SeqOfAttr->length(NumAttr); + //SeqOfAttr->length(NumAttr); if (NumAttr != 0) { Standard_Integer i = 0; for(TDF_AttributeIterator iter(_lab);iter.More();iter.Next()) { Handle(TDF_Attribute) anAttr = iter.Value(); - SALOMEDS::GenericAttribute_var anAttribute; - if (ReturnGUIDForAttribute("AttributeReal") == anAttr->ID()) { - SALOMEDS_AttributeReal_i* Attr= new SALOMEDS_AttributeReal_i(Handle(TDataStd_Real)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeReal::_this(); - } - else if (ReturnGUIDForAttribute("AttributeInteger") == anAttr->ID()) { - SALOMEDS_AttributeInteger_i* Attr= new SALOMEDS_AttributeInteger_i(Handle(TDataStd_Integer)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeInteger::_this(); - } - else if (ReturnGUIDForAttribute("AttributeSequenceOfReal") == anAttr->ID()) { - SALOMEDS_AttributeSequenceOfReal_i* Attr= new SALOMEDS_AttributeSequenceOfReal_i(Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeSequenceOfReal::_this(); - } - else if (ReturnGUIDForAttribute("AttributeSequenceOfInteger") == anAttr->ID()) { - SALOMEDS_AttributeSequenceOfInteger_i* Attr= new SALOMEDS_AttributeSequenceOfInteger_i(Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeSequenceOfInteger::_this(); - } - else if (ReturnGUIDForAttribute("AttributeName") == anAttr->ID()) { - SALOMEDS_AttributeName_i* Attr= new SALOMEDS_AttributeName_i(Handle(TDataStd_Name)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeName::_this(); - } - else if (ReturnGUIDForAttribute("AttributeComment") == anAttr->ID()) { - 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(); - } - else if (ReturnGUIDForAttribute("AttributePersistentRef") == anAttr->ID()) { - SALOMEDS_AttributePersistentRef_i* Attr= new SALOMEDS_AttributePersistentRef_i(Handle(SALOMEDS_PersRefAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributePersistentRef::_this(); + SALOMEDS::GenericAttribute_var anAttribute = SALOMEDS_GenericAttribute_i::CreateAttribute(_orb, anAttr); + if (!CORBA::is_nil(anAttribute)) { + SeqOfAttr->length(++i); + SeqOfAttr[i - 1] = anAttribute; } - else if (ReturnGUIDForAttribute("AttributeDrawable") == anAttr->ID()) { - SALOMEDS_AttributeDrawable_i* Attr= new SALOMEDS_AttributeDrawable_i(Handle(SALOMEDS_DrawableAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeDrawable::_this(); - } - else if (ReturnGUIDForAttribute("AttributeSelectable") == anAttr->ID()) { - SALOMEDS_AttributeSelectable_i* Attr= new SALOMEDS_AttributeSelectable_i(Handle(SALOMEDS_SelectableAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeSelectable::_this(); - } - else if (ReturnGUIDForAttribute("AttributeExpandable") == anAttr->ID()) { - SALOMEDS_AttributeExpandable_i* Attr= new SALOMEDS_AttributeExpandable_i(Handle(SALOMEDS_ExpandableAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeExpandable::_this(); - } - else if (ReturnGUIDForAttribute("AttributeOpened") == anAttr->ID()) { - SALOMEDS_AttributeOpened_i* Attr= new SALOMEDS_AttributeOpened_i(Handle(SALOMEDS_OpenedAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeOpened::_this(); - } - else if (ReturnGUIDForAttribute("AttributeTextColor") == anAttr->ID()) { - SALOMEDS_AttributeTextColor_i* Attr= new SALOMEDS_AttributeTextColor_i(Handle(SALOMEDS_TextColorAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTextColor::_this(); - } - else if (ReturnGUIDForAttribute("AttributeTextHighlightColor") == anAttr->ID()) { - SALOMEDS_AttributeTextHighlightColor_i* Attr= new SALOMEDS_AttributeTextHighlightColor_i(Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTextHighlightColor::_this(); - } - else if (ReturnGUIDForAttribute("AttributePixMap") == anAttr->ID()) { - SALOMEDS_AttributePixMap_i* Attr= new SALOMEDS_AttributePixMap_i(Handle(SALOMEDS_PixMapAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributePixMap::_this(); - } - else if (ReturnGUIDForAttribute("AttributeTreeNode") == anAttr->ID()) { - SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTreeNode::_this(); - } - else if (ReturnGUIDForAttribute("AttributeLocalID") == anAttr->ID()) { - SALOMEDS_AttributeLocalID_i* Attr= new SALOMEDS_AttributeLocalID_i(Handle(SALOMEDS_LocalIDAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeLocalID::_this(); - } - else if (ReturnGUIDForAttribute("AttributeTarget") == anAttr->ID()) { - SALOMEDS_AttributeTarget_i* Attr= new SALOMEDS_AttributeTarget_i(Handle(SALOMEDS_TargetAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTarget::_this(); - } - else if (ReturnGUIDForAttribute("AttributeTableOfInteger") == anAttr->ID()) { - SALOMEDS_AttributeTableOfInteger_i* Attr= new SALOMEDS_AttributeTableOfInteger_i(Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTableOfInteger::_this(); - } - else if (ReturnGUIDForAttribute("AttributeTableOfReal") == anAttr->ID()) { - SALOMEDS_AttributeTableOfReal_i* Attr= new SALOMEDS_AttributeTableOfReal_i(Handle(SALOMEDS_TableOfRealAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTableOfReal::_this(); - } - else if (ReturnGUIDForAttribute("AttributeTableOfString") == anAttr->ID()) { - SALOMEDS_AttributeTableOfString_i* Attr= new SALOMEDS_AttributeTableOfString_i(Handle(SALOMEDS_TableOfStringAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTableOfString::_this(); - } - else if (ReturnGUIDForAttribute("AttributeStudyProperties") == anAttr->ID()) { - SALOMEDS_AttributeStudyProperties_i* Attr= new SALOMEDS_AttributeStudyProperties_i(Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeStudyProperties::_this(); - } - else if (ReturnGUIDForAttribute("AttributePythonObject") == anAttr->ID()) { - SALOMEDS_AttributePythonObject_i* Attr= new SALOMEDS_AttributePythonObject_i(Handle(SALOMEDS_PythonObjectAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributePythonObject::_this(); - } - else if (!Handle(TDataStd_UAttribute)::DownCast(anAttr).IsNull()) { - SALOMEDS_AttributeUserID_i* Attr= new SALOMEDS_AttributeUserID_i(Handle(TDataStd_UAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeUserID::_this(); - } - else if (!Handle(TDataStd_TreeNode)::DownCast(anAttr).IsNull()) { - SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTreeNode::_this(); - } else { - // references attributes, for an example, never returns - continue; - } - - SeqOfAttr[i] = anAttribute; - i++; } } return SeqOfAttr._retn(); @@ -549,7 +192,7 @@ CORBA::Boolean SALOMEDS_SObject_i::ReferencedObject(SALOMEDS::SObject_out obj) * Purpose : */ //============================================================================ -CORBA::Boolean SALOMEDS_SObject_i::FindSubObject(CORBA::Long atag, SALOMEDS::SObject_out obj) +CORBA::Boolean SALOMEDS_SObject_i::FindSubObject(long atag, SALOMEDS::SObject_out obj) { TDF_Label L = _lab.FindChild(atag,false); if (L.IsNull()) return false; @@ -589,3 +232,64 @@ CORBA::Short SALOMEDS_SObject_i::Tag() { return _lab.Tag(); } + +//============================================================================ +/*! Function : + * Purpose : + */ +//============================================================================ +CORBA::Object_ptr SALOMEDS_SObject_i::GetObject() +{ + CORBA::Object_ptr obj = CORBA::Object::_nil(); + try { + Handle(SALOMEDS_IORAttribute) Att; + if (_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(),Att)) { + TCollection_AsciiString ch(Att->Get()); + char* IOR = CORBA::string_dup(ch.ToCString()); + obj = _orb->string_to_object(IOR); + } + } catch(...) {} + return obj; +} + +//============================================================================ +/*! Function : + * Purpose : + */ +//============================================================================ +char* SALOMEDS_SObject_i::GetName() { + CORBA::String_var aStr = CORBA::string_dup( "" ); + Handle(TDataStd_Name) aName; + if (_lab.FindAttribute(TDataStd_Name::GetID(), aName)) { + aStr = CORBA::string_dup(TCollection_AsciiString(aName->Get()).ToCString()); + } + return aStr._retn(); +} + +//============================================================================ +/*! Function : + * Purpose : + */ +//============================================================================ +char* SALOMEDS_SObject_i::GetComment() { + CORBA::String_var aStr = CORBA::string_dup( "" ); + Handle(TDataStd_Comment) aComment; + if (_lab.FindAttribute(TDataStd_Comment::GetID(), aComment)) { + aStr = CORBA::string_dup(TCollection_AsciiString(aComment->Get()).ToCString()); + } + return aStr._retn(); +} + +//============================================================================ +/*! Function : + * Purpose : + */ +//============================================================================ +char* SALOMEDS_SObject_i::GetIOR() { + CORBA::String_var aStr = CORBA::string_dup( "" ); + Handle(SALOMEDS_IORAttribute) anIOR; + if (_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anIOR)) { + aStr = CORBA::string_dup(TCollection_AsciiString(anIOR->Get()).ToCString()); + } + return aStr._retn(); +} diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.hxx b/src/SALOMEDS/SALOMEDS_SObject_i.hxx index cd6944c55..fa0fa58dc 100644 --- a/src/SALOMEDS/SALOMEDS_SObject_i.hxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.hxx @@ -30,7 +30,7 @@ #define __SALOMEDS_SOBJECT_I_H__ // std C++ headers -#include +#include #include #include @@ -60,7 +60,7 @@ protected: char* _name; char* _value; char* _type; - std::vector _liste_ba_type; + vector _liste_ba_type; public: @@ -73,19 +73,23 @@ public: virtual SALOMEDS::SObject_ptr GetFather() ; virtual CORBA::Boolean FindAttribute(SALOMEDS::GenericAttribute_out anAttribute, const char* aTypeOfAttribute); virtual CORBA::Boolean ReferencedObject(SALOMEDS::SObject_out obj) ; - virtual CORBA::Boolean FindSubObject(CORBA::Long atag, SALOMEDS::SObject_out obj ); + virtual CORBA::Boolean FindSubObject(long atag, SALOMEDS::SObject_out obj ); virtual SALOMEDS::Study_ptr GetStudy() ; virtual char* Name(); virtual void Name(const char*); virtual SALOMEDS::ListOfAttributes* GetAllAttributes(); + virtual CORBA::Object_ptr GetObject(); + + virtual char* GetName(); + virtual char* GetComment(); + virtual char* GetIOR(); virtual CORBA::Short Tag(); static char* AttributeIDToType(Standard_GUID); static Standard_GUID ReturnGUIDForAttribute(const char* aTypeOfAttribute); - }; #endif diff --git a/src/SALOMEDS/SALOMEDS_SelectableAttribute.cxx b/src/SALOMEDS/SALOMEDS_SelectableAttribute.cxx index aef7ac1bd..40b179eca 100644 --- a/src/SALOMEDS/SALOMEDS_SelectableAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_SelectableAttribute.cxx @@ -24,11 +24,11 @@ // File : SALOMEDS_SelectableAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ +using namespace std; #include "SALOMEDS_SelectableAttribute.ixx" #include -using namespace std; //======================================================================= //function : GetID diff --git a/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.cxx b/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.cxx index 30c1cf93a..ed256eb0a 100644 --- a/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.cxx @@ -24,10 +24,10 @@ // File : SALOMEDS_SequenceOfIntegerAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ -#include "SALOMEDS_SequenceOfIntegerAttribute.ixx" using namespace std; +#include "SALOMEDS_SequenceOfIntegerAttribute.ixx" //======================================================================= //function : GetID diff --git a/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.cxx b/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.cxx index 9cd839f05..9c8d3516d 100644 --- a/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.cxx @@ -24,11 +24,11 @@ // File : SALOMEDS_SequenceOfRealAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ +using namespace std; #include "SALOMEDS_SequenceOfRealAttribute.ixx" #include -using namespace std; //======================================================================= //function : GetID diff --git a/src/SALOMEDS/SALOMEDS_Server.cxx b/src/SALOMEDS/SALOMEDS_Server.cxx index 1ed30a91e..11be22065 100644 --- a/src/SALOMEDS/SALOMEDS_Server.cxx +++ b/src/SALOMEDS/SALOMEDS_Server.cxx @@ -129,7 +129,8 @@ int main(int argc, char** argv) } } } - } + + } catch( const SALOME_Exception &ex ) { MESSAGE( "Communication Error : " << ex.what() ); diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx index 5357fe6c9..64eba6c88 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "utilities.h" #include "SALOMEDS_Study_i.hxx" //#include "SALOMEDS_StudyBuilder_i.hxx" @@ -37,11 +38,14 @@ #include "SALOMEDS_TargetAttribute.hxx" #include "SALOMEDS_StudyPropertiesAttribute.hxx" #include "SALOMEDS_PythonObjectAttribute.hxx" +#include "SALOMEDS_ExternalFileDef.hxx" +#include "SALOMEDS_FileType.hxx" #include #include #include #include #include +#include #include #include #include @@ -49,9 +53,9 @@ #include #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_AttributeComment_i.hxx" #include "SALOMEDS_AttributeName_i.hxx" #include "SALOMEDS_AttributeSequenceOfInteger_i.hxx" #include "SALOMEDS_AttributeSequenceOfReal_i.hxx" @@ -75,15 +79,17 @@ #include "SALOMEDS_AttributePythonObject_i.hxx" #include "SALOMEDS_Tool.hxx" #include "Utils_CorbaException.hxx" +#include "Utils_ExceptHandlers.hxx" #include #include -using namespace std; #define USE_CASE_LABEL_TAG 2 #define DIRECTORYID 16661 #define FILELOCALID 26662 +UNEXPECT_CATCH(SBSalomeException, SALOME::SALOME_Exception); +UNEXPECT_CATCH(SBLockProtection, SALOMEDS::StudyBuilder::LockProtection); //============================================================================ /*! Function : constructor * Purpose : @@ -126,8 +132,8 @@ SALOMEDS_StudyBuilder_i::NewComponent(const char* DataType) imax++; TDF_Label NL = L.FindChild(imax); -// TDataStd_Comment::Set(NL,Standard_CString(DataType)); - TDataStd_Comment::Set(NL,Standard_CString(strdup(DataType))); + TDataStd_Comment::Set(NL,Standard_CString(DataType)); + // TDataStd_Comment::Set(NL,Standard_CString(CORBA::string_dup(DataType))); SALOMEDS_SComponent_i * so_servant = new SALOMEDS_SComponent_i (NL,_orb); SALOMEDS::SComponent_var so; @@ -151,12 +157,12 @@ void SALOMEDS_StudyBuilder_i::DefineComponentInstance(SALOMEDS::SComponent_ptr a TDF_Label Lab; ASSERT(!CORBA::is_nil(aComponent)); CORBA::String_var compid = aComponent->GetID(); - TDF_Tool::Label(_doc->GetData(),strdup(compid),Lab); + TDF_Tool::Label(_doc->GetData(),compid,Lab); //add IOR definition ASSERT(!CORBA::is_nil(IOR)); CORBA::String_var iorstr = _orb->object_to_string(IOR); - SALOMEDS_IORAttribute::Set(Lab,strdup(iorstr),_orb); + SALOMEDS_IORAttribute::Set(Lab,(char*)iorstr,_orb); } @@ -189,7 +195,7 @@ SALOMEDS_StudyBuilder_i::NewObject(SALOMEDS::SObject_ptr theFatherObject) ASSERT(!CORBA::is_nil(theFatherObject)); CORBA::String_var fatherid = theFatherObject->GetID(); - TDF_Tool::Label(_doc->GetData(),strdup(fatherid),Lab); + TDF_Tool::Label(_doc->GetData(),fatherid,Lab); //Create a new label //YFR DEBUG : 13/02/2002 TDF_Label NewLab = Lab.NewChild(); @@ -224,7 +230,7 @@ SALOMEDS_StudyBuilder_i::NewObjectToTag(SALOMEDS::SObject_ptr theFatherObject, ASSERT(!CORBA::is_nil(theFatherObject)); CORBA::String_var fatherid = theFatherObject->GetID(); - TDF_Tool::Label(_doc->GetData(),strdup(fatherid),Lab); + TDF_Tool::Label(_doc->GetData(),fatherid,Lab); //Create or find label TDF_Label NewLab = Lab.FindChild(atag,1); @@ -259,7 +265,7 @@ void SALOMEDS_StudyBuilder_i::RemoveObject(SALOMEDS::SObject_ptr anObject) 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())); + SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString()); Lab.ForgetAllAttributes(); } @@ -286,9 +292,9 @@ void SALOMEDS_StudyBuilder_i::RemoveObjectWithChildren(SALOMEDS::SObject_ptr anO } 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())); + SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString()); - TDF_ChildIterator it(Lab); + TDF_ChildIterator it(Lab, Standard_True); for(;it.More();it.Next()) { TDF_Label aLabel = it.Value(); if (aLabel.FindAttribute(TDF_Reference::GetID(), aReference)) { @@ -298,7 +304,7 @@ void SALOMEDS_StudyBuilder_i::RemoveObjectWithChildren(SALOMEDS::SObject_ptr anO } 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())); + SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString()); } Lab.ForgetAllAttributes(Standard_True); @@ -337,7 +343,7 @@ static void Translate_persistentID_to_IOR(TDF_Label Lab, CORBA::String_var ior_string = driver->LocalPersistentIDToIOR(so, persistent_string, isMultiFile, isASCII); - TCollection_ExtendedString value(strdup(ior_string )); + TCollection_ExtendedString value(ior_string); SALOMEDS_IORAttribute::Set (current,value,orb); //TCollection_AsciiString anEntry;TDF_Tool::Entry (current,anEntry); //SRN: No use here @@ -358,17 +364,18 @@ static void Translate_persistentID_to_IOR(TDF_Label Lab, void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, SALOMEDS::Driver_ptr aDriver) throw(SALOME::SALOME_Exception) { + Unexpect aCatch(SBSalomeException); TDF_Label Lab; ASSERT(!CORBA::is_nil(anSCO)); CORBA::String_var scoid = anSCO->GetID(); - TDF_Tool::Label(_doc->GetData(),strdup(scoid),Lab); + TDF_Tool::Label(_doc->GetData(),scoid,Lab); Handle(TDF_Attribute) Att; - + //Find the current Url of the study if (_doc->Main().FindAttribute(SALOMEDS_PersRefAttribute::GetID(),Att)) { int aLocked = anSCO->GetStudy()->GetProperties()->IsLocked(); if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(false); - + TCollection_ExtendedString Res = Handle(TDataStd_Comment)::DownCast(Att)->Get(); Handle(TDataStd_Comment) type; @@ -377,7 +384,7 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, DataType = type->Get(); else MESSAGE("No Data Type"); - + // associate the driver to the SComponent ASSERT(!CORBA::is_nil(aDriver)); // mpv 06.03.2003: SAL1927 - if component data if already loaded, it is not necessary to do it again @@ -386,9 +393,9 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, return; } DefineComponentInstance (anSCO, aDriver); - + TCollection_AsciiString aHDFPath(Res); - + char* aHDFUrl; bool isASCII = false; if (HDFascii::isASCII(aHDFPath.ToCString())) { @@ -398,12 +405,12 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, sprintf(aHDFUrl, "%shdf_from_ascii.hdf", aResultPath); delete(aResultPath); } else { - aHDFUrl = strdup(aHDFPath.ToCString()); + aHDFUrl = CORBA::string_dup(aHDFPath.ToCString()); } //Open the Study HDF file HDFfile *hdf_file = new HDFfile(aHDFUrl); - + char aMultifileState[2]; char ASCIIfileState[2]; try { @@ -413,7 +420,7 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, hdf_group->OpenOnDisk(); HDFgroup *hdf_sco_group = new HDFgroup(scoid, hdf_group); hdf_sco_group->OpenOnDisk(); - + SALOMEDS::TMPFile_var aStreamFile; if (hdf_sco_group->ExistInternalObject("FILE_STREAM")) { HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group); @@ -430,11 +437,11 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, HDFdataset *multifile_hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group); multifile_hdf_dataset->OpenOnDisk(); multifile_hdf_dataset->ReadFromDisk(aMultifileState); - + HDFdataset *ascii_hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group); ascii_hdf_dataset->OpenOnDisk(); ascii_hdf_dataset->ReadFromDisk(ASCIIfileState); - + // set path without file name from URL int aFileNameSize = Res.Length(); char* aDir = new char[aFileNameSize]; @@ -444,24 +451,24 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, aDir[aCounter+1] = 0; break; } - + CORBA::Boolean aResult = (ASCIIfileState[0]=='A')? aDriver->LoadASCII(anSCO, aStreamFile.in(), aDir, aMultifileState[0]=='M'): - aDriver->Load(anSCO, aStreamFile.in(), aDir, aMultifileState[0]=='M'); + aDriver->Load(anSCO, aStreamFile.in(), aDir, aMultifileState[0]=='M'); if(!aResult) { RemoveAttribute( anSCO, "AttributeIOR" ); if (isASCII) { SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames; aFilesToRemove->length(1); - aFilesToRemove[0] = strdup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))])); + aFilesToRemove[0] = CORBA::string_dup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))])); SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true); } delete aHDFUrl; MESSAGE("Can't load component"); THROW_SALOME_CORBA_EXCEPTION("Unable to load component data",SALOME::BAD_PARAM); -// throw HDFexception("Unable to load component"); + // throw HDFexception("Unable to load component"); } - + delete(aDir); multifile_hdf_dataset->CloseOnDisk(); @@ -474,22 +481,22 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, hdf_group = 0; hdf_file->CloseOnDisk(); delete hdf_file; - + if (isASCII) { SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames; aFilesToRemove->length(1); - aFilesToRemove[0] = strdup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))])); + aFilesToRemove[0] = CORBA::string_dup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))])); SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true); } delete aHDFUrl; } catch (HDFexception) { - MESSAGE("No persistent file Name"); + INFOS("No persistent file Name"); delete hdf_file; if (isASCII) { SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames; aFilesToRemove->length(1); - aFilesToRemove[0] = strdup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))])); + aFilesToRemove[0] = CORBA::string_dup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))])); SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true); } delete aHDFUrl; @@ -500,10 +507,10 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, try { Translate_persistentID_to_IOR (Lab,aDriver,_orb, aMultifileState[0]=='M', ASCIIfileState[0] == 'A'); } catch (SALOME::SALOME_Exception) { - MESSAGE("Can't translate PersRef to IOR"); + INFOS("Can't translate PersRef to IOR"); if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true); THROW_SALOME_CORBA_EXCEPTION("Unable to convert component persistent data to the transient",SALOME::BAD_PARAM); -// throw HDFexception("Unable to load component data"); + // throw HDFexception("Unable to load component data"); } if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true); } else @@ -521,234 +528,54 @@ void SALOMEDS_StudyBuilder_i::Load(SALOMEDS::SObject_ptr sco) MESSAGE ( "This function is not yet implemented"); } -//============================================================================ -/*! Function : AddAttribute - * Purpose : - */ -//============================================================================ -/* -void SALOMEDS_StudyBuilder_i::AddAttribute(SALOMEDS::SObject_ptr anObject, - SALOMEDS::AttributeType aType, - const char * AttributeValue ) -{ - TDF_Label Lab; - ASSERT(!CORBA::is_nil(anObject)); - CORBA::String_var anobid = anObject->GetID(); - TDF_Tool::Label(_doc->GetData(),strdup(anobid),Lab); - - TCollection_ExtendedString Value(strdup(AttributeValue)); - - Standard_GUID ID = SALOMEDS_SObject_i::TypeToAttributeID(aType); - - if (ID == TDataStd_Name::GetID()) TDataStd_Name::Set (Lab,Value); - else if (ID == TDataStd_Comment::GetID()) TDataStd_Comment::Set (Lab,Value); - else if (ID == SALOMEDS_IORAttribute::GetID()) SALOMEDS_IORAttribute::Set (Lab,Value); - else if (ID == SALOMEDS_PersRefAttribute::GetID()) SALOMEDS_PersRefAttribute::Set(Lab,Value); -} -*/ //============================================================================ /*! Function : FindOrCreateAttribute * Purpose : Add attribute of given type to SObject, if there is attribute of such type, returns * existing one */ //============================================================================ - SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SALOMEDS::SObject_ptr anObject, const char* aTypeOfAttribute) { 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, "AttributeReal") == 0 ) { - Handle(TDataStd_Real) anAttr; - if (!Lab.FindAttribute(TDataStd_Real::GetID(), anAttr)) { - CheckLocked(); - anAttr = new TDataStd_Real; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeReal_i* aRealAttr = new SALOMEDS_AttributeReal_i(anAttr, _orb); - SALOMEDS::AttributeReal_var aRA = aRealAttr->AttributeReal::_this(); - return aRA._retn(); - } - 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); - } - SALOMEDS_AttributeInteger_i* aIntAttr = new SALOMEDS_AttributeInteger_i(anAttr, _orb); - SALOMEDS::AttributeInteger_var aIA = aIntAttr->AttributeInteger::_this(); - return aIA._retn(); - } - 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); - } - SALOMEDS_AttributeSequenceOfReal_i* aSeqRealAttr = new SALOMEDS_AttributeSequenceOfReal_i(anAttr, _orb); - SALOMEDS::AttributeSequenceOfReal_var aSRA = aSeqRealAttr->AttributeSequenceOfReal::_this(); - return aSRA._retn(); - } - 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); - } - SALOMEDS_AttributeSequenceOfInteger_i* aSeqIntegerAttr = new SALOMEDS_AttributeSequenceOfInteger_i(anAttr, _orb); - SALOMEDS::AttributeSequenceOfInteger_var aSIA = aSeqIntegerAttr->AttributeSequenceOfInteger::_this(); - return aSIA._retn(); - } - 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); - } - SALOMEDS_AttributeName_i* aNameAttr = new SALOMEDS_AttributeName_i(anAttr, _orb); - SALOMEDS::AttributeName_var aSNA = aNameAttr->AttributeName::_this(); - return aSNA._retn(); - } - 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); - } - SALOMEDS_AttributeComment_i* aCommentAttr = new SALOMEDS_AttributeComment_i(anAttr, _orb); - 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); - } - SALOMEDS_AttributeIOR_i* aIORAttr = new SALOMEDS_AttributeIOR_i(anAttr, _orb); - SALOMEDS::AttributeIOR_var aIA = aIORAttr->AttributeIOR::_this(); - return aIA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributePersistentRef") == 0 ) { - Handle(SALOMEDS_PersRefAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_PersRefAttribute::GetID(), anAttr)) { - anAttr = new SALOMEDS_PersRefAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributePersistentRef_i* aPerRefAttr = new SALOMEDS_AttributePersistentRef_i(anAttr, _orb); - SALOMEDS::AttributePersistentRef_var aPRA = aPerRefAttr->AttributePersistentRef::_this(); - return aPRA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeDrawable") == 0 ) { - Handle(SALOMEDS_DrawableAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_DrawableAttribute::GetID(), anAttr)) { - anAttr = new SALOMEDS_DrawableAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeDrawable_i* aDrawableAttr = new SALOMEDS_AttributeDrawable_i(anAttr, _orb); - SALOMEDS::AttributeDrawable_var aDrawA = aDrawableAttr->AttributeDrawable::_this(); - return aDrawA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeSelectable") == 0 ) { - Handle(SALOMEDS_SelectableAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_SelectableAttribute::GetID(), anAttr)) { - anAttr = new SALOMEDS_SelectableAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeSelectable_i* aSelectableAttr = new SALOMEDS_AttributeSelectable_i(anAttr, _orb); - SALOMEDS::AttributeSelectable_var aSelA = aSelectableAttr->AttributeSelectable::_this(); - return aSelA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeExpandable") == 0 ) { - Handle(SALOMEDS_ExpandableAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_ExpandableAttribute::GetID(), anAttr)) { - anAttr = new SALOMEDS_ExpandableAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeExpandable_i* aExpandableAttr = new SALOMEDS_AttributeExpandable_i(anAttr, _orb); - SALOMEDS::AttributeExpandable_var aExpA = aExpandableAttr->AttributeExpandable::_this(); - return aExpA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeOpened") == 0 ) { - Handle(SALOMEDS_OpenedAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_OpenedAttribute::GetID(), anAttr)) { - anAttr = new SALOMEDS_OpenedAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeOpened_i* aOpenedAttr = new SALOMEDS_AttributeOpened_i(anAttr, _orb); - SALOMEDS::AttributeOpened_var aOpenA = aOpenedAttr->AttributeOpened::_this(); - return aOpenA._retn(); - } - 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); - } - SALOMEDS_AttributeTextColor_i* aTextColorAttr = new SALOMEDS_AttributeTextColor_i(anAttr, _orb); - SALOMEDS::AttributeTextColor_var aTCA = aTextColorAttr->AttributeTextColor::_this(); - return aTCA._retn(); - } - 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); - } - SALOMEDS_AttributeTextHighlightColor_i* aTextHighlightColorAttr = new SALOMEDS_AttributeTextHighlightColor_i(anAttr, _orb); - SALOMEDS::AttributeTextHighlightColor_var aTHCA = aTextHighlightColorAttr->AttributeTextHighlightColor::_this(); - return aTHCA._retn(); - } - 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); - } - SALOMEDS_AttributePixMap_i* aPixMapAttr = new SALOMEDS_AttributePixMap_i(anAttr, _orb); - SALOMEDS::AttributePixMap_var aPMA = aPixMapAttr->AttributePixMap::_this(); - return aPMA._retn(); - } - else if (strncmp(aTypeOfAttribute, "AttributeTreeNode",17) == 0 ) { + TDF_Tool::Label(_doc->GetData(),anobid,Lab); + + __FindOrCreateAttributeLocked(TDataStd_Real, AttributeReal) + __FindOrCreateAttributeLocked(TDataStd_Integer, AttributeInteger) + __FindOrCreateAttributeLocked(SALOMEDS_SequenceOfRealAttribute, AttributeSequenceOfReal) + __FindOrCreateAttributeLocked(SALOMEDS_SequenceOfIntegerAttribute, AttributeSequenceOfInteger) + __FindOrCreateAttributeLocked(TDataStd_Name, AttributeName) + __FindOrCreateAttributeLocked(TDataStd_Comment, AttributeComment) + __FindOrCreateAttributeLocked(SALOMEDS_IORAttribute, AttributeIOR) + __FindOrCreateAttributeLocked(SALOMEDS_PixMapAttribute, AttributePixMap) + __FindOrCreateAttributeLocked(SALOMEDS_LocalIDAttribute, AttributeLocalID) + __FindOrCreateAttributeLocked(SALOMEDS_TableOfIntegerAttribute, AttributeTableOfInteger) + __FindOrCreateAttributeLocked(SALOMEDS_TableOfRealAttribute, AttributeTableOfReal) + __FindOrCreateAttributeLocked(SALOMEDS_TableOfStringAttribute, AttributeTableOfString) + __FindOrCreateAttributeLocked(SALOMEDS_PythonObjectAttribute, AttributePythonObject) + + __FindOrCreateAttribute(SALOMEDS_PersRefAttribute, AttributePersistentRef) + __FindOrCreateAttribute(SALOMEDS_DrawableAttribute, AttributeDrawable) + __FindOrCreateAttribute(SALOMEDS_SelectableAttribute, AttributeSelectable) + __FindOrCreateAttribute(SALOMEDS_ExpandableAttribute, AttributeExpandable) + __FindOrCreateAttribute(SALOMEDS_OpenedAttribute, AttributeOpened) + __FindOrCreateAttribute(SALOMEDS_TextColorAttribute, AttributeTextColor) + __FindOrCreateAttribute(SALOMEDS_TextHighlightColorAttribute, AttributeTextHighlightColor) + __FindOrCreateAttribute(SALOMEDS_TargetAttribute, AttributeTarget) + __FindOrCreateAttribute(SALOMEDS_StudyPropertiesAttribute, AttributeStudyProperties) + __FindOrCreateAttribute(SALOMEDS_ExternalFileDef, AttributeExternalFileDef) + __FindOrCreateAttribute(SALOMEDS_FileType, AttributeFileType) + + if (strncmp(aTypeOfAttribute, "AttributeTreeNode",17) == 0 ) { Standard_GUID aTreeNodeGUID; - if (strcmp(aTypeOfAttribute, "AttributeTreeNode") == 0) + if (strcmp(aTypeOfAttribute, "AttributeTreeNode") == 0) { aTreeNodeGUID = TDataStd_TreeNode::GetDefaultTreeID(); - else { + } else { char* aGUIDString = new char[40]; sprintf(aGUIDString, &(aTypeOfAttribute[21])); - Standard_GUID aGUID = Standard_GUID(aGUIDString); // create tree node GUID by name + aTreeNodeGUID = Standard_GUID(aGUIDString); // create tree node GUID by name delete(aGUIDString); } Handle(TDataStd_TreeNode) anAttr; @@ -757,98 +584,19 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA 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(); + return aTreeNodeAttr->AttributeTreeNode::_this(); } - else if (strncmp(aTypeOfAttribute, "AttributeUserID",15) == 0 ) { + + if (strncmp(aTypeOfAttribute, "AttributeUserID",15) == 0 ) { Handle(TDataStd_UAttribute) 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(); - } - 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); - } - SALOMEDS_AttributeLocalID_i* aLIDAttr = new SALOMEDS_AttributeLocalID_i(anAttr, _orb); - SALOMEDS::AttributeLocalID_var aLIDA = aLIDAttr->AttributeLocalID::_this(); - return aLIDA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeTarget") == 0 ) { - Handle(SALOMEDS_TargetAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_TargetAttribute::GetID(), anAttr)) { - anAttr = new SALOMEDS_TargetAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeTarget_i* aLIDAttr = new SALOMEDS_AttributeTarget_i(anAttr, _orb); - SALOMEDS::AttributeTarget_var aLIDA = aLIDAttr->AttributeTarget::_this(); - return aLIDA._retn(); - } - 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); - } - SALOMEDS_AttributeTableOfInteger_i* aTabIntegerAttr = new SALOMEDS_AttributeTableOfInteger_i(anAttr, _orb); - SALOMEDS::AttributeTableOfInteger_var aTIA = aTabIntegerAttr->AttributeTableOfInteger::_this(); - return aTIA._retn(); - } - 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); - } - SALOMEDS_AttributeTableOfReal_i* aTabRealAttr = new SALOMEDS_AttributeTableOfReal_i(anAttr, _orb); - SALOMEDS::AttributeTableOfReal_var aTRA = aTabRealAttr->AttributeTableOfReal::_this(); - return aTRA._retn(); - } - 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); - } - SALOMEDS_AttributeTableOfString_i* aTabStringAttr = new SALOMEDS_AttributeTableOfString_i(anAttr, _orb); - SALOMEDS::AttributeTableOfString_var aTRA = aTabStringAttr->AttributeTableOfString::_this(); - return aTRA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeStudyProperties") == 0 ) { - Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { - 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(); - return aSPA._retn(); - } - 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); - } - SALOMEDS_AttributePythonObject_i* aPObjAttr = new SALOMEDS_AttributePythonObject_i(anAttr, _orb); - SALOMEDS::AttributePythonObject_var aPOA = aPObjAttr->AttributePythonObject::_this(); - return aPOA._retn(); + return aUAttr->AttributeUserID::_this(); } + return SALOMEDS::GenericAttribute::_nil(); } //============================================================================ @@ -864,141 +612,13 @@ CORBA::Boolean SALOMEDS_StudyBuilder_i::FindAttribute(SALOMEDS::SObject_ptr anOb TDF_Label Lab; ASSERT(!CORBA::is_nil(anObject)); CORBA::String_var anobid = anObject->GetID(); - TDF_Tool::Label(_doc->GetData(),strdup(anobid),Lab); + TDF_Tool::Label(_doc->GetData(),anobid,Lab); Handle(TDF_Attribute) anAttr; - Standard_Boolean found = Lab.FindAttribute(SALOMEDS_SObject_i::ReturnGUIDForAttribute(aTypeOfAttribute), anAttr); - if (found) { - if (strcmp(aTypeOfAttribute, "AttributeReal") == 0 ) { - SALOMEDS_AttributeReal_i* Attr= new SALOMEDS_AttributeReal_i(Handle(TDataStd_Real)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeReal::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeInteger") == 0 ) { - SALOMEDS_AttributeInteger_i* Attr= new SALOMEDS_AttributeInteger_i(Handle(TDataStd_Integer)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeInteger::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfReal") == 0 ) { - SALOMEDS_AttributeSequenceOfReal_i* Attr= new SALOMEDS_AttributeSequenceOfReal_i(Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeSequenceOfReal::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfInteger") == 0 ) { - SALOMEDS_AttributeSequenceOfInteger_i* Attr= new SALOMEDS_AttributeSequenceOfInteger_i(Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeSequenceOfInteger::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeName") == 0 ) { - SALOMEDS_AttributeName_i* Attr= new SALOMEDS_AttributeName_i(Handle(TDataStd_Name)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeName::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeComment") == 0 ) { - SALOMEDS_AttributeComment_i* Attr= new SALOMEDS_AttributeComment_i(Handle(TDataStd_Comment)::DownCast(anAttr), _orb); - 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(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributePersistentRef") == 0 ) { - SALOMEDS_AttributePersistentRef_i* Attr= new SALOMEDS_AttributePersistentRef_i(Handle(SALOMEDS_PersRefAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributePersistentRef::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeDrawable") == 0 ) { - SALOMEDS_AttributeDrawable_i* Attr= new SALOMEDS_AttributeDrawable_i(Handle(SALOMEDS_DrawableAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeDrawable::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeSelectable") == 0 ) { - SALOMEDS_AttributeSelectable_i* Attr= new SALOMEDS_AttributeSelectable_i(Handle(SALOMEDS_SelectableAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeSelectable::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeExpandable") == 0 ) { - SALOMEDS_AttributeExpandable_i* Attr= new SALOMEDS_AttributeExpandable_i(Handle(SALOMEDS_ExpandableAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeExpandable::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeOpened") == 0 ) { - SALOMEDS_AttributeOpened_i* Attr= new SALOMEDS_AttributeOpened_i(Handle(SALOMEDS_OpenedAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeOpened::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTextColor") == 0 ) { - SALOMEDS_AttributeTextColor_i* Attr= new SALOMEDS_AttributeTextColor_i(Handle(SALOMEDS_TextColorAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTextColor::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTextHighlightColor") == 0 ) { - SALOMEDS_AttributeTextHighlightColor_i* Attr= new SALOMEDS_AttributeTextHighlightColor_i(Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTextHighlightColor::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributePixMap") == 0 ) { - SALOMEDS_AttributePixMap_i* Attr= new SALOMEDS_AttributePixMap_i(Handle(SALOMEDS_PixMapAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributePixMap::_this(); - return Standard_True; - } - else if (strncmp(aTypeOfAttribute, "AttributeTreeNode",17) == 0 ) { - SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTreeNode::_this(); - return Standard_True; - } - else if (strncmp(aTypeOfAttribute, "AttributeUserID",15) == 0 ) { - SALOMEDS_AttributeUserID_i* Attr= new SALOMEDS_AttributeUserID_i(Handle(TDataStd_UAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeUserID::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeLocalID") == 0 ) { - SALOMEDS_AttributeLocalID_i* Attr= new SALOMEDS_AttributeLocalID_i(Handle(SALOMEDS_LocalIDAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeLocalID::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTarget") == 0 ) { - SALOMEDS_AttributeTarget_i* Attr= new SALOMEDS_AttributeTarget_i(Handle(SALOMEDS_TargetAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTarget::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTableOfInteger") == 0 ) { - SALOMEDS_AttributeTableOfInteger_i* Attr= new SALOMEDS_AttributeTableOfInteger_i(Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTableOfInteger::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTableOfReal") == 0 ) { - SALOMEDS_AttributeTableOfReal_i* Attr= new SALOMEDS_AttributeTableOfReal_i(Handle(SALOMEDS_TableOfRealAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTableOfReal::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTableOfString") == 0 ) { - SALOMEDS_AttributeTableOfString_i* Attr= new SALOMEDS_AttributeTableOfString_i(Handle(SALOMEDS_TableOfStringAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTableOfString::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeStudyProperties") == 0 ) { - SALOMEDS_AttributeStudyProperties_i* Attr= new SALOMEDS_AttributeStudyProperties_i(Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeStudyProperties::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributePythonObject") == 0 ) { - SALOMEDS_AttributePythonObject_i* Attr= new SALOMEDS_AttributePythonObject_i(Handle(SALOMEDS_PythonObjectAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributePythonObject::_this(); - return Standard_True; - } - } else return Standard_False; + if (Lab.FindAttribute(SALOMEDS_GenericAttribute_i::GetGUID(aTypeOfAttribute), anAttr)) { + anAttribute = SALOMEDS::GenericAttribute::_duplicate(SALOMEDS_GenericAttribute_i::CreateAttribute(_orb, anAttr)); + return Standard_True; + } + return Standard_False; } //============================================================================ @@ -1014,16 +634,16 @@ void SALOMEDS_StudyBuilder_i::RemoveAttribute(SALOMEDS::SObject_ptr anObject, TDF_Label Lab; ASSERT(!CORBA::is_nil(anObject)); CORBA::String_var anobid = anObject->GetID(); - TDF_Tool::Label(_doc->GetData(),strdup(anobid),Lab); + TDF_Tool::Label(_doc->GetData(),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())); + SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString()); else return; } - Lab.ForgetAttribute (SALOMEDS_SObject_i::ReturnGUIDForAttribute(aTypeOfAttribute)); + Lab.ForgetAttribute (SALOMEDS_GenericAttribute_i::GetGUID(aTypeOfAttribute)); } //============================================================================ @@ -1039,18 +659,46 @@ SALOMEDS_StudyBuilder_i::Addreference(SALOMEDS::SObject_ptr me, TDF_Label Lab; ASSERT(!CORBA::is_nil(me)); CORBA::String_var meid = me->GetID(); - TDF_Tool::Label(_doc->GetData(),strdup(meid),Lab); + TDF_Tool::Label(_doc->GetData(),meid,Lab); TDF_Label RefLab; ASSERT(!CORBA::is_nil(theReferencedObject)); CORBA::String_var roid = theReferencedObject->GetID(); - TDF_Tool::Label(_doc->GetData(),strdup(roid),RefLab); + TDF_Tool::Label(_doc->GetData(),roid,RefLab); TDF_Reference::Set(Lab,RefLab); SALOMEDS_TargetAttribute::Set(RefLab)->Append(Lab); - if(!CORBA::is_nil(_callbackOnRemove)) _callbackOnRemove->OnRemoveSObject(me); + if(!CORBA::is_nil(_callbackOnRemove) && Lab.IsDescendant(_doc->Main())) _callbackOnRemove->OnRemoveSObject(me); } +//============================================================================ +/*! Function : RemoveReference + * Purpose : + */ +//============================================================================ +void SALOMEDS_StudyBuilder_i::RemoveReference(SALOMEDS::SObject_ptr me) +{ + SALOMEDS::SObject_var theReferencedObject; + if(!me->ReferencedObject(theReferencedObject)) return; //No reference is found + + CheckLocked(); + TDF_Label Lab; + ASSERT(!CORBA::is_nil(me)); + CORBA::String_var meid = me->GetID(); + TDF_Tool::Label(_doc->GetData(),meid,Lab); + + Lab.ForgetAttribute(TDF_Reference::GetID()); + + TDF_Label RefLab; + ASSERT(!CORBA::is_nil(theReferencedObject)); + CORBA::String_var roid = theReferencedObject->GetID(); + TDF_Tool::Label(_doc->GetData(),roid,RefLab); + + RemoveAttribute(theReferencedObject, "AttributeTarget"); + //if(!CORBA::is_nil(_callbackOnRemove) && Lab.IsDescendant(_doc->Main())) _callbackOnRemove->OnRemoveSObject(me); +} + + //============================================================================ /*! Function : AddDirectory @@ -1130,7 +778,7 @@ void SALOMEDS_StudyBuilder_i::SetGUID(SALOMEDS::SObject_ptr anObject, const char TDF_Label aLabel; ASSERT(!CORBA::is_nil(anObject)); CORBA::String_var anEntry = anObject->GetID(); - TDF_Tool::Label(_doc->GetData(), strdup(anEntry), aLabel); + TDF_Tool::Label(_doc->GetData(), anEntry, aLabel); TDataStd_UAttribute::Set(aLabel, (char*)theGUID); } @@ -1144,7 +792,7 @@ bool SALOMEDS_StudyBuilder_i::IsGUID(SALOMEDS::SObject_ptr anObject, const char* TDF_Label aLabel; ASSERT(!CORBA::is_nil(anObject)); CORBA::String_var anEntry = anObject->GetID(); - TDF_Tool::Label(_doc->GetData(), strdup(anEntry), aLabel); + TDF_Tool::Label(_doc->GetData(), anEntry, aLabel); return aLabel.IsAttribute((char*)theGUID); } @@ -1174,13 +822,14 @@ void SALOMEDS_StudyBuilder_i::NewCommand() //============================================================================ void SALOMEDS_StudyBuilder_i::CommitCommand() throw (SALOMEDS::StudyBuilder::LockProtection) { + Unexpect aCatch(SBLockProtection); Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { anAttr = new SALOMEDS_StudyPropertiesAttribute; _doc->Main().AddAttribute(anAttr); } if (anAttr->IsLocked() && !anAttr->IsLockChanged(true)) { - INFOS("Locked document modification !!!"); + MESSAGE("Locked document modification !!!"); AbortCommand(); throw SALOMEDS::StudyBuilder::LockProtection(); } else { @@ -1222,13 +871,14 @@ void SALOMEDS_StudyBuilder_i::AbortCommand() //============================================================================ void SALOMEDS_StudyBuilder_i::Undo() throw (SALOMEDS::StudyBuilder::LockProtection) { + Unexpect aCatch(SBLockProtection); Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { anAttr = new SALOMEDS_StudyPropertiesAttribute; _doc->Main().AddAttribute(anAttr); } if (anAttr->IsLocked()) { - INFOS("Locked document modification !!!"); + MESSAGE("Locked document modification !!!"); throw SALOMEDS::StudyBuilder::LockProtection(); } else { SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->UndoPostponed(1); @@ -1244,21 +894,22 @@ void SALOMEDS_StudyBuilder_i::Undo() throw (SALOMEDS::StudyBuilder::LockProtecti //============================================================================ void SALOMEDS_StudyBuilder_i::Redo() throw (SALOMEDS::StudyBuilder::LockProtection) { - Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; - if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { - anAttr = new SALOMEDS_StudyPropertiesAttribute; - _doc->Main().AddAttribute(anAttr); - } - + Unexpect aCatch(SBLockProtection); + Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; + if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_StudyPropertiesAttribute; + _doc->Main().AddAttribute(anAttr); + } + if (anAttr->IsLocked()) { - INFOS("Locked document modification !!!"); + MESSAGE("Locked document modification !!!"); throw SALOMEDS::StudyBuilder::LockProtection(); } else { _doc->Redo(); SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->UndoPostponed(-1); anAttr->SetModified(anAttr->GetModified()+1); } -} + } //============================================================================ /*! Function : GetAvailableUndos @@ -1325,12 +976,72 @@ SALOMEDS::Callback_ptr SALOMEDS_StudyBuilder_i::SetOnRemoveSObject(SALOMEDS::Cal return aRet; } +//============================================================================ +/*! Function : CheckLocked + * Purpose : + */ +//============================================================================ void SALOMEDS_StudyBuilder_i::CheckLocked() throw (SALOMEDS::StudyBuilder::LockProtection) { + Unexpect aCatch(SBLockProtection); 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(); } + +//============================================================================ +/*! Function : SetName + * Purpose : + */ +//============================================================================ +void SALOMEDS_StudyBuilder_i::SetName(SALOMEDS::SObject_ptr theSO, const char* theValue) + throw(SALOMEDS::StudyBuilder::LockProtection) +{ + Unexpect aCatch(SBLockProtection); + CheckLocked(); + //Find label + TDF_Label aLabel; + ASSERT(!CORBA::is_nil(theSO)); + CORBA::String_var aSOID = theSO->GetID(); + TDF_Tool::Label(_doc->GetData(), aSOID, aLabel); + TDataStd_Name::Set(aLabel, (char*)theValue); +} + +//============================================================================ +/*! Function : SetComment + * Purpose : + */ +//============================================================================ +void SALOMEDS_StudyBuilder_i::SetComment(SALOMEDS::SObject_ptr theSO, const char* theValue) + throw(SALOMEDS::StudyBuilder::LockProtection) +{ + Unexpect aCatch(SBLockProtection); + CheckLocked(); + //Find label + TDF_Label aLabel; + ASSERT(!CORBA::is_nil(theSO)); + CORBA::String_var aSOID = theSO->GetID(); + TDF_Tool::Label(_doc->GetData(), aSOID, aLabel); + TDataStd_Comment::Set(aLabel, (char*)theValue); +} + +//============================================================================ +/*! Function : SetIOR + * Purpose : + */ +//============================================================================ +void SALOMEDS_StudyBuilder_i::SetIOR(SALOMEDS::SObject_ptr theSO, const char* theValue) + throw(SALOMEDS::StudyBuilder::LockProtection) +{ + Unexpect aCatch(SBLockProtection); + CheckLocked(); + //Find label + TDF_Label aLabel; + ASSERT(!CORBA::is_nil(theSO)); + CORBA::String_var aSOID = theSO->GetID(); + TDF_Tool::Label(_doc->GetData(), aSOID, aLabel); + SALOMEDS_IORAttribute::Set(aLabel, TCollection_ExtendedString((char*)theValue), _orb); +} diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx index f282e4e97..2b51ac838 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx @@ -122,6 +122,8 @@ public: virtual void Addreference(SALOMEDS::SObject_ptr me, SALOMEDS::SObject_ptr thereferencedObject); + virtual void RemoveReference(SALOMEDS::SObject_ptr me); + virtual void SetGUID(SALOMEDS::SObject_ptr anObject, const char* theGUID); virtual bool IsGUID(SALOMEDS::SObject_ptr anObject, const char* theGUID); @@ -142,5 +144,9 @@ public: virtual SALOMEDS::Callback_ptr SetOnAddSObject(SALOMEDS::Callback_ptr theCallback); virtual SALOMEDS::Callback_ptr SetOnRemoveSObject(SALOMEDS::Callback_ptr theCallback); + + virtual void SetName(SALOMEDS::SObject_ptr theSO, const char* theValue) throw(SALOMEDS::StudyBuilder::LockProtection); + virtual void SetComment(SALOMEDS::SObject_ptr theSO, const char* theValue) throw(SALOMEDS::StudyBuilder::LockProtection); + virtual void SetIOR(SALOMEDS::SObject_ptr theSO, const char* theValue) throw(SALOMEDS::StudyBuilder::LockProtection); }; #endif diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index 0eadebb95..222a6fe27 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -78,6 +78,11 @@ using namespace std; #include "SALOME_GenericObj_i.hh" +#include "Utils_ExceptHandlers.hxx" + +UNEXPECT_CATCH(SalomeException,SALOME::SALOME_Exception); +UNEXPECT_CATCH(LockProtection, SALOMEDS::StudyBuilder::LockProtection); + #define USE_CASE_LABEL_ID "0:2" #define AUTO_SAVE_GUID "128268A3-71C9-4036-89B1-F81BD6A4FCF2" #define AUTO_SAVE_TAG "0:8" @@ -85,292 +90,37 @@ using namespace std; //=========================================================================== //Function : LoadAttributes //=========================================================================== -static void ReadAttributes(Handle(TDF_Data)& DF, - TDF_Label& Lab, +static void ReadAttributes(SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr aSO, HDFdataset* hdf_dataset) { hdf_dataset->OpenOnDisk(); - - if (hdf_dataset->GetType() == HDF_STRING) { - - if (!strncmp(hdf_dataset->GetName(),"AttributeTreeNode",17)) { - MESSAGE("Create a Attribute : AttributeTreeNode"); - char current_strings[5][hdf_dataset->GetSize()/5]; -// char **current_strings = new (char*)[5]; -// for(int i=0;i<5;i++) -// current_strings[i] = new char[hdf_dataset->GetSize()/5+1]; - hdf_dataset->ReadFromDisk(current_strings); - - MESSAGE("Create an Attribute : AttributeTreeNode"); - Standard_GUID aGUID(current_strings[4]); - Handle(TDataStd_TreeNode) aNewNode = TDataStd_TreeNode::Set(Lab,aGUID); - TDF_Label aLabel; - Handle(TDataStd_TreeNode) aNode; - if (current_strings[0][0]) { - TDF_Tool::Label(DF,current_strings[0],aLabel,1); - if (!aLabel.FindAttribute(aGUID,aNode)) aNode = TDataStd_TreeNode::Set(aLabel,aGUID); - aNewNode->SetFather(aNode); - } - if (current_strings[1][0]) { - TDF_Tool::Label(DF,current_strings[1],aLabel,1); - if (!aLabel.FindAttribute(aGUID,aNode)) aNode = TDataStd_TreeNode::Set(aLabel,aGUID); - aNewNode->SetPrevious(aNode); - } - if (current_strings[2][0]) { - TDF_Tool::Label(DF,current_strings[2],aLabel,1); - if (!aLabel.FindAttribute(aGUID,aNode)) aNode = TDataStd_TreeNode::Set(aLabel,aGUID); - aNewNode->SetNext(aNode); - } - if (current_strings[3][0]) { - TDF_Tool::Label(DF,current_strings[3],aLabel,1); - if (!aLabel.FindAttribute(aGUID,aNode)) aNode = TDataStd_TreeNode::Set(aLabel,aGUID); - aNewNode->SetFirst(aNode); - } -// for(int i=0;i<5;i++) -// delete[] current_strings[i]; -// delete[] current_strings; - } else { - int size = hdf_dataset->GetSize(); - char* current_string = new char[size]; - hdf_dataset->ReadFromDisk(current_string); + SALOMEDS::GenericAttribute_var anAttr; - if (!strcmp(hdf_dataset->GetName(),"COMPONENTDATATYPE")) { - MESSAGE("Create a OCAF Attribute : COMPONENTDATATYPE"); - TDataStd_Comment::Set (Lab,current_string); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeComment")) { - MESSAGE("Create an Attribute : AttributeComment"); - TDataStd_Comment::Set (Lab,current_string); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeName")) { - MESSAGE("Create an Attribute : AttributeName"); - TDataStd_Name::Set (Lab,current_string); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributePersistentRef")) { - MESSAGE("Create an Attribute : AttributePersistentRef"); - SALOMEDS_PersRefAttribute::Set(Lab,current_string); - } - else if (!strcmp(hdf_dataset->GetName(),"Reference")) { - MESSAGE("Create a OCAF Attribute : Reference"); - TDF_Label RefLab; - TDF_Tool::Label(DF,current_string,RefLab,1); - TDF_Reference::Set(Lab,RefLab); - SALOMEDS_TargetAttribute::Set(RefLab)->Append(Lab); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeReal")) { - MESSAGE("Create a Attribute : AttributeReal"); - char * err = NULL; - CORBA::Double r = strtod(current_string, &err); - SCRUTE(r); - if (err == current_string) { - MESSAGE("AtttributeReal : conversion impossible"); - } - else TDataStd_Real::Set (Lab,r); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeInteger")) { - MESSAGE("Create a Attribute : AttributeInteger"); - CORBA::Long r = atol(current_string); - SCRUTE(r); - TDataStd_Integer::Set (Lab,r); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributePixMap")) { - MESSAGE("Create an Attribute : AttributePixMap"); - SALOMEDS_PixMapAttribute::Set (Lab,current_string); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeDrawable")) { - MESSAGE("Create a Attribute : DrawableAttribute"); - CORBA::Long r = atol(current_string); - SCRUTE(r); - SALOMEDS_DrawableAttribute::Set (Lab,r); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeSelectable")) { - MESSAGE("Create a Attribute : AttributeSelectable"); - CORBA::Long r = atol(current_string); - SCRUTE(r); - SALOMEDS_SelectableAttribute::Set (Lab,r); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeExpandable")) { - MESSAGE("Create a Attribute : AttributeExpandable"); - CORBA::Long r = atol(current_string); - SCRUTE(r); - SALOMEDS_ExpandableAttribute::Set (Lab,r); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeOpened")) { - MESSAGE("Create a Attribute : AttributeOpened"); - CORBA::Long r = atol(current_string); - SCRUTE(r); - SALOMEDS_OpenedAttribute::Set (Lab,r); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeLocalID")) { - MESSAGE("Create a Attribute : AttributeLocalID"); - CORBA::Long r = atol(current_string); - SCRUTE(r); - SALOMEDS_LocalIDAttribute::Set (Lab,r); - } - else if (!strncmp(hdf_dataset->GetName(),"AttributeUserID",15)) { - MESSAGE("Create an Attribute : AttributeUserID"); - TDataStd_UAttribute::Set (Lab,Standard_GUID(current_string)); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeTableOfInteger")) { - MESSAGE("Create a Attribute : AttributeTableOfInteger"); - int size = hdf_dataset->GetSize(); - Handle(SALOMEDS_TableOfIntegerAttribute) Attr = SALOMEDS_TableOfIntegerAttribute::Set(Lab); - unsigned char* aBuffer = new unsigned char[size]; - if(aBuffer == NULL) throw HDFexception("Unable to open dataset AttributeTableOfInteger"); - hdf_dataset->ReadFromDisk(aBuffer); - SALOMEDS::TMPFile_var aTMPFile = new SALOMEDS::TMPFile(size, size, aBuffer, 1); - istrstream aStream((char*)&aTMPFile[0], aTMPFile->length()); - Attr->RestoreFromString(aStream); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeTableOfReal")) { - MESSAGE("Create a Attribute : AttributeTableOfReal"); - int size = hdf_dataset->GetSize(); - Handle(SALOMEDS_TableOfRealAttribute) Attr = SALOMEDS_TableOfRealAttribute::Set(Lab); - unsigned char* aBuffer = new unsigned char[size]; - if(aBuffer == NULL) throw HDFexception("Unable to open dataset AttributeTableOfReal"); - hdf_dataset->ReadFromDisk(aBuffer); - SALOMEDS::TMPFile_var aTMPFile = new SALOMEDS::TMPFile(size, size, aBuffer, 1); - istrstream aStream((char*)&aTMPFile[0], aTMPFile->length()); - Attr->RestoreFromString(aStream); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeTableOfString")) { - MESSAGE("Create a Attribute : AttributeTableOfString"); - int size = hdf_dataset->GetSize(); - Handle(SALOMEDS_TableOfStringAttribute) Attr = SALOMEDS_TableOfStringAttribute::Set(Lab); - unsigned char* aBuffer = new unsigned char[size]; - if(aBuffer == NULL) throw HDFexception("Unable to open dataset AttributeTableOfString"); - hdf_dataset->ReadFromDisk(aBuffer); - SALOMEDS::TMPFile_var aTMPFile = new SALOMEDS::TMPFile(size, size, aBuffer, 1); - istrstream aStream((char*)&aTMPFile[0], aTMPFile->length()); - Attr->RestoreFromString(aStream); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeStudyProperties")) { - MESSAGE("Create an Attribute : AttributeStudyProperties"); -// MESSAGE("current string :"<SetCreationMode(1);break; - case 'c': aProp->SetCreationMode(2);break; - } + char* current_string = new char[hdf_dataset->GetSize()]; + hdf_dataset->ReadFromDisk(current_string); - int anIndex; - for(anIndex = 2; anIndex + 2 < size ;) { - char str[10]; - Standard_Integer aMinute, aHour, aDay, aMonth, aYear; - str[0] = current_string[anIndex++]; - str[1] = current_string[anIndex++]; - str[2] = 0; - aMinute = atoi(str); - str[0] = current_string[anIndex++]; - str[1] = current_string[anIndex++]; - aHour = atoi(str); - str[0] = current_string[anIndex++]; - str[1] = current_string[anIndex++]; - aDay = atoi(str); - str[0] = current_string[anIndex++]; - str[1] = current_string[anIndex++]; - aMonth = atoi(str); - str[0] = current_string[anIndex++]; - str[1] = current_string[anIndex++]; - str[2] = current_string[anIndex++]; - str[3] = current_string[anIndex++]; - str[4] = 0; - aYear = atoi(str); - aProp->SetModificationDate(aMinute,aHour,aDay,aMonth,aYear); - - int aNameSize; - for(aNameSize = 0; current_string[anIndex+aNameSize]!=1; aNameSize++); - char *aName = new char[aNameSize+1]; - strncpy(aName, &(current_string[anIndex]), aNameSize); - aName[aNameSize] = 0; - aProp->SetUserName(TCollection_ExtendedString(aName)); - delete(aName); - anIndex += aNameSize + 1; - if (current_string[1] == 'l') { - aProp->SetLocked(Standard_True); - aProp->IsLockChanged(true); - } - aProp->SetModified(0); - } - } - else if (!strcmp(hdf_dataset->GetName(),"AttributePythonObject")) { - MESSAGE("Create an Attribute : AttributePythonObject"); - Handle(SALOMEDS_PythonObjectAttribute) anObj = SALOMEDS_PythonObjectAttribute::Set(Lab); - Standard_Boolean aScript = (current_string[0] == 's')?Standard_True:Standard_False; - anObj->SetObject((char *)(current_string+1), aScript); - } - else { - MESSAGE(hdf_dataset->GetName()); - MESSAGE("LoadAttributes: unknown types"); - } - } - } - if (hdf_dataset->GetType() == HDF_FLOAT64) { - if (!strcmp(hdf_dataset->GetName(),"AttributeSequenceOfReal")) { - MESSAGE("Create a Attribute : AttributeSequenceOfReal"); - int size = hdf_dataset->GetSize(); - hdf_float64* val = new hdf_float64[size]; - hdf_dataset->ReadFromDisk(val); - Handle(TColStd_HSequenceOfReal) SeqReal = new TColStd_HSequenceOfReal; - for (Standard_Integer i = 0; i < size; i++) { - SeqReal->Append(val[i]); -// MESSAGE( val[i] << " restored" ); - } - SALOMEDS_SequenceOfRealAttribute::Set (Lab); - Handle(SALOMEDS_SequenceOfRealAttribute) Attr; - Handle(TDF_Attribute) Att; - Lab.FindAttribute(SALOMEDS_SequenceOfRealAttribute::GetID(),Att); - Attr = Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(Att); - Attr->Assign(SeqReal); - } else - if (!strcmp(hdf_dataset->GetName(),"AttributeTextColor")) { - MESSAGE("Create a Attribute : AttributeTextColor"); - hdf_float64 val[3]; - hdf_dataset->ReadFromDisk(val); - Handle(SALOMEDS_TextColorAttribute) TC = new SALOMEDS_TextColorAttribute; - Lab.AddAttribute(TC); - TC->SetValue(1, val[0]); - TC->SetValue(2, val[1]); - TC->SetValue(3, val[2]); - } else - if (!strcmp(hdf_dataset->GetName(),"AttributeTextHighlightColor")) { - MESSAGE("Create a Attribute : AttributeTextHighlightColor"); - hdf_float64 val[3]; - hdf_dataset->ReadFromDisk(val); - Handle(SALOMEDS_TextHighlightColorAttribute) TC = new SALOMEDS_TextHighlightColorAttribute; - Lab.AddAttribute(TC); - TC->SetValue(1, val[0]); - TC->SetValue(2, val[1]); - TC->SetValue(3, val[2]); - }else { - MESSAGE(hdf_dataset->GetName()); - MESSAGE("LoadAttributes: unknown types"); - } + if (!strcmp(hdf_dataset->GetName(),"COMPONENTDATATYPE")) { + anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, "AttributeComment"); + } else if (!strcmp(hdf_dataset->GetName(),"Reference")) { + theStudy->NewBuilder()->Addreference(aSO, theStudy->CreateObjectID(current_string)); + delete(current_string); + hdf_dataset->CloseOnDisk(); + return; + } else { + MESSAGE("Read attribute "<GetName()) + anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, hdf_dataset->GetName()); } - if (hdf_dataset->GetType() == HDF_INT32) { - if (!strcmp(hdf_dataset->GetName(),"AttributeSequenceOfInteger")) { - MESSAGE("Create a OCAF Attribute : AttributeSequenceOfInteger"); - int size = hdf_dataset->GetSize(); - hdf_int32* val = new hdf_int32[size]; - hdf_dataset->ReadFromDisk(val); - Handle(TColStd_HSequenceOfInteger) SeqInt = new TColStd_HSequenceOfInteger; - for (Standard_Integer i = 0; i < size; i++) { - SeqInt->Append(val[i]); -// MESSAGE( val[i] << " restored" ); - } - SALOMEDS_SequenceOfIntegerAttribute::Set (Lab); - Handle(SALOMEDS_SequenceOfIntegerAttribute) Attr; - Handle(TDF_Attribute) Att; - Lab.FindAttribute(SALOMEDS_SequenceOfIntegerAttribute::GetID(),Att); - Attr = Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(Att); - Attr->Assign(SeqInt); - } - else { - MESSAGE(hdf_dataset->GetName()); - MESSAGE("LoadAttributes: unknown types"); - } + + if (!CORBA::is_nil(anAttr)) { + anAttr->Restore(current_string); + MESSAGE("Restoring attribute "<GetName()<<" by string '"<GetName()); + MESSAGE("LoadAttributes: unknown types"); } + delete(current_string); hdf_dataset->CloseOnDisk(); } @@ -420,18 +170,18 @@ static void Translate_IOR_to_persistentID (SALOMEDS::Study_ptr study, //============================================================================ //Function : BuildlTree //============================================================================ -static void BuildTree (Handle(TDF_Data)& DF,HDFgroup* hdf_current_group) +static void BuildTree (SALOMEDS::Study_ptr theStudy,HDFgroup* hdf_current_group) { hdf_current_group->OpenOnDisk(); - TDF_Label Lab; - Standard_CString Entry = hdf_current_group->GetName(); + SALOMEDS::SObject_var aSO; + char* Entry = hdf_current_group->GetName(); if (strcmp(Entry,"STUDY_STRUCTURE") == 0) { MESSAGE("find the root of the document"); - Lab = DF->Root().FindChild(1,Standard_True); + aSO = theStudy->CreateObjectID("0:1"); } else { - TDF_Tool::Label (DF,Entry,Lab,1); + aSO = theStudy->CreateObjectID(Entry); MESSAGE("BuildTree : Create a new label"< Dataset: Internal Object Name : " << name); HDFdataset* new_dataset = new HDFdataset(name,hdf_current_group); - ReadAttributes (DF,Lab,new_dataset); + ReadAttributes(theStudy,aSO,new_dataset); new_dataset = 0; // will be deleted by father destructor } else if (type == HDF_GROUP) { MESSAGE( "--> Group: Internal Object Name : " << name); HDFgroup* new_group = new HDFgroup(name,hdf_current_group); - BuildTree (DF,new_group); + BuildTree (theStudy, new_group); new_group = 0; // will be deleted by father destructor } } @@ -550,6 +300,7 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* study_name) SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* aUrl) throw(SALOME::SALOME_Exception) { + Unexpect aCatch(SalomeException); MESSAGE("Begin of SALOMEDS_StudyManager_i::Open"); // open the HDFFile HDFfile *hdf_file =0; @@ -577,9 +328,9 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* aUrl) // cerr << "HDFexception ! " << endl; delete aHDFUrl; char eStr[strlen(aUrl)+17]; -// char *eStr = new char[strlen(aUrl)+17+1]; sprintf(eStr,"Can't open file %s",aUrl); THROW_SALOME_CORBA_EXCEPTION(CORBA::string_dup(eStr),SALOME::BAD_PARAM); + } MESSAGE("Open : Creating the CORBA servant holding it... "); @@ -617,7 +368,7 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* aUrl) Handle(TDF_Data) DF = Doc->GetData(); try { - BuildTree (DF,hdf_group_study_structure); + BuildTree (Study,hdf_group_study_structure); } catch (HDFexception) { @@ -625,7 +376,6 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* aUrl) // cerr << "HDFexception ! " << endl; delete aHDFUrl; char eStr[strlen(aUrl)+17]; -// char *eStr = new char[strlen(aUrl)+17+1]; sprintf(eStr,"Can't open file %s",aUrl); THROW_SALOME_CORBA_EXCEPTION(CORBA::string_dup(eStr),SALOME::BAD_PARAM); } @@ -826,372 +576,33 @@ SALOMEDS_StudyManager_i::GetStudyByID(CORBA::Short aStudyID) */ //============================================================================ static void SaveAttributes(SALOMEDS::SObject_ptr SO, HDFgroup *hdf_group_sobject) { - HDFdataset *hdf_dataset = 0; + int a; hdf_size size[1]; - hdf_int32 name_len = 0; - SALOMEDS::GenericAttribute_var SObj; - if(SO->FindAttribute(SObj, "AttributeComment")) - { - SALOMEDS::AttributeComment_var Comment = SALOMEDS::AttributeComment::_narrow(SObj); - CORBA::String_var Val = Comment->Value(); - name_len = (hdf_int32) strlen(Val); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributeComment",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(Val); - MESSAGE("attribute comment " << Val << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - // Attribute SALOMEDS::PersistentRef - if(SO->FindAttribute(SObj, "AttributePersistentRef")) - { - SALOMEDS::AttributePersistentRef_var PersRef = SALOMEDS::AttributePersistentRef::_narrow(SObj); - CORBA::String_var Val = PersRef->Value(); - name_len = (hdf_int32) strlen(Val); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributePersistentRef",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(Val); - MESSAGE("attribute persistentref " << Val << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - // Attribute SALOMEDS::Name - if(SO->FindAttribute(SObj, "AttributeName")) - { - SALOMEDS::AttributeName_var NameRef = SALOMEDS::AttributeName::_narrow(SObj); - CORBA::String_var Val = NameRef->Value(); - name_len = (hdf_int32) strlen(Val); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributeName",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(Val); - MESSAGE("attribute name " << Val << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - if(SO->FindAttribute(SObj, "AttributeReal")) - { - char RealVal[25]; - SALOMEDS::AttributeReal_var RealRef = SALOMEDS::AttributeReal::_narrow(SObj); - sprintf(RealVal, "%f", RealRef->Value()); - name_len = (hdf_int32) strlen(RealVal); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributeReal",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(RealVal); - MESSAGE("attribute Real " << RealVal << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - if(SO->FindAttribute(SObj, "AttributeInteger")) - { - char IntVal[25]; - SALOMEDS::AttributeInteger_var IntRef = SALOMEDS::AttributeInteger::_narrow(SObj); - sprintf(IntVal, "%d", IntRef->Value()); - name_len = (hdf_int32) strlen(IntVal); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributeInteger",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(IntVal); - MESSAGE("attribute Real " << IntVal << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - - if(SO->FindAttribute(SObj, "AttributeSequenceOfReal")) - { - SALOMEDS::AttributeSequenceOfReal_var RealSeq = SALOMEDS::AttributeSequenceOfReal::_narrow(SObj); - size[0] = RealSeq->Length(); - SALOMEDS::DoubleSeq_var DS = RealSeq->CorbaSequence(); - hdf_dataset = new HDFdataset("AttributeSequenceOfReal",hdf_group_sobject,HDF_FLOAT64,size,1); - hdf_dataset->CreateOnDisk(); - hdf_float64 *data = new hdf_float64[RealSeq->Length()]; - for (Standard_Integer i = 0; i < RealSeq->Length(); i++) { - MESSAGE("Value = " << i << " = " << DS[i] << " wrote on file"); - data[i] = DS[i]; - } - hdf_dataset->WriteOnDisk(data); - // delete data; - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - if(SO->FindAttribute(SObj, "AttributeSequenceOfInteger")) - { - SALOMEDS::AttributeSequenceOfInteger_var IntSeq = SALOMEDS::AttributeSequenceOfInteger::_narrow(SObj); - size[0] = IntSeq->Length(); - SALOMEDS::LongSeq_var LS = IntSeq->CorbaSequence(); - hdf_dataset = new HDFdataset("AttributeSequenceOfInteger",hdf_group_sobject,HDF_INT32,size,1); - hdf_dataset->CreateOnDisk(); - hdf_int32 *data = new hdf_int32[IntSeq->Length()]; - for (Standard_Integer i = 0; i < IntSeq->Length(); i++) { - MESSAGE("Value = " << i << " = " << LS[i] << " wrote on file"); - data[i] = LS[i]; - } - hdf_dataset->WriteOnDisk(data); - hdf_dataset->CloseOnDisk(); - // delete data; - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - if(SO->FindAttribute(SObj, "AttributeDrawable")) - { - char IntVal[25]; - SALOMEDS::AttributeDrawable_var DrRef = SALOMEDS::AttributeDrawable::_narrow(SObj); - sprintf(IntVal, "%d", DrRef->IsDrawable()); - name_len = (hdf_int32) strlen(IntVal); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributeDrawable",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(IntVal); - MESSAGE("attribute Drawable " << IntVal << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - if(SO->FindAttribute(SObj, "AttributeSelectable")) - { - char IntVal[25]; - SALOMEDS::AttributeSelectable_var SelRef = SALOMEDS::AttributeSelectable::_narrow(SObj); - sprintf(IntVal, "%d", SelRef->IsSelectable()); - name_len = (hdf_int32) strlen(IntVal); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributeSelectable",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(IntVal); - MESSAGE("attribute Selectable " << IntVal << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - if(SO->FindAttribute(SObj, "AttributeExpandable")) - { - char IntVal[25]; - SALOMEDS::AttributeExpandable_var ExRef = SALOMEDS::AttributeExpandable::_narrow(SObj); - sprintf(IntVal, "%d", ExRef->IsExpandable()); - name_len = (hdf_int32) strlen(IntVal); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributeExpandable",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(IntVal); - MESSAGE("attribute Expandable " << IntVal << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - if(SO->FindAttribute(SObj, "AttributeOpened")) - { - char IntVal[25]; - SALOMEDS::AttributeOpened_var OpRef = SALOMEDS::AttributeOpened::_narrow(SObj); - sprintf(IntVal, "%d", OpRef->IsOpened()); - name_len = (hdf_int32) strlen(IntVal); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributeOpened",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(IntVal); - MESSAGE("attribute Opened " << IntVal << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - if(SO->FindAttribute(SObj, "AttributeTextColor")) - { - SALOMEDS::AttributeTextColor_var TextRef = SALOMEDS::AttributeTextColor::_narrow(SObj); - size[0] = 3; - hdf_float64 data[3]; - SALOMEDS::Color C = TextRef->TextColor(); - data[0] = C.R; - data[1] = C.G; - data[2] = C.B; - hdf_dataset = new HDFdataset("AttributeTextColor",hdf_group_sobject,HDF_FLOAT64,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(data); - MESSAGE("attribute AttributeTextColor wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - if(SO->FindAttribute(SObj, "AttributeTextHighlightColor")) - { - SALOMEDS::AttributeTextHighlightColor_var TextRef = SALOMEDS::AttributeTextHighlightColor::_narrow(SObj); - size[0] = 3; - hdf_float64 data[3]; - SALOMEDS::Color C = TextRef->TextHighlightColor(); - data[0] = C.R; - data[1] = C.G; - data[2] = C.B; - hdf_dataset = new HDFdataset("AttributeTextHighlightColor",hdf_group_sobject,HDF_FLOAT64,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(data); - MESSAGE("attribute AttributeTextHighlightColor wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - if(SO->FindAttribute(SObj, "AttributePixMap")) - { - SALOMEDS::AttributePixMap_var PMRef = SALOMEDS::AttributePixMap::_narrow(SObj); - if (PMRef->HasPixMap()) { - CORBA::String_var Val = PMRef->GetPixMap(); - name_len = (hdf_int32) strlen(Val); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributePixMap",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(Val); - MESSAGE("attribute PixMap " << Val << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - } - if(SO->FindAttribute(SObj, "AttributeLocalID")) - { - char IntVal[25]; - SALOMEDS::AttributeLocalID_var LIDRef = SALOMEDS::AttributeLocalID::_narrow(SObj); - sprintf(IntVal, "%d", LIDRef->Value()); - name_len = (hdf_int32) strlen(IntVal); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributeLocalID",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(IntVal); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - MESSAGE("attribute AttributeLocalID wrote on file"); - } - if(SO->FindAttribute(SObj, "AttributeTableOfInteger")) - { - SALOMEDS::AttributeTableOfInteger_var IntTab = SALOMEDS::AttributeTableOfInteger::_narrow(SObj); - SALOMEDS::TMPFile_var aStream = IntTab->SaveToFile(); - - hdf_size aHDFSize[1]; - aHDFSize[0] = aStream->length(); - - HDFdataset *hdf_dataset = new HDFdataset("AttributeTableOfInteger",hdf_group_sobject, HDF_STRING, aHDFSize, 1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk((unsigned char*) &aStream[0]); //Save the stream in the HDF file - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - - MESSAGE("attribute AttributeTableOfInteger wrote on file"); - } - if(SO->FindAttribute(SObj, "AttributeTableOfReal")) - { - SALOMEDS::AttributeTableOfReal_var RealTab = SALOMEDS::AttributeTableOfReal::_narrow(SObj); - SALOMEDS::TMPFile_var aStream = RealTab->SaveToFile(); - - hdf_size aHDFSize[1]; - aHDFSize[0] = aStream->length(); - - HDFdataset *hdf_dataset = new HDFdataset("AttributeTableOfReal",hdf_group_sobject, HDF_STRING, aHDFSize, 1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk((unsigned char*) &aStream[0]); //Save the stream in the HDF file - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - - MESSAGE("attribute AttributeTableOfReal wrote on file") - } - if(SO->FindAttribute(SObj, "AttributeTableOfString")) - { - SALOMEDS::AttributeTableOfString_var StrTab = SALOMEDS::AttributeTableOfString::_narrow(SObj); - SALOMEDS::TMPFile_var aStream = StrTab->SaveToFile(); - - hdf_size aHDFSize[1]; - aHDFSize[0] = aStream->length(); - - HDFdataset *hdf_dataset = new HDFdataset("AttributeTableOfString",hdf_group_sobject, HDF_STRING, aHDFSize, 1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk((unsigned char*) &aStream[0]); //Save the stream in the HDF file - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - - MESSAGE("attribute AttributeTableOfString wrote on file") - } - if(SO->FindAttribute(SObj, "AttributePythonObject")) - { - SALOMEDS::AttributePythonObject_var anObj = SALOMEDS::AttributePythonObject::_narrow(SObj); - char* aSeq = CORBA::string_dup(anObj->GetObject()); - int aLen = strlen(aSeq); - char* aString = new char[aLen+2]; - aString[0] = anObj->IsScript()?'s':'n'; - for(int i = 0; i < aLen; i++) aString[i+1] = aSeq[i]; - aString[aLen+1] = 0; - size[0] = aLen+2 ; - hdf_dataset = new HDFdataset("AttributePythonObject",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(aString); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - MESSAGE("attribute AttributePythonObject wrote on file"); - } - -// Reference - SALOMEDS::SObject_var RefSO; - if(SO->ReferencedObject(RefSO)) - { - CORBA::String_var attribute_reference = strdup(RefSO->GetID()); - name_len = (hdf_int32) strlen(attribute_reference); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("Reference",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(attribute_reference); - MESSAGE("attribute reference " << attribute_reference << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset =0; // will be deleted by father hdf object destructor - } - -// TreeNodeAttributes with not constant GUID SALOMEDS::ListOfAttributes_var anAttrList = SO->GetAllAttributes(); - int anIndex, aLength = anAttrList->length(); - for(anIndex = 0; anIndex_is_nil()) { - char* Val = UAttr->Value(); - name_len = (hdf_int32) strlen(Val); - size[0] = name_len + 1; - char* aDataSetName = new char[60]; - sprintf(aDataSetName, "AttributeUserID_%s",Val); - hdf_dataset = new HDFdataset(aDataSetName,hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(Val); - MESSAGE("attribute UesrID " << Val << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - delete(aDataSetName); - continue; - } + for(a = anAttrList->length() - 1; a >= 0; a--) { + if (strcmp(anAttrList[a]->Type(), "AttributeIOR") == 0) continue; // never write AttributeIOR to file + if (strcmp(anAttrList[a]->Type(), "AttributeExternalFileDef") == 0) continue; // never write ExternalFileDef to file + if (strcmp(anAttrList[a]->Type(), "AttributeFileType") == 0) continue; // never write FileType to file + CORBA::String_var aSaveStr = strdup(anAttrList[a]->Store()); + size[0] = (hdf_int32) strlen(aSaveStr) + 1; + HDFdataset *hdf_dataset = new HDFdataset(anAttrList[a]->Type(),hdf_group_sobject,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(aSaveStr); + hdf_dataset->CloseOnDisk(); + //cout<<"********** Write Attribute "<Type()<<" : "<_is_nil()) { - hdf_size TNsize[2]; - int maxSize,index; - CORBA::String_var Val[5]; - - if (TNRef->HasFather()) Val[0] = TNRef->GetFather()->Label(); else Val[0] = "\0"; - maxSize = strlen(Val[0]); - if (TNRef->HasPrevious()) Val[1] = TNRef->GetPrevious()->Label(); else Val[1] = "\0"; - maxSize = Max(maxSize,strlen(Val[1])); - if (TNRef->HasNext()) Val[2] = TNRef->GetNext()->Label(); else Val[2] = "\0"; - maxSize = Max(maxSize,strlen(Val[2])); - if (TNRef->HasFirst()) Val[3] = TNRef->GetFirst()->Label(); else Val[3] = "\0"; - maxSize = Max(maxSize,strlen(Val[3])); - Val[4] = TNRef->GetTreeID(); - maxSize = Max(maxSize,strlen(Val[4])); - - TNsize[0]=5; - TNsize[1]=maxSize+1; - char Data[5][maxSize+1]; - for(index=0;index<5;index++) { - strcpy(Data[index],Val[index]); - for(int a = strlen(Data[index]) + 1; a < maxSize; a++) Data[index][a] = ' '; // mpv: for ASCII format - } - - char* aDataSetName = new char[60]; - sprintf(aDataSetName, "AttributeTreeNodeGUID%s",TNRef->GetTreeID()); - hdf_dataset = new HDFdataset(aDataSetName,hdf_group_sobject,HDF_STRING,TNsize,2); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(Data); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - MESSAGE("attribute AttributeTreeNode with various GUID wrote on file:"); - MESSAGE(aDataSetName); - delete(aDataSetName); -// for(int i=0;i<5;i++) -// delete[] Data[i]; -// delete[] Data; - } + // Reference attribute has no CORBA attribute representation, so, GetAllAttributes can not return this attribute + SALOMEDS::SObject_var RefSO; + if(SO->ReferencedObject(RefSO)) { + CORBA::String_var attribute_reference = strdup(RefSO->GetID()); + size[0] = strlen(attribute_reference) + 1 ; + HDFdataset *hdf_dataset = new HDFdataset("Reference",hdf_group_sobject,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(attribute_reference); + hdf_dataset->CloseOnDisk(); + hdf_dataset =0; // will be deleted by father hdf object destructor } } @@ -1580,7 +991,7 @@ void SALOMEDS_StudyManager_i::_SaveObject(SALOMEDS::Study_ptr aStudy, SALOMEDS::SObject_var SO = itchild->Value(); // mpv: don't save empty labels - if (SO->GetAllAttributes()->length() == 0) { + if (SO->GetAllAttributes()->length() == 0 && !SO->ReferencedObject(RefSO)) { SALOMEDS::ChildIterator_var subchild = aStudy->NewChildIterator(SC); if (!subchild->More()) { continue; @@ -1588,7 +999,8 @@ void SALOMEDS_StudyManager_i::_SaveObject(SALOMEDS::Study_ptr aStudy, subchild->InitEx(true); bool anEmpty = true; for (; subchild->More() && anEmpty; subchild->Next()) - if (subchild->Value()->GetAllAttributes()->length() != 0) anEmpty = false; + if (subchild->Value()->GetAllAttributes()->length() != 0 || + subchild->Value()->ReferencedObject(RefSO)) anEmpty = false; if (anEmpty) { continue; } @@ -1926,6 +1338,7 @@ TDF_Label SALOMEDS_StudyManager_i::PasteLabel(const SALOMEDS::Study_ptr theDesti SALOMEDS::SObject_ptr SALOMEDS_StudyManager_i::Paste(SALOMEDS::SObject_ptr theObject) throw(SALOMEDS::StudyBuilder::LockProtection) { + Unexpect aCatch(LockProtection); SALOMEDS::Study_var aStudy = theObject->GetStudy(); // if study is locked, then paste can't be done diff --git a/src/SALOMEDS/SALOMEDS_StudyPropertiesAttribute.cxx b/src/SALOMEDS/SALOMEDS_StudyPropertiesAttribute.cxx index 62835949d..4f83613be 100644 --- a/src/SALOMEDS/SALOMEDS_StudyPropertiesAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyPropertiesAttribute.cxx @@ -9,8 +9,8 @@ // Module : SALOME // $Header$ -#include using namespace std; +#include const Standard_GUID& SALOMEDS_StudyPropertiesAttribute::GetID() { diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index fc2591d58..be1599434 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "utilities.h" #include "SALOMEDS_Study_i.hxx" @@ -43,7 +44,6 @@ #include "SALOMEDS_LocalIDAttribute.hxx" #include "SALOMEDS_PersRefAttribute.hxx" #include "SALOMEDS_UseCaseIterator_i.hxx" -using namespace std; #define DIRECTORYID 16661 @@ -226,7 +226,25 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID) { // Convert aSO->GetID in TDF_Label. TDF_Label Lab; - TDF_Tool::Label(_doc->GetData(), strdup(anObjectID), Lab); + TDF_Tool::Label(_doc->GetData(), (char*)anObjectID, Lab); + + if (Lab.IsNull()) return SALOMEDS::SObject::_nil(); + SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (Lab,_orb); + SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + return so; + +} + +//============================================================================ +/*! Function : CreateObjectID + * Purpose : Creates an Object with ID = anObjectID + */ +//============================================================================ +SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID) +{ + // Convert aSO->GetID in TDF_Label. + TDF_Label Lab; + TDF_Tool::Label(_doc->GetData(), (char*)anObjectID, Lab, Standard_True); if (Lab.IsNull()) return SALOMEDS::SObject::_nil(); SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (Lab,_orb); @@ -336,7 +354,7 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR) RefSO = _FindObjectIOR(SC,anObjectIOR, _find); } } - if (!RefSO->_is_nil()) INFOS("SALOMEDS_Study_i::FindObjectIOR: found label with old methods"); + if (!RefSO->_is_nil()) MESSAGE("SALOMEDS_Study_i::FindObjectIOR: found label with old methods"); return RefSO; } @@ -649,7 +667,7 @@ SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject { //Convert aSO->GetID in TDF_Label. TDF_Label Lab; - TDF_Tool::Label(_doc->GetData(), strdup(aSO->GetID()), Lab); + TDF_Tool::Label(_doc->GetData(), aSO->GetID(), Lab); //Create iterator SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(Lab,_orb); @@ -887,7 +905,7 @@ SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const TDF_Label theLabel, CORBA:: ASSERT(!CORBA::is_nil(aStudy)); return SALOMEDS::Study::_duplicate(aStudy); } else { - INFOS("GetStudy: Problem to get study"); + MESSAGE("GetStudy: Problem to get study"); } return SALOMEDS::Study::_nil(); } @@ -1013,7 +1031,7 @@ void SALOMEDS_Study_i::AddPostponed(const char* theIOR) { if (!CORBA::is_nil(obj)) { SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj) ; if (!CORBA::is_nil(aGeneric)) { - TCollection_AsciiString anIOR(strdup(theIOR)); + TCollection_AsciiString anIOR((char*)theIOR); anIOR.Prepend("d"); myPostponedIORs.Append(anIOR); // add prefix: deleted myNbPostponed.SetValue(myNbPostponed.Length(), myNbPostponed.Last() + 1); @@ -1029,7 +1047,7 @@ void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR) { if (!CORBA::is_nil(obj)) { SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj) ; if (!CORBA::is_nil(aGeneric)) { - TCollection_AsciiString anIOR(strdup(theIOR)); + TCollection_AsciiString anIOR((char*)theIOR); anIOR.Prepend("c"); myPostponedIORs.Append(anIOR); // add prefix: created myNbPostponed.SetValue(myNbPostponed.Length(), myNbPostponed.Last() + 1); @@ -1059,7 +1077,7 @@ void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long theUndoLimit) { 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())); + CORBA::Object_var obj = _orb->string_to_object(anIOR.Split(1).ToCString()); SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj); if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy(); } @@ -1077,7 +1095,7 @@ void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long theUndoLimit) { 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())); + CORBA::Object_var obj = _orb->string_to_object(anIOR.Split(1).ToCString()); SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj); if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy(); } @@ -1090,7 +1108,7 @@ void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long theUndoLimit) { 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()); + CORBA::String_var anIOR = CORBA::string_dup(TCollection_AsciiString(anAttr->Get()).ToCString()); try { CORBA::Object_var obj = _orb->string_to_object(anIOR); SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj); diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index be93b95f9..ad314b497 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -149,6 +149,13 @@ public: */ virtual SALOMEDS::SObject_ptr FindObjectID(const char* anObjectID); + //! method to Create an Object with ID = anObjectID + /*! + \param anObjectID char* arguments + \return SObject_ptr arguments, the object found + */ + virtual SALOMEDS::SObject_ptr CreateObjectID(const char* anObjectID); + //! method to Find an Object with ID = anObjectIOR /*! \param anObjectIOR char* arguments @@ -261,7 +268,6 @@ public: */ virtual void URL(const char* url); - virtual CORBA::Short StudyId(); virtual void StudyId(CORBA::Short id); diff --git a/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.cxx b/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.cxx index abe7171f8..a5134a76f 100644 --- a/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.cxx @@ -9,12 +9,12 @@ // Module : SALOME // $Header$ +using namespace std; #include #include #include #include -using namespace std; const Standard_GUID& SALOMEDS_TableOfIntegerAttribute::GetID() { diff --git a/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.hxx b/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.hxx index a15b4bce7..f524bad98 100644 --- a/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.hxx +++ b/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.hxx @@ -111,8 +111,8 @@ Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_ Standard_EXPORT Handle_TColStd_HSequenceOfInteger GetSetRowIndices(const Standard_Integer theRow); Standard_EXPORT Handle_TColStd_HSequenceOfInteger GetSetColumnIndices(const Standard_Integer theColumn); -Standard_EXPORT void ConvertToString(std::ostrstream& theStream); -Standard_EXPORT bool RestoreFromString(std::istrstream& theStream); +Standard_EXPORT void ConvertToString(ostrstream& theStream); +Standard_EXPORT bool RestoreFromString(istrstream& theStream); Standard_EXPORT ~SALOMEDS_TableOfIntegerAttribute(); diff --git a/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.cxx b/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.cxx index f234fca97..d12b58bb2 100644 --- a/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.cxx @@ -9,13 +9,13 @@ // Module : SALOME // $Header$ +using namespace std; #include #include #include #include #include -using namespace std; const Standard_GUID& SALOMEDS_TableOfRealAttribute::GetID() { diff --git a/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.hxx b/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.hxx index 35d8e33ae..a3d35069f 100644 --- a/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.hxx +++ b/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.hxx @@ -120,8 +120,8 @@ Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_ Standard_EXPORT Handle_TColStd_HSequenceOfInteger GetSetRowIndices(const Standard_Integer theRow); Standard_EXPORT Handle_TColStd_HSequenceOfInteger GetSetColumnIndices(const Standard_Integer theColumn); -Standard_EXPORT void ConvertToString(std::ostrstream& theStream); -Standard_EXPORT bool RestoreFromString(std::istrstream& theStream); +Standard_EXPORT void ConvertToString(ostrstream& theStream); +Standard_EXPORT bool RestoreFromString(istrstream& theStream); Standard_EXPORT ~SALOMEDS_TableOfRealAttribute(); diff --git a/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.cxx b/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.cxx index 9221e9a80..737f1f752 100644 --- a/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.cxx @@ -8,13 +8,13 @@ // Author : Sergey Ruin // Module : SALOME +using namespace std; #include #include #include #include #include -using namespace std; const Standard_GUID& SALOMEDS_TableOfStringAttribute::GetID() { diff --git a/src/SALOMEDS/SALOMEDS_TargetAttribute.cxx b/src/SALOMEDS/SALOMEDS_TargetAttribute.cxx index 9833dd56c..004fd6973 100644 --- a/src/SALOMEDS/SALOMEDS_TargetAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_TargetAttribute.cxx @@ -24,13 +24,13 @@ // File : SALOMEDS_TargetAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ +using namespace std; #include "SALOMEDS_TargetAttribute.ixx" #include #include #include "utilities.h" -using namespace std; //======================================================================= //function : GetID diff --git a/src/SALOMEDS/SALOMEDS_TargetAttribute.hxx b/src/SALOMEDS/SALOMEDS_TargetAttribute.hxx index ef6af7626..8b63cb886 100644 --- a/src/SALOMEDS/SALOMEDS_TargetAttribute.hxx +++ b/src/SALOMEDS/SALOMEDS_TargetAttribute.hxx @@ -24,7 +24,7 @@ // File : SALOMEDS_TargetAttribute.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef _SALOMEDS_TargetAttribute_HeaderFile #define _SALOMEDS_TargetAttribute_HeaderFile diff --git a/src/SALOMEDS/SALOMEDS_TargetAttribute.ixx b/src/SALOMEDS/SALOMEDS_TargetAttribute.ixx index a777e0f53..7fac6a9e1 100644 --- a/src/SALOMEDS/SALOMEDS_TargetAttribute.ixx +++ b/src/SALOMEDS/SALOMEDS_TargetAttribute.ixx @@ -24,7 +24,7 @@ // File : SALOMEDS_TargetAttribute.ixx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #include "SALOMEDS_TargetAttribute.jxx" diff --git a/src/SALOMEDS/SALOMEDS_TargetAttribute.jxx b/src/SALOMEDS/SALOMEDS_TargetAttribute.jxx index 56d2fb154..eff35ad6a 100644 --- a/src/SALOMEDS/SALOMEDS_TargetAttribute.jxx +++ b/src/SALOMEDS/SALOMEDS_TargetAttribute.jxx @@ -24,7 +24,7 @@ // File : SALOMEDS_TargetAttribute.jxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef _Standard_GUID_HeaderFile #include diff --git a/src/SALOMEDS/SALOMEDS_TextColorAttribute.cxx b/src/SALOMEDS/SALOMEDS_TextColorAttribute.cxx index c5eccab88..89b033e6e 100644 --- a/src/SALOMEDS/SALOMEDS_TextColorAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_TextColorAttribute.cxx @@ -24,10 +24,10 @@ // File : SALOMEDS_TextColorAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ -#include "SALOMEDS_TextColorAttribute.ixx" using namespace std; +#include "SALOMEDS_TextColorAttribute.ixx" //======================================================================= //function : GetID diff --git a/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.cxx b/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.cxx index dd95d6f64..ccc3c70a8 100644 --- a/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.cxx @@ -24,10 +24,10 @@ // File : SALOMEDS_TextHighlightColorAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ -#include "SALOMEDS_TextHighlightColorAttribute.ixx" using namespace std; +#include "SALOMEDS_TextHighlightColorAttribute.ixx" //======================================================================= //function : GetID diff --git a/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx b/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx index 151a0bb9c..698fbb1c6 100644 --- a/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx +++ b/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx @@ -8,6 +8,7 @@ // Author : Yves FRICAUD // Module : SALOME +using namespace std; #include "SALOMEDS_UseCaseBuilder_i.hxx" #include "SALOMEDS_AttributeComment_i.hxx" #include "SALOMEDS_SObject_i.hxx" @@ -23,7 +24,6 @@ #include #include #include -using namespace std; #define USE_CASE_LABEL_TAG 2 #define USE_CASE_GUID "AA43BB12-D9CD-11d6-945D-0050DA506788" diff --git a/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx b/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx index 05507edab..69e7d39ec 100644 --- a/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx +++ b/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx @@ -8,10 +8,12 @@ // Author : Yves FRICAUD // Module : SALOME +using namespace std; #include "SALOMEDS_UseCaseIterator_i.hxx" #include "SALOMEDS_SObject_i.hxx" #include "utilities.h" -using namespace std; + + //============================================================================ /*! Function : constructor diff --git a/src/SALOMEGUI/CLIENT_msg_en.po b/src/SALOMEGUI/CLIENT_msg_en.po index c39094a02..31c7b8a77 100644 --- a/src/SALOMEGUI/CLIENT_msg_en.po +++ b/src/SALOMEGUI/CLIENT_msg_en.po @@ -20,17 +20,17 @@ msgstr "" #--------------- msgid "INF_VERSION" -msgstr "Version 1.4.0" +msgstr "Version 2.0.0" msgid "INF_COPYRIGHT" -msgstr " " +msgstr "Copyright : CEA" msgid "INF_LICENSE" msgstr " " #: SALOMEGUI_AboutDlg.cxx:42 msgid "ABOUT_TLT" -msgstr "About SALOME" +msgstr "About PAL/SALOME" #: QAD_Config.cxx:84 msgid "MEN_APPNAME" @@ -38,8 +38,8 @@ msgstr "salome" #: QAD_Application.cxx:133 msgid "QAD_Application::APP_DEFAULTTITLE" -msgstr "SALOME 1.4.0" +msgstr "SALOME 2.0.0" #: QAD_Desktop.cxx:424 msgid "QAD_Desktop::DESK_DEFAULTTITLE" -msgstr "SALOME 1.4.0" +msgstr "SALOME 2.0.0" diff --git a/src/SALOMEGUI/Makefile.in b/src/SALOMEGUI/Makefile.in index 08d0682d3..3f7bc1c78 100644 --- a/src/SALOMEGUI/Makefile.in +++ b/src/SALOMEGUI/Makefile.in @@ -92,6 +92,7 @@ EXPORT_HEADERS = \ Handle_SALOME_NumberFilter.hxx \ SALOME_DataMapOfIOMapOfInteger.hxx \ Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx \ + SALOMEGUI.h \ SALOMEGUI_LoadStudiesDlg.h \ SALOMEGUI_TableDlg.h \ SALOMEGUI_NameDlg.h \ @@ -99,7 +100,6 @@ EXPORT_HEADERS = \ SALOMEGUI_SetupCurveDlg.h \ SALOMEGUI_CloseDlg.h - # .po files to transform in .qm PO_FILES = \ QAD_icons.po \ @@ -150,6 +150,7 @@ LIB_SRC = \ QAD_StudyFrame.cxx \ QAD_Tools.cxx \ QAD_ViewFrame.cxx \ + SALOMEGUI.cxx \ SALOMEGUI_Application.cxx \ SALOMEGUI_Desktop.cxx \ SALOMEGUI_ImportOperation.cxx \ @@ -182,6 +183,7 @@ LIB_SRC = \ SALOMEGUI_CloseDlg.cxx \ SALOMEGUI_ActivateComponentDlg.cxx LIB_MOC = \ + SALOMEGUI.h \ SALOMEGUI_Application.h \ SALOMEGUI_Desktop.h \ QAD_Application.h \ @@ -218,7 +220,7 @@ LIB_CLIENT_IDL = SALOMEDS.idl \ SALOME_Exception.idl CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) -LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lqsplitterP -lSalomeLifeCycleCORBA -lOpUtil -lSalomeObject +LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lqsplitterP -lSalomeLifeCycleCORBA -lOpUtil -lSalomeObject -lEvent LIBS+= $(PYTHON_LIBS) diff --git a/src/SALOMEGUI/PyInterp_PyQt.cxx b/src/SALOMEGUI/PyInterp_PyQt.cxx index 7f59b13a4..dd136e506 100644 --- a/src/SALOMEGUI/PyInterp_PyQt.cxx +++ b/src/SALOMEGUI/PyInterp_PyQt.cxx @@ -10,18 +10,17 @@ // $Header$ #include "PyInterp_PyQt.h" - #include "utilities.h" + using namespace std; -extern "C" PyObject * PyEval_EvalCode(PyObject *co, PyObject *g, PyObject *l); /*! * constructor : the main SALOME Python interpreter is used for PyQt GUI. * calls initialize method defined in base class, which calls virtual methods * initstate & initcontext redefined here */ -PyInterp_PyQt::PyInterp_PyQt() +PyInterp_PyQt::PyInterp_PyQt(): PyInterp_base() { initialize(); } @@ -32,7 +31,6 @@ PyInterp_PyQt::~PyInterp_PyQt() void PyInterp_PyQt::initState() { - salomeAcquireLock(); //acquire python global lock (one for all interpreters) SCRUTE(PyInterp_base::_gtstate); _tstate=PyInterp_base::_gtstate; PyThreadState_Swap(_tstate); @@ -47,49 +45,23 @@ void PyInterp_PyQt::initContext() Py_DECREF(bimod); } -void PyInterp_PyQt::enter() -{ - PyThreadState *oldstate; - SCRUTE(_tstate); - salomeAcquireLock(); - oldstate=PyThreadState_Swap(_tstate); - SCRUTE(oldstate); -} - -void PyInterp_PyQt::quit() -{ - MESSAGE("quit"); - salomeReleaseLock(); - MESSAGE("fin quit"); -} - void PyInterp_PyQt::run(const char *command) { - PyObject *code,*r; - enter(); MESSAGE("compile"); - code=Py_CompileString((char *)command,"PyGUI",Py_file_input); - if (code == NULL) - { - /* - Une erreur s est produite en general SyntaxError - */ - PyErr_Print(); - quit(); - return; - } - r = PyEval_EvalCode(code,_g,_g); + PyLockWrapper aLock(_tstate); + PyObject *code = Py_CompileString((char *)command,"PyGUI",Py_file_input); + if(!code){ + // Une erreur s est produite en general SyntaxError + PyErr_Print(); + return; + } + PyObject *r = PyEval_EvalCode(code,_g,_g); Py_DECREF(code); - if (r==NULL) - { - /* - Une erreur s est produite a l execution - */ - PyErr_Print(); - quit(); - return; - } + if(!r){ + // Une erreur s est produite a l execution + PyErr_Print(); + return; + } Py_DECREF(r); - quit(); } diff --git a/src/SALOMEGUI/PyInterp_PyQt.h b/src/SALOMEGUI/PyInterp_PyQt.h index bc6a29849..74d743e27 100644 --- a/src/SALOMEGUI/PyInterp_PyQt.h +++ b/src/SALOMEGUI/PyInterp_PyQt.h @@ -19,13 +19,12 @@ class PyInterp_PyQt : public PyInterp_base public: PyInterp_PyQt(); ~PyInterp_PyQt(); - void enter(); - void quit(); + void run(const char *command); protected: - void initState(); - void initContext(); + virtual void initState(); + virtual void initContext(); }; #endif diff --git a/src/SALOMEGUI/PyInterp_base.cxx b/src/SALOMEGUI/PyInterp_base.cxx index fb88526ed..e16f1e041 100644 --- a/src/SALOMEGUI/PyInterp_base.cxx +++ b/src/SALOMEGUI/PyInterp_base.cxx @@ -9,199 +9,114 @@ // Module : SALOME // $Header$ -#include "PyInterp_base.h" -#include "utilities.h" #include #include + +#include #include +#include + +#include "PyInterp_base.h" +#include "utilities.h" + + using namespace std; -extern "C" PyObject * PyEval_EvalCode(PyObject *co, PyObject *g, PyObject *l); -static PyThreadState *savedThreadState = NULL; +#ifdef _DEBUG_ +static int MYDEBUG = 0; +static int MYPYDEBUG = 0; +#else +static int MYDEBUG = 0; +static int MYPYDEBUG = 0; +#endif -/*! - * We have our own routines which are identical to the SIP routines - * to not depend from SIP software evolutions - */ -extern "C" void salomeAcquireLock() +static QMutex myMutex(false); + + +PyLockWrapper::PyLockWrapper(PyThreadState* theThreadState): + myThreadState(theThreadState), + mySaveThreadState(PyInterp_base::_gtstate) { - MESSAGE("salomeAcquireLock"); - PyEval_RestoreThread(savedThreadState); - savedThreadState = NULL; + PyEval_AcquireLock(); + mySaveThreadState = PyThreadState_Swap(myThreadState); } -extern "C" void salomeReleaseLock() -{ - MESSAGE("salomeReleaseLock"); - savedThreadState = PyEval_SaveThread(); + +PyLockWrapper::~PyLockWrapper(){ + PyThreadState_Swap(mySaveThreadState); + PyEval_ReleaseLock(); } -extern "C" int salomeCondAcquireLock() + +ThreadLock::ThreadLock(QMutex* theMutex, const char* theComment): + myMutex(theMutex), + myComment(theComment) { - MESSAGE("salomeCondAcquireLock"); - if(savedThreadState != NULL) - { - /* - * If savedThreadState is not NULL, Python global lock is not already acquired - * We acquire it - * and return 1 to the caller - */ - salomeAcquireLock(); - //MESSAGE("We got it (the lock)"); - return 1; - } - /* - * If savedThreadState is NULL, Python global lock is already acquired - * We don't acquire or release it - * We return 0 to the caller - * CAUTION : it's only true when there is no event programming running (Tkinter, PyQt) - */ - return 0; + if(MYDEBUG && myComment != "") MESSAGE(" ThreadLock "<locked()); + myMutex->lock(); } -extern "C" void salomeCondReleaseLock(int rellock) -{ - MESSAGE("salomeCondReleaseLock"); - if(rellock ) - salomeReleaseLock(); + +ThreadLock::~ThreadLock(){ + if(MYDEBUG && myComment != "") MESSAGE("~ThreadLock "<unlock(); } -// main python interpreter -PyThreadState *PyInterp_base::_gtstate=0; // force 0 before execution -int PyInterp_base::_argc=1; -char* PyInterp_base::_argv[] = {""}; +bool IsPyLocked(){ + return myMutex.locked(); +} -PyObject *PyInterp_base::builtinmodule=NULL; -PyObject *PyInterp_base::salome_shared_modules_module=NULL; -void init_python() -{ - SCRUTE(PyInterp_base::_gtstate); - if (PyInterp_base::_gtstate) return; - Py_Initialize(); // Initialize the interpreter - PyEval_InitThreads(); // Create (and acquire) the interpreter lock - PySys_SetArgv(PyInterp_base::_argc,PyInterp_base::_argv); // initialize sys.argv - PyInterp_base::_gtstate = PyThreadState_Get(); - SCRUTE(PyInterp_base::_gtstate); - - // /* - // * Import __builtin__ module and store it to use it with all sub-interpreters - // * This hack could be used with event programming (PyQt) to avoid errors - // * encountered with incoherent builtins - // */ - - // PyInterp_base::builtinmodule =PyImport_ImportModule("__builtin__"); - // SCRUTE(PyInterp_base::builtinmodule->ob_refcnt); - - /* - * Import salome_shared_modules module and store it to use it with all sub-interpreters - */ - - PyInterp_base::salome_shared_modules_module =PyImport_ImportModule("salome_shared_modules"); - if(PyInterp_base::salome_shared_modules_module == NULL){ - MESSAGE("init_python: problem with salome_shared_modules import"); - PyErr_Print(); - PyErr_Clear(); - salomeReleaseLock(); - return; - } - SCRUTE(PyInterp_base::salome_shared_modules_module->ob_refcnt); - salomeReleaseLock(); +ThreadLock GetPyThreadLock(const char* theComment){ + return ThreadLock(&myMutex,theComment); } -/*! - * This function compiles a string (command) and then evaluates it in the dictionnary - * context if possible. - * Returns : - * -1 : fatal error - * 1 : incomplete text - * 0 : complete text executed with success - */ -int compile_command(const char *command,PyObject *context) -{ - SCRUTE(command); - PyObject *m,*v,*r; - - m=PyImport_AddModule("codeop"); - if(m == NULL) - { - /* - * Fatal error. No way to go on. - */ - PyErr_Print(); - return -1; - } - v= PyObject_CallMethod(m,"compile_command","s",command); - if (v == NULL) - { - /* - * Error encountered. It should be SyntaxError - * so we don't write out traceback - */ - PyObject *exception,*value,*tb; - PyErr_Fetch(&exception, &value, &tb); - PyErr_NormalizeException(&exception, &value, &tb); - PyErr_Display(exception, value, NULL); - Py_XDECREF(exception); - Py_XDECREF(value); - Py_XDECREF(tb); +class PyReleaseLock{ +public: + ~PyReleaseLock(){ + if(MYPYDEBUG) MESSAGE("~PyReleaseLock()"); + PyEval_ReleaseLock(); + } +}; - return -1; - } - else if (v == Py_None) - { - /* - * Incomplete text we return 1 : we need a complete text to execute - */ - return 1; - } - else - { - /* - * Complete and correct text. We evaluate it. - */ - r = PyEval_EvalCode(v,context,context); - Py_DECREF(v); - if (r==NULL) - { - /* - * Execution error. We return -1 - */ - PyErr_Print(); - return -1; - } - Py_DECREF(r); - /* - * The command has been successfully executed. Return 0 - */ - return 0; - } + +PyLockWrapper PyInterp_base::GetLockWrapper(){ + return _tstate; } + +// main python interpreter + +PyThreadState *PyInterp_base::_gtstate = 0; // force 0 before execution +int PyInterp_base::_argc = 1; +char* PyInterp_base::_argv[] = {""}; + +PyObject *PyInterp_base::builtinmodule = NULL; +PyObject *PyInterp_base::salome_shared_modules_module = NULL; + + /*! * basic constructor here : herited classes constructors must call initalize() method * defined here. */ - -PyInterp_base::PyInterp_base():_tstate(0),_vout(0),_verr(0),_g(0),_atFirst(true) +PyInterp_base::PyInterp_base(): _tstate(0), _vout(0), _verr(0), _g(0), _atFirst(true) { - MESSAGE("PyInterp_base::PyInterp_base()"); + if(MYPYDEBUG) MESSAGE("PyInterp_base::PyInterp_base() - this = "<NewOutput(128); - _verr=PycStringIO->NewOutput(128); + PycStringIO = (PycStringIO_CAPI *)xxxPyCObject_Import("cStringIO", "cStringIO_CAPI"); + _vout = PycStringIO->NewOutput(128); + _verr = PycStringIO->NewOutput(128); // All the initRun outputs are redirected to the standard output (console) - this->initRun(); - - // We go out of Python world to enter the C++ world. Release the Python global lock - salomeReleaseLock(); - SCRUTE(_tstate); - SCRUTE(this); + initRun(); } + string PyInterp_base::getbanner() { - MESSAGE("PyInterp_base::getbanner()"); - string banner = "Python "; - banner = banner + Py_GetVersion() + " on " + Py_GetPlatform() ; - banner = banner + "\ntype help to get general information on environment\n"; - return banner.c_str(); + string aBanner("Python "); + aBanner = aBanner + Py_GetVersion() + " on " + Py_GetPlatform() ; + aBanner = aBanner + "\ntype help to get general information on environment\n"; + return aBanner; } + int PyInterp_base::initRun() { - MESSAGE("PyInterp_base::initRun()"); PySys_SetObject("stderr",_verr); PySys_SetObject("stdout",_vout); - PyObject *v = PyObject_CallMethod(_verr,"reset",""); - Py_XDECREF(v); - v = PyObject_CallMethod(_vout,"reset",""); - Py_XDECREF(v); - + PyObjWrapper verr(PyObject_CallMethod(_verr,"reset","")); + PyObjWrapper vout(PyObject_CallMethod(_vout,"reset","")); - PyObject *m; - m = PyImport_GetModuleDict(); + PyObject *m = PyImport_GetModuleDict(); PySys_SetObject("stdout",PySys_GetObject("__stdout__")); PySys_SetObject("stderr",PySys_GetObject("__stderr__")); - MESSAGE(this->getvout()); - MESSAGE(this->getverr()); - + if(MYPYDEBUG) MESSAGE("PyInterp_base::initRun() - this = "<simpleRun("from Help import *"); - MESSAGE(this->getvout()) - MESSAGE(this->getverr()) - if (ret != 0) return ret; - ret = this->simpleRun("import salome"); - MESSAGE(this->getvout()); - MESSAGE(this->getverr()) - if (ret != 0) return ret; - } - ret = this->simpleRun(command); - return ret; + if(_atFirst){ + int ret = 0; + _atFirst = false; + ret = simpleRun("from Help import *"); + if (ret) return ret; + ret = simpleRun("import salome"); + if (ret) return ret; + } + return simpleRun(command); } + int PyInterp_base::simpleRun(const char *command) { - SCRUTE(command); - PyObject *v,*m,*r,*g; - char *output; - int ier=0; - string s_com = command; - - if (s_com.size() > 0) - { - _history.push_back(s_com); - _ith = _history.end(); - SCRUTE(_history.back()); - } + if(strcmp(command,"") != 0){ + _history.push_back(command); + _ith = _history.end(); + } - // SCRUTE(this); - // SCRUTE(_tstate); // We come from C++ to enter Python world // We need to acquire the Python global lock - salomeAcquireLock(); - // Restore the sub interpreter thread state : this._tstate - PyThreadState_Swap(_tstate); + PyLockWrapper aLock(_tstate); - /* - Reset redirected outputs before treatment - */ + // Reset redirected outputs before treatment PySys_SetObject("stderr",_verr); PySys_SetObject("stdout",_vout); - - v = PyObject_CallMethod(_verr,"reset",""); - Py_XDECREF(v); - v = PyObject_CallMethod(_vout,"reset",""); - Py_XDECREF(v); + + PyObjWrapper verr(PyObject_CallMethod(_verr,"reset","")); + PyObjWrapper vout(PyObject_CallMethod(_vout,"reset","")); - ier=compile_command(command,_g); + int ier = compile_command(command,_g); // Outputs are redirected on standards outputs (console) PySys_SetObject("stdout",PySys_GetObject("__stdout__")); PySys_SetObject("stderr",PySys_GetObject("__stderr__")); - - // We go back to the C++ world. Release the lock. - salomeReleaseLock(); return ier; } -static string vout_buffer; -static string verr_buffer; - -char * PyInterp_base::getverr() -{ - MESSAGE("PyInterp_base::getverr"); - PyObject *v; - v=PycStringIO->cgetvalue(_verr); - verr_buffer=PyString_AsString(v); - Py_DECREF(v); - return (char *)verr_buffer.c_str(); -} -char * PyInterp_base::getvout() -{ - MESSAGE("PyInterp_base::getvout"); - PyObject *v; - v=PycStringIO->cgetvalue(_vout); - vout_buffer=PyString_AsString(v); - Py_DECREF(v); - return (char *)vout_buffer.c_str(); -} - const char * PyInterp_base::getPrevious() { - MESSAGE("PyInterp_base::getPrevious"); - if (_ith != _history.begin()) - { - _ith--; - return (*_ith).c_str(); - } + if(_ith != _history.begin()){ + _ith--; + return (*_ith).c_str(); + } else return BEGIN_HISTORY_PY; } + const char * PyInterp_base::getNext() { - MESSAGE("PyInterp_base::getNext"); - if (_ith != _history.end()) - { - _ith++; - } + if(_ith != _history.end()){ + _ith++; + } if (_ith == _history.end()) return TOP_HISTORY_PY; else return (*_ith).c_str(); } + + +string PyInterp_base::getverr(){ + PyLockWrapper aLock(_tstate); + PyObjWrapper v(PycStringIO->cgetvalue(_verr)); + string aRet(PyString_AsString(v)); + return aRet; +} + + +string PyInterp_base::getvout(){ + PyLockWrapper aLock(_tstate); + PyObjWrapper v(PycStringIO->cgetvalue(_vout)); + string aRet(PyString_AsString(v)); + return aRet; +} + diff --git a/src/SALOMEGUI/PyInterp_base.h b/src/SALOMEGUI/PyInterp_base.h index 9fe277d6a..157d5c3f7 100644 --- a/src/SALOMEGUI/PyInterp_base.h +++ b/src/SALOMEGUI/PyInterp_base.h @@ -12,65 +12,126 @@ #ifndef _PYINTERP_BASE_H_ #define _PYINTERP_BASE_H_ -#include -#include #include #include -using namespace std; +#include + +#include + +class QSemaphore; +class QMutex; + +extern "C" PyObject * PyEval_EvalCode(PyObject *co, PyObject *g, PyObject *l); #define TOP_HISTORY_PY "--- top of history ---" #define BEGIN_HISTORY_PY "--- begin of history ---" -/*! - * We have our own routines which are identical to the SIP routines - * to not depend from SIP software evolutions - */ -extern "C" void salomeAcquireLock(); -extern "C" void salomeReleaseLock(); -extern "C" int salomeCondAcquireLock(); -extern "C" void salomeCondReleaseLock(int rellock); +class SemaphoreLock{ + QSemaphore* mySemaphore; + std::string myComment; + public: + SemaphoreLock(QSemaphore* theSemaphore, const char* theComment = ""); + ~SemaphoreLock(); +}; -/*! this class can only be used with derivation : - * 2 pure virtual methods, initstate() & initcontext() - */ -class PyInterp_base -{ +class PyLockWrapper{ + PyThreadState* myThreadState; + PyThreadState* mySaveThreadState; + public: + PyLockWrapper(PyThreadState* theThreadState); + ~PyLockWrapper(); +}; + + +class ThreadLock{ + QMutex* myMutex; + std::string myComment; + public: + ThreadLock(QMutex* theMutex, const char* theComment = ""); + ~ThreadLock(); +}; + + +bool IsPyLocked(); + +ThreadLock GetPyThreadLock(const char* theComment = ""); + + +class PyInterp_base{ public: static PyThreadState *_gtstate; static int _argc; static char* _argv[]; static PyObject *builtinmodule; static PyObject *salome_shared_modules_module; - + PyInterp_base(); ~PyInterp_base(); - void initialize(); + + virtual void initialize(); + int run(const char *command); - char * getverr(); - char * getvout(); - string getbanner(); + + PyLockWrapper GetLockWrapper(); + + std::string getbanner(); + std::string getverr(); + std::string getvout(); + const char * getPrevious(); const char * getNext(); - void enter(); - void quit(); - void basicRun(const char *command); protected: PyThreadState * _tstate; - PyObject * _vout; - PyObject * _verr; - PyObject * _g; - list _history; - list ::iterator _ith; + PyObject * _vout; + PyObject * _verr; + PyObject * _g; + std::list _history; + std::list::iterator _ith; bool _atFirst; int simpleRun(const char* command); int initRun(); virtual void initState() = 0; - virtual void initContext() =0; + virtual void initContext() = 0; }; + +class PyObjWrapper{ + PyObject* myObject; +public: + PyObjWrapper(PyObject* theObject): myObject(theObject) {} + PyObjWrapper(): myObject(0) {} + operator PyObject*(){ + return myObject; + } + PyObject* operator->(){ + return myObject; + } + PyObject* get(){ + return myObject; + } + bool operator!(){ + return !myObject; + } + bool operator==(PyObject* theObject){ + return myObject == theObject; + } + PyObject** operator&(){ + return &myObject; + } + PyObjWrapper& operator=(PyObjWrapper* theObjWrapper){ + Py_XDECREF(myObject); + myObject = theObjWrapper->myObject; + return *this; + } + virtual ~PyObjWrapper(){ + Py_XDECREF(myObject); + } +}; + + #endif diff --git a/src/SALOMEGUI/QAD_Action.h b/src/SALOMEGUI/QAD_Action.h index 0a82f62b6..5dcea8c45 100644 --- a/src/SALOMEGUI/QAD_Action.h +++ b/src/SALOMEGUI/QAD_Action.h @@ -37,19 +37,19 @@ class ActionMap { ActionMap() {} ~ActionMap() { - QMapIterator it; + QMapIterator it; for ( it = myMap.begin(); it != myMap.end(); it++ ) delete (QActionP*)it.data(); myMap.clear(); } - bool isEmpty() { return myMap.isEmpty(); } - void insert( const unsigned int id, QActionP* action ) { myMap[id] = action; } - QActionP* at( const unsigned int id ) { return myMap[id]; } + bool isEmpty() { return myMap.isEmpty(); } + void insert( const int id, QActionP* action ) { myMap[id] = action; } + QActionP* at( const int id ) { return myMap[id]; } void clear() { myMap.clear(); } - QActionP*& operator[] (const unsigned int id) { return myMap[id]; } - bool hasAction( const unsigned int id ) { return myMap.contains(id); } + QActionP*& operator[] (const int id) { return myMap[id]; } + bool hasAction( const int id ) { return myMap.contains(id); } private: - QMap myMap; + QMap myMap; }; diff --git a/src/SALOMEGUI/QAD_Application.cxx b/src/SALOMEGUI/QAD_Application.cxx index 252875c5c..eb8b43d5e 100644 --- a/src/SALOMEGUI/QAD_Application.cxx +++ b/src/SALOMEGUI/QAD_Application.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; /*! \class QAD_Application QAD_Application.h \brief Study manager for QAD-based application. @@ -61,7 +62,6 @@ #include #include #include -using namespace std; static bool checkPermission(QString fileName) { if ( QFile::exists( fileName ) ) { @@ -823,6 +823,8 @@ QAD_Study* QAD_Application::newStudy() newStudy = new QAD_Study( this, aStudy, StudyName); } + newStudy->Init(); + if ( newStudy->getResult() ) { addStudy( newStudy ); @@ -1243,11 +1245,13 @@ void QAD_Application::onStudyActivated(QAD_Study* study) myActiveStudy = study; - /* notification */ - onActiveStudyChanged( oldActiveStudy, myActiveStudy ); - + // VSR : call app activate before informing modules that active study is changed ===> /* application activated */ emit appActivated( this ); + + /* notification */ + onActiveStudyChanged( oldActiveStudy, myActiveStudy ); + // VSR : call app activate before informing modules that active study is changed <=== } /*! @@ -1257,8 +1261,8 @@ void QAD_Application::onStudyDeactivated(QAD_Study* study) { // MESSAGE ("QAD_Application::onStudyDeactivated init. "); QAD_ASSERT_DEBUG_ONLY ( myActiveStudy == study ); - myActiveStudy->onStudyDeactivated(); - myActiveStudy = 0; + if ( study ) + study->onStudyDeactivated(); // MESSAGE ("QAD_Application::onStudyDeactivated done. "); } diff --git a/src/SALOMEGUI/QAD_Config.cxx b/src/SALOMEGUI/QAD_Config.cxx index 593e2c41b..b9d734f16 100644 --- a/src/SALOMEGUI/QAD_Config.cxx +++ b/src/SALOMEGUI/QAD_Config.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; /*! \class QAD_Config QAD_Config.h \brief Settings file management for QAD-based application. @@ -39,7 +40,6 @@ #include #include #include -using namespace std; /*! diff --git a/src/SALOMEGUI/QAD_Config.h b/src/SALOMEGUI/QAD_Config.h index 24baa207b..e5b202a97 100644 --- a/src/SALOMEGUI/QAD_Config.h +++ b/src/SALOMEGUI/QAD_Config.h @@ -55,9 +55,9 @@ public: /** Gets directory of the local configuration file. */ QDir getConfigDir() const { return configDir; } - /** Sets directory of SALOME_ROOT. */ + /** Sets directory of KERNEL_ROOT. */ void setPrgDir(QDir _prgDir) { prgDir=_prgDir; } - /** Gets directory of SALOME_ROOT. */ + /** Gets directory of KERNEL_ROOT. */ QDir getPrgDir() const { return prgDir; } bool createConfigFile( bool overwrite=false ); diff --git a/src/SALOMEGUI/QAD_Desktop.cxx b/src/SALOMEGUI/QAD_Desktop.cxx index 9a100591e..3f2222027 100644 --- a/src/SALOMEGUI/QAD_Desktop.cxx +++ b/src/SALOMEGUI/QAD_Desktop.cxx @@ -43,6 +43,7 @@ #include "QAD_Desktop.h" #include "QAD_LeftFrame.h" #include "QAD_RightFrame.h" +#include "QAD_PyEditor.h" #include "QAD_Operation.h" #include "QAD_XmlHandler.h" #include "QAD_MessageBox.h" @@ -55,12 +56,13 @@ //NRI #include "QAD_HelpWindow.h" #include "QAD_DirListDlg.h" #include "QAD_WaitCursor.h" +#include "SALOMEGUI.h" #include "SALOMEGUI_OpenWith.h" #include "SALOMEGUI_StudyPropertiesDlg.h" #include "SALOMEGUI_TrihedronSizeDlg.h" #include "SALOMEGUI_ExternalBrowserDlg.h" #include "SALOMEGUI_LoadStudiesDlg.h" -#include "SALOME_Selection.h" +//#include "SALOME_Selection.h" #include "SALOME_InteractiveObject.hxx" #include "SALOME_ListIteratorOfListIO.hxx" #include "SALOMEGUI_AboutDlg.h" @@ -71,6 +73,8 @@ #include "SALOMEGUI_CloseDlg.h" #include "SALOMEGUI_ActivateComponentDlg.h" +#include "SALOME_Event.hxx" + // QT Includes #include #include @@ -93,12 +97,15 @@ #include #include +#include + #if QT_VERSION > 300 #include #include #endif // Open CASCADE Includes +#include #include #include #include @@ -313,10 +320,8 @@ myQueryClose( true ) tr("INF_RESOURCES"); //QMessageBox::warning( this, tr("WRN_WARNING"), errMsg, tr ("BUT_OK") ); } - - if ( !QString(list_composants[ind].modulename).isEmpty() ) - myCombo->insertItem( strdup(list_composants[ind].moduleusername) ); - + if ( ( resDir || moduleusername == "Salome" ) && !modulename.isEmpty() ) // VSR: Force "Salome" component to appear in the combo box + myCombo->insertItem( moduleusername ); } myCombo->adjustSize(); @@ -352,6 +357,7 @@ QAD_Desktop::~QAD_Desktop () //NRI : SAL2214 myNewViewPopup.clear(); //NRI : SAL2214 + myHelpContentsModulePopup.clear(); myToolsPopup.clear(); myPrefPopup.clear(); myStdActions.clear(); @@ -445,9 +451,28 @@ bool QAD_Desktop::eventFilter( QObject* o, QEvent* e ) } } } + else if ( e->type() == SALOME_EVENT ) { + SALOME_Event* aSE = (SALOME_Event*)((QCustomEvent*)e)->data(); + processEvent( aSE ); + // Signal the calling thread that the event has been processed + aSE->processed(); + ((QCustomEvent*)e)->setData( 0 ); + delete aSE; + return TRUE; + } return QMainWindow::eventFilter( o, e ); } +/*! + Dispatches to the target component GUI +*/ +void QAD_Desktop::processEvent( SALOME_Event* theEvent ) +{ + if ( !theEvent ) + return; + theEvent->Execute(); +} + /*! Creates and initializes the standard file operations such as 'New/Open/Save/SaveAs/Close' and 'Help'. @@ -583,9 +608,16 @@ void QAD_Desktop::createActions() exitAction->addTo( &myFilePopup ); myStdActions.insert ( FileExitId, exitAction ); + QAD_ASSERT( connect( &myFilePopup, SIGNAL(highlighted( int )), + this, SLOT(onFilePopupStatusText( int )) )); + + /* 'Edit' actions : provided by application only */ myEditPos = 0; + QAD_ASSERT( connect( &myEditPopup, SIGNAL(highlighted( int )), + this, SLOT(onEditPopupStatusText( int )) )); + /* 'View' actions */ /* toolbars popup menu */ myViewPopup.insertItem( tr("MEN_DESK_VIEW_TOOLBARS"), &myToolBarsPopup ); @@ -627,6 +659,9 @@ void QAD_Desktop::createActions() myViewPos = myViewPopup.count(); + QAD_ASSERT( connect( &myViewPopup, SIGNAL(highlighted( int )), + this, SLOT(onViewPopupStatusText( int )) )); + /* Parse xml file */ QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); if ( resMgr ) { @@ -934,17 +969,46 @@ void QAD_Desktop::createActions() /* 'Help' actions */ /* contents */ - QActionP* helpContentsAction = new QActionP( "", tr("MEN_DESK_HELP_CONTENTS"), Key_F1, this ); - helpContentsAction->setStatusTip ( tr("PRP_DESK_HELP_CONTENTS") ); - QAD_ASSERT(connect( helpContentsAction, SIGNAL(activated()), - this, SLOT( onHelpContents() ))); - helpContentsAction->addTo( &myHelpPopup ); - myStdActions.insert( HelpContentsId , helpContentsAction ); + // MZN : Commented + // QActionP* helpContentsAction = new QActionP( "", tr("MEN_DESK_HELP_CONTENTS"), Key_F1, this ); + // helpContentsAction->setStatusTip ( tr("PRP_DESK_HELP_CONTENTS") ); +// QAD_ASSERT(connect( helpContentsAction, SIGNAL(activated()), +// this, SLOT( onHelpContents() ))); +// helpContentsAction->addTo( &myHelpPopup ); +// myStdActions.insert( HelpContentsId , helpContentsAction ); - id = myHelpPopup.insertSeparator(); +// id = myHelpPopup.insertSeparator(); /* GUI contents */ - // NRI : Temporary commented + myHelpPopup.insertItem( tr("MEN_DESK_HELP_MODULECONTENTS"), &myHelpContentsModulePopup, HelpContentsModuleId); + bool toEnable = false; + + CORBA::Object_var objVarN = myNameService->Resolve("/Kernel/ModulCatalog"); + myCatalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN); + + SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants = + myCatalogue->GetComponentIconeList(); + + for (unsigned int ind = 0; ind < list_composants->length(); ind++) { + QString aModuleName = strdup(list_composants[ind].modulename) ; + QString dir; + if (dir = getenv( aModuleName + "_ROOT_DIR")) { + dir = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + "doc/salome/" ); + QString aFileName = aModuleName + "_index.html"; + if ( QFileInfo( dir + aFileName ).exists() ) { + QString aModuleUserName = strdup(list_composants[ind].moduleusername) ; + if ( aModuleUserName == "Salome" ) aModuleUserName = "Kernel" ; + QActionP* moduleHelpAction = new QActionP( "", aModuleUserName + " Help" , 0, this, aModuleName); + QAD_ASSERT(connect( moduleHelpAction, SIGNAL(activated()), this, SLOT(onHelpContentsModule() ))); + moduleHelpAction->addTo( &myHelpContentsModulePopup ); + if (!toEnable) toEnable = true; + } + } + } + + myHelpContentsModulePopup.setEnabled(toEnable); + + // NRI : Temporary commented // QActionP* helpContentsActionGUI = new QActionP( "", tr("MEN_DESK_HELP_GUICONTENTS"), 0, this ); // helpContentsActionGUI->setStatusTip ( tr("PRP_DESK_HELP_GUICONTENTS") ); @@ -953,13 +1017,22 @@ void QAD_Desktop::createActions() // helpContentsActionGUI->addTo( &myHelpPopup ); // myStdActions.insert( HelpContentsId , helpContentsActionGUI ); + /* TUI contents */ + /* QActionP* helpContentsActionTUI = new QActionP( "", tr("MEN_DESK_HELP_TUICONTENTS"), 0, this ); helpContentsActionTUI->setStatusTip ( tr("PRP_DESK_HELP_TUICONTENTS") ); QAD_ASSERT(connect( helpContentsActionTUI, SIGNAL(activated()), this, SLOT( onHelpContentsTUI() ))); helpContentsActionTUI->addTo( &myHelpPopup ); myStdActions.insert( HelpContentsId , helpContentsActionTUI ); + */ + + + // Provide status tip for Module help menu item + QAD_ASSERT( connect( &myHelpPopup, SIGNAL(highlighted( int )), this, + SLOT(onHelpModulePopupStatusText( int )) )); + /* search */ // QActionP* helpSearchAction = new QActionP( "", tr("MEN_DESK_HELP_SEARCH"), 0, this ); @@ -1800,15 +1873,7 @@ bool QAD_Desktop::onSaveAsStudy( QAD_Study* study ) */ bool QAD_Desktop::onCloseStudy() { - bool close = this->onCloseStudy ( myActiveStudy, true ); - if ( close && !myXmlHandler->myIdList.IsEmpty() ) { - clearMenus(); - myActiveComp = ""; - myCombo->setCurrentItem (0); - for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) { - aButton->setOn(false); - } - } + bool close = this->onCloseStudy ( getActiveStudy(), true ); return close; } @@ -1859,6 +1924,7 @@ bool QAD_Desktop::onCloseStudy( QAD_Study* study, bool ask ) /* close active component */ if (!myXmlHandler->myIdList.IsEmpty()) { + deactivateComponent(); clearMenus(); myActiveComp=""; myCombo->setCurrentItem (0); @@ -1962,10 +2028,10 @@ void QAD_Desktop::onSelectionMode() { const QActionP* obj = (QActionP*) sender(); - int SelectionMode = 4; + Selection_Mode SelectionMode = ActorSelection; if ( obj == myStdActions.at(SelectionActorId) ) { - SelectionMode = 4; + SelectionMode = ActorSelection; if ( obj->isOn() ) { myStdActions.at(SelectionCellId)->setOn(false); myStdActions.at(SelectionEdgeId)->setOn(false); @@ -1974,7 +2040,7 @@ void QAD_Desktop::onSelectionMode() myStdActions.at(SelectionActorId)->setOn(true); } else if ( obj == myStdActions.at(SelectionCellId) ) { - SelectionMode = 3; + SelectionMode = CellSelection; if ( obj->isOn() ) { myStdActions.at(SelectionActorId)->setOn(false); myStdActions.at(SelectionEdgeId)->setOn(false); @@ -1983,7 +2049,7 @@ void QAD_Desktop::onSelectionMode() myStdActions.at(SelectionActorId)->setOn(true); } else if ( obj == myStdActions.at(SelectionEdgeId) ) { - SelectionMode = 2; + SelectionMode = EdgeOfCellSelection; if ( obj->isOn() ) { myStdActions.at(SelectionActorId)->setOn(false); myStdActions.at(SelectionCellId)->setOn(false); @@ -1992,7 +2058,7 @@ void QAD_Desktop::onSelectionMode() myStdActions.at(SelectionActorId)->setOn(true); } else if ( obj == myStdActions.at(SelectionPointId) ) { - SelectionMode = 1; + SelectionMode = NodeSelection; if ( obj->isOn() ) { myStdActions.at(SelectionEdgeId)->setOn(false); myStdActions.at(SelectionCellId)->setOn(false); @@ -2011,10 +2077,10 @@ void QAD_Desktop::onSelectionMode() /*! Called on 'View\Selection Mode' */ -void QAD_Desktop::SetSelectionMode(int mode, bool activeCompOnly) +void QAD_Desktop::SetSelectionMode(Selection_Mode mode, bool activeCompOnly) { switch (mode) { - case 1: + case NodeSelection: { myStdActions.at(SelectionEdgeId)->setOn(false); myStdActions.at(SelectionCellId)->setOn(false); @@ -2022,7 +2088,7 @@ void QAD_Desktop::SetSelectionMode(int mode, bool activeCompOnly) myStdActions.at(SelectionPointId)->setOn(true); break; } - case 2: + case EdgeOfCellSelection: { myStdActions.at(SelectionActorId)->setOn(false); myStdActions.at(SelectionCellId)->setOn(false); @@ -2030,15 +2096,18 @@ void QAD_Desktop::SetSelectionMode(int mode, bool activeCompOnly) myStdActions.at(SelectionEdgeId)->setOn(true); break; } - case 3: - { + case CellSelection: + case EdgeSelection: + case FaceSelection: + case VolumeSelection: + { myStdActions.at(SelectionActorId)->setOn(false); myStdActions.at(SelectionEdgeId)->setOn(false); myStdActions.at(SelectionPointId)->setOn(false); myStdActions.at(SelectionCellId)->setOn(true); break; } - case 4: + case ActorSelection: { myStdActions.at(SelectionCellId)->setOn(false); myStdActions.at(SelectionEdgeId)->setOn(false); @@ -2128,6 +2197,16 @@ private: }; +// Provide status tip for GUI help menu item + +void QAD_Desktop::onHelpModulePopupStatusText(int id) +{ + int Id = myHelpPopup.idAt( 0 ); // HelpContentsModuleId + // MESSAGE ( "myHelpContentsModulePopup : " << id << "-" << Id) + if (id == Id) + putInfo("Shows the help contents of each module"); +} + /*! Called on 'help\contents' */ @@ -2158,41 +2237,42 @@ void QAD_Desktop::onHelpContents() } /*! - Called on 'help\GUI Reference' + Called on 'Module Help Reference' */ -void QAD_Desktop::onHelpContentsGUI() -{ -// QCString dir; -// QString root; -// QString homeDir; +void QAD_Desktop::onHelpContentsModule() +{ + const QActionP* obj = (QActionP*) sender(); -// if ( (dir = getenv("KERNEL_ROOT_DIR")) ) { -// root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + "doc" ); -// root = QAD_Tools::addSlash( root + "guihtml" ); -// root = QAD_Tools::addSlash( root + "guihtml" ); -// if ( QFileInfo( root + "salomedoc.html" ).exists() ) { -// homeDir = root; -// } -// } -// if ( root.isEmpty() ) { -// if ( QFileInfo( "/usr/local/doc/guihtml/salomedoc.html" ).exists() ) { -// homeDir = "/usr/local/doc/guihtml/"; -// } -// } -// 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"); + QString aComponentName = obj->name(); + QString aFileName = aComponentName + "_index.html"; + + QCString dir; + QString root; + QString homeDir; + if (dir = getenv( aComponentName + "_ROOT_DIR")) { + root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("doc") + QAD_Tools::addSlash("salome") ); + if ( QFileInfo( root + aFileName ).exists() ) { + homeDir = root; + } else { + QMessageBox::warning( this, tr("WRN_WARNING"), + QString( "%1"+ aFileName + " doesn't exist." ).arg(root), tr ("BUT_OK") ); + return; + } + } + + QString helpFile = QFileInfo( homeDir + aFileName ).absFilePath(); + QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application"); + QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters"); -// RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile); -// rs->start(); - + RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile); + rs->start(); } /*! Called on 'help\TUI Reference' */ + +/* Commented void QAD_Desktop::onHelpContentsTUI() { if (myActiveComp == "") @@ -2202,16 +2282,18 @@ void QAD_Desktop::onHelpContentsTUI() QString root; QString homeDir; if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) { - root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + QAD_Tools::addSlash("doc") + "html" ); + root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("doc") + "html" ); if ( QFileInfo( root + "index.html" ).exists() ) { homeDir = root; - } else { + } else if (QFileInfo( root + "html/index.html" ).exists()) + homeDir = root + QAD_Tools::addSlash("html"); + else { QMessageBox::warning( this, tr("WRN_WARNING"), QString( "%1index.html doesn't exist." ).arg(root), tr ("BUT_OK") ); return; } } - + QString helpFile = QFileInfo( homeDir + "index.html" ).absFilePath(); QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application"); @@ -2220,6 +2302,8 @@ void QAD_Desktop::onHelpContentsTUI() RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile); rs->start(); } +*/ + // /*! // Called on 'help\search' @@ -2359,10 +2443,10 @@ void QAD_Desktop::onWindowPopupAboutToShow() */ void QAD_Desktop::onWindowsPopupStatusText( int id ) { - int cascadeId = myWindowPopup.idAt( 0 ); - int tileId = myWindowPopup.idAt( 1 ); + int cascadeId = myWindowPopup.idAt( 1 ); + int tileId = myWindowPopup.idAt( 2 ); if ( id == cascadeId || id == tileId ) - return; + return; putInfo( tr("PRP_DESK_WINDOW_ACTIVATE") ); } @@ -2478,8 +2562,8 @@ 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++) { - QString compusername = getComponentUserName(strdup(list_type_composants[ind])); - if ( compusername.compare("") != 0 ) + QString compusername = getComponentUserName( strdup(list_type_composants[ind]) ); + if ( !compusername.isEmpty() ) aDlg->addComponent( compusername ); } @@ -2520,28 +2604,16 @@ void QAD_Desktop::onOpenWith() QApplication::restoreOverrideCursor(); } -typedef bool OneDim1(QAD_Desktop*); -typedef bool OneDim2(QAD_Desktop*, char*); /*! Called to define settings of component. */ void QAD_Desktop::setSettings() { - if (!myActiveComp.isEmpty()) { - OSD_Function osdF = mySharedLibrary.DlSymb("SetSettings"); - if ( osdF != NULL ) - if (_islibso) - { - OneDim1 (*f1) = (bool (*) (QAD_Desktop*)) osdF; - (*f1)(this); - } - else - { - QString Component =mapComponentName[myActiveComp]; - OneDim2 (*f1) = (bool (*) (QAD_Desktop*, char*)) osdF; - (*f1)(this, (char*)Component.latin1()); - } + SALOMEGUI* anActiveGUI = getActiveGUI(); + if ( anActiveGUI ) { + QString Component = mapComponentName[myActiveComp]; + anActiveGUI->SetSettings( this, (char*)Component.latin1() ); } } @@ -2621,95 +2693,16 @@ bool QAD_Desktop::loadComponent(QString Component) int nbToolbars = 0; if (myActiveMenus) nbToolbars = myActiveMenus->getToolBarList().count(); - /* Open Shared Library */ - mySharedLibrary = OSD_SharedLibrary(); - _islibso = false; - QString ComponentLib; - QCString libs; - QFileInfo fileInfo ; - QString fileString ; - QString dir; - - if ( libs = getenv("LD_LIBRARY_PATH")) { - // MESSAGE ( " LD_LIBRARY_PATH : " << libs ); - QStringList dirList = QStringList::split( SEPARATOR, libs, false ); // skip empty entries - for ( int i = dirList.count()-1; i >= 0; i-- ) { - dir = dirList[ i ]; -#ifdef WNT - fileString = QAD_Tools::addSlash( dir ) + "lib" + Component + "GUI.dll" ; -#else - fileString = QAD_Tools::addSlash( dir ) + "lib" + Component + "GUI.so" ; -#endif - - fileInfo.setFile(fileString) ; - if (fileInfo.exists()) { - // MESSAGE ( " GUI library = " << fileString ); - ComponentLib = fileInfo.fileName() ; - _islibso = true; - break; - } - } - } - - if (!_islibso) // component GUI could be in PyQt, use generic library - { - MESSAGE("GUI library not found, trying generic library for PyQt GUI"); - bool found = false; - if (dir = getenv("KERNEL_ROOT_DIR")) - { - dir = QAD_Tools::addSlash(dir) ; - dir = dir + "lib" ; - dir = QAD_Tools::addSlash(dir) ; - dir = dir + "salome" ; - dir = QAD_Tools::addSlash(dir) ; -#ifdef WNT - dir = dir + "libSalomePyQtcmodule.dll" ; -#else - dir = dir + "libSalomePyQtcmodule.so" ; -#endif - MESSAGE ( " GUI library = " << dir ); - fileInfo.setFile(dir) ; - if (fileInfo.exists()) - { - ComponentLib = fileInfo.fileName() ; - found = true; - } - } - if ( !found ) - { - QMessageBox::critical( this, - tr("ERR_ERROR"), - tr("ERR_LIBGUI" ).arg(Component) ); - return false; - } - } - - mySharedLibrary.SetName(TCollection_AsciiString((char*)ComponentLib.latin1()).ToCString()); - ok = mySharedLibrary.DlOpen(OSD_RTLD_LAZY); - if (!ok) { - wc.stop(); - QMessageBox::critical( this, - tr("ERR_ERROR"), - tr( mySharedLibrary.DlError() ) ); + // san - avoid loading component GUI library multiple times + QString aUserName( getComponentUserName( Component ) ); + + SALOMEGUI* anActiveGUI = getComponentGUI(aUserName); + if ( !anActiveGUI ) return false; - } /* SETTINGS */ - OSD_Function osdF = mySharedLibrary.DlSymb("SetSettings"); - if ( osdF != NULL ) - if (_islibso) - { - OneDim1 (*f1) = (bool (*) (QAD_Desktop*)) osdF; - (*f1)(this); - } - else - { - OneDim2 (*f1) = (bool (*) (QAD_Desktop*, char*)) osdF; - (*f1)(this, (char*)Component.latin1()); - } - - + anActiveGUI->SetSettings( this, (char*)Component.latin1() ); /* COMPONENT INTERFACE */ SALOME_ModuleCatalog::Acomponent_ptr aComponent = @@ -2773,7 +2766,8 @@ bool QAD_Desktop::loadComponent(QString Component) QString QAD_Desktop::changeXmlInputSourceData(QString theData, QString theComponent) { - if ( theComponent=="Supervision" ) { + // MESSAGE ( " changeXmlInputSourceData : " << theComponent.latin1() ) + if ( theComponent=="SUPERV" ) { //Supervision main menu item int aItemId = 300; int aPosId = 3; @@ -2782,7 +2776,7 @@ QString QAD_Desktop::changeXmlInputSourceData(QString theData, QString theCompon theData = theData.replace( QRegExp(aStrOld), aStrNew ); } - if ( theComponent == "Visu" ) { + if ( theComponent == "VISU" ) { //Visualization main menu item int aItemId = 401; int aPosId = 3; @@ -2835,44 +2829,44 @@ QString QAD_Desktop::changeXmlInputSourceData(QString theData, QString theCompon 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 ); +// aItemId = 80; +// aPosId = 7; +// aStrOld = createString( aItemId, aPosId ); +// aStrNew = createString( aItemId, aPosId+1 ); +// theData = theData.replace( QRegExp(aStrOld), aStrNew ); } - if ( theComponent == "Geometry" ) { + if ( theComponent == "GEOM" ) { //New Entity main menu item - int aItemId = 70; + int aItemId = 40; 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; + aItemId = 50; aPosId = 4; aStrOld = createString( aItemId, aPosId ); aStrNew = createString( aItemId, aPosId+1 ); theData = theData.replace( QRegExp(aStrOld), aStrNew ); //Repair main menu item - aItemId = 50; + aItemId = 60; aPosId = 5; aStrOld = createString( aItemId, aPosId ); aStrNew = createString( aItemId, aPosId+1 ); theData = theData.replace( QRegExp(aStrOld), aStrNew ); //Measures main menu item - aItemId = 60; + aItemId = 70; aPosId = 6; aStrOld = createString( aItemId, aPosId ); aStrNew = createString( aItemId, aPosId+1 ); theData = theData.replace( QRegExp(aStrOld), aStrNew ); } - if ( theComponent == "Med" ) { + if ( theComponent == "MED" ) { //MED main menu item int aItemId = 90; int aPosId = 3; @@ -2987,14 +2981,9 @@ void QAD_Desktop::onDispatchTools(int id) */ void QAD_Desktop::onDispatch(int id) { - if (!myActiveComp.isEmpty()) { - OSD_Function osdF = mySharedLibrary.DlSymb("OnGUIEvent"); - OneDim (*f1) = NULL; - if ( osdF != NULL ) { - f1 = (bool (*) (int, QAD_Desktop*)) osdF; - (*f1)(id,this); - } - } + SALOMEGUI* anActiveGUI = getActiveGUI(); + if ( anActiveGUI ) + anActiveGUI->OnGUIEvent(id,this); } /*! @@ -3014,6 +3003,9 @@ void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoad { if (myActiveStudy != 0) { if (myActiveComp.compare(component)!=0) { + // deactivate previous component + deactivateComponent(); + if (!myXmlHandler->myIdList.IsEmpty()) clearMenus(); if ( myCombo->currentText() != component ) myCombo->setCurrentText( component ); @@ -3077,8 +3069,13 @@ void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoad } } } else if (component.compare(QString("Salome"))!= 0) { - - SALOMEGUI_ActivateComponentDlg aDlg( this ); + + QPixmap pm; + for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) { + if ( aButton->textLabel().compare( component ) == 0 ) + pm = aButton->iconSet().pixmap(); + } + SALOMEGUI_ActivateComponentDlg aDlg( this, component, pm ); int res = aDlg.exec(); switch ( res ) @@ -3177,13 +3174,9 @@ typedef bool TwoDim1(QKeyEvent* pe, QAD_Desktop*, QAD_StudyFrame*); void QAD_Desktop::onKeyPress( QKeyEvent* pe ) { // MESSAGE ( "QAD_Desktop::onKeyPress" ) - if (!myActiveComp.isEmpty()) { - OSD_Function osdF = mySharedLibrary.DlSymb("OnKeyPress"); - if ( osdF != NULL ) { - TwoDim1 (*f1) = (bool (*) (QKeyEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF; - (*f1)(pe,this,myActiveStudy->getActiveStudyFrame()); - } - } + SALOMEGUI* anActiveGUI = getActiveGUI(); + if ( anActiveGUI ) + anActiveGUI->OnKeyPress(pe,this,myActiveStudy->getActiveStudyFrame()); } typedef bool TwoDim(QMouseEvent* pe, QAD_Desktop*, QAD_StudyFrame*); @@ -3193,13 +3186,9 @@ typedef bool TwoDim(QMouseEvent* pe, QAD_Desktop*, QAD_StudyFrame*); bool QAD_Desktop::onMousePress( QMouseEvent* pe ) { // MESSAGE ( "QAD_Desktop::onMousePress" ) - if (!myActiveComp.isEmpty()) { - OSD_Function osdF = mySharedLibrary.DlSymb("OnMousePress"); - if ( osdF != NULL ) { - TwoDim (*f1) = (bool (*) (QMouseEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF; - return (*f1)(pe,this,myActiveStudy->getActiveStudyFrame()); - } - } + SALOMEGUI* anActiveGUI = getActiveGUI(); + if ( anActiveGUI ) + return anActiveGUI->OnMousePress(pe,this,myActiveStudy->getActiveStudyFrame()); return false; } @@ -3208,13 +3197,9 @@ bool QAD_Desktop::onMousePress( QMouseEvent* pe ) */ void QAD_Desktop::onMouseMove( QMouseEvent* pe ) { - if (!myActiveComp.isEmpty()) { - OSD_Function osdF = mySharedLibrary.DlSymb("OnMouseMove"); - if ( osdF != NULL ) { - TwoDim (*f1) = (bool (*) (QMouseEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF; - (*f1)(pe,this,myActiveStudy->getActiveStudyFrame()); - } - } + SALOMEGUI* anActiveGUI = getActiveGUI(); + if ( anActiveGUI ) + anActiveGUI->OnMouseMove(pe,this,myActiveStudy->getActiveStudyFrame()); } /*! @@ -3225,55 +3210,179 @@ const QString& QAD_Desktop::getActiveComponent() const return myActiveComp; } +SALOMEGUI* QAD_Desktop::getActiveGUI() +{ + SALOMEGUI* anActiveGUI = 0; + if ( myComponents.find( myActiveComp ) != myComponents.end() ) + anActiveGUI = myComponents[myActiveComp]; + return anActiveGUI; +} -typedef bool defineP( QString & theContext, QString & theParent, QString & theObject); +typedef SALOMEGUI* (*ComponentGUI)(); -void QAD_Desktop::definePopup(QString & theContext, - QString & theParent, - QString & theObject ) +SALOMEGUI* QAD_Desktop::getComponentGUI( const QString& component ) { - if (!myActiveComp.isEmpty()) { - OSD_Function osdF = mySharedLibrary.DlSymb("definePopup"); + SALOMEGUI* aCompGUI = 0; + + // Load component GUI if requested for the first time + if ( myComponents.find( component ) == myComponents.end() ) { + OSD_SharedLibrary aSharedLibrary; + QString ComponentLib; + QCString libs; + QFileInfo fileInfo ; + QString fileString ; + QString dir; + + QAD_WaitCursor wc; + + _islibso= false; + + if ( libs = getenv("LD_LIBRARY_PATH")) { + // MESSAGE ( " LD_LIBRARY_PATH : " << libs ); + QStringList dirList = QStringList::split( SEPARATOR, libs, false ); // skip empty entries + for ( int i = dirList.count()-1; i >= 0; i-- ) { + dir = dirList[ i ]; +#ifdef WNT + fileString = QAD_Tools::addSlash( dir ) + "lib" + getComponentName( component ) + "GUI.dll" ; +#else + fileString = QAD_Tools::addSlash( dir ) + "lib" + getComponentName( component ) + "GUI.so" ; +#endif + + fileInfo.setFile(fileString) ; + if (fileInfo.exists()) { + // MESSAGE( " GUI library = " << fileString.latin1() ); + ComponentLib = fileInfo.fileName() ; + _islibso = true; + break; + } + } + } + + if (!_islibso) // component GUI could be in PyQt, use generic library + { + MESSAGE("GUI library not found, trying generic library for PyQt GUI"); + bool found = false; + if (dir = getenv("KERNEL_ROOT_DIR")) + { + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "lib" ; + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "salome" ; + dir = QAD_Tools::addSlash(dir) ; +#ifdef WNT + dir = dir + "libSalomePyQtcmodule.dll" ; +#else + dir = dir + "libSalomePyQtcmodule.so" ; +#endif + MESSAGE ( " GUI library = " << dir ); + fileInfo.setFile(dir) ; + if (fileInfo.exists()) + { + ComponentLib = fileInfo.fileName() ; + found = true; + } + } + if ( !found ) + { + QMessageBox::critical( this, + tr("ERR_ERROR"), + tr("ERR_LIBGUI" ).arg(component) ); + return aCompGUI; + } + } + + aSharedLibrary.SetName(TCollection_AsciiString((char*)ComponentLib.latin1()).ToCString()); + bool ok = aSharedLibrary.DlOpen(OSD_RTLD_LAZY); + if (!ok) { + wc.stop(); + QMessageBox::critical( this, + tr("ERR_ERROR"), + tr( aSharedLibrary.DlError() ) ); + return aCompGUI; + } + + OSD_Function osdF = aSharedLibrary.DlSymb("GetComponentGUI"); if ( osdF != NULL ) { - defineP (*f1) = (bool (*) (QString &, QString &, QString &)) osdF; - (*f1)(theContext, theParent, theObject); + ComponentGUI f1 = (SALOMEGUI* (*) ()) osdF; + SALOMEGUI* aCompGUI = (*f1)(); + if ( aCompGUI ) + myComponents.insert( component, aCompGUI ); + else { + wc.stop(); + QMessageBox::critical( this, + tr("ERR_ERROR"), + tr("ERR_GET_GUI_FAILED" ).arg(component) ); + return aCompGUI; + } + } + else { + wc.stop(); + QMessageBox::critical( this, + tr("ERR_ERROR"), + tr("ERR_GET_GUI_NOT_FOUND" ).arg(ComponentLib) ); + return aCompGUI; } } + aCompGUI = myComponents[component]; + return aCompGUI; } + +void QAD_Desktop::definePopup(QString & theContext, + QString & theParent, + QString & theObject ) +{ + SALOMEGUI* anActiveGUI = getActiveGUI(); + if ( anActiveGUI ) + anActiveGUI->DefinePopup(theContext, theParent, theObject); +} + + /*! - Create popup + Copy popup menu [ static ] */ -void QAD_Desktop::createPopup(QPopupMenu* popupFather, QPopupMenu* popup, - QString text, int popupID, bool separator) -{ - QMenuItem* item = popup->findItem(popupID); - if (item) { - QPopupMenu* popupChild = item->popup(); - if ( popupChild ) { - QPopupMenu* newPopup = new QPopupMenu; - int count = popupChild->count(); - // add items at the top of - for (int i = count - 1; i >= 0; i--) { - int j = popupChild->idAt(i); - QString text = popupChild->text(j); - createPopup( newPopup, popupChild, text, j); +static void makePopup( QPopupMenu* popup, QPopupMenu* fromPopup, QAD_Desktop* receiver ) +{ + // safe check + if ( !popup || !fromPopup ) + return; + // iterator through all popup items + for ( int i = fromPopup->count()-1; i >= 0; i-- ) { + int cmdId = fromPopup->idAt( i ); + QMenuItem* item = fromPopup->findItem( cmdId ); + if ( item ) { + // if item is a separator + if ( item->isSeparator() ) { + popup->insertSeparator( 0 ); + } + else { + QIconSet* iconSet = item->iconSet(); + QKeySequence accel = fromPopup->accel( cmdId ); + + QPopupMenu* popupChild = item->popup(); + // if item is a popup + if ( popupChild && popupChild != fromPopup ) { + QPopupMenu* newPopup = new QPopupMenu( popup ); + if ( iconSet ) + popup->insertItem( *iconSet, item->text(), newPopup, cmdId, 0 ); + else + popup->insertItem( item->text(), newPopup, cmdId, 0 ); + makePopup( newPopup, popupChild, receiver ); + } + // if item is a command + else { + if ( iconSet ) + popup->insertItem( *iconSet, item->text(), cmdId, 0 ); + else + popup->insertItem( item->text(), cmdId, 0 ); + popup->connectItem( cmdId, receiver, SLOT( onDispatch( int ) ) ); + } + popup->setAccel( accel, cmdId ); } - popupFather->insertItem(popup->text(popupID), - newPopup, popupID, 0); - } else { - if ( !text.isNull() ) { - popupFather->insertItem(popup->text(popupID), - this, - SLOT( onDispatch(int) ), 0, popupID, 0);// try adding item at the top - } /*else if ( separator ) - popupFather->insertTearOffHandle(-1, 0);*/ - else - popupFather->insertSeparator(0); } } } - + /*! Create popup */ @@ -3282,34 +3391,8 @@ void QAD_Desktop::createPopup(QPopupMenu* popup, const QString & theContext, { if ( !myActiveComp.isEmpty() && getOperatorMenus()->createPopupMenu(theContext,theParent,theObject) != NULL ) { - QPopupMenu* aPopup = getOperatorMenus()->createPopupMenu(theContext,theParent,theObject)->getPopup(); - int count = aPopup->count(); - - //for (int i = 0; i < count; i++) { - for (int i = count - 1; i >= 0; i--) { - int id = aPopup->idAt(i); - QString text = aPopup->text(id); - //QString mes("Inserting popup menu item loaded from XML: "); - //mes += text; - //MESSAGE ( mes.latin1() ) - if (i==0) - popup->insertItem(aPopup->text(id), - this, - SLOT( onDispatch(int) ), 0, id, 0);// try adding item at the top - else - createPopup( popup, aPopup, text, id); - } - } //else { - //QString mes("Popup does not exist for given (Context = "); - //mes += theContext; - //mes += ", Parent = "; - //mes += theParent; - //mes += ", Object = "; - //mes += theObject; - //MESSAGE (mes.latin1()) - //popup->clear(); - //} - + makePopup( popup, getOperatorMenus()->createPopupMenu(theContext,theParent,theObject)->getPopup(), this ); + } // IAPP Popup // Should be moved to SALOMEGUI_Application::onCreatePopup()... if ( myActiveComp.isEmpty() ) { @@ -3329,38 +3412,32 @@ void QAD_Desktop::createPopup(QPopupMenu* popup, const QString & theContext, } } } - -} -typedef bool activeStudyChanged(QAD_Desktop*); +} void QAD_Desktop::onActiveStudyChanged() { - if (!myActiveComp.isEmpty()) { - OSD_Function osdF = mySharedLibrary.DlSymb("activeStudyChanged"); - if ( osdF != NULL ) { - activeStudyChanged (*f1) = (bool (*) (QAD_Desktop*)) osdF; - (*f1)(this); - } - } + SALOMEGUI* anActiveGUI = getActiveGUI(); + if ( anActiveGUI ) + anActiveGUI->ActiveStudyChanged(this); +} + +void QAD_Desktop::deactivateComponent() +{ + SALOMEGUI* anActiveGUI = getActiveGUI(); + if ( anActiveGUI ) + anActiveGUI->Deactivate(); } -typedef bool customP(QAD_Desktop*, QPopupMenu*, const QString & theContext, - const QString & theParent, const QString & theObject); /*! Custom popup ( GUI Library ) */ void QAD_Desktop::customPopup(QPopupMenu* popup, const QString & theContext, const QString & theParent, const QString & theObject) { - if (!myActiveComp.isEmpty()) { - OSD_Function osdF = mySharedLibrary.DlSymb("customPopup"); - if ( osdF != NULL ) { - customP (*f1) = (bool (*) (QAD_Desktop*, QPopupMenu*, const QString &, - const QString &, const QString &)) osdF; - (*f1)(this, popup, theContext, theParent, theObject); - } - } + SALOMEGUI* anActiveGUI = getActiveGUI(); + if ( anActiveGUI ) + anActiveGUI->CustomPopup(this, popup, theContext, theParent, theObject); } void QAD_Desktop::onObjectBrowser() @@ -3579,6 +3656,7 @@ void QAD_Desktop::onViewerOCC() QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() ); if (c.isValid()) { + /* VSR : PAL5420 --------------------------------------------------- if ( myActiveApp ) { QList& studies = myActiveApp->getStudies(); for ( QAD_Study* study = studies.first(); study; study = studies.next() ) { @@ -3591,6 +3669,7 @@ void QAD_Desktop::onViewerOCC() } } } + VSR : PAL5420 --------------------------------------------------- */ QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorRed", c.red() ); QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorGreen", c.green() ); QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorBlue", c.blue() ); @@ -3614,6 +3693,7 @@ void QAD_Desktop::onGraphSupervisor() QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() ); if (c.isValid()) { + /* VSR : PAL5420 --------------------------------------------------- if ( myActiveApp ) { QList& studies = myActiveApp->getStudies(); for ( QAD_Study* study = studies.first(); study; study = studies.next() ) { @@ -3626,7 +3706,7 @@ void QAD_Desktop::onGraphSupervisor() } } } - + VSR : PAL5420 --------------------------------------------------- */ QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorRed", c.red() ); QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorGreen", c.green() ); QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorBlue", c.blue() ); @@ -3650,6 +3730,7 @@ void QAD_Desktop::onViewerVTK() QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() ); if (c.isValid()) { + /* VSR : PAL5420 --------------------------------------------------- if ( myActiveApp ) { QList& studies = myActiveApp->getStudies(); for ( QAD_Study* study = studies.first(); study; study = studies.next() ) { @@ -3662,7 +3743,7 @@ void QAD_Desktop::onViewerVTK() } } } - + VSR : PAL5420 --------------------------------------------------- */ QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorRed", c.red() ); QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorGreen", c.green() ); QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorBlue", c.blue() ); @@ -3682,12 +3763,13 @@ void QAD_Desktop::onPlot2d() color = QColor( bgRed, bgGreen, bgBlue ); } else { - color = QColor(0, 0, 0); + color = QColor(255, 255, 255); } color = QColorDialog::getColor( color, QAD_Application::getDesktop() ); if ( color.isValid() ) { + /* VSR : PAL5420 --------------------------------------------------- if ( myActiveApp ) { QList& studies = myActiveApp->getStudies(); for ( QAD_Study* study = studies.first(); study; study = studies.next() ) { @@ -3700,6 +3782,7 @@ void QAD_Desktop::onPlot2d() } } } + VSR : PAL5420 --------------------------------------------------- */ QStringList bgData; bgData.append( QString::number( color.red() ) ); bgData.append( QString::number( color.green() ) ); @@ -3820,6 +3903,88 @@ void QAD_Desktop::onUndoLevel() } } +/* Update status bar for File menu items */ +void QAD_Desktop::onFilePopupStatusText( int id ) +{ + QString component = getActiveComponent(); + + if (component != "") { + //one of the modules is active now + int importId = myFilePopup.idAt(8); + int exportId = myFilePopup.idAt(9); + int importTableId = myFilePopup.idAt(10); + + if (component == getComponentUserName("SMESH") || component == getComponentUserName("GEOM")) { + if (id == importId) + putInfo( tr("PRP_DESK_FILE_IMPORT") ); + if (id == exportId) + putInfo( tr("PRP_DESK_FILE_EXPORT") ); + } + if (component == getComponentUserName("VISU")) { + if (id == importId) + putInfo( tr("PRP_DESK_FILE_IMPORTMED") ); + if (id == importTableId) + putInfo( tr("PRP_DESK_FILE_IMPORTTABLE") ); + if (id == exportId) + putInfo( tr("PRP_DESK_FILE_EXPLOREMEDFILE") ); + } + if (component == getComponentUserName("SUPERV")) { + if (id == importId) + putInfo( tr("PRP_DESK_FILE_IMPORTDF") ); + if (id == exportId) + putInfo( tr("PRP_DESK_FILE_EXPORTDF") ); + } + } +} + +/* Update status bar for Edit menu items */ +void QAD_Desktop::onEditPopupStatusText( int id ) +{ + QString component = getActiveComponent(); + + if (component != "") { + //one of the modules is active now + + if (component == getComponentUserName("SMESH") || component == getComponentUserName("GEOM") ) { + int deleteId = myEditPopup.idAt(5); + if (id == deleteId) + putInfo( tr("PRP_DESK_EDIT_DELETE") ); + } + if (component == getComponentUserName("SUPERV") ) { + int newDFId = myEditPopup.idAt(5); + int modifyDFId = myEditPopup.idAt(6); + if (id == newDFId) + putInfo( tr("PRP_DESK_EDIT_NEWDF") ); + if (id == modifyDFId) + putInfo( tr("PRP_DESK_EDIT_MODIFYDF") ); + } + } +} + +/* Update status bar for View menu items */ +void QAD_Desktop::onViewPopupStatusText( int id ) +{ + QString component = getActiveComponent(); + + if (component != "") { + //one of the modules is active now + int DispModeId = myViewPopup.idAt(2); + + if (component == getComponentUserName("GEOM")) { + if (id == DispModeId) + putInfo( tr("PRP_DESK_VIEW_DISPLAYMODE") ); + } + if (component == getComponentUserName("SMESH")) { + int updateId = myViewPopup.idAt(3); + + if (id == DispModeId) + putInfo( tr("PRP_DESK_VIEW_DISPLAYMODE") ); + if (id == updateId) + putInfo( tr("PRP_DESK_VIEW_UPDATE") ); + } + } +} + /********************************************************************* ** 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 56f8a7907..96d3b9089 100644 --- a/src/SALOMEGUI/QAD_Desktop.h +++ b/src/SALOMEGUI/QAD_Desktop.h @@ -39,6 +39,7 @@ #include "SALOME_NamingService.hxx" #include "SALOME_LifeCycleCORBA.hxx" +#include "SALOME_Selection.h" // IDL Headers #include @@ -59,10 +60,9 @@ #include #include -// Open CASCADE Includes -#include - class QAD_XmlHandler; +class SALOMEGUI; +class SALOME_Event; class QAD_EXPORT QAD_Desktop : public QMainWindow { @@ -71,7 +71,7 @@ class QAD_EXPORT QAD_Desktop : public QMainWindow protected: //NRI - unused - : enum ComponentType {GEOM, MESH, SOLVER, DATA, VISU, OTHER} ; - enum { FileNewId = 0, FileOpenId, FileLoadId, FileCloseId, FileSaveId, FileSaveAsId, FilePropsId, FileExitId, + enum { FileNewId = -1000, FileOpenId, FileLoadId, FileCloseId, FileSaveId, FileSaveAsId, FilePropsId, FileExitId, ViewStatusBarId, SelectionPointId, SelectionEdgeId, SelectionCellId, SelectionActorId, PrefViewerOCCId, PrefViewerVTKId, PrefGraphSupervisorId, PrefViewerPlot2dId, @@ -86,7 +86,8 @@ protected: WindowNew3dId, ViewOCCId, ViewVTKId, ViewPlot2dId, //NRI : SAL2214 WindowCascadeId, WindowTileId, - HelpContentsId, HelpSearchId, HelpWhatsThisId, HelpAboutId }; + HelpContentsId, HelpContentsModuleId, + HelpSearchId, HelpWhatsThisId, HelpAboutId }; enum UpdateCommand { ActivateApp, DeactivateApp }; /* Desktop can be created only by application */ @@ -114,16 +115,13 @@ public: void definePopup(QString & theContext, QString & theParent, QString & theObject ); - - void createPopup(QPopupMenu* popupFather, QPopupMenu* popup, - QString text, int popupID, bool separator = false); void createPopup(QPopupMenu* popup, const QString & theContext, const QString & theParent, const QString & theObject ); void customPopup(QPopupMenu* popup, const QString & theContext, const QString & theParent, const QString & theObject); /* selection mode */ - void SetSelectionMode(int mode, bool activeCompOnly = false); + void SetSelectionMode(Selection_Mode mode, bool activeCompOnly = false); /* desktop */ void showDesktop(); @@ -155,6 +153,7 @@ public: bool loadComponent(QString); QString changeXmlInputSourceData(QString theData, QString theComponent); void activateComponent(const QString& theName, bool isLoadData = true); + void deactivateComponent(); void createStudy(); void setSettings(); @@ -163,8 +162,9 @@ public: QAD_Menus* getActiveMenus() {return myActiveMenus;} QAD_OperatorMenus* getOperatorMenus() {return myOperatorMenus;} - const OSD_SharedLibrary& getHandle() const {return mySharedLibrary;}// never return sych objects "by value" const QString& getActiveComponent() const; + SALOMEGUI* getActiveGUI(); + SALOMEGUI* getComponentGUI( const QString& ); // accepts component`s user name SALOME_NamingService* getNameService() {return myNameService;} Engines::Component_var getEngine(const char *containerName, @@ -220,6 +220,11 @@ protected slots: virtual void onWindowPopupAboutToShow(); void onWindowsPopupActivated( int id ); void onWindowsPopupStatusText( int id ); + void onHelpModulePopupStatusText(int id); + + void onFilePopupStatusText( int id ); + void onEditPopupStatusText( int id ); + void onViewPopupStatusText( int id ); void onSelectionMode(); @@ -245,8 +250,8 @@ protected slots: void onDeactivateApp(QAD_Application* app); void onHelpContents(); - void onHelpContentsGUI(); - void onHelpContentsTUI(); + void onHelpContentsModule(); + /* void onHelpContentsTUI(); */ /* void onHelpSearch(); */ void onHelpAbout(); @@ -285,11 +290,13 @@ protected: //NRI : SAL2214 QPopupMenu myNewViewPopup; //NRI : SAL2214 + QPopupMenu myHelpContentsModulePopup; + QPopupMenu myToolsPopup; QPopupMenu myPrefPopup; QPopupMenu mySelectionModePopup; QPopupMenu myWindowPopup; /* not customized by an application */ - + ActionMap myStdActions; /* default actions */ QToolBar* myStdToolBar; /* standard toolbar */ QStatusBar* myStatusBar; /* the only status bar */ @@ -317,12 +324,17 @@ protected: QMap mapComponentName; +private: + void processEvent( SALOME_Event* ); + +private: + typedef QMap ComponentMap; + private: static QAD_ResourceMgr* resourceMgr; static QPalette* palette; void createActions(); void updateActions(); - OSD_SharedLibrary mySharedLibrary; QAD_XmlHandler* myXmlHandler; QString myActiveComp; SALOME_NamingService* myNameService; @@ -331,6 +343,8 @@ private: QComboBox * myCombo; bool myQueryClose; bool _islibso; + + ComponentMap myComponents; }; /******************************************************************** diff --git a/src/SALOMEGUI/QAD_DirListDlg.cxx b/src/SALOMEGUI/QAD_DirListDlg.cxx index 542df51cf..a45638cd5 100644 --- a/src/SALOMEGUI/QAD_DirListDlg.cxx +++ b/src/SALOMEGUI/QAD_DirListDlg.cxx @@ -9,6 +9,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "QAD_DirListDlg.h" #include "QAD_Desktop.h" #include "QAD_FileDlg.h" @@ -18,7 +19,6 @@ #include #include #include -using namespace std; #define MIN_WIDTH 400 #define MIN_HEIGHT 200 diff --git a/src/SALOMEGUI/QAD_FileDlg.cxx b/src/SALOMEGUI/QAD_FileDlg.cxx index a8d717339..df22e1e21 100644 --- a/src/SALOMEGUI/QAD_FileDlg.cxx +++ b/src/SALOMEGUI/QAD_FileDlg.cxx @@ -9,6 +9,7 @@ // Module : SALOME // $Header$ +using namespace std; #include #include #include @@ -21,7 +22,6 @@ #include "QAD_FileDlg.h" #include "QAD_MessageBox.h" #include "QAD_Tools.h" -using namespace std; #define MIN_COMBO_SIZE 100 diff --git a/src/SALOMEGUI/QAD_FileValidator.cxx b/src/SALOMEGUI/QAD_FileValidator.cxx index d62145052..f12915a41 100644 --- a/src/SALOMEGUI/QAD_FileValidator.cxx +++ b/src/SALOMEGUI/QAD_FileValidator.cxx @@ -9,6 +9,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "QAD_FileValidator.h" #include "QAD_Application.h" #include "QAD_Desktop.h" @@ -16,7 +17,6 @@ #include #include -using namespace std; /* constructor */ QAD_FileValidator::QAD_FileValidator(QWidget* parent) : diff --git a/src/SALOMEGUI/QAD_Help.cxx b/src/SALOMEGUI/QAD_Help.cxx index e14035b59..ad6697036 100644 --- a/src/SALOMEGUI/QAD_Help.cxx +++ b/src/SALOMEGUI/QAD_Help.cxx @@ -26,8 +26,8 @@ // Module : SALOME // $Header$ -#include "QAD_Help.h" using namespace std; +#include "QAD_Help.h" /*! \class QAD_Help QAD_HelpL.h diff --git a/src/SALOMEGUI/QAD_HelpWindow.cxx b/src/SALOMEGUI/QAD_HelpWindow.cxx index 3aa9a8586..8f4322541 100644 --- a/src/SALOMEGUI/QAD_HelpWindow.cxx +++ b/src/SALOMEGUI/QAD_HelpWindow.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; /*! \class QAD_HelpWindow QAD_HelpWindow.h \brief Html browser for help. @@ -45,7 +46,6 @@ #include #include #include -using namespace std; /*! Constructor @@ -111,9 +111,9 @@ QAD_HelpWindow::QAD_HelpWindow() /* // look for index.html and set homeDir - // 1. $(SALOME_ROOT_DIR)/doc/index.html - // 2. $(SALOME_ROOT_DIR)/doc/html/index.html - // 3. $(SALOME_ROOT_DIR)/doc/html/html/index.html + // 1. $(KERNEL_ROOT_DIR)/doc/index.html + // 2. $(KERNEL_ROOT_DIR)/doc/html/index.html + // 3. $(KERNEL_ROOT_DIR)/doc/html/html/index.html // 4. /usr/local/doc/html/index.html QCString dir; diff --git a/src/SALOMEGUI/QAD_LeftFrame.cxx b/src/SALOMEGUI/QAD_LeftFrame.cxx index 8edb54c48..c3a021d26 100644 --- a/src/SALOMEGUI/QAD_LeftFrame.cxx +++ b/src/SALOMEGUI/QAD_LeftFrame.cxx @@ -26,10 +26,10 @@ // Module : SALOME // $Header$ +using namespace std; #include "QAD_LeftFrame.h" #include "QAD_ObjectBrowser.h" #include -using namespace std; /*! \class QAD_LeftFrame QAD_LeftFrame.h diff --git a/src/SALOMEGUI/QAD_ListMenuIdAction.cxx b/src/SALOMEGUI/QAD_ListMenuIdAction.cxx index 16bb368dc..04c8d041d 100644 --- a/src/SALOMEGUI/QAD_ListMenuIdAction.cxx +++ b/src/SALOMEGUI/QAD_ListMenuIdAction.cxx @@ -26,8 +26,8 @@ // Module : SALOME // $Header$ -#include "QAD_ListMenuIdAction.h" using namespace std; +#include "QAD_ListMenuIdAction.h" QAD_ListMenuIdAction::QAD_ListMenuIdAction(QPopupMenu* theMenu, int id, diff --git a/src/SALOMEGUI/QAD_ListPopupMenu.cxx b/src/SALOMEGUI/QAD_ListPopupMenu.cxx index 1d9e9a7b9..e5a5d134f 100644 --- a/src/SALOMEGUI/QAD_ListPopupMenu.cxx +++ b/src/SALOMEGUI/QAD_ListPopupMenu.cxx @@ -26,8 +26,8 @@ // Module : SALOME // $Header$ -#include "QAD_ListPopupMenu.h" using namespace std; +#include "QAD_ListPopupMenu.h" /*! Constructor. diff --git a/src/SALOMEGUI/QAD_ListView.cxx b/src/SALOMEGUI/QAD_ListView.cxx index 9b19755df..d555fd378 100644 --- a/src/SALOMEGUI/QAD_ListView.cxx +++ b/src/SALOMEGUI/QAD_ListView.cxx @@ -9,6 +9,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "QAD_ListView.h" #include @@ -24,7 +25,6 @@ #include #include -using namespace std; ////////////////////////////////////////////////////////////////////// // QAD_ListView class implementation diff --git a/src/SALOMEGUI/QAD_Menus.cxx b/src/SALOMEGUI/QAD_Menus.cxx index b7ddf6ae7..904ee2713 100644 --- a/src/SALOMEGUI/QAD_Menus.cxx +++ b/src/SALOMEGUI/QAD_Menus.cxx @@ -26,8 +26,8 @@ // Module : SALOME // $Header$ -#include "QAD_Menus.h" using namespace std; +#include "QAD_Menus.h" /*! Constructor. diff --git a/src/SALOMEGUI/QAD_Message.cxx b/src/SALOMEGUI/QAD_Message.cxx index 1f5f570c4..4730b1ee8 100644 --- a/src/SALOMEGUI/QAD_Message.cxx +++ b/src/SALOMEGUI/QAD_Message.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "QAD_Message.h" #include "QAD_Application.h" #include "QAD_Config.h" @@ -34,7 +35,6 @@ #include #include #include -using namespace std; enum { IdCopy, IdClear, IdSelectAll }; diff --git a/src/SALOMEGUI/QAD_MessageBox.cxx b/src/SALOMEGUI/QAD_MessageBox.cxx index 2f4160624..c6aad0f76 100644 --- a/src/SALOMEGUI/QAD_MessageBox.cxx +++ b/src/SALOMEGUI/QAD_MessageBox.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; /*! \class QAD_MessageBox QAD_MessageBox.h \brief Message dialog box for QAD-based application. @@ -36,7 +37,6 @@ // QT Includes #include #include -using namespace std; /*! Shows info message box with one button [ static ] diff --git a/src/SALOMEGUI/QAD_ObjectBrowser.cxx b/src/SALOMEGUI/QAD_ObjectBrowser.cxx index 9b7d93fc6..4516e9934 100644 --- a/src/SALOMEGUI/QAD_ObjectBrowser.cxx +++ b/src/SALOMEGUI/QAD_ObjectBrowser.cxx @@ -73,6 +73,14 @@ using namespace std; #define UC_CLEAR_ID 1000014 #define UC_SET_CURRENT_ID 1000016 + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + + /*! Small button which updates Object Browser's contents */ @@ -658,7 +666,7 @@ void QAD_ObjectBrowser::Update( SALOMEDS::SObject_ptr SO, myListViewMap[ RefSOEntry ].append( Item ); } else { - MESSAGE("QAD_ObjectBrowser::Update : noname item: "<GetID()); + if(MYDEBUG) MESSAGE("QAD_ObjectBrowser::Update : noname item: "<GetID()); } } else { // getting Value @@ -675,7 +683,7 @@ void QAD_ObjectBrowser::Update( SALOMEDS::SObject_ptr SO, myListViewMap[ CSOEntry ].append( Item ); } else { - MESSAGE("QAD_ObjectBrowser::Update : noname item: "<GetID()); + if(MYDEBUG) MESSAGE("QAD_ObjectBrowser::Update : noname item: "<GetID()); } // adding other attributes if (Item) { @@ -720,9 +728,12 @@ void QAD_ObjectBrowser::Update( SALOMEDS::SObject_ptr SO, QString msg; QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); if ( resMgr ) { - if(resMgr->loadResources( QString(aFatherName->Value()) + "GUI", msg )) { - QPixmap icon ( resMgr->loadPixmap( QString(aFatherName->Value()) + "GUI", - tr(aPixmap->GetPixMap()) /*tr( "ICON_OBJBROWSER_" + theComponent )*/ )); + //if(resMgr->loadResources( QString(aFatherName->Value()) + "GUI", msg )) { + if( resMgr->loadResources( QAD_Application::getDesktop()->getComponentName( QString( aFatherName->Value() ) ), msg ) ) { + QPixmap icon ( resMgr->loadPixmap( QAD_Application::getDesktop()->getComponentName( QString( aFatherName->Value() ) ), + tr( aPixmap->GetPixMap() ) /*tr( "ICON_OBJBROWSER_" + theComponent )*/ ) ); + //QPixmap icon ( resMgr->loadPixmap( QString(aFatherName->Value()) + "GUI", + //tr(aPixmap->GetPixMap()) /*tr( "ICON_OBJBROWSER_" + theComponent )*/ )); Item->setPixmap( 0, icon ); } } @@ -857,8 +868,8 @@ void QAD_ObjectBrowser::Update() QString msg; QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); if ( resMgr ) { - MESSAGE ( " Component " << aName->Value() ) - MESSAGE ( " Icon " << aPixmap->GetPixMap() ) + if(MYDEBUG) MESSAGE ( " Component " << aName->Value() ); + if(MYDEBUG) MESSAGE ( " Icon " << aPixmap->GetPixMap() ); if(resMgr->loadResources( QAD_Application::getDesktop()->getComponentName(QString(aName->Value())), msg )) { QPixmap icon ( resMgr->loadPixmap( QAD_Application::getDesktop()->getComponentName(QString(aName->Value())), tr(aPixmap->GetPixMap()) /*tr( "ICON_OBJBROWSER_" + theComponent )*/ )); diff --git a/src/SALOMEGUI/QAD_ObjectBrowserItem.cxx b/src/SALOMEGUI/QAD_ObjectBrowserItem.cxx index 696fb78f4..370358317 100644 --- a/src/SALOMEGUI/QAD_ObjectBrowserItem.cxx +++ b/src/SALOMEGUI/QAD_ObjectBrowserItem.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "QAD_ObjectBrowserItem.h" #include @@ -33,7 +34,6 @@ #include #include #include -using namespace std; /*! Constructors diff --git a/src/SALOMEGUI/QAD_Operation.cxx b/src/SALOMEGUI/QAD_Operation.cxx index 42e0bb955..87c99f194 100644 --- a/src/SALOMEGUI/QAD_Operation.cxx +++ b/src/SALOMEGUI/QAD_Operation.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; /*! \class QAD_Operation QAD_Operation.h \brief Base class for OCAF operations in QAD-based application. @@ -38,7 +39,6 @@ // QT Include #include -using namespace std; /*! Constructor diff --git a/src/SALOMEGUI/QAD_OperatorMenus.cxx b/src/SALOMEGUI/QAD_OperatorMenus.cxx index 34bc0290c..8ad4e40d0 100644 --- a/src/SALOMEGUI/QAD_OperatorMenus.cxx +++ b/src/SALOMEGUI/QAD_OperatorMenus.cxx @@ -26,9 +26,9 @@ // Module : SALOME // $Header$ +using namespace std; #include "QAD_OperatorMenus.h" #include "QAD_Desktop.h" -using namespace std; /*! Constructor. diff --git a/src/SALOMEGUI/QAD_ParserSettings.cxx b/src/SALOMEGUI/QAD_ParserSettings.cxx index cb8fb7692..b824dad2a 100644 --- a/src/SALOMEGUI/QAD_ParserSettings.cxx +++ b/src/SALOMEGUI/QAD_ParserSettings.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "QAD_ParserSettings.h" #include @@ -34,7 +35,7 @@ #include #include #include -using namespace std; + /*! Constructor. diff --git a/src/SALOMEGUI/QAD_Popup.cxx b/src/SALOMEGUI/QAD_Popup.cxx index 9bd085b6b..aa2c65a93 100644 --- a/src/SALOMEGUI/QAD_Popup.cxx +++ b/src/SALOMEGUI/QAD_Popup.cxx @@ -26,10 +26,10 @@ // Module : SALOME // $Header$ +using namespace std; #include "QAD.h" #include "QAD_Popup.h" #include "utilities.h" -using namespace std; /***************************************************************************** ** Class QAD_PopupClientServer diff --git a/src/SALOMEGUI/QAD_PyEditor.cxx b/src/SALOMEGUI/QAD_PyEditor.cxx index 488a50cd6..72e22033e 100644 --- a/src/SALOMEGUI/QAD_PyEditor.cxx +++ b/src/SALOMEGUI/QAD_PyEditor.cxx @@ -33,12 +33,11 @@ #include "QAD_Config.h" #include "QAD_Tools.h" #include "QAD_MessageBox.h" -//#include "QAD_RightFrame.h" -using namespace std; #include #include #include +#include // NRI : Temporary added // IDL Headers @@ -47,39 +46,175 @@ using namespace std; #include CORBA_SERVER_HEADER(SALOMEDS_Attributes) //NRI +using namespace std; + + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + + #define SIZEPR 4 enum { IdCopy, IdPaste, IdClear, IdSelectAll }; + +static QString PROMPT = ">>> "; + + +class TInitEditorThread : public QThread +{ +public: + TInitEditorThread(QAD_PyInterp*& theInterp, + QMutex* theStudyMutex, QMutex* theMutex, + QAD_PyEditor* theListener): + myInterp(theInterp), + myMutex(theMutex), + myStudyMutex(theStudyMutex), + myListener(theListener) + { + // san - commented as inefficient: sometimes event is processed significant period of time after this moment + //QThread::postEvent(myListener, new QCustomEvent(QAD_PyEditor::SET_WAIT_CURSOR)); + } + + virtual ~TInitEditorThread(){} + +protected: + virtual void run(){ + ThreadLock anEditorLock(myMutex,"TInitEditorThread::anEditorLock"); + ThreadLock aStudyLock(myStudyMutex,"TInitEditorThread::aStudyLock"); + ThreadLock aPyLock = GetPyThreadLock("TInitEditorThread::aPyLock"); + if(MYDEBUG) MESSAGE("TInitEditorThread::run() - myInterp = "<run( myCommand.latin1() ); + if(MYDEBUG) MESSAGE("TExecCommand::run() - myInterp = "< 0) + anId = QAD_PyEditor::PYTHON_INCOMPLETE; + myListener->myError = myInterp->getverr().c_str(); + myListener->myOutput = myInterp->getvout().c_str(); + }else{ + myListener->myError = ""; + myListener->myOutput = ""; + } + QThread::postEvent(myListener, new QCustomEvent(anId)); + QThread::postEvent(myListener, new QCustomEvent(QAD_PyEditor::UNSET_CURSOR)); + } + +private: + QMutex* myMutex; + QMutex* myStudyMutex; + QAD_PyInterp*& myInterp; + QAD_PyEditor* myListener; + QString myCommand; +}; + + /*! Constructor */ -QAD_PyEditor::QAD_PyEditor(QAD_PyInterp* interp, - QWidget *parent, const char *name) - : QMultiLineEdit(parent,name) +QAD_PyEditor::QAD_PyEditor(QAD_PyInterp*& theInterp, QMutex* theMutex, + QWidget *theParent, const char* theName): + QTextEdit(theParent,theName), + myStudyMutex(theMutex), + myInitEditorMutex(new QMutex), + myExecCommandMutex(new QMutex), + myInterp(theInterp), + myInitEditorThread(0), + myExecCommandThread(0) { QString fntSet = QAD_CONFIG->getSetting("Viewer:ConsoleFont"); QFont myFont = QAD_Tools::stringToFont( fntSet ); // QFont myFont("Courier",11); setFont(myFont); - _interp = interp; - string banner = _interp->getbanner(); - setText(banner.c_str()); - _isInHistory = false; - _currentPrompt = ">>> "; - // put error messages of interpreter if they exist. - _buf.truncate(0); - setText(_interp->getverr()); - setText(_currentPrompt); + setTextFormat(QTextEdit::PlainText); + + // san - This is necessary for troubleless initialization + setReadOnly( true ); + viewport()->setCursor( waitCursor ); + + myInitEditorThread = new TInitEditorThread(myInterp,myStudyMutex,myInitEditorMutex,this); + myExecCommandThread = new TExecCommandThread(myInterp,myStudyMutex,myExecCommandMutex,this); + + _currentPrompt = PROMPT; setPalette( QAD_Application::getPalette(true) ); setWordWrap(NoWrap); + connect(this,SIGNAL(returnPressed()),this,SLOT(handleReturn()) ); } + +void QAD_PyEditor::Init() +{ + myInitEditorThread->start(); +} + + /*! Destructor */ QAD_PyEditor::~QAD_PyEditor() { + if(MYDEBUG) MESSAGE("QAD_PyEditor::~QAD_PyEditor()"); + { + { + ThreadLock aLock(myInitEditorMutex,"myInitEditorMutex"); + delete myInitEditorThread; + } + delete myInitEditorMutex; + } + { + { + ThreadLock aLock(myExecCommandMutex,"myExecCommandMutex"); + delete myExecCommandThread; + } + delete myExecCommandMutex; + } } /*! @@ -87,12 +222,11 @@ QAD_PyEditor::~QAD_PyEditor() */ void QAD_PyEditor::setText(QString s) { -// MESSAGE("setText"); - int line=numLines()-1; - int col=lineLength(line); - insertAt(s,line,col); - int n = numLines()-1; - setCursorPosition( n, textLine(n).length()); + int para=paragraphs()-1; + int col=paragraphLength(para); + insertAt(s,para,col); + int n = paragraphs()-1; + setCursorPosition( n, paragraphLength(n)); } /*! @@ -100,9 +234,8 @@ void QAD_PyEditor::setText(QString s) */ void QAD_PyEditor::handleReturn() { - QApplication::setOverrideCursor( Qt::waitCursor ); int ret; - int line=numLines()-2; + int para=paragraphs()-2; // NRI : Temporary added SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); @@ -121,24 +254,11 @@ void QAD_PyEditor::handleReturn() } // NRI - _buf.append(textLine(line).remove(0,SIZEPR)); - ret = _interp->run(_buf); - if(ret <= 0) - { - _buf.truncate(0); - setText(_interp->getvout()); - setText(_interp->getverr()); - _currentPrompt = ">>> "; - setText(_currentPrompt); - } - if(ret == 1) - { - _buf.append("\n"); - _currentPrompt = "... "; - setText(_currentPrompt); - } - _isInHistory = false; - QApplication::restoreOverrideCursor(); + _buf.append(text(para).remove(0,SIZEPR)); + _buf.truncate( _buf.length() - 1 ); + setReadOnly( true ); + viewport()->setCursor( waitCursor ); + myExecCommandThread->exec(_buf.latin1()); } /* @@ -150,10 +270,10 @@ void QAD_PyEditor::mousePressEvent (QMouseEvent * event) QPopupMenu *popup = new QPopupMenu( this ); QMap idMap; - int line1, col1, line2, col2; - getMarkedRegion(&line1, &col1, &line2, &col2); - bool allSelected = getMarkedRegion(&line1, &col1, &line2, &col2) && - line1 == 0 && line2 == numLines()-1 && col1 == 0 && col2 == lineLength(line2); + int para1, col1, para2, col2; + getSelection(¶1, &col1, ¶2, &col2); + bool allSelected = hasSelectedText() && + para1 == 0 && para2 == paragraphs()-1 && col1 == 0 && para2 == paragraphLength(para2); int id; id = popup->insertItem( tr( "EDIT_COPY_CMD" ) ); idMap.insert(IdCopy, id); @@ -164,7 +284,7 @@ void QAD_PyEditor::mousePressEvent (QMouseEvent * event) popup->insertSeparator(); id = popup->insertItem( tr( "EDIT_SELECTALL_CMD" ) ); idMap.insert(IdSelectAll, id); - popup->setItemEnabled( idMap[ IdCopy ], hasMarkedText() ); + popup->setItemEnabled( idMap[ IdCopy ], hasSelectedText() ); popup->setItemEnabled( idMap[ IdPaste ], !isReadOnly() && (bool)QApplication::clipboard()->text().length() ); popup->setItemEnabled( idMap[ IdSelectAll ], @@ -181,8 +301,7 @@ void QAD_PyEditor::mousePressEvent (QMouseEvent * event) } else if ( r == idMap[ IdClear ] ) { clear(); - string banner = _interp->getbanner(); - setText(banner.c_str()); + setText(myBanner); setText(_currentPrompt); } else if ( r == idMap[ IdSelectAll ] ) { @@ -191,7 +310,7 @@ void QAD_PyEditor::mousePressEvent (QMouseEvent * event) return; } else { - QMultiLineEdit::mousePressEvent(event); + QTextEdit::mousePressEvent(event); } } @@ -201,14 +320,14 @@ void QAD_PyEditor::mousePressEvent (QMouseEvent * event) void QAD_PyEditor::mouseReleaseEvent ( QMouseEvent * e ) { // MESSAGE("mouseReleaseEvent"); - int curLine, curCol; // for cursor position - int endLine, endCol; // for last edited line - getCursorPosition(&curLine, &curCol); - endLine = numLines() -1; + int curPara, curCol; // for cursor position + int endPara, endCol; // for last edited line + getCursorPosition(&curPara, &curCol); + endPara = paragraphs() -1; if (e->button() != MidButton) - QMultiLineEdit::mouseReleaseEvent(e); - else if ((curLine == endLine) && (curCol >= SIZEPR)) - QMultiLineEdit::mouseReleaseEvent(e); + QTextEdit::mouseReleaseEvent(e); + else if ((curPara == endPara) && (curCol >= SIZEPR)) + QTextEdit::mouseReleaseEvent(e); } /*! @@ -216,7 +335,7 @@ void QAD_PyEditor::mouseReleaseEvent ( QMouseEvent * e ) */ void QAD_PyEditor::dropEvent (QDropEvent *e) { - INFOS("dropEvent : not handled"); + MESSAGE("dropEvent : not handled"); } /*! @@ -239,7 +358,7 @@ void QAD_PyEditor::keyPressEvent( QKeyEvent *e ) int curLine, curCol; // for cursor position int endLine, endCol; // for last edited line getCursorPosition(&curLine, &curCol); - endLine = numLines() -1; + endLine = paragraphs() -1; //MESSAGE("current position " << curLine << ", " << curCol); //MESSAGE("last line " << endLine); //MESSAGE(e->key()); @@ -257,34 +376,30 @@ void QAD_PyEditor::keyPressEvent( QKeyEvent *e ) { case 0 : { - if (curLine 0 ){ - setCursorPosition(curLine-1, curCol, true); + moveCursor(QTextEdit::MoveUp, true); } // scroll the commands stack up else { @@ -292,18 +407,18 @@ void QAD_PyEditor::keyPressEvent( QKeyEvent *e ) if (! _isInHistory) { _isInHistory = true; - _currentCommand = textLine(endLine).remove(0,SIZEPR); + _currentCommand = text(endLine).remove(0,SIZEPR); + _currentCommand.truncate( _currentCommand.length() - 1 ); SCRUTE(_currentCommand); } - QString previousCommand = _interp->getPrevious(); + QString previousCommand = myInterp->getPrevious(); if (previousCommand.compare(BEGIN_HISTORY_PY) != 0) { - removeLine(endLine); + removeParagraph(endLine); histLine.append(previousCommand); - insertLine(histLine); + insertParagraph(histLine, -1); } - endLine = numLines() -1; - setCursorPosition(endLine, lineLength(endLine)); + moveCursor(QTextEdit::MoveEnd, false); } break; } @@ -311,74 +426,91 @@ void QAD_PyEditor::keyPressEvent( QKeyEvent *e ) { // if Cntr+Key_Down event then move cursor down if (ctrlPressed) { - QMultiLineEdit::cursorDown( ); + moveCursor(QTextEdit::MoveDown, false); } // if Shift+Key_Down event then move cursor down and select the text else if ( shftPressed && curLine < endLine ) { - setCursorPosition(curLine+1, curCol, true); + moveCursor(QTextEdit::MoveDown, true); } // scroll the commands stack down else { QString histLine = _currentPrompt; - QString nextCommand = _interp->getNext(); + QString nextCommand = myInterp->getNext(); if (nextCommand.compare(TOP_HISTORY_PY) != 0) { - removeLine(endLine); + removeParagraph(endLine); histLine.append(nextCommand); - insertLine(histLine); + insertParagraph(histLine, -1); } else if (_isInHistory) { _isInHistory = false; - removeLine(endLine); + removeParagraph(endLine); histLine.append(_currentCommand); - insertLine(histLine); + insertParagraph(histLine, -1); } - endLine = numLines() -1; - setCursorPosition(endLine, lineLength(endLine)); + moveCursor(QTextEdit::MoveEnd, false); } break; } case Key_Left: { - if (!shftPressed && isCommand(textLine(curLine)) && curCol <= SIZEPR ) + if (!shftPressed && isCommand(text(curLine)) && curCol <= SIZEPR ) { setCursorPosition((curLine -1), SIZEPR); - end(); + moveCursor(QTextEdit::MoveLineEnd, false); } - else QMultiLineEdit::keyPressEvent( e ); + else QTextEdit::keyPressEvent( e ); break; } case Key_Right: { - if (!shftPressed && isCommand(textLine(curLine)) - && curCol < SIZEPR) setCursorPosition(curLine, SIZEPR-1); - QMultiLineEdit::keyPressEvent( e ); + if (!shftPressed && isCommand(text(curLine)) + && curCol < SIZEPR) setCursorPosition(curLine, SIZEPR); + QTextEdit::keyPressEvent( e ); break; } case Key_Home: { - if (isCommand(textLine(curLine)) && curCol <= SIZEPR) - setCursorPosition(curLine, SIZEPR, shftPressed); - else setCursorPosition(curLine, 0, shftPressed); + horizontalScrollBar()->setValue( horizontalScrollBar()->minValue() ); + if (isCommand(text(curLine))) { + setCursorPosition(curLine, SIZEPR); + if ( curCol > SIZEPR && shftPressed ) + setSelection( curLine, SIZEPR, curLine, curCol ); + else + selectAll( false ); + } + else moveCursor(QTextEdit::MoveLineStart, shftPressed); break; } case Key_End: { - setCursorPosition(curLine, textLine(curLine).length(), shftPressed); + moveCursor(QTextEdit::MoveLineEnd, shftPressed); break; } case Key_Backspace : { if ((curLine == endLine) && (curCol > SIZEPR)) - QMultiLineEdit::keyPressEvent( e ); + QTextEdit::keyPressEvent( e ); break; } case Key_Delete : { if ((curLine == endLine) && (curCol > SIZEPR-1)) - QMultiLineEdit::keyPressEvent( e ); + QTextEdit::keyPressEvent( e ); + break; + } + case Key_Insert : + { + if ( ctrlPressed ) + copy(); + else if ( shftPressed ) { + moveCursor(QTextEdit::MoveEnd, false); + paste(); + } + else + QTextEdit::keyPressEvent( e ); break; } } @@ -398,3 +530,48 @@ void QAD_PyEditor::keyPressEvent( QKeyEvent *e ) QAD_Application::getDesktop()->onKeyPress( e ); // NRI // } + +void QAD_PyEditor::customEvent(QCustomEvent *e) +{ + switch( e->type() ) { + case PYTHON_OK: + case PYTHON_ERROR: + { + _buf.truncate(0); + setText(myOutput); + setText(myError); + _currentPrompt = ">>> "; + setText(_currentPrompt); + break; + } + case PYTHON_INCOMPLETE: + { + _buf.append("\n"); + _currentPrompt = "... "; + setText(_currentPrompt); + break; + } + case INITIALIZE: + { + setText(myInterp->getbanner().c_str()); + _buf.truncate(0); + QApplication::restoreOverrideCursor(); + break; + } + case SET_WAIT_CURSOR: + { + viewport()->setCursor( waitCursor ); + break; + } + case UNSET_CURSOR: + { + viewport()->unsetCursor(); + break; + } + default: + QTextEdit::customEvent( e ); + } + + setReadOnly( false ); + _isInHistory = false; +} diff --git a/src/SALOMEGUI/QAD_PyEditor.h b/src/SALOMEGUI/QAD_PyEditor.h index 5086b7d94..fd7ff4955 100644 --- a/src/SALOMEGUI/QAD_PyEditor.h +++ b/src/SALOMEGUI/QAD_PyEditor.h @@ -29,36 +29,61 @@ #ifndef QAD_PyEditor_H #define QAD_PyEditor_H -#include +#include +#include + +class QMutex; class QAD_PyInterp; +class TInitEditorThread; +class TExecCommandThread; -class QAD_PyEditor : public QMultiLineEdit +class QAD_PyEditor : public QTextEdit { - Q_OBJECT + Q_OBJECT; + + friend class TInitEditorThread; + friend class TExecCommandThread; + +public: + enum { PYTHON_OK = QEvent::User + 5000, PYTHON_ERROR, PYTHON_INCOMPLETE, + INITIALIZE, SET_WAIT_CURSOR, UNSET_CURSOR }; public: - QAD_PyEditor(QAD_PyInterp* interp, QWidget *parent=0, const char *name=0); + QAD_PyEditor(QAD_PyInterp*& theInterp, QMutex* theMutex, + QWidget *theParent = 0, const char* theName = ""); + virtual void Init(); ~QAD_PyEditor(); - void setText(QString s); + virtual void setText(QString s); bool isCommand(const QString& str) const; protected: - void keyPressEvent (QKeyEvent * e); - void mousePressEvent (QMouseEvent * e); - void mouseReleaseEvent (QMouseEvent * e); - void dropEvent (QDropEvent *e); + virtual void keyPressEvent (QKeyEvent * e); + virtual void mousePressEvent (QMouseEvent * e); + virtual void mouseReleaseEvent (QMouseEvent * e); + virtual void dropEvent (QDropEvent *e); + virtual void customEvent (QCustomEvent *e); public slots: void handleReturn(); private: - QAD_PyInterp * _interp; QString _buf; QString _currentCommand; QString _currentPrompt; bool _isInHistory; + + QAD_PyInterp*& myInterp; + QMutex* myStudyMutex; + QMutex* myInitEditorMutex; + QMutex* myExecCommandMutex; + TInitEditorThread* myInitEditorThread; + TExecCommandThread* myExecCommandThread; + + QString myBanner; + QString myOutput; + QString myError; }; #endif diff --git a/src/SALOMEGUI/QAD_PyInterp.cxx b/src/SALOMEGUI/QAD_PyInterp.cxx index d01da91fa..d7da14e42 100644 --- a/src/SALOMEGUI/QAD_PyInterp.cxx +++ b/src/SALOMEGUI/QAD_PyInterp.cxx @@ -28,8 +28,17 @@ #include "QAD_PyInterp.h" #include "utilities.h" + using namespace std; + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + + /*! * constructor : multi Python interpreter, one per SALOME study. * calls initialize method defined in base class, which calls virtual methods @@ -37,7 +46,6 @@ using namespace std; */ QAD_PyInterp::QAD_PyInterp(): PyInterp_base() { - initialize(); } QAD_PyInterp::~QAD_PyInterp() @@ -64,71 +72,58 @@ QAD_PyInterp::~QAD_PyInterp() void QAD_PyInterp::initState() { - MESSAGE("QAD_PyInterp::initState"); - salomeAcquireLock(); //acquire python global lock (one for all interpreters) - _tstate = Py_NewInterpreter(); //create an interpreter and save current state - SCRUTE(_tstate); - SCRUTE(PyInterp_base::_argc); - SCRUTE(PyInterp_base::_argv[0]); - PySys_SetArgv(PyInterp_base::_argc,PyInterp_base::_argv); // initialize sys.argv + _tstate = Py_NewInterpreter(); // create an interpreter and save current state + PySys_SetArgv(PyInterp_base::_argc,PyInterp_base::_argv); // initialize sys.argv + if(MYDEBUG) MESSAGE("QAD_PyInterp::initState - this = "<ob_refcnt); // builtinmodule reference counter - _tstate->interp->builtins = PyModule_GetDict(builtinmodule); - Py_INCREF(_tstate->interp->builtins); + if(builtinmodule){ + PyObject *m = PyImport_GetModuleDict(); + PyDict_SetItemString(m, "__builtin__", builtinmodule); + SCRUTE(builtinmodule->ob_refcnt); // builtinmodule reference counter + _tstate->interp->builtins = PyModule_GetDict(builtinmodule); + Py_INCREF(_tstate->interp->builtins); + } } + void QAD_PyInterp::initContext() { - MESSAGE("QAD_PyInterp::initContext"); - PyObject *m; - m=PyImport_AddModule("__main__"); // interpreter main module (module context) - if(m == NULL) - { - MESSAGE("problem..."); - PyErr_Print(); - ASSERT(0); - salomeReleaseLock(); - return; - } + PyObject *m = PyImport_AddModule("__main__"); // interpreter main module (module context) + if(!m){ + if(MYDEBUG) MESSAGE("problem..."); + PyErr_Print(); + ASSERT(0); + return; + } _g = PyModule_GetDict(m); // get interpreter dictionnary context - SCRUTE(_g); + if(MYDEBUG) MESSAGE("QAD_PyInterp::initContext - this = "< #include -using namespace std; /* configuration file */ static const char* CONFIG_FILE = "config"; @@ -56,6 +56,7 @@ static const char* RES_DOCS = "docs"; static const char* RES_PIXMAPS = "icons"; static const char* RES_STRINGS = "strings"; static const char* RES_LANGUAGE = "language"; +static const char* RES_FILES = "resources"; static const char* SEPARATOR = ":"; @@ -125,8 +126,11 @@ bool QAD_ResourceMgr::loadResources( const char* prefix, QString &msg ) */ QString resDirs = collectDirs( prefix ); conf.insert( RES_DIR, new QString( resDirs ) ); - QString fileConfig = path( CONFIG_FILE, prefix, 0 ) ; + QString fileConfig = QString( prefix ) + QString( "." ) + QString( CONFIG_FILE ); + fileConfig = path( fileConfig, prefix, 0 ) ; //MESSAGE("QAD_ResourceMgr::loadresources : config : "<= 0; i-- ) { - QString dir = dirList[ i ]; - QString fileString = QAD_Tools::addSlash( dir ) + stFile; - QString fileImage = QAD_Tools::addSlash( dir ) + imagesFile; + QStringList resFiles = conf[ RES_FILES ] ? QStringList::split( SEPARATOR, *( conf[ RES_FILES ] ), false ) : QStringList(); + + // first load main module's resources + QString fileString = path( stFile, prefix, 0 ); + QString fileImage = path( imagesFile, prefix, 0 ); + + if ( !fileString.isEmpty() && settings->load( fileString ) ) { + bLoadString = true; + } + if ( !fileImage.isEmpty() && settings->load( fileImage ) ) { + bLoadImages = true; + } + + // then load additional module's resources if any are given + for ( int j = 0; j < resFiles.count(); j++ ) { + QString stFileAdd = resFiles[j] + "_msg_" + *( conf[ RES_LANGUAGE ] ) + ".qm" ; + QString imagesFileAdd = resFiles[j] + "_" + RES_PIXMAPS + ".qm"; + if ( conf[ RES_STRINGS ] && !conf[ RES_STRINGS ]->isEmpty() ) + stFileAdd = QAD_Tools::addSlash( *conf[ RES_STRINGS ] ) + stFileAdd; + if ( conf[ RES_PIXMAPS ] && !conf[ RES_PIXMAPS ]->isEmpty() ) + imagesFileAdd = QAD_Tools::addSlash( *conf[ RES_PIXMAPS ] ) + imagesFileAdd; - if ( settings->load( fileString ) ) { - bLoadString = true; - } - if ( settings->load( fileImage ) ) { - bLoadImages = true; - } + QString fileStringAdd = path( stFileAdd, prefix, 0 ); + QString fileImageAdd = path( imagesFileAdd, prefix, 0 ); + + if ( !fileStringAdd.isEmpty() ) + settings->load( fileStringAdd ); + if ( !fileImageAdd.isEmpty() ) + settings->load( fileImageAdd ); } - + if ( !bLoadString ) { QString warnMsg; warnMsg.sprintf( "String resources for module %s not found.\n" @@ -241,14 +262,14 @@ QString QAD_ResourceMgr::resources( const char* prefix ) const can be situated The order is following : - _ROOT_DIR/share/salome/resources directory - - CSF_Resources env.var directory ( or directory list ) + - SALOME_Resources env.var directory ( or directory list ) - ${HOME}/.salome/resources directory - KERNEL_ROOT_DIR/share/salome/resources directory */ QString QAD_ResourceMgr::collectDirs( const QString& prefix ) const { QString dirList; - QCString envVar( "CSF_" ); + QCString envVar; QString dir; char* cenv; @@ -270,9 +291,9 @@ QString QAD_ResourceMgr::collectDirs( const QString& prefix ) const } } - // Try CSF_Resources env.var directory ( or directory list ) + // Try SALOME_Resources env.var directory ( or directory list ) if ( !prefix.isEmpty() ) { - envVar = QCString( "CSF_" ) + prefix.latin1() + QCString( "Resources" ); + envVar = QCString( "SALOME_" ) + prefix.latin1() + QCString( "Resources" ); cenv = getenv( ( const char* ) envVar ); if ( cenv ) { dir.sprintf( "%s", cenv ); @@ -357,8 +378,6 @@ QString QAD_ResourceMgr::findFile( const QString& filename, const char* prefix ) */ QString QAD_ResourceMgr::path( const QString& filename, const char* prefix, const char* key ) const { - QString filePath; - ResourceSettings* rs = myRes[ prefix ]; if ( rs ) { StringDict& conf = rs->config(); @@ -369,22 +388,20 @@ QString QAD_ResourceMgr::path( const QString& filename, const char* prefix, cons for ( int i = 0; i < dirList.count(); i++ ) { QString dir = dirList[ i ]; dir = QAD_Tools::addSlash( dir ); - if ( key ) { - QString* where = conf[ key ]; - if ( where ) - dir = dir + QAD_Tools::addSlash( *where ); + if ( key && conf[ key ] ) { + dir = dir + QString( *( conf[ key ] ) ); + dir = QAD_Tools::addSlash( dir ); } dir = dir + filename; QFileInfo fileInfo( dir ); if ( fileInfo.isFile() && fileInfo.exists() ) { - filePath = fileInfo.filePath(); - break; + return fileInfo.filePath(); } } } } //MESSAGE("QAD_ResourceMgr::path : <"< : "< // QT Include @@ -38,6 +41,7 @@ // Open CASCADE Include #include + using namespace std; /*! @@ -51,19 +55,19 @@ typedef QAD_ViewFrame* View(QAD_RightFrame*); /*! Constructor */ -QAD_RightFrame::QAD_RightFrame(QWidget *parent, const char *name, - QAD_PyInterp* interp, ViewType vt) - : QAD_Splitter( Qt::Vertical, parent, name ) +QAD_RightFrame::QAD_RightFrame(QWidget *theParent, + const char *theTitle, ViewType theTypeView, + QAD_PyInterp*& theInterp, QMutex* theMutex): + QAD_Splitter( Qt::Vertical, theParent, theTitle ), + myViewType(theTypeView), + myInterp(theInterp) { this->setCompressEnabled( true ); - myViewType = vt; QAD_Desktop* Desktop = QAD_Application::getDesktop(); int DesktopHeight = Desktop->getMainFrame()->width(); int DesktopWidth = Desktop->getMainFrame()->height(); - _interp = interp; - OSD_SharedLibrary SharedLib = OSD_SharedLibrary(); QString ComponentLib; QCString dir; @@ -184,12 +188,15 @@ QAD_RightFrame::QAD_RightFrame(QWidget *parent, const char *name, QValueList sizes; myViewFrame->setMinimumSize( 1, 1 ); - vsplitter = new QAD_Splitter( Qt::Horizontal, this ); - vsplitter->setMinimumSize( 1, 1 ); - vsplitter->setCompressEnabled( true ); - myPyEditor = new QAD_PyEditor(_interp, vsplitter ,"Python Interpreter"); + mySplitter = new QAD_Splitter( Qt::Horizontal, this ); + mySplitter->setMinimumSize( 1, 1 ); + mySplitter->setCompressEnabled( true ); + + myPyEditor = new QAD_PyEditor(myInterp, theMutex, mySplitter ,"Python Interpreter"); myPyEditor->setMinimumSize( 1, 1 ); - myMessage = new QAD_Message( vsplitter ,"Message"); + myPyEditor->Init(); + + myMessage = new QAD_Message( mySplitter ,"Message"); myMessage->setMinimumSize( 1, 1 ); sizes.append( (int)(0.48 * DesktopHeight) ); @@ -198,7 +205,7 @@ QAD_RightFrame::QAD_RightFrame(QWidget *parent, const char *name, sizes.clear(); sizes.append( (int)(0.25 * DesktopWidth) ); sizes.append( (int)(0.25 * DesktopWidth) ); - vsplitter->setSizes( sizes ); + mySplitter->setSizes( sizes ); } /*! @@ -226,7 +233,7 @@ QAD_Message* QAD_RightFrame::getMessage() const */ QAD_PyInterp* QAD_RightFrame::get_PyInterp(void) { - return _interp; + return myInterp; } /*! diff --git a/src/SALOMEGUI/QAD_RightFrame.h b/src/SALOMEGUI/QAD_RightFrame.h index 1b454310a..b92b6eb66 100644 --- a/src/SALOMEGUI/QAD_RightFrame.h +++ b/src/SALOMEGUI/QAD_RightFrame.h @@ -31,15 +31,19 @@ #include "QAD_ViewFrame.h" #include "QAD_Message.h" -#include "QAD_PyEditor.h" #include "QAD_Splitter.h" -#include "QAD_PyInterp.h" + +class QMutex; + +class QAD_PyEditor; +class QAD_PyInterp; class QAD_EXPORT QAD_RightFrame : public QAD_Splitter { public: - QAD_RightFrame(QWidget *parent, const char *name, - QAD_PyInterp* interp, ViewType vt); + QAD_RightFrame(QWidget *theParent, + const char *theTitle, ViewType theTypeView, + QAD_PyInterp*& theInterp, QMutex* theMutex); ~QAD_RightFrame(); QAD_ViewFrame* getViewFrame() const; @@ -58,8 +62,8 @@ protected: QAD_ViewFrame* myViewFrame; QAD_PyEditor* myPyEditor; QAD_Message* myMessage; - QAD_Splitter* vsplitter; - QAD_PyInterp* _interp; + QAD_Splitter* mySplitter; + QAD_PyInterp*& myInterp; }; #endif diff --git a/src/SALOMEGUI/QAD_Settings.cxx b/src/SALOMEGUI/QAD_Settings.cxx index d1fec9a21..14df2e8f3 100644 --- a/src/SALOMEGUI/QAD_Settings.cxx +++ b/src/SALOMEGUI/QAD_Settings.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "QAD_Settings.h" #include @@ -35,7 +36,6 @@ #include #include #include -using namespace std; /*! Class QAD_Settings is a base class for different kind of settings diff --git a/src/SALOMEGUI/QAD_SpinBoxDbl.cxx b/src/SALOMEGUI/QAD_SpinBoxDbl.cxx index dffa96919..6bf31664c 100644 --- a/src/SALOMEGUI/QAD_SpinBoxDbl.cxx +++ b/src/SALOMEGUI/QAD_SpinBoxDbl.cxx @@ -9,6 +9,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "QAD_SpinBoxDbl.h" #include #include @@ -18,7 +19,6 @@ #include #include #include -using namespace std; //****************************************************************************** // QDblRangeControl class diff --git a/src/SALOMEGUI/QAD_Splitter.cxx b/src/SALOMEGUI/QAD_Splitter.cxx index 0d620f597..cb472ea71 100644 --- a/src/SALOMEGUI/QAD_Splitter.cxx +++ b/src/SALOMEGUI/QAD_Splitter.cxx @@ -26,8 +26,8 @@ // Module : SALOME // $Header$ -#include "QAD_Splitter.h" using namespace std; +#include "QAD_Splitter.h" /*! Constructs an horizontal splitter. diff --git a/src/SALOMEGUI/QAD_Study.cxx b/src/SALOMEGUI/QAD_Study.cxx index 166e8acf9..f43c8714f 100644 --- a/src/SALOMEGUI/QAD_Study.cxx +++ b/src/SALOMEGUI/QAD_Study.cxx @@ -42,6 +42,7 @@ #include "QAD_ObjectBrowser.h" #include "QAD_PyInterp.h" #include "QAD_Config.h" +#include "QAD_PyInterp.h" #include "utilities.h" @@ -58,59 +59,104 @@ // QT Include #include +#include +#include + using namespace std; -/*! - Constructor -*/ -QAD_Study::QAD_Study(QAD_Application* app, - SALOMEDS::Study_var aStudy, - const QString& path ) : -myOperationState( Undef ), -myApp( app ), -myActiveStudyFrame( 0 ), -myStudyFrameCount( 0 ), -myPath( path ) -{ - myStudy = aStudy; - myTitle = QAD_Tools::getFileNameFromPath( path, true ); +#ifdef _DEBUG_ +static int MYDEBUG = 1; +#else +static int MYDEBUG = 0; +#endif - myIsActive = false; - myIsSaved = false; - myIsModified = false; - myIsReadOnly = false; - myStudyFrames.clear(); - myOperations.clear(); +class TInitStudyThread : public QThread{ + TInitStudyThread(); + TInitStudyThread(const TInitStudyThread&); - myStudyFrames.setAutoDelete( true ); - myOperations.setAutoDelete( true ); - myChildWidgets.setAutoDelete( true ); +public: + TInitStudyThread(QAD_PyInterp*& theInterp, QMutex* theMutex): + myInterp(theInterp), + myStudyLock(new ThreadLock(theMutex,"TInitStudyThread::TInitStudyThread")) + {} + virtual ~TInitStudyThread() { + if(myStudyLock) + delete myStudyLock; + } - /* create python interpreter */ - _interp = new QAD_PyInterp(); - SCRUTE(_interp); +protected: + virtual void run(){ + { + ThreadLock aPyLock = GetPyThreadLock("TInitStudyThread::aPyLock"); + if(MYDEBUG) MESSAGE("TInitStudyThread::run()"); + myInterp = new QAD_PyInterp(); + myInterp->initialize(); + } + delete myStudyLock; + myStudyLock = NULL; + } + +private: + QAD_PyInterp*& myInterp; + ThreadLock* myStudyLock; +}; - /* create default selection */ - //NRI Selection( "Salome" ); - Selection( QAD_Application::getDesktop()->getComponentUserName( "KERNEL" ) ); - /* create study frame */ - myResult = true; - createStudyFrame( getNextStudyFrameName() ); +/*! + Constructor +*/ +QAD_Study::QAD_Study(QAD_Application* theApp, + SALOMEDS::Study_var theStudy, + const QString& thePath): + myStudy(theStudy), + myOperationState(Undef), + myApp(theApp), + myActiveStudyFrame(0), + myStudyFrameCount(0), + myPath(thePath), + myTitle(QAD_Tools::getFileNameFromPath(thePath,true)), + myIsActive(false), + myIsSaved(false), + myIsModified(false), + myIsReadOnly(false), + myResult(true), + myInterp(0), + myInitStudyThread(0), + myMutex(new QMutex()) +{ + myStudyFrames.setAutoDelete( true ); + myOperations.setAutoDelete( true ); + myChildWidgets.setAutoDelete( true ); + + /* create default selection */ + //NRI Selection( "Salome" ); + Selection( QAD_Application::getDesktop()->getComponentUserName( "KERNEL" ) ); + + /* create python interpreter */ + myInitStudyThread = new TInitStudyThread(myInterp,myMutex); + myInitStudyThread->start(); - /* set default Undo/Redo limit */ - QAD_ASSERT_DEBUG_ONLY( !myStudy->_is_nil() ); - SALOMEDS::StudyBuilder_var SB = myStudy->NewBuilder(); + /* create study frame */ + createStudyFrame( getNextStudyFrameName() ); + + /* set default Undo/Redo limit */ + QAD_ASSERT_DEBUG_ONLY( !myStudy->_is_nil() ); + SALOMEDS::StudyBuilder_var SB = myStudy->NewBuilder(); + + int aLocked = myStudy->GetProperties()->IsLocked(); + if (aLocked) myStudy->GetProperties()->SetLocked(false); + SB->UndoLimit(QAD_Desktop::getUndoLevel()); + if (aLocked) myStudy->GetProperties()->SetLocked(true); +} - int aLocked = myStudy->GetProperties()->IsLocked(); - if (aLocked) myStudy->GetProperties()->SetLocked(false); - SB->UndoLimit(QAD_Desktop::getUndoLevel()); - if (aLocked) myStudy->GetProperties()->SetLocked(true); +void QAD_Study::Init() +{ } + /*! Destructor */ @@ -119,6 +165,14 @@ QAD_Study::~QAD_Study () close(); //SRN: added - clear selection in case the study will be loaded again so the title will coincide SALOME_Selection::RemoveSelection( QString(myTitle + "_" + mySelection) ); + { + { + ThreadLock aLock(myMutex,"QAD_Study::~QAD_Study()"); + delete myInitStudyThread; + } + delete myMutex; + delete myInterp; + } } /*! @@ -344,10 +398,10 @@ void QAD_Study::setReadOnly(bool state) */ void QAD_Study::onStudyFrameActivated( QAD_StudyFrame* activeStudyFrame ) { - static int IS_FIRST_STUDY = 1; - if(IS_FIRST_STUDY){ //for normally initialize "salome.py and ..." - _interp->run(""); IS_FIRST_STUDY = 0; - } +// static int IS_FIRST_STUDY = 1; +// if(IS_FIRST_STUDY){ //for normally initialize "salome.py and ..." +// _interp->run(""); IS_FIRST_STUDY = 0; +// } // bool found = false; for ( QAD_StudyFrame* studyframe = myStudyFrames.first(); studyframe; studyframe = myStudyFrames.next() ) { if ( studyframe == activeStudyFrame) { /* one of my study frames */ @@ -591,7 +645,8 @@ QAD_StudyFrame* QAD_Study::createStudyFrame( const QString& title, ViewType theV if ( theViewType == VIEW_OCC) { // MESSAGE ("Create Study Frame for OCC viewer"); sf = new QAD_StudyFrame ( this, parent->getMainFrame(), - title, _interp, VIEW_OCC ); + title, VIEW_OCC, + myInterp, myMutex ); Standard_CString name = strdup(sf->title().latin1()); anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName"); @@ -608,7 +663,8 @@ QAD_StudyFrame* QAD_Study::createStudyFrame( const QString& title, ViewType theV else if ( theViewType == VIEW_VTK) { // MESSAGE ("Create Study Frame for VTK viewer"); sf = new QAD_StudyFrame ( this, parent->getMainFrame(), - title, _interp, VIEW_VTK ); + title, VIEW_VTK, + myInterp, myMutex ); Standard_CString name = strdup(sf->title().latin1()); anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName"); aName = SALOMEDS::AttributeName::_narrow(anAttr); @@ -624,7 +680,8 @@ QAD_StudyFrame* QAD_Study::createStudyFrame( const QString& title, ViewType theV else if ( theViewType == VIEW_GRAPHSUPERV) { //MESSAGE ("Create Study Frame for SUPER`VISOR Graph"); sf = new QAD_StudyFrame ( this, parent->getMainFrame(), - title, _interp, VIEW_GRAPHSUPERV ); + title, VIEW_GRAPHSUPERV, + myInterp, myMutex ); Standard_CString name = strdup(sf->title().latin1()); anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName"); aName = SALOMEDS::AttributeName::_narrow(anAttr); @@ -639,7 +696,8 @@ QAD_StudyFrame* QAD_Study::createStudyFrame( const QString& title, ViewType theV } else if ( theViewType == VIEW_PLOT2D ) { sf = new QAD_StudyFrame ( this, parent->getMainFrame(), - title, _interp, VIEW_PLOT2D ); + title, VIEW_PLOT2D, + myInterp, myMutex ); Standard_CString name = strdup(sf->title().latin1()); anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName"); aName = SALOMEDS::AttributeName::_narrow(anAttr); @@ -1245,7 +1303,7 @@ QString QAD_Study::getNextStudyFrameName() */ QAD_PyInterp* QAD_Study::get_PyInterp(void) { - return _interp; + return myInterp; } /*! diff --git a/src/SALOMEGUI/QAD_Study.h b/src/SALOMEGUI/QAD_Study.h index 94fe80305..8139e8a5d 100644 --- a/src/SALOMEGUI/QAD_Study.h +++ b/src/SALOMEGUI/QAD_Study.h @@ -44,7 +44,10 @@ #include class QAD_Application; + +class QMutex; class QAD_PyInterp; +class TInitStudyThread; class QAD_EXPORT QAD_Study : public QObject { @@ -54,6 +57,7 @@ public: QAD_Study(QAD_Application* app, SALOMEDS::Study_var aStudy, const QString& title); + virtual void Init(); ~QAD_Study(); /* Event filter */ @@ -189,7 +193,10 @@ private: bool myIsModified; bool myIsReadOnly; bool myResult; - QAD_PyInterp* _interp; + + QMutex* myMutex; + QAD_PyInterp* myInterp; + TInitStudyThread* myInitStudyThread; }; #endif diff --git a/src/SALOMEGUI/QAD_StudyFrame.cxx b/src/SALOMEGUI/QAD_StudyFrame.cxx index d397302e0..b54b6dfc0 100644 --- a/src/SALOMEGUI/QAD_StudyFrame.cxx +++ b/src/SALOMEGUI/QAD_StudyFrame.cxx @@ -34,55 +34,51 @@ #include "QAD_StudyFrame.h" #include "QAD_RightFrame.h" #include "QAD_LeftFrame.h" +#include "QAD_Splitter.h" #include "QAD_Application.h" #include "QAD_Desktop.h" #include "QAD_Study.h" #include "QAD_ObjectBrowser.h" +#include "QAD_PyInterp.h" + #include + using namespace std; /*! Constructor */ -QAD_StudyFrame::QAD_StudyFrame(QAD_Study* study, QWidget* parent, const QString& title, - QAD_PyInterp* interp, ViewType typeView) : - QMainWindow( parent , title, WStyle_NormalBorder | +QAD_StudyFrame::QAD_StudyFrame(QAD_Study* theStudy, QWidget* theParent, + const QString& theTitle, ViewType theTypeView, + QAD_PyInterp*& theInterp, QMutex* theMutex): + QMainWindow( theParent , theTitle, WStyle_NormalBorder | WStyle_MinMax | WStyle_SysMenu | WDestructiveClose), - myStudy(study) + myTitle(theTitle), + myEntry(""), + myTypeView(theTypeView), + myStudy(theStudy), + myInterp(theInterp) { - myTypeView = typeView; - myTitle = title; setCaption( myTitle ); setPalette(QAD_Application::getPalette()); - myEntry = ""; - _interp = interp; - - s1 = new QAD_Splitter( Qt::Horizontal, this); - s1->setCompressEnabled( true ); + mySplitter = new QAD_Splitter( Qt::Horizontal, this); + mySplitter->setCompressEnabled( true ); - setCentralWidget( s1 ); - myLeftFrm = new QAD_LeftFrame(study->getStudyDocument(), s1 , title ); - myRightFrm = new QAD_RightFrame( s1, title, _interp, myTypeView); + setCentralWidget(mySplitter); + myLeftFrm = new QAD_LeftFrame(myStudy->getStudyDocument(), mySplitter, theTitle ); + myRightFrm = new QAD_RightFrame( mySplitter, theTitle, myTypeView, myInterp, theMutex); QValueList sizes; sizes.append( (int)(0.30*QAD_Application::getDesktop()->getMainFrame()->width()) ); sizes.append( (int)(0.50*QAD_Application::getDesktop()->getMainFrame()->width()) ); - s1->setSizes( sizes ); + mySplitter->setSizes( sizes ); - QAD_ASSERT_DEBUG_ONLY ( parent->inherits("QWorkspaceP") ); - QAD_ASSERT ( QObject::connect( (QWorkspaceP*)parent, SIGNAL(windowActivated(QWidget*)), + QAD_ASSERT_DEBUG_ONLY ( theParent->inherits("QWorkspaceP") ); + QAD_ASSERT ( QObject::connect( (QWorkspaceP*)theParent, SIGNAL(windowActivated(QWidget*)), this, SLOT(onStudyFrameActivated(QWidget*))) ); } -/*! - Constructor -*/ -QAD_StudyFrame::QAD_StudyFrame(QAD_Study* study, QWidget* parent ) : - QMainWindow ( parent ), - myStudy(study) -{ -} /*! Destructor @@ -124,6 +120,11 @@ void QAD_StudyFrame::setVisible( bool visible ) */ void QAD_StudyFrame::closeEvent(QCloseEvent* e) { + if ( IsPyLocked() ) { + e->ignore(); + return; + } + emit sfStudyFrameClosing(this); } @@ -132,22 +133,22 @@ void QAD_StudyFrame::closeEvent(QCloseEvent* e) */ void QAD_StudyFrame::compressLeft() { - s1->compress(myLeftFrm); + mySplitter->compress(myLeftFrm); } void QAD_StudyFrame::compressRight() { - s1->compress(myRightFrm); + mySplitter->compress(myRightFrm); } void QAD_StudyFrame::unCompressLeft() { - s1->unCompress(myLeftFrm); + mySplitter->unCompress(myLeftFrm); } void QAD_StudyFrame::unCompressRight() { - s1->unCompress(myRightFrm); + mySplitter->unCompress(myRightFrm); } /*! @@ -201,5 +202,5 @@ void QAD_StudyFrame::onStudyFrameActivated ( QWidget* activeWindow ) */ QAD_PyInterp* QAD_StudyFrame::get_PyInterp(void) { - return _interp; + return myInterp; } diff --git a/src/SALOMEGUI/QAD_StudyFrame.h b/src/SALOMEGUI/QAD_StudyFrame.h index e8b393b44..cdb83befa 100644 --- a/src/SALOMEGUI/QAD_StudyFrame.h +++ b/src/SALOMEGUI/QAD_StudyFrame.h @@ -30,17 +30,18 @@ #define QAD_StudyFrame_H #include "QAD.h" -#include "QAD_Splitter.h" -#include "QAD_PyInterp.h" // QT Includes #include #include +class QMutex; + class QAD_RightFrame; class QAD_LeftFrame; class QAD_Splitter; class QAD_Study; +class QAD_PyInterp; enum ViewType { VIEW_OCC, @@ -55,11 +56,9 @@ class QAD_EXPORT QAD_StudyFrame: public QMainWindow Q_OBJECT public: - QAD_StudyFrame(QAD_Study* study, - QWidget* parent, const QString& title, - QAD_PyInterp* interp, ViewType typeView); - QAD_StudyFrame(QAD_Study*, - QWidget* parent = 0); + QAD_StudyFrame(QAD_Study* theStudy, QWidget* theParent, + const QString& theTitle, ViewType theTypeView, + QAD_PyInterp*& theInterp, QMutex* theMutex); virtual ~QAD_StudyFrame(); QAD_Study* getStudy() { return myStudy; } @@ -77,7 +76,6 @@ class QAD_EXPORT QAD_StudyFrame: public QMainWindow const QString& entry() const; void setVisible( bool isVisible = true ); - void closeEvent(QCloseEvent* e); void compressLeft(); void compressRight(); @@ -90,6 +88,9 @@ class QAD_EXPORT QAD_StudyFrame: public QMainWindow public slots: void onStudyFrameActivated ( QWidget* ); + + protected: + virtual void closeEvent ( QCloseEvent* ); private: @@ -99,9 +100,9 @@ class QAD_EXPORT QAD_StudyFrame: public QMainWindow ViewType myTypeView; QAD_LeftFrame* myLeftFrm; QAD_RightFrame* myRightFrm; - QAD_Splitter* s1; - QAD_PyInterp* _interp; + QAD_Splitter* mySplitter; QAD_Study* myStudy; + QAD_PyInterp*& myInterp; }; #endif diff --git a/src/SALOMEGUI/QAD_Tools.cxx b/src/SALOMEGUI/QAD_Tools.cxx index dfa23e5c7..e2e85bf53 100644 --- a/src/SALOMEGUI/QAD_Tools.cxx +++ b/src/SALOMEGUI/QAD_Tools.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; /*! \class QAD_Tools QAD_Tools.h \brief Helpful functions for QAD. @@ -43,7 +44,6 @@ #include #include #include -using namespace std; static char* tempName() { diff --git a/src/SALOMEGUI/QAD_ViewFrame.cxx b/src/SALOMEGUI/QAD_ViewFrame.cxx index b5c19c9b4..6fa905371 100644 --- a/src/SALOMEGUI/QAD_ViewFrame.cxx +++ b/src/SALOMEGUI/QAD_ViewFrame.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "QAD.h" #include "QAD_ViewFrame.h" #include "QAD_Application.h" @@ -36,7 +37,6 @@ #include #include #include "utilities.h" -using namespace std; /*! Constructor diff --git a/src/SALOMEGUI/QAD_ViewFrame.h b/src/SALOMEGUI/QAD_ViewFrame.h index b894bb703..48aa8693a 100644 --- a/src/SALOMEGUI/QAD_ViewFrame.h +++ b/src/SALOMEGUI/QAD_ViewFrame.h @@ -33,6 +33,7 @@ #include "QAD_Application.h" #include "QAD_StudyFrame.h" #include "SALOME_InteractiveObject.hxx" +#include "SALOME_Selection.h" // QT Include #include @@ -57,7 +58,7 @@ public: virtual void setBackgroundColor( const QColor& ) = 0; virtual QColor backgroundColor() const = 0; - virtual void SetSelectionMode( int mode ) = 0; + virtual void SetSelectionMode( Selection_Mode mode ) = 0; virtual void onAdjustTrihedron() = 0; diff --git a/src/SALOMEGUI/QAD_WaitCursor.h b/src/SALOMEGUI/QAD_WaitCursor.h index 3d33a2f70..2f5dbe6d9 100644 --- a/src/SALOMEGUI/QAD_WaitCursor.h +++ b/src/SALOMEGUI/QAD_WaitCursor.h @@ -18,19 +18,20 @@ class QAD_EXPORT QAD_WaitCursor { public: // constructor - QAD_WaitCursor() : myStarted(false) { start(); } + QAD_WaitCursor() : myStarted( false ), myDepth( 1 ) { start(); } // destructor - ~QAD_WaitCursor() { stop(); } + ~QAD_WaitCursor() { if ( !myStarted ) { myDepth--; start(); } else { QApplication::restoreOverrideCursor(); } } // sets WAIT cursor if not set yet - void start() { if (!myStarted) { QApplication::setOverrideCursor(Qt::waitCursor); myStarted = true; } } + void start() { if ( !myStarted ) { while( myDepth-- ) QApplication::setOverrideCursor( Qt::waitCursor ); myStarted = true; } myDepth = 0; } // clears WAIT cursor if set - void stop() { if (myStarted) { QApplication::restoreOverrideCursor(); myStarted = false; } } + void stop() { if ( myStarted ) { while( QApplication::overrideCursor() ) { QApplication::restoreOverrideCursor(); myDepth++; } myStarted = false; } } // returns true if WAIT cursor is active bool isStarted() { return myStarted; } private: bool myStarted; + int myDepth; }; #endif diff --git a/src/SALOMEGUI/QAD_XmlHandler.cxx b/src/SALOMEGUI/QAD_XmlHandler.cxx index 85df10900..2226782d4 100644 --- a/src/SALOMEGUI/QAD_XmlHandler.cxx +++ b/src/SALOMEGUI/QAD_XmlHandler.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; #define INCLUDE_MENUITEM_DEF #include "QAD_Desktop.h" @@ -40,7 +41,6 @@ #include #include #include -using namespace std; map QAD_XmlHandler::_bibmap; diff --git a/src/SALOMEGUI/QAD_msg_en.po b/src/SALOMEGUI/QAD_msg_en.po index e845d78e4..a843fd12f 100644 --- a/src/SALOMEGUI/QAD_msg_en.po +++ b/src/SALOMEGUI/QAD_msg_en.po @@ -28,7 +28,7 @@ msgid "" msgstr "" "Project-Id-Version: example-Qt-message-extraction\n" "POT-Creation-Date: 1999-02-23 15:38+0200\n" -"PO-Revision-Date: 1999-02-23 15:38+0200\n" +"PO-Revision-Date: 2004-04-26 16:29+0400\n" "Last-Translator: \n" "Content-Type: text/plain; charset=iso-8859-1\n" @@ -176,8 +176,8 @@ msgid "QAD_Desktop::MEN_DESK_HELP_CONTENTS" msgstr "&Contents" #: QAD_Desktop.cxx:265 -msgid "QAD_Desktop::MEN_DESK_HELP_GUICONTENTS" -msgstr "&GUI Reference" +msgid "QAD_Desktop::MEN_DESK_HELP_MODULECONTENTS" +msgstr "&Module Help" #: QAD_Desktop.cxx:265 msgid "QAD_Desktop::MEN_DESK_HELP_TUICONTENTS" @@ -374,6 +374,54 @@ msgstr "Saves the active study" msgid "QAD_Desktop::PRP_DESK_FILE_SAVEAS" msgstr "Saves the active study with a new name" +#: QAD_Desktop.cxx:3759 +msgid "QAD_Desktop::PRP_DESK_FILE_IMPORT" +msgstr "Import file" + +#: QAD_Desktop.cxx:3765 +msgid "QAD_Desktop::PRP_DESK_FILE_IMPORTMESH" +msgstr "Import Mesh from file" + +#: QAD_Desktop.cxx:3765 +msgid "QAD_Desktop::PRP_DESK_FILE_IMPORTMED" +msgstr "Import MED file" + +#: QAD_Desktop.cxx:3765 +msgid "QAD_Desktop::PRP_DESK_FILE_IMPORTTABLE" +msgstr "Import TABLE from file" + +#: QAD_Desktop.cxx:3765 +msgid "QAD_Desktop::PRP_DESK_FILE_EXPLOREMEDFILE" +msgstr "Explore MED file" + +#: QAD_Desktop.cxx:3771 +msgid "QAD_Desktop::PRP_DESK_FILE_IMPORTDF" +msgstr "Import Dataflow from file" + +#: QAD_Desktop.cxx:3761 +msgid "QAD_Desktop::PRP_DESK_FILE_EXPORT" +msgstr "Export file" + +#: QAD_Desktop.cxx:3761 +msgid "QAD_Desktop::PRP_DESK_FILE_EXPORTRESULT" +msgstr "Export Result" + +#: QAD_Desktop.cxx:3773 +msgid "QAD_Desktop::PRP_DESK_FILE_EXPORTDF" +msgstr "Export Dataflow" + +#: QAD_Desktop.cxx:3793 +msgid "QAD_Desktop::PRP_DESK_EDIT_DELETE" +msgstr "Delete object" + +#: QAD_Desktop.cxx:3799 +msgid "QAD_Desktop::PRP_DESK_EDIT_NEWDF" +msgstr "Creates new Dataflow" + +#: QAD_Desktop.cxx:3801 +msgid "QAD_Desktop::PRP_DESK_EDIT_MODIFYDF" +msgstr "Modifies already existent Dataflow" + #: QAD_Desktop.cxx:292 msgid "QAD_Desktop::PRP_DESK_HELP_ABOUT" msgstr "Shows \'About\' dialog" @@ -409,6 +457,14 @@ msgstr "Toggles status bar view on/off" msgid "QAD_Desktop::PRP_DESK_VIEW_TOOLBAR" msgstr "Toggles toolbar on/off" +#: QAD_Desktop.cxx:220 +msgid "QAD_Desktop::PRP_DESK_VIEW_DISPLAYMODE" +msgstr "Choose the display mode" + +#: QAD_Desktop.cxx:220 +msgid "QAD_Desktop::PRP_DESK_VIEW_UPDATE" +msgstr "Update view" + #: QAD_Desktop.cxx:871 msgid "QAD_Desktop::PRP_DESK_WINDOW_ACTIVATE" msgstr "Activates this window" @@ -524,7 +580,13 @@ msgstr "This function is available only in Plot2d viewer" #: QAD_Desktop.cxx:2339 msgid "ERR_LIBGUI" -msgstr "lib%1.so has not been found. Check LD_LIBRARY_PATH environment variable" +msgstr "lib%1GUI.so has not been found. Check LD_LIBRARY_PATH environment variable" + +msgid "ERR_GET_GUI_FAILED" +msgstr "%1GUI instance creation failed!" + +msgid "ERR_GET_GUI_NOT_FOUND" +msgstr "GetComponentGUI() function not found in %1 library!" #--------------- # QUESTION diff --git a/src/SALOMEGUI/SALOMEGUI.cxx b/src/SALOMEGUI/SALOMEGUI.cxx index 69a3b241b..5f853a485 100644 --- a/src/SALOMEGUI/SALOMEGUI.cxx +++ b/src/SALOMEGUI/SALOMEGUI.cxx @@ -22,109 +22,158 @@ // // // File : SALOMEGUI.cxx -// Author : Nicolas REJNERI +// Author : Sergey ANIKIN // Module : SALOME // $Header$ -using namespace std; -#include -#include CORBA_SERVER_HEADER(SALOMEDS) - -#include "QAD.h" -#include "QAD_MessageBox.h" -#include "QAD_Application.h" -#include "SALOMEGUI_Application.h" - -#include -#include - -#include "SALOME_NamingService.hxx" - -int main(int argc, char* argv[]) -{ - QApplication a( argc, argv ); - - // Setting up the CORBA environment - // Initializing omniORB - SALOME_NamingService * name_service; - CORBA::ORB_var orb; - - // orb = CORBA::ORB_init(argc, argv, "omniORB4"); - orb = CORBA::ORB_init(argc, argv, "omniORB3"); - - // Get the reference the server. - name_service = new SALOME_NamingService(orb); - - QAD_ASSERT ( QObject::connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) ) ); - - /* Initialize the desktop and 'SALOMEGUI' application */ - SALOMEGUI_Application* app = - new SALOMEGUI_Application ( "MDTV-Standard", "HDF","hdf" ); - - if ( !SALOMEGUI_Application::addToDesktop ( app, name_service ) ) - { - QAD_MessageBox::error1 ( 0, - QObject::tr("ERR_ERROR"), - QObject::tr("ERR_APP_INITFAILED"), - QObject::tr("BUT_OK") ); - return -1; - } - - QPalette pal; - QColorGroup cg; - cg.setColor( QColorGroup::Foreground, Qt::black ); - cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) ); - cg.setColor( QColorGroup::Light, Qt::white ); - cg.setColor( QColorGroup::Midlight, QColor( 223, 223, 223) ); - cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) ); - cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) ); - cg.setColor( QColorGroup::Text, Qt::black ); - cg.setColor( QColorGroup::BrightText, Qt::white ); - cg.setColor( QColorGroup::ButtonText, Qt::black ); - cg.setColor( QColorGroup::Base, Qt::white ); - cg.setColor( QColorGroup::Background, QColor( 192, 192, 192) ); - cg.setColor( QColorGroup::Shadow, Qt::black ); - cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) ); - cg.setColor( QColorGroup::HighlightedText, Qt::white ); - pal.setActive( cg ); - cg.setColor( QColorGroup::Foreground, Qt::black ); - cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) ); - cg.setColor( QColorGroup::Light, Qt::white ); - cg.setColor( QColorGroup::Midlight, QColor( 220, 220, 220) ); - cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) ); - cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) ); - cg.setColor( QColorGroup::Text, Qt::black ); - cg.setColor( QColorGroup::BrightText, Qt::white ); - cg.setColor( QColorGroup::ButtonText, Qt::black ); - cg.setColor( QColorGroup::Base, Qt::white ); - cg.setColor( QColorGroup::Background, QColor( 192, 192, 192) ); - cg.setColor( QColorGroup::Shadow, Qt::black ); - cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) ); - cg.setColor( QColorGroup::HighlightedText, Qt::white ); - pal.setInactive( cg ); - cg.setColor( QColorGroup::Foreground, QColor( 128, 128, 128) ); - cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) ); - cg.setColor( QColorGroup::Light, Qt::white ); - cg.setColor( QColorGroup::Midlight, QColor( 220, 220, 220) ); - cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) ); - cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) ); - cg.setColor( QColorGroup::Text, Qt::black ); - cg.setColor( QColorGroup::BrightText, Qt::white ); - cg.setColor( QColorGroup::ButtonText, QColor( 128, 128, 128) ); - cg.setColor( QColorGroup::Base, Qt::white ); - cg.setColor( QColorGroup::Background, QColor( 192, 192, 192) ); - cg.setColor( QColorGroup::Shadow, Qt::black ); - cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) ); - cg.setColor( QColorGroup::HighlightedText, Qt::white ); - pal.setDisabled( cg ); - qApp->setPalette( pal ); - - /* Run 'SALOMEGUI' application */ - QAD_Application::run(); - a.exec(); - - delete name_service; - orb->destroy(); - - return 0; +#include "SALOMEGUI.h" +#include "QAD_Desktop.h" + + +//============================================================================= +/*! + * + */ +//============================================================================= +SALOMEGUI::SALOMEGUI( const QString& name, QObject* parent ) +: QObject( parent ), + myName( name ) +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= +SALOMEGUI::~SALOMEGUI() +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= +bool SALOMEGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + return true; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +bool SALOMEGUI::OnKeyPress(QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) +{ + return true; } + +//============================================================================= +/*! + * + */ +//============================================================================= +bool SALOMEGUI::OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) +{ + return true; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +bool SALOMEGUI::OnMouseMove(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) +{ + return true; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +bool SALOMEGUI::SetSettings( QAD_Desktop* parent ) +{ + return true; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +bool SALOMEGUI::SetSettings( QAD_Desktop* parent, char* compName ) +{ + return SetSettings( parent); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +bool SALOMEGUI::CustomPopup( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext, + const QString & theParent, const QString & theObject ) +{ + return true; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SALOMEGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject ) +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= +bool SALOMEGUI::ActiveStudyChanged( QAD_Desktop* parent ) +{ + //static QAD_Study* aPrevStudy = NULL; + //QAD_Study* aStudy = parent->getActiveStudy(); + //if(!aPrevStudy) + // aPrevStudy = aStudy; + //if(aStudy != aPrevStudy){ + // emit SignalCloseAllDialogs(); + // aPrevStudy = aStudy; + //} + emit SignalCloseAllDialogs(); + return true; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SALOMEGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& theIO ) +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SALOMEGUI::SupportedViewType(int* buffer, int bufferSize) +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SALOMEGUI::Deactivate() +{ + emit SignalCloseAllDialogs(); +} + diff --git a/src/SALOMEGUI/SALOMEGUI.h b/src/SALOMEGUI/SALOMEGUI.h new file mode 100644 index 000000000..d823c6e41 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI.h @@ -0,0 +1,79 @@ +// SALOME SALOMEGUI : implementation of desktop and GUI kernel +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// 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 +// 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 +// +// +// +// File : SALOMEGUI.hxx +// Author : Sergey ANIKIN +// Module : SALOME +// $Header$ + +#ifndef SALOMEGUI_HeaderFile +#define SALOMEGUI_HeaderFile + +#include + +#include +#include + +class QAD_Desktop; +class QAD_StudyFrame; +class SALOME_Event; + +class Handle_SALOME_InteractiveObject; + +class QKeyEvent; +class QMouseEvent; +class QPopupMenu; +class QString; + + +class Standard_EXPORT SALOMEGUI : public QObject +{ + Q_OBJECT + +public: + SALOMEGUI( const QString& name = "", QObject* parent = 0 ); + virtual ~SALOMEGUI(); + + virtual bool OnGUIEvent (int theCommandID, QAD_Desktop* parent); + virtual bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame); + virtual bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame); + virtual bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame); + virtual bool SetSettings ( QAD_Desktop* parent ); + virtual bool SetSettings ( QAD_Desktop* parent, char* compName ); + virtual bool CustomPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext, + const QString & theParent, const QString & theObject ); + virtual void DefinePopup ( QString & theContext, QString & theParent, QString & theObject ); + virtual bool ActiveStudyChanged( QAD_Desktop* parent ); + virtual void BuildPresentation ( const Handle(SALOME_InteractiveObject)& theIO ); + virtual void SupportedViewType (int* buffer, int bufferSize); + virtual void Deactivate (); + +signals: + void SignalDeactivateActiveDialog(); + void SignalCloseAllDialogs (); + +private: + QString myName; +}; + +#endif diff --git a/src/SALOMEGUI/SALOMEGUI_AboutDlg.cxx b/src/SALOMEGUI/SALOMEGUI_AboutDlg.cxx index fb7e59301..7ae5111de 100644 --- a/src/SALOMEGUI/SALOMEGUI_AboutDlg.cxx +++ b/src/SALOMEGUI/SALOMEGUI_AboutDlg.cxx @@ -26,13 +26,13 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEGUI_AboutDlg.h" #include "QAD_Desktop.h" #include "QAD_Tools.h" #include #include #include -using namespace std; /* * Constructor diff --git a/src/SALOMEGUI/SALOMEGUI_ActivateComponentDlg.cxx b/src/SALOMEGUI/SALOMEGUI_ActivateComponentDlg.cxx index b5e0ecd19..42859b842 100644 --- a/src/SALOMEGUI/SALOMEGUI_ActivateComponentDlg.cxx +++ b/src/SALOMEGUI/SALOMEGUI_ActivateComponentDlg.cxx @@ -8,72 +8,193 @@ // Author : Michael Zorin (mzn) // Module : SALOME +using namespace std; #include "SALOMEGUI_ActivateComponentDlg.h" +#include +#include #include -#include -#include -#include -#include -using namespace std; +#include +#include +static const char* const default_icon[] = { +"48 48 17 1", +". c None", +"# c #161e4c", +"b c #1d3638", +"e c #2f585b", +"i c #345b5e", +"c c #386266", +"g c #3f7477", +"d c #4d8589", +"m c #519099", +"o c #6abbc1", +"a c #70c9d3", +"f c #79ddea", +"n c #7adff2", +"k c #7ce2f4", +"j c #993550", +"h c #d84b71", +"l c #ef537d", +"................................................", +"................................................", +"................................................", +"................................................", +"................................................", +"................########.########.########......", +"...............#aaaaaa###aaaaaa###aaaaaa##......", +"..............#aaaaaa#b#aaaaaa#b#aaaaaa#c#......", +".............########b########b########cc#......", +".............#dddddd#b#dddddd#b#dddddd#cc#......", +"...........########d########d########d#cc#......", +"..........#aaaaaa###aaaaaa###aaaaaa##d#cc#......", +".........#aaaaaa#b#aaaaaa#b#aaaaaa#c#d#cc#......", +"........########b########e########cc#d#c#.......", +"........#dddddd#b#dddddd#e#ffffff#cc#d####......", +"......########d########d########f#cc###g##......", +".....#aaaaaa###aaaaaa###hhhhhh##f#cc#gg#c#......", +"....#aaaaaa#b#aaaaaa#i#hhhhhh#j#f#cc###cc#......", +"...########b########i########jj#f#c#gg#cc#......", +"...#kkkkkk#b#kkkkkk#i#llllll#jj#f####g#cc#......", +"...#kkkkkk#b#kkkkkk#i#llllll#jj###m##g#cc#......", +"...#knnkkk#b#kkkkkk#i#llllll#jj#mm#c#g#cc#......", +"...#knnkkk#b#kkkkkk#i#llllll#jj###cc#g#c#.......", +"...#kkkkkk#b#kkkkkk#i#llllll#j#dd#cc#g####......", +"...#kkkkkk###kkkkkk###llllll####d#cc###g##......", +"...########g########g########o##d#cc#gg#c#......", +"....#gggggg#b#gggggg#b#oooooo#c#d#cc###cc#......", +"...########b########b########cc#d#c#gg#cc#......", +"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#d####g#cc#......", +"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###g##g#cc#......", +"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#gg#c#g#cc#......", +"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###cc#g#c#.......", +"...#kkkkkk#b#kkkkkk#b#kkkkkk#c#gg#cc#g##........", +"...#kkkkkk###kkkkkk###kkkkkk####g#cc###.........", +"...########g########g########g##g#cc#...........", +"....#gggggg#b#gggggg#b#gggggg#c#g#cc#...........", +"...########b########b########cc#g#c#............", +"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#g##.............", +"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###..............", +"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................", +"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................", +"...#kkkkkk#b#kkkkkk#b#kkkkkk#c#.................", +"...#kkkkkk###kkkkkk###kkkkkk##..................", +"...########.########.########...................", +"................................................", +"................................................", +"................................................", +"................................................"}; -SALOMEGUI_ActivateComponentDlg::SALOMEGUI_ActivateComponentDlg ( QWidget * parent, const char * name, bool modal, WFlags f ) - : QDialog ( parent, "", TRUE, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +//============================================================================================================================== +/*! + * SALOMEGUI_ActivateComponentDlg::SALOMEGUI_ActivateComponentDlg + * + * Constructor + */ +//============================================================================================================================== +SALOMEGUI_ActivateComponentDlg::SALOMEGUI_ActivateComponentDlg ( QWidget * parent, const QString& component, const QPixmap icon ) + : QDialog ( parent, "ActivateModuleDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) { - setSizeGripEnabled ( TRUE ) ; + QPixmap defaultIcon( ( const char** ) default_icon ); setCaption( tr( "CAPTION" ) ); + setSizeGripEnabled( TRUE ); + + QGridLayout* ActivateModuleDlgLayout = new QGridLayout( this ); + ActivateModuleDlgLayout->setMargin( 11 ); ActivateModuleDlgLayout->setSpacing( 6 ); - QVBoxLayout* m_vbL = new QVBoxLayout( this ); - m_vbL->setMargin( 11 ); m_vbL->setSpacing( 6 ); - - QLabel* m_lIcon = new QLabel (this, "m_lDescr"); - QPixmap pm = QMessageBox::standardIcon( QMessageBox::Information ); - m_lIcon->setPixmap( pm ); - m_lIcon->setScaledContents( false ); - m_lIcon->setAlignment( Qt::AlignCenter ); - - QLabel* m_lDescr = new QLabel (this, "m_lDescr"); - m_lDescr->setText ( tr ("ActivateComponent_DESCRIPTION") ); - m_lDescr->setAlignment( Qt::AlignCenter ); - m_lDescr->setMinimumHeight( m_lDescr->sizeHint().height()*5 ); - m_lDescr->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + // Module's name and icon + myComponentFrame = new QFrame( this, "myComponentFrame" ); + myComponentFrame->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ) ); + myComponentFrame->setMinimumHeight( 100 ); + myComponentFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); + + QGridLayout* myComponentFrameLayout = new QGridLayout( myComponentFrame ); + myComponentFrameLayout->setMargin( 11 ); myComponentFrameLayout->setSpacing( 6 ); - QHBoxLayout* m_hl1 = new QHBoxLayout(); - m_hl1->setMargin( 0 ); m_hl1->setSpacing( 6 ); - m_hl1->addWidget( m_lIcon ); - m_hl1->addWidget( m_lDescr ); + // --> icon + myComponentIcon = new QLabel( myComponentFrame, "myComponentIcon" ); + myComponentIcon->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); + myComponentIcon->setPixmap( !icon.isNull() ? icon : defaultIcon ); + myComponentIcon->setScaledContents( false ); + myComponentIcon->setAlignment( AlignCenter ); + // --> name + myComponentLab = new QLabel( component, myComponentFrame, "myComponentLab" ); + QFont fnt = myComponentLab->font(); fnt.setBold( TRUE ); myComponentLab->setFont( fnt ); + myComponentLab->setAlignment( AlignCenter ); - m_pb1 = new QPushButton( tr ("NEW"), this ); - m_pb2 = new QPushButton( tr ("OPEN"), this ); - m_pb3 = new QPushButton( tr ("LOAD"), this ); - m_pb4 = new QPushButton( tr ("CANCEL"), this ); + myComponentFrameLayout->addWidget( myComponentIcon, 0, 0 ); + myComponentFrameLayout->addWidget( myComponentLab, 0, 1 ); - QGridLayout* m_hl2 = new QGridLayout(); - m_hl2->setMargin( 0 ); m_hl2->setSpacing( 6 ); - m_hl2->addWidget( m_pb1, 0, 0 ); - m_hl2->addWidget( m_pb2, 0, 1 ); - m_hl2->addWidget( m_pb3, 0, 2 ); - m_hl2->addColSpacing( 3, 10 ); - m_hl2->setColStretch( 3, 5 ); - m_hl2->addWidget( m_pb4, 0, 4 ); + // Info + QVBoxLayout* infoLayout = new QVBoxLayout(); + infoLayout->setMargin( 0 ); infoLayout->setSpacing( 6 ); - m_vbL->addLayout( m_hl1 ); - m_vbL->addLayout( m_hl2 ); + // --> top line + QFrame* myLine1 = new QFrame( this, "myLine1" ); + myLine1->setFrameStyle( QFrame::HLine | QFrame::Plain ); + // --> info label + myInfoLabel = new QLabel( tr ("ActivateComponent_DESCRIPTION"), this, "myInfoLabel" ); + myInfoLabel->setAlignment( AlignCenter ); + // --> bottom line + QFrame* myLine2 = new QFrame( this, "myLine2" ); + myLine2->setFrameStyle( QFrame::HLine | QFrame::Plain ); + + infoLayout->addStretch(); + infoLayout->addWidget( myLine1 ); + infoLayout->addWidget( myInfoLabel ); + infoLayout->addWidget( myLine2 ); + infoLayout->addStretch(); + + // Buttons + QHBoxLayout* btnLayout = new QHBoxLayout(); + btnLayout->setMargin( 0 ); btnLayout->setSpacing( 6 ); + + // --> New + myNewBtn = new QPushButton( tr( "NEW" ), this, "myNewBtn" ); + myNewBtn->setDefault( true ); myNewBtn->setAutoDefault( true ); + // --> Open + myOpenBtn = new QPushButton( tr( "OPEN" ), this, "myOpenBtn" ); + myOpenBtn->setAutoDefault( true ); + // --> Load + myLoadBtn = new QPushButton( tr( "LOAD" ), this, "myLoadBtn" ); + myLoadBtn->setAutoDefault( true ); + // --> Cancel + myCancelBtn = new QPushButton( tr( "CANCEL" ), this, "myCancelBtn" ); + myCancelBtn->setAutoDefault( true ); + + btnLayout->addWidget( myNewBtn ); + btnLayout->addWidget( myOpenBtn ); + btnLayout->addWidget( myLoadBtn ); + btnLayout->addStretch(); + btnLayout->addSpacing( 70 ); + btnLayout->addStretch(); + btnLayout->addWidget( myCancelBtn ); + + ActivateModuleDlgLayout->addWidget( myComponentFrame, 0, 0 ); + ActivateModuleDlgLayout->addLayout( infoLayout, 0, 1 ); + ActivateModuleDlgLayout->addMultiCellLayout( btnLayout, 1, 1, 0, 1 ); - connect( m_pb1, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) ); - connect( m_pb2, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) ); - connect( m_pb3, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) ); - connect( m_pb4, SIGNAL( clicked() ), this, SLOT( reject() ) ); + // signals and slots connections + connect( myNewBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) ); + connect( myOpenBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) ); + connect( myLoadBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) ); + connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); } +//============================================================================================================================== +/*! + * SALOMEGUI_ActivateComponentDlg::onButtonClicked + * + * Buttons slot + */ +//============================================================================================================================== void SALOMEGUI_ActivateComponentDlg::onButtonClicked() { QPushButton* btn = ( QPushButton* )sender(); - if ( btn == m_pb1 ) + if ( btn == myNewBtn ) done( 1 ); - if ( btn == m_pb2 ) + if ( btn == myOpenBtn ) done( 2 ); - if ( btn == m_pb3 ) + if ( btn == myLoadBtn ) done( 3 ); } diff --git a/src/SALOMEGUI/SALOMEGUI_ActivateComponentDlg.h b/src/SALOMEGUI/SALOMEGUI_ActivateComponentDlg.h index 17544d0a2..878cb9d08 100644 --- a/src/SALOMEGUI/SALOMEGUI_ActivateComponentDlg.h +++ b/src/SALOMEGUI/SALOMEGUI_ActivateComponentDlg.h @@ -12,23 +12,32 @@ #define SALOMEGUI_ActivateComponentDlg_H #include +#include + +class QFrame; +class QLabel; +class QPushButton; class SALOMEGUI_ActivateComponentDlg: public QDialog { Q_OBJECT public: - SALOMEGUI_ActivateComponentDlg ( QWidget * parent = 0, const char * name = 0, bool modal = FALSE, WFlags f = 0 ) ; + SALOMEGUI_ActivateComponentDlg ( QWidget* parent, const QString& component, const QPixmap icon = QPixmap() ) ; ~SALOMEGUI_ActivateComponentDlg ( ) { }; private slots: void onButtonClicked(); private: - QPushButton* m_pb1; - QPushButton *m_pb2; - QPushButton *m_pb3; - QPushButton *m_pb4; + QFrame* myComponentFrame; + QLabel* myComponentLab; + QLabel* myComponentIcon; + QLabel* myInfoLabel; + QPushButton* myNewBtn; + QPushButton* myOpenBtn; + QPushButton* myLoadBtn; + QPushButton* myCancelBtn; }; #endif diff --git a/src/SALOMEGUI/SALOMEGUI_Application.cxx b/src/SALOMEGUI/SALOMEGUI_Application.cxx index faa38b44d..8d95761e9 100644 --- a/src/SALOMEGUI/SALOMEGUI_Application.cxx +++ b/src/SALOMEGUI/SALOMEGUI_Application.cxx @@ -29,6 +29,7 @@ #include "SALOMEGUI_Application.h" #include "SALOMEGUI_Desktop.h" #include "SALOMEGUI_ImportOperation.h" +#include "SALOMEGUI.h" #include "SALOME_Selection.h" #include "SALOME_ListIO.hxx" #include "SALOME_ListIteratorOfListIO.hxx" @@ -429,104 +430,26 @@ void SALOMEGUI_Application::onDisplay(int id) return; } - // Obtain the component's GUI library - // Library cashing will be implemented soon in QAD_Desktop to increase performance - OSD_Function osdF, osdViewTypeFunc; - OSD_SharedLibrary foreignGUI; - void (*builder)(const Handle(SALOME_InteractiveObject)&); - bool isForeignGUIUsed = false; bool isViewTypeOK = true; int viewTypes[VIEW_TYPE_MAX]; for (int i = 0; i < VIEW_TYPE_MAX; i++) viewTypes[i] = -1; - if (parentComp.compare(desktop->getActiveComponent()) == 0) { // use active GUI library - const OSD_SharedLibrary& compGUI = desktop->getHandle(); - osdF = compGUI.DlSymb("buildPresentation"); - if ( osdF == NULL ) { - MESSAGE("BuildPresentation method not found in component's GUI") - return; - } - osdViewTypeFunc = compGUI.DlSymb("supportedViewType"); - if ( osdViewTypeFunc == NULL ) { - MESSAGE("supportedViewType method not found in component's GUI") - } - MESSAGE("onDisplay(): using active GUI to build presentations") - } else { // use native GUI library - QString ComponentLib; - QCString dir; - QFileInfo fileInfo ; - bool found = false; - if ( getenv( QAD_Application::getDesktop()->getComponentName(parentComp) + "_ROOT_DIR") ) { - dir.fill('\0'); - dir.sprintf("%s", getenv( QAD_Application::getDesktop()->getComponentName(parentComp) + "_ROOT_DIR")); - dir = QAD_Tools::addSlash(dir) ; - dir = dir + "lib" ; - dir = QAD_Tools::addSlash(dir) ; - dir = dir + "salome" ; - dir = QAD_Tools::addSlash(dir) ; -#ifdef WNT - dir = dir + "lib" + QAD_Application::getDesktop()->getComponentName(parentComp).latin1() + "GUI.dll" ; -#else - dir = dir + "lib" + QAD_Application::getDesktop()->getComponentName(parentComp).latin1() + "GUI.so" ; -#endif - MESSAGE ( " GUI library = " << dir ) - fileInfo.setFile(dir) ; - if (fileInfo.exists()) { - ComponentLib = fileInfo.fileName() ; - found = true; - MESSAGE ( " found " ) - } else { - MESSAGE ( " Not found " ) - } - } - - if (ComponentLib.isEmpty()) { - waitCursor.stop(); - QMessageBox::critical( desktop, - tr("ERR_ERROR"), - "Empty name of component "+ parentComp + " library"); - return; - } - - foreignGUI.SetName(TCollection_AsciiString((char*)ComponentLib.latin1()).ToCString()); - - bool ok = foreignGUI.DlOpen(OSD_RTLD_LAZY); - if (!ok) { - waitCursor.stop(); - QMessageBox::critical( desktop, - tr("ERR_ERROR"), - tr( foreignGUI.DlError() ) ); - return; - } - - osdF = foreignGUI.DlSymb("buildPresentation"); - if ( osdF == NULL ) { - MESSAGE("BuildPresentation method not found in component's GUI") - foreignGUI.DlClose(); - return; - } - osdViewTypeFunc = foreignGUI.DlSymb("supportedViewType"); - if ( osdViewTypeFunc == NULL ) { - MESSAGE("supportedViewType method not found in component's GUI") - } - isForeignGUIUsed = true; - MESSAGE("onDisplay(): using parent component's GUI to build presentations") - } + // Obtain the component's GUI + SALOMEGUI* aGUI = desktop->getComponentGUI( parentComp ); + if ( !aGUI ) + return; // Check if another view type is required (if viewToActivate < 0 then any type of view is acceptable) - if (osdViewTypeFunc) { - void (*viewTypeChecker)(int*, int) = (void (*)(int*, int)) osdViewTypeFunc; - (*viewTypeChecker)(viewTypes, VIEW_TYPE_MAX); - if (viewTypes[0] >= 0) { // not all the view types are supported - for (int i = 0; i < VIEW_TYPE_MAX; i++) { - if (viewTypes[i] < 0) // no more types supported - break; - isViewTypeOK = ((int)myActiveStudy->getActiveStudyFrame()->getTypeView() == viewTypes[i]); - if (isViewTypeOK) // one of supported views is already active - break; - } + aGUI->SupportedViewType(viewTypes, VIEW_TYPE_MAX); + if (viewTypes[0] >= 0) { // not all the view types are supported + for (int i = 0; i < VIEW_TYPE_MAX; i++) { + if (viewTypes[i] < 0) // no more types supported + break; + isViewTypeOK = ((int)myActiveStudy->getActiveStudyFrame()->getTypeView() == viewTypes[i]); + if (isViewTypeOK) // one of supported views is already active + break; } } @@ -557,7 +480,6 @@ void SALOMEGUI_Application::onDisplay(int id) QAD_ViewFrame* viewFrame = myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame(); // Build the graphic presentation (it is stored in the corresponding viewer) - builder = (void (*) (const Handle(SALOME_InteractiveObject)&)) osdF; // Copy the selection SALOME_ListIteratorOfListIO itInit( Sel->StoredIObjects() ); @@ -598,13 +520,13 @@ void SALOMEGUI_Application::onDisplay(int id) childIObject->setEntry(child->GetID()); // Ensure that proper 3D presentation exists for IObject - (*builder)(childIObject); + aGUI->BuildPresentation(childIObject); viewFrame->Display(childIObject, false); needRepaint = true; } } else { // for child object -> simply display it (no children are displayed) // Ensure that proper 3D presentation exists for IObject - (*builder)(IObject); + aGUI->BuildPresentation(IObject); viewFrame->Display(IObject, false); needRepaint = true; } @@ -614,8 +536,6 @@ void SALOMEGUI_Application::onDisplay(int id) if (needRepaint) viewFrame->Repaint(); - if (isForeignGUIUsed) - ;//foreignGUI.DlClose(); // VSR: Fix crash on Display objects from non-parent components myActiveStudy->updateObjBrowser(true); } diff --git a/src/SALOMEGUI/SALOMEGUI_CloseDlg.cxx b/src/SALOMEGUI/SALOMEGUI_CloseDlg.cxx index 556e10ca4..090d66ad2 100644 --- a/src/SALOMEGUI/SALOMEGUI_CloseDlg.cxx +++ b/src/SALOMEGUI/SALOMEGUI_CloseDlg.cxx @@ -8,6 +8,7 @@ // Author : Vasily RUSYAEV (vrv) // Module : SALOME +using namespace std; #include "SALOMEGUI_CloseDlg.h" #include @@ -15,7 +16,6 @@ #include #include #include -using namespace std; SALOMEGUI_CloseDlg::SALOMEGUI_CloseDlg ( QWidget * parent, const char * name, bool modal, WFlags f ) diff --git a/src/SALOMEGUI/SALOMEGUI_Desktop.cxx b/src/SALOMEGUI/SALOMEGUI_Desktop.cxx index 0b24b49b0..63ce9dbe8 100644 --- a/src/SALOMEGUI/SALOMEGUI_Desktop.cxx +++ b/src/SALOMEGUI/SALOMEGUI_Desktop.cxx @@ -26,10 +26,10 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEGUI_Desktop.h" #include "SALOME_Selection.h" #include "SALOME_ListIteratorOfListIO.hxx" -using namespace std; #include CORBA_SERVER_HEADER(SALOMEDS_Attributes) diff --git a/src/SALOMEGUI/SALOMEGUI_ExternalBrowserDlg.cxx b/src/SALOMEGUI/SALOMEGUI_ExternalBrowserDlg.cxx index 52de812f9..2cb58f858 100644 --- a/src/SALOMEGUI/SALOMEGUI_ExternalBrowserDlg.cxx +++ b/src/SALOMEGUI/SALOMEGUI_ExternalBrowserDlg.cxx @@ -1,8 +1,9 @@ // File : SALOMEGUI_ExternalBrowserDlg.cxx // Author : Nichael ZORIN // Module : SALOME -// $Header: /dn05/salome/CVS/SALOME_ROOT/SALOME/src/SALOMEGUI/SALOMEGUI_ExternalBrowserDlg.cxx +// $Header$ +using namespace std; #include "SALOMEGUI_ExternalBrowserDlg.h" #include @@ -13,7 +14,6 @@ #include "QAD_FileDlg.h" #include "QAD_Tools.h" -using namespace std; /* * Constructs a modal SALOMEGUI_ExternalBowserDlg which is a child of 'parent' diff --git a/src/SALOMEGUI/SALOMEGUI_ExternalBrowserDlg.h b/src/SALOMEGUI/SALOMEGUI_ExternalBrowserDlg.h index 95156994b..f92b559c4 100644 --- a/src/SALOMEGUI/SALOMEGUI_ExternalBrowserDlg.h +++ b/src/SALOMEGUI/SALOMEGUI_ExternalBrowserDlg.h @@ -1,7 +1,7 @@ // File : SALOMEGUI_ExternalBrowserDlg.h // Author : Michael Zorin // Module : SALOME -// $Header: /dn05/salome/CVS/SALOME_ROOT/SALOME/src/SALOMEGUI/SALOMEGUI_ExternalBrowserDlg.h +// $Header$ #ifndef SALOMEGUI_EXTERNAL_BROWSER_DLG_H #define SALOMEGUI_EXTERNAL_BROWSER_DLG_H diff --git a/src/SALOMEGUI/SALOMEGUI_ImportOperation.cxx b/src/SALOMEGUI/SALOMEGUI_ImportOperation.cxx index 84e0c17ce..36c535e83 100644 --- a/src/SALOMEGUI/SALOMEGUI_ImportOperation.cxx +++ b/src/SALOMEGUI/SALOMEGUI_ImportOperation.cxx @@ -26,8 +26,8 @@ // Module : SALOME // $Header$ -#include "SALOMEGUI_ImportOperation.h" using namespace std; +#include "SALOMEGUI_ImportOperation.h" SALOMEGUI_ImportOperation::SALOMEGUI_ImportOperation( QAD_Study* study ) : QAD_Operation( study ) diff --git a/src/SALOMEGUI/SALOMEGUI_LoadStudiesDlg.cxx b/src/SALOMEGUI/SALOMEGUI_LoadStudiesDlg.cxx index 0e3c09dce..de3343aff 100644 --- a/src/SALOMEGUI/SALOMEGUI_LoadStudiesDlg.cxx +++ b/src/SALOMEGUI/SALOMEGUI_LoadStudiesDlg.cxx @@ -26,13 +26,13 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEGUI_LoadStudiesDlg.h" #include #include #include #include -using namespace std; #define SPACING_SIZE 6 #define MARGIN_SIZE 11 diff --git a/src/SALOMEGUI/SALOMEGUI_NameDlg.cxx b/src/SALOMEGUI/SALOMEGUI_NameDlg.cxx index 3153d8317..841e42f9b 100644 --- a/src/SALOMEGUI/SALOMEGUI_NameDlg.cxx +++ b/src/SALOMEGUI/SALOMEGUI_NameDlg.cxx @@ -9,6 +9,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEGUI_NameDlg.h" #include "QAD_Application.h" #include "QAD_Desktop.h" @@ -19,7 +20,6 @@ #include #include #include -using namespace std; /*! Constructor @@ -97,7 +97,8 @@ SALOMEGUI_NameDlg::~SALOMEGUI_NameDlg() void SALOMEGUI_NameDlg::setName( const QString& name ) { myLineEdit->setText( name ); - myLineEdit->selectAll(); + myLineEdit->end(false); + myLineEdit->home(true); } /*! @@ -108,6 +109,13 @@ QString SALOMEGUI_NameDlg::name() return myLineEdit->text(); } +void SALOMEGUI_NameDlg::accept() +{ + if ( name().stripWhiteSpace().isEmpty() ) + return; + QDialog::accept(); +} + /*! Creates modal dialog and returns name entered [ static ] */ diff --git a/src/SALOMEGUI/SALOMEGUI_NameDlg.h b/src/SALOMEGUI/SALOMEGUI_NameDlg.h index 42ec8382d..23fa03eb2 100644 --- a/src/SALOMEGUI/SALOMEGUI_NameDlg.h +++ b/src/SALOMEGUI/SALOMEGUI_NameDlg.h @@ -34,6 +34,9 @@ public: static QString getName( QWidget* parent = 0, const QString& oldName = QString::null ); +protected slots: + void accept(); + private: QPushButton* myButtonOk; QPushButton* myButtonCancel; diff --git a/src/SALOMEGUI/SALOMEGUI_OpenWith.cxx b/src/SALOMEGUI/SALOMEGUI_OpenWith.cxx index 16664321e..1638bdbb9 100644 --- a/src/SALOMEGUI/SALOMEGUI_OpenWith.cxx +++ b/src/SALOMEGUI/SALOMEGUI_OpenWith.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEGUI_OpenWith.h" #include @@ -33,7 +34,6 @@ #include #include #include -using namespace std; #define SPACING_SIZE 6 #define MARGIN_SIZE 11 @@ -92,6 +92,7 @@ SALOMEGUI_OpenWith::SALOMEGUI_OpenWith(QWidget* parent, const char* name) connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); connect( ListComponent, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() )); + connect( ListComponent, SIGNAL( doubleClicked( QListBoxItem* ) ), this, SLOT( onDoubleClickEvent( QListBoxItem* ) )); updateButtonState(); } @@ -135,3 +136,9 @@ void SALOMEGUI_OpenWith:: updateButtonState() buttonOk->setEnabled( ListComponent->currentItem() >=0 && ListComponent->currentItem() < ListComponent->count() ) ; } + +void SALOMEGUI_OpenWith::onDoubleClickEvent( QListBoxItem* item ) +{ + if ( item ) + accept(); +} diff --git a/src/SALOMEGUI/SALOMEGUI_OpenWith.h b/src/SALOMEGUI/SALOMEGUI_OpenWith.h index 961dcb8d4..b71ac6e08 100644 --- a/src/SALOMEGUI/SALOMEGUI_OpenWith.h +++ b/src/SALOMEGUI/SALOMEGUI_OpenWith.h @@ -32,6 +32,7 @@ #include class QListBox; +class QListBoxItem; class QCheckBox; class QPushButton; @@ -49,10 +50,11 @@ public: protected slots: void onSelectionChanged(); + void onDoubleClickEvent( QListBoxItem* item ); protected: void updateButtonState(); - + protected: QListBox* ListComponent; QCheckBox* AllwaysCheckBox; diff --git a/src/SALOMEGUI/SALOMEGUI_QtCatchCorbaException.cxx b/src/SALOMEGUI/SALOMEGUI_QtCatchCorbaException.cxx index ede2c4366..971433632 100644 --- a/src/SALOMEGUI/SALOMEGUI_QtCatchCorbaException.cxx +++ b/src/SALOMEGUI/SALOMEGUI_QtCatchCorbaException.cxx @@ -26,12 +26,12 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEGUI_QtCatchCorbaException.hxx" #include "utilities.h" #include "QAD_Desktop.h" #include "QAD_MessageBox.h" -using namespace std; void QtCatchCorbaException(const SALOME::SALOME_Exception & S_ex) { diff --git a/src/SALOMEGUI/SALOMEGUI_SetValueDlg.cxx b/src/SALOMEGUI/SALOMEGUI_SetValueDlg.cxx index caa274038..3a8eb70f2 100644 --- a/src/SALOMEGUI/SALOMEGUI_SetValueDlg.cxx +++ b/src/SALOMEGUI/SALOMEGUI_SetValueDlg.cxx @@ -9,6 +9,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEGUI_SetValueDlg.h" #include "QAD_Tools.h" @@ -18,7 +19,6 @@ #include #include #include -using namespace std; #define MARGIN_SIZE 11 #define SPACING_SIZE 6 diff --git a/src/SALOMEGUI/SALOMEGUI_SetupCurveDlg.cxx b/src/SALOMEGUI/SALOMEGUI_SetupCurveDlg.cxx index 4265cb95d..15e5b4cb6 100644 --- a/src/SALOMEGUI/SALOMEGUI_SetupCurveDlg.cxx +++ b/src/SALOMEGUI/SALOMEGUI_SetupCurveDlg.cxx @@ -9,6 +9,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEGUI_SetupCurveDlg.h" #include "QAD_Tools.h" #include @@ -19,7 +20,6 @@ #include #include #include -using namespace std; #define MARGIN_SIZE 11 #define SPACING_SIZE 6 diff --git a/src/SALOMEGUI/SALOMEGUI_StudyPropertiesDlg.cxx b/src/SALOMEGUI/SALOMEGUI_StudyPropertiesDlg.cxx index 4d9a73281..0019a14dd 100644 --- a/src/SALOMEGUI/SALOMEGUI_StudyPropertiesDlg.cxx +++ b/src/SALOMEGUI/SALOMEGUI_StudyPropertiesDlg.cxx @@ -9,6 +9,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEGUI_StudyPropertiesDlg.h" #include "QAD_Desktop.h" @@ -18,7 +19,6 @@ #include #include -using namespace std; #define DEFAULT_MARGIN 11 #define DEFAULT_SPACING 6 diff --git a/src/SALOMEGUI/SALOMEGUI_Swig.cxx b/src/SALOMEGUI/SALOMEGUI_Swig.cxx index 9bf557876..00f6efb08 100644 --- a/src/SALOMEGUI/SALOMEGUI_Swig.cxx +++ b/src/SALOMEGUI/SALOMEGUI_Swig.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "QAD_Application.h" #include "QAD_Desktop.h" #include "QAD_Study.h" @@ -37,7 +38,6 @@ #include "SALOME_Selection.h" #include "SALOME_InteractiveObject.hxx" #include "SALOME_ListIteratorOfListIO.hxx" -using namespace std; /*! @@ -374,7 +374,7 @@ bool SALOMEGUI_Swig::IsInCurrentView(const char *Entry) if ((viewId >=0) && (viewId getStudyFrame(viewId)->getRightFrame()->getViewFrame()->getRenderer(); } - if (myRenderer == NULL) INFOS("No VTK Renderer available !"); + if (myRenderer == NULL) MESSAGE("No VTK Renderer available !"); return myRenderer; } */ diff --git a/src/SALOMEGUI/SALOMEGUI_TableDlg.cxx b/src/SALOMEGUI/SALOMEGUI_TableDlg.cxx index 59afc147b..07c1b7bdb 100644 --- a/src/SALOMEGUI/SALOMEGUI_TableDlg.cxx +++ b/src/SALOMEGUI/SALOMEGUI_TableDlg.cxx @@ -9,6 +9,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEGUI_TableDlg.h" #include "QAD_Tools.h" #include "QAD_MessageBox.h" @@ -21,7 +22,6 @@ #include #include #include "utilities.h" -using namespace std; #define MARGIN_SIZE 11 #define SPACING_SIZE 6 diff --git a/src/SALOMEGUI/SALOMEGUI_TrihedronSizeDlg.cxx b/src/SALOMEGUI/SALOMEGUI_TrihedronSizeDlg.cxx index 8f78226ce..ed31165c3 100644 --- a/src/SALOMEGUI/SALOMEGUI_TrihedronSizeDlg.cxx +++ b/src/SALOMEGUI/SALOMEGUI_TrihedronSizeDlg.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEGUI_TrihedronSizeDlg.h" #include @@ -33,7 +34,6 @@ #include #include #include -using namespace std; #define MARGIN_SIZE 11 #define SPACING_SIZE 6 diff --git a/src/SALOMEGUI/SALOMEGUI_ViewChoiceDlg.cxx b/src/SALOMEGUI/SALOMEGUI_ViewChoiceDlg.cxx index 9451c8777..d091d18da 100644 --- a/src/SALOMEGUI/SALOMEGUI_ViewChoiceDlg.cxx +++ b/src/SALOMEGUI/SALOMEGUI_ViewChoiceDlg.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOMEGUI_ViewChoiceDlg.h" #include "QAD_Config.h" #include "QAD_StudyFrame.h" @@ -38,7 +39,6 @@ #include #include #include -using namespace std; /* * Constructs a SALOMEGUI_ViewChoiceDlg which is a child of 'parent', with the diff --git a/src/SALOMEGUI/SALOMEGUI_msg_en.po b/src/SALOMEGUI/SALOMEGUI_msg_en.po index 311b6075f..e050c3f4b 100644 --- a/src/SALOMEGUI/SALOMEGUI_msg_en.po +++ b/src/SALOMEGUI/SALOMEGUI_msg_en.po @@ -646,9 +646,15 @@ msgid "MEN_PLOT2D_SETTINGS" msgstr "&Settings" msgid "PRP_PLOT2D_SETTINGS" msgstr "Setups view properties" +msgid "TOT_PLOT2D_CHANGE_BACKGROUND" +msgstr "Change background" +msgid "MEN_PLOT2D_CHANGE_BACKGROUND" +msgstr "Change background..." +msgid "PRP_PLOT2D_CHANGE_BACKGROUND" +msgstr "Change background color" msgid "INF_COORDINATES" -msgstr "Coordinates" +msgstr "Coordinates: X : %1, Y : %2" msgid "SALOMEGUI_SetupCurveDlg::TLT_SETUP_CURVE" msgstr "Setup Curve" @@ -694,7 +700,7 @@ msgid "SALOMEGUI_ActivateComponentDlg::CANCEL" msgstr "&Cancel" msgid "SALOMEGUI_ActivateComponentDlg::ActivateComponent_DESCRIPTION" -msgstr "You need to create, open or load study before." +msgstr "Create, open or load study." msgid "SALOMEGUI_HELP_TITLE" msgstr "SALOME Help" diff --git a/src/SALOMEGUI/SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_0.cxx b/src/SALOMEGUI/SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_0.cxx index 7cc57f40b..1fca36e3e 100644 --- a/src/SALOMEGUI/SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_0.cxx +++ b/src/SALOMEGUI/SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_0.cxx @@ -24,6 +24,7 @@ // File : SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_0.cxx // Module : SALOME +using namespace std; #include "SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx" #ifndef _Standard_NoSuchObject_HeaderFile @@ -44,7 +45,6 @@ #ifndef _SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_HeaderFile #include "SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx" #endif -using namespace std; #define TheKey Handle_SALOME_InteractiveObject diff --git a/src/SALOMEGUI/SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_0.cxx b/src/SALOMEGUI/SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_0.cxx index f58510533..7fefc9c06 100644 --- a/src/SALOMEGUI/SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_0.cxx +++ b/src/SALOMEGUI/SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_0.cxx @@ -24,6 +24,7 @@ // File : SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_0.cxx // Module : SALOME +using namespace std; #include "SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx" #ifndef _Standard_TypeMismatch_HeaderFile @@ -45,9 +46,6 @@ #ifndef _SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_HeaderFile #include "SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx" #endif -using namespace std; - - SALOME_DataMapNodeOfDataMapOfIOMapOfInteger::~SALOME_DataMapNodeOfDataMapOfIOMapOfInteger() {} diff --git a/src/SALOMEGUI/SALOME_DataMapOfIOMapOfInteger_0.cxx b/src/SALOMEGUI/SALOME_DataMapOfIOMapOfInteger_0.cxx index 9800abcf3..990e1bad6 100644 --- a/src/SALOMEGUI/SALOME_DataMapOfIOMapOfInteger_0.cxx +++ b/src/SALOMEGUI/SALOME_DataMapOfIOMapOfInteger_0.cxx @@ -24,6 +24,7 @@ // File : SALOME_DataMapOfIOMapOfInteger_0.cxx // Module : SALOME +using namespace std; #include "SALOME_DataMapOfIOMapOfInteger.hxx" #ifndef _Standard_DomainError_HeaderFile @@ -47,7 +48,6 @@ #ifndef _SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_HeaderFile #include "SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx" #endif -using namespace std; #define TheKey Handle_SALOME_InteractiveObject diff --git a/src/SALOMEGUI/SALOME_Filter.cxx b/src/SALOMEGUI/SALOME_Filter.cxx index 816c9869f..2a095e50a 100644 --- a/src/SALOMEGUI/SALOME_Filter.cxx +++ b/src/SALOMEGUI/SALOME_Filter.cxx @@ -26,6 +26,6 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOME_Filter.ixx" -using namespace std; diff --git a/src/SALOMEGUI/SALOME_ListIO.hxx b/src/SALOMEGUI/SALOME_ListIO.hxx index 434a31f64..e028e243f 100644 --- a/src/SALOMEGUI/SALOME_ListIO.hxx +++ b/src/SALOMEGUI/SALOME_ListIO.hxx @@ -90,10 +90,10 @@ Standard_EXPORT void Clear() ; Standard_EXPORT Standard_Boolean IsEmpty() const; Standard_EXPORT void Prepend(const Handle(SALOME_InteractiveObject)& I) ; Standard_EXPORT void Prepend(SALOME_ListIO& Other) ; -Standard_EXPORT void Prepend(const Handle(SALOME_InteractiveObject)& I,SALOME_ListIteratorOfListIO& It); +Standard_EXPORT void Prepend(const Handle(SALOME_InteractiveObject)& I, SALOME_ListIteratorOfListIO& It) ; Standard_EXPORT void Append(const Handle(SALOME_InteractiveObject)& I) ; -Standard_EXPORT void Append(const Handle(SALOME_InteractiveObject)& I,SALOME_ListIteratorOfListIO& It); Standard_EXPORT void Append(SALOME_ListIO& Other) ; +Standard_EXPORT void Append(const Handle(SALOME_InteractiveObject)& I, SALOME_ListIteratorOfListIO& It) ; Standard_EXPORT Handle_SALOME_InteractiveObject& First() const; Standard_EXPORT Handle_SALOME_InteractiveObject& Last() const; Standard_EXPORT void RemoveFirst() ; diff --git a/src/SALOMEGUI/SALOME_ListIO_0.cxx b/src/SALOMEGUI/SALOME_ListIO_0.cxx index 71260fa5b..0c5ee6097 100644 --- a/src/SALOMEGUI/SALOME_ListIO_0.cxx +++ b/src/SALOMEGUI/SALOME_ListIO_0.cxx @@ -24,6 +24,7 @@ // File : SALOME_ListIO_0.cxx // Module : SALOME +using namespace std; #include "SALOME_ListIO.hxx" #ifndef _Standard_NoSuchObject_HeaderFile @@ -38,7 +39,6 @@ #ifndef _SALOME_ListNodeOfListIO_HeaderFile #include "SALOME_ListNodeOfListIO.hxx" #endif -using namespace std; #define Item Handle_SALOME_InteractiveObject diff --git a/src/SALOMEGUI/SALOME_ListIteratorOfListIO_0.cxx b/src/SALOMEGUI/SALOME_ListIteratorOfListIO_0.cxx index adb55ab72..928d94559 100644 --- a/src/SALOMEGUI/SALOME_ListIteratorOfListIO_0.cxx +++ b/src/SALOMEGUI/SALOME_ListIteratorOfListIO_0.cxx @@ -24,6 +24,7 @@ // File : SALOME_ListIteratorOfListIO_0.cxx // Module : SALOME +using namespace std; #include "SALOME_ListIteratorOfListIO.hxx" #ifndef _Standard_NoMoreObject_HeaderFile @@ -41,7 +42,6 @@ #ifndef _SALOME_ListNodeOfListIO_HeaderFile #include "SALOME_ListNodeOfListIO.hxx" #endif -using namespace std; #define Item Handle_SALOME_InteractiveObject diff --git a/src/SALOMEGUI/SALOME_ListIteratorOfListOfFilter_0.cxx b/src/SALOMEGUI/SALOME_ListIteratorOfListOfFilter_0.cxx index 57a0e587b..95cba8a29 100644 --- a/src/SALOMEGUI/SALOME_ListIteratorOfListOfFilter_0.cxx +++ b/src/SALOMEGUI/SALOME_ListIteratorOfListOfFilter_0.cxx @@ -24,6 +24,7 @@ // File : SALOME_ListIteratorOfListOfFilter_0.cxx // Module : SALOME +using namespace std; #include "SALOME_ListIteratorOfListOfFilter.hxx" #ifndef _Standard_NoMoreObject_HeaderFile @@ -41,7 +42,6 @@ #ifndef _SALOME_ListNodeOfListOfFilter_HeaderFile #include "SALOME_ListNodeOfListOfFilter.hxx" #endif -using namespace std; #define Item Handle_SALOME_Filter diff --git a/src/SALOMEGUI/SALOME_ListNodeOfListIO_0.cxx b/src/SALOMEGUI/SALOME_ListNodeOfListIO_0.cxx index 932626022..95147d20d 100644 --- a/src/SALOMEGUI/SALOME_ListNodeOfListIO_0.cxx +++ b/src/SALOMEGUI/SALOME_ListNodeOfListIO_0.cxx @@ -24,6 +24,7 @@ // File : SALOME_ListNodeOfListIO_0.cxx // Module : SALOME +using namespace std; #include "SALOME_ListNodeOfListIO.hxx" #ifndef _Standard_TypeMismatch_HeaderFile @@ -39,9 +40,6 @@ #ifndef _SALOME_ListIteratorOfListIO_HeaderFile #include "SALOME_ListIteratorOfListIO.hxx" #endif -using namespace std; - - SALOME_ListNodeOfListIO::~SALOME_ListNodeOfListIO() {} diff --git a/src/SALOMEGUI/SALOME_ListNodeOfListOfFilter_0.cxx b/src/SALOMEGUI/SALOME_ListNodeOfListOfFilter_0.cxx index 6837e6fca..b89c9d1e7 100644 --- a/src/SALOMEGUI/SALOME_ListNodeOfListOfFilter_0.cxx +++ b/src/SALOMEGUI/SALOME_ListNodeOfListOfFilter_0.cxx @@ -24,6 +24,7 @@ // File : SALOME_ListNodeOfListOfFilter_0.cxx // Module : SALOME +using namespace std; #include "SALOME_ListNodeOfListOfFilter.hxx" #ifndef _Standard_TypeMismatch_HeaderFile @@ -39,10 +40,6 @@ #ifndef _SALOME_ListIteratorOfListOfFilter_HeaderFile #include "SALOME_ListIteratorOfListOfFilter.hxx" #endif -using namespace std; - - - SALOME_ListNodeOfListOfFilter::~SALOME_ListNodeOfListOfFilter() {} diff --git a/src/SALOMEGUI/SALOME_ListOfFilter.hxx b/src/SALOMEGUI/SALOME_ListOfFilter.hxx index fef6bfd5c..1024a2159 100644 --- a/src/SALOMEGUI/SALOME_ListOfFilter.hxx +++ b/src/SALOMEGUI/SALOME_ListOfFilter.hxx @@ -94,10 +94,10 @@ Standard_EXPORT void Clear() ; Standard_EXPORT inline Standard_Boolean IsEmpty() const; Standard_EXPORT void Prepend(const Handle(SALOME_Filter)& I) ; Standard_EXPORT void Prepend(SALOME_ListOfFilter& Other) ; -Standard_EXPORT void Prepend(const Handle(SALOME_Filter)& I,SALOME_ListIteratorOfListOfFilter& It); +Standard_EXPORT void Prepend(const Handle(SALOME_Filter)& I, SALOME_ListIteratorOfListOfFilter& It) ; Standard_EXPORT void Append(const Handle(SALOME_Filter)& I) ; Standard_EXPORT void Append(SALOME_ListOfFilter& Other) ; -Standard_EXPORT void Append(const Handle(SALOME_Filter)& I,SALOME_ListIteratorOfListOfFilter& It); +Standard_EXPORT void Append(const Handle(SALOME_Filter)& I, SALOME_ListIteratorOfListOfFilter& It) ; Standard_EXPORT Handle_SALOME_Filter& First() const; Standard_EXPORT Handle_SALOME_Filter& Last() const; Standard_EXPORT void RemoveFirst() ; diff --git a/src/SALOMEGUI/SALOME_ListOfFilter_0.cxx b/src/SALOMEGUI/SALOME_ListOfFilter_0.cxx index 8b30df9f6..6dbbdaacf 100644 --- a/src/SALOMEGUI/SALOME_ListOfFilter_0.cxx +++ b/src/SALOMEGUI/SALOME_ListOfFilter_0.cxx @@ -24,6 +24,7 @@ // File : SALOME_ListOfFilter_0.cxx // Module : SALOME +using namespace std; #include "SALOME_ListOfFilter.hxx" #ifndef _Standard_NoSuchObject_HeaderFile @@ -38,7 +39,6 @@ #ifndef _SALOME_ListNodeOfListOfFilter_HeaderFile #include "SALOME_ListNodeOfListOfFilter.hxx" #endif -using namespace std; #define Item Handle_SALOME_Filter diff --git a/src/SALOMEGUI/SALOME_NumberFilter.cxx b/src/SALOMEGUI/SALOME_NumberFilter.cxx index cdc63948e..3574d8d64 100644 --- a/src/SALOMEGUI/SALOME_NumberFilter.cxx +++ b/src/SALOMEGUI/SALOME_NumberFilter.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOME_NumberFilter.ixx" #include "SALOME_Selection.h" #include "SALOME_InteractiveObject.hxx" @@ -33,7 +34,6 @@ #include "QAD_Application.h" #include "QAD_Desktop.h" #include "QAD_Study.h" -using namespace std; SALOME_NumberFilter::SALOME_NumberFilter(NumberFilter TheKind, Standard_Integer aValue): myKind(TheKind), diff --git a/src/SALOMEGUI/SALOME_Selection.cxx b/src/SALOMEGUI/SALOME_Selection.cxx index c5477bd63..21fa00996 100644 --- a/src/SALOMEGUI/SALOME_Selection.cxx +++ b/src/SALOMEGUI/SALOME_Selection.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +using namespace std; /*! \class SALOME_Selection SALOME_Selection.h \brief Selection Mechanism of Interactive Object. @@ -39,7 +40,8 @@ #include "QAD_Desktop.h" #include "utilities.h" -using namespace std; + +#include static QList& SALOME_Sel_GetSelections() { @@ -59,7 +61,7 @@ SALOME_Selection::SALOME_Selection(const QString& aName) : { myFilters.Clear(); myIObjects.Clear(); - mySelectionMode = 4; /*Actor*/ + mySelectionMode = ActorSelection; /*4*/ mySelActiveCompOnly = false; QAD_Desktop* aDesktop = QAD_Application::getDesktop(); @@ -328,13 +330,13 @@ bool SALOME_Selection::IsOk(const Handle(SALOME_InteractiveObject)& anObj) return true; } -void SALOME_Selection::SetSelectionMode(int mode, bool activeCompOnly) +void SALOME_Selection::SetSelectionMode(Selection_Mode mode, bool activeCompOnly) { mySelectionMode = mode; mySelActiveCompOnly = activeCompOnly; } -int SALOME_Selection::SelectionMode() +Selection_Mode SALOME_Selection::SelectionMode() { return mySelectionMode; } @@ -378,7 +380,7 @@ bool SALOME_Selection::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& bool modeShift, bool update) { - MESSAGE ( " SALOME_Selection::AddOrRemoveIndex " << index << " - " << modeShift ) + MESSAGE ( " SALOME_Selection::AddOrRemoveIndex " << index << " - " << modeShift ); QAD_Desktop* myDesktop = (QAD_Desktop*) QAD_Application::getDesktop(); QAD_Study* myActiveStudy = myDesktop->getActiveStudy(); @@ -412,6 +414,86 @@ bool SALOME_Selection::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& return false; } +bool SALOME_Selection::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, + const TColStd_MapOfInteger& theIndices, + bool modeShift, + bool update) +{ + QAD_Desktop* myDesktop = (QAD_Desktop*) QAD_Application::getDesktop(); + QAD_Study* myActiveStudy = myDesktop->getActiveStudy(); + + if ( !myMapIOSubIndex.IsBound( IObject ) ) { + TColStd_MapOfInteger Empty; + myMapIOSubIndex.Bind( IObject, Empty ); + } + TColStd_MapOfInteger& MapIndex = myMapIOSubIndex.ChangeFind( IObject ); + TColStd_MapIteratorOfMapOfInteger It; + It.Initialize(theIndices); + + bool add = true; + + if (MapIndex.Contains(It.Key())) + { + if (!modeShift) return add; + add = false; + } + else if (!modeShift) + MapIndex.Clear(); + + if (add) + for(;It.More();It.Next()) + MapIndex.Add(It.Key()); + else + for(;It.More();It.Next()) + MapIndex.Remove(It.Key()); + + + myActiveStudy->highlight( IObject, true, update ); + if ( MapIndex.IsEmpty() ) myMapIOSubIndex.UnBind( IObject ); + emit currentSelectionChanged(); + + return add; +} + +bool SALOME_Selection::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, + const std::vector& theIndices, + bool modeShift, + bool update) +{ + QAD_Desktop* myDesktop = (QAD_Desktop*) QAD_Application::getDesktop(); + QAD_Study* myActiveStudy = myDesktop->getActiveStudy(); + + if ( !myMapIOSubIndex.IsBound( IObject ) ) { + TColStd_MapOfInteger Empty; + myMapIOSubIndex.Bind( IObject, Empty ); + } + TColStd_MapOfInteger& MapIndex = myMapIOSubIndex.ChangeFind( IObject ); + + bool add = true; + + if (MapIndex.Contains(theIndices[0])) + { + if (!modeShift) return add; + add = false; + } + else if (!modeShift) + MapIndex.Clear(); + + if (add) + for (int i=0; ihighlight( IObject, true, update ); + if ( MapIndex.IsEmpty() ) + myMapIOSubIndex.UnBind( IObject ); + emit currentSelectionChanged(); + + return add; +} + void SALOME_Selection::RemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, int index ) { if ( myMapIOSubIndex.IsBound( IObject ) ) { diff --git a/src/SALOMEGUI/SALOME_Selection.h b/src/SALOMEGUI/SALOME_Selection.h index 6c0eca8a6..0058a1984 100644 --- a/src/SALOMEGUI/SALOME_Selection.h +++ b/src/SALOMEGUI/SALOME_Selection.h @@ -43,11 +43,23 @@ // Open CASCADE Include #include +#include + +enum Selection_Mode { + NodeSelection, + CellSelection, + EdgeOfCellSelection, + EdgeSelection, + FaceSelection, + VolumeSelection, + ActorSelection }; + class SALOME_Selection : public QObject { Q_OBJECT public: + SALOME_Selection(const QString& aName); ~SALOME_Selection(); @@ -78,8 +90,8 @@ public: bool IsOk( const Handle(SALOME_InteractiveObject)& IObject ) ; - void SetSelectionMode(int mode, bool activeCompOnly = false); - int SelectionMode(); + void SetSelectionMode(Selection_Mode mode, bool activeCompOnly = false); + Selection_Mode SelectionMode(); bool IsSelectActiveCompOnly() const; bool HasIndex( const Handle(SALOME_InteractiveObject)& IObject ); @@ -87,6 +99,8 @@ public: TColStd_MapOfInteger& theIndex ); bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, int index, bool modeShift, bool update=true ); + bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, const TColStd_MapOfInteger& theIndices, bool modeShift, bool update=true ); + bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, const std::vector& theIndices, bool modeShift, bool update=true ); void RemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, int index ); bool IsIndexSelected(const Handle(SALOME_InteractiveObject)& IObject, int index); @@ -100,7 +114,7 @@ private: SALOME_DataMapOfIOMapOfInteger myMapIOSubIndex; - int mySelectionMode; + Selection_Mode mySelectionMode; bool mySelActiveCompOnly; }; diff --git a/src/SALOMEGUI/SALOME_TypeFilter.cxx b/src/SALOMEGUI/SALOME_TypeFilter.cxx index 83f1d71ec..4bc2a5246 100644 --- a/src/SALOMEGUI/SALOME_TypeFilter.cxx +++ b/src/SALOMEGUI/SALOME_TypeFilter.cxx @@ -26,9 +26,9 @@ // Module : SALOME // $Header$ +using namespace std; #include "SALOME_TypeFilter.ixx" #include "SALOME_InteractiveObject.hxx" -using namespace std; SALOME_TypeFilter::SALOME_TypeFilter(const Standard_CString TheKind): myKind(TheKind){}