--- /dev/null
+// 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
+
--- /dev/null
+// 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<Object> IORTab;
+ interface MPIObject
+ {
+ attribute IORTab tior;
+ } ;
+} ;
+
+#endif
top_srcdir=@top_srcdir@
top_builddir=..
srcdir=@srcdir@
-VPATH=.:$(srcdir)
+VPATH=.
@COMMENCE@
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
$(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) $<
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 \
distclean:
-$(RM) *.py
- -$(RM) $(IDL_FILES:%=$(top_builddir)/idl/%)
+ -$(RM) $(IDL_FILES:%=$(top_builddir)/idl/salome/%)
-$(RM) Makefile
*/
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
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.
*/
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);
};
//==========================================================================
/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();
};
\note <BR>This exception is raised only outside a transaction.
*/
void CheckLocked() raises (LockProtection);
+
+ string Store();
+
+ void Restore(in string theData);
+
+ string Type();
+
+ SObject GetSObject();
};
Attribute allowing to store a real value
*/
//==========================================================================
+
interface AttributeReal : GenericAttribute
{
/*!
<BR><VAR>See also <A href=exemple/Example1.html> an example </A> of this method usage in batchmode of %SALOME application.</VAR>
*/
void SetValue(in double value);
+
};
//==========================================================================
/*! \brief Attribute allowing to store an integer value
*/
module Engines
{
+/*!
+ General Key Value Structure to set or get properties, for component
+*/
+ struct KeyValuePair
+ {
+ string key;
+ any value;
+ };
+
+ typedef sequence<KeyValuePair> FieldsDict;
+
interface Component ;
/*! \brief Interface of the %Container
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
string Parametername; /*!<Name of the parameter.*/
} ;
+ enum DataStreamDependency {
+ DATASTREAM_UNDEFINED,
+ DATASTREAM_TEMPORAL,
+ DATASTREAM_ITERATIVE
+ } ;
+
+ enum DataStreamType {
+ DATASTREAM_UNKNOWN,
+ DATASTREAM_INTEGER,
+ DATASTREAM_FLOAT,
+ DATASTREAM_DOUBLE,
+ DATASTREAM_STRING,
+ DATASTREAM_BOOLEAN
+ } ;
+
+ struct ServicesDataStreamParameter
+ {
+ DataStreamType Parametertype; /*!<Type of the parameter.*/
+ string Parametername; /*!<Name of the parameter.*/
+ DataStreamDependency Parameterdependency; /*!<Temporal or iterative dependency.*/
+ } ;
+
/*!
The list of the parameters of service.
*/
typedef sequence<ServicesParameter> ListOfServicesParameter;
+ typedef sequence<ServicesDataStreamParameter> ListOfServicesDataStreamParameter;
/*!
This struct contains fields completely defining each service.
struct Service
{
- string ServiceName; /*!<Name of the service.*/
- ListOfServicesParameter ServiceinParameter; /*!< List of input parameters of the services.*/
- ListOfServicesParameter ServiceoutParameter; /*!< List of output parameters of the services.*/
- boolean Servicebydefault; /*!<True if the service is taken with its defult fields.*/
+ string ServiceName; /*!<Name of the service.*/
+ ListOfServicesParameter ServiceinParameter; /*!< List of input parameters of the services.*/
+ ListOfServicesParameter ServiceoutParameter; /*!< List of output parameters of the services.*/
+ ListOfServicesDataStreamParameter ServiceinDataStreamParameter; /*!< List of input parameters of the services.*/
+ ListOfServicesDataStreamParameter ServiceoutDataStreamParameter; /*!< List of output parameters of the services.*/
+ boolean Servicebydefault; /*!<True if the service is taken with its default fields.*/
+ boolean TypeOfNode; /*!<True is the service is a factory node. Otherwise, it's a compute node.*/
} ;
/*!
List of services of the interface.
List of names of interfaces.
*/
typedef sequence<string> 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<PathPrefix> 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.
*/
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.
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();
} ;
};
interface TestComponent : Component
{
string Coucou(in long L);
+ void Setenv();
};
};
--- /dev/null
+// 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
--- /dev/null
+// 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<double> DoubleVec ;
+ typedef sequence<long> IntVec;
+
+ typedef struct CSR {
+ unsigned long nbpos;
+ unsigned long nbval;
+ IntVec pos;
+ IntVec col;
+ DoubleVec data;
+ } CSRMatStruct;
+
+} ;
+
+#endif
+
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOME_Component_i.hxx"
#include "RegistryConnexion.hxx"
#include "OpUtil.hxx"
#include <stdio.h>
#include <dlfcn.h>
+#include <cstdlib>
#include "utilities.h"
-using namespace std;
extern bool _Sleeping ;
static Engines_Component_i * theEngines_Component ;
return _id ;
}
+void Engines_Component_i::setProperties(const Engines::FieldsDict& dico)
+{
+ _fieldsDict.clear();
+ for (CORBA::ULong i=0; i<dico.length(); i++)
+ {
+ std::string cle(dico[i].key);
+ _fieldsDict[cle] = dico[i].value;
+ }
+}
+
+Engines::FieldsDict* Engines_Component_i::getProperties()
+{
+ Engines::FieldsDict_var copie = new Engines::FieldsDict;
+ copie->length(_fieldsDict.size());
+ map<std::string,CORBA::Any>::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
// 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<std::string,CORBA::Any>::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: "<<cle<<" = "<< value);
+ }
+ }
}
void Engines_Component_i::endService(const char *serviceName)
return CORBA::string_dup( _nodeName.c_str() ) ;
}
-bool Engines_Component_i::Killer( pthread_t ThreadId , int signum ) {
+bool Engines_Component_i::Killer( int ThreadId , int signum ) {
if ( ThreadId ) {
if ( signum == 0 ) {
if ( pthread_cancel( ThreadId ) ) {
return cpu ;
}
-CORBA::Long Engines_Component_i::CpuUsed_impl() {
+long Engines_Component_i::CpuUsed_impl() {
long cpu = 0 ;
if ( _ThreadId || _Executed ) {
if ( _ThreadId > 0 ) {
// 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_<SALOME_NamingService>::Instance() ;
ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting()) ;
SCRUTE(_containerName);
_NS->Register(pCont, _containerName.c_str());
}
-
}
Engines_Container_i::~Engines_Container_i()
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 "
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
}
}
catch (...) {
- MESSAGE( "Container_i::load_impl catched" ) ;
+ INFOS( "Container_i::load_impl catched" ) ;
}
//Jr _numInstanceMutex.lock() ; // lock on the add on handle_map (necessary ?)
<< " si_pid " << siginfo->si_pid) ;
if ( _Sleeping ) {
_Sleeping = false ;
- INFOS("SigIntHandler END sleeping.")
MESSAGE("SigIntHandler END sleeping.") ;
return ;
}
}
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 ;
LDFLAGS+= -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification -lSALOMELocalTrace
-LIBS += @LDEXPDYNFLAGS@ $(PYTHON_LIBS)
+LIBS += -Xlinker -export-dynamic $(PYTHON_LIBS)
@CONCLUDE@
class SALOME_ComponentPy_i (Engines__POA.Component):
_orb = None
_poa = None
+ _fieldsDict = []
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------
+ 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)
#include <unistd.h>
#include <sys/types.h>
#include <string>
+#include <map>
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOME_Component)
#include "NOTIFICATION.hxx"
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);
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 ;
Engines_Component_i * _thisObj ;
RegistryConnexion *_myConnexionToRegistry;
NOTIFICATION_Supplier* _notifSupplier;
+ map<std::string,CORBA::Any>_fieldsDict;
private:
pthread_t _ThreadId ;
#include <iostream>
#include <string>
#include "utilities.h"
+#include "Utils_CatchSignals.h"
using namespace std;
#ifdef CHECKTIME
MESSAGE("SALOME_Registry_Server.cxx - orb->run()");
timer.ShowAbsolute();
#endif
+ Utils_CatchSignals aCatch;
+ aCatch.Activate();
+
orb->run();
+ aCatch.Deactivate();
orb->destroy();
}
catch(CORBA::SystemException&)
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
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();
char* machineName();
void ping();
- // Kill current container
+ //! Kill current container
bool Kill_impl() ;
+
char* getHostName();
long getPID();
std::map<std::string, void *> remove_map ;
omni_mutex _numInstanceMutex ; // if several threads on the same object
- //private:
+private:
int _argc ;
char** _argv ;
// File : SALOME_DataTypeCatalog_Client.cxx
// Module : SALOME
+using namespace std;
/* $Header$ */
-#include <iostream>
+#include <iostream.h>
#include "SALOME_NamingService.hxx"
#include "SALOME_DataTypeCatalog.hh"
#include <string>
#include "utilities.h"
-using namespace std;
int main(int argc,char **argv)
{
// Module : SALOME
// $Header$
+using namespace std;
#define WRITE_CATA_DATA_TYPE
#include "SALOME_DataTypeCatalog_Handler.hxx"
-using namespace std;
//----------------------------------------------------------------------
// Function : SALOME_DataTypeCatalog_Handler
// Module : SALOME
// $Header$
-#include <iostream>
+#include <iostream.h>
#include "SALOME_NamingService.hxx"
#include "SALOME_DataTypeCatalog_impl.hxx"
#include "utilities.h"
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOME_DataTypeCatalog_impl.hxx"
+#include "Utils_ExceptHandlers.hxx"
#include <fstream>
-using namespace std;
+
+UNEXPECT_CATCH(DTC_NotFound, SALOME_DataTypeCatalog::NotFound);
//----------------------------------------------------------------------
// Function : SALOME_DataTypeCatalogImpl
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;
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++)
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++)
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 =
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)
using namespace SALOME;
GenericObj_i::GenericObj_i(PortableServer::POA_ptr thePOA): myRefCounter(1){
- INFOS("GenericObj_i::GenericObj_i() - this = "<<this<<
+ MESSAGE("GenericObj_i::GenericObj_i() - this = "<<this<<
"; CORBA::is_nil(thePOA) = "<<CORBA::is_nil(thePOA));
if(CORBA::is_nil(thePOA))
myPOA = PortableServer::RefCountServantBase::_default_POA();
void GenericObj_i::Register(){
- INFOS("GenericObj_i::Register "<<this<<"; myRefCounter = "<<myRefCounter)
+ MESSAGE("GenericObj_i::Register "<<this<<"; myRefCounter = "<<myRefCounter)
++myRefCounter;
}
void GenericObj_i::Destroy(){
- INFOS("GenericObj_i::Destroy "<<this<<"; myRefCounter = "<<myRefCounter)
+ MESSAGE("GenericObj_i::Destroy "<<this<<"; myRefCounter = "<<myRefCounter)
if(--myRefCounter <= 0){
PortableServer::ObjectId_var anObjectId = myPOA->servant_to_id(this);
myPOA->deactivate_object(anObjectId.in());
+using namespace std;
// File : SALOMEDS_Tool.cxx
// Created : Mon Oct 21 16:24:34 2002
// Author : Sergey RUIN
#include <string.h>
#include <fcntl.h>
#include <stdio.h>
-using namespace std;
bool CreateAttributeFromASCII(HDFinternalObject *father, FILE* fp);
bool CreateDatasetFromASCII(HDFcontainerObject *father, FILE *fp);
// File : HDFattribute.cc
// Module : SALOME
+using namespace std;
extern "C"
{
#include "hdfi.h"
#include "HDFexception.hxx"
#include "HDFattribute.hxx"
#include "HDFinternalObject.hxx"
-using namespace std;
HDFattribute::HDFattribute(char *name,HDFinternalObject *father,hdf_type type, size_t size)
: HDFobject(name)
size_t HDFattribute::GetSize()
{
- int size;
if(_size == 0) {
- if((size = HDFattrGetSize(_id)) < 0)
+ if((_size = HDFattrGetSize(_id)) < 0)
throw HDFexception("Can't determine the size of data in the attribute");
- else
- _size = size;
}
return _size;
}
// File : HDFcontainerObject.cc
// Module : SALOME
+using namespace std;
extern "C"
{
#include "hdfi.h"
#include "HDFcontainerObject.hxx"
#include "HDFexception.hxx"
#include "utilities.h"
-using namespace std;
HDFcontainerObject::HDFcontainerObject(char *name)
: HDFinternalObject(name)
// File : HDFconvert.cc
// Module : SALOME
-#include "HDFconvert.hxx"
using namespace std;
+#include "HDFconvert.hxx"
int HDFConvert::FromAscii(const string& file, const HDFcontainerObject & hdf_container, const string& nomdataset)
{
#endif
// Creation du Dataset utilisateur
- hdf_dataset = new HDFdataset( (char *) nomdataset.c_str(), /*discard const */
- (HDFcontainerObject*) &hdf_container, /*discard const, pas de constructeur par référence */
- HDF_STRING,
- &length_long,1);
+ hdf_dataset = new HDFdataset::HDFdataset( (char *) nomdataset.c_str(), /*discard const */
+ (HDFcontainerObject*) &hdf_container, /*discard const, pas de constructeur par référence */
+ HDF_STRING,
+ &length_long,1);
// Cree le Dataset sur le disk
hdf_dataset->CreateOnDisk();
perror("HDFConvert::FromAscii");
return -1;
};
-
- return 0;
};
#include "HDFfile.hxx"
#include <string>
+using namespace std;
+
class HDFConvert
{
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);
};
// File : HDFdataset.cc
// Module : SALOME
+using namespace std;
extern "C"
{
#include "hdfi.h"
+#include <string.h>
}
-#include <string>
#include "HDFdataset.hxx"
#include "HDFcontainerObject.hxx"
#include "HDFexception.hxx"
-#include <iostream>
-using namespace std;
+#include <iostream.h>
herr_t dataset_attr(hid_t loc_id, const char *attr_name, void *operator_data)
{
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 ");
}
/* Exception */
#include <iostream>
+using namespace std;
+
class HDFexception
{
public :
HDFexception(const char *message) {
- std::cerr << message << std::endl;
+ cerr << message << endl;
}
};
// 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)
{
// File : HDFfile.cc
// Module : SALOME
+using namespace std;
extern "C"
{
#include "hdfi.h"
#include <unistd.h>
+#include <string.h>
}
-#include <string>
-#include <iostream>
+#include <iostream.h>
#include "HDFfile.hxx"
#include "HDFexception.hxx"
-using namespace std;
herr_t file_attr(hid_t loc_id, const char *attr_name, void *operator_data)
{
// File : HDFgroup.cc
// Module : SALOME
+using namespace std;
extern "C"
{
#include "hdfi.h"
+#include <string.h>
}
-#include <string>
#include "HDFgroup.hxx"
#include "HDFexception.hxx"
-using namespace std;
herr_t group_attr(hid_t loc_id, const char *attr_name, void *operator_data)
{
// 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)
// File : HDFobject.cc
// Module : SALOME
+using namespace std;
#include "HDFobject.hxx"
extern "C"
{
#include "hdfi.h"
+#include <string.h>
}
-#include <string>
#include "utilities.h"
-using namespace std;
HDFobject::HDFobject(char *name)
{
#-------------------------------------------------------------------------
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/"
// Module : SALOME
// $Header$
+using namespace std;
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
-using namespace std;
#include "OpUtil.hxx"
#include "utilities.h"
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 ) {
}
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 " ;
}
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 -" ;
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 ;
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 ;
}
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 = "" ;
}
}
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 ) ;
// Module : SALOME
// $Header$
+using namespace std;
#include "utilities.h"
#include <iostream>
#include <unistd.h>
#include "SALOME_NamingService.hxx"
#include "SALOME_LifeCycleCORBA.hxx"
#include <OpUtil.hxx>
-using namespace std;
int main (int argc, char * argv[])
{
// Module : SALOME
// $Header$
+using namespace std;
#include "InquireServersQThread.h"
#include <qlabel.h>
#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)
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);
int InquireServersGUI::getExitStatus()
{
myThread->getExitStatus();
- return 0;
}
InquireServersQThread::InquireServersQThread( InquireServersGUI* r )
// Module : SALOME
// $Header$
+using namespace std;
/*! \file SALOME_Session_loader.cxx
*/
#include "Utils_SINGLETON.hxx"
#include "SALOME_NamingService.hxx"
#include "utilities.h"
-using namespace std;
//! CORBA client for SALOME Session server : launch GUI
/*!
// Author : Vasily Rusyaev
// Module : SALOME
+using namespace std;
#include <iostream>
-
#include "SALOME_Logger_Server.hxx"
#include <SALOMEconfig.h>
#include <sys/types.h>
#include <unistd.h>
-using namespace std;
omni_mutex Logger::myLock;
/////////////////////////////////////////////////////////////////////
// Author : Vasily Rusyaev
// Module : SALOME
+using namespace std;
#include "SALOME_Trace.hxx"
#include <memory.h>
#include <string>
+//#include <stdio.h>
#include <stdlib.h>
#include <iostream>
-#include "SALOME_Trace.hxx"
-using namespace std;
-
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
# endif /* WNT */
-#include <strstream.h>
+using namespace std;
+#include <strstream.h>
#include "Logger.hh"
-using namespace std;
class SALOME_Trace : public ostrstream
{
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):
// File : MPIContainer_i.cxx
// Module : SALOME
+using namespace std;
#include <iostream.h>
#include <dlfcn.h>
#include <stdio.h>
#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_<SALOME_NamingService>::Instance() ;
ASSERT(SINGLETON_<SALOME_NamingService>::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
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,
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);
}
// 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;
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() ;
{
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<string, void *>::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()");
}
#define _SALOME_PCONTAINER_
#include <SALOMEconfig.h>
-#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
// File : MPIObject_i.cxx
// Module : SALOME
+using namespace std;
#include "MPIObject_i.hxx"
#include "utilities.h"
#include <mpi.h>
-using namespace std;
MPIObject_i::MPIObject_i()
{
}
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);
-
}
#define _SALOME_POBJECT_I_H_
#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SALOME_MPIObject)
+#include CORBA_SERVER_HEADER(MPIObject)
class MPIObject_i: public POA_Engines::MPIObject
{
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@
+// 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 <iostream>
#include "MPIContainer_i.hxx"
-#include "Utils_ORB_INIT.hxx"
-#include "Utils_SINGLETON.hxx"
#include "utilities.h"
#include <mpi.h>
-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_<ORB_INIT>::Instance() ;
- ASSERT(SINGLETON_<ORB_INIT>::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");
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]);
}
// File : msg2qm.cxx
// Module : SALOME
+using namespace std;
/****************************************************************************
** $Id$
**
#include <stdio.h>
#include <stdlib.h>
-using namespace std;
static QString* defaultScope = 0;
@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@
@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 !
BIN_SERVER_IDL = SALOME_ModuleCatalog.idl
CPPFLAGS+= $(QT_MT_INCLUDES)
-CXXFLAGS+= @CXXTMPDPTHFLAGS@
LDFLAGS+= $(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace
@CONCLUDE@
// Author : Estelle Deville
// Module : SALOME
// $Header$
+//
#ifndef PATH_PREFIX_H
#define PATH_PREFIX_H
struct PathPrefix
{
string path ;
- vector<string> ListOfComputer ;
+ vector<string> listOfComputer ;
} ;
typedef vector<PathPrefix> ListOfPathPrefix ;
// 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
// 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");
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
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");
}
//----------------------------------------------------------------------
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();
}
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;
}
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")
}
}
}
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();
}
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;
}
//----------------------------------------------------------------------
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]);
}
}
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;
}
//----------------------------------------------------------------------
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;
}
//----------------------------------------------------------------------
char* SALOME_ModuleCatalog_AcomponentImpl::constraint()
{
- return CORBA::string_dup(_constraint);
+ return CORBA::string_dup(_Component.constraint);
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
char* SALOME_ModuleCatalog_AcomponentImpl::componentname()
{
- return CORBA::string_dup(_component_name);
+ return CORBA::string_dup(_Component.name);
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
char* SALOME_ModuleCatalog_AcomponentImpl::componentusername()
{
- return CORBA::string_dup(_component_user_name);
+ return CORBA::string_dup(_Component.username);
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
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 ;
}
//----------------------------------------------------------------------
SALOME_ModuleCatalog::ComponentType
SALOME_ModuleCatalog_AcomponentImpl::component_type()
{
- return _componenttype;
+ return _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]);
+}
+
+
#define ACOMPONENT_IMPL_H
#include "utilities.h"
-#include "PathPrefix.hxx"
+#include "SALOME_ModuleCatalog_Parser.hxx"
#include <SALOMEconfig.h>
+
#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
class SALOME_ModuleCatalog_AcomponentImpl: public POA_SALOME_ModuleCatalog::Acomponent,
{
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();
//! 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
#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;
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);
exit (-1);
}
- MESSAGE("Component of name : " << Geom->componentname() << " created ");
- MESSAGE("Component type : " << Geom->component_type() << " multistudy : " <<Geom->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");
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 : " <<Superv->multistudy());
- MESSAGE("Component constraint : " << Superv->constraint());
- MESSAGE("Component icone : " << Superv->component_icone());
+ PrintComponent(Superv);
// obtain prefix path for a computer
char* path;
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 <second_service->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 <second_service->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 <second_service->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 <second_service->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 <service_1->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 <service_1->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")
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; i<n; i++)
+ {
+ MESSAGE(" Parameter "
+ << Service->ServiceinParameter[i].Parametername);
+ MESSAGE(" Type : "
+ << Service->ServiceinParameter[i].Parametertype);
+ }
+
+ MESSAGE("Out Parameter(s):");
+ n = Service->ServiceoutParameter.length();
+ for (i = 0; i<n; i++)
+ {
+ MESSAGE(" Parameter "
+ << Service->ServiceoutParameter[i].Parametername);
+ MESSAGE(" Type : "
+ << Service->ServiceoutParameter[i].Parametertype);
+ }
+
+ MESSAGE("In DataStreamParameter(s):");
+ n = Service->ServiceinDataStreamParameter.length();
+ for (i = 0; i<n; i++)
+ {
+ MESSAGE(" Parameter "
+ << Service->ServiceinDataStreamParameter[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; i<n; i++)
+ {
+ MESSAGE(" Parameter "
+ << Service->ServiceoutDataStreamParameter[i].Parametername);
+ MESSAGE(" Type : "
+ << Service->ServiceoutDataStreamParameter[i].Parametertype);
+ MESSAGE(" Dependency : "
+ << Service->ServiceoutDataStreamParameter[i].Parametertype);
+ }
+
-
-
-
+}
// 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 <sstream>
//----------------------------------------------------------------------
// Function : SALOME_ModuleCatalog_Handler
//----------------------------------------------------------------------
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");
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
SALOME_ModuleCatalog_Handler::~SALOME_ModuleCatalog_Handler()
{
- MESSAGE("SALOME_ModuleCatalog_Handler destruction")
+ BEGIN_OF("~SALOME_ModuleCatalog_Handler()")
+ END_OF("~SALOME_ModuleCatalog_Handler()")
}
//----------------------------------------------------------------------
{
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;
}
const QString& qName,
const QXmlAttributes& atts)
{
+ _xml_pile.push(qName);
+
return true;
}
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;
// Print all informations find in the catalog
// (only in DEBUG mode!!)
//----------------------------------------------------------------------
+#include <fstream>
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;
}
#include "SALOME_ModuleCatalog_Parser.hxx"
#include <qxml.h>
#include <string>
-#include <vector>
+#include <stack>
+#include <map>
class SALOME_ModuleCatalog_Handler : public QXmlDefaultHandler
{
//! 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
*/
//! 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
*/
//! 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);
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<QString> _xml_pile;
};
#endif // SALOME_CATALOG_HANDLER_H
// Author : Estelle Deville
// Module : SALOME
// $Header$
-
+//
#ifndef SALOME_CATALOG_PARSER_H
#define SALOME_CATALOG_PARSER_H
// Type Definitions
struct ParserPathPrefix
{
- string path;
- vector<string> ListOfComputer ;
+ std::string path;
+ std::vector<std::string> listOfComputer ;
};
-typedef vector<ParserPathPrefix> ListOfParserPathPrefix ;
+typedef std::vector<ParserPathPrefix> 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<ParserServParam> ListOfParserServicesParameter;
+
+struct ParserDataStreamParameter
+{
+ std::string type;
+ std::string name;
+ std::string dependency;
+} ;
+
+typedef std::vector<ParserParameter> ParserParameters;
+typedef std::vector<ParserDataStreamParameter> 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<ParserService> ListOfParserServices ;
+typedef std::vector<ParserService> ParserServices ;
-struct ParserDefInterface
+struct ParserInterface
{
- string Parserinterfacename ;
- ListOfParserServices Parserinterfaceservicelist ;
+ std::string name ;
+ ParserServices services ;
} ;
-typedef vector<ParserDefInterface> ListOfDefinitionInterface;
+typedef std::vector<ParserInterface> 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<ParserComponent> ListOfParserComponent ;
+typedef std::vector<ParserComponent> 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
--- /dev/null
+
+// 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 <string>
+#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<n; i++)
+ f << S.inParameters[i] << std::endl;
+ if (n == 0) f << std::endl;
+
+ n = S.inDataStreamParameters.size();
+ f << " in DataStream parameters : " << n << std::endl;
+ for (i=0; i<n; i++)
+ f << S.inDataStreamParameters[i] << std::endl;
+ if (n == 0) f << std::endl;
+
+ n = S.outParameters.size();
+ f << " out parameters : " << n << std::endl;
+ for (i=0; i<n; i++)
+ f << S.outParameters[i] << std::endl;
+ if (n == 0) f << std::endl;
+
+ n = S.outDataStreamParameters.size();
+ f << " out DataStream parameters : " << n << std::endl;
+ for (i=0; i<n; i++)
+ f << S.outDataStreamParameters[i] << std::endl;
+ if (n == 0) f << std::endl;
+
+ return f;
+}
+
+std::ostream & operator<< (std::ostream & f,
+ const ParserInterface & I)
+{
+ int j, n;
+ f << " name : " << I.name << std::endl;
+
+ n = I.services.size();
+ f << " services : " << n << std::endl;
+ for (j=0; j<n; j++) {
+ MESSAGE(I.services[j].name);
+ f << I.services[j] << std::endl;
+ }
+
+ return f;
+}
+
+std::ostream & operator<< (std::ostream & f,
+ const ParserComponentType & T)
+{
+ std::string s;
+ switch (T) {
+ case GEOM : s = "GEOM"; break;
+ case MESH : s = "MESH"; break;
+ case Med : s = "Med"; break;
+ case SOLVER : s = "SOLVER"; break;
+ case DATA : s = "DATA"; break;
+ case VISU : s = "VISU"; break;
+ case SUPERV : s = "SUPERV"; break;
+ default : s = "OTHER"; break;
+ }
+ f << s << std::endl;
+ return f;
+}
+
+std::ostream & operator<< (std::ostream & f,
+ const ParserComponent & C)
+{
+ int j, n;
+ f << std::endl
+ << " name : " << C.name << std::endl;
+ f << " user name : " << C.username << std::endl;
+ f << " type : " << C.type << std::endl;
+ f << " multistudy : " << (C.multistudy ? "yes" : "no")
+ << std::endl;
+ f << " icon : " << C.icon << std::endl;
+ f << " constraint : " << C.constraint << std::endl;
+
+ n = C.interfaces.size();
+ f << " interfaces : " << n << std::endl;
+ for (j=0; j<n; j++)
+ f << C.interfaces[j] << std::endl;
+ if (n == 0) f << std::endl;
+
+ return f;
+}
+
+
--- /dev/null
+
+// 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.hxx
+// Author : Marc Tajchman
+// Module : SALOME
+// $Header$
+
+#ifndef SALOME_CATALOG_PARSER_IO_H
+#define SALOME_CATALOG_PARSER_IO_H
+
+#include "SALOME_ModuleCatalog_Parser.hxx"
+#include <iostream>
+
+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
+
//
// File : SALOME_ModuleCatalog_Server.cxx
// Module : SALOME
-
/* $Header$ */
+
#include <iostream>
#include "SALOME_NamingService.hxx"
#include "SALOME_ModuleCatalog_impl.hxx"
}
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) ;
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;
}
// 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;
#endif
orb->run();
+ mgr->deactivate(true,true);
poa->destroy(1,1);
-
+
}
catch(CORBA::SystemException&) {
INFOS("Caught CORBA::SystemException.")
// Author : Estelle Deville
// Module : SALOME
// $Header$
-
+//
#include "SALOME_ModuleCatalog_impl.hxx"
#include "SALOME_ModuleCatalog_Acomponent_impl.hxx"
#include <fstream>
+#include <map>
#include <qstringlist.h>
#include <qfileinfo.h>
// 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);
// 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");
}
}
// Function : GetPathPrefix
// Purpose : get the PathPrefix of a computer
//----------------------------------------------------------------------
-char*
+char *
SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) {
MESSAGE("Begin of GetPathPrefix")
// Variables initialisation
// 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
{
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
// 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]) ;
}
{
// 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" )
// 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);
}
{
// 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() ;
// 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++;
}
{
_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") ;
}
}
// 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
// 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;
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
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);
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<modulelist.size(); j++) {
+ if (modulelist[j].name == _moduleList[i].name)
+ break;
+ }
+ if (j < modulelist.size())
+ modulelist[j] = _moduleList[i];
+ else
+ modulelist.push_back(_moduleList[i]);
+ }
+
+ for ( i=0; i < _pathList.size(); i++)
+ pathList.push_back(_pathList[i]) ;
+
+ for (j=0; j<modulelist.size(); j++)
+ modulelist[j].prefixes = pathList;
}
+void
+SALOME_ModuleCatalogImpl::ImportXmlCatalogFile(const char* file)
+{
+ _parse_xml_file(file, _personal_module_list, _personal_path_list);
+}
+
+
+//
+// Duplicate functions create a Corba structure (component,
+// interface, service, parameter) from the corresponding C++
+// parser structure
+//
+
//----------------------------------------------------------------------
-// Function : duplicate_interfaces
-// Purpose : create a list of interfaces from the parsing of the catalog
+// Function : duplicate
+// Purpose : create a component from the catalog parsing
//----------------------------------------------------------------------
-SALOME_ModuleCatalog::ListOfDefInterface
-SALOME_ModuleCatalogImpl::duplicate_interfaces(ListOfDefinitionInterface list_interface)
+void SALOME_ModuleCatalogImpl::duplicate
+(SALOME_ModuleCatalog::Component & C_corba,
+ const ParserComponent & C_parser)
{
- SALOME_ModuleCatalog::ListOfDefInterface _list_interfaces;
- unsigned int _length_interfaces = list_interface.size();
- _list_interfaces.length(_length_interfaces);
+ C_corba.name = CORBA::string_dup(C_parser.name.c_str());
+ C_corba.username = CORBA::string_dup(C_parser.username.c_str());
+ C_corba.multistudy = C_parser.multistudy;
+ C_corba.icon = CORBA::string_dup(C_parser.icon.c_str());
+ C_corba.type = ComponentTypeConvert[C_parser.type];
+ C_corba.implementationType = C_parser.implementationType;
+
+ unsigned int _length = C_parser.interfaces.size();
+ C_corba.interfaces.length(_length);
- for (unsigned int ind = 0; ind < _length_interfaces; ind++)
- {
- //duplicate interface name
- _list_interfaces[ind].interfacename = CORBA::string_dup(list_interface[ind].Parserinterfacename.c_str());
+ for (unsigned int ind = 0; ind < _length; ind++)
+ duplicate(C_corba.interfaces[ind], C_parser.interfaces[ind]);
+}
- // duplicate service list
- unsigned int _length_services = list_interface[ind].Parserinterfaceservicelist.size();
- _list_interfaces[ind].interfaceservicelist.length(_length_services);
- for (unsigned int ind1 = 0; ind1 < _length_services ; ind1 ++)
- {
- // duplicate service name
- _list_interfaces[ind].interfaceservicelist[ind1].ServiceName =
- CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceName.c_str());
-
- // duplicate service by default
- _list_interfaces[ind].interfaceservicelist[ind1].Servicebydefault =
- list_interface[ind].Parserinterfaceservicelist[ind1].ParserServicebydefault;
-
- // duplicate in Parameters
- unsigned int _length_in_param = list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceinParameter.size();
- _list_interfaces[ind].interfaceservicelist[ind1].ServiceinParameter.length(_length_in_param);
- for (unsigned int ind2 = 0; ind2 < _length_in_param ; ind2 ++)
- {
- // duplicate parameter type
- _list_interfaces[ind].interfaceservicelist[ind1].ServiceinParameter[ind2].Parametertype = CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceinParameter[ind2].ParserParamtype.c_str());
-
- // duplicate parameter name
- _list_interfaces[ind].interfaceservicelist[ind1].ServiceinParameter[ind2].Parametername = CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceinParameter[ind2].ParserParamname.c_str());
- }
+//----------------------------------------------------------------------
+// Function : duplicate
+// Purpose : create an interface from the catalog parsing
+//----------------------------------------------------------------------
+void SALOME_ModuleCatalogImpl::duplicate
+(SALOME_ModuleCatalog::DefinitionInterface & I_corba,
+ const ParserInterface & I_parser)
+{
+ //duplicate interface name
+ I_corba.interfacename = CORBA::string_dup(I_parser.name.c_str());
+
+ // duplicate service list
+ unsigned int _length = I_parser.services.size();
+ SCRUTE(_length);
+ // I_corba.interfaceservicelist
+ // = new SALOME_ModuleCatalog::ListOfInterfaceService;
+ I_corba.interfaceservicelist.length(_length);
+
+ for (unsigned int ind1 = 0; ind1 < _length ; ind1 ++)
+ duplicate(I_corba.interfaceservicelist[ind1],
+ I_parser.services[ind1]);
+}
- // duplicate out Parameters
- unsigned int _length_out_param = list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceoutParameter.size();
- _list_interfaces[ind].interfaceservicelist[ind1].ServiceoutParameter.length(_length_out_param);
- for (unsigned int ind2 = 0; ind2 < _length_out_param ; ind2 ++)
- {
- // duplicate parameter type
- _list_interfaces[ind].interfaceservicelist[ind1].ServiceoutParameter[ind2].Parametertype = CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceoutParameter[ind2].ParserParamtype.c_str());
-
- // duplicate parameter name
- _list_interfaces[ind].interfaceservicelist[ind1].ServiceoutParameter[ind2].Parametername = CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceoutParameter[ind2].ParserParamname.c_str());
- }
-
- }
- }
- return _list_interfaces;
+//----------------------------------------------------------------------
+// Function : duplicate
+// Purpose : create a service from the catalog parsing
+//----------------------------------------------------------------------
+void SALOME_ModuleCatalogImpl::duplicate
+(SALOME_ModuleCatalog::Service & S_corba,
+ const ParserService & S_parser)
+{
+ // duplicate service name
+ S_corba.ServiceName = CORBA::string_dup(S_parser.name.c_str());
+
+ // duplicate service by default
+ S_corba.Servicebydefault = S_parser.byDefault;
+
+ S_corba.TypeOfNode = S_parser.typeOfNode;
+
+ unsigned int _length;
+
+ // duplicate in Parameters
+ _length = S_parser.inParameters.size();
+ S_corba.ServiceinParameter.length(_length);
+
+ for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
+ duplicate(S_corba.ServiceinParameter[ind2],
+ S_parser.inParameters[ind2]);
+
+ // duplicate out Parameters
+ _length = S_parser.outParameters.size();
+ S_corba.ServiceoutParameter.length(_length);
+
+ for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
+ duplicate(S_corba.ServiceoutParameter[ind2],
+ S_parser.outParameters[ind2]);
+
+ // duplicate in DataStreamParameters
+ _length = S_parser.inDataStreamParameters.size();
+ S_corba.ServiceinDataStreamParameter.length(_length);
+
+ for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
+ duplicate(S_corba.ServiceinDataStreamParameter[ind2],
+ S_parser.inDataStreamParameters[ind2]);
+
+ // duplicate out DataStreamParameters
+ _length = S_parser.outDataStreamParameters.size();
+ SCRUTE(_length);
+ S_corba.ServiceoutDataStreamParameter.length(_length);
+
+ for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
+ duplicate(S_corba.ServiceoutDataStreamParameter[ind2],
+ S_parser.outDataStreamParameters[ind2]);
+}
+
+//----------------------------------------------------------------------
+// Function : duplicate
+// Purpose : create a service parameter from the catalog parsing
+//----------------------------------------------------------------------
+void SALOME_ModuleCatalogImpl::duplicate
+(SALOME_ModuleCatalog::ServicesParameter & P_corba,
+ const ParserParameter & P_parser)
+{
+ // duplicate parameter name
+ P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
+
+ // duplicate parameter type
+ P_corba.Parametertype = CORBA::string_dup(P_parser.type.c_str());
}
//----------------------------------------------------------------------
-// Function : duplicate_pathes
-// Purpose : create the path prefix structures from the catalog parsing
+// Function : duplicate
+// Purpose : create a service datastream parameter from the catalog parsing
//----------------------------------------------------------------------
-ListOfPathPrefix
-SALOME_ModuleCatalogImpl::duplicate_pathes(ListOfParserPathPrefix pathes)
+void SALOME_ModuleCatalogImpl::duplicate
+(SALOME_ModuleCatalog::ServicesDataStreamParameter & P_corba,
+ const ParserDataStreamParameter & P_parser)
{
- ListOfPathPrefix _pathes ;
+ std::map < std::string,
+ SALOME_ModuleCatalog::DataStreamType >::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;
}
// particular computer
//----------------------------------------------------------------------
bool
-SALOME_ModuleCatalogImpl::_verify_path_prefix(ListOfParserPathPrefix pathlist)
+SALOME_ModuleCatalogImpl::_verify_path_prefix(ParserPathPrefixes & pathList)
{
bool _return_value = true;
vector<string> _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]);
}
}
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)
{
// 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;
- }
-*/
}
}
}
// Module : SALOME
// $Header$
+
#ifndef MODULECATALOG_IMPL_H
#define MODULECATALOG_IMPL_H
#include "utilities.h"
+#include <string>
+#include <map>
+
#include "SALOME_ModuleCatalog_Handler.hxx"
-#include "PathPrefix.hxx"
+
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOME_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();
*/
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
*/
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
// 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 <std::string, SALOME_ModuleCatalog::DataStreamType>
+ DataStreamTypeConvert;
+
+ std::map <std::string, SALOME_ModuleCatalog::DataStreamDependency>
+ DataStreamDepConvert;
+
+ std::map <ParserComponentType, SALOME_ModuleCatalog::ComponentType>
+ ComponentTypeConvert;
+ CORBA::ORB_ptr _orb;
};
#endif // MODULECATALOG_IMPL_H
--- /dev/null
+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
+
"COMP_TYPE" : "",
"COMP_NAME" : "",
"COMP_UNAME" : "",
- "COMP_MULT" : ""
+ "COMP_MULT" : "",
+ "COMP_IMPL" : ""
}
nb_components = 0
#--------------------------------------------------
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:
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
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):
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):
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
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
#--------------------------------------------------
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)
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 = <inParameter>
- n_ext = i_ext.getChild('inParameter-name')
- if n_ext is None: continue
- present = 0
-
- for i_int in L_int.childs:
- # i_int = <inParameter>
- 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 = <outParameter>
- 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)
#--------------------------------------------------
def __init__(self, name=None, comment='unknown'):
- Tree.__init__(self)
+ Tree.__init__(self, key=name)
if name is None: return
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"])
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:
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
def startElement(self, name, attrs):
p = self.list[len(self.list)-1]
-
if name == 'component':
e = p.addChild(Component())
elif name == 'component-interface-name':
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)
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
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)
n.accept(self)
def visitInterface(self, node):
+
if node.mainFile():
self.EngineType = 0
if ((s[0] == "Engines") & (s[1] == "Component")):
self.EngineType = 1; break
- Comp = Component()
+ Comp = Component(node.identifier())
self.currentInterface = Comp.createInterface(node.identifier())
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)
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):
# 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'
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
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)
print
print "Usage : omniidl -bIDLparser [-I<catalog files directory>]* -Wbcatalog=<my_catalog.xml>[,icon=<pngfile>][,version=<num>][,author=<name>][,name=<component_name>][,username=<component_username>][,multistudy=<component_multistudy>] <file.idl>"
print
+
+
Les scripts de test se trouvent dans le repertoire
- <SALOME_ROOT>/SALOME/src/ModuleGenerator/tests
+ <KERNEL_SRC>/src/ModuleGenerator/tests
Les fichiers idl servant aux tests se trouvent dans les repertoires
- <SALOME_ROOT>/idl
- <SALOME_ROOT>/SALOME/src/ModuleGenerator/tests
+ <KERNEL_SRC>/idl
+ <KERNEL_SRC>/src/ModuleGenerator/tests
// Author : Francis KLOSS
// Module : SALOME
-#include "NOTIFICATION_Swig.hxx"
using namespace std;
+#include "NOTIFICATION_Swig.hxx"
// Swig notification supplier
// --------------------------
// Author : Francis KLOSS
// Module : SALOME
-#include "NOTIFICATION.hxx"
using namespace std;
+#include "NOTIFICATION.hxx"
class NOTIFICATION_Supplier_Swig {
public:
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOME_NamingService.hxx"
#include "ServiceUnreachable.hxx"
#include <iostream>
#include <cstring>
-using namespace std;
//----------------------------------------------------------------------
/*! Function : SALOME_NamingService
_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");
}
}
}
_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");
}
}
}
_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();
}
}
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();
}
}
catch (ServiceUnreachable&)
{
- MESSAGE( "!!!list(): ServiceUnreachable" )
+ INFOS( "!!!list(): ServiceUnreachable" )
throw ServiceUnreachable();
}
{
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();
}
{
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();
}
{
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();
}
{
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();
}
}
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();
}
{
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();
}
#define SALOME_NAMINGSERVICE_H
#include "utilities.h"
-//#include <omniORB4/CORBA.h>
-//##include <omniORB3/CORBA.h>
#include <CORBA.h>
#include <vector>
#include <string>
// File : ServiceUnreachable.cxx
// Module : SALOME
+using namespace std;
#include "ServiceUnreachable.hxx"
ServiceUnreachable::ServiceUnreachable( void ): SALOME_Exception( "ServiceUnreachable" )
// 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_<ORB_INIT>::Instance(); ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
// Author : Laurent DADA / Francis KLOSS
// Module : SALOME
-#include "NOTIFICATION.hxx"
using namespace std;
+#include "NOTIFICATION.hxx"
NOTIFICATION_Consumer::NOTIFICATION_Consumer():
proxy_supplier(0),
// Author : Laurent DADA / Francis KLOSS
// Module : SALOME
-#include "NOTIFICATION.hxx"
using namespace std;
+#include "NOTIFICATION.hxx"
long NOTIFICATION_Supplier::_stamp = 0;
// Module : SALOME
// $Header$
-#include "SALOME_AISObject.ixx"
using namespace std;
+#include "SALOME_AISObject.ixx"
// 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) {
}
#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"
#include <vtkObjectFactory.h>
#include <vtkDataSetMapper.h>
#include <vtkPolyDataMapper.h>
-#include <vtkTransformPolyDataFilter.h>
-
-// For test
-#include <vtkMapperCollection.h>
-#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<vtkDataSetMapper*>(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<vtkPolyDataMapper*>(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();
}
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;
}
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<int> 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;
}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// SALOME Includes
#include "VTKViewer_Common.h"
#include "SALOME_InteractiveObject.hxx"
-#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
-#include "Handle_SALOME_InteractiveObject.hxx"
-#endif
+
#include <vector>
class SALOME_Transform;
+class SALOME_GeometryFilter;
class SALOME_TransformFilter;
class SALOME_PassThroughFilter;
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; }
virtual void AddToRender(vtkRenderer* theRenderer);
virtual void RemoveFromRender(vtkRenderer* theRenderer);
- virtual vtkPolyData* GetPolyDataInput();
+ typedef std::vector<int> 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);
// 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<SALOME_PassThroughFilter*> myPassFilter;
+ bool myStoreMapping;
+ SALOME_GeometryFilter *myGeomFilter;
SALOME_TransformFilter *myTransformFilter;
- vtkProperty *myProperty;
+ std::vector<SALOME_PassThroughFilter*> myPassFilter;
+
int myRepresentation;
+ vtkProperty *myProperty;
};
#endif // SALOME_ACTOR_H
// Module : SALOME
// $Header$
+using namespace std;
/*!
\class SALOME_InteractiveObject SALOME_InteractiveObject.hxx
\brief ...
*/
#include "SALOME_InteractiveObject.ixx"
-using namespace std;
SALOME_InteractiveObject::SALOME_InteractiveObject()
{
// Module : SALOME
// $Header$
+using namespace std;
#include "OCCViewer.h"
#include "OCCViewer_ViewFrame.h"
-using namespace std;
QAD_ViewFrame* OCCViewer::createView(QAD_RightFrame* parent)
{
// Module : SALOME
// $Header$
+using namespace std;
/*!
\class OCCViewer_AISSelector OCCViewer_AISSelector.h
\brief Selector for AIS interactive context.
*/
#include "OCCViewer_AISSelector.h"
-using namespace std;
/*!
Constructor
// 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
// Module : SALOME
// $Header$
+using namespace std;
#include "OCCViewer_VService.h"
// Open CASCADE Includes
#include <Xdps_Driver.hxx>
#include <Xw_TypeOfMapping.hxx>
#endif
-using namespace std;
// For 2d
#define LOPTIM
// Module : SALOME
// $Header$
+using namespace std;
#include "OCCViewer_ViewFrame.h"
#include "OCCViewer_Viewer3d.h"
#include "OCCViewer_ViewPort.h"
#include <V3d_View.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <Visual3d_View.hxx>
-using namespace std;
/*!
Constructor
#include "OCCViewer_ViewPort.h"
#include "QAD_ViewFrame.h"
+#include "SALOME_Selection.h"
class OCCViewer_Viewer3d;
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* );
// Module : SALOME
// $Header$
+using namespace std;
#include <stdlib.h>
#if !defined WNT
#include <qpixmap.h>
#include <qintdict.h>
-using namespace std;
/* XPM */
const char* imageZoomCursor[] = {
// Module : SALOME
// $Header$
+using namespace std;
#include "OCCViewer_ViewPort3d.h"
#include "QAD.h"
#if !defined WNT
#include <Xw.hxx>
#endif
-using namespace std;
/*!
Constructor
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();
}
}
// Module : SALOME
// $Header$
+using namespace std;
/*!
\class OCCViewer_Viewer3d OCCViewer_Viewer3d.h
\brief Open CASCADE Viewer 3D with viewport 3D and selection.
#include <Geom_Axis2Placement.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
-using namespace std;
/*!
Constructor
// File : qsplitterP.cxx
// Module : SALOME
+using namespace std;
/****************************************************************************
** $Id$
**
#include <qobjectlist.h>
#include <qapplication.h> //sendPostedEvents
-using namespace std;
#define SPLITTER_ICON_WIDTH 10
#define SPLITTER_ICON_HEIGHT 12
// Module : SALOME
// $Header$
+using namespace std;
#include "qworkspaceP.h"
#include <qapplication.h>
#include <private/qapplication_p.h>
#include <private/qinternal_p.h>
-using namespace std;
#define BUTTON_WIDTH 16
#define BUTTON_HEIGHT 14
// Module : SALOME
// $Header$
+using namespace std;
#include "Plot2d_Curve.h"
#include "utilities.h"
-using namespace std;
/*!
Constructor
// Module : SALOME
// $Header$
-#include "Plot2d_CurveContainer.h"
using namespace std;
+#include "Plot2d_CurveContainer.h"
/*!
Constructor
#include <qtoolbar.h>
#include <qtoolbutton.h>
#include <qcursor.h>
+#include <qcolordialog.h>
#include <qwt_math.h>
#include <qwt_plot_canvas.h>
#include <stdlib.h>
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
// settings
myPopup->insertSeparator();
myActions[ SettingsId ]->addTo( myPopup );
+ // Change background
+ myPopup->insertSeparator();
+ myActions[ ChangeBackgroundId ]->addTo( myPopup );
}
}
/*!
*/
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("<<i<<") = "<<majXmark<<" "<<xmark<<" "<<pnt.x());
+ break;
+ }
+ }
+ if ( !xFound ) {
+ for ( int i = 0; i < aXscale->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("<<i<<") = "<<minXmark<<" "<<xmark<<" "<<pnt.x());
+ break;
+ }
+ }
+ }
+ const QwtScaleDiv* aYscale = myPlot->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;
}
/*!
}
delete dlg;
}
+/*!
+ Change background color
+*/
+void Plot2d_ViewFrame::onChangeBackground()
+{
+ QColor selColor = QColorDialog::getColor ( backgroundColor(), this );
+ if ( selColor.isValid() ) {
+ setBackgroundColor( selColor );
+ }
+}
/*!
Sets curve type
*/
#include "QAD_Action.h"
#include "Plot2d_Curve.h"
#include "Plot2d_CurveContainer.h"
+#include "SALOME_Selection.h"
#include <qmainwindow.h>
#include <qmap.h>
#include <qintdict.h>
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 = "" );
/* inherited */
ViewType getTypeView() const { return VIEW_PLOT2D; }
QWidget* getViewWidget();
- void SetSelectionMode( int mode ) {}
+ void SetSelectionMode( Selection_Mode mode ) {}
void onAdjustTrihedron( ) {}
/* popup management */
void onCurves();
void onSettings();
void onFitData();
+ void onChangeBackground();
protected slots:
void onLegendClicked( long key );
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
// Module : SALOME
// $Header$
+using namespace std;
+using namespace std;
# include "Utils_ORB_INIT.hxx"
# include "RegistryConnexion.hxx"
# include "SALOME_NamingService.hxx"
// Module : SALOME
// $Header$
+using namespace std;
+using namespace std;
# include "RegistryService.hxx"
# include "OpUtil.hxx"
# include "utilities.h"
-using namespace std;
extern "C"
{
# include <map>
+using namespace std;
class RegistryService : public POA_Registry::Components //, public PortableServer::RefCountServantBase
{
const char *_SessionName ;
int _Compteur ;
- std::map<int,client_infos *> _reg ;
- std::map<int,client_infos *> _fin ;
+ map<int,client_infos *> _reg ;
+ map<int,client_infos *> _fin ;
- Registry::AllInfos* makeseq(std::map<int,client_infos *> &mymap );
+ Registry::AllInfos* makeseq(map<int,client_infos *> &mymap );
} ;
// Module : SALOME
// $Header$
-# include <stdlib.h>
-# include <iostream>
-# include <fstream>
+#include <stdlib.h>
+#include <iostream.h>
+#include <fstream.h>
extern "C"
{
#endif
using namespace std;
-//#define CHECKTIME
-#ifdef CHECKTIME
-#include <Utils_Timer.hxx>
-#endif
-
int main( int argc , char **argv )
{
BEGIN_OF( argv[0] )
// Module : SALOME
// $Header$
+using namespace std;
# include "HelpWindow.hxx"
# include "utilities.h"
# include <qpushbutton.h>
# include <qtextstream.h>
# include <qfile.h>
-using namespace std;
HelpWindow::HelpWindow(QWidget* parent, const char* name )
: QMainWindow( parent, name, WType_TopLevel | WDestructiveClose )
// Module : SALOME
// $Header$
+using namespace std;
# include <qpushbutton.h>
# include <qlistview.h>
# include <qtabwidget.h>
# include "RegWidget.hxx"
# include "HelpWindow.hxx"
# include "IntervalWindow.hxx"
-using namespace std;
typedef int PIXELS;
RegWidget* RegWidget::myRegWidgetPtr = 0;
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() ) {
// Module : SALOME
// $Header$
+using namespace std;
# include "RegWidget.hxx"
# include "utilities.h"
-using namespace std;
extern "C"
{
// File : SALOME_RessourcesCatalog_Client.cxx
// Module : SALOME
+using namespace std;
/* $Header$ */
-#include <iostream>
+#include <iostream.h>
#include "SALOME_NamingService.hxx"
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOME_RessourcesCatalog)
#include <string>
#include "utilities.h"
-using namespace std;
int main(int argc,char **argv)
{
// Module : SALOME
//$Header$
+using namespace std;
#define WRITE_RESSOURCES_TYPE
#include "SALOME_RessourcesCatalog_Handler.hxx"
-using namespace std;
//----------------------------------------------------------------------
//Function : SALOME_RessourcesCatalog_Handler
}
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))
{
}
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))
{
// Author : Estelle Deville
// Module : SALOME
+using namespace std;
#include "SALOME_RessourcesCatalog_impl.hxx"
#include <fstream>
-using namespace std;
+
+#include "Utils_ExceptHandlers.hxx"
+UNEXPECT_CATCH(RC_NotFound, SALOME_RessourcesCatalog::NotFound);
//----------------------------------------------------------------------
// Function : SALOME_RessourcesCatalogImpl
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;
throw(SALOME_RessourcesCatalog::NotFound)
{
MESSAGE("Begin of GetComputerInfo");
+ Unexpect aCatch(RC_NotFound);
SALOME_RessourcesCatalog::computer_info_var _computer_info =
new SALOME_RessourcesCatalog::computer_info;
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)
// File : Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef _Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile
#define _Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile
// File : Handle_SALOMEDS_LocalIDAttribute.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef _Handle_SALOMEDS_LocalIDAttribute_HeaderFile
#define _Handle_SALOMEDS_LocalIDAttribute_HeaderFile
// File : Handle_SALOMEDS_TargetAttribute.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef _Handle_SALOMEDS_TargetAttribute_HeaderFile
#define _Handle_SALOMEDS_TargetAttribute_HeaderFile
@COMMENCE@
+EXPORT_HEADERS= \
+ SALOMEDS_StudyManager_i.hxx \
+ SALOMEDS_OCAFApplication.hxx \
+ Handle_SALOMEDS_OCAFApplication.hxx
# Libraries targets
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEDS_AttributeComment_i.hxx"
#include <TCollection_ExtendedString.hxx>
#include "SALOMEDS_SObject_i.hxx"
-using namespace std;
char* SALOMEDS_AttributeComment_i::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);
+}
char* Value();
void SetValue(const char* value);
-
+
+ char* Store();
+ void Restore(const char*);
+
};
// 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);
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');
+}
~SALOMEDS_AttributeDrawable_i() {};
CORBA::Boolean IsDrawable();
void SetDrawable(CORBA::Boolean value);
+
+ char* Store();
+ void Restore(const char*);
+
};
// 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);
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');
+}
~SALOMEDS_AttributeExpandable_i() {};
CORBA::Boolean IsExpandable();
void SetExpandable(CORBA::Boolean value);
+
+ char* Store();
+ void Restore(const char*);
+
};
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEDS_AttributeExternalFileDef_i.hxx"
#include <TCollection_ExtendedString.hxx>
#include "SALOMEDS_SObject_i.hxx"
-using namespace std;
char* SALOMEDS_AttributeExternalFileDef_i::Value()
{
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEDS_AttributeFileType_i.hxx"
#include <TCollection_ExtendedString.hxx>
#include "SALOMEDS_SObject_i.hxx"
-using namespace std;
char* SALOMEDS_AttributeFileType_i::Value()
{
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEDS_AttributeIOR_i.hxx"
#include <TCollection_ExtendedString.hxx>
#include "SALOMEDS_SObject_i.hxx"
#include "SALOMEDS_Study_i.hxx"
-using namespace std;
char* SALOMEDS_AttributeIOR_i::Value()
{
// 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() {
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);
+}
CORBA::Long Value();
void SetValue(CORBA::Long value);
+
+ char* Store();
+ void Restore(const char*);
+
};
// 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();
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);
+}
~SALOMEDS_AttributeLocalID_i() {};
CORBA::Long Value();
void SetValue(CORBA::Long value);
+
+ char* Store();
+ void Restore(const char*);
+
};
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEDS_AttributeName_i.hxx"
#include <TCollection_ExtendedString.hxx>
#include "SALOMEDS_SObject_i.hxx"
-using namespace std;
char* SALOMEDS_AttributeName_i::Value() {
TCollection_ExtendedString S = Handle(TDataStd_Name)::DownCast(_myAttr)->Get();
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);
+}
char* Value();
void SetValue(const char* value);
+
+ char* Store();
+ void Restore(const char*);
+
};
// 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);
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');
+}
~SALOMEDS_AttributeOpened_i() {};
CORBA::Boolean IsOpened();
void SetOpened(CORBA::Boolean value);
+
+ char* Store();
+ void Restore(const char*);
+
};
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEDS_AttributePersistentRef_i.hxx"
#include <TCollection_ExtendedString.hxx>
#include "SALOMEDS_SObject_i.hxx"
-using namespace std;
char* SALOMEDS_AttributePersistentRef_i::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);
+}
// File : SALOMEDS_AttributePersistentRef_i.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef SALOMEDS_AttributePersistentRef_i_HeaderFile
#define SALOMEDS_AttributePersistentRef_i_HeaderFile
char* Value();
void SetValue(const char* value);
+
+ char* Store();
+ void Restore(const char*);
};
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEDS_AttributePixMap_i.hxx"
#include "SALOMEDS_SObject_i.hxx"
#include <TCollection_AsciiString.hxx>
-using namespace std;
CORBA::Boolean SALOMEDS_AttributePixMap_i::HasPixMap() {
TCollection_ExtendedString S = Handle(SALOMEDS_PixMapAttribute)::DownCast(_myAttr)->Get();
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);
+}
// File : SALOMEDS_AttributePixMap_i.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef SALOMEDS_AttributePixMap_i_HeaderFile
#define SALOMEDS_AttributePixMap_i_HeaderFile
CORBA::Boolean HasPixMap();
char* GetPixMap();
void SetPixMap(const char* value);
+
+ char* Store();
+ void Restore(const char*);
+
};
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEDS_AttributePythonObject_i.hxx"
#include <TCollection_ExtendedString.hxx>
#include <TColStd_HArray1OfCharacter.hxx>
#include "SALOMEDS_SObject_i.hxx"
-using namespace std;
void SALOMEDS_AttributePythonObject_i::SetObject(const char* theSequence, CORBA::Boolean IsScript) {
CheckLocked();
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');
+}
virtual char* GetObject();
virtual CORBA::Boolean IsScript();
+ virtual char* Store();
+ virtual void Restore(const char*);
+
};
// 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();
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);
+}
// File : SALOMEDS_AttributeReal_i.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef SALOMEDS_AttributeReal_i_HeaderFile
#define SALOMEDS_AttributeReal_i_HeaderFile
CORBA::Double Value();
void SetValue(CORBA::Double value);
+
+ char* Store();
+ void Restore(const char*);
+
};
// 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);
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');
+}
~SALOMEDS_AttributeSelectable_i() {};
CORBA::Boolean IsSelectable();
void SetSelectable(CORBA::Boolean value);
+
+ char* Store();
+ void Restore(const char*);
+
};
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEDS_AttributeSequenceOfInteger_i.hxx"
#include "SALOMEDS_SObject_i.hxx"
#include <TColStd_HSequenceOfInteger.hxx>
-using namespace std;
+
void SALOMEDS_AttributeSequenceOfInteger_i::Assign(const SALOMEDS::LongSeq& other)
{
{
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);
+}
void ChangeValue(CORBA::Long index, CORBA::Long value);
CORBA::Long Value(CORBA::Short index);
CORBA::Long Length();
+
+ char* Store();
+ void Restore(const char*);
+
};
#endif
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEDS_AttributeSequenceOfReal_i.hxx"
#include "SALOMEDS_SObject_i.hxx"
#include <TColStd_HSequenceOfReal.hxx>
-using namespace std;
void SALOMEDS_AttributeSequenceOfReal_i::Assign(const SALOMEDS::DoubleSeq& other)
{
{
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);
+}
void ChangeValue(CORBA::Long index, CORBA::Double value);
CORBA::Double Value(CORBA::Short index);
CORBA::Long Length();
+
+ char* Store();
+ void Restore(const char*);
};
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEDS_AttributeStudyProperties_i.hxx"
#include "SALOMEDS_SObject_i.hxx"
#include <TColStd_HSequenceOfExtendedString.hxx>
#include <TColStd_HSequenceOfInteger.hxx>
-using namespace std;
#define CREATION_MODE_NOTDEFINED 0
#define CREATION_MODE_SCRATCH 1
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() {
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,
(*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);
+}
SALOMEDS::LongSeq_out theMonths,
SALOMEDS::LongSeq_out theYears,
CORBA::Boolean theWithCreator);
+
+ char* Store();
+ void Restore(const char*);
+
};
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEDS_AttributeTableOfInteger_i.hxx"
#include "SALOMEDS_SObject_i.hxx"
#include <TColStd_HSequenceOfInteger.hxx>
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx>
+#include "Utils_ExceptHandlers.hxx"
+#include <stdexcept>
#include <strstream>
#include <string>
-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);
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();
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();
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();
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();
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();
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();
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);
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);
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();
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);
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);
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();
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);
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();
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);
+}
virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream);
virtual SALOMEDS::TMPFile* SaveToFile();
+
+ virtual char* Store();
+ virtual void Restore(const char*);
+
};
#endif
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEDS_AttributeTableOfReal_i.hxx"
#include "SALOMEDS_SObject_i.hxx"
#include <TColStd_HSequenceOfReal.hxx>
#include <strstream>
#include <string>
-using namespace std;
+
+#include "Utils_ExceptHandlers.hxx"
+UNEXPECT_CATCH(ATR_IncorrectIndex, SALOMEDS::AttributeTableOfReal::IncorrectIndex);
+UNEXPECT_CATCH(ATR_IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength);
#define SEPARATOR '\1'
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();
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();
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();
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();
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();
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();
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);
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);
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();
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);
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);
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();
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);
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();
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);
+}
virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream);
virtual SALOMEDS::TMPFile* SaveToFile();
+
+ virtual char* Store();
+ virtual void Restore(const char*);
+
};
#endif
// Author : Sergey Ruin
// Module : SALOME
+using namespace std;
#include <TCollection_ExtendedString.hxx>
#include <TCollection_AsciiString.hxx>
#include <strstream>
#include <string>
-using namespace std;
+
+#include "Utils_ExceptHandlers.hxx"
+UNEXPECT_CATCH(ATS_IncorrectIndex, SALOMEDS::AttributeTableOfString::IncorrectIndex);
+UNEXPECT_CATCH(ATS_IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectArgumentLength);
#define SEPARATOR '\1'
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();
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();
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();
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();
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();
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();
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);
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);
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();
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);
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);
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();
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);
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();
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);
+}
virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream);
virtual SALOMEDS::TMPFile* SaveToFile();
+
+ char* Store();
+ void Restore(const char*);
+
};
#endif
// 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 <TDF_LabelList.hxx>
#include <TDF_ListIteratorOfLabelList.hxx>
-using namespace std;
void SALOMEDS_AttributeTarget_i::Add(SALOMEDS::SObject_ptr anObject) {
TDF_Label aLabel;
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEDS_AttributeTextColor_i.hxx"
#include "SALOMEDS_SObject_i.hxx"
#include <TColStd_HArray1OfReal.hxx>
-using namespace std;
SALOMEDS::Color SALOMEDS_AttributeTextColor_i::TextColor() {
SALOMEDS::Color TextColor;
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);
+}
// File : SALOMEDS_AttributeTextColor_i.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef SALOMEDS_AttributeTextColor_i_HeaderFile
#define SALOMEDS_AttributeTextColor_i_HeaderFile
SALOMEDS::Color TextColor();
void SetTextColor(const SALOMEDS::Color& value);
+
+ char* Store();
+ void Restore(const char*);
+
};
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEDS_AttributeTextHighlightColor_i.hxx"
#include "SALOMEDS_SObject_i.hxx"
#include <TColStd_HArray1OfReal.hxx>
-using namespace std;
SALOMEDS::Color SALOMEDS_AttributeTextHighlightColor_i::TextHighlightColor() {
SALOMEDS::Color TextHighlightColor;
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);
+}
// File : SALOMEDS_AttributeTextHighlightColor_i.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef SALOMEDS_AttributeTextHighlightColor_i_HeaderFile
#define SALOMEDS_AttributeTextHighlightColor_i_HeaderFile
SALOMEDS::Color TextHighlightColor();
void SetTextHighlightColor(const SALOMEDS::Color& value);
+
+ char* Store();
+ void Restore(const char*);
+
};
// 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 <TDocStd_Document.hxx>
+#include <TDF_Tool.hxx>
static Handle(TDataStd_TreeNode) GetNode(SALOMEDS::AttributeTreeNode_ptr value,
const Handle(TDataStd_TreeNode)& aNode) {
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);
+ }
+}
CORBA::Boolean IsFather(SALOMEDS::AttributeTreeNode_ptr value);
CORBA::Boolean IsChild(SALOMEDS::AttributeTreeNode_ptr value);
char* Label();
+
+ char* Store();
+ void Restore(const char*);
+
};
#endif
// File : SALOMEDS_AttributeName_i.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
+using namespace std;
#include "SALOMEDS_AttributeUserID_i.hxx"
#include <TCollection_ExtendedString.hxx>
#include "SALOMEDS_SObject_i.hxx"
-using namespace std;
char* SALOMEDS_AttributeUserID_i::Value() {
char aGUID[40];
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) {
+}
static Standard_GUID SALOMEDS_DefaultUserAttributeID ("FFFFFFFF-D9CD-11d6-945D-1050DA506788");
return SALOMEDS_DefaultUserAttributeID;
}
+
+ char* Store();
+ void Restore(const char*);
+
};
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")));}
}
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEDS_ChildIterator_i.hxx"
#include "SALOMEDS_SObject_i.hxx"
#include "utilities.h"
-using namespace std;
+
+
//============================================================================
/*! Function : constructor
// File : SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef _SALOMEDS_DataMapIteratorOfDataMapStringLabel_HeaderFile
#define _SALOMEDS_DataMapIteratorOfDataMapStringLabel_HeaderFile
// File : SALOMEDS_DataMapIteratorOfDataMapStringLabel_0.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
+using namespace std;
#include "SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx"
#ifndef _Standard_NoSuchObject_HeaderFile
#ifndef _SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile
#include "SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx"
#endif
-using namespace std;
#define TheKey TCollection_ExtendedString
// File : SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef _SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile
#define _SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile
// File : Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel_0.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
+using namespace std;
#include "SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx"
#ifndef _Standard_TypeMismatch_HeaderFile
#ifndef _SALOMEDS_DataMapIteratorOfDataMapStringLabel_HeaderFile
#include "SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx"
#endif
-using namespace std;
SALOMEDS_DataMapNodeOfDataMapStringLabel::~SALOMEDS_DataMapNodeOfDataMapStringLabel() {}
// File : SALOMEDS_DataMapStringLabel.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef _SALOMEDS_DataMapStringLabel_HeaderFile
#define _SALOMEDS_DataMapStringLabel_HeaderFile
// File : SALOMEDS_DataMapStringLabel_0.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
+using namespace std;
#include "SALOMEDS_DataMapStringLabel.hxx"
#ifndef _Standard_DomainError_HeaderFile
#ifndef _SALOMEDS_DataMapIteratorOfDataMapStringLabel_HeaderFile
#include "SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx"
#endif
-using namespace std;
#define TheKey TCollection_ExtendedString
// File : SALOMEDS_DrawableAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
+using namespace std;
#include "SALOMEDS_DrawableAttribute.ixx"
#include <TDataStd_Integer.hxx>
-using namespace std;
//=======================================================================
//function : GetID
// File : SALOMEDS_ExpandableAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
+using namespace std;
#include "SALOMEDS_ExpandableAttribute.ixx"
#include <TDataStd_Integer.hxx>
-using namespace std;
//=======================================================================
//function : GetID
// File : SALOMEDS_ExternalFileDef.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#include "SALOMEDS_ExternalFileDef.ixx"
#include <TDataStd_Comment.hxx>
// File : SALOMEDS_FileType.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#include "SALOMEDS_FileType.ixx"
#include <TDataStd_Comment.hxx>
// Module : SALOME
// $Header$
-#include "SALOMEDS_StudyBuilder_i.hxx"
using namespace std;
+#include <TDataStd_TreeNode.hxx>
+#include <TDataStd_UAttribute.hxx>
+
+#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)){
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();
+}
#include CORBA_SERVER_HEADER(SALOMEDS)
#include <TDF_Attribute.hxx>
#include "SALOMEDS_SObject_i.hxx"
-#include "SALOMEDS_IORAttribute.hxx"
class SALOMEDS_GenericAttribute_i: public POA_SALOMEDS::GenericAttribute,
public PortableServer::RefCountServantBase {
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<<endl;
+#define __ReturnCORBAAttribute(OCAF_Name, CORBA_Name) if (theAttr->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<<endl;
+#define __FindOrCreateAttribute(OCAF_Name, CORBA_Name) if (strcmp(aTypeOfAttribute, #CORBA_Name) == 0) { \
+ Handle(OCAF_Name) anAttr; \
+ if (!Lab.FindAttribute(OCAF_Name::GetID(), anAttr)) { \
+ anAttr = new OCAF_Name; \
+ Lab.AddAttribute(anAttr); \
+ } \
+ SALOMEDS_##CORBA_Name##_i* Attr = new SALOMEDS_##CORBA_Name##_i(anAttr, _orb); \
+ return Attr->CORBA_Name::_this(); \
+ }
+
+//cout<<"Create New Attribute "<<#CORBA_Name<<endl;
+#define __FindOrCreateAttributeLocked(OCAF_Name, CORBA_Name) if (strcmp(aTypeOfAttribute, #CORBA_Name) == 0) { \
+ Handle(OCAF_Name) anAttr; \
+ if (!Lab.FindAttribute(OCAF_Name::GetID(), anAttr)) { \
+ CheckLocked(); \
+ anAttr = new OCAF_Name; \
+ Lab.AddAttribute(anAttr); \
+ } \
+ SALOMEDS_##CORBA_Name##_i* Attr = new SALOMEDS_##CORBA_Name##_i(anAttr, _orb); \
+ return Attr->CORBA_Name::_this(); \
+ }
+
#endif
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEDS_IORAttribute.ixx"
#include <TDataStd_Comment.hxx>
#include <TCollection_ExtendedString.hxx>
#include "SALOMEDS_Study_i.hxx"
-using namespace std;
//=======================================================================
//function : GetID
// File : SALOMEDS_LocalIDAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
+using namespace std;
#include "SALOMEDS_LocalIDAttribute.ixx"
#include <TDataStd_Integer.hxx>
-using namespace std;
//=======================================================================
//function : GetID
// File : SALOMEDS_LocalIDAttribute.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef _SALOMEDS_LocalIDAttribute_HeaderFile
#define _SALOMEDS_LocalIDAttribute_HeaderFile
// File : SALOMEDS_LocalIDAttribute.ixx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#include "SALOMEDS_LocalIDAttribute.jxx"
// File : SALOMEDS_LocalIDAttribute.jxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef _Standard_GUID_HeaderFile
#include <Standard_GUID.hxx>
// Module : SALOME
// $Header$
-#include "SALOMEDS_OCAFApplication.ixx"
using namespace std;
+#include "SALOMEDS_OCAFApplication.ixx"
//=======================================================================
//function : SALOMEDS_OCAFApplication
// File : SALOMEDS_OpenedAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
+using namespace std;
#include "SALOMEDS_OpenedAttribute.ixx"
#include <TDataStd_Integer.hxx>
-using namespace std;
//=======================================================================
//function : GetID
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEDS_PersRefAttribute.ixx"
#include <TDataStd_Comment.hxx>
#include <TCollection_ExtendedString.hxx>
-using namespace std;
//=======================================================================
//function : GetID
// File : SALOMEDS_PixMapAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
+using namespace std;
#include "SALOMEDS_PixMapAttribute.ixx"
#include <TDataStd_Comment.hxx>
#include <TCollection_ExtendedString.hxx>
-using namespace std;
//=======================================================================
//function : GetID
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEDS_PythonObjectAttribute.ixx"
#include <string>
-using namespace std;
const Standard_GUID& SALOMEDS_PythonObjectAttribute::GetID()
{
// Module : SALOME
// $Header$
-#include "SALOMEDS_SComponentIterator_i.hxx"
using namespace std;
+#include "SALOMEDS_SComponentIterator_i.hxx"
+
//============================================================================
/*! Function : constructor
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEDS_SComponent_i.hxx"
#include "utilities.h"
-using namespace std;
+
//============================================================================
/*! Function : constructor
// 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 <TDF_AttributeIterator.hxx>
-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
ASSERT(!CORBA::is_nil(Study));
return SALOMEDS::Study::_duplicate(Study); //return Study = abort...
}
- INFOS("Problem GetStudy");
+ MESSAGE("Problem GetStudy");
return SALOMEDS::Study::_nil();
}
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;
}
//============================================================================
{
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();
* 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;
{
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();
+}
#define __SALOMEDS_SOBJECT_I_H__
// std C++ headers
-#include <iostream>
+#include <iostream.h>
#include <vector>
#include <string>
char* _name;
char* _value;
char* _type;
- std::vector<std::string> _liste_ba_type;
+ vector<string> _liste_ba_type;
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
// File : SALOMEDS_SelectableAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
+using namespace std;
#include "SALOMEDS_SelectableAttribute.ixx"
#include <TDataStd_Integer.hxx>
-using namespace std;
//=======================================================================
//function : GetID
// File : SALOMEDS_SequenceOfIntegerAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
-#include "SALOMEDS_SequenceOfIntegerAttribute.ixx"
using namespace std;
+#include "SALOMEDS_SequenceOfIntegerAttribute.ixx"
//=======================================================================
//function : GetID
// File : SALOMEDS_SequenceOfRealAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
+using namespace std;
#include "SALOMEDS_SequenceOfRealAttribute.ixx"
#include <TDataStd_Real.hxx>
-using namespace std;
//=======================================================================
//function : GetID
}
}
}
- }
+
+ }
catch( const SALOME_Exception &ex )
{
MESSAGE( "Communication Error : " << ex.what() );
// Module : SALOME
// $Header$
+using namespace std;
#include "utilities.h"
#include "SALOMEDS_Study_i.hxx"
//#include "SALOMEDS_StudyBuilder_i.hxx"
#include "SALOMEDS_TargetAttribute.hxx"
#include "SALOMEDS_StudyPropertiesAttribute.hxx"
#include "SALOMEDS_PythonObjectAttribute.hxx"
+#include "SALOMEDS_ExternalFileDef.hxx"
+#include "SALOMEDS_FileType.hxx"
#include <TDF_ChildIterator.hxx>
#include <TDF_Label.hxx>
#include <TDataStd_Name.hxx>
#include <TDataStd_Comment.hxx>
#include <TDataStd_UAttribute.hxx>
+#include <TDataStd_Real.hxx>
#include <TDF_Tool.hxx>
#include <TDF_Reference.hxx>
#include <TDF_Data.hxx>
#include <TDF_ListIteratorOfAttributeList.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_AttributeComment_i.hxx"
#include "SALOMEDS_AttributeName_i.hxx"
#include "SALOMEDS_AttributeSequenceOfInteger_i.hxx"
#include "SALOMEDS_AttributeSequenceOfReal_i.hxx"
#include "SALOMEDS_AttributePythonObject_i.hxx"
#include "SALOMEDS_Tool.hxx"
#include "Utils_CorbaException.hxx"
+#include "Utils_ExceptHandlers.hxx"
#include <HDFOI.hxx>
#include <stdlib.h>
-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 :
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;
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);
}
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();
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);
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();
}
}
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)) {
}
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);
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
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;
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
return;
}
DefineComponentInstance (anSCO, aDriver);
-
+
TCollection_AsciiString aHDFPath(Res);
-
+
char* aHDFUrl;
bool isASCII = false;
if (HDFascii::isASCII(aHDFPath.ToCString())) {
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 {
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);
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];
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();
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;
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
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;
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();
}
//============================================================================
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;
}
//============================================================================
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));
}
//============================================================================
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
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);
}
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);
}
//============================================================================
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 {
//============================================================================
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);
//============================================================================
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
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);
+}
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);
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
#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"
//===========================================================================
//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 :"<<current_string);
- Handle(SALOMEDS_StudyPropertiesAttribute) aProp = SALOMEDS_StudyPropertiesAttribute::Set (Lab);
- switch (current_string[0]) {
- case 'f': aProp->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 "<<hdf_dataset->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 "<<hdf_dataset->GetName()<<" by string '"<<current_string<<"' done")
+ } else {
+ MESSAGE(hdf_dataset->GetName());
+ MESSAGE("LoadAttributes: unknown types");
}
+ delete(current_string);
hdf_dataset->CloseOnDisk();
}
//============================================================================
//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"<<Entry);
}
char name[HDF_NAME_MAX_LEN+1];
if (type == HDF_DATASET) {
MESSAGE("--> 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
}
}
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;
// 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... ");
Handle(TDF_Data) DF = Doc->GetData();
try {
- BuildTree (DF,hdf_group_study_structure);
+ BuildTree (Study,hdf_group_study_structure);
}
catch (HDFexception)
{
// 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);
}
*/
//============================================================================
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<aLength; anIndex++) {
- SALOMEDS::AttributeUserID_var UAttr = SALOMEDS::AttributeUserID::_narrow(anAttrList[anIndex]);
- if (!UAttr->_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 "<<anAttrList[a]->Type()<<" : "<<aSaveStr<<" done"<<endl;
+ hdf_dataset=0; //will be deleted by hdf_sco_group destructor
+ }
- SALOMEDS::AttributeTreeNode_var TNRef = SALOMEDS::AttributeTreeNode::_narrow(anAttrList[anIndex]);
- if (!TNRef->_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
}
}
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;
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;
}
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
// Module : SALOME
// $Header$
-#include <SALOMEDS_StudyPropertiesAttribute.ixx>
using namespace std;
+#include <SALOMEDS_StudyPropertiesAttribute.ixx>
const Standard_GUID& SALOMEDS_StudyPropertiesAttribute::GetID()
{
// Module : SALOME
// $Header$
+using namespace std;
#include "utilities.h"
#include "SALOMEDS_Study_i.hxx"
#include "SALOMEDS_LocalIDAttribute.hxx"
#include "SALOMEDS_PersRefAttribute.hxx"
#include "SALOMEDS_UseCaseIterator_i.hxx"
-using namespace std;
#define DIRECTORYID 16661
{
// 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);
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;
}
{
//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);
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();
}
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);
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);
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();
}
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();
}
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);
*/
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
*/
virtual void URL(const char* url);
-
virtual CORBA::Short StudyId();
virtual void StudyId(CORBA::Short id);
// Module : SALOME
// $Header$
+using namespace std;
#include <SALOMEDS_TableOfIntegerAttribute.ixx>
#include <Standard_Failure.hxx>
#include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
#include <string>
-using namespace std;
const Standard_GUID& SALOMEDS_TableOfIntegerAttribute::GetID()
{
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();
// Module : SALOME
// $Header$
+using namespace std;
#include <SALOMEDS_TableOfRealAttribute.ixx>
#include <Standard_Failure.hxx>
#include <TColStd_DataMapIteratorOfDataMapOfIntegerReal.hxx>
#include <string>
#include <stdio.h>
-using namespace std;
const Standard_GUID& SALOMEDS_TableOfRealAttribute::GetID()
{
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();
// Author : Sergey Ruin
// Module : SALOME
+using namespace std;
#include <SALOMEDS_TableOfStringAttribute.ixx>
#include <Standard_Failure.hxx>
#include <SALOMEDS_DataMapIteratorOfDataMapOfIntegerString.hxx>
#include <string>
#include <stdio.h>
-using namespace std;
const Standard_GUID& SALOMEDS_TableOfStringAttribute::GetID()
{
// File : SALOMEDS_TargetAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
+using namespace std;
#include "SALOMEDS_TargetAttribute.ixx"
#include <TDF_Reference.hxx>
#include <TDF_ListIteratorOfAttributeList.hxx>
#include "utilities.h"
-using namespace std;
//=======================================================================
//function : GetID
// File : SALOMEDS_TargetAttribute.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef _SALOMEDS_TargetAttribute_HeaderFile
#define _SALOMEDS_TargetAttribute_HeaderFile
// File : SALOMEDS_TargetAttribute.ixx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#include "SALOMEDS_TargetAttribute.jxx"
// File : SALOMEDS_TargetAttribute.jxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef _Standard_GUID_HeaderFile
#include <Standard_GUID.hxx>
// File : SALOMEDS_TextColorAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
-#include "SALOMEDS_TextColorAttribute.ixx"
using namespace std;
+#include "SALOMEDS_TextColorAttribute.ixx"
//=======================================================================
//function : GetID
// File : SALOMEDS_TextHighlightColorAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
-#include "SALOMEDS_TextHighlightColorAttribute.ixx"
using namespace std;
+#include "SALOMEDS_TextHighlightColorAttribute.ixx"
//=======================================================================
//function : GetID
// Author : Yves FRICAUD
// Module : SALOME
+using namespace std;
#include "SALOMEDS_UseCaseBuilder_i.hxx"
#include "SALOMEDS_AttributeComment_i.hxx"
#include "SALOMEDS_SObject_i.hxx"
#include <TDataStd_ChildNodeIterator.hxx>
#include <TCollection_AsciiString.hxx>
#include <TDF_ChildIterator.hxx>
-using namespace std;
#define USE_CASE_LABEL_TAG 2
#define USE_CASE_GUID "AA43BB12-D9CD-11d6-945D-0050DA506788"
// 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
#---------------
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"
#: 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"
Handle_SALOME_NumberFilter.hxx \
SALOME_DataMapOfIOMapOfInteger.hxx \
Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx \
+ SALOMEGUI.h \
SALOMEGUI_LoadStudiesDlg.h \
SALOMEGUI_TableDlg.h \
SALOMEGUI_NameDlg.h \
SALOMEGUI_SetupCurveDlg.h \
SALOMEGUI_CloseDlg.h
-
# .po files to transform in .qm
PO_FILES = \
QAD_icons.po \
QAD_StudyFrame.cxx \
QAD_Tools.cxx \
QAD_ViewFrame.cxx \
+ SALOMEGUI.cxx \
SALOMEGUI_Application.cxx \
SALOMEGUI_Desktop.cxx \
SALOMEGUI_ImportOperation.cxx \
SALOMEGUI_CloseDlg.cxx \
SALOMEGUI_ActivateComponentDlg.cxx
LIB_MOC = \
+ SALOMEGUI.h \
SALOMEGUI_Application.h \
SALOMEGUI_Desktop.h \
QAD_Application.h \
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)
// $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();
}
void PyInterp_PyQt::initState()
{
- salomeAcquireLock(); //acquire python global lock (one for all interpreters)
SCRUTE(PyInterp_base::_gtstate);
_tstate=PyInterp_base::_gtstate;
PyThreadState_Swap(_tstate);
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();
}
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
// Module : SALOME
// $Header$
-#include "PyInterp_base.h"
-#include "utilities.h"
#include <string>
#include <vector>
+
+#include <Python.h>
#include <cStringIO.h>
+#include <qmutex.h>
+
+#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 "<<this<<"::"<<myMutex<<" - "<<myComment<<" - "<<myMutex->locked());
+ myMutex->lock();
}
-extern "C" void salomeCondReleaseLock(int rellock)
-{
- MESSAGE("salomeCondReleaseLock");
- if(rellock )
- salomeReleaseLock();
+
+ThreadLock::~ThreadLock(){
+ if(MYDEBUG && myComment != "") MESSAGE("~ThreadLock "<<this<<"::"<<myMutex<<" - "<<myComment);
+ myMutex->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 = "<<this);
}
PyInterp_base::~PyInterp_base()
{
- MESSAGE("PyInterp_base::~PyInterp_base()");
- salomeAcquireLock();
- PyThreadState_Swap(_tstate);
- Py_EndInterpreter(_tstate);
- salomeReleaseLock();
+ if(MYPYDEBUG) MESSAGE("PyInterp_base::~PyInterp_base() - this = "<<this);
+ PyLockWrapper aLock(_tstate);
+ //Py_EndInterpreter(_tstate);
}
+
/*!
* Must be called by herited classes constructors. initialize() calls virtuals methods
* initstate & initcontext, not defined here in base class. initstate & initcontext methods
*/
void PyInterp_base::initialize()
{
- MESSAGE("PyInterp_base::initialize()");
- PyObject *m,*v,*c;
-
_history.clear(); // start a new list of user's commands
_ith = _history.begin();
- init_python();
+ if(!_gtstate){
+ PyReleaseLock aReleaseLock;
+ Py_Initialize(); // Initialize the interpreter
+ PyEval_InitThreads(); // Initialize and acquire the global interpreter lock
+ PySys_SetArgv(_argc,_argv); // initialize sys.argv
+ _gtstate = PyThreadState_Get();
+
+ /*
+ * salome_shared_modules should be imported only once
+ */
+ salome_shared_modules_module = PyImport_ImportModule("salome_shared_modules");
+ if(!salome_shared_modules_module)
+ {
+ INFOS("PyInterp_base::initialize() - salome_shared_modules_module == NULL");
+ PyErr_Print();
+ PyErr_Clear();
+ }
+ }
+ // Here the global lock is released
+ if(MYPYDEBUG) MESSAGE("PyInterp_base::initialize() - this = "<<this<<"; _gtstate = "<<_gtstate);
- initState();
+ // The lock will be acquired in initState. Make provision to release it on exit
+ PyReleaseLock aReleaseLock;
+ initState();
initContext();
- m=PyImport_ImportModule("codeop"); // used to interpret & compile commands
- if(m == NULL)
- {
- MESSAGE("Problem...");
- PyErr_Print();
- ASSERT(0);
- salomeReleaseLock();
- return;
- }
- Py_DECREF(m);
+ // used to interpret & compile commands
+ PyObjWrapper m(PyImport_ImportModule("codeop"));
+ if(!m){
+ INFOS("PyInterp_base::initialize() - PyImport_ImportModule('codeop') failed");
+ PyErr_Print();
+ ASSERT(0);
+ return;
+ }
- /*
- * Create cStringIO to capture stdout and stderr
- */
+ // Create cStringIO to capture stdout and stderr
//PycString_IMPORT;
- PycStringIO=(PycStringIO_CAPI *)xxxPyCObject_Import("cStringIO", "cStringIO_CAPI");
- _vout=PycStringIO->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 = "<<this<<"; _verr = "<<_verr<<"; _vout = "<<_vout);
return 0;
}
-void PyInterp_base::enter()
-{
- MESSAGE("PyInterp_base::enter()");
- salomeAcquireLock();
- PyThreadState_Swap(_tstate);
-}
-void PyInterp_base::quit()
-{
- MESSAGE("PyInterp_base::quit()");
- salomeReleaseLock();
-}
-
-void PyInterp_base::basicRun(const char *command)
+/*!
+ * 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 *code,*r;
- enter();
- code=Py_CompileString((char *)command,"PyInterp_base",Py_file_input);
- if (code == NULL)
- {
- /*
- * Caught an error : SyntaxError
- * Print it and quit
- */
- PyErr_Print();
- quit();
- return;
- }
- r = PyEval_EvalCode(code,_g,_g);
- Py_DECREF(code);
- if (r==NULL)
- {
- /*
- * Caught an error during execution
- * Print it and quit
- */
+ PyObject *m = PyImport_AddModule("codeop");
+ if(!m){ // Fatal error. No way to go on.
+ PyErr_Print();
+ return -1;
+ }
+ PyObjWrapper v(PyObject_CallMethod(m,"compile_command","s",command));
+ if(!v){
+ // Error encountered. It should be SyntaxError,
+ //so we don't write out traceback
+ PyObjWrapper exception, value, tb;
+ PyErr_Fetch(&exception, &value, &tb);
+ PyErr_NormalizeException(&exception, &value, &tb);
+ PyErr_Display(exception, value, NULL);
+ 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.
+ PyObjWrapper r(PyEval_EvalCode(v,context,context));
+ if(!r){
+ // Execution error. We return -1
PyErr_Print();
- quit();
- return;
+ return -1;
}
- Py_DECREF(r);
- quit();
+ // The command has been successfully executed. Return 0
+ return 0;
+ }
}
+
int PyInterp_base::run(const char *command)
{
- SCRUTE(command);
- int ret = 0;
- if (_atFirst)
- {
- _atFirst = false;
- ret = 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;
+}
+
#ifndef _PYINTERP_BASE_H_
#define _PYINTERP_BASE_H_
-#include <iostream>
-#include <Python.h>
#include <list>
#include <string>
-using namespace std;
+#include <iostream>
+
+#include <Python.h>
+
+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 <string> _history;
- list <string>::iterator _ith;
+ PyObject * _vout;
+ PyObject * _verr;
+ PyObject * _g;
+ std::list<std::string> _history;
+ std::list<std::string>::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
ActionMap() {}
~ActionMap()
{
- QMapIterator<unsigned int, QActionP*> it;
+ QMapIterator<int, QActionP*> 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<unsigned int, QActionP*> myMap;
+ QMap<int, QActionP*> myMap;
};
// Module : SALOME
// $Header$
+using namespace std;
/*!
\class QAD_Application QAD_Application.h
\brief Study manager for QAD-based application.
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Standard_Failure.hxx>
-using namespace std;
static bool checkPermission(QString fileName) {
if ( QFile::exists( fileName ) ) {
newStudy = new QAD_Study( this, aStudy, StudyName);
}
+ newStudy->Init();
+
if ( newStudy->getResult() ) {
addStudy( newStudy );
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 <===
}
/*!
{
// MESSAGE ("QAD_Application::onStudyDeactivated init. ");
QAD_ASSERT_DEBUG_ONLY ( myActiveStudy == study );
- myActiveStudy->onStudyDeactivated();
- myActiveStudy = 0;
+ if ( study )
+ study->onStudyDeactivated();
// MESSAGE ("QAD_Application::onStudyDeactivated done. ");
}
// Module : SALOME
// $Header$
+using namespace std;
/*!
\class QAD_Config QAD_Config.h
\brief Settings file management for QAD-based application.
#include <qfile.h>
#include <qregexp.h>
#include <qtextstream.h>
-using namespace std;
/*!
/** 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 );
#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"
//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"
#include "SALOMEGUI_CloseDlg.h"
#include "SALOMEGUI_ActivateComponentDlg.h"
+#include "SALOME_Event.hxx"
+
// QT Includes
#include <qlabel.h>
#include <qlayout.h>
#include <qdatetime.h>
#include <qthread.h>
+#include <qstringlist.h>
+
#if QT_VERSION > 300
#include <qlistbox.h>
#include <qregexp.h>
#endif
// Open CASCADE Includes
+#include <OSD_SharedLibrary.hxx>
#include <OSD_LoadMode.hxx>
#include <OSD_Function.hxx>
#include <TCollection_AsciiString.hxx>
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();
//NRI : SAL2214
myNewViewPopup.clear();
//NRI : SAL2214
+ myHelpContentsModulePopup.clear();
myToolsPopup.clear();
myPrefPopup.clear();
myStdActions.clear();
}
}
}
+ 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 <theEvent> 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'.
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 );
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 ) {
/* '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") );
// 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 );
*/
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;
}
/* close active component */
if (!myXmlHandler->myIdList.IsEmpty())
{
+ deactivateComponent();
clearMenus();
myActiveComp="";
myCombo->setCurrentItem (0);
{
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);
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);
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);
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);
/*!
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);
myStdActions.at(SelectionPointId)->setOn(true);
break;
}
- case 2:
+ case EdgeOfCellSelection:
{
myStdActions.at(SelectionActorId)->setOn(false);
myStdActions.at(SelectionCellId)->setOn(false);
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);
};
+// 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'
*/
}
/*!
- 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 == "")
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");
RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
rs->start();
}
+*/
+
// /*!
// Called on 'help\search'
*/
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") );
}
} 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 );
}
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() );
}
}
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 =
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;
theData = theData.replace( QRegExp(aStrOld), aStrNew );
}
- if ( theComponent == "Visu" ) {
+ if ( theComponent == "VISU" ) {
//Visualization main menu item
int aItemId = 401;
int aPosId = 3;
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;
*/
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);
}
/*!
{
if (myActiveStudy != 0) {
if (myActiveComp.compare(component)!=0) {
+ // deactivate previous component
+ deactivateComponent();
+
if (!myXmlHandler->myIdList.IsEmpty()) clearMenus();
if ( myCombo->currentText() != component )
myCombo->setCurrentText( component );
}
}
} 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 )
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*);
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;
}
*/
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());
}
/*!
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 <popupFather>
- 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
*/
{
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() ) {
}
}
}
-
-}
-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()
QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
if (c.isValid()) {
+ /* VSR : PAL5420 ---------------------------------------------------
if ( myActiveApp ) {
QList<QAD_Study>& studies = myActiveApp->getStudies();
for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
}
}
}
+ VSR : PAL5420 --------------------------------------------------- */
QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorRed", c.red() );
QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorGreen", c.green() );
QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorBlue", c.blue() );
QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
if (c.isValid()) {
+ /* VSR : PAL5420 ---------------------------------------------------
if ( myActiveApp ) {
QList<QAD_Study>& studies = myActiveApp->getStudies();
for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
}
}
}
-
+ VSR : PAL5420 --------------------------------------------------- */
QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorRed", c.red() );
QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorGreen", c.green() );
QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorBlue", c.blue() );
QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
if (c.isValid()) {
+ /* VSR : PAL5420 ---------------------------------------------------
if ( myActiveApp ) {
QList<QAD_Study>& studies = myActiveApp->getStudies();
for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
}
}
}
-
+ VSR : PAL5420 --------------------------------------------------- */
QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorRed", c.red() );
QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorGreen", c.green() );
QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorBlue", c.blue() );
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<QAD_Study>& studies = myActiveApp->getStudies();
for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
}
}
}
+ VSR : PAL5420 --------------------------------------------------- */
QStringList bgData;
bgData.append( QString::number( color.red() ) );
bgData.append( QString::number( color.green() ) );
}
}
+/* 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
#include "SALOME_NamingService.hxx"
#include "SALOME_LifeCycleCORBA.hxx"
+#include "SALOME_Selection.h"
// IDL Headers
#include <SALOMEconfig.h>
#include <qfiledialog.h>
#include <qtoolbutton.h>
-// Open CASCADE Includes
-#include <OSD_SharedLibrary.hxx>
-
class QAD_XmlHandler;
+class SALOMEGUI;
+class SALOME_Event;
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,
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 */
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();
bool loadComponent(QString);
QString changeXmlInputSourceData(QString theData, QString theComponent);
void activateComponent(const QString& theName, bool isLoadData = true);
+ void deactivateComponent();
void createStudy();
void setSettings();
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,
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();
void onDeactivateApp(QAD_Application* app);
void onHelpContents();
- void onHelpContentsGUI();
- void onHelpContentsTUI();
+ void onHelpContentsModule();
+ /* void onHelpContentsTUI(); */
/* void onHelpSearch(); */
void onHelpAbout();
//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 */
QMap<QString,QString> mapComponentName;
+private:
+ void processEvent( SALOME_Event* );
+
+private:
+ typedef QMap<QString, SALOMEGUI*> ComponentMap;
+
private:
static QAD_ResourceMgr* resourceMgr;
static QPalette* palette;
void createActions();
void updateActions();
- OSD_SharedLibrary mySharedLibrary;
QAD_XmlHandler* myXmlHandler;
QString myActiveComp;
SALOME_NamingService* myNameService;
QComboBox * myCombo;
bool myQueryClose;
bool _islibso;
+
+ ComponentMap myComponents;
};
/********************************************************************
// Module : SALOME
// $Header$
+using namespace std;
#include "QAD_DirListDlg.h"
#include "QAD_Desktop.h"
#include "QAD_FileDlg.h"
#include <qlabel.h>
#include <qpushbutton.h>
#include <qapplication.h>
-using namespace std;
#define MIN_WIDTH 400
#define MIN_HEIGHT 200
// Module : SALOME
// $Header$
+using namespace std;
#include <qapplication.h>
#include <qdir.h>
#include <qlabel.h>
#include "QAD_FileDlg.h"
#include "QAD_MessageBox.h"
#include "QAD_Tools.h"
-using namespace std;
#define MIN_COMBO_SIZE 100
// Module : SALOME
// $Header$
+using namespace std;
#include "QAD_FileValidator.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include <qfile.h>
#include <qfileinfo.h>
-using namespace std;
/* constructor */
QAD_FileValidator::QAD_FileValidator(QWidget* parent) :
// Module : SALOME
// $Header$
-#include "QAD_Help.h"
using namespace std;
+#include "QAD_Help.h"
/*!
\class QAD_Help QAD_HelpL.h
// Module : SALOME
// $Header$
+using namespace std;
/*!
\class QAD_HelpWindow QAD_HelpWindow.h
\brief Html browser for help.
#include <qtoolbutton.h>
#include <qcombobox.h>
#include <qfileinfo.h>
-using namespace std;
/*!
Constructor
/*
// 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;
// Module : SALOME
// $Header$
+using namespace std;
#include "QAD_LeftFrame.h"
#include "QAD_ObjectBrowser.h"
#include <qlayout.h>
-using namespace std;
/*!
\class QAD_LeftFrame QAD_LeftFrame.h
// Module : SALOME
// $Header$
-#include "QAD_ListMenuIdAction.h"
using namespace std;
+#include "QAD_ListMenuIdAction.h"
QAD_ListMenuIdAction::QAD_ListMenuIdAction(QPopupMenu* theMenu,
int id,
// Module : SALOME
// $Header$
-#include "QAD_ListPopupMenu.h"
using namespace std;
+#include "QAD_ListPopupMenu.h"
/*!
Constructor.
// Module : SALOME
// $Header$
+using namespace std;
#include "QAD_ListView.h"
#include <qheader.h>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_ListIteratorOfListOfReal.hxx>
-using namespace std;
//////////////////////////////////////////////////////////////////////
// QAD_ListView class implementation
// Module : SALOME
// $Header$
-#include "QAD_Menus.h"
using namespace std;
+#include "QAD_Menus.h"
/*!
Constructor.
// Module : SALOME
// $Header$
+using namespace std;
#include "QAD_Message.h"
#include "QAD_Application.h"
#include "QAD_Config.h"
#include <qstring.h>
#include <qpopupmenu.h>
#include <qmap.h>
-using namespace std;
enum { IdCopy, IdClear, IdSelectAll };
// Module : SALOME
// $Header$
+using namespace std;
/*!
\class QAD_MessageBox QAD_MessageBox.h
\brief Message dialog box for QAD-based application.
// QT Includes
#include <qmessagebox.h>
#include <qapplication.h>
-using namespace std;
/*!
Shows info message box with one button [ static ]
#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
*/
myListViewMap[ RefSOEntry ].append( Item );
}
else {
- MESSAGE("QAD_ObjectBrowser::Update : noname item: "<<CSO->GetID());
+ if(MYDEBUG) MESSAGE("QAD_ObjectBrowser::Update : noname item: "<<CSO->GetID());
}
} else {
// getting Value
myListViewMap[ CSOEntry ].append( Item );
}
else {
- MESSAGE("QAD_ObjectBrowser::Update : noname item: "<<CSO->GetID());
+ if(MYDEBUG) MESSAGE("QAD_ObjectBrowser::Update : noname item: "<<CSO->GetID());
}
// adding other attributes
if (Item) {
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 );
}
}
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 )*/ ));
// Module : SALOME
// $Header$
+using namespace std;
#include "QAD_ObjectBrowserItem.h"
#include <qcolor.h>
#include <qpixmap.h>
#include <qstringlist.h>
#include <qpainter.h>
-using namespace std;
/*!
Constructors
// Module : SALOME
// $Header$
+using namespace std;
/*!
\class QAD_Operation QAD_Operation.h
\brief Base class for OCAF operations in QAD-based application.
// QT Include
#include <qapplication.h>
-using namespace std;
/*!
Constructor
// Module : SALOME
// $Header$
+using namespace std;
#include "QAD_OperatorMenus.h"
#include "QAD_Desktop.h"
-using namespace std;
/*!
Constructor.
// Module : SALOME
// $Header$
+using namespace std;
#include "QAD_ParserSettings.h"
#include <stdio.h>
#include <qfile.h>
#include <qfileinfo.h>
#include <qtextstream.h>
-using namespace std;
+
/*!
Constructor.
// Module : SALOME
// $Header$
+using namespace std;
#include "QAD.h"
#include "QAD_Popup.h"
#include "utilities.h"
-using namespace std;
/*****************************************************************************
** Class QAD_PopupClientServer
#include "QAD_Config.h"
#include "QAD_Tools.h"
#include "QAD_MessageBox.h"
-//#include "QAD_RightFrame.h"
-using namespace std;
#include <qapplication.h>
#include <qmap.h>
#include <qclipboard.h>
+#include <qthread.h>
// NRI : Temporary added
// IDL Headers
#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 = "<<myInterp<<"; myMutex = "<<myMutex);
+ myListener->myBanner = myInterp->getbanner().c_str();
+ QThread::postEvent(myListener, new QCustomEvent(QAD_PyEditor::INITIALIZE));
+ QThread::postEvent(myListener, new QCustomEvent(QAD_PyEditor::PYTHON_OK));
+ QThread::postEvent(myListener, new QCustomEvent(QAD_PyEditor::UNSET_CURSOR));
+ }
+
+private:
+ QMutex* myMutex;
+ QMutex* myStudyMutex;
+ QAD_PyInterp*& myInterp;
+ QAD_PyEditor* myListener;
+};
+
+
+class TExecCommandThread : public QThread
+{
+public:
+ TExecCommandThread(QAD_PyInterp*& theInterp,
+ QMutex* theStudyMutex, QMutex* theMutex,
+ QAD_PyEditor* theListener):
+ myInterp(theInterp),
+ myMutex(theMutex),
+ myStudyMutex(theStudyMutex),
+ myListener(theListener),
+ myCommand("")
+ {
+ //QThread::postEvent(myListener, new QCustomEvent(QAD_PyEditor::SET_WAIT_CURSOR));
+ }
+
+ virtual ~TExecCommandThread() {}
+
+ void exec(const char* theCommand){
+ myCommand = theCommand;
+ start();
+ }
+
+protected:
+ virtual void run(){
+ //QThread::postEvent(myListener, new QCustomEvent(QAD_PyEditor::SET_WAIT_CURSOR));
+ int anId = QAD_PyEditor::PYTHON_OK;
+ if(myCommand != ""){
+ ThreadLock anEditorLock(myMutex,"TExecCommandThread::anEditorLock");
+ //ThreadLock aStudyLock(myStudyMutex,"TExecCommandThread::aStudyLock");
+ ThreadLock aPyLock = GetPyThreadLock("TExecCommandThread::aPyLock");
+ int ret = myInterp->run( myCommand.latin1() );
+ if(MYDEBUG) MESSAGE("TExecCommand::run() - myInterp = "<<myInterp<<"; myCommand = '"<<myCommand.latin1()<<"' - "<<ret);
+ if(ret < 0)
+ anId = QAD_PyEditor::PYTHON_ERROR;
+ if(ret > 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;
+ }
}
/*!
*/
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));
}
/*!
*/
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();
}
// 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());
}
/*
QPopupMenu *popup = new QPopupMenu( this );
QMap<int, int> 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);
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 ],
}
else if ( r == idMap[ IdClear ] ) {
clear();
- string banner = _interp->getbanner();
- setText(banner.c_str());
+ setText(myBanner);
setText(_currentPrompt);
}
else if ( r == idMap[ IdSelectAll ] ) {
return;
}
else {
- QMultiLineEdit::mousePressEvent(event);
+ QTextEdit::mousePressEvent(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);
}
/*!
*/
void QAD_PyEditor::dropEvent (QDropEvent *e)
{
- INFOS("dropEvent : not handled");
+ MESSAGE("dropEvent : not handled");
}
/*!
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());
{
case 0 :
{
- if (curLine <endLine)
- {
- setCursorPosition(endLine, SIZEPR);
- end();
- }
- QMultiLineEdit::keyPressEvent( e );
+ if (curLine <endLine || curCol < SIZEPR )
+ moveCursor(QTextEdit::MoveEnd, false);
+ QTextEdit::keyPressEvent( e );
break;
}
case Key_Return:
case Key_Enter:
{
if (curLine <endLine)
- {
- setCursorPosition(endLine, SIZEPR);
- }
- end();
- QMultiLineEdit::keyPressEvent( e );
+ moveCursor(QTextEdit::MoveEnd, false);
+ else
+ moveCursor(QTextEdit::MoveLineEnd, false);
+ QTextEdit::keyPressEvent( e );
break;
}
case Key_Up:
{
// if Cntr+Key_Up event then move cursor up
if (ctrlPressed) {
- QMultiLineEdit::cursorUp( );
+ moveCursor(QTextEdit::MoveUp, false);
}
// if Shift+Key_Up event then move cursor up and select the text
else if ( shftPressed && curLine > 0 ){
- setCursorPosition(curLine-1, curCol, true);
+ moveCursor(QTextEdit::MoveUp, true);
}
// scroll the commands stack up
else {
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;
}
{
// 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;
}
}
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;
+}
#ifndef QAD_PyEditor_H
#define QAD_PyEditor_H
-#include <qmultilineedit.h>
+#include <qtextedit.h>
+#include <qevent.h>
+
+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
#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
*/
QAD_PyInterp::QAD_PyInterp(): PyInterp_base()
{
- initialize();
}
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 = "<<this<<"; _tstate = "<<_tstate);
- if(builtinmodule == NULL)return;
/*
* If builtinmodule has been initialized all the sub interpreters
* will have the same __builtin__ module
*/
- 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);
+ 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 = "<<this<<"; _g = "<<_g);
- if(builtinmodule)
- {
- PyDict_SetItemString(_g, "__builtins__", builtinmodule); // assign singleton __builtin__ module
- }
-// Debut modif CCAR
- /*
- * Import special module to change the import mechanism
- */
- m =PyImport_ImportModule("import_hook");
- if(m == NULL){
- MESSAGE("initContext: problem with import_hook import");
+ if(builtinmodule){
+ PyDict_SetItemString(_g, "__builtins__", builtinmodule); // assign singleton __builtin__ module
+ }
+
+ // Debut modif CCAR
+ // Import special module to change the import mechanism
+ PyObjWrapper m1(PyImport_ImportModule("import_hook"));
+ if(!m1){
+ MESSAGE("initContext: problem with import_hook import");
+ PyErr_Print();
+ PyErr_Clear();
+ ASSERT(0);
+ }else{
+ // Call init_shared_modules to initialize the shared import mechanism for modules
+ //that must not be imported twice
+ PyObjWrapper m2(PyObject_CallMethod(m1,"init_shared_modules","O",salome_shared_modules_module));
+ if(!m2){
+ MESSAGE("initContext: problem with init_shared_modules call");
PyErr_Print();
PyErr_Clear();
ASSERT(0);
+ }
}
- /*
- * Call init_shared_modules to initialize the shared import mechanism for modules
- * that must not be imported twice
- */
- if(m != NULL){
- m= PyObject_CallMethod(m,
- "init_shared_modules","O",salome_shared_modules_module);
- if (m == NULL){
- MESSAGE("initContext: problem with init_shared_modules call");
- PyErr_Print();
- PyErr_Clear();
- ASSERT(0);
- }
- }
-// Fin modif CCAR
-
+ // Fin modif CCAR
}
// Module : SALOME
// $Header$
+
#include "QAD_PyInterp_mono.h"
#include "utilities.h"
+
using namespace std;
/*!
*/
QAD_PyInterp_mono::QAD_PyInterp_mono(): PyInterp_base()
{
- initialize();
}
QAD_PyInterp_mono::~QAD_PyInterp_mono()
void QAD_PyInterp_mono::initState()
{
- salomeAcquireLock(); //acquire python global lock (one for all interpreters)
_tstate = PyThreadState_Get();
PySys_SetArgv(PyInterp_base::_argc,PyInterp_base::_argv); // initialize sys.argv
}
// Module : SALOME
// $Header$
+using namespace std;
/*!
\class QAD_ResourceMgr QAD_ResourceMgr.h
\brief ResourceMgr QAD-based application.
#include <qfileinfo.h>
#include <Standard.hxx>
-using namespace std;
/* configuration file */
static const char* CONFIG_FILE = "config";
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 = ":";
*/
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 : "<<fileConfig);
+ if ( fileConfig.isEmpty() )
+ fileConfig = path( CONFIG_FILE, prefix, 0 ) ;
if ( !fileConfig.isEmpty() ) {
QFile configFile( fileConfig );
if ( !configFile.exists() || !configFile.open( IO_ReadOnly ) ) {
bool bLoadString = false;
bool bLoadImages = false;
- QStringList dirList = QStringList::split( SEPARATOR, resDirs, false ); // skip empty entries
- for ( int i = dirList.count()-1; i >= 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"
can be situated
The order is following :
- <prefix>_ROOT_DIR/share/salome/resources directory
- - CSF_<prefix>Resources env.var directory ( or directory list )
+ - SALOME_<prefix>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;
}
}
- // Try CSF_<prefix>Resources env.var directory ( or directory list )
+ // Try SALOME_<prefix>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 );
*/
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();
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 : <"<<filename.latin1()<<"> : "<<filePath.latin1()) ;
- return filePath;
+ return QString::null;
}
/*!
#include "QAD_Desktop.h"
#include "QAD_StudyFrame.h"
#include "QAD_Tools.h"
+#include "QAD_PyEditor.h"
+#include "QAD_PyInterp.h"
+
#include <qvaluelist.h>
// QT Include
// Open CASCADE Include
#include <OSD_SharedLibrary.hxx>
+
using namespace std;
/*!
/*!
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;
QValueList<int> 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) );
sizes.clear();
sizes.append( (int)(0.25 * DesktopWidth) );
sizes.append( (int)(0.25 * DesktopWidth) );
- vsplitter->setSizes( sizes );
+ mySplitter->setSizes( sizes );
}
/*!
*/
QAD_PyInterp* QAD_RightFrame::get_PyInterp(void)
{
- return _interp;
+ return myInterp;
}
/*!
#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;
QAD_ViewFrame* myViewFrame;
QAD_PyEditor* myPyEditor;
QAD_Message* myMessage;
- QAD_Splitter* vsplitter;
- QAD_PyInterp* _interp;
+ QAD_Splitter* mySplitter;
+ QAD_PyInterp*& myInterp;
};
#endif
// Module : SALOME
// $Header$
+using namespace std;
#include "QAD_Settings.h"
#include <stdio.h>
#include <qregexp.h>
#include <qstring.h>
#include <qtextstream.h>
-using namespace std;
/*!
Class QAD_Settings is a base class for different kind of settings
// Module : SALOME
// $Header$
+using namespace std;
#include "QAD_SpinBoxDbl.h"
#include <qpushbutton.h>
#include <qpainter.h>
#include <qpixmapcache.h>
#include <qapplication.h>
#include <limits.h>
-using namespace std;
//******************************************************************************
// QDblRangeControl class
// Module : SALOME
// $Header$
-#include "QAD_Splitter.h"
using namespace std;
+#include "QAD_Splitter.h"
/*!
Constructs an horizontal splitter.
#include "QAD_ObjectBrowser.h"
#include "QAD_PyInterp.h"
#include "QAD_Config.h"
+#include "QAD_PyInterp.h"
#include "utilities.h"
// QT Include
#include <qapplication.h>
+#include <qthread.h>
+#include <qmutex.h>
+
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
*/
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;
+ }
}
/*!
*/
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 */
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");
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);
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);
}
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);
*/
QAD_PyInterp* QAD_Study::get_PyInterp(void)
{
- return _interp;
+ return myInterp;
}
/*!
#include <qstring.h>
class QAD_Application;
+
+class QMutex;
class QAD_PyInterp;
+class TInitStudyThread;
class QAD_EXPORT QAD_Study : public QObject
{
QAD_Study(QAD_Application* app,
SALOMEDS::Study_var aStudy,
const QString& title);
+ virtual void Init();
~QAD_Study();
/* Event filter */
bool myIsModified;
bool myIsReadOnly;
bool myResult;
- QAD_PyInterp* _interp;
+
+ QMutex* myMutex;
+ QAD_PyInterp* myInterp;
+ TInitStudyThread* myInitStudyThread;
};
#endif
#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 <qvaluelist.h>
+
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<int> 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
*/
void QAD_StudyFrame::closeEvent(QCloseEvent* e)
{
+ if ( IsPyLocked() ) {
+ e->ignore();
+ return;
+ }
+
emit sfStudyFrameClosing(this);
}
*/
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);
}
/*!
*/
QAD_PyInterp* QAD_StudyFrame::get_PyInterp(void)
{
- return _interp;
+ return myInterp;
}
#define QAD_StudyFrame_H
#include "QAD.h"
-#include "QAD_Splitter.h"
-#include "QAD_PyInterp.h"
// QT Includes
#include <qwidget.h>
#include <qmainwindow.h>
+class QMutex;
+
class QAD_RightFrame;
class QAD_LeftFrame;
class QAD_Splitter;
class QAD_Study;
+class QAD_PyInterp;
enum ViewType {
VIEW_OCC,
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; }
const QString& entry() const;
void setVisible( bool isVisible = true );
- void closeEvent(QCloseEvent* e);
void compressLeft();
void compressRight();
public slots:
void onStudyFrameActivated ( QWidget* );
+
+ protected:
+ virtual void closeEvent ( QCloseEvent* );
private:
ViewType myTypeView;
QAD_LeftFrame* myLeftFrm;
QAD_RightFrame* myRightFrm;
- QAD_Splitter* s1;
- QAD_PyInterp* _interp;
+ QAD_Splitter* mySplitter;
QAD_Study* myStudy;
+ QAD_PyInterp*& myInterp;
};
#endif
// Module : SALOME
// $Header$
+using namespace std;
/*!
\class QAD_Tools QAD_Tools.h
\brief Helpful functions for QAD.
#include <string.h>
#include <ctype.h>
#include <qstringlist.h>
-using namespace std;
static char* tempName()
{
// Module : SALOME
// $Header$
+using namespace std;
#include "QAD.h"
#include "QAD_ViewFrame.h"
#include "QAD_Application.h"
#include <qapplication.h>
#include <qimage.h>
#include "utilities.h"
-using namespace std;
/*!
Constructor
#include "QAD_Application.h"
#include "QAD_StudyFrame.h"
#include "SALOME_InteractiveObject.hxx"
+#include "SALOME_Selection.h"
// QT Include
#include <qmainwindow.h>
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;
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
// Module : SALOME
// $Header$
+using namespace std;
#define INCLUDE_MENUITEM_DEF
#include "QAD_Desktop.h"
#include <qaccel.h>
#include <qstringlist.h>
#include <qfileinfo.h>
-using namespace std;
map<int,QString> QAD_XmlHandler::_bibmap;
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"
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"
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"
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"
#: 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
//
//
// File : SALOMEGUI.cxx
-// Author : Nicolas REJNERI
+// Author : Sergey ANIKIN
// Module : SALOME
// $Header$
-using namespace std;
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SALOMEDS)
-
-#include "QAD.h"
-#include "QAD_MessageBox.h"
-#include "QAD_Application.h"
-#include "SALOMEGUI_Application.h"
-
-#include <qmainwindow.h>
-#include <qapplication.h>
-
-#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();
+}
+
--- /dev/null
+// 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 <Standard_Macro.hxx>
+
+#include <qobject.h>
+#include <qstring.h>
+
+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
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEGUI_AboutDlg.h"
#include "QAD_Desktop.h"
#include "QAD_Tools.h"
#include <qlayout.h>
#include <qpixmap.h>
#include <qmessagebox.h>
-using namespace std;
/*
* Constructor
// Author : Michael Zorin (mzn)
// Module : SALOME
+using namespace std;
#include "SALOMEGUI_ActivateComponentDlg.h"
+#include <qframe.h>
+#include <qlabel.h>
#include <qpushbutton.h>
-#include <qhbuttongroup.h>
-#include <qlayout.h>
-#include <qlabel.h>
-#include <qmessagebox.h>
-using namespace std;
+#include <qlayout.h>
+#include <qpixmap.h>
+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 );
}
#define SALOMEGUI_ActivateComponentDlg_H
#include <qdialog.h>
+#include <qpixmap.h>
+
+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
#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"
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;
}
}
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() );
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;
}
if (needRepaint)
viewFrame->Repaint();
- if (isForeignGUIUsed)
- ;//foreignGUI.DlClose(); // VSR: Fix crash on Display objects from non-parent components
myActiveStudy->updateObjBrowser(true);
}
// Author : Vasily RUSYAEV (vrv)
// Module : SALOME
+using namespace std;
#include "SALOMEGUI_CloseDlg.h"
#include <qpushbutton.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qmessagebox.h>
-using namespace std;
SALOMEGUI_CloseDlg::SALOMEGUI_CloseDlg ( QWidget * parent, const char * name, bool modal, WFlags f )
// 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)
// 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 <qbuttongroup.h>
#include "QAD_FileDlg.h"
#include "QAD_Tools.h"
-using namespace std;
/*
* Constructs a modal SALOMEGUI_ExternalBowserDlg which is a child of 'parent'
// 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
// Module : SALOME
// $Header$
-#include "SALOMEGUI_ImportOperation.h"
using namespace std;
+#include "SALOMEGUI_ImportOperation.h"
SALOMEGUI_ImportOperation::SALOMEGUI_ImportOperation( QAD_Study* study ) :
QAD_Operation( study )
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEGUI_LoadStudiesDlg.h"
#include <qlabel.h>
#include <qlayout.h>
#include <qlistbox.h>
#include <qpushbutton.h>
-using namespace std;
#define SPACING_SIZE 6
#define MARGIN_SIZE 11
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEGUI_NameDlg.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qlayout.h>
-using namespace std;
/*!
Constructor
void SALOMEGUI_NameDlg::setName( const QString& name )
{
myLineEdit->setText( name );
- myLineEdit->selectAll();
+ myLineEdit->end(false);
+ myLineEdit->home(true);
}
/*!
return myLineEdit->text();
}
+void SALOMEGUI_NameDlg::accept()
+{
+ if ( name().stripWhiteSpace().isEmpty() )
+ return;
+ QDialog::accept();
+}
+
/*!
Creates modal <Rename> dialog and returns name entered [ static ]
*/
static QString getName( QWidget* parent = 0, const QString& oldName = QString::null );
+protected slots:
+ void accept();
+
private:
QPushButton* myButtonOk;
QPushButton* myButtonCancel;
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEGUI_OpenWith.h"
#include <qlabel.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qlistbox.h>
-using namespace std;
#define SPACING_SIZE 6
#define MARGIN_SIZE 11
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();
}
buttonOk->setEnabled( ListComponent->currentItem() >=0 &&
ListComponent->currentItem() < ListComponent->count() ) ;
}
+
+void SALOMEGUI_OpenWith::onDoubleClickEvent( QListBoxItem* item )
+{
+ if ( item )
+ accept();
+}
#include <qdialog.h>
class QListBox;
+class QListBoxItem;
class QCheckBox;
class QPushButton;
protected slots:
void onSelectionChanged();
+ void onDoubleClickEvent( QListBoxItem* item );
protected:
void updateButtonState();
-
+
protected:
QListBox* ListComponent;
QCheckBox* AllwaysCheckBox;
// 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)
{
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEGUI_SetValueDlg.h"
#include "QAD_Tools.h"
#include <qpushbutton.h>
#include <qlayout.h>
#include <qvalidator.h>
-using namespace std;
#define MARGIN_SIZE 11
#define SPACING_SIZE 6
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEGUI_SetupCurveDlg.h"
#include "QAD_Tools.h"
#include <qlayout.h>
#include <qtoolbutton.h>
#include <qgroupbox.h>
#include <qcolordialog.h>
-using namespace std;
#define MARGIN_SIZE 11
#define SPACING_SIZE 6
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEGUI_StudyPropertiesDlg.h"
#include "QAD_Desktop.h"
#include <qpushbutton.h>
#include <qlayout.h>
-using namespace std;
#define DEFAULT_MARGIN 11
#define DEFAULT_SPACING 6
// Module : SALOME
// $Header$
+using namespace std;
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_Study.h"
#include "SALOME_Selection.h"
#include "SALOME_InteractiveObject.hxx"
#include "SALOME_ListIteratorOfListIO.hxx"
-using namespace std;
/*!
if ((viewId >=0) && (viewId <nbStudyFrames))
myRenderer = myStudy->getStudyFrame(viewId)->getRightFrame()->getViewFrame()->getRenderer();
}
- if (myRenderer == NULL) INFOS("No VTK Renderer available !");
+ if (myRenderer == NULL) MESSAGE("No VTK Renderer available !");
return myRenderer;
}
*/
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEGUI_TableDlg.h"
#include "QAD_Tools.h"
#include "QAD_MessageBox.h"
#include <qinputdialog.h>
#include <qlabel.h>
#include "utilities.h"
-using namespace std;
#define MARGIN_SIZE 11
#define SPACING_SIZE 6
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEGUI_TrihedronSizeDlg.h"
#include <qbuttongroup.h>
#include <qpushbutton.h>
#include <qspinbox.h>
#include <qlayout.h>
-using namespace std;
#define MARGIN_SIZE 11
#define SPACING_SIZE 6
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOMEGUI_ViewChoiceDlg.h"
#include "QAD_Config.h"
#include "QAD_StudyFrame.h"
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
-using namespace std;
/*
* Constructs a SALOMEGUI_ViewChoiceDlg which is a child of 'parent', with the
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"
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"
// File : SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_0.cxx
// Module : SALOME
+using namespace std;
#include "SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx"
#ifndef _Standard_NoSuchObject_HeaderFile
#ifndef _SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_HeaderFile
#include "SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx"
#endif
-using namespace std;
#define TheKey Handle_SALOME_InteractiveObject
// File : SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_0.cxx
// Module : SALOME
+using namespace std;
#include "SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx"
#ifndef _Standard_TypeMismatch_HeaderFile
#ifndef _SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_HeaderFile
#include "SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx"
#endif
-using namespace std;
-
-
SALOME_DataMapNodeOfDataMapOfIOMapOfInteger::~SALOME_DataMapNodeOfDataMapOfIOMapOfInteger() {}
// File : SALOME_DataMapOfIOMapOfInteger_0.cxx
// Module : SALOME
+using namespace std;
#include "SALOME_DataMapOfIOMapOfInteger.hxx"
#ifndef _Standard_DomainError_HeaderFile
#ifndef _SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_HeaderFile
#include "SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx"
#endif
-using namespace std;
#define TheKey Handle_SALOME_InteractiveObject
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOME_Filter.ixx"
-using namespace std;
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() ;
// File : SALOME_ListIO_0.cxx
// Module : SALOME
+using namespace std;
#include "SALOME_ListIO.hxx"
#ifndef _Standard_NoSuchObject_HeaderFile
#ifndef _SALOME_ListNodeOfListIO_HeaderFile
#include "SALOME_ListNodeOfListIO.hxx"
#endif
-using namespace std;
#define Item Handle_SALOME_InteractiveObject
// File : SALOME_ListIteratorOfListIO_0.cxx
// Module : SALOME
+using namespace std;
#include "SALOME_ListIteratorOfListIO.hxx"
#ifndef _Standard_NoMoreObject_HeaderFile
#ifndef _SALOME_ListNodeOfListIO_HeaderFile
#include "SALOME_ListNodeOfListIO.hxx"
#endif
-using namespace std;
#define Item Handle_SALOME_InteractiveObject
// File : SALOME_ListIteratorOfListOfFilter_0.cxx
// Module : SALOME
+using namespace std;
#include "SALOME_ListIteratorOfListOfFilter.hxx"
#ifndef _Standard_NoMoreObject_HeaderFile
#ifndef _SALOME_ListNodeOfListOfFilter_HeaderFile
#include "SALOME_ListNodeOfListOfFilter.hxx"
#endif
-using namespace std;
#define Item Handle_SALOME_Filter
// File : SALOME_ListNodeOfListIO_0.cxx
// Module : SALOME
+using namespace std;
#include "SALOME_ListNodeOfListIO.hxx"
#ifndef _Standard_TypeMismatch_HeaderFile
#ifndef _SALOME_ListIteratorOfListIO_HeaderFile
#include "SALOME_ListIteratorOfListIO.hxx"
#endif
-using namespace std;
-
-
SALOME_ListNodeOfListIO::~SALOME_ListNodeOfListIO() {}
// File : SALOME_ListNodeOfListOfFilter_0.cxx
// Module : SALOME
+using namespace std;
#include "SALOME_ListNodeOfListOfFilter.hxx"
#ifndef _Standard_TypeMismatch_HeaderFile
#ifndef _SALOME_ListIteratorOfListOfFilter_HeaderFile
#include "SALOME_ListIteratorOfListOfFilter.hxx"
#endif
-using namespace std;
-
-
-
SALOME_ListNodeOfListOfFilter::~SALOME_ListNodeOfListOfFilter() {}
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() ;
// File : SALOME_ListOfFilter_0.cxx
// Module : SALOME
+using namespace std;
#include "SALOME_ListOfFilter.hxx"
#ifndef _Standard_NoSuchObject_HeaderFile
#ifndef _SALOME_ListNodeOfListOfFilter_HeaderFile
#include "SALOME_ListNodeOfListOfFilter.hxx"
#endif
-using namespace std;
#define Item Handle_SALOME_Filter
// Module : SALOME
// $Header$
+using namespace std;
#include "SALOME_NumberFilter.ixx"
#include "SALOME_Selection.h"
#include "SALOME_InteractiveObject.hxx"
#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),
// Module : SALOME
// $Header$
+using namespace std;
/*!
\class SALOME_Selection SALOME_Selection.h
\brief Selection Mechanism of Interactive Object.
#include "QAD_Desktop.h"
#include "utilities.h"
-using namespace std;
+
+#include <TColStd_MapIteratorOfMapOfInteger.hxx>
static QList<SALOME_Selection>& SALOME_Sel_GetSelections()
{
{
myFilters.Clear();
myIObjects.Clear();
- mySelectionMode = 4; /*Actor*/
+ mySelectionMode = ActorSelection; /*4*/
mySelActiveCompOnly = false;
QAD_Desktop* aDesktop = QAD_Application::getDesktop();
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;
}
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();
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<int>& 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; i<theIndices.size();i++)
+ MapIndex.Add(theIndices[i]);
+ else
+ for (int i=0; i<theIndices.size();i++)
+ MapIndex.Remove(theIndices[i]);
+
+ myActiveStudy->highlight( 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 ) ) {
// Open CASCADE Include
#include <TColStd_MapOfInteger.hxx>
+#include <vector>
+
+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();
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 );
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<int>& theIndices, bool modeShift, bool update=true );
void RemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, int index );
bool IsIndexSelected(const Handle(SALOME_InteractiveObject)& IObject, int index);
SALOME_DataMapOfIOMapOfInteger myMapIOSubIndex;
- int mySelectionMode;
+ Selection_Mode mySelectionMode;
bool mySelActiveCompOnly;
};
// 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){}