From: smh Date: Fri, 2 Apr 2004 13:11:41 +0000 (+0000) Subject: SALOME PAL V1_4_1 X-Git-Tag: PAL_SALOME_1_4_1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c8fe7264fe64d2430771eded28b09c811982aec2;p=modules%2Fkernel.git SALOME PAL V1_4_1 --- diff --git a/bin/VERSION b/bin/VERSION index 037ad6d66..d0dee5fc9 100755 --- a/bin/VERSION +++ b/bin/VERSION @@ -1 +1 @@ -THIS IS SALOME - KERNEL VERSION: 1.4.0 +THIS IS SALOME - KERNEL VERSION: 1.4.1 diff --git a/bin/killSalome.py b/bin/killSalome.py index 814420dfa..63171b0b9 100755 --- a/bin/killSalome.py +++ b/bin/killSalome.py @@ -1,40 +1,13 @@ #!/usr/bin/env python - -import sys,os,pickle,signal - -process_id={} - -# ----------------------------------------------------------------------------- -# -# Fonction d'arrêt de salome -# - -def killSalome(): - print "arret des serveurs SALOME" - for pid, cmd in process_id.items(): - print "arret du process %s : %s"% (pid, cmd[0]) - try: - os.kill(pid,signal.SIGKILL) - except: - print " ------------------ process %s : %s inexistant"% (pid, cmd[0]) - print "arret du naming service" - os.system("killall -9 omniNames") - -# ----------------------------------------------------------------------------- - -filedict='/tmp/'+os.getenv('USER')+'_SALOME_pidict' -#filedict='/tmp/'+os.getlogin()+'_SALOME_pidict' -try: - fpid=open(filedict, 'r') -except: - print "le fichier %s des process SALOME n'est pas accessible"% filedict - sys.exit(1) - -process_id=pickle.load(fpid) -fpid.close() - -killSalome() - -os.remove(filedict) - - +import os, string + +from killSalomeWithPort import killSalome + +user = os.getenv('USER') +for file in os.listdir("/tmp"): + l = string.split(file, "_") + if len(l) >= 4: + if file[:len(user)] == user: + if l[len(l)-2] == "SALOME" and l[len(l)-1] == "pidict": + killSalome(l[len(l)-3]) + pass diff --git a/bin/orbmodule.py b/bin/orbmodule.py index 1154b0101..a96bc9847 100755 --- a/bin/orbmodule.py +++ b/bin/orbmodule.py @@ -24,6 +24,7 @@ class NamingServer(Server): USER=os.getenv('USER') if USER is None: USER='anonymous' + os.system("mkdir -m 777 -p /tmp/logs") LOGDIR="/tmp/logs/" + USER os.system("mkdir -m 777 -p " + LOGDIR) CMD="runNS.sh > " + LOGDIR + "/salomeNS.log 2>&1" diff --git a/bin/runNS.sh b/bin/runNS.sh index 226bc9be6..76b7452bf 100755 --- a/bin/runNS.sh +++ b/bin/runNS.sh @@ -11,14 +11,15 @@ Username=`/usr/bin/whoami` # clear log files -mkdir -m 775 ${BaseDir}/logs +mkdir -m 777 ${BaseDir}/logs mkdir ${BaseDir}/logs/${Username} touch ${BaseDir}/logs/${Username}/dummy \rm -f ${BaseDir}/logs/${Username}/omninames* ${BaseDir}/logs/${Username}/dummy ${BaseDir}/logs/${Username}/*.log echo "Name Service... " - -omniNames -start -logdir ${BaseDir}/logs/${Username} & +aSedCommand="s/ORBInitRef NameService=corbaname::`hostname`:\([[:digit:]]*\)/\1/" +aPort=`sed -e"$aSedCommand" $OMNIORB_CONFIG` +omniNames -start $aPort -logdir ${BaseDir}/logs/${Username} & # In LifeCycleCORBA, FactoryServer is started with rsh on the requested # computer if this Container does not exist. Default is localhost. diff --git a/bin/runSalome b/bin/runSalome index 3a3d0e2d2..48951369e 100755 --- a/bin/runSalome +++ b/bin/runSalome @@ -1,6 +1,28 @@ -#!/bin/sh +#!/bin/bash -python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --xterm --containers=cpp,python --killall +NSPORT=2809 +echo -n "Searching for free port for the SALOME Naming Service: " +while [ ${NSPORT} -lt 3000 ]; do + NSPORT=`expr ${NSPORT} + 1` + aRes=`netstat -ltn | grep -E :${NSPORT}` + if [ -z "$aRes" ]; then +cat > ${OMNIORB_CONFIG} <_ROOT_DIR doit etre préalablement - positionnée (modulen doit etre en majuscule). - KERNEL_ROOT_DIR est obligatoire. -""" - +import sys, os, string, glob, time, pickle + +### read launch configure xml file and command line options +import launchConfigureParser +args = launchConfigureParser.args + +### kill servers if it is need +if args['killall']: + import killSalome +elif args['portkill']: + from killSalomeWithPort import killSalome + filedict='/tmp/'+os.getenv('USER')+"_"+str(args['port'])+'_'+args['appname'].upper()+'_pidict' + try: + killSalome(my_port) + except: + pass + pass + # ----------------------------------------------------------------------------- # -# Fonction d'arrêt de salome +# Fonctions helper pour ajouter des variables d'environnement # -def killSalome(): - print "arret des serveurs SALOME" - for pid, cmd in process_id.items(): - print "arret du process %s : %s"% (pid, cmd[0]) - try: - os.kill(pid,signal.SIGKILL) - except: - print " ------------------ process %s : %s inexistant"% (pid, cmd[0]) - print "arret du naming service" - os.system("killall -9 omniNames") - -# ----------------------------------------------------------------------------- -# -# Fonction message -# +def add_path(directory, variable_name): + if not os.environ.has_key(variable_name): + os.environ[variable_name] = "" + pass + os.environ[variable_name]=directory + ":" + os.environ[variable_name] + if variable_name=="PYTHONPATH": + sys.path[:0]=[directory] -def message(code, msg=''): - if msg: print msg - sys.exit(code) - -import sys,os,string,glob,time,signal,pickle,getopt - -init_time=os.times() -opts, args=getopt.getopt(sys.argv[1:], 'hmglxck:', ['help','modules=','gui','logger','xterm','containers=','killall']) -modules_root_dir={} -process_id={} -liste_modules={} -liste_containers={} -with_gui=0 -with_logger=0 -with_xterm=0 - -with_container_cpp=0 -with_container_python=0 -with_container_superv=0 - -try: - for o, a in opts: - if o in ('-h', '--help'): - print usage - sys.exit(1) - elif o in ('-g', '--gui'): - with_gui=1 - elif o in ('-l', '--logger'): - with_logger=1 - elif o in ('-x', '--xterm'): - with_xterm=1 - elif o in ('-m', '--modules'): - liste_modules = [x.upper() for x in a.split(',')] - elif o in ('-c', '--containers'): - liste_containers = [x.lower() for x in a.split(',')] - for r in liste_containers: - if r not in ('cpp', 'python', 'superv'): - message(1, 'Invalid -c/--containers option: %s' % a) - if 'cpp' in liste_containers: - with_container_cpp=1 - else: - with_container_cpp=0 - if 'python' in liste_containers: - with_container_python=1 - else: - with_container_python=0 - if 'superv' in liste_containers: - with_container_superv=1 - else: - with_container_superv=0 - elif o in ('-k', '--killall'): - filedict='/tmp/'+os.getenv('USER')+'_SALOME_pidict' - #filedict='/tmp/'+os.getlogin()+'_SALOME_pidict' - found = 0 - try: - fpid=open(filedict, 'r') - found = 1 - except: - print "le fichier %s des process SALOME n'est pas accessible"% filedict - - if found: - process_id=pickle.load(fpid) - fpid.close() - killSalome() - process_id={} - os.remove(filedict) - -except getopt.error, msg: - print usage - sys.exit(1) +init_time = os.times() # ----------------------------------------------------------------------------- # -# Vérification des variables d'environnement +# Check variables _ROOT_DIR and set list of used modules (without KERNEL) +# Add to the PATH-variables modules' specific paths # -try: - kernel_root_dir=os.environ["KERNEL_ROOT_DIR"] - modules_root_dir["KERNEL"]=kernel_root_dir -except: - print usage - sys.exit(1) - -for module in liste_modules : - try: - module=module.upper() - module_root_dir=os.environ[module +"_ROOT_DIR"] - modules_root_dir[module]=module_root_dir - except: - print usage - sys.exit(1) - -# il faut KERNEL en premier dans la liste des modules -# - l'ordre des modules dans le catalogue sera identique -# - la liste des modules presents dans le catalogue est exploitée pour charger les modules CORBA python, -# il faut charger les modules python du KERNEL en premier - -if "KERNEL" in liste_modules:liste_modules.remove("KERNEL") -liste_modules[:0]=["KERNEL"] -#print liste_modules -#print modules_root_dir - -os.environ["SALOMEPATH"]=":".join(modules_root_dir.values()) -if "SUPERV" in liste_modules:with_container_superv=1 +modules_list = [] +if args.has_key("modules"): + modules_list += args["modules"] +modules_list[:0] = ["KERNEL"] # KERNEL must be last in the list to locate it at the first place in PATH variables +modules_list.reverse() + +modules_root_dir = {} +modules_root_dir_list = [] +python_version="python%d.%d" % sys.version_info[0:2] + +to_remove_list=[] +for module in modules_list : + module_variable=module.upper()+"_ROOT_DIR" + if not os.environ.has_key(module_variable): + print "*******************************************************************************" + print "*" + print "* Environment variable",module_variable,"must be set" + print "* Module", module, "will be not available" + print "*" + print "*******************************************************************************" + to_remove_list.append(module) + continue + pass + module_root_dir = os.environ[module_variable] + modules_root_dir[module]=module_root_dir + modules_root_dir_list[:0] = [module_root_dir] + add_path(os.path.join(module_root_dir,"lib",args['appname']), "LD_LIBRARY_PATH") + add_path(os.path.join(module_root_dir,"bin",args['appname']), "PATH") + if os.path.exists(module_root_dir + "/examples") : + add_path(os.path.join(module_root_dir,"examples"), "PYTHONPATH") + +for to_remove in to_remove_list: + modules_list.remove(to_remove) + +while "KERNEL" in modules_list: + modules_list.remove("KERNEL") + pass + +# KERNEL must be last in the list to locate it at the first place in PYTHONPATH variable +list_modules = modules_list[:] + ["KERNEL"] +for module in list_modules: + module_root_dir = modules_root_dir[module] + add_path(os.path.join(module_root_dir,"bin",args['appname']), "PYTHONPATH") + add_path(os.path.join(module_root_dir,"lib",python_version,"site-packages",args['appname']), "PYTHONPATH") + add_path(os.path.join(module_root_dir,"lib",args['appname']), "PYTHONPATH") + add_path(os.path.join(module_root_dir,"lib",python_version,"site-packages",args['appname'],"shared_modules"), "PYTHONPATH") + +#os.environ["SALOMEPATH"]=":".join(modules_root_dir.values()) +os.environ["SALOMEPATH"]=":".join(modules_root_dir_list) +if "SUPERV" in modules_list and not 'superv' in args['containers']: + args['containers'].append("superv") + pass # ----------------------------------------------------------------------------- @@ -149,28 +99,31 @@ if "SUPERV" in liste_modules:with_container_superv=1 class Server: CMD=[] - if with_xterm: + if args['xterm']: ARGS=['xterm', '-iconic', '-sb', '-sl', '500', '-e'] else: ARGS=[] def run(self): - args = self.ARGS+self.CMD - #print "args = ", args - pid = os.spawnvp(os.P_NOWAIT, args[0], args) - process_id[pid]=self.CMD + global process_id + command = self.ARGS+self.CMD + #print "args = ", args + pid = os.spawnvp(os.P_NOWAIT, command[0], command) + process_id[pid]=self.CMD class CatalogServer(Server): SCMD1=['SALOME_ModuleCatalog_Server','-common'] SCMD2=['-personal','${HOME}/Salome/resources/CatalogModulePersonnel.xml'] - def setpath(self,liste_modules): + def setpath(self,modules_list): cata_path=[] - for module in liste_modules: + list_modules = modules_list[:] + list_modules.reverse() + for module in ["KERNEL"] + list_modules: module_root_dir=modules_root_dir[module] module_cata=module+"Catalog.xml" print " ", module_cata - cata_path.extend(glob.glob(os.path.join(module_root_dir,"share","salome","resources",module_cata))) + cata_path.extend(glob.glob(os.path.join(module_root_dir,"share",args['appname'],"resources",module_cata))) self.CMD=self.SCMD1 + [string.join(cata_path,':')] + self.SCMD2 class SalomeDSServer(Server): @@ -180,88 +133,49 @@ class RegistryServer(Server): CMD=['SALOME_Registry_Server', '--salome_session','theSession'] class ContainerCPPServer(Server): - CMD=['SALOME_Container','FactoryServer','-ORBInitRef','NameService=corbaname::localhost'] + #CMD=['SALOME_Container','FactoryServer','-ORBInitRef','NameService=corbaname::localhost'] + CMD=['SALOME_Container','FactoryServer'] class ContainerPYServer(Server): - CMD=['SALOME_ContainerPy.py','FactoryServerPy','-ORBInitRef','NameService=corbaname::localhost'] + #CMD=['SALOME_ContainerPy.py','FactoryServerPy','-ORBInitRef','NameService=corbaname::localhost'] + CMD=['SALOME_ContainerPy.py','FactoryServerPy'] class ContainerSUPERVServer(Server): - CMD=['SALOME_Container','SuperVisionContainer','-ORBInitRef','NameService=corbaname::localhost'] + #CMD=['SALOME_Container','SuperVisionContainer','-ORBInitRef','NameService=corbaname::localhost'] + CMD=['SALOME_Container','SuperVisionContainer'] class LoggerServer(Server): CMD=['SALOME_Logger_Server', 'logger.log'] class SessionLoader(Server): CMD=['SALOME_Session_Loader'] - if with_container_cpp: + if "cpp" in args['containers']: CMD=CMD+['CPP'] - if with_container_python: + if "python" in args['containers']: CMD=CMD+['PY'] - if with_container_superv: + if "superv" in args['containers']: CMD=CMD+['SUPERV'] - if with_gui: + if args['gui']: CMD=CMD+['GUI'] class SessionServer(Server): CMD=['SALOME_Session_Server'] class NotifyServer(Server): - CMD=['notifd','-c','${KERNEL_ROOT_DIR}/share/salome/resources/channel.cfg -DFactoryIORFileName=/tmp/${LOGNAME}_rdifact.ior -DChannelIORFileName=/tmp/${LOGNAME}_rdichan.ior'] - -# ----------------------------------------------------------------------------- -# -# Fonction de test -# - -def test(clt): - # create an LifeCycleCORBA instance - import LifeCycleCORBA - lcc = LifeCycleCORBA.LifeCycleCORBA(clt.orb) - med = lcc.FindOrLoadComponent("FactoryServer", "MED") - #pycalc = lcc.FindOrLoadComponent("FactoryServerPy", "CalculatorPy") - -# ----------------------------------------------------------------------------- -# -# Fonctions helper pour ajouter des variables d'environnement -# - -def add_path(directory): - os.environ["PATH"]=directory + ":" + os.environ["PATH"] - -def add_ld_library_path(directory): - os.environ["LD_LIBRARY_PATH"]=directory + ":" + os.environ["LD_LIBRARY_PATH"] - -def add_python_path(directory): - os.environ["PYTHONPATH"]=directory + ":" + os.environ["PYTHONPATH"] - sys.path[:0]=[directory] + myLogName = os.environ["LOGNAME"] + CMD=['notifd','-c',modules_root_dir["KERNEL"]+'/share/salome/resources/channel.cfg', '-DFactoryIORFileName=/tmp/'+myLogName+'_rdifact.ior', '-DChannelIORFileName=/tmp/'+myLogName+'_rdichan.ior'] # ----------------------------------------------------------------------------- # # initialisation des variables d'environnement # -python_version="python%d.%d" % sys.version_info[0:2] - -# -# Ajout du chemin d'acces aux executables de KERNEL dans le PATH -# - -add_path(os.path.join(kernel_root_dir,"bin","salome")) -#print "PATH=",os.environ["PATH"] - -# -# Ajout des modules dans le LD_LIBRARY_PATH -# -for module in liste_modules: - module_root_dir=modules_root_dir[module] - add_ld_library_path(os.path.join(module_root_dir,"lib","salome")) - os.environ["SALOME_trace"]="local" -if with_logger: +if args['logger']: os.environ["SALOME_trace"]="with_logger" locdir=os.environ['PWD'] libtracedir=os.path.join(locdir,"libSalomeTrace") - libtrace = os.path.join(kernel_root_dir,"lib","salome","libSALOMELoggerClient.so.0.0.0") + libtrace = os.path.join(modules_root_dir["KERNEL"],"lib",args['appname'],"libSALOMELoggerClient.so.0.0.0") libtraceln = os.path.join(libtracedir,"libSALOMELocalTrace.so") aCommand = 'rm -rf ' + libtracedir + "; " aCommand += 'mkdir ' + libtracedir + "; " @@ -269,27 +183,30 @@ if with_logger: aCommand += 'ln -s ' + libtrace + " " + libtraceln + ".0; " aCommand += 'ln -s ' + libtrace + " " + libtraceln + ".0.0.0; " os.system(aCommand) - add_ld_library_path(libtracedir) + add_path(libtracedir, "LD_LIBRARY_PATH") + +# set environment for SMESH plugins + +if "SMESH" in args["modules"]: + os.environ["SMESH_MeshersList"]="StdMeshers" + if not os.environ.has_key("SALOME_StdMeshersResources"): + os.environ["SALOME_StdMeshersResources"] = modules_root_dir["SMESH"]+"/share/"+args["appname"]+"/resources" + pass + if args.has_key("SMESH_plugins"): + for plugin in args["SMESH_plugins"]: + if os.environ.has_key(plugin.upper()+"_ROOT_DIR"): + os.environ["SMESH_MeshersList"]=os.environ["SMESH_MeshersList"]+":"+plugin + plugin_root = os.environ[plugin.upper()+"_ROOT_DIR"] + if not os.environ.has_key("SALOME_"+plugin+"Resources"): + os.environ["SALOME_"+plugin+"Resources"] = plugin_root+"/share/"+args["appname"]+"/resources" + add_path(os.path.join(plugin_root,"lib",python_version,"site-packages",args['appname']), "PYTHONPATH") + add_path(os.path.join(plugin_root,"lib",args['appname']), "PYTHONPATH") + add_path(os.path.join(plugin_root,"lib",args['appname']), "LD_LIBRARY_PATH") + add_path(os.path.join(plugin_root,"bin",args['appname']), "PYTHONPATH") + add_path(os.path.join(plugin_root,"bin",args['appname']), "PATH") + pass + pass -#print "LD_LIBRARY_PATH=",os.environ["LD_LIBRARY_PATH"] - -# -# Ajout des modules dans le PYTHONPATH (KERNEL prioritaire, donc en dernier) -# - -liste_modules_reverse=liste_modules[:] -liste_modules_reverse.reverse() -#print liste_modules -#print liste_modules_reverse -for module in liste_modules_reverse: - module_root_dir=modules_root_dir[module] - add_python_path(os.path.join(module_root_dir,"bin","salome")) - add_python_path(os.path.join(module_root_dir,"lib",python_version,"site-packages","salome")) - add_python_path(os.path.join(module_root_dir,"lib","salome")) - add_python_path(os.path.join(module_root_dir,"lib",python_version,"site-packages","salome","shared_modules")) - -#print "PYTHONPATH=",sys.path - import orbmodule # @@ -316,7 +233,7 @@ def startSalome(): # Lancement Session Loader # - if with_gui: + if args['gui']: SessionLoader().run() # @@ -328,10 +245,13 @@ def startSalome(): # (non obligatoire) Lancement Logger Server et attente de sa disponibilite dans le naming service # - if with_logger: + if args['logger']: LoggerServer().run() clt.waitLogger("Logger") + # Notify Server launch + # + NotifyServer().run() # # Lancement Registry Server @@ -350,7 +270,7 @@ def startSalome(): # cataServer=CatalogServer() - cataServer.setpath(liste_modules) + cataServer.setpath(modules_list) cataServer.run() # @@ -364,13 +284,13 @@ def startSalome(): # Lancement SalomeDS Server # - os.environ["CSF_PluginDefaults"]=os.path.join(kernel_root_dir,"share","salome","resources") - os.environ["CSF_SALOMEDS_ResourcesDefaults"]=os.path.join(kernel_root_dir,"share","salome","resources") + os.environ["CSF_PluginDefaults"]=os.path.join(modules_root_dir["KERNEL"],"share",args['appname'],"resources") + os.environ["CSF_SALOMEDS_ResourcesDefaults"]=os.path.join(modules_root_dir["KERNEL"],"share",args['appname'],"resources") SalomeDSServer().run() - if "GEOM" in liste_modules: + if "GEOM" in modules_list: print "GEOM OCAF Resources" - os.environ["CSF_GEOMDS_ResourcesDefaults"]=os.path.join(modules_root_dir["GEOM"],"share","salome","resources") + os.environ["CSF_GEOMDS_ResourcesDefaults"]=os.path.join(modules_root_dir["GEOM"],"share",args['appname'],"resources") # @@ -400,7 +320,7 @@ def startSalome(): # # Lancement Container C++ local # - if with_container_cpp: + if 'cpp' in args['containers']: ContainerCPPServer().run() # @@ -413,7 +333,7 @@ def startSalome(): # Lancement Container Python local # - if with_container_python: + if 'python' in args['containers']: ContainerPYServer().run() # @@ -422,7 +342,7 @@ def startSalome(): clt.waitNS("/Containers/" + theComputer + "/FactoryServerPy") - if with_container_superv: + if 'superv' in args['containers']: # # Lancement Container Supervision local @@ -453,42 +373,50 @@ def startSalome(): # ----------------------------------------------------------------------------- # +process_id = {} if __name__ == "__main__": - clt=None - try: - clt = startSalome() - except: - print - print - print "--- erreur au lancement Salome ---" - - #print process_id - - - filedict='/tmp/'+os.getenv('USER')+'_SALOME_pidict' - #filedict='/tmp/'+os.getlogin()+'_SALOME_pidict' - - fpid=open(filedict, 'w') - pickle.dump(process_id,fpid) - fpid.close() - - print - print "Sauvegarde du dictionnaire des process dans ", filedict - print "Pour tuer les process SALOME, executer : python killSalome.py depuis" - print "une console, ou bien killSalome() depuis le present interpreteur," - print "s'il n'est pas fermé." - print - print "runSalome, avec l'option --killall, commence par tuer les process restants d'une execution précédente." - print - print "Pour lancer uniquement le GUI, executer startGUI() depuis le present interpreteur," - print "s'il n'est pas fermé." - - # - # Impression arborescence Naming Service - # - - if clt != None: - print - print " --- registered objects tree in Naming Service ---" - clt.showNS() - + clt=None + try: + clt = startSalome() + except: + print + print + print "--- erreur au lancement Salome ---" + + #print process_id + + filedict='/tmp/'+os.getenv('USER')+"_"+str(args['port'])+'_'+args['appname'].upper()+'_pidict' + #filedict='/tmp/'+os.getlogin()+'_SALOME_pidict' + + + process_ids = [] + try: + fpid=open(filedict, 'r') + process_ids=pickle.load(fpid) + fpid.close() + except: + pass + + fpid=open(filedict, 'w') + process_ids.append(process_id) + pickle.dump(process_ids,fpid) + fpid.close() + + print + print "Saving of the dictionary of Salome processes in ", filedict + print "To kill SALOME processes launch : python killSalome.py from" + print "a console or killSalome() from the present interpreter, if it is not closed." + print + print "runSalome, with --killall option, starts with killing the processes resulting from the previous execution." + print + print "To launch only GUI only execute startGUI() from the present interpreter," + print "if it is not closed." + + # + # Impression arborescence Naming Service + # + + if clt != None: + print + print " --- registered objects tree in Naming Service ---" + clt.showNS() diff --git a/doc/Makefile.in b/doc/Makefile.in index 2033a4172..7295ede75 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -11,9 +11,11 @@ top_builddir=.. srcdir=@srcdir@ VPATH=.:@srcdir@ -SUBDIRS=html DevelopersGuide +SUBDIRS= salome -doc: +@COMMENCE@ + +docs: @@SETX@; for d in $(SUBDIRS); do \ (cd $$d && $(MAKE) $@) || exit 1; \ done @@ -31,3 +33,8 @@ install: @@SETX@; for d in $(SUBDIRS); do \ (cd $$d && $(MAKE) $@) || exit 1; \ done + +uninstall: + @@SETX@; for d in $(SUBDIRS); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done diff --git a/idl/Makefile.in b/idl/Makefile.in index 8033ab2b0..5d8a1f21d 100644 --- a/idl/Makefile.in +++ b/idl/Makefile.in @@ -6,7 +6,7 @@ top_srcdir=@top_srcdir@ top_builddir=.. srcdir=@srcdir@ -VPATH=.:$(srcdir) +VPATH=. @COMMENCE@ @@ -30,11 +30,14 @@ IDL_FILES = \ PY_CLIENT_IDL = $(IDL_FILES) # we copy all idl file in $(top_builddir)/idl -inc: $(IDL_FILES:%=$(top_builddir)/idl/%) +inc: $(top_builddir)/idl/salome $(IDL_FILES:%=$(top_builddir)/idl/salome/%) -$(IDL_FILES:%=$(top_builddir)/idl/%):$(top_builddir)/idl/%:% +$(top_builddir)/idl/salome: + mkdir $@ + +$(IDL_FILES:%=$(top_builddir)/idl/salome/%):$(IDL_FILES:%=$(top_srcdir)/idl/%) # $(CP) $< $@ - cp -f $< $@ + cp -f $^ $(top_builddir)/idl/salome lib: pyidl @@ -46,7 +49,7 @@ pyidl: $(PYTHON_BUILD_SITE) $(IDL_FILES:%.idl=$(PYTHON_BUILD_SITE)/%_idl.py) $(PYTHON_BUILD_SITE): $(INSTALL) -d $@ -$(PYTHON_BUILD_SITE)/%_idl.py: %.idl +$(PYTHON_BUILD_SITE)/%_idl.py: $(top_builddir)/idl/salome/%.idl $(OMNIORB_IDL) $(OMNIORB_IDLPYFLAGS) -C$(PYTHON_BUILD_SITE) $< @@ -54,12 +57,12 @@ $(PYTHON_BUILD_SITE)/%_idl.py: %.idl install: install-pyidl install-idl # create directory $(idldir) and copy idl files into it -install-idl: $(IDL_FILES) +install-idl: $(IDL_FILES:%=$(top_builddir)/idl/salome/%) $(INSTALL) -d $(idldir) - cp -p $^ $(idldir) + cp -p -f $^ $(idldir) -install-pyidl: $(IDL_FILES) +install-pyidl: $(IDL_FILES:%=$(top_builddir)/idl/salome/%) $(INSTALL) -d $(PYTHON_SITE_INSTALL) @for file in $^ dummy; do \ if [ $$file != "dummy" ]; then \ @@ -74,6 +77,6 @@ cleandep: distclean: -$(RM) *.py - -$(RM) $(IDL_FILES:%=$(top_builddir)/idl/%) + -$(RM) $(IDL_FILES:%=$(top_builddir)/idl/salome/%) -$(RM) Makefile diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index 686297a17..6184f8fb1 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -196,6 +196,13 @@ during each working session. */ SObject FindObjectID (in ID aObjectID); +/*! + Allows to create a %SObject by its ID + \param aObjectID This parameter defines the ID of the required object + \return The created %SObject + +*/ + SObject CreateObjectID (in ID aObjectID); /*! Allows to find a %SObject by IOR of the object belonging to this %SObject. \param anObjectName This parameter defines the IOR of the object @@ -606,6 +613,29 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin */ Callback SetOnRemoveSObject(in Callback theCallback); +/*! + Puts name attribute with the given string value to the given %SObject + + \param theSO Existing SObject to set name attribute. + \param theValue The value to be set to the name attribute. +*/ + void SetName(in SObject theSO, in string theValue) raises (LockProtection); + +/*! + Puts comment attribute with the given string value to the given %SObject + + \param theSO Existing SObject to set comment attribute. + \param theValue The value to be set to the comment attribute. +*/ + void SetComment(in SObject theSO, in string theValue) raises (LockProtection); + +/*! + Puts IOR attribute with the given string value to the given %SObject + + \param theSO Existing SObject to set IOR attribute. + \param theValue The value to be set to the IOR attribute. +*/ + void SetIOR(in SObject theSO, in string theValue) raises (LockProtection); }; //========================================================================== @@ -817,6 +847,31 @@ Gets the list of open studies /return The study containing the given %SObject. */ Study GetStudy(); + +/*! Gets the CORBA object by its own IOR attribute. + Returns nil, if can't. + + /return The CORBA object of the %SObject. +*/ + Object GetObject(); + +/*! + Returns the name attribute value of this SObject. + Returns empty string if there is no name attribute. +*/ + string GetName(); + +/*! + Returns the comment attribute value of this SObject. + Returns empty string if there is no comment attribute. +*/ + string GetComment(); + +/*! + Returns the IOR attribute value of this SObject. + Returns empty string if there is no IOR attribute. +*/ + string GetIOR(); }; @@ -840,6 +895,14 @@ Gets the list of open studies \note
This exception is raised only outside a transaction. */ void CheckLocked() raises (LockProtection); + + string Store(); + + void Restore(in string theData); + + string Type(); + + SObject GetSObject(); }; diff --git a/idl/SALOMEDS_Attributes.idl b/idl/SALOMEDS_Attributes.idl index 27f1f6dbd..42310794f 100644 --- a/idl/SALOMEDS_Attributes.idl +++ b/idl/SALOMEDS_Attributes.idl @@ -63,6 +63,7 @@ module SALOMEDS Attribute allowing to store a real value */ //========================================================================== + interface AttributeReal : GenericAttribute { /*! @@ -77,6 +78,7 @@ module SALOMEDS
See also an example of this method usage in batchmode of %SALOME application. */ void SetValue(in double value); + }; //========================================================================== /*! \brief Attribute allowing to store an integer value diff --git a/idl/SALOME_Component.idl b/idl/SALOME_Component.idl index ad9be3b06..a18580fe7 100644 --- a/idl/SALOME_Component.idl +++ b/idl/SALOME_Component.idl @@ -83,6 +83,14 @@ module Engines Returns True if the %container has been killed */ boolean Kill_impl() ; +/*! + Returns the hostname of the container +*/ + string getHostName(); +/*! + Returns the PID of the container +*/ + long getPID(); }; /*! \brief Interface of the %component diff --git a/idl/SALOME_ModuleCatalog.idl b/idl/SALOME_ModuleCatalog.idl index 227c6b7e0..61883a91c 100644 --- a/idl/SALOME_ModuleCatalog.idl +++ b/idl/SALOME_ModuleCatalog.idl @@ -74,6 +74,7 @@ This struct contains fields completely defining each service. ListOfServicesParameter ServiceinParameter; /*!< List of input parameters of the services.*/ ListOfServicesParameter ServiceoutParameter; /*!< List of output parameters of the services.*/ boolean Servicebydefault; /*! , size_t size; const Standard_CString aName="toto"; diff --git a/salome_adm/unix/make_commence.in b/salome_adm/unix/make_commence.in index a970492b1..72033bdcd 100644 --- a/salome_adm/unix/make_commence.in +++ b/salome_adm/unix/make_commence.in @@ -34,6 +34,10 @@ CXX = @CXX@ CXXFLAGS = @CXXFLAGS@ CXX_DEPEND_FLAG = @CXX_DEPEND_FLAG@ +# BOOST Library + +BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ + # JAVA JAVA_INCLUDES = @JAVA_INCLUDES@ @@ -131,7 +135,7 @@ OMNIORB_CXXFLAGS = @OMNIORB_CXXFLAGS@ OMNIORB_IDL = @OMNIORB_IDL@ OMNIORB_IDLCXXFLAGS = @OMNIORB_IDLCXXFLAGS@ -OMNIORB_IDLPYFLAGS = @OMNIORB_IDLPYFLAGS@ -I$(top_builddir)/idl +OMNIORB_IDLPYFLAGS = @OMNIORB_IDLPYFLAGS@ -I$(top_builddir)/salome/idl OMNIORB_IDL_CLN_H = @OMNIORB_IDL_CLN_H@ OMNIORB_IDL_CLN_CXX = @OMNIORB_IDL_CLN_CXX@ @@ -148,7 +152,7 @@ CORBA_INCLUDES = @CORBA_INCLUDES@ CORBA_LIBS = @CORBA_LIBS@ CORBA_CXXFLAGS = @CORBA_CXXFLAGS@ -IDLCXXFLAGS = -bcxx @IDLCXXFLAGS@ -I$(top_builddir)/idl +IDLCXXFLAGS = -bcxx @IDLCXXFLAGS@ -I$(top_builddir)/salome/idl IDLPYFLAGS = @IDLPYFLAGS@ IDL = @IDL@ @@ -202,13 +206,13 @@ idldir=${prefix}/idl/salome sharedpydir=@libdir@/python$(PYTHON_VERSION)/site-packages/salome/shared_modules incmakedir=${prefix}/salome_adm/unix -docdir=$(datadir)/doc +docdir=${prefix}/doc/salome # # begin of package rules # -.PHONY: all lib bin inc resources data doc tests install uninstall dep depend depend_idl cleandep mostlyclean clean distclean +.PHONY: all lib bin inc resources data docs tests install uninstall dep depend depend_idl cleandep mostlyclean clean distclean .SUFFIXES: .cxx .cc .c .f .o .lo .idl .py .i .ui .po .qm @@ -251,7 +255,7 @@ ac_cxx_namespaces.m4 check_omniorb.m4 pyembed.m4 \ ac_cxx_partial_specialization.m4 check_opengl.m4 python.m4 \ ac_cxx_typename.m4 check_pthreads.m4 check_cas.m4 \ ac_cc_warnings.m4 check_qt.m4 check_med2.m4 \ -check_swig.m4 +check_swig.m4 check_boost.m4 $(top_srcdir)/aclocal.m4: $(ACLOCAL_SRC:%=@KERNEL_ROOT_DIR@/salome_adm/unix/config_files/%) cd $(top_srcdir) ; aclocal --acdir=adm_local/unix/config_files -I @KERNEL_ROOT_DIR@/salome_adm/unix/config_files diff --git a/salome_adm/unix/make_conclude.in b/salome_adm/unix/make_conclude.in index fe43d0e54..b791f484d 100644 --- a/salome_adm/unix/make_conclude.in +++ b/salome_adm/unix/make_conclude.in @@ -161,7 +161,7 @@ install: $(LIB) $(BIN) $(TEST_PROGS) $(libdir) $(includedir) $(bindir) $(datadir # Install exported includes in includedir @for f in X $(EXPORT_HEADERS:%=$(srcdir)/%); do \ if test $$f != X; then \ - (cp -p $$f $(includedir) || exit 1); \ + (cp -p -f $$f $(includedir) || exit 1); \ fi; \ done diff --git a/salome_adm/unix/make_module.in b/salome_adm/unix/make_module.in index 983342227..2d08f49ba 100644 --- a/salome_adm/unix/make_module.in +++ b/salome_adm/unix/make_module.in @@ -57,11 +57,11 @@ data: @if test "X$(top_builddir)" = "X."; then \ ((cd examples && $(MAKE) $@) || exit 1); \ fi; - -doc: - @if test "X$(top_builddir)" = "X."; then \ - ((cd doc && $(MAKE) $@) || exit 1); \ - fi; +# Commented because we need not to make docs when we make BUILD +# docs: +# @if test "X$(top_builddir)" = "X."; then \ +# ((cd doc && $(MAKE) $@) || exit 1); \ +# fi; install: install-resources @@SETX@; for d in $(SUBDIRS); do \ diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index 05f7c84f8..91383b168 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -58,6 +58,7 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, int argc , char* argv[] ) : _numInstance(0) { + _pid = (long)getpid(); ActSigIntHandler() ; @@ -124,6 +125,7 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, int flag ) : _numInstance(0) { + _pid = (long)getpid(); string hostname = GetHostname(); SCRUTE(hostname); @@ -184,12 +186,12 @@ Engines::Container_ptr Engines_Container_i::start_impl( cont += machineName() ; cont += "/" ; cont += ContainerName; - INFOS(machineName() << " start_impl unknown container " << cont.c_str() + MESSAGE(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(machineName() << " start_impl unknown container " + MESSAGE(machineName() << " start_impl unknown container " << ContainerName); } } @@ -201,7 +203,7 @@ Engines::Container_ptr Engines_Container_i::start_impl( } if ( !nilvar ) { _numInstanceMutex.unlock() ; - MESSAGE("start_impl container found without runSession") ; + MESSAGE("start_impl container found without new launch") ; return Engines::Container::_narrow(obj); } int i = 0 ; @@ -209,12 +211,8 @@ Engines::Container_ptr Engines_Container_i::start_impl( MESSAGE(" argv" << i << " " << _argv[ i ]) ; i++ ; } -// string shstr( "rsh -n " ) ; -// shstr += machineName() ; -// shstr += " " ; -// shstr += _argv[ 0 ] ; -// string shstr( _argv[ 0 ] ) ; - string shstr( "./runSession SALOME_Container " ) ; + string shstr = string(getenv("KERNEL_ROOT_DIR")) + "/bin/salome/SALOME_Container "; +// string shstr( "./runSession SALOME_Container " ) ; shstr += ContainerName ; if ( _argc == 4 ) { shstr += " " ; @@ -228,38 +226,37 @@ Engines::Container_ptr Engines_Container_i::start_impl( MESSAGE("system(" << shstr << ")") ; int status = system( shstr.c_str() ) ; if (status == -1) { - INFOS("Engines_Container_i::start_impl runSession(SALOME_Container) failed (system command status -1)") ; + MESSAGE("Engines_Container_i::start_impl SALOME_Container failed (system command status -1)") ; } else if (status == 217) { - INFOS("Engines_Container_i::start_impl runSession(SALOME_Container) failed (system command status 217)") ; + MESSAGE("Engines_Container_i::start_impl SALOME_Container failed (system command status 217)") ; } - INFOS(machineName() << " Engines_Container_i::start_impl runSession(SALOME_Container) done"); -#if 0 - pid_t pid = fork() ; - if ( pid == 0 ) { - string anExe( _argv[ 0 ] ) ; - anExe += "runSession" ; - char * args[ 6 ] ; - args[ 0 ] = "runSession" ; - args[ 1 ] = "SALOME_Container" ; - args[ 2 ] = strdup( ContainerName ) ; - args[ 3 ] = strdup( _argv[ 2 ] ) ; - args[ 4 ] = strdup( _argv[ 3 ] ) ; - args[ 5 ] = NULL ; - MESSAGE("execl(" << anExe.c_str() << " , " << args[ 0 ] << " , " - << args[ 1 ] << " , " << args[ 2 ] << " , " << args[ 3 ] - << " , " << args[ 4 ] << ")") ; - int status = execv( anExe.c_str() , args ) ; - if (status == -1) { - INFOS("Engines_Container_i::start_impl execl failed (system command status -1)") ; - perror( "Engines_Container_i::start_impl execl error ") ; - } - else { - INFOS(machineName() << " Engines_Container_i::start_impl execl done"); - } - exit(0) ; - } -#endif + MESSAGE(machineName() << " Engines_Container_i::start_impl SALOME_Container launch done"); + +// pid_t pid = fork() ; +// if ( pid == 0 ) { +// string anExe( _argv[ 0 ] ) ; +// anExe += "runSession" ; +// char * args[ 6 ] ; +// args[ 0 ] = "runSession" ; +// args[ 1 ] = "SALOME_Container" ; +// args[ 2 ] = strdup( ContainerName ) ; +// args[ 3 ] = strdup( _argv[ 2 ] ) ; +// args[ 4 ] = strdup( _argv[ 3 ] ) ; +// args[ 5 ] = NULL ; +// MESSAGE("execl(" << anExe.c_str() << " , " << args[ 0 ] << " , " +// << args[ 1 ] << " , " << args[ 2 ] << " , " << args[ 3 ] +// << " , " << args[ 4 ] << ")") ; +// int status = execv( anExe.c_str() , args ) ; +// if (status == -1) { +// INFOS("Engines_Container_i::start_impl execl failed (system command status -1)") ; +// perror( "Engines_Container_i::start_impl execl error ") ; +// } +// else { +// INFOS(machineName() << " Engines_Container_i::start_impl execl done"); +// } +// exit(0) ; +// } obj = Engines::Container::_nil() ; try { @@ -274,14 +271,14 @@ Engines::Container_ptr Engines_Container_i::start_impl( obj = _NS->Resolve(cont.c_str()); nilvar = CORBA::is_nil( obj ) ; if ( nilvar ) { - INFOS(count << ". " << machineName() + MESSAGE(count << ". " << machineName() << " start_impl unknown container " << cont.c_str()); count -= 1 ; } } _numInstanceMutex.unlock() ; if ( !nilvar ) { - MESSAGE("start_impl container found after runSession(SALOME_Container)") ; + MESSAGE("start_impl container found after new launch of SALOME_Container") ; } return Engines::Container::_narrow(obj); } @@ -292,7 +289,7 @@ Engines::Container_ptr Engines_Container_i::start_impl( INFOS(machineName() << "Caught unknown exception."); } _numInstanceMutex.unlock() ; - MESSAGE("start_impl container not found after runSession(SALOME_Container)") ; + MESSAGE("start_impl container not found after new launch of SALOME_Container") ; return Engines::Container::_nil() ; } @@ -365,7 +362,7 @@ Engines::Component_ptr Engines_Container_i::load_impl( const char* nameToRegiste } } catch (...) { - MESSAGE( "Container_i::load_impl catched" ) ; + INFOS( "Container_i::load_impl catched" ) ; } //Jr _numInstanceMutex.lock() ; // lock on the add on handle_map (necessary ?) @@ -423,7 +420,7 @@ void ActSigIntHandler() { exit(0) ; } else { - INFOS(pthread_self() << "SigIntHandler activated") ; + MESSAGE(pthread_self() << "SigIntHandler activated") ; } } @@ -437,7 +434,6 @@ void SigIntHandler(int what , siginfo_t * siginfo , << " si_pid " << siginfo->si_pid) ; if ( _Sleeping ) { _Sleeping = false ; - INFOS("SigIntHandler END sleeping.") MESSAGE("SigIntHandler END sleeping.") ; return ; } @@ -448,16 +444,26 @@ void SigIntHandler(int what , siginfo_t * siginfo , } else { _Sleeping = true ; - INFOS("SigIntHandler BEGIN sleeping.") MESSAGE("SigIntHandler BEGIN sleeping.") ; int count = 0 ; while( _Sleeping ) { sleep( 1 ) ; count += 1 ; } - INFOS("SigIntHandler LEAVE sleeping after " << count << " s.") MESSAGE("SigIntHandler LEAVE sleeping after " << count << " s.") ; } return ; } } + +// Get the PID of the Container + +long Engines_Container_i::getPID() { + return(_pid); +} + +// Get the hostName of the Container + +char* Engines_Container_i::getHostName() { + return((char*)(GetHostname().c_str())); +} diff --git a/src/Container/SALOME_Container.cxx b/src/Container/SALOME_Container.cxx index 77a06b9de..921c3ce26 100644 --- a/src/Container/SALOME_Container.cxx +++ b/src/Container/SALOME_Container.cxx @@ -35,6 +35,7 @@ #include #include #include "utilities.h" +#include "Utils_CatchSignals.h" using namespace std; #ifdef CHECKTIME @@ -198,8 +199,12 @@ int main(int argc, char* argv[]) MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); timer.ShowAbsolute(); #endif + Utils_CatchSignals aCatch; + aCatch.Activate(); + orb->run(); + aCatch.Deactivate(); orb->destroy(); } catch(CORBA::SystemException&) diff --git a/src/Container/SALOME_ContainerPy.py b/src/Container/SALOME_ContainerPy.py index 6444ef148..d3d54ae13 100755 --- a/src/Container/SALOME_ContainerPy.py +++ b/src/Container/SALOME_ContainerPy.py @@ -83,11 +83,12 @@ class SALOME_ContainerPy_i (Engines__POA.Container): if container is None: MESSAGE( "SALOME_ContainerPy_i::start_impl " + str(containerName) + ".object exists but is not a Container" ) else : - MESSAGE( "SALOME_ContainerPy_i::start_impl " + str(ContainerName) + ".object found without runSession" ) + MESSAGE( "SALOME_ContainerPy_i::start_impl " + str(ContainerName) + ".object found without new launch" ) return container #shstr = os.getenv( "PWD" ) + "/" #shstr += "runSession ./SALOME_ContainerPy.py " - shstr = "runSession SALOME_ContainerPy.py " + shstr = os.getenv("KERNEL_ROOT_DIR") + "/bin/salome/SALOME_ContainerPy.py "; + #shstr = "runSession SALOME_ContainerPy.py " shstr += ContainerName # mpv: fix for SAL4731 - allways create new file to write log of server diff --git a/src/Container/SALOME_Container_i.hxx b/src/Container/SALOME_Container_i.hxx index ee6e460d5..bcb57ef22 100644 --- a/src/Container/SALOME_Container_i.hxx +++ b/src/Container/SALOME_Container_i.hxx @@ -40,6 +40,8 @@ #include #include +using namespace std; + class SALOME_NamingService; class Engines_Container_i: public POA_Engines::Container, @@ -70,6 +72,8 @@ public: char* machineName(); void ping(); bool Kill_impl() ; + char* getHostName(); + long getPID(); protected: @@ -88,6 +92,7 @@ private: int _argc ; char** _argv ; + long _pid; }; diff --git a/src/DataTypeCatalog/SALOME_DataTypeCatalog_impl.cxx b/src/DataTypeCatalog/SALOME_DataTypeCatalog_impl.cxx index fdcdd0738..1fb5f45e1 100644 --- a/src/DataTypeCatalog/SALOME_DataTypeCatalog_impl.cxx +++ b/src/DataTypeCatalog/SALOME_DataTypeCatalog_impl.cxx @@ -28,8 +28,11 @@ using namespace std; #include "SALOME_DataTypeCatalog_impl.hxx" +#include "Utils_ExceptHandlers.hxx" #include +UNEXPECT_CATCH(DTC_NotFound, SALOME_DataTypeCatalog::NotFound); + //---------------------------------------------------------------------- // Function : SALOME_DataTypeCatalogImpl // Purpose : Constructor @@ -103,7 +106,7 @@ SALOME_DataTypeCatalogImpl::isDerivedFrom(const char* type_in, const char* type_out) throw(SALOME_DataTypeCatalog::NotFound) { - + Unexpect aCatch(DTC_NotFound); CORBA::Boolean _return_value = false ; bool _found_in = false; bool _found_out = false; @@ -143,6 +146,7 @@ char* SALOME_DataTypeCatalogImpl::GetDataInterfaceRead(const char* type) throw(SALOME_DataTypeCatalog::NotFound) { + Unexpect aCatch(DTC_NotFound); char* return_value = NULL; bool _find = false; for (unsigned int ind=0; ind < _datatype_list.size();ind++) @@ -172,6 +176,7 @@ char* SALOME_DataTypeCatalogImpl::GetDataInterfaceWrite(const char* type) throw(SALOME_DataTypeCatalog::NotFound) { + Unexpect aCatch(DTC_NotFound); char* return_value = NULL; bool _find = false; for (unsigned int ind=0; ind < _datatype_list.size();ind++) @@ -199,6 +204,8 @@ SALOME_DataTypeCatalogImpl::GetDataInterfaceWrite(const char* type) SALOME_DataTypeCatalog::ListOfDataTypeName* SALOME_DataTypeCatalogImpl::GetDataTypeParents(const char* type) throw(SALOME_DataTypeCatalog::NotFound) { + Unexpect aCatch(DTC_NotFound); + bool _find = false ; SALOME_DataTypeCatalog::ListOfDataTypeName_var _list_data = @@ -347,7 +354,7 @@ SALOME_DataTypeCatalogImpl::_parseArguments(int argc, char **argv, if (strcmp(argv[ind],"-help") == 0) { - INFOS( "Usage: " << argv[0] << " -common 'path to data type catalog' -ORBInitRef NameService=corbaname::localhost"); + MESSAGE( "Usage: " << argv[0] << " -common 'path to data type catalog' -ORBInitRef NameService=corbaname::localhost"); _return_value = false ; } if (strcmp(argv[ind],"-common") == 0) diff --git a/src/GenericObj/SALOME_GenericObj_i.cc b/src/GenericObj/SALOME_GenericObj_i.cc index 93aaa9d8e..f0fdad6e0 100644 --- a/src/GenericObj/SALOME_GenericObj_i.cc +++ b/src/GenericObj/SALOME_GenericObj_i.cc @@ -30,7 +30,7 @@ using namespace SALOME; GenericObj_i::GenericObj_i(PortableServer::POA_ptr thePOA): myRefCounter(1){ - INFOS("GenericObj_i::GenericObj_i() - this = "< +using namespace std; + class HDFConvert { private: diff --git a/src/HDFPersist/HDFexception.hxx b/src/HDFPersist/HDFexception.hxx index b23d32101..5395341a8 100644 --- a/src/HDFPersist/HDFexception.hxx +++ b/src/HDFPersist/HDFexception.hxx @@ -27,6 +27,8 @@ /* Exception */ #include +using namespace std; + class HDFexception { public : diff --git a/src/LifeCycleCORBA/LifeCycleCORBA.py b/src/LifeCycleCORBA/LifeCycleCORBA.py index 9c683e51f..fe19bfdff 100644 --- a/src/LifeCycleCORBA/LifeCycleCORBA.py +++ b/src/LifeCycleCORBA/LifeCycleCORBA.py @@ -98,7 +98,8 @@ class LifeCycleCORBA: def ComputerPath(self, ComputerName ): try: - path = self._catalog.GetPathPrefix( ComputerName ) + #path = self._catalog.GetPathPrefix( ComputerName ) + path = os.getenv("KERNEL_ROOT_DIR") + "/bin/salome/" except SALOME_ModuleCatalog.NotFound, ex: path = "" return path @@ -137,14 +138,14 @@ class LifeCycleCORBA: else : rshstr = "rsh -n " + theComputer + " " path = self.ComputerPath( theComputer ) - if path != "" : - rshstr = rshstr + path + "/../bin/" - else : - rshstr = rshstr + os.getenv( "SALOME_ROOT_DIR" ) + "/bin/" +## if path != "" : +## rshstr = rshstr + path + "/../bin/" +## else : +## rshstr = rshstr + os.getenv( "KERNEL_ROOT_DIR" ) + "/bin/" if theContainer == "FactoryServer" : - rshstr = rshstr + "./runSession ./SALOME_Container " + rshstr = rshstr + path + "SALOME_Container " else : - rshstr = rshstr + "./runSession ./SALOME_ContainerPy.py '" + rshstr = rshstr + path + "SALOME_ContainerPy.py '" rshstr = rshstr + theContainer + " -" omniORBcfg = os.getenv( "OMNIORB_CONFIG" ) file = os.open( omniORBcfg , os.O_RDONLY ) @@ -177,7 +178,7 @@ class LifeCycleCORBA: return aContainer return aContainer - #os.system("rsh -n dm2s0017 /export/home/SALOME_ROOT/bin/runSession SALOME_Container -ORBInitRef NameService=corbaname::dm2s0017:1515") + #os.system("rsh -n dm2s0017 /export/home/KERNEL_ROOT/bin/runSession SALOME_Container -ORBInitRef NameService=corbaname::dm2s0017:1515") #------------------------------------------------------------------------- diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index 844d02448..e86b0c0a1 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -99,7 +99,7 @@ string SALOME_LifeCycleCORBA::ComputerPath( path = Catalog->GetPathPrefix( theComputer ); } catch (SALOME_ModuleCatalog::NotFound&) { - MESSAGE("GetPathPrefix(" << theComputer << ") not found!"); + INFOS("GetPathPrefix(" << theComputer << ") not found!"); path = "" ; } SCRUTE( path ) ; @@ -209,10 +209,10 @@ Engines::Container_var SALOME_LifeCycleCORBA::FindOrStartContainer( SCRUTE( rsh ); int status = system( rsh.c_str() ) ; if (status == -1) { - INFOS("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status -1)") ; + MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status -1)") ; } else if (status == 217) { - INFOS("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status 217)") ; + MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status 217)") ; } else { int count = 21 ; @@ -224,7 +224,7 @@ Engines::Container_var SALOME_LifeCycleCORBA::FindOrStartContainer( aFactoryServer = FindContainer( FactoryServer.c_str() ) ; } if ( CORBA::is_nil( aFactoryServer ) ) { - INFOS("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed") ; + MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed") ; } else if ( strcmp( theComputer.c_str() , GetHostname().c_str() ) ) { _FactoryServer = aFactoryServer ; @@ -367,14 +367,14 @@ Engines::Component_var SALOME_LifeCycleCORBA::FindOrLoad_Component } catch (SALOME_ModuleCatalog::NotFound&) { - MESSAGE("GetPathPrefix(" << machine << ") not found!" + INFOS("GetPathPrefix(" << machine << ") not found!" << "trying localhost"); try { path = compoInfo->GetPathPrefix("localhost") ; path += "/" ; } catch (SALOME_ModuleCatalog::NotFound&) { - MESSAGE("GetPathPrefix(localhost) not found!") ; + INFOS("GetPathPrefix(localhost) not found!") ; path = "" ; } } diff --git a/src/Loader/InquireServersQThread.cxx b/src/Loader/InquireServersQThread.cxx index b80547c9d..812a04e8d 100644 --- a/src/Loader/InquireServersQThread.cxx +++ b/src/Loader/InquireServersQThread.cxx @@ -50,7 +50,7 @@ static QString findFile( QString filename ); static QString addSlash( const QString& path ); InquireServersGUI::InquireServersGUI() - : QVBox(0, "SFA splash", Qt::WDestructiveClose | Qt::WStyle_Customize | Qt::WStyle_NoBorder ) + : QVBox(0, "SFA splash", Qt::WDestructiveClose | Qt::WStyle_Customize | Qt::WStyle_NoBorder | WType_TopLevel | WStyle_StaysOnTop | WX11BypassWM ) { myGUI = false; myThread = new InquireServersQThread(this); diff --git a/src/Logger/SALOME_Trace.py b/src/Logger/SALOME_Trace.py index ab30f3379..fd507c7c7 100644 --- a/src/Logger/SALOME_Trace.py +++ b/src/Logger/SALOME_Trace.py @@ -15,7 +15,8 @@ import time import os trace="local" -if (os.environ["SALOME_trace"] == "with_logger"): +if (os.environ.has_key("SALOME_trace")): + if (os.environ["SALOME_trace"] == "with_logger"): trace="logger" class SALOME_Trace : diff --git a/src/MPIContainer/MPIContainer_i.cxx b/src/MPIContainer/MPIContainer_i.cxx index 8201d24f0..22ba51053 100644 --- a/src/MPIContainer/MPIContainer_i.cxx +++ b/src/MPIContainer/MPIContainer_i.cxx @@ -95,8 +95,8 @@ Engines::Component_ptr MPIContainer_i::load_impl(const char* nameToRegister, 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() ; } diff --git a/src/Makefile.in b/src/Makefile.in index f35650e42..ef5ce55e6 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -33,7 +33,7 @@ VPATH=.:@srcdir@ @COMMENCE@ SUBDIRS = MSG2QM SALOMELocalTrace Logger SALOMELogger Utils PatchQt \ - GenericObj NamingService Registry \ + GenericObj MEDWrapper NamingService Registry \ ModuleCatalog DataTypeCatalog RessourcesCatalog \ Notification NOTIFICATION_SWIG \ Container TestContainer LifeCycleCORBA HDFPersist \ diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx index 35e5c2e3e..7513f9a66 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx @@ -29,6 +29,9 @@ using namespace std; #include "SALOME_ModuleCatalog_Acomponent_impl.hxx" +#include "Utils_ExceptHandlers.hxx" +UNEXPECT_CATCH(MC_NotFound, SALOME_ModuleCatalog::NotFound); + //---------------------------------------------------------------------- // Function : SALOME_ModuleCatalog_AcomponentImpl // Purpose : Constructor @@ -45,7 +48,8 @@ SALOME_ModuleCatalog_AcomponentImpl::SALOME_ModuleCatalog_AcomponentImpl( CORBA::Boolean componentmultistudy, const char* icone, SALOME_ModuleCatalog::ListOfDefInterface list_interfaces, - ListOfPathPrefix pathes) + ListOfPathPrefix pathes, + CORBA::Boolean implementationtype) { MESSAGE("Component creation") // Affect component name @@ -65,6 +69,9 @@ SALOME_ModuleCatalog_AcomponentImpl::SALOME_ModuleCatalog_AcomponentImpl( // Affect component multistudy _componentmultistudy = componentmultistudy; + + // Affect component implementation + _implementationtype = implementationtype; // Affect icone _icone =new char[strlen(icone)+1]; @@ -125,6 +132,7 @@ SALOME_ModuleCatalog::DefinitionInterface* SALOME_ModuleCatalog_AcomponentImpl::GetInterface(const char* interfacename) throw(SALOME_ModuleCatalog::NotFound) { + Unexpect aCatch( MC_NotFound ); SALOME_ModuleCatalog::DefinitionInterface_var _interface = new SALOME_ModuleCatalog::DefinitionInterface; SALOME_ModuleCatalog::Service_var _service = new SALOME_ModuleCatalog::Service; // Variables initialisation @@ -184,6 +192,7 @@ SALOME_ModuleCatalog::ListOfServices* SALOME_ModuleCatalog_AcomponentImpl::GetServiceList(const char* interfacename) throw(SALOME_ModuleCatalog::NotFound) { + Unexpect aCatch( MC_NotFound ); SALOME_ModuleCatalog::ListOfServices_var _list = new SALOME_ModuleCatalog::ListOfServices; // Variables initialisation @@ -235,6 +244,7 @@ SALOME_ModuleCatalog_AcomponentImpl::GetService(const char* interfacename, const char* servicename) throw(SALOME_ModuleCatalog::NotFound) { + Unexpect aCatch( MC_NotFound ); SALOME_ModuleCatalog::Service_var _service = new SALOME_ModuleCatalog::Service; // Varaibles initialisation bool _find = false ; @@ -287,6 +297,7 @@ SALOME_ModuleCatalog::Service* SALOME_ModuleCatalog_AcomponentImpl::GetDefaultService(const char* interfacename) throw(SALOME_ModuleCatalog::NotFound) { + Unexpect aCatch( MC_NotFound ); SALOME_ModuleCatalog::Service_var _service = new SALOME_ModuleCatalog::Service; // Variables initialisation @@ -339,6 +350,7 @@ SALOME_ModuleCatalog_AcomponentImpl::GetPathPrefix(const char* machinename) throw(SALOME_ModuleCatalog::NotFound) { MESSAGE("Begin of GetPathPrefix") + Unexpect aCatch( MC_NotFound ); // Variables initialisation char* _path = NULL; bool _find = false ; @@ -413,6 +425,15 @@ CORBA::Boolean SALOME_ModuleCatalog_AcomponentImpl::multistudy() return _componentmultistudy ; } +//---------------------------------------------------------------------- +// Function : implementation type +// Purpose : define if a component is implemeted in C++ or Python +//---------------------------------------------------------------------- +CORBA::Boolean SALOME_ModuleCatalog_AcomponentImpl::implementation_type() +{ + return _implementationtype ; +} + //---------------------------------------------------------------------- // Function : component_type // Purpose : define the type of the component @@ -445,6 +466,8 @@ SALOME_ModuleCatalog_AcomponentImpl::_duplicate_service(SALOME_ModuleCatalog::Se _service->ServiceName = CORBA::string_dup(service.ServiceName); // service by default _service->Servicebydefault = service.Servicebydefault; + // type of node + _service->TypeOfNode = service.TypeOfNode; // in Parameters service unsigned int _length_in_param = service.ServiceinParameter.length(); diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx index 0a7c715d5..40d202307 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx @@ -46,7 +46,8 @@ public: CORBA::Boolean componentmultistudy, const char* icone, SALOME_ModuleCatalog::ListOfDefInterface list_interfaces, - ListOfPathPrefix pathes); + ListOfPathPrefix pathes, + CORBA::Boolean implementationtype); //! standard destructor virtual ~SALOME_ModuleCatalog_AcomponentImpl(); @@ -141,6 +142,12 @@ public: */ virtual char* component_icone(); + //! method to define if a component is implemented in C++ or Python + /*! + \return true if it's C++ component + */ + virtual CORBA::Boolean implementation_type(); + private : char* _component_name ; char* _component_user_name ; @@ -148,6 +155,7 @@ private : char* _icone; SALOME_ModuleCatalog::ComponentType _componenttype; CORBA::Boolean _componentmultistudy; + CORBA::Boolean _implementationtype; SALOME_ModuleCatalog::ListOfDefInterface _list_interfaces; ListOfPathPrefix _pathes ; diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx index 8f8f0e241..fa8d3f749 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx @@ -48,12 +48,15 @@ SALOME_ModuleCatalog_Handler::SALOME_ModuleCatalog_Handler() test_component_type = "component-type" ; test_component_multistudy="component-multistudy"; test_component_icone="component-icone" ; + test_component_impltype="component-impltype"; test_interface_name = "component-interface-name" ; test_service_name = "service-name"; test_defaultservice = "service-by-default"; + test_typeofnode = "type-of-node"; + test_inParameter_type="inParameter-type"; test_inParameter_name="inParameter-name"; test_inParameter="inParameter"; @@ -189,6 +192,10 @@ bool SALOME_ModuleCatalog_Handler::endElement(const QString&, if((qName.compare(QString(test_component_multistudy))==0)) _amodule.Parsercomponentmultistudy = atoi(content.c_str()) ; + // tag test_component_impltype + if((qName.compare(QString(test_component_impltype))==0)) + _amodule.Parsercomponentimpltype = atoi(content.c_str()) ; + // tag test_component_icone if((qName.compare(QString(test_component_icone))==0)) _amodule.Parsercomponenticone = content ; @@ -209,6 +216,10 @@ bool SALOME_ModuleCatalog_Handler::endElement(const QString&, if((qName.compare(QString(test_defaultservice))==0)) _aService.ParserServicebydefault = atoi(content.c_str()) ; + //tag test_typeofnode + if((qName.compare(QString(test_typeofnode))==0)) + _aService.ParserTypeOfNode = atoi(content.c_str()) ; + // Parameter in // tag test_inParameter_type @@ -268,6 +279,7 @@ bool SALOME_ModuleCatalog_Handler::endElement(const QString&, // Empty temporary structures _aService.ParserServiceName = ""; + _aService.ParserTypeOfNode = 1; _aService.ParserServiceinParameter.resize(0); _aService.ParserServiceoutParameter.resize(0); } diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx index c12c49cef..48c9e1cb3 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx @@ -115,11 +115,13 @@ private: const char* test_component_type ; const char* test_component_multistudy ; const char* test_component_icone ; + const char* test_component_impltype ; const char* test_interface_name; const char* test_service_name; const char* test_defaultservice; + const char* test_typeofnode; const char* test_inParameter_type; const char* test_inParameter_name; diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx index 236763abb..654b8fb0f 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx @@ -57,6 +57,7 @@ struct ParserService ListOfParserServicesParameter ParserServiceinParameter; ListOfParserServicesParameter ParserServiceoutParameter; bool ParserServicebydefault; + bool ParserTypeOfNode; } ; typedef vector ListOfParserServices ; @@ -78,6 +79,7 @@ struct ParserComponent string Parsercomponenticone; ListOfDefinitionInterface ParserListInterface; string Parserconstraint ; + bool Parsercomponentimpltype ; }; typedef vector ListOfParserComponent ; diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx index c206cc846..85104043a 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx @@ -88,7 +88,7 @@ int main(int argc,char **argv) } catch( CORBA::COMM_FAILURE& ) { - MESSAGE( "Module Catalog Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); + INFOS( "Module Catalog Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); } if (!CORBA::is_nil(theObj)) { @@ -109,11 +109,11 @@ int main(int argc,char **argv) object = inc->resolve(name);} catch(CosNaming::NamingContext::NotFound) { - MESSAGE( "Logger Server wasn't found" ); + INFOS( "Logger Server wasn't found" ); } catch(...) { - MESSAGE( "Module Catalog Server: Unknown exception" ) ; + INFOS( "Module Catalog Server: Unknown exception" ) ; } if (!CORBA::is_nil(object)) { diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx index 9f912a7d3..04efd4244 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx @@ -399,6 +399,7 @@ SALOME_ModuleCatalogImpl::GetComponent(const char* componentname) CORBA::Boolean _componentmultistudy = false ; // default initialisation ListOfPathPrefix _pathes ; _pathes.resize(0); + CORBA::Boolean _implementationtype = true ; // default initialisation bool find = false ; @@ -464,6 +465,8 @@ SALOME_ModuleCatalogImpl::GetComponent(const char* componentname) // get pathes prefix _pathes = duplicate_pathes(_personal_path_list); + // get implementation type + _implementationtype = _personal_module_list[ind].Parsercomponentimpltype; } } @@ -477,7 +480,8 @@ SALOME_ModuleCatalogImpl::GetComponent(const char* componentname) _componentmultistudy, _icone, _list_interfaces, - _pathes); + _pathes, + _implementationtype); compo = aComponentImpl->_this(); } @@ -528,6 +532,9 @@ SALOME_ModuleCatalogImpl::GetComponent(const char* componentname) // get component multistudy _componentmultistudy = _general_module_list[ind].Parsercomponentmultistudy ; + // get implementation type + _implementationtype = _general_module_list[ind].Parsercomponentimpltype ; + // get component icone _icone = CORBA::string_dup(_general_module_list[ind].Parsercomponenticone.c_str()); @@ -552,7 +559,8 @@ SALOME_ModuleCatalogImpl::GetComponent(const char* componentname) _componentmultistudy, _icone, _list_interfaces, - _pathes); + _pathes, + _implementationtype); compo = aComponentImpl->_this(); } @@ -623,6 +631,10 @@ SALOME_ModuleCatalogImpl::duplicate_interfaces(ListOfDefinitionInterface list_in _list_interfaces[ind].interfaceservicelist[ind1].Servicebydefault = list_interface[ind].Parserinterfaceservicelist[ind1].ParserServicebydefault; + // duplicate type of node + _list_interfaces[ind].interfaceservicelist[ind1].TypeOfNode = + list_interface[ind].Parserinterfaceservicelist[ind1].ParserTypeOfNode; + // 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); @@ -740,7 +752,7 @@ SALOME_ModuleCatalogImpl::_parseArguments(int argc, char **argv, if (strcmp(argv[ind],"-help") == 0) { - INFOS( "Usage: " << argv[0] << " -common 'path to general catalog' -personal 'path to personal catalog' -ORBInitRef NameService=corbaname::localhost"); + MESSAGE( "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) diff --git a/src/ModuleGenerator/IDLparser.py b/src/ModuleGenerator/IDLparser.py index 1743563c6..09f777f7d 100644 --- a/src/ModuleGenerator/IDLparser.py +++ b/src/ModuleGenerator/IDLparser.py @@ -36,7 +36,8 @@ common_data={"AUTHOR" : "", "COMP_TYPE" : "", "COMP_NAME" : "", "COMP_UNAME" : "", - "COMP_MULT" : "" + "COMP_MULT" : "", + "COMP_IMPL" : "" } nb_components = 0 @@ -237,6 +238,7 @@ class Service(Tree): self.addNamedChild('service-version',common_data["VERSION"]) self.addNamedChild('service-comment', comment) self.addNamedChild('service-by-default', "0") + self.addNamedChild('type-of-node', "1") self.addNamedChild('inParameter-list') self.addNamedChild('outParameter-list') @@ -394,6 +396,7 @@ class Component(Tree): self.addNamedChild('component-version', common_data["VERSION"]) self.addNamedChild('component-comment', 'unknown') self.addNamedChild('component-multistudy', common_data["COMP_MULT"]) + self.addNamedChild('component-impltype', common_data["COMP_IMPL"]) self.addNamedChild('component-icone', common_data["ICON"]) self.addNamedChild('constraint') self.addNamedChild('component-interface-list') @@ -665,6 +668,7 @@ def run(tree, args): common_data["COMP_UNAME"] = getParamValue("username", "", args) common_data["COMP_TYPE"] = getParamValue("type", "OTHER", args) common_data["COMP_MULT"] = getParamValue("multistudy", "1", args) + common_data["COMP_IMPL"] = getParamValue("impltype", "1", args) print common_data diff --git a/src/ModuleGenerator/README b/src/ModuleGenerator/README index c5b46c91f..34c4a62da 100644 --- a/src/ModuleGenerator/README +++ b/src/ModuleGenerator/README @@ -70,8 +70,8 @@ ou vaut 1, 1b, 2, 3, 4, 5 Les scripts de test se trouvent dans le repertoire - /SALOME/src/ModuleGenerator/tests + /src/ModuleGenerator/tests Les fichiers idl servant aux tests se trouvent dans les repertoires - /idl - /SALOME/src/ModuleGenerator/tests + /idl + /src/ModuleGenerator/tests diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx index c4865c196..6fe58e93c 100644 --- a/src/NamingService/SALOME_NamingService.cxx +++ b/src/NamingService/SALOME_NamingService.cxx @@ -183,7 +183,7 @@ void SALOME_NamingService::Register(CORBA::Object_ptr ObjRef, _temp_context = _current_context->bind_new_context(_context_name); _current_context = _temp_context; - //MESSAGE("This context was'nt created, it's now done"); + //INFOS("This context was'nt created, it's now done"); } } } @@ -456,7 +456,7 @@ bool SALOME_NamingService::Create_Directory(const char* Path) _temp_context = _current_context->bind_new_context(_context_name); _current_context = _temp_context; - MESSAGE("This context was'nt created, it's now done"); + INFOS("This context was'nt created, it's now done"); } } } @@ -563,31 +563,31 @@ bool SALOME_NamingService::Change_Directory(const char* Path) _return_code = false; CosNaming::Name n = ex.rest_of_name; if (ex.why == CosNaming::NamingContext::missing_node) - MESSAGE( "Change_Directory() : " << (char *) n[0].id + INFOS( "Change_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") not found") if (ex.why == CosNaming::NamingContext::not_context) - MESSAGE("Change_Directory() : " << (char *) n[0].id + INFOS("Change_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not a context" ) if (ex.why == CosNaming::NamingContext::not_object) - MESSAGE( "Change_Directory() : " << (char *) n[0].id + INFOS( "Change_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not an object" ) } catch(CosNaming::NamingContext::CannotProceed&) { _return_code = false; - MESSAGE( "!!!Change_Directory() : CosNaming::NamingContext::CannotProceed" ) + INFOS( "!!!Change_Directory() : CosNaming::NamingContext::CannotProceed" ) } catch(CosNaming::NamingContext::InvalidName&) { _return_code = false; - MESSAGE( "!!!Change_Directory() : CosNaming::NamingContext::InvalidName" ) + INFOS( "!!!Change_Directory() : CosNaming::NamingContext::InvalidName" ) } catch(CORBA::COMM_FAILURE&) { _return_code = false; - MESSAGE( "!!!Change_Directory() :CORBA::COMM_FAILURE : unable to contact" + INFOS( "!!!Change_Directory() :CORBA::COMM_FAILURE : unable to contact" << "the naming service") throw ServiceUnreachable(); } @@ -631,7 +631,7 @@ char* SALOME_NamingService::Current_Directory() } catch(CORBA::COMM_FAILURE&) { - MESSAGE("!!!Current_Directory(): CORBA::COMM_FAILURE : unable to contact" + INFOS("!!!Current_Directory(): CORBA::COMM_FAILURE : unable to contact" << " the naming service" ) throw ServiceUnreachable(); } @@ -685,7 +685,7 @@ void SALOME_NamingService::list() } catch (ServiceUnreachable&) { - MESSAGE( "!!!list(): ServiceUnreachable" ) + INFOS( "!!!list(): ServiceUnreachable" ) throw ServiceUnreachable(); } @@ -777,28 +777,28 @@ void SALOME_NamingService::Destroy_Name(const char* Path) { CosNaming::Name n = ex.rest_of_name; if (ex.why == CosNaming::NamingContext::missing_node) - MESSAGE( "Destroy_Name() : " << (char *) n[0].id + INFOS( "Destroy_Name() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") not found" ) if (ex.why == CosNaming::NamingContext::not_context) - MESSAGE( "Destroy_Name() : " << (char *) n[0].id + INFOS( "Destroy_Name() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not a context" ) if (ex.why == CosNaming::NamingContext::not_object) - MESSAGE( "Destroy_Name() : " << (char *) n[0].id + INFOS( "Destroy_Name() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not an object" ) } catch (CosNaming::NamingContext::InvalidName &) { - MESSAGE( "!!!Destroy_Name() : CosNaming::NamingContext::InvalidName" ) + INFOS( "!!!Destroy_Name() : CosNaming::NamingContext::InvalidName" ) } catch (CosNaming::NamingContext::CannotProceed &) { - MESSAGE( "!!!Destroy_Name(): CosNaming::NamingContext::CannotProceed" ) + INFOS( "!!!Destroy_Name(): CosNaming::NamingContext::CannotProceed" ) } catch(CORBA::COMM_FAILURE&) { - MESSAGE( "!!!Destroy_Name() : CORBA::COMM_FAILURE : unable to contact" + INFOS( "!!!Destroy_Name() : CORBA::COMM_FAILURE : unable to contact" << " the naming service") throw ServiceUnreachable(); } @@ -821,28 +821,28 @@ void SALOME_NamingService::Destroy_Name(const char* Path) { CosNaming::Name n = ex.rest_of_name; if (ex.why == CosNaming::NamingContext::missing_node) - MESSAGE( "Destroy_Name() : " << (char *) n[0].id + INFOS( "Destroy_Name() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") not found" ) if (ex.why == CosNaming::NamingContext::not_context) - MESSAGE( "Destroy_Name() : " << (char *) n[0].id + INFOS( "Destroy_Name() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not a context" ) if (ex.why == CosNaming::NamingContext::not_object) - MESSAGE( "Destroy_Name() : " << (char *) n[0].id + INFOS( "Destroy_Name() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not an object" ) } catch(CosNaming::NamingContext::CannotProceed&) { - MESSAGE( "!!!Destroy_Name() : CosNaming::NamingContext::CannotProceed") + INFOS( "!!!Destroy_Name() : CosNaming::NamingContext::CannotProceed") } catch(CosNaming::NamingContext::InvalidName&) { - MESSAGE( "!!!Destroy_Name() : CosNaming::NamingContext::InvalidName") + INFOS( "!!!Destroy_Name() : CosNaming::NamingContext::InvalidName") } catch(CORBA::COMM_FAILURE&) { - MESSAGE( "!!!Destroy_Name() :CORBA::COMM_FAILURE : unable to contact" + INFOS( "!!!Destroy_Name() :CORBA::COMM_FAILURE : unable to contact" << " the naming service") throw ServiceUnreachable(); } @@ -900,28 +900,28 @@ void SALOME_NamingService::Destroy_Directory(const char* Path) { CosNaming::Name n = ex.rest_of_name; if (ex.why == CosNaming::NamingContext::missing_node) - MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + INFOS( "Destroy_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") not found") if (ex.why == CosNaming::NamingContext::not_context) - MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + INFOS( "Destroy_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not a context" ) if (ex.why == CosNaming::NamingContext::not_object) - MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + INFOS( "Destroy_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not an object" ) } catch (CosNaming::NamingContext::InvalidName &) { - MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName" ) + INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName" ) } catch (CosNaming::NamingContext::CannotProceed &) { - MESSAGE("!!!Destroy_Directory(): CosNaming::NamingContext::CannotProceed" ) + INFOS("!!!Destroy_Directory(): CosNaming::NamingContext::CannotProceed" ) } catch(CORBA::COMM_FAILURE&) { - MESSAGE( "!!!Destroy_Directory() : CORBA::COMM_FAILURE : unable to contact" + INFOS( "!!!Destroy_Directory() : CORBA::COMM_FAILURE : unable to contact" << " the naming service" ) throw ServiceUnreachable(); } @@ -944,28 +944,28 @@ void SALOME_NamingService::Destroy_Directory(const char* Path) { CosNaming::Name n = ex.rest_of_name; if (ex.why == CosNaming::NamingContext::missing_node) - MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + INFOS( "Destroy_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") not found" ) if (ex.why == CosNaming::NamingContext::not_context) - MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + INFOS( "Destroy_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not a context" ) if (ex.why == CosNaming::NamingContext::not_object) - MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + INFOS( "Destroy_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not an object" ) } catch (CosNaming::NamingContext::InvalidName &) { - MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName" ) + INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName" ) } catch (CosNaming::NamingContext::CannotProceed &) { - MESSAGE( "!!!Destroy_Directory(): CosNaming::NamingContext::CannotProceed" ) + INFOS( "!!!Destroy_Directory(): CosNaming::NamingContext::CannotProceed" ) } catch(CORBA::COMM_FAILURE&) { - MESSAGE( "!!!Destroy_Directory() : CORBA::COMM_FAILURE : unable to contact" + INFOS( "!!!Destroy_Directory() : CORBA::COMM_FAILURE : unable to contact" << " the naming service" ) throw ServiceUnreachable(); } @@ -979,12 +979,12 @@ void SALOME_NamingService::Destroy_Directory(const char* Path) } catch(CosNaming::NamingContext::NotEmpty&) { - MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::NoEmpty " + INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::NoEmpty " << Path << " is not empty" ) } catch(CORBA::COMM_FAILURE&) { - MESSAGE( "!!!Destroy_Directory() :CORBA::COMM_FAILURE : " + INFOS( "!!!Destroy_Directory() :CORBA::COMM_FAILURE : " << "unable to contact the naming service") throw ServiceUnreachable(); } @@ -999,28 +999,28 @@ void SALOME_NamingService::Destroy_Directory(const char* Path) { CosNaming::Name n = ex.rest_of_name; if (ex.why == CosNaming::NamingContext::missing_node) - MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + INFOS( "Destroy_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") not found" ) if (ex.why == CosNaming::NamingContext::not_context) - MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + INFOS( "Destroy_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not a context" ) if (ex.why == CosNaming::NamingContext::not_object) - MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + INFOS( "Destroy_Directory() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") is not an object" ) } catch(CosNaming::NamingContext::CannotProceed&) { - MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::CannotProceed") + INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::CannotProceed") } catch(CosNaming::NamingContext::InvalidName&) { - MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName") + INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName") } catch(CORBA::COMM_FAILURE&) { - MESSAGE( "!!!Destroy_Directory() :CORBA::COMM_FAILURE : unable to contact" + INFOS( "!!!Destroy_Directory() :CORBA::COMM_FAILURE : unable to contact" << " the naming service") throw ServiceUnreachable(); } diff --git a/src/OBJECT/SALOME_Actor.cxx b/src/OBJECT/SALOME_Actor.cxx index db7a30cf2..31f2c3026 100644 --- a/src/OBJECT/SALOME_Actor.cxx +++ b/src/OBJECT/SALOME_Actor.cxx @@ -33,9 +33,9 @@ #include "SALOME_Actor.h" #include "SALOME_Transform.h" +#include "SALOME_GeometryFilter.h" #include "SALOME_TransformFilter.h" #include "SALOME_PassThroughFilter.h" -#include "SALOME_GeometryFilter.h" // SALOME Includes #include "utilities.h" @@ -44,11 +44,6 @@ #include #include #include -#include - -// For test -#include -#include "vtkTimerLog.h" using namespace std; @@ -57,35 +52,91 @@ 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; + myPassFilter.at(anId)->SetInput(theMapper->GetInput()); + myGeomFilter->SetStoreMapping(myStoreMapping); + myGeomFilter->SetInput(myPassFilter.at(anId)->GetOutput()); + + anId++; + myPassFilter.at(anId)->SetInput(myGeomFilter->GetOutput()); + myPassFilter.at(anId+1)->SetInput(myPassFilter.at(anId)->GetOutput()); + + anId++; + myPassFilter.at(anId+1)->SetInput(myPassFilter.at(anId)->GetOutput()); + + anId++; + myTransformFilter->SetInput(myPassFilter.at(anId)->GetPolyDataOutput()); + + anId++; + myPassFilter.at(anId)->SetInput(myTransformFilter->GetOutput()); + myPassFilter.at(anId+1)->SetInput(myPassFilter.at(anId)->GetOutput()); + + anId++; if(vtkDataSetMapper* aMapper = dynamic_cast(theMapper)) - aMapper->SetInput(myPassFilter[3]->GetPolyDataOutput()); + aMapper->SetInput(myPassFilter.at(anId)->GetOutput()); else if(vtkPolyDataMapper* aMapper = dynamic_cast(theMapper)) - aMapper->SetInput(myPassFilter[3]->GetPolyDataOutput()); + aMapper->SetInput(myPassFilter.at(anId)->GetPolyDataOutput()); } vtkLODActor::SetMapper(theMapper); } -void SALOME_Actor::SetTransform(SALOME_Transform* theTransform){ - myTransformFilter->SetTransform(theTransform); +vtkPolyData* SALOME_Actor::GetPolyDataInput(){ + return myPassFilter.back()->GetPolyDataOutput(); } @@ -109,47 +160,71 @@ void SALOME_Actor::SetRepresentation(int theMode) { GetProperty()->DeepCopy(myProperty); break; default: + break; GetProperty()->SetAmbient(1.0); GetProperty()->SetDiffuse(0.0); GetProperty()->SetSpecular(0.0); } switch(theMode){ case 3 : - myPassFilter[0]->SetInside(true); + myGeomFilter->SetInside(true); GetProperty()->SetRepresentation(1); break; case 0 : GetProperty()->SetPointSize(SALOME_POINT_SIZE); default : GetProperty()->SetRepresentation(theMode); - myPassFilter[0]->SetInside(false); + myGeomFilter->SetInside(false); } myRepresentation = theMode; } + int SALOME_Actor::GetRepresentation(){ return myRepresentation; } - -SALOME_Actor::SALOME_Actor(){ - PreviewProperty = NULL; - ispreselected = Standard_False; - myProperty = vtkProperty::New(); - myRepresentation = 2; - myTransformFilter = SALOME_TransformFilter::New(); - myPassFilter.push_back(SALOME_PassThroughFilter::New()); - myPassFilter.push_back(SALOME_PassThroughFilter::New()); - myPassFilter.push_back(SALOME_PassThroughFilter::New()); - myPassFilter.push_back(SALOME_PassThroughFilter::New()); -} - -SALOME_Actor::~SALOME_Actor(){ - myTransformFilter->Delete(); - SetPreviewProperty(NULL); - for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++) - if(myPassFilter[i] != NULL){ - myPassFilter[i]->UnRegisterAllOutputs(); - myPassFilter[i]->Delete(); +//================================================================================= +// function : GetObjDimension +// purpose : Return object dimension. +// Virtual method shoulb be redifined by derived classes +//================================================================================= +int SALOME_Actor::GetObjDimension( const int theObjId ) +{ + if ( theObjId < 0 ) + return 0; + + std::vector aVtkList = GetVtkId( theObjId ); + int nbVtk = aVtkList.size(); + + if ( nbVtk == 0 ) + return 0; + else if ( nbVtk > 1 ) + return 3; + else // nbVtk = 1 + { + if ( vtkDataSet* aGrid = GetMapper()->GetInput() ) + { + if ( vtkCell* aCell = aGrid->GetCell( aVtkList.front() ) ) + return aCell->GetCellDimension(); } - myProperty->Delete(); + } + return 0; } + + + + + + + + + + + + + + + + + + diff --git a/src/OBJECT/SALOME_Actor.h b/src/OBJECT/SALOME_Actor.h index 03758fee9..08a15bd4e 100644 --- a/src/OBJECT/SALOME_Actor.h +++ b/src/OBJECT/SALOME_Actor.h @@ -32,12 +32,11 @@ // SALOME Includes #include "VTKViewer_Common.h" #include "SALOME_InteractiveObject.hxx" -#ifndef _Handle_SALOME_InteractiveObject_HeaderFile -#include "Handle_SALOME_InteractiveObject.hxx" -#endif -#include + +#include class SALOME_Transform; +class SALOME_GeometryFilter; class SALOME_TransformFilter; class SALOME_PassThroughFilter; @@ -54,22 +53,6 @@ class SALOME_Actor : public vtkLODActor{ vtkTypeMacro(SALOME_Actor,vtkLODActor); - // Description: - // This causes the actor to be rendered. It, in turn, will render the actor`s - // property and then mapper. - //virtual void Render(vtkRenderer *, vtkMapper *); - - // Description: - // This method is used internally by the rendering process. - // We overide the superclass method to properly set the estimated render time. - //virtual int RenderOpaqueGeometry(vtkViewport *viewport); - - // Description: - // Release any graphics resources that are being consumed by this actor. - // The parameter window could be used to determine which graphic - // resources to release. - //virtual void ReleaseGraphicsResources(vtkWindow *); - virtual Standard_Boolean hasIO() { return !myIO.IsNull(); } virtual Handle_SALOME_InteractiveObject getIO() { return myIO; } virtual void setIO(const Handle(SALOME_InteractiveObject)& io) { myIO = io; } @@ -103,10 +86,16 @@ class SALOME_Actor : public vtkLODActor{ virtual void AddToRender(vtkRenderer* theRenderer); virtual void RemoveFromRender(vtkRenderer* theRenderer); - virtual vtkPolyData* GetPolyDataInput(); + typedef std::vector TVectorId; + virtual int GetObjId(int theVtkID) { return -1;} + virtual TVectorId GetVtkId(int theObjID) { return TVectorId();} + + virtual int GetObjDimension( const int theObjId ); + virtual void SetMapper(vtkMapper* theMapper); - virtual void SetTransform(SALOME_Transform* theTransform); + virtual vtkPolyData* GetPolyDataInput(); + virtual void SetTransform(SALOME_Transform* theTransform); virtual unsigned long int GetMTime(); virtual void SetRepresentation(int theMode); @@ -114,24 +103,27 @@ class SALOME_Actor : public vtkLODActor{ // Infinitive means actor without size (point for example // which is not taken into account in calculation of boundaries of the scene - virtual bool IsInfinitive() { return false; } + virtual bool IsInfinitive() { return myIsInfinite; } protected: vtkProperty *PreviewProperty; Standard_Boolean ispreselected; - Handle_SALOME_InteractiveObject myIO; + Handle(SALOME_InteractiveObject) myIO; Standard_CString myName; float m_opacity; Standard_Boolean ishighlighted; int myDisplayMode; + bool myIsInfinite; - SALOME_Transform *myTransform; - std::vector myPassFilter; + bool myStoreMapping; + SALOME_GeometryFilter *myGeomFilter; SALOME_TransformFilter *myTransformFilter; - vtkProperty *myProperty; + std::vector myPassFilter; + int myRepresentation; + vtkProperty *myProperty; }; #endif // SALOME_ACTOR_H diff --git a/src/OCCViewer/OCCViewer_ViewFrame.h b/src/OCCViewer/OCCViewer_ViewFrame.h index 61125300f..46bdb4af7 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.h +++ b/src/OCCViewer/OCCViewer_ViewFrame.h @@ -31,6 +31,7 @@ #include "OCCViewer_ViewPort.h" #include "QAD_ViewFrame.h" +#include "SALOME_Selection.h" class OCCViewer_Viewer3d; class QAD_EXPORT OCCViewer_ViewFrame : public QAD_ViewFrame @@ -64,7 +65,7 @@ class QAD_EXPORT OCCViewer_ViewFrame : public QAD_ViewFrame void setCursor( const QCursor& ); QCursor cursor() const; - void SetSelectionMode( int mode ) {}; + void SetSelectionMode( Selection_Mode mode ) {}; /* popup management */ void setPopupServer( QAD_Application* ); diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx index 88601ea0b..1782f8785 100644 --- a/src/OCCViewer/OCCViewer_ViewPort3d.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort3d.cxx @@ -295,10 +295,11 @@ void OCCViewer_ViewPort3d::setBackgroundColor( const QColor& color) myActiveView->SetBackgroundColor( Quantity_TOC_RGB, color.red()/255., color.green()/255., color.blue()/255.); + /* VSR : PAL5420 --------------------------------------------------- QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorRed", color.red() ); QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorGreen", color.green() ); QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorBlue", color.blue() ); - + VSR : PAL5420 --------------------------------------------------- */ myActiveView->Update(); } } diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index b5d094b9f..a2a03544d 100644 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -233,6 +234,13 @@ void Plot2d_ViewFrame::createActions() fitDataAction->setStatusTip ( tr( "PRP_PLOT2D_FITDATA" ) ); myActions.insert( FitDataId, fitDataAction ); connect( fitDataAction, SIGNAL( activated() ), this, SLOT( onFitData() ) ); + + // Change background + QActionP* changeBGAction = new QActionP ( tr( "TOT_PLOT2D_CHANGE_BACKGROUND"), + tr( "MEN_PLOT2D_CHANGE_BACKGROUND" ), 0, this ); + fitDataAction->setStatusTip ( tr( "PRP_PLOT2D_CHANGE_BACKGROUND" ) ); + myActions.insert( ChangeBackgroundId, changeBGAction ); + connect( changeBGAction, SIGNAL( activated() ), this, SLOT( onChangeBackground() ) ); } /*! Gets window's central widget @@ -274,6 +282,9 @@ void Plot2d_ViewFrame::onCreatePopup() // settings myPopup->insertSeparator(); myActions[ SettingsId ]->addTo( myPopup ); + // Change background + myPopup->insertSeparator(); + myActions[ ChangeBackgroundId ]->addTo( myPopup ); } } /*! @@ -523,11 +534,59 @@ void Plot2d_ViewFrame::writePreferences() */ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt ) { - QString info; - info.sprintf( "X : %g\tY : %g", - myPlot->invTransform( QwtPlot::xBottom, pnt.x() ), - myPlot->invTransform( QwtPlot::yLeft, pnt.y() ) ); - info = tr( "INF_COORDINATES" ) + " : " + info; + bool xFound = false, yFound = false; + double xCoord, yCoord; + const QwtScaleDiv* aXscale = myPlot->axisScale( QwtPlot::xBottom ); + for ( int i = 0; i < aXscale->majCnt(); i++ ) { + double majXmark = aXscale->majMark( i ); + int xmark = myPlot->transform( QwtPlot::xBottom, majXmark ); + if ( xmark-2 == pnt.x() ) { + xCoord = majXmark; + xFound = true; + MESSAGE("Plot2d_ViewFrame::getInfo : close maj X mark("<minCnt(); i++ ) { + double minXmark = aXscale->minMark( i ); + int xmark = myPlot->transform( QwtPlot::xBottom, minXmark ); + if ( xmark-2 == pnt.x() ) { + xCoord = minXmark; + xFound = true; + MESSAGE("Plot2d_ViewFrame::getInfo : close min X mark("<axisScale( QwtPlot::yLeft ); + for ( int i = 0; i < aYscale->majCnt(); i++ ) { + double majYmark = aYscale->majMark( i ); + int ymark = myPlot->transform( QwtPlot::yLeft, majYmark ); + if ( ymark-2 == pnt.y() ) { + yCoord = majYmark; + yFound = true; + break; + } + } + if ( !yFound ) { + for ( int i = 0; i < aYscale->minCnt(); i++ ) { + double minYmark = aYscale->minMark( i ); + int ymark = myPlot->transform( QwtPlot::yLeft, minYmark ); + if ( ymark-2 == pnt.y() ) { + yCoord = minYmark; + yFound = true; + break; + } + } + } + QString strX = QString::number( xFound ? xCoord : myPlot->invTransform( QwtPlot::xBottom, pnt.x() ) ).stripWhiteSpace(); + if ( strX == "-0" ) + strX = "0"; + QString strY = QString::number( yFound ? yCoord : myPlot->invTransform( QwtPlot::yLeft, pnt.y() ) ).stripWhiteSpace(); + if ( strY == "-0" ) + strY = "0"; + QString info = tr("INF_COORDINATES").arg( strX ).arg( strY ); return info; } /*! @@ -1082,6 +1141,16 @@ void Plot2d_ViewFrame::onFitData() } delete dlg; } +/*! + Change background color +*/ +void Plot2d_ViewFrame::onChangeBackground() +{ + QColor selColor = QColorDialog::getColor ( backgroundColor(), this ); + if ( selColor.isValid() ) { + setBackgroundColor( selColor ); + } +} /*! Sets curve type */ diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index ee92ee7ba..40e41b357 100644 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -15,6 +15,7 @@ #include "QAD_Action.h" #include "Plot2d_Curve.h" #include "Plot2d_CurveContainer.h" +#include "SALOME_Selection.h" #include #include #include @@ -34,7 +35,7 @@ class QAD_EXPORT Plot2d_ViewFrame : public QAD_ViewFrame, public QAD_PopupClient enum { NoOpId, FitAllId, FitAreaId, ZoomId, PanId, DumpId, ModeXLinearId, ModeXLogarithmicId, ModeYLinearId, ModeYLogarithmicId, - LegendId, CurvePointsId, CurveLinesId, CurveSplinesId, SettingsId, FitDataId }; + LegendId, CurvePointsId, CurveLinesId, CurveSplinesId, SettingsId, FitDataId, ChangeBackgroundId }; public: /* Construction/destruction */ Plot2d_ViewFrame( QWidget* parent, const QString& title = "" ); @@ -44,7 +45,7 @@ public: /* inherited */ ViewType getTypeView() const { return VIEW_PLOT2D; } QWidget* getViewWidget(); - void SetSelectionMode( int mode ) {} + void SetSelectionMode( Selection_Mode mode ) {} void onAdjustTrihedron( ) {} /* popup management */ @@ -145,6 +146,7 @@ public slots: void onCurves(); void onSettings(); void onFitData(); + void onChangeBackground(); protected slots: void onLegendClicked( long key ); diff --git a/src/Registry/RegistryService.hxx b/src/Registry/RegistryService.hxx index 0144b59b3..3c26d92b7 100644 --- a/src/Registry/RegistryService.hxx +++ b/src/Registry/RegistryService.hxx @@ -34,6 +34,7 @@ # include +using namespace std; class RegistryService : public POA_Registry::Components //, public PortableServer::RefCountServantBase { diff --git a/src/RegistryDisplay/RegWidget.cxx b/src/RegistryDisplay/RegWidget.cxx index afc79eac9..c7a16048f 100644 --- a/src/RegistryDisplay/RegWidget.cxx +++ b/src/RegistryDisplay/RegWidget.cxx @@ -621,8 +621,8 @@ QString findFile( QString filename ) return fileInfo.filePath(); } } - // Try ${SALOME_ROOT_DIR}/share/salome/resources directory - cenv = getenv( "SALOME_ROOT_DIR" ); + // Try ${KERNEL_ROOT_DIR}/share/salome/resources directory + cenv = getenv( "KERNEL_ROOT_DIR" ); if ( cenv ) { dir.sprintf( "%s", cenv ); if ( !dir.isEmpty() ) { diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx index e9a16146c..4275a4924 100644 --- a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx @@ -87,7 +87,7 @@ int main(int argc,char **argv) } catch( CORBA::COMM_FAILURE& ) { - MESSAGE( "Ressources Catalog: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); + INFOS( "Ressources Catalog: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); } if(!CORBA::is_nil(inc)) { @@ -103,11 +103,11 @@ int main(int argc,char **argv) } catch(CosNaming::NamingContext::NotFound) { - MESSAGE( "Ressources Catalog: Logger Server wasn't found" ); + INFOS( "Ressources Catalog: Logger Server wasn't found" ); } catch(...) { - MESSAGE( "Ressources Catalog: Unknown exception" ); + INFOS( "Ressources Catalog: Unknown exception" ); } if (!CORBA::is_nil(object)) { diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_impl.cxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_impl.cxx index d0d277749..cc819e495 100644 --- a/src/RessourcesCatalog/SALOME_RessourcesCatalog_impl.cxx +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_impl.cxx @@ -29,6 +29,9 @@ using namespace std; #include "SALOME_RessourcesCatalog_impl.hxx" #include +#include "Utils_ExceptHandlers.hxx" +UNEXPECT_CATCH(RC_NotFound, SALOME_RessourcesCatalog::NotFound); + //---------------------------------------------------------------------- // Function : SALOME_RessourcesCatalogImpl // Purpose : Constructor @@ -95,6 +98,7 @@ SALOME_RessourcesCatalog::ListOfContainerType* SALOME_RessourcesCatalogImpl::GetContainerTypeList(const char* computer) throw(SALOME_RessourcesCatalog::NotFound) { + Unexpect aCatch(RC_NotFound); MESSAGE("Begin of GetContainerTypeList"); SALOME_RessourcesCatalog::ListOfContainerType_var _list = new SALOME_RessourcesCatalog::ListOfContainerType; @@ -149,6 +153,7 @@ SALOME_RessourcesCatalogImpl::GetComputerInfo(const char* computer) throw(SALOME_RessourcesCatalog::NotFound) { MESSAGE("Begin of GetComputerInfo"); + Unexpect aCatch(RC_NotFound); SALOME_RessourcesCatalog::computer_info_var _computer_info = new SALOME_RessourcesCatalog::computer_info; @@ -253,7 +258,7 @@ SALOME_RessourcesCatalogImpl::_parseArguments(int argc, char **argv, if (strcmp(argv[ind],"-help") == 0) { - INFOS( "Usage: " << argv[0] << " -common 'path to ressources catalog' -ORBInitRef NameService=corbaname::localhost"); + MESSAGE( "Usage: " << argv[0] << " -common 'path to ressources catalog' -ORBInitRef NameService=corbaname::localhost"); _return_value = false ; } if (strcmp(argv[ind],"-common") == 0) diff --git a/src/SALOMEDS/Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx b/src/SALOMEDS/Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx index 911d848a2..5da8aeccb 100644 --- a/src/SALOMEDS/Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx +++ b/src/SALOMEDS/Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx @@ -24,7 +24,7 @@ // File : Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef _Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile #define _Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile diff --git a/src/SALOMEDS/Handle_SALOMEDS_LocalIDAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_LocalIDAttribute.hxx index dd2c6f14a..dbb2c1c0c 100644 --- a/src/SALOMEDS/Handle_SALOMEDS_LocalIDAttribute.hxx +++ b/src/SALOMEDS/Handle_SALOMEDS_LocalIDAttribute.hxx @@ -24,7 +24,7 @@ // File : Handle_SALOMEDS_LocalIDAttribute.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef _Handle_SALOMEDS_LocalIDAttribute_HeaderFile #define _Handle_SALOMEDS_LocalIDAttribute_HeaderFile diff --git a/src/SALOMEDS/Handle_SALOMEDS_TargetAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_TargetAttribute.hxx index 0c6eee09e..bab384766 100644 --- a/src/SALOMEDS/Handle_SALOMEDS_TargetAttribute.hxx +++ b/src/SALOMEDS/Handle_SALOMEDS_TargetAttribute.hxx @@ -24,7 +24,7 @@ // File : Handle_SALOMEDS_TargetAttribute.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef _Handle_SALOMEDS_TargetAttribute_HeaderFile #define _Handle_SALOMEDS_TargetAttribute_HeaderFile diff --git a/src/SALOMEDS/SALOMEDS_AttributeComment_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeComment_i.cxx index f967482d8..3bf3299f2 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeComment_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeComment_i.cxx @@ -45,3 +45,11 @@ void SALOMEDS_AttributeComment_i::SetValue(const char* value) CORBA::String_var Str = CORBA::string_dup(value); Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str)); } + +char* SALOMEDS_AttributeComment_i::Store() { + return Value(); +} + +void SALOMEDS_AttributeComment_i::Restore(const char* value) { + SetValue(value); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeComment_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeComment_i.hxx index 9ebeb45fd..0171acb75 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeComment_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeComment_i.hxx @@ -48,7 +48,10 @@ public: char* Value(); void SetValue(const char* value); - + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx index 903d1ead7..f21ae9b3b 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx @@ -40,3 +40,11 @@ void SALOMEDS_AttributeDrawable_i::SetDrawable(CORBA::Boolean value) { if (value != 0) val = 1; Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val); } + +char* SALOMEDS_AttributeDrawable_i::Store() { + return strdup(IsDrawable()?"1":"0"); +} + +void SALOMEDS_AttributeDrawable_i::Restore(const char* value) { + SetDrawable(value[0] == '1'); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.hxx index 80c71284f..6f41440e5 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.hxx @@ -48,6 +48,10 @@ public: ~SALOMEDS_AttributeDrawable_i() {}; CORBA::Boolean IsDrawable(); void SetDrawable(CORBA::Boolean value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx index 1560deeaa..98a0720cf 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx @@ -39,3 +39,11 @@ void SALOMEDS_AttributeExpandable_i::SetExpandable(CORBA::Boolean value) { if (value != 0) val = 1; Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val); } + +char* SALOMEDS_AttributeExpandable_i::Store() { + return strdup(IsExpandable()?"1":"0"); +} + +void SALOMEDS_AttributeExpandable_i::Restore(const char* value) { + SetExpandable(value[0] == '1'); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.hxx index 4ac190956..0c18dd2eb 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.hxx @@ -48,6 +48,10 @@ public: ~SALOMEDS_AttributeExpandable_i() {}; CORBA::Boolean IsExpandable(); void SetExpandable(CORBA::Boolean value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeInteger_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeInteger_i.cxx index d9f013db7..8d3484709 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeInteger_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeInteger_i.cxx @@ -39,3 +39,15 @@ void SALOMEDS_AttributeInteger_i::SetValue(CORBA::Long value) { CheckLocked(); Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(value); } + +char* SALOMEDS_AttributeInteger_i::Store() { + char* IntVal = new char[25]; + sprintf(IntVal, "%d", Value()); + return IntVal; +} + +void SALOMEDS_AttributeInteger_i::Restore(const char* value) { + char *err = NULL; + CORBA::Long l = atol(value); + SetValue(l); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeInteger_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeInteger_i.hxx index 8e2a12f84..be877a735 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeInteger_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeInteger_i.hxx @@ -49,6 +49,10 @@ public: CORBA::Long Value(); void SetValue(CORBA::Long value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.cxx index 0ed4628b8..d55ea0d99 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.cxx @@ -24,7 +24,7 @@ // File : SALOMEDS_AttributeLocalID_i.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ using namespace std; #include "SALOMEDS_AttributeLocalID_i.hxx" @@ -38,3 +38,15 @@ void SALOMEDS_AttributeLocalID_i::SetValue(CORBA::Long value) { CheckLocked(); Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(value); } + +char* SALOMEDS_AttributeLocalID_i::Store() { + char* IntVal = new char[25]; + sprintf(IntVal, "%d", Value()); + return IntVal; +} + +void SALOMEDS_AttributeLocalID_i::Restore(const char* value) { + char *err = NULL; + CORBA::Long l = atol(value); + SetValue(l); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.hxx index 6340696db..7b0d5c148 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.hxx @@ -48,6 +48,10 @@ public: ~SALOMEDS_AttributeLocalID_i() {}; CORBA::Long Value(); void SetValue(CORBA::Long value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeName_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeName_i.cxx index 415f71af3..e9ce976d4 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeName_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeName_i.cxx @@ -42,3 +42,11 @@ void SALOMEDS_AttributeName_i::SetValue(const char* value) { CORBA::String_var Str = CORBA::string_dup(value); Handle(TDataStd_Name)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str)); } + +char* SALOMEDS_AttributeName_i::Store() { + return Value(); +} + +void SALOMEDS_AttributeName_i::Restore(const char* value) { + SetValue(value); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeName_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeName_i.hxx index c4c46509d..d2a149258 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeName_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeName_i.hxx @@ -49,6 +49,10 @@ public: char* Value(); void SetValue(const char* value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeOpened_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeOpened_i.cxx index c202cb043..cd4e87f17 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeOpened_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeOpened_i.cxx @@ -39,3 +39,11 @@ void SALOMEDS_AttributeOpened_i::SetOpened(CORBA::Boolean value) { if (value != 0) val = 1; Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val); } + +char* SALOMEDS_AttributeOpened_i::Store() { + return strdup(IsOpened()?"1":"0"); +} + +void SALOMEDS_AttributeOpened_i::Restore(const char* value) { + SetOpened(value[0] == '1'); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeOpened_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeOpened_i.hxx index a5b08df3e..ea75a4990 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeOpened_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeOpened_i.hxx @@ -48,6 +48,10 @@ public: ~SALOMEDS_AttributeOpened_i() {}; CORBA::Boolean IsOpened(); void SetOpened(CORBA::Boolean value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.cxx b/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.cxx index 626ad9711..c8e72e102 100644 --- a/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.cxx @@ -44,3 +44,11 @@ void SALOMEDS_AttributePersistentRef_i::SetValue(const char* value) CORBA::String_var Str = CORBA::string_dup(value); Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str)); } + +char* SALOMEDS_AttributePersistentRef_i::Store() { + return Value(); +} + +void SALOMEDS_AttributePersistentRef_i::Restore(const char* value) { + SetValue(value); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.hxx b/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.hxx index 0173a5e46..5d986a15e 100644 --- a/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.hxx @@ -24,7 +24,7 @@ // File : SALOMEDS_AttributePersistentRef_i.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef SALOMEDS_AttributePersistentRef_i_HeaderFile #define SALOMEDS_AttributePersistentRef_i_HeaderFile @@ -47,6 +47,9 @@ public: char* Value(); void SetValue(const char* value); + + char* Store(); + void Restore(const char*); }; diff --git a/src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx b/src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx index 5015f1697..a34de4967 100644 --- a/src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx @@ -47,3 +47,11 @@ void SALOMEDS_AttributePixMap_i::SetPixMap(const char* value) { CORBA::String_var Str = CORBA::string_dup(value); Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str)); } + +char* SALOMEDS_AttributePixMap_i::Store() { + return GetPixMap(); +} + +void SALOMEDS_AttributePixMap_i::Restore(const char* value) { + SetPixMap(value); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributePixMap_i.hxx b/src/SALOMEDS/SALOMEDS_AttributePixMap_i.hxx index 3058b356a..16696a4a5 100644 --- a/src/SALOMEDS/SALOMEDS_AttributePixMap_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributePixMap_i.hxx @@ -24,7 +24,7 @@ // File : SALOMEDS_AttributePixMap_i.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef SALOMEDS_AttributePixMap_i_HeaderFile #define SALOMEDS_AttributePixMap_i_HeaderFile @@ -48,6 +48,10 @@ public: CORBA::Boolean HasPixMap(); char* GetPixMap(); void SetPixMap(const char* value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.cxx b/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.cxx index 86f7a1ca4..a02fa874e 100644 --- a/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.cxx @@ -30,3 +30,16 @@ char* SALOMEDS_AttributePythonObject_i::GetObject() { CORBA::Boolean SALOMEDS_AttributePythonObject_i::IsScript() { return Handle(SALOMEDS_PythonObjectAttribute)::DownCast(_myAttr)->IsScript(); } + +char* SALOMEDS_AttributePythonObject_i::Store() { + CORBA::String_var aString = GetObject(); + char* aResult = new char[strlen(aString) + 2]; + aResult[0] = IsScript()?'s':'n'; + strcpy(aResult+1, aString); + return aResult; +} + +void SALOMEDS_AttributePythonObject_i::Restore(const char* value) { + char* aString = strdup(value); + SetObject(aString + 1, aString[0]=='s'); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.hxx b/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.hxx index d15d36649..1db4b14ea 100644 --- a/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.hxx @@ -34,6 +34,9 @@ public: virtual char* GetObject(); virtual CORBA::Boolean IsScript(); + virtual char* Store(); + virtual void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeReal_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeReal_i.cxx index fc5611c8e..c87b60486 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeReal_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeReal_i.cxx @@ -38,3 +38,15 @@ void SALOMEDS_AttributeReal_i::SetValue(CORBA::Double value) { CheckLocked(); Handle(TDataStd_Real)::DownCast(_myAttr)->Set(value); } + +char* SALOMEDS_AttributeReal_i::Store() { + char* RealVal = new char[25]; + sprintf(RealVal, "%f", Value()); + return RealVal; +} + +void SALOMEDS_AttributeReal_i::Restore(const char* value) { + char *err = NULL; + CORBA::Double r = strtod(value, &err); + if (err != value) SetValue(r); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeReal_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeReal_i.hxx index a4399c9f7..42263a161 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeReal_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeReal_i.hxx @@ -24,7 +24,7 @@ // File : SALOMEDS_AttributeReal_i.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef SALOMEDS_AttributeReal_i_HeaderFile #define SALOMEDS_AttributeReal_i_HeaderFile @@ -48,6 +48,10 @@ public: CORBA::Double Value(); void SetValue(CORBA::Double value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.cxx index b526f3c99..fd9fa7ad2 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.cxx @@ -39,3 +39,11 @@ void SALOMEDS_AttributeSelectable_i::SetSelectable(CORBA::Boolean value) { if (value != 0) val = 1; Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val); } + +char* SALOMEDS_AttributeSelectable_i::Store() { + return strdup(IsSelectable()?"1":"0"); +} + +void SALOMEDS_AttributeSelectable_i::Restore(const char* value) { + SetSelectable(value[0] == '1'); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.hxx index b9936d47b..c844f03bf 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.hxx @@ -48,6 +48,10 @@ public: ~SALOMEDS_AttributeSelectable_i() {}; CORBA::Boolean IsSelectable(); void SetSelectable(CORBA::Boolean value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.cxx index 61e08b1bd..703810bc5 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.cxx @@ -80,3 +80,30 @@ CORBA::Long SALOMEDS_AttributeSequenceOfInteger_i::Length() { return Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Length(); } + +char* SALOMEDS_AttributeSequenceOfInteger_i::Store() { + Handle(SALOMEDS_SequenceOfIntegerAttribute) CasCadeSeq = Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr); + Standard_Integer aLength = CasCadeSeq->Length(); + char* aResult = new char[aLength * 25]; + aResult[0] = 0; + Standard_Integer aPosition = 0; + for (int i = 1; i <= aLength; i++) { + sprintf(aResult + aPosition , "%d ", CasCadeSeq->Value(i)); + aPosition += strlen(aResult + aPosition); + } + return aResult; +} + +void SALOMEDS_AttributeSequenceOfInteger_i::Restore(const char* value) { + Handle(TColStd_HSequenceOfInteger) CasCadeSeq = new TColStd_HSequenceOfInteger; + + char* aCopy = strdup(value); + char* adr = strtok(aCopy, " "); + while (adr) { + CORBA::Long l = atol(adr); + CasCadeSeq->Append(l); + adr = strtok(NULL, " "); + } + delete(aCopy); + Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Assign(CasCadeSeq); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.hxx index ee0b71eef..06b24a7c5 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.hxx @@ -55,6 +55,10 @@ public: void ChangeValue(CORBA::Long index, CORBA::Long value); CORBA::Long Value(CORBA::Short index); CORBA::Long Length(); + + char* Store(); + void Restore(const char*); + }; #endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.cxx index 8b48632b2..d7f480a16 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.cxx @@ -79,3 +79,32 @@ CORBA::Long SALOMEDS_AttributeSequenceOfReal_i::Length() { return Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Length(); } + +char* SALOMEDS_AttributeSequenceOfReal_i::Store() { + Handle(SALOMEDS_SequenceOfRealAttribute) CasCadeSeq = Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr); + Standard_Integer aLength = CasCadeSeq->Length(); + char* aResult = new char[aLength * 25]; + aResult[0] = 0; + Standard_Integer aPosition = 0; + for (int i = 1; i <= aLength; i++) { + sprintf(aResult + aPosition , "%f ", CasCadeSeq->Value(i)); + aPosition += strlen(aResult + aPosition); + } + return aResult; +} + +void SALOMEDS_AttributeSequenceOfReal_i::Restore(const char* value) { + Handle(TColStd_HSequenceOfReal) CasCadeSeq = new TColStd_HSequenceOfReal; + + char* aCopy = strdup(value); + char* adr = strtok(aCopy, " "); + char *err = NULL; + while (adr) { + CORBA::Double r = strtod(adr, &err); + if (err == adr) break; + else CasCadeSeq->Append(r); + adr = strtok(NULL, " "); + } + delete(aCopy); + Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Assign(CasCadeSeq); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.hxx index ded1a3584..044fbc460 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.hxx @@ -54,6 +54,9 @@ public: void ChangeValue(CORBA::Long index, CORBA::Double value); CORBA::Double Value(CORBA::Short index); CORBA::Long Length(); + + char* Store(); + void Restore(const char*); }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx index 1646f3db4..9b2b8912c 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx @@ -22,8 +22,7 @@ using namespace std; void SALOMEDS_AttributeStudyProperties_i::SetUserName(const char* theName) { CheckLocked(); Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr); - CORBA::String_var Str = CORBA::string_dup(theName); - aProp->SetFirstName(TCollection_ExtendedString(Str)); + aProp->SetFirstName(TCollection_ExtendedString(strdup(theName))); } char* SALOMEDS_AttributeStudyProperties_i::GetUserName() { @@ -112,7 +111,7 @@ void SALOMEDS_AttributeStudyProperties_i::SetModification(const char* theName, CORBA::Long theYear) { CheckLocked(); Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr); - aProp->SetUserName(CORBA::string_dup(theName)); + aProp->SetUserName(strdup(theName)); aProp->SetModificationDate((int)theMinute, (int)theHour, (int)theDay, (int)theMonth, (int)theYear); } void SALOMEDS_AttributeStudyProperties_i::GetModificationsList(SALOMEDS::StringSeq_out theNames, @@ -153,3 +152,80 @@ void SALOMEDS_AttributeStudyProperties_i::GetModificationsList(SALOMEDS::StringS (*theYears)[a] = aYears->Value(a + 1 + ((theWithCreator)?0:1)); } } + +char* SALOMEDS_AttributeStudyProperties_i::Store() { + Handle(TColStd_HSequenceOfExtendedString) aNames; + Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears; + Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr); + aNames = aProp->GetUserNames(); + aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears); + + int aLength, anIndex; + for(aLength = 0, anIndex = aNames->Length(); anIndex > 0; anIndex--) aLength += aNames->Value(anIndex).Length() + 1; + + char* aProperty = new char[3 + aLength + 12 * aNames->Length()]; + + sprintf(aProperty,"%c%c", strlen(GetCreationMode())?GetCreationMode()[0]:'0', IsLocked()?'l':'u'); + + aLength = aNames->Length(); + int a = 2; + for(anIndex = 1; anIndex <= aLength; anIndex++) { + sprintf(&(aProperty[a]),"%2d%2d%2d%2d%4d%s", + (int)(aMinutes->Value(anIndex)), + (int)(aHours->Value(anIndex)), + (int)(aDays->Value(anIndex)), + (int)(aMonths->Value(anIndex)), + (int)(aYears->Value(anIndex)), + (char*)(TCollection_AsciiString(aNames->Value(anIndex)).ToCString())); + a = strlen(aProperty); + aProperty[a++] = 1; + } + aProperty[a] = 0; + return aProperty; +} + +void SALOMEDS_AttributeStudyProperties_i::Restore(const char* value) { + char* aCopy = strdup(value); + if (aCopy[0] == 'f') SetCreationMode("from scratch"); + else if (aCopy[0] == 'c') SetCreationMode("copy from"); + else SetCreationMode("none"); + + int anIndex; + for(anIndex = 2; anIndex + 2 < strlen(value) ;) { + char str[10]; + Standard_Integer aMinute, aHour, aDay, aMonth, aYear; + str[0] = aCopy[anIndex++]; + str[1] = aCopy[anIndex++]; + str[2] = 0; + aMinute = atoi(str); + str[0] = aCopy[anIndex++]; + str[1] = aCopy[anIndex++]; + aHour = atoi(str); + str[0] = aCopy[anIndex++]; + str[1] = aCopy[anIndex++]; + aDay = atoi(str); + str[0] = aCopy[anIndex++]; + str[1] = aCopy[anIndex++]; + aMonth = atoi(str); + str[0] = aCopy[anIndex++]; + str[1] = aCopy[anIndex++]; + str[2] = aCopy[anIndex++]; + str[3] = aCopy[anIndex++]; + str[4] = 0; + aYear = atoi(str); + + int aNameSize; + for(aNameSize = 0; aCopy[anIndex+aNameSize]!=1; aNameSize++); + char *aName = new char[aNameSize+1]; + strncpy(aName, &(aCopy[anIndex]), aNameSize); + aName[aNameSize] = 0; + SetModification(aName, aMinute,aHour,aDay,aMonth,aYear); + delete(aName); + anIndex += aNameSize + 1; + } + if (aCopy[1] == 'l') { + SetLocked(Standard_True); + } + SetModified(0); + delete(aCopy); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.hxx index 95d30cb65..2d7ebeb3b 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.hxx @@ -53,6 +53,10 @@ public: SALOMEDS::LongSeq_out theMonths, SALOMEDS::LongSeq_out theYears, CORBA::Boolean theWithCreator); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.cxx index f80457bb6..df037e525 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.cxx @@ -15,12 +15,17 @@ using namespace std; #include #include #include +#include "Utils_ExceptHandlers.hxx" +#include #include #include #define SEPARATOR '\1' +UNEXPECT_CATCH(ATI_IncorrectIndex, SALOMEDS::AttributeTableOfInteger::IncorrectIndex); +UNEXPECT_CATCH(ATI_IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength); + static TCollection_ExtendedString getUnit(TCollection_ExtendedString theString) { TCollection_ExtendedString aString(theString); @@ -57,6 +62,7 @@ char* SALOMEDS_AttributeTableOfInteger_i::GetTitle() { void SALOMEDS_AttributeTableOfInteger_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + Unexpect aCatch (ATI_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); @@ -74,6 +80,7 @@ void SALOMEDS_AttributeTableOfInteger_i::SetRowTitle(CORBA::Long theIndex, const void SALOMEDS_AttributeTableOfInteger_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength) { + Unexpect aCatch (ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength(); @@ -94,6 +101,7 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowTitles() { void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + Unexpect aCatch (ATI_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); @@ -104,6 +112,7 @@ void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitle(CORBA::Long theIndex, co void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength) { + Unexpect aCatch(ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength(); @@ -125,6 +134,7 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumnTitles() { void SALOMEDS_AttributeTableOfInteger_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + Unexpect aCatch (ATI_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); @@ -139,6 +149,7 @@ void SALOMEDS_AttributeTableOfInteger_i::SetRowUnit(CORBA::Long theIndex, const void SALOMEDS_AttributeTableOfInteger_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength) { + Unexpect aCatch (ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength(); @@ -166,6 +177,7 @@ CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetNbColumns() { void SALOMEDS_AttributeTableOfInteger_i::AddRow(const SALOMEDS::LongSeq& theData) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength) { + Unexpect aCatch(ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); @@ -182,6 +194,7 @@ void SALOMEDS_AttributeTableOfInteger_i::AddRow(const SALOMEDS::LongSeq& theData void SALOMEDS_AttributeTableOfInteger_i::SetRow(CORBA::Long theRow, const SALOMEDS::LongSeq& theData) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + Unexpect aCatch(ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); @@ -198,6 +211,7 @@ void SALOMEDS_AttributeTableOfInteger_i::SetRow(CORBA::Long theRow, const SALOME SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetRow(CORBA::Long theRow) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + Unexpect aCatch(ATI_IncorrectIndex); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); @@ -213,6 +227,7 @@ SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetRow(CORBA::Long theRow void SALOMEDS_AttributeTableOfInteger_i::AddColumn(const SALOMEDS::LongSeq& theData) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength) { + Unexpect aCatch(ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); @@ -229,6 +244,7 @@ void SALOMEDS_AttributeTableOfInteger_i::AddColumn(const SALOMEDS::LongSeq& theD void SALOMEDS_AttributeTableOfInteger_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::LongSeq& theData) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + Unexpect aCatch(ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); @@ -245,6 +261,7 @@ void SALOMEDS_AttributeTableOfInteger_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumn(CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + Unexpect aCatch(ATI_IncorrectIndex); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); @@ -260,6 +277,7 @@ SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumn(CORBA::Long the void SALOMEDS_AttributeTableOfInteger_i::PutValue(CORBA::Long theValue, CORBA::Long theRow, CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + Unexpect aCatch(ATI_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); @@ -278,6 +296,7 @@ CORBA::Boolean SALOMEDS_AttributeTableOfInteger_i::HasValue(CORBA::Long theRow, CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + Unexpect aCatch(ATI_IncorrectIndex); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); @@ -341,3 +360,20 @@ SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfInteger_i::SaveToFile() return aStreamFile._retn(); } +char* SALOMEDS_AttributeTableOfInteger_i::Store() { + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + + ostrstream ostr; + aTable->ConvertToString(ostr); + string aString = ostr.rdbuf()->str(); + + CORBA::String_var aBuffer = CORBA::string_dup(aString.c_str()); + return aBuffer._retn(); +} + +void SALOMEDS_AttributeTableOfInteger_i::Restore(const char* value) { + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + + istrstream aStream(value, strlen(value)); + aTable->RestoreFromString(aStream); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.hxx index c26bf5d9f..6b3ca5238 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.hxx @@ -75,6 +75,10 @@ public: virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream); virtual SALOMEDS::TMPFile* SaveToFile(); + + virtual char* Store(); + virtual void Restore(const char*); + }; #endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx index 432f42e5e..cb06a664f 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx @@ -19,6 +19,10 @@ using namespace std; #include #include +#include "Utils_ExceptHandlers.hxx" +UNEXPECT_CATCH(ATR_IncorrectIndex, SALOMEDS::AttributeTableOfReal::IncorrectIndex); +UNEXPECT_CATCH(ATR_IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength); + #define SEPARATOR '\1' static TCollection_ExtendedString getUnit(TCollection_ExtendedString theString) @@ -57,6 +61,7 @@ char* SALOMEDS_AttributeTableOfReal_i::GetTitle() { void SALOMEDS_AttributeTableOfReal_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + Unexpect aCatch (ATR_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); @@ -74,6 +79,7 @@ void SALOMEDS_AttributeTableOfReal_i::SetRowTitle(CORBA::Long theIndex, const ch void SALOMEDS_AttributeTableOfReal_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) { + Unexpect aCatch (ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength(); @@ -94,6 +100,7 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetRowTitles() { void SALOMEDS_AttributeTableOfReal_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + Unexpect aCatch (ATR_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); @@ -104,6 +111,7 @@ void SALOMEDS_AttributeTableOfReal_i::SetColumnTitle(CORBA::Long theIndex, const void SALOMEDS_AttributeTableOfReal_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) { + Unexpect aCatch(ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength(); @@ -125,6 +133,7 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetColumnTitles() { void SALOMEDS_AttributeTableOfReal_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + Unexpect aCatch (ATR_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); @@ -139,6 +148,7 @@ void SALOMEDS_AttributeTableOfReal_i::SetRowUnit(CORBA::Long theIndex, const cha void SALOMEDS_AttributeTableOfReal_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) { + Unexpect aCatch (ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength(); @@ -167,6 +177,7 @@ CORBA::Long SALOMEDS_AttributeTableOfReal_i::GetNbColumns() { void SALOMEDS_AttributeTableOfReal_i::AddRow(const SALOMEDS::DoubleSeq& theData) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) { + Unexpect aCatch(ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -178,6 +189,7 @@ void SALOMEDS_AttributeTableOfReal_i::AddRow(const SALOMEDS::DoubleSeq& theData) void SALOMEDS_AttributeTableOfReal_i::SetRow(CORBA::Long theRow, const SALOMEDS::DoubleSeq& theData) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + Unexpect aCatch(ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -189,6 +201,7 @@ void SALOMEDS_AttributeTableOfReal_i::SetRow(CORBA::Long theRow, const SALOMEDS: SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetRow(CORBA::Long theRow) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + Unexpect aCatch(ATR_IncorrectIndex); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); @@ -204,6 +217,7 @@ SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetRow(CORBA::Long theRow) void SALOMEDS_AttributeTableOfReal_i::AddColumn(const SALOMEDS::DoubleSeq& theData) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) { + Unexpect aCatch(ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -215,6 +229,7 @@ void SALOMEDS_AttributeTableOfReal_i::AddColumn(const SALOMEDS::DoubleSeq& theDa void SALOMEDS_AttributeTableOfReal_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::DoubleSeq& theData) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + Unexpect aCatch(ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -226,6 +241,7 @@ void SALOMEDS_AttributeTableOfReal_i::SetColumn(CORBA::Long theColumn, const SAL SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetColumn(CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + Unexpect aCatch(ATR_IncorrectIndex); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); @@ -241,6 +257,7 @@ SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetColumn(CORBA::Long theC void SALOMEDS_AttributeTableOfReal_i::PutValue(CORBA::Double theValue, CORBA::Long theRow, CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + Unexpect aCatch(ATR_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -254,6 +271,7 @@ CORBA::Boolean SALOMEDS_AttributeTableOfReal_i::HasValue(CORBA::Long theRow, COR CORBA::Double SALOMEDS_AttributeTableOfReal_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + Unexpect aCatch(ATR_IncorrectIndex); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); @@ -320,3 +338,20 @@ SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfReal_i::SaveToFile() return aStreamFile._retn(); } +char* SALOMEDS_AttributeTableOfReal_i::Store() { + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + + ostrstream ostr; + aTable->ConvertToString(ostr); + string aString = ostr.rdbuf()->str(); + + CORBA::String_var aBuffer = CORBA::string_dup(aString.c_str()); + return aBuffer._retn(); +} + +void SALOMEDS_AttributeTableOfReal_i::Restore(const char* value) { + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + + istrstream aStream(value, strlen(value)); + aTable->RestoreFromString(aStream); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.hxx index 63ba28ccb..a3e8056b8 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.hxx @@ -75,6 +75,10 @@ public: virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream); virtual SALOMEDS::TMPFile* SaveToFile(); + + virtual char* Store(); + virtual void Restore(const char*); + }; #endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.cxx index 262cdce8d..b77322d31 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.cxx @@ -22,6 +22,10 @@ using namespace std; #include #include +#include "Utils_ExceptHandlers.hxx" +UNEXPECT_CATCH(ATS_IncorrectIndex, SALOMEDS::AttributeTableOfString::IncorrectIndex); +UNEXPECT_CATCH(ATS_IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectArgumentLength); + #define SEPARATOR '\1' static TCollection_ExtendedString getUnit(TCollection_ExtendedString theString) @@ -60,6 +64,7 @@ char* SALOMEDS_AttributeTableOfString_i::GetTitle() { void SALOMEDS_AttributeTableOfString_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + Unexpect aCatch(ATS_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); @@ -77,6 +82,7 @@ void SALOMEDS_AttributeTableOfString_i::SetRowTitle(CORBA::Long theIndex, const void SALOMEDS_AttributeTableOfString_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength) { + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength(); @@ -97,6 +103,7 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRowTitles() { void SALOMEDS_AttributeTableOfString_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + Unexpect aCatch(ATS_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); @@ -107,6 +114,7 @@ void SALOMEDS_AttributeTableOfString_i::SetColumnTitle(CORBA::Long theIndex, con void SALOMEDS_AttributeTableOfString_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength) { + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength(); @@ -128,6 +136,7 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetColumnTitles() { void SALOMEDS_AttributeTableOfString_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + Unexpect aCatch(ATS_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); @@ -142,6 +151,7 @@ void SALOMEDS_AttributeTableOfString_i::SetRowUnit(CORBA::Long theIndex, const c void SALOMEDS_AttributeTableOfString_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength) { + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength(); @@ -170,6 +180,7 @@ CORBA::Long SALOMEDS_AttributeTableOfString_i::GetNbColumns() { void SALOMEDS_AttributeTableOfString_i::AddRow(const SALOMEDS::StringSeq& theData) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength) { + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); @@ -181,6 +192,7 @@ void SALOMEDS_AttributeTableOfString_i::AddRow(const SALOMEDS::StringSeq& theDat void SALOMEDS_AttributeTableOfString_i::SetRow(CORBA::Long theRow, const SALOMEDS::StringSeq& theData) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectIndex) { + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); @@ -192,6 +204,7 @@ void SALOMEDS_AttributeTableOfString_i::SetRow(CORBA::Long theRow, const SALOMED SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRow(CORBA::Long theRow) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + Unexpect aCatch(ATS_IncorrectIndex); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); @@ -207,6 +220,7 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRow(CORBA::Long theRo void SALOMEDS_AttributeTableOfString_i::AddColumn(const SALOMEDS::StringSeq& theData) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength) { + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); @@ -218,6 +232,7 @@ void SALOMEDS_AttributeTableOfString_i::AddColumn(const SALOMEDS::StringSeq& the void SALOMEDS_AttributeTableOfString_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::StringSeq& theData) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectIndex) { + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); @@ -229,6 +244,7 @@ void SALOMEDS_AttributeTableOfString_i::SetColumn(CORBA::Long theColumn, const S SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetColumn(CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + Unexpect aCatch(ATS_IncorrectIndex); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); @@ -244,6 +260,7 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetColumn(CORBA::Long th void SALOMEDS_AttributeTableOfString_i::PutValue(const char* theValue, CORBA::Long theRow, CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + Unexpect aCatch(ATS_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); char* aValue = CORBA::string_dup(theValue); @@ -258,6 +275,7 @@ CORBA::Boolean SALOMEDS_AttributeTableOfString_i::HasValue(CORBA::Long theRow, C char* SALOMEDS_AttributeTableOfString_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + Unexpect aCatch(ATS_IncorrectIndex); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); @@ -316,3 +334,20 @@ SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfString_i::SaveToFile() return aStreamFile._retn(); } +char* SALOMEDS_AttributeTableOfString_i::Store() { + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + + ostrstream ostr; + aTable->ConvertToString(ostr); + string aString = ostr.rdbuf()->str(); + + CORBA::String_var aBuffer = CORBA::string_dup(aString.c_str()); + return aBuffer._retn(); +} + +void SALOMEDS_AttributeTableOfString_i::Restore(const char* value) { + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + + istrstream aStream(value, strlen(value)); + aTable->RestoreFromString(aStream); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.hxx index 0368c59c5..f3a87deea 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.hxx @@ -74,6 +74,10 @@ public: virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream); virtual SALOMEDS::TMPFile* SaveToFile(); + + char* Store(); + void Restore(const char*); + }; #endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx index f5f35cc7b..1d14121c1 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx @@ -24,7 +24,7 @@ // File : SALOMEDS_AttributeTarget_i.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ using namespace std; #include "SALOMEDS_AttributeTarget_i.hxx" diff --git a/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.cxx index 0f040990c..cf63ff0d9 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.cxx @@ -55,3 +55,20 @@ void SALOMEDS_AttributeTextColor_i::SetTextColor(const SALOMEDS::Color& value) { anArray->SetValue(3, value.B); Handle(SALOMEDS_TextColorAttribute)::DownCast(_myAttr)->ChangeArray(anArray); } + +char* SALOMEDS_AttributeTextColor_i::Store() { + SALOMEDS::Color aColor = TextColor(); + char *Val = new char[75]; + sprintf(Val, "%f %f %f", (float)aColor.R, (float)aColor.G, (float)aColor.B); + return Val; +} + +void SALOMEDS_AttributeTextColor_i::Restore(const char* value) { + SALOMEDS::Color aColor; + float r, g, b; + sscanf(value, "%f %f %f", &r, &g, &b); + aColor.R = r; + aColor.G = g; + aColor.B = b; + SetTextColor(aColor); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.hxx index f03c98b9e..46b50ff12 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.hxx @@ -24,7 +24,7 @@ // File : SALOMEDS_AttributeTextColor_i.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef SALOMEDS_AttributeTextColor_i_HeaderFile #define SALOMEDS_AttributeTextColor_i_HeaderFile @@ -48,6 +48,10 @@ public: SALOMEDS::Color TextColor(); void SetTextColor(const SALOMEDS::Color& value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.cxx index 9ba430ba8..0995ac90a 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.cxx @@ -55,3 +55,20 @@ void SALOMEDS_AttributeTextHighlightColor_i::SetTextHighlightColor(const SALOMED anArray->SetValue(3, value.B); Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(_myAttr)->ChangeArray(anArray); } + +char* SALOMEDS_AttributeTextHighlightColor_i::Store() { + SALOMEDS::Color aColor = TextHighlightColor(); + char *Val = new char[75]; + sprintf(Val, "%f %f %f", (float)aColor.R, (float)aColor.G, (float)aColor.B); + return Val; +} + +void SALOMEDS_AttributeTextHighlightColor_i::Restore(const char* value) { + SALOMEDS::Color aColor; + float r, g, b; + sscanf(value, "%f %f %f", &r, &g, &b); + aColor.R = r; + aColor.G = g; + aColor.B = b; + SetTextHighlightColor(aColor); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.hxx index 2b7e487dc..2ca180ffe 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.hxx @@ -24,7 +24,7 @@ // File : SALOMEDS_AttributeTextHighlightColor_i.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef SALOMEDS_AttributeTextHighlightColor_i_HeaderFile #define SALOMEDS_AttributeTextHighlightColor_i_HeaderFile @@ -48,6 +48,10 @@ public: SALOMEDS::Color TextHighlightColor(); void SetTextHighlightColor(const SALOMEDS::Color& value); + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx index 11d326b5c..6e575f131 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx @@ -24,12 +24,14 @@ // File : SALOMEDS_AttributeTreeNode_i.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ using namespace std; #include "SALOMEDS_AttributeTreeNode_i.hxx" #include "SALOMEDS_SObject_i.hxx" #include "utilities.h" +#include +#include static Handle(TDataStd_TreeNode) GetNode(SALOMEDS::AttributeTreeNode_ptr value, const Handle(TDataStd_TreeNode)& aNode) { @@ -182,3 +184,56 @@ char* SALOMEDS_AttributeTreeNode_i::Label() { TDF_Tool::Entry(_myAttr->Label(),aLabelName); return CORBA::String_var(CORBA::string_dup(aLabelName.ToCString()))._retn(); } + +char* SALOMEDS_AttributeTreeNode_i::Store() { + char* aStr[4]; + + if (HasFather()) aStr[0] = GetFather()->Label(); else aStr[0] = "!"; + if (HasPrevious()) aStr[1] = GetPrevious()->Label(); else aStr[1] = "!"; + if (HasNext()) aStr[2] = GetNext()->Label(); else aStr[2] = "!"; + if (HasFirst()) aStr[3] = GetFirst()->Label(); else aStr[3] = "!"; + + int aLength = 4; + aLength += strlen(aStr[0]) + strlen(aStr[1]) + strlen(aStr[2]) + strlen(aStr[3]); + CORBA::String_var aResult = new char[aLength]; + sprintf(aResult, "%s %s %s %s", aStr[0], aStr[1], aStr[2], aStr[3]); + return aResult._retn(); +} + +void SALOMEDS_AttributeTreeNode_i::Restore(const char* value) { + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); + Handle(TDF_Data) DF = TDocStd_Document::Get(_myAttr->Label())->GetData(); + + char* aCopy = strdup(value); + char* adr = strtok(aCopy, " "); + + TDF_Label aLabel; + Handle(TDataStd_TreeNode) aDepNode; + + if (adr && adr[0] != '!') { + TDF_Tool::Label(DF, adr, aLabel, 1); + if (!aLabel.FindAttribute(aNode->ID(), aDepNode)) aDepNode = TDataStd_TreeNode::Set(aLabel, aNode->ID()); + aNode->SetFather(aDepNode); + } + + adr = strtok(NULL, " "); + if (adr && adr[0] != '!') { + TDF_Tool::Label(DF, adr, aLabel, 1); + if (!aLabel.FindAttribute(aNode->ID(), aDepNode)) aDepNode = TDataStd_TreeNode::Set(aLabel, aNode->ID()); + aNode->SetPrevious(aDepNode); + } + + adr = strtok(NULL, " "); + if (adr && adr[0] != '!') { + TDF_Tool::Label(DF, adr, aLabel, 1); + if (!aLabel.FindAttribute(aNode->ID(), aDepNode)) aDepNode = TDataStd_TreeNode::Set(aLabel, aNode->ID()); + aNode->SetNext(aDepNode); + } + + adr = strtok(NULL, " "); + if (adr && adr[0] != '!') { + TDF_Tool::Label(DF, adr, aLabel, 1); + if (!aLabel.FindAttribute(aNode->ID(), aDepNode)) aDepNode = TDataStd_TreeNode::Set(aLabel, aNode->ID()); + aNode->SetFirst(aDepNode); + } +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.hxx index c8bda02dc..14e134b27 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.hxx @@ -71,6 +71,10 @@ public: CORBA::Boolean IsFather(SALOMEDS::AttributeTreeNode_ptr value); CORBA::Boolean IsChild(SALOMEDS::AttributeTreeNode_ptr value); char* Label(); + + char* Store(); + void Restore(const char*); + }; #endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeUserID_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeUserID_i.cxx index 632d95beb..b7fa64a41 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeUserID_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeUserID_i.cxx @@ -24,7 +24,7 @@ // File : SALOMEDS_AttributeName_i.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ using namespace std; #include "SALOMEDS_AttributeUserID_i.hxx" @@ -43,3 +43,10 @@ void SALOMEDS_AttributeUserID_i::SetValue(const char* value) { CORBA::String_var Str = CORBA::string_dup(value); Handle(TDataStd_UAttribute)::DownCast(_myAttr)->SetID(Standard_GUID(Standard_CString(Str))); } + +char* SALOMEDS_AttributeUserID_i::Store() { + return ""; +} + +void SALOMEDS_AttributeUserID_i::Restore(const char* value) { +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeUserID_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeUserID_i.hxx index 662d21eca..e080658af 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeUserID_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeUserID_i.hxx @@ -54,6 +54,10 @@ public: static Standard_GUID SALOMEDS_DefaultUserAttributeID ("FFFFFFFF-D9CD-11d6-945D-1050DA506788"); return SALOMEDS_DefaultUserAttributeID; } + + char* Store(); + void Restore(const char*); + }; diff --git a/src/SALOMEDS/SALOMEDS_BasicAttributeFactory.cxx b/src/SALOMEDS/SALOMEDS_BasicAttributeFactory.cxx index bd83af147..707c40e10 100644 --- a/src/SALOMEDS/SALOMEDS_BasicAttributeFactory.cxx +++ b/src/SALOMEDS/SALOMEDS_BasicAttributeFactory.cxx @@ -38,16 +38,17 @@ using namespace std; SALOMEDS_BasicAttribute_i* BasicAttributeFactory::Create(const char* type) throw (SALOME_Exception) { - if (!strcmp(type,"AttReal")) - { - SALOMEDS_AttReal_i *A = new SALOMEDS_AttReal_i(); - return A; - } - else if(!strcmp(type,"AttLong")) - { - SALOMEDS_AttLong_i *A = new SALOMEDS_AttLong_i(); - return A; - } - else throw(SALOME_Exception(LOCALIZED("bad attribute type name"))); - + try { + if (!strcmp(type,"AttReal")) + { + SALOMEDS_AttReal_i *A = new SALOMEDS_AttReal_i(); + return A; + } + else if(!strcmp(type,"AttLong")) + { + SALOMEDS_AttLong_i *A = new SALOMEDS_AttLong_i(); + return A; + } + else throw(SALOME_Exception(LOCALIZED("bad attribute type name"))); + } catch (...) {throw(SALOME_Exception(LOCALIZED("Unexpected exception was caught")));} } diff --git a/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx b/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx index 216055253..98c011e27 100644 --- a/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx +++ b/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx @@ -24,7 +24,7 @@ // File : SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef _SALOMEDS_DataMapIteratorOfDataMapStringLabel_HeaderFile #define _SALOMEDS_DataMapIteratorOfDataMapStringLabel_HeaderFile diff --git a/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel_0.cxx b/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel_0.cxx index 080f4b79d..1473d66c5 100644 --- a/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel_0.cxx +++ b/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel_0.cxx @@ -24,7 +24,7 @@ // File : SALOMEDS_DataMapIteratorOfDataMapStringLabel_0.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ using namespace std; #include "SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx" diff --git a/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx b/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx index 175205a6e..5fa7a9f17 100644 --- a/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx +++ b/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx @@ -24,7 +24,7 @@ // File : SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef _SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile #define _SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile diff --git a/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel_0.cxx b/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel_0.cxx index 2b063d479..401a2b77e 100644 --- a/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel_0.cxx +++ b/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel_0.cxx @@ -24,7 +24,7 @@ // File : Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel_0.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ using namespace std; #include "SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx" diff --git a/src/SALOMEDS/SALOMEDS_DataMapStringLabel.hxx b/src/SALOMEDS/SALOMEDS_DataMapStringLabel.hxx index ef2ddbdff..7de27e8e1 100644 --- a/src/SALOMEDS/SALOMEDS_DataMapStringLabel.hxx +++ b/src/SALOMEDS/SALOMEDS_DataMapStringLabel.hxx @@ -24,7 +24,7 @@ // File : SALOMEDS_DataMapStringLabel.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef _SALOMEDS_DataMapStringLabel_HeaderFile #define _SALOMEDS_DataMapStringLabel_HeaderFile diff --git a/src/SALOMEDS/SALOMEDS_DataMapStringLabel_0.cxx b/src/SALOMEDS/SALOMEDS_DataMapStringLabel_0.cxx index 4befe2030..76dab0d3b 100644 --- a/src/SALOMEDS/SALOMEDS_DataMapStringLabel_0.cxx +++ b/src/SALOMEDS/SALOMEDS_DataMapStringLabel_0.cxx @@ -24,7 +24,7 @@ // File : SALOMEDS_DataMapStringLabel_0.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ using namespace std; #include "SALOMEDS_DataMapStringLabel.hxx" diff --git a/src/SALOMEDS/SALOMEDS_DrawableAttribute.cxx b/src/SALOMEDS/SALOMEDS_DrawableAttribute.cxx index 62bed2f1b..8d72f6a6a 100644 --- a/src/SALOMEDS/SALOMEDS_DrawableAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_DrawableAttribute.cxx @@ -24,7 +24,7 @@ // File : SALOMEDS_DrawableAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ using namespace std; #include "SALOMEDS_DrawableAttribute.ixx" diff --git a/src/SALOMEDS/SALOMEDS_ExpandableAttribute.cxx b/src/SALOMEDS/SALOMEDS_ExpandableAttribute.cxx index ad3cc3c5d..b20dd9c10 100644 --- a/src/SALOMEDS/SALOMEDS_ExpandableAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_ExpandableAttribute.cxx @@ -24,7 +24,7 @@ // File : SALOMEDS_ExpandableAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ using namespace std; #include "SALOMEDS_ExpandableAttribute.ixx" diff --git a/src/SALOMEDS/SALOMEDS_ExternalFileDef.cxx b/src/SALOMEDS/SALOMEDS_ExternalFileDef.cxx index 2e07b0106..3b5af8399 100644 --- a/src/SALOMEDS/SALOMEDS_ExternalFileDef.cxx +++ b/src/SALOMEDS/SALOMEDS_ExternalFileDef.cxx @@ -24,7 +24,7 @@ // File : SALOMEDS_ExternalFileDef.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #include "SALOMEDS_ExternalFileDef.ixx" #include diff --git a/src/SALOMEDS/SALOMEDS_FileType.cxx b/src/SALOMEDS/SALOMEDS_FileType.cxx index 515bbc551..a26ebe3f4 100644 --- a/src/SALOMEDS/SALOMEDS_FileType.cxx +++ b/src/SALOMEDS/SALOMEDS_FileType.cxx @@ -24,7 +24,7 @@ // File : SALOMEDS_FileType.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #include "SALOMEDS_FileType.ixx" #include diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx index d3fc65e30..27d6d5fdd 100644 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx @@ -10,9 +10,91 @@ // $Header$ using namespace std; + +#include +#include + +#include "SALOMEDS_AttributeDrawable_i.hxx" +#include "SALOMEDS_AttributeSelectable_i.hxx" +#include "SALOMEDS_AttributeOpened_i.hxx" +#include "SALOMEDS_AttributeTextColor_i.hxx" +#include "SALOMEDS_AttributeTextHighlightColor_i.hxx" +#include "SALOMEDS_AttributePixMap_i.hxx" +#include "SALOMEDS_AttributeExpandable_i.hxx" +#include "SALOMEDS_AttributeLocalID_i.hxx" +#include "SALOMEDS_AttributeTarget_i.hxx" +#include "SALOMEDS_AttributeTableOfInteger_i.hxx" +#include "SALOMEDS_AttributeTableOfReal_i.hxx" +#include "SALOMEDS_AttributeTableOfString_i.hxx" +#include "SALOMEDS_AttributeStudyProperties_i.hxx" +#include "SALOMEDS_AttributePythonObject_i.hxx" +#include "SALOMEDS_AttributeTreeNode_i.hxx" +#include "SALOMEDS_AttributeUserID_i.hxx" +#include "SALOMEDS_AttributeExternalFileDef_i.hxx" +#include "SALOMEDS_AttributeFileType_i.hxx" #include "SALOMEDS_StudyBuilder_i.hxx" +#include "SALOMEDS_SequenceOfRealAttribute.hxx" +#include "SALOMEDS_SequenceOfIntegerAttribute.hxx" +#include "SALOMEDS_IORAttribute.hxx" +#include "SALOMEDS_PersRefAttribute.hxx" +#include "SALOMEDS_DrawableAttribute.hxx" +#include "SALOMEDS_SelectableAttribute.hxx" +#include "SALOMEDS_ExpandableAttribute.hxx" +#include "SALOMEDS_OpenedAttribute.hxx" +#include "SALOMEDS_TextColorAttribute.hxx" +#include "SALOMEDS_TextHighlightColorAttribute.hxx" +#include "SALOMEDS_PixMapAttribute.hxx" +#include "SALOMEDS_LocalIDAttribute.hxx" +#include "SALOMEDS_PythonObjectAttribute.hxx" +#include "SALOMEDS_TargetAttribute.hxx" +#include "SALOMEDS_StudyPropertiesAttribute.hxx" +#include "SALOMEDS_TableOfIntegerAttribute.hxx" +#include "SALOMEDS_TableOfRealAttribute.hxx" +#include "SALOMEDS_TableOfStringAttribute.hxx" +#include "SALOMEDS_ExternalFileDef.hxx" +#include "SALOMEDS_FileType.hxx" +#include "Utils_ExceptHandlers.hxx" +#define RegisteredAttributes 26 + +UNEXPECT_CATCH(GALockProtection, SALOMEDS::GenericAttribute::LockProtection); + +const char AttributesTypeNames[RegisteredAttributes][30] = { + "AttributeReal", "AttributeInteger", + "AttributeSequenceOfReal", "AttributeSequenceOfInteger", + "AttributeName", "AttributeComment", + "AttributeIOR", "AttributePersistentRef", + "AttributeDrawable", "AttributeSelectable", + "AttributeExpandable", "AttributeOpened", + "AttributeTextColor", "AttributeTextHighlightColor", "AttributePixMap", + "AttributeTreeNode", "AttributeLocalID", + "AttributeTarget", + "AttributeTableOfInteger", "AttributeTableOfReal", "AttributeTableOfString", + "AttributeStudyProperties", + "AttributePythonObject", + "AttributeUserID", + "ExternalFileDef", "FileType" +}; + +const Standard_GUID AttributesGUIDs[RegisteredAttributes] = { + TDataStd_Real::GetID(), TDataStd_Integer::GetID(), + SALOMEDS_SequenceOfRealAttribute::GetID(), SALOMEDS_SequenceOfIntegerAttribute::GetID(), + TDataStd_Name::GetID(), TDataStd_Comment::GetID(), + SALOMEDS_IORAttribute::GetID(), SALOMEDS_PersRefAttribute::GetID(), + SALOMEDS_DrawableAttribute::GetID(), SALOMEDS_SelectableAttribute::GetID(), + SALOMEDS_ExpandableAttribute::GetID(), SALOMEDS_OpenedAttribute::GetID(), + SALOMEDS_TextColorAttribute::GetID(), SALOMEDS_TextHighlightColorAttribute::GetID(), SALOMEDS_PixMapAttribute::GetID(), + TDataStd_TreeNode::GetDefaultTreeID(), SALOMEDS_LocalIDAttribute::GetID(), + SALOMEDS_TargetAttribute::GetID(), + SALOMEDS_TableOfIntegerAttribute::GetID(), SALOMEDS_TableOfRealAttribute::GetID(), SALOMEDS_TableOfStringAttribute::GetID(), + SALOMEDS_StudyPropertiesAttribute::GetID(), + SALOMEDS_PythonObjectAttribute::GetID(), + Standard_GUID("FFFFFFFF-D9CD-11d6-945D-1050DA506788"), + SALOMEDS_ExternalFileDef::GetID(), SALOMEDS_FileType::GetID() +}; + void SALOMEDS_GenericAttribute_i::CheckLocked() throw (SALOMEDS::GenericAttribute::LockProtection) { + Unexpect aCatch(GALockProtection); if (!_myAttr.IsNull() && _myAttr->IsValid() && !CORBA::is_nil(_myOrb)) { Handle(SALOMEDS_IORAttribute) Att; if (_myAttr->Label().Root().FindAttribute(SALOMEDS_IORAttribute::GetID(),Att)){ @@ -20,12 +102,107 @@ void SALOMEDS_GenericAttribute_i::CheckLocked() throw (SALOMEDS::GenericAttribut char* IOR = CORBA::string_dup(ch.ToCString()); CORBA::Object_var obj = _myOrb->string_to_object(IOR); SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj); - // ASSERT(!CORBA::is_nil(aStudy)); +// ASSERT(!CORBA::is_nil(aStudy)); if (aStudy->NewBuilder()->HasOpenCommand()) return; if (aStudy->GetProperties()->IsLocked()) { - // INFOS("Locked document modification !!!"); +// MESSAGE("Locked document modification !!!"); throw SALOMEDS::GenericAttribute::LockProtection(); } } } } + +SALOMEDS::SObject_ptr SALOMEDS_GenericAttribute_i::GetSObject() { + if (_myAttr.IsNull() || _myAttr->Label().IsNull()) return SALOMEDS::SObject::_nil(); + SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (_myAttr->Label(),_myOrb); + SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + return so._retn(); +} + +Standard_GUID SALOMEDS_GenericAttribute_i::GetGUID(const char* theType) { + Standard_Integer i; + for(i = 0; i < RegisteredAttributes; i++) { + if (strcmp(AttributesTypeNames[i], theType) == 0) return AttributesGUIDs[i]; + } + + if (strncmp(theType, "AttributeTreeNodeGUID",21) == 0) { + char* aGUIDString = new char[40]; + sprintf(aGUIDString, &(theType[21])); + Standard_GUID aGUID = Standard_GUID(aGUIDString); // create tree node GUID by name + delete(aGUIDString); + return aGUID; + } + return Standard_GUID(); +} + +char* SALOMEDS_GenericAttribute_i::Type() { + if (_myAttr.IsNull()) return ""; + int i; + for(i = 0; i < RegisteredAttributes; i++) { + if (_myAttr->ID() == AttributesGUIDs[i]) { + CORBA::String_var aString(AttributesTypeNames[i]); + return aString._retn(); + } + } + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); + if (!aNode.IsNull()) { + char* aNodeName = new char[60]; + char aGUID[40]; + aNode->ID().ToCString(aGUID); + sprintf(aNodeName, "AttributeTreeNodeGUID%s",aGUID); + return aNodeName; + } + + Handle(TDataStd_UAttribute) aUAttr = Handle(TDataStd_UAttribute)::DownCast(_myAttr); + if (!aUAttr.IsNull()) { + char* aUAttrName = new char[60]; + char aGUID[40]; + aUAttr->ID().ToCString(aGUID); + sprintf(aUAttrName, "AttributeUserID_%s",aGUID); + return aUAttrName; + } + + return ""; +} + +SALOMEDS::GenericAttribute_ptr SALOMEDS_GenericAttribute_i::CreateAttribute(CORBA::ORB_ptr theOrb, + const Handle(TDF_Attribute)& theAttr) { + + __ReturnCORBAAttribute(TDataStd_Real, AttributeReal); + __ReturnCORBAAttribute(TDataStd_Integer, AttributeInteger); + __ReturnCORBAAttribute(SALOMEDS_SequenceOfRealAttribute, AttributeSequenceOfReal); + __ReturnCORBAAttribute(SALOMEDS_SequenceOfIntegerAttribute, AttributeSequenceOfInteger); + __ReturnCORBAAttribute(TDataStd_Name, AttributeName); + __ReturnCORBAAttribute(TDataStd_Comment, AttributeComment); + __ReturnCORBAAttribute(SALOMEDS_IORAttribute, AttributeIOR); + __ReturnCORBAAttribute(SALOMEDS_PersRefAttribute, AttributePersistentRef); + __ReturnCORBAAttribute(SALOMEDS_DrawableAttribute, AttributeDrawable); + __ReturnCORBAAttribute(SALOMEDS_SelectableAttribute, AttributeSelectable); + __ReturnCORBAAttribute(SALOMEDS_ExpandableAttribute, AttributeExpandable); + __ReturnCORBAAttribute(SALOMEDS_OpenedAttribute, AttributeOpened); + __ReturnCORBAAttribute(SALOMEDS_TextColorAttribute, AttributeTextColor); + __ReturnCORBAAttribute(SALOMEDS_TextHighlightColorAttribute, AttributeTextHighlightColor); + __ReturnCORBAAttribute(SALOMEDS_PixMapAttribute, AttributePixMap); + __ReturnCORBAAttribute(SALOMEDS_LocalIDAttribute, AttributeLocalID); + __ReturnCORBAAttribute(SALOMEDS_TargetAttribute, AttributeTarget); + __ReturnCORBAAttribute(SALOMEDS_TableOfIntegerAttribute, AttributeTableOfInteger); + __ReturnCORBAAttribute(SALOMEDS_TableOfRealAttribute, AttributeTableOfReal); + __ReturnCORBAAttribute(SALOMEDS_TableOfStringAttribute, AttributeTableOfString); + __ReturnCORBAAttribute(SALOMEDS_StudyPropertiesAttribute, AttributeStudyProperties); + __ReturnCORBAAttribute(SALOMEDS_PythonObjectAttribute, AttributePythonObject); + __ReturnCORBAAttribute(SALOMEDS_ExternalFileDef, AttributeExternalFileDef); + __ReturnCORBAAttribute(SALOMEDS_FileType, AttributeFileType); + + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(theAttr); + if (!aNode.IsNull()) { + SALOMEDS_AttributeTreeNode_i* Attr = new SALOMEDS_AttributeTreeNode_i(aNode, theOrb); \ + return Attr->AttributeTreeNode::_this(); \ + } + + Handle(TDataStd_UAttribute) aUAttr = Handle(TDataStd_UAttribute)::DownCast(theAttr); + if (!aUAttr.IsNull()) { + SALOMEDS_AttributeUserID_i* Attr = new SALOMEDS_AttributeUserID_i(aUAttr, theOrb); \ + return Attr->AttributeUserID::_this(); \ + } + return SALOMEDS::GenericAttribute::_nil(); +} diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx index 6d404b719..2ea8c97fe 100644 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx @@ -34,7 +34,6 @@ #include CORBA_SERVER_HEADER(SALOMEDS) #include #include "SALOMEDS_SObject_i.hxx" -#include "SALOMEDS_IORAttribute.hxx" class SALOMEDS_GenericAttribute_i: public POA_SALOMEDS::GenericAttribute, public PortableServer::RefCountServantBase { @@ -45,16 +44,51 @@ public: SALOMEDS_GenericAttribute_i() {}; void CheckLocked() throw (SALOMEDS::GenericAttribute::LockProtection); + + char* Store() {return "";}; + + void Restore(const char*) {}; - ~SALOMEDS_GenericAttribute_i() {}; + char* Type(); -// CORBA::Boolean GetPtr(SALOMEDS::SObject_out so) { -// SALOMEDS_SObject_i* sob_impl = new SALOMEDS_SObject_i(_myAttr->Label(), _myOrb); -// SALOMEDS::SObject_var sob = sob_impl->_this(); -// return sob._retn(); -// }; + SALOMEDS::SObject_ptr GetSObject(); + + ~SALOMEDS_GenericAttribute_i() {}; + static Standard_GUID GetGUID(const char* theType); + static SALOMEDS::GenericAttribute_ptr CreateAttribute(CORBA::ORB_ptr theOrb, const Handle(TDF_Attribute)& theAttr); }; +// defines for creation attributes objects + +//cout<<"*** Create new CORBA attribute for "<<#CORBA_Name<ID() == OCAF_Name::GetID()) { \ + SALOMEDS_##CORBA_Name##_i* Attr = new SALOMEDS_##CORBA_Name##_i(Handle(OCAF_Name)::DownCast(theAttr), theOrb); \ + return Attr->CORBA_Name::_this(); \ + } + +//cout<<"Create New Attribute "<<#CORBA_Name<CORBA_Name::_this(); \ + } + +//cout<<"Create New Attribute "<<#CORBA_Name<CORBA_Name::_this(); \ + } + #endif diff --git a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.cxx b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.cxx index 9f8ece15c..f38360b4a 100644 --- a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.cxx @@ -24,7 +24,7 @@ // File : SALOMEDS_LocalIDAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ using namespace std; #include "SALOMEDS_LocalIDAttribute.ixx" diff --git a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.hxx b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.hxx index 6729106ed..0e930f04f 100644 --- a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.hxx +++ b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.hxx @@ -24,7 +24,7 @@ // File : SALOMEDS_LocalIDAttribute.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef _SALOMEDS_LocalIDAttribute_HeaderFile #define _SALOMEDS_LocalIDAttribute_HeaderFile diff --git a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.ixx b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.ixx index f50e7b9c3..56d6d331b 100644 --- a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.ixx +++ b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.ixx @@ -24,7 +24,7 @@ // File : SALOMEDS_LocalIDAttribute.ixx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #include "SALOMEDS_LocalIDAttribute.jxx" diff --git a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.jxx b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.jxx index aa12fd108..fc43ec07d 100644 --- a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.jxx +++ b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.jxx @@ -24,7 +24,7 @@ // File : SALOMEDS_LocalIDAttribute.jxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef _Standard_GUID_HeaderFile #include diff --git a/src/SALOMEDS/SALOMEDS_OpenedAttribute.cxx b/src/SALOMEDS/SALOMEDS_OpenedAttribute.cxx index d59512cdf..fc074bf13 100644 --- a/src/SALOMEDS/SALOMEDS_OpenedAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_OpenedAttribute.cxx @@ -24,7 +24,7 @@ // File : SALOMEDS_OpenedAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ using namespace std; #include "SALOMEDS_OpenedAttribute.ixx" diff --git a/src/SALOMEDS/SALOMEDS_PixMapAttribute.cxx b/src/SALOMEDS/SALOMEDS_PixMapAttribute.cxx index 3fde4f60e..fa84b6180 100644 --- a/src/SALOMEDS/SALOMEDS_PixMapAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_PixMapAttribute.cxx @@ -24,7 +24,7 @@ // File : SALOMEDS_PixMapAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ using namespace std; #include "SALOMEDS_PixMapAttribute.ixx" diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.cxx b/src/SALOMEDS/SALOMEDS_SObject_i.cxx index e10791ded..c202a0921 100644 --- a/src/SALOMEDS/SALOMEDS_SObject_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.cxx @@ -31,129 +31,10 @@ using namespace std; #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 -//============================================================================ -/*! 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 * Purpose : @@ -244,7 +125,7 @@ SALOMEDS::Study_ptr SALOMEDS_SObject_i::GetStudy() ASSERT(!CORBA::is_nil(Study)); return SALOMEDS::Study::_duplicate(Study); //return Study = abort... } - INFOS("Problem GetStudy"); + MESSAGE("Problem GetStudy"); return SALOMEDS::Study::_nil(); } @@ -257,139 +138,11 @@ CORBA::Boolean SALOMEDS_SObject_i::FindAttribute (SALOMEDS::GenericAttribute_out const char* aTypeOfAttribute) { Handle(TDF_Attribute) anAttr; - Standard_Boolean found = _lab.FindAttribute(SALOMEDS_SObject_i::ReturnGUIDForAttribute(aTypeOfAttribute), anAttr); - if (found) { - if (strcmp(aTypeOfAttribute, "AttributeReal") == 0 ) { - SALOMEDS_AttributeReal_i* Attr = new SALOMEDS_AttributeReal_i(Handle(TDataStd_Real)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeReal::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeInteger") == 0 ) { - SALOMEDS_AttributeInteger_i* Attr = new SALOMEDS_AttributeInteger_i(Handle(TDataStd_Integer)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeInteger::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfReal") == 0 ) { - SALOMEDS_AttributeSequenceOfReal_i* Attr = new SALOMEDS_AttributeSequenceOfReal_i(Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeSequenceOfReal::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfInteger") == 0 ) { - SALOMEDS_AttributeSequenceOfInteger_i* Attr = new SALOMEDS_AttributeSequenceOfInteger_i(Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeSequenceOfInteger::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeName") == 0 ) { - SALOMEDS_AttributeName_i* Attr = new SALOMEDS_AttributeName_i(Handle(TDataStd_Name)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeName::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeComment") == 0 ) { - SALOMEDS_AttributeComment_i* Attr = new SALOMEDS_AttributeComment_i(Handle(TDataStd_Comment)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeComment::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeExternalFileDef") == 0 ) { - SALOMEDS_AttributeExternalFileDef_i* Attr = new SALOMEDS_AttributeExternalFileDef_i(Handle(SALOMEDS_ExternalFileDef)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeExternalFileDef::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeFileType") == 0 ) { - SALOMEDS_AttributeFileType_i* Attr = new SALOMEDS_AttributeFileType_i(Handle(SALOMEDS_FileType)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeFileType::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0 ) { - SALOMEDS_AttributeIOR_i* Attr = new SALOMEDS_AttributeIOR_i(Handle(SALOMEDS_IORAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeIOR::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributePersistentRef") == 0 ) { - SALOMEDS_AttributePersistentRef_i* Attr = new SALOMEDS_AttributePersistentRef_i(Handle(SALOMEDS_PersRefAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributePersistentRef::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeDrawable") == 0 ) { - SALOMEDS_AttributeDrawable_i* Attr = new SALOMEDS_AttributeDrawable_i(Handle(SALOMEDS_DrawableAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeDrawable::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeSelectable") == 0 ) { - SALOMEDS_AttributeSelectable_i* Attr= new SALOMEDS_AttributeSelectable_i(Handle(SALOMEDS_SelectableAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeSelectable::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeExpandable") == 0 ) { - SALOMEDS_AttributeExpandable_i* Attr = new SALOMEDS_AttributeExpandable_i(Handle(SALOMEDS_ExpandableAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeExpandable::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeOpened") == 0 ) { - SALOMEDS_AttributeOpened_i* Attr= new SALOMEDS_AttributeOpened_i(Handle(SALOMEDS_OpenedAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeOpened::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTextColor") == 0 ) { - SALOMEDS_AttributeTextColor_i* Attr= new SALOMEDS_AttributeTextColor_i(Handle(SALOMEDS_TextColorAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTextColor::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTextHighlightColor") == 0 ) { - SALOMEDS_AttributeTextHighlightColor_i* Attr= new SALOMEDS_AttributeTextHighlightColor_i(Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTextHighlightColor::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributePixMap") == 0 ) { - SALOMEDS_AttributePixMap_i* Attr= new SALOMEDS_AttributePixMap_i(Handle(SALOMEDS_PixMapAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributePixMap::_this(); - return Standard_True; - } - else if (strncmp(aTypeOfAttribute, "AttributeTreeNode",17) == 0 ) { - SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTreeNode::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeLocalID") == 0 ) { - SALOMEDS_AttributeLocalID_i* Attr= new SALOMEDS_AttributeLocalID_i(Handle(SALOMEDS_LocalIDAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeLocalID::_this(); - return Standard_True; - } - else if (strncmp(aTypeOfAttribute, "AttributeUserID",15) == 0 ) { - SALOMEDS_AttributeUserID_i* Attr= new SALOMEDS_AttributeUserID_i(Handle(TDataStd_UAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeUserID::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTarget") == 0 ) { - SALOMEDS_AttributeTarget_i* Attr= new SALOMEDS_AttributeTarget_i(Handle(SALOMEDS_TargetAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTarget::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTableOfInteger") == 0 ) { - SALOMEDS_AttributeTableOfInteger_i* Attr = new SALOMEDS_AttributeTableOfInteger_i(Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTableOfInteger::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTableOfReal") == 0 ) { - SALOMEDS_AttributeTableOfReal_i* Attr = new SALOMEDS_AttributeTableOfReal_i(Handle(SALOMEDS_TableOfRealAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTableOfReal::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTableOfString") == 0 ) { - SALOMEDS_AttributeTableOfString_i* Attr = new SALOMEDS_AttributeTableOfString_i(Handle(SALOMEDS_TableOfStringAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTableOfString::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeStudyProperties") == 0 ) { - SALOMEDS_AttributeStudyProperties_i* Attr = new SALOMEDS_AttributeStudyProperties_i(Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeStudyProperties::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributePythonObject") == 0 ) { - SALOMEDS_AttributePythonObject_i* Attr = new SALOMEDS_AttributePythonObject_i(Handle(SALOMEDS_PythonObjectAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributePythonObject::_this(); - return Standard_True; - } - } else return Standard_False; + if (_lab.FindAttribute(SALOMEDS_GenericAttribute_i::GetGUID(aTypeOfAttribute), anAttr)) { + anAttribute = SALOMEDS::GenericAttribute::_duplicate(SALOMEDS_GenericAttribute_i::CreateAttribute(_orb, anAttr)); + return Standard_True; + } + return Standard_False; } //============================================================================ @@ -402,126 +155,16 @@ SALOMEDS::ListOfAttributes* SALOMEDS_SObject_i::GetAllAttributes() { Standard_Integer NumAttr = _lab.NbAttributes(); SALOMEDS::ListOfAttributes_var SeqOfAttr = new SALOMEDS::ListOfAttributes; - SeqOfAttr->length(NumAttr); + //SeqOfAttr->length(NumAttr); if (NumAttr != 0) { Standard_Integer i = 0; for(TDF_AttributeIterator iter(_lab);iter.More();iter.Next()) { Handle(TDF_Attribute) anAttr = iter.Value(); - SALOMEDS::GenericAttribute_var anAttribute; - if (ReturnGUIDForAttribute("AttributeReal") == anAttr->ID()) { - SALOMEDS_AttributeReal_i* Attr= new SALOMEDS_AttributeReal_i(Handle(TDataStd_Real)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeReal::_this(); - } - else if (ReturnGUIDForAttribute("AttributeInteger") == anAttr->ID()) { - SALOMEDS_AttributeInteger_i* Attr= new SALOMEDS_AttributeInteger_i(Handle(TDataStd_Integer)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeInteger::_this(); - } - else if (ReturnGUIDForAttribute("AttributeSequenceOfReal") == anAttr->ID()) { - SALOMEDS_AttributeSequenceOfReal_i* Attr= new SALOMEDS_AttributeSequenceOfReal_i(Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeSequenceOfReal::_this(); - } - else if (ReturnGUIDForAttribute("AttributeSequenceOfInteger") == anAttr->ID()) { - SALOMEDS_AttributeSequenceOfInteger_i* Attr= new SALOMEDS_AttributeSequenceOfInteger_i(Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeSequenceOfInteger::_this(); - } - else if (ReturnGUIDForAttribute("AttributeName") == anAttr->ID()) { - SALOMEDS_AttributeName_i* Attr= new SALOMEDS_AttributeName_i(Handle(TDataStd_Name)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeName::_this(); - } - else if (ReturnGUIDForAttribute("AttributeComment") == anAttr->ID()) { - SALOMEDS_AttributeComment_i* Attr= new SALOMEDS_AttributeComment_i(Handle(TDataStd_Comment)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeComment::_this(); - } - else if (ReturnGUIDForAttribute("AttributeExternalFileDef") == anAttr->ID()) { - SALOMEDS_AttributeExternalFileDef_i* Attr= new SALOMEDS_AttributeExternalFileDef_i(Handle(SALOMEDS_ExternalFileDef)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeExternalFileDef::_this(); - } - else if (ReturnGUIDForAttribute("AttributeFileType") == anAttr->ID()) { - SALOMEDS_AttributeFileType_i* Attr= new SALOMEDS_AttributeFileType_i(Handle(SALOMEDS_FileType)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeFileType::_this(); - } - else if (ReturnGUIDForAttribute("AttributeIOR") == anAttr->ID()) { - SALOMEDS_AttributeIOR_i* Attr= new SALOMEDS_AttributeIOR_i(Handle(SALOMEDS_IORAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeIOR::_this(); - } - else if (ReturnGUIDForAttribute("AttributePersistentRef") == anAttr->ID()) { - SALOMEDS_AttributePersistentRef_i* Attr= new SALOMEDS_AttributePersistentRef_i(Handle(SALOMEDS_PersRefAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributePersistentRef::_this(); + SALOMEDS::GenericAttribute_var anAttribute = SALOMEDS_GenericAttribute_i::CreateAttribute(_orb, anAttr); + if (!CORBA::is_nil(anAttribute)) { + SeqOfAttr->length(++i); + SeqOfAttr[i - 1] = anAttribute; } - else if (ReturnGUIDForAttribute("AttributeDrawable") == anAttr->ID()) { - SALOMEDS_AttributeDrawable_i* Attr= new SALOMEDS_AttributeDrawable_i(Handle(SALOMEDS_DrawableAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeDrawable::_this(); - } - else if (ReturnGUIDForAttribute("AttributeSelectable") == anAttr->ID()) { - SALOMEDS_AttributeSelectable_i* Attr= new SALOMEDS_AttributeSelectable_i(Handle(SALOMEDS_SelectableAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeSelectable::_this(); - } - else if (ReturnGUIDForAttribute("AttributeExpandable") == anAttr->ID()) { - SALOMEDS_AttributeExpandable_i* Attr= new SALOMEDS_AttributeExpandable_i(Handle(SALOMEDS_ExpandableAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeExpandable::_this(); - } - else if (ReturnGUIDForAttribute("AttributeOpened") == anAttr->ID()) { - SALOMEDS_AttributeOpened_i* Attr= new SALOMEDS_AttributeOpened_i(Handle(SALOMEDS_OpenedAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeOpened::_this(); - } - else if (ReturnGUIDForAttribute("AttributeTextColor") == anAttr->ID()) { - SALOMEDS_AttributeTextColor_i* Attr= new SALOMEDS_AttributeTextColor_i(Handle(SALOMEDS_TextColorAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTextColor::_this(); - } - else if (ReturnGUIDForAttribute("AttributeTextHighlightColor") == anAttr->ID()) { - SALOMEDS_AttributeTextHighlightColor_i* Attr= new SALOMEDS_AttributeTextHighlightColor_i(Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTextHighlightColor::_this(); - } - else if (ReturnGUIDForAttribute("AttributePixMap") == anAttr->ID()) { - SALOMEDS_AttributePixMap_i* Attr= new SALOMEDS_AttributePixMap_i(Handle(SALOMEDS_PixMapAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributePixMap::_this(); - } - else if (ReturnGUIDForAttribute("AttributeTreeNode") == anAttr->ID()) { - SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTreeNode::_this(); - } - else if (ReturnGUIDForAttribute("AttributeLocalID") == anAttr->ID()) { - SALOMEDS_AttributeLocalID_i* Attr= new SALOMEDS_AttributeLocalID_i(Handle(SALOMEDS_LocalIDAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeLocalID::_this(); - } - else if (ReturnGUIDForAttribute("AttributeTarget") == anAttr->ID()) { - SALOMEDS_AttributeTarget_i* Attr= new SALOMEDS_AttributeTarget_i(Handle(SALOMEDS_TargetAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTarget::_this(); - } - else if (ReturnGUIDForAttribute("AttributeTableOfInteger") == anAttr->ID()) { - SALOMEDS_AttributeTableOfInteger_i* Attr= new SALOMEDS_AttributeTableOfInteger_i(Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTableOfInteger::_this(); - } - else if (ReturnGUIDForAttribute("AttributeTableOfReal") == anAttr->ID()) { - SALOMEDS_AttributeTableOfReal_i* Attr= new SALOMEDS_AttributeTableOfReal_i(Handle(SALOMEDS_TableOfRealAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTableOfReal::_this(); - } - else if (ReturnGUIDForAttribute("AttributeTableOfString") == anAttr->ID()) { - SALOMEDS_AttributeTableOfString_i* Attr= new SALOMEDS_AttributeTableOfString_i(Handle(SALOMEDS_TableOfStringAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTableOfString::_this(); - } - else if (ReturnGUIDForAttribute("AttributeStudyProperties") == anAttr->ID()) { - SALOMEDS_AttributeStudyProperties_i* Attr= new SALOMEDS_AttributeStudyProperties_i(Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeStudyProperties::_this(); - } - else if (ReturnGUIDForAttribute("AttributePythonObject") == anAttr->ID()) { - SALOMEDS_AttributePythonObject_i* Attr= new SALOMEDS_AttributePythonObject_i(Handle(SALOMEDS_PythonObjectAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributePythonObject::_this(); - } - else if (!Handle(TDataStd_UAttribute)::DownCast(anAttr).IsNull()) { - SALOMEDS_AttributeUserID_i* Attr= new SALOMEDS_AttributeUserID_i(Handle(TDataStd_UAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeUserID::_this(); - } - else if (!Handle(TDataStd_TreeNode)::DownCast(anAttr).IsNull()) { - SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTreeNode::_this(); - } else { - // references attributes, for an example, never returns - continue; - } - - SeqOfAttr[i] = anAttribute; - i++; } } return SeqOfAttr._retn(); @@ -589,3 +232,64 @@ CORBA::Short SALOMEDS_SObject_i::Tag() { return _lab.Tag(); } + +//============================================================================ +/*! Function : + * Purpose : + */ +//============================================================================ +CORBA::Object_ptr SALOMEDS_SObject_i::GetObject() +{ + CORBA::Object_ptr obj = CORBA::Object::_nil(); + try { + Handle(SALOMEDS_IORAttribute) Att; + if (_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(),Att)) { + TCollection_AsciiString ch(Att->Get()); + char* IOR = CORBA::string_dup(ch.ToCString()); + obj = _orb->string_to_object(IOR); + } + } catch(...) {} + return obj; +} + +//============================================================================ +/*! Function : + * Purpose : + */ +//============================================================================ +char* SALOMEDS_SObject_i::GetName() { + CORBA::String_var aStr; + 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; + 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; + Handle(SALOMEDS_IORAttribute) anIOR; + if (_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anIOR)) { + aStr = CORBA::string_dup(TCollection_AsciiString(anIOR->Get()).ToCString()); + } + return aStr._retn(); +} diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.hxx b/src/SALOMEDS/SALOMEDS_SObject_i.hxx index be22a90b2..fa0fa58dc 100644 --- a/src/SALOMEDS/SALOMEDS_SObject_i.hxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.hxx @@ -80,12 +80,16 @@ public: virtual void Name(const char*); virtual SALOMEDS::ListOfAttributes* GetAllAttributes(); + virtual CORBA::Object_ptr GetObject(); + + virtual char* GetName(); + virtual char* GetComment(); + virtual char* GetIOR(); virtual CORBA::Short Tag(); static char* AttributeIDToType(Standard_GUID); static Standard_GUID ReturnGUIDForAttribute(const char* aTypeOfAttribute); - }; #endif diff --git a/src/SALOMEDS/SALOMEDS_SelectableAttribute.cxx b/src/SALOMEDS/SALOMEDS_SelectableAttribute.cxx index 241792584..40b179eca 100644 --- a/src/SALOMEDS/SALOMEDS_SelectableAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_SelectableAttribute.cxx @@ -24,7 +24,7 @@ // File : SALOMEDS_SelectableAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ using namespace std; #include "SALOMEDS_SelectableAttribute.ixx" diff --git a/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.cxx b/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.cxx index 51bdda48a..ed256eb0a 100644 --- a/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.cxx @@ -24,7 +24,7 @@ // File : SALOMEDS_SequenceOfIntegerAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ using namespace std; #include "SALOMEDS_SequenceOfIntegerAttribute.ixx" diff --git a/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.cxx b/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.cxx index 9e3cf84e9..9c8d3516d 100644 --- a/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.cxx @@ -24,7 +24,7 @@ // File : SALOMEDS_SequenceOfRealAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ using namespace std; #include "SALOMEDS_SequenceOfRealAttribute.ixx" diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx index d3cb87809..df8bf416c 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx @@ -38,11 +38,14 @@ using namespace std; #include "SALOMEDS_TargetAttribute.hxx" #include "SALOMEDS_StudyPropertiesAttribute.hxx" #include "SALOMEDS_PythonObjectAttribute.hxx" +#include "SALOMEDS_ExternalFileDef.hxx" +#include "SALOMEDS_FileType.hxx" #include #include #include #include #include +#include #include #include #include @@ -50,9 +53,9 @@ using namespace std; #include #include "SALOMEDS_AttributePersistentRef_i.hxx" #include "SALOMEDS_AttributeIOR_i.hxx" -#include "SALOMEDS_AttributeComment_i.hxx" #include "SALOMEDS_AttributeExternalFileDef_i.hxx" #include "SALOMEDS_AttributeFileType_i.hxx" +#include "SALOMEDS_AttributeComment_i.hxx" #include "SALOMEDS_AttributeName_i.hxx" #include "SALOMEDS_AttributeSequenceOfInteger_i.hxx" #include "SALOMEDS_AttributeSequenceOfReal_i.hxx" @@ -76,6 +79,7 @@ using namespace std; #include "SALOMEDS_AttributePythonObject_i.hxx" #include "SALOMEDS_Tool.hxx" #include "Utils_CorbaException.hxx" +#include "Utils_ExceptHandlers.hxx" #include #include @@ -84,6 +88,8 @@ using namespace std; #define DIRECTORYID 16661 #define FILELOCALID 26662 +UNEXPECT_CATCH(SBSalomeException, SALOME::SALOME_Exception); +UNEXPECT_CATCH(SBLockProtection, SALOMEDS::StudyBuilder::LockProtection); //============================================================================ /*! Function : constructor * Purpose : @@ -126,8 +132,8 @@ SALOMEDS_StudyBuilder_i::NewComponent(const char* DataType) imax++; TDF_Label NL = L.FindChild(imax); -// TDataStd_Comment::Set(NL,Standard_CString(DataType)); - TDataStd_Comment::Set(NL,Standard_CString(strdup(DataType))); + TDataStd_Comment::Set(NL,Standard_CString(DataType)); + // TDataStd_Comment::Set(NL,Standard_CString(CORBA::string_dup(DataType))); SALOMEDS_SComponent_i * so_servant = new SALOMEDS_SComponent_i (NL,_orb); SALOMEDS::SComponent_var so; @@ -151,12 +157,12 @@ void SALOMEDS_StudyBuilder_i::DefineComponentInstance(SALOMEDS::SComponent_ptr a TDF_Label Lab; ASSERT(!CORBA::is_nil(aComponent)); CORBA::String_var compid = aComponent->GetID(); - TDF_Tool::Label(_doc->GetData(),strdup(compid),Lab); + TDF_Tool::Label(_doc->GetData(),compid,Lab); //add IOR definition ASSERT(!CORBA::is_nil(IOR)); CORBA::String_var iorstr = _orb->object_to_string(IOR); - SALOMEDS_IORAttribute::Set(Lab,strdup(iorstr),_orb); + SALOMEDS_IORAttribute::Set(Lab,(char*)iorstr,_orb); } @@ -189,7 +195,7 @@ SALOMEDS_StudyBuilder_i::NewObject(SALOMEDS::SObject_ptr theFatherObject) ASSERT(!CORBA::is_nil(theFatherObject)); CORBA::String_var fatherid = theFatherObject->GetID(); - TDF_Tool::Label(_doc->GetData(),strdup(fatherid),Lab); + TDF_Tool::Label(_doc->GetData(),fatherid,Lab); //Create a new label //YFR DEBUG : 13/02/2002 TDF_Label NewLab = Lab.NewChild(); @@ -224,7 +230,7 @@ SALOMEDS_StudyBuilder_i::NewObjectToTag(SALOMEDS::SObject_ptr theFatherObject, ASSERT(!CORBA::is_nil(theFatherObject)); CORBA::String_var fatherid = theFatherObject->GetID(); - TDF_Tool::Label(_doc->GetData(),strdup(fatherid),Lab); + TDF_Tool::Label(_doc->GetData(),fatherid,Lab); //Create or find label TDF_Label NewLab = Lab.FindChild(atag,1); @@ -259,7 +265,7 @@ void SALOMEDS_StudyBuilder_i::RemoveObject(SALOMEDS::SObject_ptr anObject) Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)) - SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(strdup(TCollection_AsciiString(anAttr->Get()).ToCString())); + SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString()); Lab.ForgetAllAttributes(); } @@ -286,9 +292,9 @@ void SALOMEDS_StudyBuilder_i::RemoveObjectWithChildren(SALOMEDS::SObject_ptr anO } Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)) - SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(strdup(TCollection_AsciiString(anAttr->Get()).ToCString())); + SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString()); - TDF_ChildIterator it(Lab); + TDF_ChildIterator it(Lab, Standard_True); for(;it.More();it.Next()) { TDF_Label aLabel = it.Value(); if (aLabel.FindAttribute(TDF_Reference::GetID(), aReference)) { @@ -298,7 +304,7 @@ void SALOMEDS_StudyBuilder_i::RemoveObjectWithChildren(SALOMEDS::SObject_ptr anO } Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects if (aLabel.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)) - SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(strdup(TCollection_AsciiString(anAttr->Get()).ToCString())); + SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString()); } Lab.ForgetAllAttributes(Standard_True); @@ -337,7 +343,7 @@ static void Translate_persistentID_to_IOR(TDF_Label Lab, CORBA::String_var ior_string = driver->LocalPersistentIDToIOR(so, persistent_string, isMultiFile, isASCII); - TCollection_ExtendedString value(strdup(ior_string )); + TCollection_ExtendedString value(ior_string); SALOMEDS_IORAttribute::Set (current,value,orb); //TCollection_AsciiString anEntry;TDF_Tool::Entry (current,anEntry); //SRN: No use here @@ -358,17 +364,18 @@ static void Translate_persistentID_to_IOR(TDF_Label Lab, void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, SALOMEDS::Driver_ptr aDriver) throw(SALOME::SALOME_Exception) { + Unexpect aCatch(SBSalomeException); TDF_Label Lab; ASSERT(!CORBA::is_nil(anSCO)); CORBA::String_var scoid = anSCO->GetID(); - TDF_Tool::Label(_doc->GetData(),strdup(scoid),Lab); + TDF_Tool::Label(_doc->GetData(),scoid,Lab); Handle(TDF_Attribute) Att; - + //Find the current Url of the study if (_doc->Main().FindAttribute(SALOMEDS_PersRefAttribute::GetID(),Att)) { int aLocked = anSCO->GetStudy()->GetProperties()->IsLocked(); if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(false); - + TCollection_ExtendedString Res = Handle(TDataStd_Comment)::DownCast(Att)->Get(); Handle(TDataStd_Comment) type; @@ -377,7 +384,7 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, DataType = type->Get(); else MESSAGE("No Data Type"); - + // associate the driver to the SComponent ASSERT(!CORBA::is_nil(aDriver)); // mpv 06.03.2003: SAL1927 - if component data if already loaded, it is not necessary to do it again @@ -386,9 +393,9 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, return; } DefineComponentInstance (anSCO, aDriver); - + TCollection_AsciiString aHDFPath(Res); - + char* aHDFUrl; bool isASCII = false; if (HDFascii::isASCII(aHDFPath.ToCString())) { @@ -398,12 +405,12 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, sprintf(aHDFUrl, "%shdf_from_ascii.hdf", aResultPath); delete(aResultPath); } else { - aHDFUrl = strdup(aHDFPath.ToCString()); + aHDFUrl = CORBA::string_dup(aHDFPath.ToCString()); } //Open the Study HDF file HDFfile *hdf_file = new HDFfile(aHDFUrl); - + char aMultifileState[2]; char ASCIIfileState[2]; try { @@ -413,7 +420,7 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, hdf_group->OpenOnDisk(); HDFgroup *hdf_sco_group = new HDFgroup(scoid, hdf_group); hdf_sco_group->OpenOnDisk(); - + SALOMEDS::TMPFile_var aStreamFile; if (hdf_sco_group->ExistInternalObject("FILE_STREAM")) { HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group); @@ -430,11 +437,11 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, HDFdataset *multifile_hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group); multifile_hdf_dataset->OpenOnDisk(); multifile_hdf_dataset->ReadFromDisk(aMultifileState); - + HDFdataset *ascii_hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group); ascii_hdf_dataset->OpenOnDisk(); ascii_hdf_dataset->ReadFromDisk(ASCIIfileState); - + // set path without file name from URL int aFileNameSize = Res.Length(); char* aDir = new char[aFileNameSize]; @@ -444,24 +451,24 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, aDir[aCounter+1] = 0; break; } - + CORBA::Boolean aResult = (ASCIIfileState[0]=='A')? aDriver->LoadASCII(anSCO, aStreamFile.in(), aDir, aMultifileState[0]=='M'): - aDriver->Load(anSCO, aStreamFile.in(), aDir, aMultifileState[0]=='M'); + aDriver->Load(anSCO, aStreamFile.in(), aDir, aMultifileState[0]=='M'); if(!aResult) { RemoveAttribute( anSCO, "AttributeIOR" ); if (isASCII) { SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames; aFilesToRemove->length(1); - aFilesToRemove[0] = strdup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))])); + aFilesToRemove[0] = CORBA::string_dup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))])); SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true); } delete aHDFUrl; MESSAGE("Can't load component"); THROW_SALOME_CORBA_EXCEPTION("Unable to load component data",SALOME::BAD_PARAM); -// throw HDFexception("Unable to load component"); + // throw HDFexception("Unable to load component"); } - + delete(aDir); multifile_hdf_dataset->CloseOnDisk(); @@ -474,22 +481,22 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, hdf_group = 0; hdf_file->CloseOnDisk(); delete hdf_file; - + if (isASCII) { SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames; aFilesToRemove->length(1); - aFilesToRemove[0] = strdup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))])); + aFilesToRemove[0] = CORBA::string_dup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))])); SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true); } delete aHDFUrl; } catch (HDFexception) { - MESSAGE("No persistent file Name"); + INFOS("No persistent file Name"); delete hdf_file; if (isASCII) { SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames; aFilesToRemove->length(1); - aFilesToRemove[0] = strdup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))])); + aFilesToRemove[0] = CORBA::string_dup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))])); SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true); } delete aHDFUrl; @@ -500,10 +507,10 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, try { Translate_persistentID_to_IOR (Lab,aDriver,_orb, aMultifileState[0]=='M', ASCIIfileState[0] == 'A'); } catch (SALOME::SALOME_Exception) { - MESSAGE("Can't translate PersRef to IOR"); + INFOS("Can't translate PersRef to IOR"); if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true); THROW_SALOME_CORBA_EXCEPTION("Unable to convert component persistent data to the transient",SALOME::BAD_PARAM); -// throw HDFexception("Unable to load component data"); + // throw HDFexception("Unable to load component data"); } if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true); } else @@ -521,234 +528,54 @@ void SALOMEDS_StudyBuilder_i::Load(SALOMEDS::SObject_ptr sco) MESSAGE ( "This function is not yet implemented"); } -//============================================================================ -/*! Function : AddAttribute - * Purpose : - */ -//============================================================================ -/* -void SALOMEDS_StudyBuilder_i::AddAttribute(SALOMEDS::SObject_ptr anObject, - SALOMEDS::AttributeType aType, - const char * AttributeValue ) -{ - TDF_Label Lab; - ASSERT(!CORBA::is_nil(anObject)); - CORBA::String_var anobid = anObject->GetID(); - TDF_Tool::Label(_doc->GetData(),strdup(anobid),Lab); - - TCollection_ExtendedString Value(strdup(AttributeValue)); - - Standard_GUID ID = SALOMEDS_SObject_i::TypeToAttributeID(aType); - - if (ID == TDataStd_Name::GetID()) TDataStd_Name::Set (Lab,Value); - else if (ID == TDataStd_Comment::GetID()) TDataStd_Comment::Set (Lab,Value); - else if (ID == SALOMEDS_IORAttribute::GetID()) SALOMEDS_IORAttribute::Set (Lab,Value); - else if (ID == SALOMEDS_PersRefAttribute::GetID()) SALOMEDS_PersRefAttribute::Set(Lab,Value); -} -*/ //============================================================================ /*! Function : FindOrCreateAttribute * Purpose : Add attribute of given type to SObject, if there is attribute of such type, returns * existing one */ //============================================================================ - SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SALOMEDS::SObject_ptr anObject, const char* aTypeOfAttribute) { TDF_Label Lab; ASSERT(!CORBA::is_nil(anObject)); CORBA::String_var anobid = anObject->GetID(); - TDF_Tool::Label(_doc->GetData(),strdup(anobid),Lab); - - if (strcmp(aTypeOfAttribute, "AttributeReal") == 0 ) { - Handle(TDataStd_Real) anAttr; - if (!Lab.FindAttribute(TDataStd_Real::GetID(), anAttr)) { - CheckLocked(); - anAttr = new TDataStd_Real; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeReal_i* aRealAttr = new SALOMEDS_AttributeReal_i(anAttr, _orb); - SALOMEDS::AttributeReal_var aRA = aRealAttr->AttributeReal::_this(); - return aRA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeInteger") == 0 ) { - Handle(TDataStd_Integer) anAttr; - if (!Lab.FindAttribute(TDataStd_Integer::GetID(), anAttr)) { - CheckLocked(); - anAttr = new TDataStd_Integer; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeInteger_i* aIntAttr = new SALOMEDS_AttributeInteger_i(anAttr, _orb); - SALOMEDS::AttributeInteger_var aIA = aIntAttr->AttributeInteger::_this(); - return aIA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfReal") == 0 ) { - Handle(SALOMEDS_SequenceOfRealAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_SequenceOfRealAttribute::GetID(), anAttr)) { - CheckLocked(); - anAttr = new SALOMEDS_SequenceOfRealAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeSequenceOfReal_i* aSeqRealAttr = new SALOMEDS_AttributeSequenceOfReal_i(anAttr, _orb); - SALOMEDS::AttributeSequenceOfReal_var aSRA = aSeqRealAttr->AttributeSequenceOfReal::_this(); - return aSRA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfInteger") == 0 ) { - Handle(SALOMEDS_SequenceOfIntegerAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_SequenceOfIntegerAttribute::GetID(), anAttr)) { - CheckLocked(); - anAttr = new SALOMEDS_SequenceOfIntegerAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeSequenceOfInteger_i* aSeqIntegerAttr = new SALOMEDS_AttributeSequenceOfInteger_i(anAttr, _orb); - SALOMEDS::AttributeSequenceOfInteger_var aSIA = aSeqIntegerAttr->AttributeSequenceOfInteger::_this(); - return aSIA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeName") == 0 ) { - Handle(TDataStd_Name) anAttr; - if (!Lab.FindAttribute(TDataStd_Name::GetID(), anAttr)) { - CheckLocked(); - anAttr = new TDataStd_Name; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeName_i* aNameAttr = new SALOMEDS_AttributeName_i(anAttr, _orb); - SALOMEDS::AttributeName_var aSNA = aNameAttr->AttributeName::_this(); - return aSNA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeComment") == 0 ) { - Handle(TDataStd_Comment) anAttr; - if (!Lab.FindAttribute(TDataStd_Comment::GetID(), anAttr)) { - CheckLocked(); - anAttr = new TDataStd_Comment; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeComment_i* aCommentAttr = new SALOMEDS_AttributeComment_i(anAttr, _orb); - SALOMEDS::AttributeComment_var aCA = aCommentAttr->AttributeComment::_this(); - return aCA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeExternalFileDef") == 0 ) { - Handle(SALOMEDS_ExternalFileDef) anAttr; - if (!Lab.FindAttribute(SALOMEDS_ExternalFileDef::GetID(), anAttr)) { - anAttr = new SALOMEDS_ExternalFileDef; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeExternalFileDef_i* anExternalFileDefAttr = new SALOMEDS_AttributeExternalFileDef_i(anAttr, _orb); - SALOMEDS::AttributeExternalFileDef_var aCA = anExternalFileDefAttr->AttributeExternalFileDef::_this(); - return aCA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeFileType") == 0 ) { - Handle(SALOMEDS_FileType) anAttr; - if (!Lab.FindAttribute(SALOMEDS_FileType::GetID(), anAttr)) { - anAttr = new SALOMEDS_FileType; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeFileType_i* anFileTypeAttr = new SALOMEDS_AttributeFileType_i(anAttr, _orb); - SALOMEDS::AttributeFileType_var aCA = anFileTypeAttr->AttributeFileType::_this(); - return aCA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0 ) { - Handle(SALOMEDS_IORAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)) { - CheckLocked(); - anAttr = new SALOMEDS_IORAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeIOR_i* aIORAttr = new SALOMEDS_AttributeIOR_i(anAttr, _orb); - SALOMEDS::AttributeIOR_var aIA = aIORAttr->AttributeIOR::_this(); - return aIA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributePersistentRef") == 0 ) { - Handle(SALOMEDS_PersRefAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_PersRefAttribute::GetID(), anAttr)) { - anAttr = new SALOMEDS_PersRefAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributePersistentRef_i* aPerRefAttr = new SALOMEDS_AttributePersistentRef_i(anAttr, _orb); - SALOMEDS::AttributePersistentRef_var aPRA = aPerRefAttr->AttributePersistentRef::_this(); - return aPRA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeDrawable") == 0 ) { - Handle(SALOMEDS_DrawableAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_DrawableAttribute::GetID(), anAttr)) { - anAttr = new SALOMEDS_DrawableAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeDrawable_i* aDrawableAttr = new SALOMEDS_AttributeDrawable_i(anAttr, _orb); - SALOMEDS::AttributeDrawable_var aDrawA = aDrawableAttr->AttributeDrawable::_this(); - return aDrawA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeSelectable") == 0 ) { - Handle(SALOMEDS_SelectableAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_SelectableAttribute::GetID(), anAttr)) { - anAttr = new SALOMEDS_SelectableAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeSelectable_i* aSelectableAttr = new SALOMEDS_AttributeSelectable_i(anAttr, _orb); - SALOMEDS::AttributeSelectable_var aSelA = aSelectableAttr->AttributeSelectable::_this(); - return aSelA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeExpandable") == 0 ) { - Handle(SALOMEDS_ExpandableAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_ExpandableAttribute::GetID(), anAttr)) { - anAttr = new SALOMEDS_ExpandableAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeExpandable_i* aExpandableAttr = new SALOMEDS_AttributeExpandable_i(anAttr, _orb); - SALOMEDS::AttributeExpandable_var aExpA = aExpandableAttr->AttributeExpandable::_this(); - return aExpA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeOpened") == 0 ) { - Handle(SALOMEDS_OpenedAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_OpenedAttribute::GetID(), anAttr)) { - anAttr = new SALOMEDS_OpenedAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeOpened_i* aOpenedAttr = new SALOMEDS_AttributeOpened_i(anAttr, _orb); - SALOMEDS::AttributeOpened_var aOpenA = aOpenedAttr->AttributeOpened::_this(); - return aOpenA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeTextColor") == 0 ) { - Handle(SALOMEDS_TextColorAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_TextColorAttribute::GetID(), anAttr)) { - CheckLocked(); - anAttr = new SALOMEDS_TextColorAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeTextColor_i* aTextColorAttr = new SALOMEDS_AttributeTextColor_i(anAttr, _orb); - SALOMEDS::AttributeTextColor_var aTCA = aTextColorAttr->AttributeTextColor::_this(); - return aTCA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeTextHighlightColor") == 0 ) { - Handle(SALOMEDS_TextHighlightColorAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_TextHighlightColorAttribute::GetID(), anAttr)) { - CheckLocked(); - anAttr = new SALOMEDS_TextHighlightColorAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeTextHighlightColor_i* aTextHighlightColorAttr = new SALOMEDS_AttributeTextHighlightColor_i(anAttr, _orb); - SALOMEDS::AttributeTextHighlightColor_var aTHCA = aTextHighlightColorAttr->AttributeTextHighlightColor::_this(); - return aTHCA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributePixMap") == 0 ) { - Handle(SALOMEDS_PixMapAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_PixMapAttribute::GetID(), anAttr)) { - CheckLocked(); - anAttr = new SALOMEDS_PixMapAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributePixMap_i* aPixMapAttr = new SALOMEDS_AttributePixMap_i(anAttr, _orb); - SALOMEDS::AttributePixMap_var aPMA = aPixMapAttr->AttributePixMap::_this(); - return aPMA._retn(); - } - else if (strncmp(aTypeOfAttribute, "AttributeTreeNode",17) == 0 ) { + TDF_Tool::Label(_doc->GetData(),anobid,Lab); + + __FindOrCreateAttributeLocked(TDataStd_Real, AttributeReal) + __FindOrCreateAttributeLocked(TDataStd_Integer, AttributeInteger) + __FindOrCreateAttributeLocked(SALOMEDS_SequenceOfRealAttribute, AttributeSequenceOfReal) + __FindOrCreateAttributeLocked(SALOMEDS_SequenceOfIntegerAttribute, AttributeSequenceOfInteger) + __FindOrCreateAttributeLocked(TDataStd_Name, AttributeName) + __FindOrCreateAttributeLocked(TDataStd_Comment, AttributeComment) + __FindOrCreateAttributeLocked(SALOMEDS_IORAttribute, AttributeIOR) + __FindOrCreateAttributeLocked(SALOMEDS_PixMapAttribute, AttributePixMap) + __FindOrCreateAttributeLocked(SALOMEDS_LocalIDAttribute, AttributeLocalID) + __FindOrCreateAttributeLocked(SALOMEDS_TableOfIntegerAttribute, AttributeTableOfInteger) + __FindOrCreateAttributeLocked(SALOMEDS_TableOfRealAttribute, AttributeTableOfReal) + __FindOrCreateAttributeLocked(SALOMEDS_TableOfStringAttribute, AttributeTableOfString) + __FindOrCreateAttributeLocked(SALOMEDS_PythonObjectAttribute, AttributePythonObject) + + __FindOrCreateAttribute(SALOMEDS_PersRefAttribute, AttributePersistentRef) + __FindOrCreateAttribute(SALOMEDS_DrawableAttribute, AttributeDrawable) + __FindOrCreateAttribute(SALOMEDS_SelectableAttribute, AttributeSelectable) + __FindOrCreateAttribute(SALOMEDS_ExpandableAttribute, AttributeExpandable) + __FindOrCreateAttribute(SALOMEDS_OpenedAttribute, AttributeOpened) + __FindOrCreateAttribute(SALOMEDS_TextColorAttribute, AttributeTextColor) + __FindOrCreateAttribute(SALOMEDS_TextHighlightColorAttribute, AttributeTextHighlightColor) + __FindOrCreateAttribute(SALOMEDS_TargetAttribute, AttributeTarget) + __FindOrCreateAttribute(SALOMEDS_StudyPropertiesAttribute, AttributeStudyProperties) + __FindOrCreateAttribute(SALOMEDS_ExternalFileDef, AttributeExternalFileDef) + __FindOrCreateAttribute(SALOMEDS_FileType, AttributeFileType) + + if (strncmp(aTypeOfAttribute, "AttributeTreeNode",17) == 0 ) { Standard_GUID aTreeNodeGUID; - if (strcmp(aTypeOfAttribute, "AttributeTreeNode") == 0) + if (strcmp(aTypeOfAttribute, "AttributeTreeNode") == 0) { aTreeNodeGUID = TDataStd_TreeNode::GetDefaultTreeID(); - else { + } else { char* aGUIDString = new char[40]; sprintf(aGUIDString, &(aTypeOfAttribute[21])); - Standard_GUID aGUID = Standard_GUID(aGUIDString); // create tree node GUID by name + aTreeNodeGUID = Standard_GUID(aGUIDString); // create tree node GUID by name delete(aGUIDString); } Handle(TDataStd_TreeNode) anAttr; @@ -757,98 +584,19 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA anAttr = TDataStd_TreeNode::Set(Lab, aTreeNodeGUID); } SALOMEDS_AttributeTreeNode_i* aTreeNodeAttr = new SALOMEDS_AttributeTreeNode_i(anAttr, _orb); - SALOMEDS::AttributeTreeNode_var aTNA = aTreeNodeAttr->AttributeTreeNode::_this(); - return aTNA._retn(); + return aTreeNodeAttr->AttributeTreeNode::_this(); } - else if (strncmp(aTypeOfAttribute, "AttributeUserID",15) == 0 ) { + + if (strncmp(aTypeOfAttribute, "AttributeUserID",15) == 0 ) { Handle(TDataStd_UAttribute) anAttr; if (!Lab.FindAttribute(SALOMEDS_AttributeUserID_i::DefaultID(), anAttr)) { CheckLocked(); anAttr = TDataStd_UAttribute::Set(Lab, SALOMEDS_AttributeUserID_i::DefaultID()); } SALOMEDS_AttributeUserID_i* aUAttr = new SALOMEDS_AttributeUserID_i(anAttr, _orb); - SALOMEDS::AttributeUserID_var aUA = aUAttr->AttributeUserID::_this(); - return aUA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeLocalID") == 0 ) { - Handle(SALOMEDS_LocalIDAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_LocalIDAttribute::GetID(), anAttr)) { - CheckLocked(); - anAttr = new SALOMEDS_LocalIDAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeLocalID_i* aLIDAttr = new SALOMEDS_AttributeLocalID_i(anAttr, _orb); - SALOMEDS::AttributeLocalID_var aLIDA = aLIDAttr->AttributeLocalID::_this(); - return aLIDA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeTarget") == 0 ) { - Handle(SALOMEDS_TargetAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_TargetAttribute::GetID(), anAttr)) { - anAttr = new SALOMEDS_TargetAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeTarget_i* aLIDAttr = new SALOMEDS_AttributeTarget_i(anAttr, _orb); - SALOMEDS::AttributeTarget_var aLIDA = aLIDAttr->AttributeTarget::_this(); - return aLIDA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeTableOfInteger") == 0 ) { - Handle(SALOMEDS_TableOfIntegerAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_TableOfIntegerAttribute::GetID(), anAttr)) { - CheckLocked(); - anAttr = new SALOMEDS_TableOfIntegerAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeTableOfInteger_i* aTabIntegerAttr = new SALOMEDS_AttributeTableOfInteger_i(anAttr, _orb); - SALOMEDS::AttributeTableOfInteger_var aTIA = aTabIntegerAttr->AttributeTableOfInteger::_this(); - return aTIA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeTableOfReal") == 0 ) { - Handle(SALOMEDS_TableOfRealAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_TableOfRealAttribute::GetID(), anAttr)) { - CheckLocked(); - anAttr = new SALOMEDS_TableOfRealAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeTableOfReal_i* aTabRealAttr = new SALOMEDS_AttributeTableOfReal_i(anAttr, _orb); - SALOMEDS::AttributeTableOfReal_var aTRA = aTabRealAttr->AttributeTableOfReal::_this(); - return aTRA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeTableOfString") == 0 ) { - Handle(SALOMEDS_TableOfStringAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_TableOfStringAttribute::GetID(), anAttr)) { - CheckLocked(); - anAttr = new SALOMEDS_TableOfStringAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributeTableOfString_i* aTabStringAttr = new SALOMEDS_AttributeTableOfString_i(anAttr, _orb); - SALOMEDS::AttributeTableOfString_var aTRA = aTabStringAttr->AttributeTableOfString::_this(); - return aTRA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributeStudyProperties") == 0 ) { - Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { - CheckLocked(); - if (!Lab.FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { - anAttr = new SALOMEDS_StudyPropertiesAttribute; - Lab.AddAttribute(anAttr); - anAttr->SetModified(0); - } - } - SALOMEDS_AttributeStudyProperties_i* aStPropAttr = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb); - SALOMEDS::AttributeStudyProperties_var aSPA = aStPropAttr->AttributeStudyProperties::_this(); - return aSPA._retn(); - } - else if (strcmp(aTypeOfAttribute, "AttributePythonObject") == 0 ) { - Handle(SALOMEDS_PythonObjectAttribute) anAttr; - if (!Lab.FindAttribute(SALOMEDS_PythonObjectAttribute::GetID(), anAttr)) { - CheckLocked(); - anAttr = new SALOMEDS_PythonObjectAttribute; - Lab.AddAttribute(anAttr); - } - SALOMEDS_AttributePythonObject_i* aPObjAttr = new SALOMEDS_AttributePythonObject_i(anAttr, _orb); - SALOMEDS::AttributePythonObject_var aPOA = aPObjAttr->AttributePythonObject::_this(); - return aPOA._retn(); + return aUAttr->AttributeUserID::_this(); } + return SALOMEDS::GenericAttribute::_nil(); } //============================================================================ @@ -864,141 +612,13 @@ CORBA::Boolean SALOMEDS_StudyBuilder_i::FindAttribute(SALOMEDS::SObject_ptr anOb TDF_Label Lab; ASSERT(!CORBA::is_nil(anObject)); CORBA::String_var anobid = anObject->GetID(); - TDF_Tool::Label(_doc->GetData(),strdup(anobid),Lab); + TDF_Tool::Label(_doc->GetData(),anobid,Lab); Handle(TDF_Attribute) anAttr; - Standard_Boolean found = Lab.FindAttribute(SALOMEDS_SObject_i::ReturnGUIDForAttribute(aTypeOfAttribute), anAttr); - if (found) { - if (strcmp(aTypeOfAttribute, "AttributeReal") == 0 ) { - SALOMEDS_AttributeReal_i* Attr= new SALOMEDS_AttributeReal_i(Handle(TDataStd_Real)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeReal::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeInteger") == 0 ) { - SALOMEDS_AttributeInteger_i* Attr= new SALOMEDS_AttributeInteger_i(Handle(TDataStd_Integer)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeInteger::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfReal") == 0 ) { - SALOMEDS_AttributeSequenceOfReal_i* Attr= new SALOMEDS_AttributeSequenceOfReal_i(Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeSequenceOfReal::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfInteger") == 0 ) { - SALOMEDS_AttributeSequenceOfInteger_i* Attr= new SALOMEDS_AttributeSequenceOfInteger_i(Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeSequenceOfInteger::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeName") == 0 ) { - SALOMEDS_AttributeName_i* Attr= new SALOMEDS_AttributeName_i(Handle(TDataStd_Name)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeName::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeComment") == 0 ) { - SALOMEDS_AttributeComment_i* Attr= new SALOMEDS_AttributeComment_i(Handle(TDataStd_Comment)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeComment::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeExternalFileDef") == 0 ) { - SALOMEDS_AttributeExternalFileDef_i* Attr= new SALOMEDS_AttributeExternalFileDef_i(Handle(SALOMEDS_ExternalFileDef)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeExternalFileDef::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeFileType") == 0 ) { - SALOMEDS_AttributeFileType_i* Attr= new SALOMEDS_AttributeFileType_i(Handle(SALOMEDS_FileType)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeFileType::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0 ) { - SALOMEDS_AttributeIOR_i* Attr= new SALOMEDS_AttributeIOR_i(Handle(SALOMEDS_IORAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeIOR::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributePersistentRef") == 0 ) { - SALOMEDS_AttributePersistentRef_i* Attr= new SALOMEDS_AttributePersistentRef_i(Handle(SALOMEDS_PersRefAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributePersistentRef::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeDrawable") == 0 ) { - SALOMEDS_AttributeDrawable_i* Attr= new SALOMEDS_AttributeDrawable_i(Handle(SALOMEDS_DrawableAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeDrawable::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeSelectable") == 0 ) { - SALOMEDS_AttributeSelectable_i* Attr= new SALOMEDS_AttributeSelectable_i(Handle(SALOMEDS_SelectableAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeSelectable::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeExpandable") == 0 ) { - SALOMEDS_AttributeExpandable_i* Attr= new SALOMEDS_AttributeExpandable_i(Handle(SALOMEDS_ExpandableAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeExpandable::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeOpened") == 0 ) { - SALOMEDS_AttributeOpened_i* Attr= new SALOMEDS_AttributeOpened_i(Handle(SALOMEDS_OpenedAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeOpened::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTextColor") == 0 ) { - SALOMEDS_AttributeTextColor_i* Attr= new SALOMEDS_AttributeTextColor_i(Handle(SALOMEDS_TextColorAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTextColor::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTextHighlightColor") == 0 ) { - SALOMEDS_AttributeTextHighlightColor_i* Attr= new SALOMEDS_AttributeTextHighlightColor_i(Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTextHighlightColor::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributePixMap") == 0 ) { - SALOMEDS_AttributePixMap_i* Attr= new SALOMEDS_AttributePixMap_i(Handle(SALOMEDS_PixMapAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributePixMap::_this(); - return Standard_True; - } - else if (strncmp(aTypeOfAttribute, "AttributeTreeNode",17) == 0 ) { - SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTreeNode::_this(); - return Standard_True; - } - else if (strncmp(aTypeOfAttribute, "AttributeUserID",15) == 0 ) { - SALOMEDS_AttributeUserID_i* Attr= new SALOMEDS_AttributeUserID_i(Handle(TDataStd_UAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeUserID::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeLocalID") == 0 ) { - SALOMEDS_AttributeLocalID_i* Attr= new SALOMEDS_AttributeLocalID_i(Handle(SALOMEDS_LocalIDAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeLocalID::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTarget") == 0 ) { - SALOMEDS_AttributeTarget_i* Attr= new SALOMEDS_AttributeTarget_i(Handle(SALOMEDS_TargetAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTarget::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTableOfInteger") == 0 ) { - SALOMEDS_AttributeTableOfInteger_i* Attr= new SALOMEDS_AttributeTableOfInteger_i(Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTableOfInteger::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTableOfReal") == 0 ) { - SALOMEDS_AttributeTableOfReal_i* Attr= new SALOMEDS_AttributeTableOfReal_i(Handle(SALOMEDS_TableOfRealAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTableOfReal::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeTableOfString") == 0 ) { - SALOMEDS_AttributeTableOfString_i* Attr= new SALOMEDS_AttributeTableOfString_i(Handle(SALOMEDS_TableOfStringAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeTableOfString::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributeStudyProperties") == 0 ) { - SALOMEDS_AttributeStudyProperties_i* Attr= new SALOMEDS_AttributeStudyProperties_i(Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributeStudyProperties::_this(); - return Standard_True; - } - else if (strcmp(aTypeOfAttribute, "AttributePythonObject") == 0 ) { - SALOMEDS_AttributePythonObject_i* Attr= new SALOMEDS_AttributePythonObject_i(Handle(SALOMEDS_PythonObjectAttribute)::DownCast(anAttr), _orb); - anAttribute = Attr->AttributePythonObject::_this(); - return Standard_True; - } - } else return Standard_False; + if (Lab.FindAttribute(SALOMEDS_GenericAttribute_i::GetGUID(aTypeOfAttribute), anAttr)) { + anAttribute = SALOMEDS::GenericAttribute::_duplicate(SALOMEDS_GenericAttribute_i::CreateAttribute(_orb, anAttr)); + return Standard_True; + } + return Standard_False; } //============================================================================ @@ -1014,16 +634,16 @@ void SALOMEDS_StudyBuilder_i::RemoveAttribute(SALOMEDS::SObject_ptr anObject, TDF_Label Lab; ASSERT(!CORBA::is_nil(anObject)); CORBA::String_var anobid = anObject->GetID(); - TDF_Tool::Label(_doc->GetData(),strdup(anobid),Lab); + TDF_Tool::Label(_doc->GetData(),anobid,Lab); if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0) { // postponed removing of CORBA objects Handle(SALOMEDS_IORAttribute) anAttr; if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)) - SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(strdup(TCollection_AsciiString(anAttr->Get()).ToCString())); + SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString()); else return; } - Lab.ForgetAttribute (SALOMEDS_SObject_i::ReturnGUIDForAttribute(aTypeOfAttribute)); + Lab.ForgetAttribute (SALOMEDS_GenericAttribute_i::GetGUID(aTypeOfAttribute)); } //============================================================================ @@ -1039,16 +659,16 @@ SALOMEDS_StudyBuilder_i::Addreference(SALOMEDS::SObject_ptr me, TDF_Label Lab; ASSERT(!CORBA::is_nil(me)); CORBA::String_var meid = me->GetID(); - TDF_Tool::Label(_doc->GetData(),strdup(meid),Lab); + TDF_Tool::Label(_doc->GetData(),meid,Lab); TDF_Label RefLab; ASSERT(!CORBA::is_nil(theReferencedObject)); CORBA::String_var roid = theReferencedObject->GetID(); - TDF_Tool::Label(_doc->GetData(),strdup(roid),RefLab); + TDF_Tool::Label(_doc->GetData(),roid,RefLab); TDF_Reference::Set(Lab,RefLab); SALOMEDS_TargetAttribute::Set(RefLab)->Append(Lab); - if(!CORBA::is_nil(_callbackOnRemove)) _callbackOnRemove->OnRemoveSObject(me); + if(!CORBA::is_nil(_callbackOnRemove) && Lab.IsDescendant(_doc->Main())) _callbackOnRemove->OnRemoveSObject(me); } @@ -1130,7 +750,7 @@ void SALOMEDS_StudyBuilder_i::SetGUID(SALOMEDS::SObject_ptr anObject, const char TDF_Label aLabel; ASSERT(!CORBA::is_nil(anObject)); CORBA::String_var anEntry = anObject->GetID(); - TDF_Tool::Label(_doc->GetData(), strdup(anEntry), aLabel); + TDF_Tool::Label(_doc->GetData(), anEntry, aLabel); TDataStd_UAttribute::Set(aLabel, (char*)theGUID); } @@ -1144,7 +764,7 @@ bool SALOMEDS_StudyBuilder_i::IsGUID(SALOMEDS::SObject_ptr anObject, const char* TDF_Label aLabel; ASSERT(!CORBA::is_nil(anObject)); CORBA::String_var anEntry = anObject->GetID(); - TDF_Tool::Label(_doc->GetData(), strdup(anEntry), aLabel); + TDF_Tool::Label(_doc->GetData(), anEntry, aLabel); return aLabel.IsAttribute((char*)theGUID); } @@ -1174,13 +794,14 @@ void SALOMEDS_StudyBuilder_i::NewCommand() //============================================================================ void SALOMEDS_StudyBuilder_i::CommitCommand() throw (SALOMEDS::StudyBuilder::LockProtection) { + Unexpect aCatch(SBLockProtection); Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { anAttr = new SALOMEDS_StudyPropertiesAttribute; _doc->Main().AddAttribute(anAttr); } if (anAttr->IsLocked() && !anAttr->IsLockChanged(true)) { - INFOS("Locked document modification !!!"); + MESSAGE("Locked document modification !!!"); AbortCommand(); throw SALOMEDS::StudyBuilder::LockProtection(); } else { @@ -1222,13 +843,14 @@ void SALOMEDS_StudyBuilder_i::AbortCommand() //============================================================================ void SALOMEDS_StudyBuilder_i::Undo() throw (SALOMEDS::StudyBuilder::LockProtection) { + Unexpect aCatch(SBLockProtection); Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { anAttr = new SALOMEDS_StudyPropertiesAttribute; _doc->Main().AddAttribute(anAttr); } if (anAttr->IsLocked()) { - INFOS("Locked document modification !!!"); + MESSAGE("Locked document modification !!!"); throw SALOMEDS::StudyBuilder::LockProtection(); } else { SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->UndoPostponed(1); @@ -1244,21 +866,22 @@ void SALOMEDS_StudyBuilder_i::Undo() throw (SALOMEDS::StudyBuilder::LockProtecti //============================================================================ void SALOMEDS_StudyBuilder_i::Redo() throw (SALOMEDS::StudyBuilder::LockProtection) { - Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; - if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { - anAttr = new SALOMEDS_StudyPropertiesAttribute; - _doc->Main().AddAttribute(anAttr); - } - + Unexpect aCatch(SBLockProtection); + Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; + if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_StudyPropertiesAttribute; + _doc->Main().AddAttribute(anAttr); + } + if (anAttr->IsLocked()) { - INFOS("Locked document modification !!!"); + MESSAGE("Locked document modification !!!"); throw SALOMEDS::StudyBuilder::LockProtection(); } else { _doc->Redo(); SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->UndoPostponed(-1); anAttr->SetModified(anAttr->GetModified()+1); } -} + } //============================================================================ /*! Function : GetAvailableUndos @@ -1325,12 +948,72 @@ SALOMEDS::Callback_ptr SALOMEDS_StudyBuilder_i::SetOnRemoveSObject(SALOMEDS::Cal return aRet; } +//============================================================================ +/*! Function : CheckLocked + * Purpose : + */ +//============================================================================ void SALOMEDS_StudyBuilder_i::CheckLocked() throw (SALOMEDS::StudyBuilder::LockProtection) { + Unexpect aCatch(SBLockProtection); if (_doc->HasOpenCommand()) return; Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { anAttr = new SALOMEDS_StudyPropertiesAttribute; _doc->Main().AddAttribute(anAttr); - } + } if (anAttr->IsLocked()) throw SALOMEDS::StudyBuilder::LockProtection(); } + +//============================================================================ +/*! Function : SetName + * Purpose : + */ +//============================================================================ +void SALOMEDS_StudyBuilder_i::SetName(SALOMEDS::SObject_ptr theSO, const char* theValue) + throw(SALOMEDS::StudyBuilder::LockProtection) +{ + Unexpect aCatch(SBLockProtection); + CheckLocked(); + //Find label + TDF_Label aLabel; + ASSERT(!CORBA::is_nil(theSO)); + CORBA::String_var aSOID = theSO->GetID(); + TDF_Tool::Label(_doc->GetData(), aSOID, aLabel); + TDataStd_Name::Set(aLabel, (char*)theValue); +} + +//============================================================================ +/*! Function : SetComment + * Purpose : + */ +//============================================================================ +void SALOMEDS_StudyBuilder_i::SetComment(SALOMEDS::SObject_ptr theSO, const char* theValue) + throw(SALOMEDS::StudyBuilder::LockProtection) +{ + Unexpect aCatch(SBLockProtection); + CheckLocked(); + //Find label + TDF_Label aLabel; + ASSERT(!CORBA::is_nil(theSO)); + CORBA::String_var aSOID = theSO->GetID(); + TDF_Tool::Label(_doc->GetData(), aSOID, aLabel); + TDataStd_Comment::Set(aLabel, (char*)theValue); +} + +//============================================================================ +/*! Function : SetIOR + * Purpose : + */ +//============================================================================ +void SALOMEDS_StudyBuilder_i::SetIOR(SALOMEDS::SObject_ptr theSO, const char* theValue) + throw(SALOMEDS::StudyBuilder::LockProtection) +{ + Unexpect aCatch(SBLockProtection); + CheckLocked(); + //Find label + TDF_Label aLabel; + ASSERT(!CORBA::is_nil(theSO)); + CORBA::String_var aSOID = theSO->GetID(); + TDF_Tool::Label(_doc->GetData(), aSOID, aLabel); + SALOMEDS_IORAttribute::Set(aLabel, TCollection_ExtendedString((char*)theValue), _orb); +} diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx index f282e4e97..9b668f402 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx @@ -142,5 +142,9 @@ public: virtual SALOMEDS::Callback_ptr SetOnAddSObject(SALOMEDS::Callback_ptr theCallback); virtual SALOMEDS::Callback_ptr SetOnRemoveSObject(SALOMEDS::Callback_ptr theCallback); + + virtual void SetName(SALOMEDS::SObject_ptr theSO, const char* theValue) throw(SALOMEDS::StudyBuilder::LockProtection); + virtual void SetComment(SALOMEDS::SObject_ptr theSO, const char* theValue) throw(SALOMEDS::StudyBuilder::LockProtection); + virtual void SetIOR(SALOMEDS::SObject_ptr theSO, const char* theValue) throw(SALOMEDS::StudyBuilder::LockProtection); }; #endif diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index ba14acbf0..8c8daa9c7 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -78,6 +78,11 @@ using namespace std; #include +#include "Utils_ExceptHandlers.hxx" + +UNEXPECT_CATCH(SalomeException,SALOME::SALOME_Exception); +UNEXPECT_CATCH(LockProtection, SALOMEDS::StudyBuilder::LockProtection); + #define USE_CASE_LABEL_ID "0:2" #define AUTO_SAVE_GUID "128268A3-71C9-4036-89B1-F81BD6A4FCF2" #define AUTO_SAVE_TAG "0:8" @@ -85,286 +90,37 @@ using namespace std; //=========================================================================== //Function : LoadAttributes //=========================================================================== -static void ReadAttributes(Handle(TDF_Data)& DF, - TDF_Label& Lab, +static void ReadAttributes(SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr aSO, HDFdataset* hdf_dataset) { hdf_dataset->OpenOnDisk(); - - if (hdf_dataset->GetType() == HDF_STRING) { - - if (!strncmp(hdf_dataset->GetName(),"AttributeTreeNode",17)) { - MESSAGE("Create a Attribute : AttributeTreeNode"); - char current_strings[5][hdf_dataset->GetSize()/5]; - 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); - } - } else { - int size = hdf_dataset->GetSize(); - char* current_string = new char[size]; - hdf_dataset->ReadFromDisk(current_string); + SALOMEDS::GenericAttribute_var anAttr; - if (!strcmp(hdf_dataset->GetName(),"COMPONENTDATATYPE")) { - MESSAGE("Create a OCAF Attribute : COMPONENTDATATYPE"); - TDataStd_Comment::Set (Lab,current_string); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeComment")) { - MESSAGE("Create an Attribute : AttributeComment"); - TDataStd_Comment::Set (Lab,current_string); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeName")) { - MESSAGE("Create an Attribute : AttributeName"); - TDataStd_Name::Set (Lab,current_string); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributePersistentRef")) { - MESSAGE("Create an Attribute : AttributePersistentRef"); - SALOMEDS_PersRefAttribute::Set(Lab,current_string); - } - else if (!strcmp(hdf_dataset->GetName(),"Reference")) { - MESSAGE("Create a OCAF Attribute : Reference"); - TDF_Label RefLab; - TDF_Tool::Label(DF,current_string,RefLab,1); - TDF_Reference::Set(Lab,RefLab); - SALOMEDS_TargetAttribute::Set(RefLab)->Append(Lab); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeReal")) { - MESSAGE("Create a Attribute : AttributeReal"); - char * err = NULL; - CORBA::Double r = strtod(current_string, &err); - SCRUTE(r); - if (err == current_string) { - MESSAGE("AtttributeReal : conversion impossible"); - } - else TDataStd_Real::Set (Lab,r); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeInteger")) { - MESSAGE("Create a Attribute : AttributeInteger"); - CORBA::Long r = atol(current_string); - SCRUTE(r); - TDataStd_Integer::Set (Lab,r); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributePixMap")) { - MESSAGE("Create an Attribute : AttributePixMap"); - SALOMEDS_PixMapAttribute::Set (Lab,current_string); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeDrawable")) { - MESSAGE("Create a Attribute : DrawableAttribute"); - CORBA::Long r = atol(current_string); - SCRUTE(r); - SALOMEDS_DrawableAttribute::Set (Lab,r); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeSelectable")) { - MESSAGE("Create a Attribute : AttributeSelectable"); - CORBA::Long r = atol(current_string); - SCRUTE(r); - SALOMEDS_SelectableAttribute::Set (Lab,r); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeExpandable")) { - MESSAGE("Create a Attribute : AttributeExpandable"); - CORBA::Long r = atol(current_string); - SCRUTE(r); - SALOMEDS_ExpandableAttribute::Set (Lab,r); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeOpened")) { - MESSAGE("Create a Attribute : AttributeOpened"); - CORBA::Long r = atol(current_string); - SCRUTE(r); - SALOMEDS_OpenedAttribute::Set (Lab,r); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeLocalID")) { - MESSAGE("Create a Attribute : AttributeLocalID"); - CORBA::Long r = atol(current_string); - SCRUTE(r); - SALOMEDS_LocalIDAttribute::Set (Lab,r); - } - else if (!strncmp(hdf_dataset->GetName(),"AttributeUserID",15)) { - MESSAGE("Create an Attribute : AttributeUserID"); - TDataStd_UAttribute::Set (Lab,Standard_GUID(current_string)); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeTableOfInteger")) { - MESSAGE("Create a Attribute : AttributeTableOfInteger"); - int size = hdf_dataset->GetSize(); - Handle(SALOMEDS_TableOfIntegerAttribute) Attr = SALOMEDS_TableOfIntegerAttribute::Set(Lab); - unsigned char* aBuffer = new unsigned char[size]; - if(aBuffer == NULL) throw HDFexception("Unable to open dataset AttributeTableOfInteger"); - hdf_dataset->ReadFromDisk(aBuffer); - SALOMEDS::TMPFile_var aTMPFile = new SALOMEDS::TMPFile(size, size, aBuffer, 1); - istrstream aStream((char*)&aTMPFile[0], aTMPFile->length()); - Attr->RestoreFromString(aStream); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeTableOfReal")) { - MESSAGE("Create a Attribute : AttributeTableOfReal"); - int size = hdf_dataset->GetSize(); - Handle(SALOMEDS_TableOfRealAttribute) Attr = SALOMEDS_TableOfRealAttribute::Set(Lab); - unsigned char* aBuffer = new unsigned char[size]; - if(aBuffer == NULL) throw HDFexception("Unable to open dataset AttributeTableOfReal"); - hdf_dataset->ReadFromDisk(aBuffer); - SALOMEDS::TMPFile_var aTMPFile = new SALOMEDS::TMPFile(size, size, aBuffer, 1); - istrstream aStream((char*)&aTMPFile[0], aTMPFile->length()); - Attr->RestoreFromString(aStream); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeTableOfString")) { - MESSAGE("Create a Attribute : AttributeTableOfString"); - int size = hdf_dataset->GetSize(); - Handle(SALOMEDS_TableOfStringAttribute) Attr = SALOMEDS_TableOfStringAttribute::Set(Lab); - unsigned char* aBuffer = new unsigned char[size]; - if(aBuffer == NULL) throw HDFexception("Unable to open dataset AttributeTableOfString"); - hdf_dataset->ReadFromDisk(aBuffer); - SALOMEDS::TMPFile_var aTMPFile = new SALOMEDS::TMPFile(size, size, aBuffer, 1); - istrstream aStream((char*)&aTMPFile[0], aTMPFile->length()); - Attr->RestoreFromString(aStream); - } - else if (!strcmp(hdf_dataset->GetName(),"AttributeStudyProperties")) { - MESSAGE("Create an Attribute : AttributeStudyProperties"); -// MESSAGE("current string :"<SetCreationMode(1);break; - case 'c': aProp->SetCreationMode(2);break; - } + char* current_string = new char[hdf_dataset->GetSize()]; + hdf_dataset->ReadFromDisk(current_string); - int anIndex; - for(anIndex = 2; anIndex + 2 < size ;) { - char str[10]; - Standard_Integer aMinute, aHour, aDay, aMonth, aYear; - str[0] = current_string[anIndex++]; - str[1] = current_string[anIndex++]; - str[2] = 0; - aMinute = atoi(str); - str[0] = current_string[anIndex++]; - str[1] = current_string[anIndex++]; - aHour = atoi(str); - str[0] = current_string[anIndex++]; - str[1] = current_string[anIndex++]; - aDay = atoi(str); - str[0] = current_string[anIndex++]; - str[1] = current_string[anIndex++]; - aMonth = atoi(str); - str[0] = current_string[anIndex++]; - str[1] = current_string[anIndex++]; - str[2] = current_string[anIndex++]; - str[3] = current_string[anIndex++]; - str[4] = 0; - aYear = atoi(str); - aProp->SetModificationDate(aMinute,aHour,aDay,aMonth,aYear); - - int aNameSize; - for(aNameSize = 0; current_string[anIndex+aNameSize]!=1; aNameSize++); - char *aName = new char[aNameSize+1]; - strncpy(aName, &(current_string[anIndex]), aNameSize); - aName[aNameSize] = 0; - aProp->SetUserName(TCollection_ExtendedString(aName)); - delete(aName); - anIndex += aNameSize + 1; - if (current_string[1] == 'l') { - aProp->SetLocked(Standard_True); - aProp->IsLockChanged(true); - } - aProp->SetModified(0); - } - } - else if (!strcmp(hdf_dataset->GetName(),"AttributePythonObject")) { - MESSAGE("Create an Attribute : AttributePythonObject"); - Handle(SALOMEDS_PythonObjectAttribute) anObj = SALOMEDS_PythonObjectAttribute::Set(Lab); - Standard_Boolean aScript = (current_string[0] == 's')?Standard_True:Standard_False; - anObj->SetObject((char *)(current_string+1), aScript); - } - else { - MESSAGE(hdf_dataset->GetName()); - MESSAGE("LoadAttributes: unknown types"); - } - } - } - if (hdf_dataset->GetType() == HDF_FLOAT64) { - if (!strcmp(hdf_dataset->GetName(),"AttributeSequenceOfReal")) { - MESSAGE("Create a Attribute : AttributeSequenceOfReal"); - int size = hdf_dataset->GetSize(); - hdf_float64* val = new hdf_float64[size]; - hdf_dataset->ReadFromDisk(val); - Handle(TColStd_HSequenceOfReal) SeqReal = new TColStd_HSequenceOfReal; - for (Standard_Integer i = 0; i < size; i++) { - SeqReal->Append(val[i]); -// MESSAGE( val[i] << " restored" ); - } - SALOMEDS_SequenceOfRealAttribute::Set (Lab); - Handle(SALOMEDS_SequenceOfRealAttribute) Attr; - Handle(TDF_Attribute) Att; - Lab.FindAttribute(SALOMEDS_SequenceOfRealAttribute::GetID(),Att); - Attr = Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(Att); - Attr->Assign(SeqReal); - } else - if (!strcmp(hdf_dataset->GetName(),"AttributeTextColor")) { - MESSAGE("Create a Attribute : AttributeTextColor"); - hdf_float64 val[3]; - hdf_dataset->ReadFromDisk(val); - Handle(SALOMEDS_TextColorAttribute) TC = new SALOMEDS_TextColorAttribute; - Lab.AddAttribute(TC); - TC->SetValue(1, val[0]); - TC->SetValue(2, val[1]); - TC->SetValue(3, val[2]); - } else - if (!strcmp(hdf_dataset->GetName(),"AttributeTextHighlightColor")) { - MESSAGE("Create a Attribute : AttributeTextHighlightColor"); - hdf_float64 val[3]; - hdf_dataset->ReadFromDisk(val); - Handle(SALOMEDS_TextHighlightColorAttribute) TC = new SALOMEDS_TextHighlightColorAttribute; - Lab.AddAttribute(TC); - TC->SetValue(1, val[0]); - TC->SetValue(2, val[1]); - TC->SetValue(3, val[2]); - }else { - MESSAGE(hdf_dataset->GetName()); - MESSAGE("LoadAttributes: unknown types"); - } + if (!strcmp(hdf_dataset->GetName(),"COMPONENTDATATYPE")) { + anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, "AttributeComment"); + } else if (!strcmp(hdf_dataset->GetName(),"Reference")) { + theStudy->NewBuilder()->Addreference(aSO, theStudy->CreateObjectID(current_string)); + delete(current_string); + hdf_dataset->CloseOnDisk(); + return; + } else { + MESSAGE("Read attribute "<GetName()) + anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, hdf_dataset->GetName()); } - if (hdf_dataset->GetType() == HDF_INT32) { - if (!strcmp(hdf_dataset->GetName(),"AttributeSequenceOfInteger")) { - MESSAGE("Create a OCAF Attribute : AttributeSequenceOfInteger"); - int size = hdf_dataset->GetSize(); - hdf_int32* val = new hdf_int32[size]; - hdf_dataset->ReadFromDisk(val); - Handle(TColStd_HSequenceOfInteger) SeqInt = new TColStd_HSequenceOfInteger; - for (Standard_Integer i = 0; i < size; i++) { - SeqInt->Append(val[i]); -// MESSAGE( val[i] << " restored" ); - } - SALOMEDS_SequenceOfIntegerAttribute::Set (Lab); - Handle(SALOMEDS_SequenceOfIntegerAttribute) Attr; - Handle(TDF_Attribute) Att; - Lab.FindAttribute(SALOMEDS_SequenceOfIntegerAttribute::GetID(),Att); - Attr = Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(Att); - Attr->Assign(SeqInt); - } - else { - MESSAGE(hdf_dataset->GetName()); - MESSAGE("LoadAttributes: unknown types"); - } + + if (!CORBA::is_nil(anAttr)) { + anAttr->Restore(current_string); + MESSAGE("Restoring attribute "<GetName()<<" by string '"<GetName()); + MESSAGE("LoadAttributes: unknown types"); } + delete(current_string); hdf_dataset->CloseOnDisk(); } @@ -414,18 +170,18 @@ static void Translate_IOR_to_persistentID (SALOMEDS::Study_ptr study, //============================================================================ //Function : BuildlTree //============================================================================ -static void BuildTree (Handle(TDF_Data)& DF,HDFgroup* hdf_current_group) +static void BuildTree (SALOMEDS::Study_ptr theStudy,HDFgroup* hdf_current_group) { hdf_current_group->OpenOnDisk(); - TDF_Label Lab; - Standard_CString Entry = hdf_current_group->GetName(); + SALOMEDS::SObject_var aSO; + char* Entry = hdf_current_group->GetName(); if (strcmp(Entry,"STUDY_STRUCTURE") == 0) { MESSAGE("find the root of the document"); - Lab = DF->Root().FindChild(1,Standard_True); + aSO = theStudy->CreateObjectID("0:1"); } else { - TDF_Tool::Label (DF,Entry,Lab,1); + aSO = theStudy->CreateObjectID(Entry); MESSAGE("BuildTree : Create a new label"< Dataset: Internal Object Name : " << name); HDFdataset* new_dataset = new HDFdataset(name,hdf_current_group); - ReadAttributes (DF,Lab,new_dataset); + ReadAttributes(theStudy,aSO,new_dataset); new_dataset = 0; // will be deleted by father destructor } else if (type == HDF_GROUP) { MESSAGE( "--> Group: Internal Object Name : " << name); HDFgroup* new_group = new HDFgroup(name,hdf_current_group); - BuildTree (DF,new_group); + BuildTree (theStudy, new_group); new_group = 0; // will be deleted by father destructor } } @@ -544,6 +300,7 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* study_name) SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* aUrl) throw(SALOME::SALOME_Exception) { + Unexpect aCatch(SalomeException); MESSAGE("Begin of SALOMEDS_StudyManager_i::Open"); // open the HDFFile HDFfile *hdf_file =0; @@ -611,7 +368,7 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* aUrl) Handle(TDF_Data) DF = Doc->GetData(); try { - BuildTree (DF,hdf_group_study_structure); + BuildTree (Study,hdf_group_study_structure); } catch (HDFexception) { @@ -819,369 +576,33 @@ SALOMEDS_StudyManager_i::GetStudyByID(CORBA::Short aStudyID) */ //============================================================================ static void SaveAttributes(SALOMEDS::SObject_ptr SO, HDFgroup *hdf_group_sobject) { - HDFdataset *hdf_dataset = 0; + int a; hdf_size size[1]; - hdf_int32 name_len = 0; - SALOMEDS::GenericAttribute_var SObj; - if(SO->FindAttribute(SObj, "AttributeComment")) - { - SALOMEDS::AttributeComment_var Comment = SALOMEDS::AttributeComment::_narrow(SObj); - CORBA::String_var Val = Comment->Value(); - name_len = (hdf_int32) strlen(Val); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributeComment",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(Val); - MESSAGE("attribute comment " << Val << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - // Attribute SALOMEDS::PersistentRef - if(SO->FindAttribute(SObj, "AttributePersistentRef")) - { - SALOMEDS::AttributePersistentRef_var PersRef = SALOMEDS::AttributePersistentRef::_narrow(SObj); - CORBA::String_var Val = PersRef->Value(); - name_len = (hdf_int32) strlen(Val); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributePersistentRef",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(Val); - MESSAGE("attribute persistentref " << Val << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - // Attribute SALOMEDS::Name - if(SO->FindAttribute(SObj, "AttributeName")) - { - SALOMEDS::AttributeName_var NameRef = SALOMEDS::AttributeName::_narrow(SObj); - CORBA::String_var Val = NameRef->Value(); - name_len = (hdf_int32) strlen(Val); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributeName",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(Val); - MESSAGE("attribute name " << Val << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - if(SO->FindAttribute(SObj, "AttributeReal")) - { - char RealVal[25]; - SALOMEDS::AttributeReal_var RealRef = SALOMEDS::AttributeReal::_narrow(SObj); - sprintf(RealVal, "%f", RealRef->Value()); - name_len = (hdf_int32) strlen(RealVal); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributeReal",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(RealVal); - MESSAGE("attribute Real " << RealVal << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - if(SO->FindAttribute(SObj, "AttributeInteger")) - { - char IntVal[25]; - SALOMEDS::AttributeInteger_var IntRef = SALOMEDS::AttributeInteger::_narrow(SObj); - sprintf(IntVal, "%d", IntRef->Value()); - name_len = (hdf_int32) strlen(IntVal); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributeInteger",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(IntVal); - MESSAGE("attribute Real " << IntVal << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - - if(SO->FindAttribute(SObj, "AttributeSequenceOfReal")) - { - SALOMEDS::AttributeSequenceOfReal_var RealSeq = SALOMEDS::AttributeSequenceOfReal::_narrow(SObj); - size[0] = RealSeq->Length(); - SALOMEDS::DoubleSeq_var DS = RealSeq->CorbaSequence(); - hdf_dataset = new HDFdataset("AttributeSequenceOfReal",hdf_group_sobject,HDF_FLOAT64,size,1); - hdf_dataset->CreateOnDisk(); - hdf_float64 *data = new hdf_float64[RealSeq->Length()]; - for (Standard_Integer i = 0; i < RealSeq->Length(); i++) { - MESSAGE("Value = " << i << " = " << DS[i] << " wrote on file"); - data[i] = DS[i]; - } - hdf_dataset->WriteOnDisk(data); - // delete data; - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - if(SO->FindAttribute(SObj, "AttributeSequenceOfInteger")) - { - SALOMEDS::AttributeSequenceOfInteger_var IntSeq = SALOMEDS::AttributeSequenceOfInteger::_narrow(SObj); - size[0] = IntSeq->Length(); - SALOMEDS::LongSeq_var LS = IntSeq->CorbaSequence(); - hdf_dataset = new HDFdataset("AttributeSequenceOfInteger",hdf_group_sobject,HDF_INT32,size,1); - hdf_dataset->CreateOnDisk(); - hdf_int32 *data = new hdf_int32[IntSeq->Length()]; - for (Standard_Integer i = 0; i < IntSeq->Length(); i++) { - MESSAGE("Value = " << i << " = " << LS[i] << " wrote on file"); - data[i] = LS[i]; - } - hdf_dataset->WriteOnDisk(data); - hdf_dataset->CloseOnDisk(); - // delete data; - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - if(SO->FindAttribute(SObj, "AttributeDrawable")) - { - char IntVal[25]; - SALOMEDS::AttributeDrawable_var DrRef = SALOMEDS::AttributeDrawable::_narrow(SObj); - sprintf(IntVal, "%d", DrRef->IsDrawable()); - name_len = (hdf_int32) strlen(IntVal); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributeDrawable",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(IntVal); - MESSAGE("attribute Drawable " << IntVal << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - if(SO->FindAttribute(SObj, "AttributeSelectable")) - { - char IntVal[25]; - SALOMEDS::AttributeSelectable_var SelRef = SALOMEDS::AttributeSelectable::_narrow(SObj); - sprintf(IntVal, "%d", SelRef->IsSelectable()); - name_len = (hdf_int32) strlen(IntVal); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributeSelectable",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(IntVal); - MESSAGE("attribute Selectable " << IntVal << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - if(SO->FindAttribute(SObj, "AttributeExpandable")) - { - char IntVal[25]; - SALOMEDS::AttributeExpandable_var ExRef = SALOMEDS::AttributeExpandable::_narrow(SObj); - sprintf(IntVal, "%d", ExRef->IsExpandable()); - name_len = (hdf_int32) strlen(IntVal); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributeExpandable",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(IntVal); - MESSAGE("attribute Expandable " << IntVal << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - if(SO->FindAttribute(SObj, "AttributeOpened")) - { - char IntVal[25]; - SALOMEDS::AttributeOpened_var OpRef = SALOMEDS::AttributeOpened::_narrow(SObj); - sprintf(IntVal, "%d", OpRef->IsOpened()); - name_len = (hdf_int32) strlen(IntVal); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributeOpened",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(IntVal); - MESSAGE("attribute Opened " << IntVal << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - if(SO->FindAttribute(SObj, "AttributeTextColor")) - { - SALOMEDS::AttributeTextColor_var TextRef = SALOMEDS::AttributeTextColor::_narrow(SObj); - size[0] = 3; - hdf_float64 data[3]; - SALOMEDS::Color C = TextRef->TextColor(); - data[0] = C.R; - data[1] = C.G; - data[2] = C.B; - hdf_dataset = new HDFdataset("AttributeTextColor",hdf_group_sobject,HDF_FLOAT64,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(data); - MESSAGE("attribute AttributeTextColor wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - if(SO->FindAttribute(SObj, "AttributeTextHighlightColor")) - { - SALOMEDS::AttributeTextHighlightColor_var TextRef = SALOMEDS::AttributeTextHighlightColor::_narrow(SObj); - size[0] = 3; - hdf_float64 data[3]; - SALOMEDS::Color C = TextRef->TextHighlightColor(); - data[0] = C.R; - data[1] = C.G; - data[2] = C.B; - hdf_dataset = new HDFdataset("AttributeTextHighlightColor",hdf_group_sobject,HDF_FLOAT64,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(data); - MESSAGE("attribute AttributeTextHighlightColor wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - if(SO->FindAttribute(SObj, "AttributePixMap")) - { - SALOMEDS::AttributePixMap_var PMRef = SALOMEDS::AttributePixMap::_narrow(SObj); - if (PMRef->HasPixMap()) { - CORBA::String_var Val = PMRef->GetPixMap(); - name_len = (hdf_int32) strlen(Val); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributePixMap",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(Val); - MESSAGE("attribute PixMap " << Val << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - } - } - if(SO->FindAttribute(SObj, "AttributeLocalID")) - { - char IntVal[25]; - SALOMEDS::AttributeLocalID_var LIDRef = SALOMEDS::AttributeLocalID::_narrow(SObj); - sprintf(IntVal, "%d", LIDRef->Value()); - name_len = (hdf_int32) strlen(IntVal); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("AttributeLocalID",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(IntVal); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - MESSAGE("attribute AttributeLocalID wrote on file"); - } - if(SO->FindAttribute(SObj, "AttributeTableOfInteger")) - { - SALOMEDS::AttributeTableOfInteger_var IntTab = SALOMEDS::AttributeTableOfInteger::_narrow(SObj); - SALOMEDS::TMPFile_var aStream = IntTab->SaveToFile(); - - hdf_size aHDFSize[1]; - aHDFSize[0] = aStream->length(); - - HDFdataset *hdf_dataset = new HDFdataset("AttributeTableOfInteger",hdf_group_sobject, HDF_STRING, aHDFSize, 1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk((unsigned char*) &aStream[0]); //Save the stream in the HDF file - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - - MESSAGE("attribute AttributeTableOfInteger wrote on file"); - } - if(SO->FindAttribute(SObj, "AttributeTableOfReal")) - { - SALOMEDS::AttributeTableOfReal_var RealTab = SALOMEDS::AttributeTableOfReal::_narrow(SObj); - SALOMEDS::TMPFile_var aStream = RealTab->SaveToFile(); - - hdf_size aHDFSize[1]; - aHDFSize[0] = aStream->length(); - - HDFdataset *hdf_dataset = new HDFdataset("AttributeTableOfReal",hdf_group_sobject, HDF_STRING, aHDFSize, 1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk((unsigned char*) &aStream[0]); //Save the stream in the HDF file - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - - MESSAGE("attribute AttributeTableOfReal wrote on file") - } - if(SO->FindAttribute(SObj, "AttributeTableOfString")) - { - SALOMEDS::AttributeTableOfString_var StrTab = SALOMEDS::AttributeTableOfString::_narrow(SObj); - SALOMEDS::TMPFile_var aStream = StrTab->SaveToFile(); - - hdf_size aHDFSize[1]; - aHDFSize[0] = aStream->length(); - - HDFdataset *hdf_dataset = new HDFdataset("AttributeTableOfString",hdf_group_sobject, HDF_STRING, aHDFSize, 1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk((unsigned char*) &aStream[0]); //Save the stream in the HDF file - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - - MESSAGE("attribute AttributeTableOfString wrote on file") - } - if(SO->FindAttribute(SObj, "AttributePythonObject")) - { - SALOMEDS::AttributePythonObject_var anObj = SALOMEDS::AttributePythonObject::_narrow(SObj); - char* aSeq = CORBA::string_dup(anObj->GetObject()); - int aLen = strlen(aSeq); - char* aString = new char[aLen+2]; - aString[0] = anObj->IsScript()?'s':'n'; - for(int i = 0; i < aLen; i++) aString[i+1] = aSeq[i]; - aString[aLen+1] = 0; - size[0] = aLen+2 ; - hdf_dataset = new HDFdataset("AttributePythonObject",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(aString); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - MESSAGE("attribute AttributePythonObject wrote on file"); - } - -// Reference - SALOMEDS::SObject_var RefSO; - if(SO->ReferencedObject(RefSO)) - { - CORBA::String_var attribute_reference = strdup(RefSO->GetID()); - name_len = (hdf_int32) strlen(attribute_reference); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("Reference",hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(attribute_reference); - MESSAGE("attribute reference " << attribute_reference << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset =0; // will be deleted by father hdf object destructor - } - -// TreeNodeAttributes with not constant GUID SALOMEDS::ListOfAttributes_var anAttrList = SO->GetAllAttributes(); - int anIndex, aLength = anAttrList->length(); - for(anIndex = 0; anIndex_is_nil()) { - char* Val = UAttr->Value(); - name_len = (hdf_int32) strlen(Val); - size[0] = name_len + 1; - char* aDataSetName = new char[60]; - sprintf(aDataSetName, "AttributeUserID_%s",Val); - hdf_dataset = new HDFdataset(aDataSetName,hdf_group_sobject,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(Val); - MESSAGE("attribute UesrID " << Val << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - delete(aDataSetName); - continue; - } + for(a = anAttrList->length() - 1; a >= 0; a--) { + if (strcmp(anAttrList[a]->Type(), "AttributeIOR") == 0) continue; // never write AttributeIOR to file + if (strcmp(anAttrList[a]->Type(), "AttributeExternalFileDef") == 0) continue; // never write ExternalFileDef to file + if (strcmp(anAttrList[a]->Type(), "AttributeFileType") == 0) continue; // never write FileType to file + CORBA::String_var aSaveStr = strdup(anAttrList[a]->Store()); + size[0] = (hdf_int32) strlen(aSaveStr) + 1; + HDFdataset *hdf_dataset = new HDFdataset(anAttrList[a]->Type(),hdf_group_sobject,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(aSaveStr); + hdf_dataset->CloseOnDisk(); + //cout<<"********** Write Attribute "<Type()<<" : "<_is_nil()) { - hdf_size TNsize[2]; - int maxSize,index; - CORBA::String_var Val[5]; - - if (TNRef->HasFather()) Val[0] = TNRef->GetFather()->Label(); else Val[0] = "\0"; - maxSize = strlen(Val[0]); - if (TNRef->HasPrevious()) Val[1] = TNRef->GetPrevious()->Label(); else Val[1] = "\0"; - maxSize = Max(maxSize,strlen(Val[1])); - if (TNRef->HasNext()) Val[2] = TNRef->GetNext()->Label(); else Val[2] = "\0"; - maxSize = Max(maxSize,strlen(Val[2])); - if (TNRef->HasFirst()) Val[3] = TNRef->GetFirst()->Label(); else Val[3] = "\0"; - maxSize = Max(maxSize,strlen(Val[3])); - Val[4] = TNRef->GetTreeID(); - maxSize = Max(maxSize,strlen(Val[4])); - - TNsize[0]=5; - TNsize[1]=maxSize+1; - char Data[5][maxSize+1]; - for(index=0;index<5;index++) { - strcpy(Data[index],Val[index]); - for(int a = strlen(Data[index]) + 1; a < maxSize; a++) Data[index][a] = ' '; // mpv: for ASCII format - } - - char* aDataSetName = new char[60]; - sprintf(aDataSetName, "AttributeTreeNodeGUID%s",TNRef->GetTreeID()); - hdf_dataset = new HDFdataset(aDataSetName,hdf_group_sobject,HDF_STRING,TNsize,2); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(Data); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - MESSAGE("attribute AttributeTreeNode with various GUID wrote on file:"); - MESSAGE(aDataSetName); - delete(aDataSetName); - } + // 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 } } @@ -1570,7 +991,7 @@ void SALOMEDS_StudyManager_i::_SaveObject(SALOMEDS::Study_ptr aStudy, SALOMEDS::SObject_var SO = itchild->Value(); // mpv: don't save empty labels - if (SO->GetAllAttributes()->length() == 0) { + if (SO->GetAllAttributes()->length() == 0 && !SO->ReferencedObject(RefSO)) { SALOMEDS::ChildIterator_var subchild = aStudy->NewChildIterator(SC); if (!subchild->More()) { continue; @@ -1578,7 +999,8 @@ void SALOMEDS_StudyManager_i::_SaveObject(SALOMEDS::Study_ptr aStudy, subchild->InitEx(true); bool anEmpty = true; for (; subchild->More() && anEmpty; subchild->Next()) - if (subchild->Value()->GetAllAttributes()->length() != 0) anEmpty = false; + if (subchild->Value()->GetAllAttributes()->length() != 0 || + subchild->Value()->ReferencedObject(RefSO)) anEmpty = false; if (anEmpty) { continue; } @@ -1916,6 +1338,7 @@ TDF_Label SALOMEDS_StudyManager_i::PasteLabel(const SALOMEDS::Study_ptr theDesti SALOMEDS::SObject_ptr SALOMEDS_StudyManager_i::Paste(SALOMEDS::SObject_ptr theObject) throw(SALOMEDS::StudyBuilder::LockProtection) { + Unexpect aCatch(LockProtection); SALOMEDS::Study_var aStudy = theObject->GetStudy(); // if study is locked, then paste can't be done diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index ed98968e8..be1599434 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -226,7 +226,25 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID) { // Convert aSO->GetID in TDF_Label. TDF_Label Lab; - TDF_Tool::Label(_doc->GetData(), strdup(anObjectID), Lab); + TDF_Tool::Label(_doc->GetData(), (char*)anObjectID, Lab); + + if (Lab.IsNull()) return SALOMEDS::SObject::_nil(); + SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (Lab,_orb); + SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + return so; + +} + +//============================================================================ +/*! Function : CreateObjectID + * Purpose : Creates an Object with ID = anObjectID + */ +//============================================================================ +SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID) +{ + // Convert aSO->GetID in TDF_Label. + TDF_Label Lab; + TDF_Tool::Label(_doc->GetData(), (char*)anObjectID, Lab, Standard_True); if (Lab.IsNull()) return SALOMEDS::SObject::_nil(); SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (Lab,_orb); @@ -336,7 +354,7 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR) RefSO = _FindObjectIOR(SC,anObjectIOR, _find); } } - if (!RefSO->_is_nil()) INFOS("SALOMEDS_Study_i::FindObjectIOR: found label with old methods"); + if (!RefSO->_is_nil()) MESSAGE("SALOMEDS_Study_i::FindObjectIOR: found label with old methods"); return RefSO; } @@ -649,7 +667,7 @@ SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject { //Convert aSO->GetID in TDF_Label. TDF_Label Lab; - TDF_Tool::Label(_doc->GetData(), strdup(aSO->GetID()), Lab); + TDF_Tool::Label(_doc->GetData(), aSO->GetID(), Lab); //Create iterator SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(Lab,_orb); @@ -887,7 +905,7 @@ SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const TDF_Label theLabel, CORBA:: ASSERT(!CORBA::is_nil(aStudy)); return SALOMEDS::Study::_duplicate(aStudy); } else { - INFOS("GetStudy: Problem to get study"); + MESSAGE("GetStudy: Problem to get study"); } return SALOMEDS::Study::_nil(); } @@ -1013,7 +1031,7 @@ void SALOMEDS_Study_i::AddPostponed(const char* theIOR) { if (!CORBA::is_nil(obj)) { SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj) ; if (!CORBA::is_nil(aGeneric)) { - TCollection_AsciiString anIOR(strdup(theIOR)); + TCollection_AsciiString anIOR((char*)theIOR); anIOR.Prepend("d"); myPostponedIORs.Append(anIOR); // add prefix: deleted myNbPostponed.SetValue(myNbPostponed.Length(), myNbPostponed.Last() + 1); @@ -1029,7 +1047,7 @@ void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR) { if (!CORBA::is_nil(obj)) { SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj) ; if (!CORBA::is_nil(aGeneric)) { - TCollection_AsciiString anIOR(strdup(theIOR)); + TCollection_AsciiString anIOR((char*)theIOR); anIOR.Prepend("c"); myPostponedIORs.Append(anIOR); // add prefix: created myNbPostponed.SetValue(myNbPostponed.Length(), myNbPostponed.Last() + 1); @@ -1059,7 +1077,7 @@ void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long theUndoLimit) { for(anIndex = anOld + 1; anIndex <= aNew; anIndex++) { TCollection_AsciiString anIOR = myPostponedIORs(anIndex); if (anIOR.Value(1) == 'c') { - CORBA::Object_var obj = _orb->string_to_object(strdup(anIOR.Split(1).ToCString())); + CORBA::Object_var obj = _orb->string_to_object(anIOR.Split(1).ToCString()); SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj); if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy(); } @@ -1077,7 +1095,7 @@ void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long theUndoLimit) { for(anIndex = 1; anIndex <= anOld; anIndex++) { TCollection_AsciiString anIOR = myPostponedIORs(anIndex); if (anIOR.Value(1) == 'd') { - CORBA::Object_var obj = _orb->string_to_object(strdup(anIOR.Split(1).ToCString())); + CORBA::Object_var obj = _orb->string_to_object(anIOR.Split(1).ToCString()); SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj); if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy(); } @@ -1090,7 +1108,7 @@ void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long theUndoLimit) { TDF_ChildIDIterator anIter(_doc->GetData()->Root(), SALOMEDS_IORAttribute::GetID(), Standard_True); for(; anIter.More(); anIter.Next()) { Handle(SALOMEDS_IORAttribute) anAttr = Handle(SALOMEDS_IORAttribute)::DownCast(anIter.Value()); - CORBA::String_var anIOR = strdup(TCollection_AsciiString(anAttr->Get()).ToCString()); + CORBA::String_var anIOR = CORBA::string_dup(TCollection_AsciiString(anAttr->Get()).ToCString()); try { CORBA::Object_var obj = _orb->string_to_object(anIOR); SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj); diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index be93b95f9..ad314b497 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -149,6 +149,13 @@ public: */ virtual SALOMEDS::SObject_ptr FindObjectID(const char* anObjectID); + //! method to Create an Object with ID = anObjectID + /*! + \param anObjectID char* arguments + \return SObject_ptr arguments, the object found + */ + virtual SALOMEDS::SObject_ptr CreateObjectID(const char* anObjectID); + //! method to Find an Object with ID = anObjectIOR /*! \param anObjectIOR char* arguments @@ -261,7 +268,6 @@ public: */ virtual void URL(const char* url); - virtual CORBA::Short StudyId(); virtual void StudyId(CORBA::Short id); diff --git a/src/SALOMEDS/SALOMEDS_TargetAttribute.cxx b/src/SALOMEDS/SALOMEDS_TargetAttribute.cxx index a043b9610..004fd6973 100644 --- a/src/SALOMEDS/SALOMEDS_TargetAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_TargetAttribute.cxx @@ -24,7 +24,7 @@ // File : SALOMEDS_TargetAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ using namespace std; #include "SALOMEDS_TargetAttribute.ixx" diff --git a/src/SALOMEDS/SALOMEDS_TargetAttribute.hxx b/src/SALOMEDS/SALOMEDS_TargetAttribute.hxx index ef6af7626..8b63cb886 100644 --- a/src/SALOMEDS/SALOMEDS_TargetAttribute.hxx +++ b/src/SALOMEDS/SALOMEDS_TargetAttribute.hxx @@ -24,7 +24,7 @@ // File : SALOMEDS_TargetAttribute.hxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef _SALOMEDS_TargetAttribute_HeaderFile #define _SALOMEDS_TargetAttribute_HeaderFile diff --git a/src/SALOMEDS/SALOMEDS_TargetAttribute.ixx b/src/SALOMEDS/SALOMEDS_TargetAttribute.ixx index a777e0f53..7fac6a9e1 100644 --- a/src/SALOMEDS/SALOMEDS_TargetAttribute.ixx +++ b/src/SALOMEDS/SALOMEDS_TargetAttribute.ixx @@ -24,7 +24,7 @@ // File : SALOMEDS_TargetAttribute.ixx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #include "SALOMEDS_TargetAttribute.jxx" diff --git a/src/SALOMEDS/SALOMEDS_TargetAttribute.jxx b/src/SALOMEDS/SALOMEDS_TargetAttribute.jxx index 56d2fb154..eff35ad6a 100644 --- a/src/SALOMEDS/SALOMEDS_TargetAttribute.jxx +++ b/src/SALOMEDS/SALOMEDS_TargetAttribute.jxx @@ -24,7 +24,7 @@ // File : SALOMEDS_TargetAttribute.jxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ #ifndef _Standard_GUID_HeaderFile #include diff --git a/src/SALOMEDS/SALOMEDS_TextColorAttribute.cxx b/src/SALOMEDS/SALOMEDS_TextColorAttribute.cxx index c264f94b3..89b033e6e 100644 --- a/src/SALOMEDS/SALOMEDS_TextColorAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_TextColorAttribute.cxx @@ -24,7 +24,7 @@ // File : SALOMEDS_TextColorAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ using namespace std; #include "SALOMEDS_TextColorAttribute.ixx" diff --git a/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.cxx b/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.cxx index 4194d1353..ccc3c70a8 100644 --- a/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.cxx @@ -24,7 +24,7 @@ // File : SALOMEDS_TextHighlightColorAttribute.cxx // Author : Yves FRICAUD // Module : SALOME -// $Header: +// $Header$ using namespace std; #include "SALOMEDS_TextHighlightColorAttribute.ixx" diff --git a/src/SALOMEGUI/CLIENT_msg_en.po b/src/SALOMEGUI/CLIENT_msg_en.po index e20546601..b70fcfcfc 100644 --- a/src/SALOMEGUI/CLIENT_msg_en.po +++ b/src/SALOMEGUI/CLIENT_msg_en.po @@ -20,17 +20,17 @@ msgstr "" #--------------- msgid "INF_VERSION" -msgstr "Version 1.3.0" +msgstr "Version 1.4.1" msgid "INF_COPYRIGHT" -msgstr " " +msgstr "Copyright : CEA" msgid "INF_LICENSE" msgstr " " #: SALOMEGUI_AboutDlg.cxx:42 msgid "ABOUT_TLT" -msgstr "About SALOME" +msgstr "About PAL/SALOME" #: QAD_Config.cxx:84 msgid "MEN_APPNAME" @@ -38,8 +38,8 @@ msgstr "salome" #: QAD_Application.cxx:133 msgid "QAD_Application::APP_DEFAULTTITLE" -msgstr "SALOME 1.3.0" +msgstr "PAL/SALOME 1.4.1" #: QAD_Desktop.cxx:424 msgid "QAD_Desktop::DESK_DEFAULTTITLE" -msgstr "SALOME 1.3.0" +msgstr "PAL/SALOME 1.4.1" diff --git a/src/SALOMEGUI/PyInterp_base.h b/src/SALOMEGUI/PyInterp_base.h index 48781e85f..1e4ac5fea 100644 --- a/src/SALOMEGUI/PyInterp_base.h +++ b/src/SALOMEGUI/PyInterp_base.h @@ -12,12 +12,13 @@ #ifndef _PYINTERP_BASE_H_ #define _PYINTERP_BASE_H_ -using namespace std; #include #include #include #include +using namespace std; + #define TOP_HISTORY_PY "--- top of history ---" #define BEGIN_HISTORY_PY "--- begin of history ---" diff --git a/src/SALOMEGUI/QAD_Action.h b/src/SALOMEGUI/QAD_Action.h index 0a82f62b6..5dcea8c45 100644 --- a/src/SALOMEGUI/QAD_Action.h +++ b/src/SALOMEGUI/QAD_Action.h @@ -37,19 +37,19 @@ class ActionMap { ActionMap() {} ~ActionMap() { - QMapIterator it; + QMapIterator it; for ( it = myMap.begin(); it != myMap.end(); it++ ) delete (QActionP*)it.data(); myMap.clear(); } - bool isEmpty() { return myMap.isEmpty(); } - void insert( const unsigned int id, QActionP* action ) { myMap[id] = action; } - QActionP* at( const unsigned int id ) { return myMap[id]; } + bool isEmpty() { return myMap.isEmpty(); } + void insert( const int id, QActionP* action ) { myMap[id] = action; } + QActionP* at( const int id ) { return myMap[id]; } void clear() { myMap.clear(); } - QActionP*& operator[] (const unsigned int id) { return myMap[id]; } - bool hasAction( const unsigned int id ) { return myMap.contains(id); } + QActionP*& operator[] (const int id) { return myMap[id]; } + bool hasAction( const int id ) { return myMap.contains(id); } private: - QMap myMap; + QMap myMap; }; diff --git a/src/SALOMEGUI/QAD_Application.cxx b/src/SALOMEGUI/QAD_Application.cxx index 439362886..99e1eca15 100644 --- a/src/SALOMEGUI/QAD_Application.cxx +++ b/src/SALOMEGUI/QAD_Application.cxx @@ -1243,11 +1243,13 @@ void QAD_Application::onStudyActivated(QAD_Study* study) myActiveStudy = study; - /* notification */ - onActiveStudyChanged( oldActiveStudy, myActiveStudy ); - + // VSR : call app activate before informing modules that active study is changed ===> /* application activated */ emit appActivated( this ); + + /* notification */ + onActiveStudyChanged( oldActiveStudy, myActiveStudy ); + // VSR : call app activate before informing modules that active study is changed <=== } /*! @@ -1257,8 +1259,8 @@ void QAD_Application::onStudyDeactivated(QAD_Study* study) { // MESSAGE ("QAD_Application::onStudyDeactivated init. "); QAD_ASSERT_DEBUG_ONLY ( myActiveStudy == study ); - myActiveStudy->onStudyDeactivated(); - myActiveStudy = 0; + if ( study ) + study->onStudyDeactivated(); // MESSAGE ("QAD_Application::onStudyDeactivated done. "); } diff --git a/src/SALOMEGUI/QAD_Config.h b/src/SALOMEGUI/QAD_Config.h index 24baa207b..e5b202a97 100644 --- a/src/SALOMEGUI/QAD_Config.h +++ b/src/SALOMEGUI/QAD_Config.h @@ -55,9 +55,9 @@ public: /** Gets directory of the local configuration file. */ QDir getConfigDir() const { return configDir; } - /** Sets directory of SALOME_ROOT. */ + /** Sets directory of KERNEL_ROOT. */ void setPrgDir(QDir _prgDir) { prgDir=_prgDir; } - /** Gets directory of SALOME_ROOT. */ + /** Gets directory of KERNEL_ROOT. */ QDir getPrgDir() const { return prgDir; } bool createConfigFile( bool overwrite=false ); diff --git a/src/SALOMEGUI/QAD_Desktop.cxx b/src/SALOMEGUI/QAD_Desktop.cxx index 2c9111917..c113b87cc 100644 --- a/src/SALOMEGUI/QAD_Desktop.cxx +++ b/src/SALOMEGUI/QAD_Desktop.cxx @@ -61,7 +61,7 @@ using namespace std; #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" @@ -94,6 +94,8 @@ using namespace std; #include #include +#include + #if QT_VERSION > 300 #include #include @@ -313,10 +315,8 @@ myQueryClose( true ) tr("INF_RESOURCES"); //QMessageBox::warning( this, tr("WRN_WARNING"), errMsg, tr ("BUT_OK") ); } - - if ( !QString(list_composants[ind].modulename).isEmpty() ) - myCombo->insertItem( strdup(list_composants[ind].moduleusername) ); - + if ( ( resDir || moduleusername == "Salome" ) && !modulename.isEmpty() ) // VSR: Force "Salome" component to appear in the combo box + myCombo->insertItem( moduleusername ); } myCombo->adjustSize(); @@ -352,6 +352,7 @@ QAD_Desktop::~QAD_Desktop () //NRI : SAL2214 myNewViewPopup.clear(); //NRI : SAL2214 + myHelpContentsModulePopup.clear(); myToolsPopup.clear(); myPrefPopup.clear(); myStdActions.clear(); @@ -583,9 +584,16 @@ void QAD_Desktop::createActions() exitAction->addTo( &myFilePopup ); myStdActions.insert ( FileExitId, exitAction ); + QAD_ASSERT( connect( &myFilePopup, SIGNAL(highlighted( int )), + this, SLOT(onFilePopupStatusText( int )) )); + + /* 'Edit' actions : provided by application only */ myEditPos = 0; + QAD_ASSERT( connect( &myEditPopup, SIGNAL(highlighted( int )), + this, SLOT(onEditPopupStatusText( int )) )); + /* 'View' actions */ /* toolbars popup menu */ myViewPopup.insertItem( tr("MEN_DESK_VIEW_TOOLBARS"), &myToolBarsPopup ); @@ -627,6 +635,9 @@ void QAD_Desktop::createActions() myViewPos = myViewPopup.count(); + QAD_ASSERT( connect( &myViewPopup, SIGNAL(highlighted( int )), + this, SLOT(onViewPopupStatusText( int )) )); + /* Parse xml file */ QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); if ( resMgr ) { @@ -934,17 +945,46 @@ void QAD_Desktop::createActions() /* 'Help' actions */ /* contents */ - QActionP* helpContentsAction = new QActionP( "", tr("MEN_DESK_HELP_CONTENTS"), Key_F1, this ); - helpContentsAction->setStatusTip ( tr("PRP_DESK_HELP_CONTENTS") ); - QAD_ASSERT(connect( helpContentsAction, SIGNAL(activated()), - this, SLOT( onHelpContents() ))); - helpContentsAction->addTo( &myHelpPopup ); - myStdActions.insert( HelpContentsId , helpContentsAction ); + // MZN : Commented + // QActionP* helpContentsAction = new QActionP( "", tr("MEN_DESK_HELP_CONTENTS"), Key_F1, this ); + // helpContentsAction->setStatusTip ( tr("PRP_DESK_HELP_CONTENTS") ); +// QAD_ASSERT(connect( helpContentsAction, SIGNAL(activated()), +// this, SLOT( onHelpContents() ))); +// helpContentsAction->addTo( &myHelpPopup ); +// myStdActions.insert( HelpContentsId , helpContentsAction ); - id = myHelpPopup.insertSeparator(); +// id = myHelpPopup.insertSeparator(); /* GUI contents */ - // NRI : Temporary commented + myHelpPopup.insertItem( tr("MEN_DESK_HELP_MODULECONTENTS"), &myHelpContentsModulePopup, HelpContentsModuleId); + bool toEnable = false; + + CORBA::Object_var objVarN = myNameService->Resolve("/Kernel/ModulCatalog"); + myCatalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN); + + SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants = + myCatalogue->GetComponentIconeList(); + + for (unsigned int ind = 0; ind < list_composants->length(); ind++) { + QString aModuleName = strdup(list_composants[ind].modulename) ; + QString dir; + if (dir = getenv( aModuleName + "_ROOT_DIR")) { + dir = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + "doc/salome/" ); + QString aFileName = aModuleName + "_index.html"; + if ( QFileInfo( dir + aFileName ).exists() ) { + QString aModuleUserName = strdup(list_composants[ind].moduleusername) ; + if ( aModuleUserName == "Salome" ) aModuleUserName = "Kernel" ; + QActionP* moduleHelpAction = new QActionP( "", aModuleUserName + " Help" , 0, this, aModuleName); + QAD_ASSERT(connect( moduleHelpAction, SIGNAL(activated()), this, SLOT(onHelpContentsModule() ))); + moduleHelpAction->addTo( &myHelpContentsModulePopup ); + if (!toEnable) toEnable = true; + } + } + } + + myHelpContentsModulePopup.setEnabled(toEnable); + + // NRI : Temporary commented // QActionP* helpContentsActionGUI = new QActionP( "", tr("MEN_DESK_HELP_GUICONTENTS"), 0, this ); // helpContentsActionGUI->setStatusTip ( tr("PRP_DESK_HELP_GUICONTENTS") ); @@ -953,13 +993,22 @@ void QAD_Desktop::createActions() // helpContentsActionGUI->addTo( &myHelpPopup ); // myStdActions.insert( HelpContentsId , helpContentsActionGUI ); + /* TUI contents */ + /* QActionP* helpContentsActionTUI = new QActionP( "", tr("MEN_DESK_HELP_TUICONTENTS"), 0, this ); helpContentsActionTUI->setStatusTip ( tr("PRP_DESK_HELP_TUICONTENTS") ); QAD_ASSERT(connect( helpContentsActionTUI, SIGNAL(activated()), this, SLOT( onHelpContentsTUI() ))); helpContentsActionTUI->addTo( &myHelpPopup ); myStdActions.insert( HelpContentsId , helpContentsActionTUI ); + */ + + + // Provide status tip for Module help menu item + QAD_ASSERT( connect( &myHelpPopup, SIGNAL(highlighted( int )), this, + SLOT(onHelpModulePopupStatusText( int )) )); + /* search */ // QActionP* helpSearchAction = new QActionP( "", tr("MEN_DESK_HELP_SEARCH"), 0, this ); @@ -1800,15 +1849,7 @@ bool QAD_Desktop::onSaveAsStudy( QAD_Study* study ) */ bool QAD_Desktop::onCloseStudy() { - bool close = this->onCloseStudy ( myActiveStudy, true ); - if ( close && !myXmlHandler->myIdList.IsEmpty() ) { - clearMenus(); - myActiveComp = ""; - myCombo->setCurrentItem (0); - for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) { - aButton->setOn(false); - } - } + bool close = this->onCloseStudy ( getActiveStudy(), true ); return close; } @@ -1859,6 +1900,7 @@ bool QAD_Desktop::onCloseStudy( QAD_Study* study, bool ask ) /* close active component */ if (!myXmlHandler->myIdList.IsEmpty()) { + deactivateComponent(); clearMenus(); myActiveComp=""; myCombo->setCurrentItem (0); @@ -1962,10 +2004,10 @@ void QAD_Desktop::onSelectionMode() { const QActionP* obj = (QActionP*) sender(); - int SelectionMode = 4; + Selection_Mode SelectionMode = ActorSelection; if ( obj == myStdActions.at(SelectionActorId) ) { - SelectionMode = 4; + SelectionMode = ActorSelection; if ( obj->isOn() ) { myStdActions.at(SelectionCellId)->setOn(false); myStdActions.at(SelectionEdgeId)->setOn(false); @@ -1974,7 +2016,7 @@ void QAD_Desktop::onSelectionMode() myStdActions.at(SelectionActorId)->setOn(true); } else if ( obj == myStdActions.at(SelectionCellId) ) { - SelectionMode = 3; + SelectionMode = CellSelection; if ( obj->isOn() ) { myStdActions.at(SelectionActorId)->setOn(false); myStdActions.at(SelectionEdgeId)->setOn(false); @@ -1983,7 +2025,7 @@ void QAD_Desktop::onSelectionMode() myStdActions.at(SelectionActorId)->setOn(true); } else if ( obj == myStdActions.at(SelectionEdgeId) ) { - SelectionMode = 2; + SelectionMode = EdgeOfCellSelection; if ( obj->isOn() ) { myStdActions.at(SelectionActorId)->setOn(false); myStdActions.at(SelectionCellId)->setOn(false); @@ -1992,7 +2034,7 @@ void QAD_Desktop::onSelectionMode() myStdActions.at(SelectionActorId)->setOn(true); } else if ( obj == myStdActions.at(SelectionPointId) ) { - SelectionMode = 1; + SelectionMode = NodeSelection; if ( obj->isOn() ) { myStdActions.at(SelectionEdgeId)->setOn(false); myStdActions.at(SelectionCellId)->setOn(false); @@ -2011,10 +2053,10 @@ void QAD_Desktop::onSelectionMode() /*! Called on 'View\Selection Mode' */ -void QAD_Desktop::SetSelectionMode(int mode, bool activeCompOnly) +void QAD_Desktop::SetSelectionMode(Selection_Mode mode, bool activeCompOnly) { switch (mode) { - case 1: + case NodeSelection: { myStdActions.at(SelectionEdgeId)->setOn(false); myStdActions.at(SelectionCellId)->setOn(false); @@ -2022,7 +2064,7 @@ void QAD_Desktop::SetSelectionMode(int mode, bool activeCompOnly) myStdActions.at(SelectionPointId)->setOn(true); break; } - case 2: + case EdgeOfCellSelection: { myStdActions.at(SelectionActorId)->setOn(false); myStdActions.at(SelectionCellId)->setOn(false); @@ -2030,15 +2072,18 @@ void QAD_Desktop::SetSelectionMode(int mode, bool activeCompOnly) myStdActions.at(SelectionEdgeId)->setOn(true); break; } - case 3: - { + case CellSelection: + case EdgeSelection: + case FaceSelection: + case VolumeSelection: + { myStdActions.at(SelectionActorId)->setOn(false); myStdActions.at(SelectionEdgeId)->setOn(false); myStdActions.at(SelectionPointId)->setOn(false); myStdActions.at(SelectionCellId)->setOn(true); break; } - case 4: + case ActorSelection: { myStdActions.at(SelectionCellId)->setOn(false); myStdActions.at(SelectionEdgeId)->setOn(false); @@ -2128,6 +2173,16 @@ private: }; +// Provide status tip for GUI help menu item + +void QAD_Desktop::onHelpModulePopupStatusText(int id) +{ + int Id = myHelpPopup.idAt( 0 ); // HelpContentsModuleId + // MESSAGE ( "myHelpContentsModulePopup : " << id << "-" << Id) + if (id == Id) + putInfo("Shows the help contents of each module"); +} + /*! Called on 'help\contents' */ @@ -2158,41 +2213,42 @@ void QAD_Desktop::onHelpContents() } /*! - Called on 'help\GUI Reference' + Called on 'Module Help Reference' */ -void QAD_Desktop::onHelpContentsGUI() -{ -// QCString dir; -// QString root; -// QString homeDir; +void QAD_Desktop::onHelpContentsModule() +{ + const QActionP* obj = (QActionP*) sender(); -// if ( (dir = getenv("KERNEL_ROOT_DIR")) ) { -// root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + "doc" ); -// root = QAD_Tools::addSlash( root + "guihtml" ); -// root = QAD_Tools::addSlash( root + "guihtml" ); -// if ( QFileInfo( root + "salomedoc.html" ).exists() ) { -// homeDir = root; -// } -// } -// if ( root.isEmpty() ) { -// if ( QFileInfo( "/usr/local/doc/guihtml/salomedoc.html" ).exists() ) { -// homeDir = "/usr/local/doc/guihtml/"; -// } -// } -// if ( root.isEmpty() ) -// root = "./doc/"; -// QString helpFile = QFileInfo( homeDir + "salomedoc.html" ).absFilePath(); -// QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application"); -// QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters"); + QString aComponentName = obj->name(); + QString aFileName = aComponentName + "_index.html"; + + QCString dir; + QString root; + QString homeDir; + if (dir = getenv( aComponentName + "_ROOT_DIR")) { + root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("doc") + QAD_Tools::addSlash("salome") ); + if ( QFileInfo( root + aFileName ).exists() ) { + homeDir = root; + } else { + QMessageBox::warning( this, tr("WRN_WARNING"), + QString( "%1"+ aFileName + " doesn't exist." ).arg(root), tr ("BUT_OK") ); + return; + } + } + + QString helpFile = QFileInfo( homeDir + aFileName ).absFilePath(); + QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application"); + QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters"); -// RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile); -// rs->start(); - + RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile); + rs->start(); } /*! Called on 'help\TUI Reference' */ + +/* Commented void QAD_Desktop::onHelpContentsTUI() { if (myActiveComp == "") @@ -2202,16 +2258,18 @@ void QAD_Desktop::onHelpContentsTUI() QString root; QString homeDir; if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) { - root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + QAD_Tools::addSlash("doc") + "html" ); + root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("doc") + "html" ); if ( QFileInfo( root + "index.html" ).exists() ) { homeDir = root; - } else { + } else if (QFileInfo( root + "html/index.html" ).exists()) + homeDir = root + QAD_Tools::addSlash("html"); + else { QMessageBox::warning( this, tr("WRN_WARNING"), QString( "%1index.html doesn't exist." ).arg(root), tr ("BUT_OK") ); return; } } - + QString helpFile = QFileInfo( homeDir + "index.html" ).absFilePath(); QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application"); @@ -2220,6 +2278,8 @@ void QAD_Desktop::onHelpContentsTUI() RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile); rs->start(); } +*/ + // /*! // Called on 'help\search' @@ -2359,10 +2419,10 @@ void QAD_Desktop::onWindowPopupAboutToShow() */ void QAD_Desktop::onWindowsPopupStatusText( int id ) { - int cascadeId = myWindowPopup.idAt( 0 ); - int tileId = myWindowPopup.idAt( 1 ); + int cascadeId = myWindowPopup.idAt( 1 ); + int tileId = myWindowPopup.idAt( 2 ); if ( id == cascadeId || id == tileId ) - return; + return; putInfo( tr("PRP_DESK_WINDOW_ACTIVATE") ); } @@ -2478,7 +2538,9 @@ void QAD_Desktop::onOpenWith() } else if ( list_type_composants->length() > 1 ) { SALOMEGUI_OpenWith* aDlg = new SALOMEGUI_OpenWith( this ); for (unsigned int ind = 0; ind < list_type_composants->length();ind++) { - aDlg->addComponent( strdup(list_type_composants[ind]) ); + QString compusername = getComponentUserName( strdup(list_type_composants[ind]) ); + if ( !compusername.isEmpty() ) + aDlg->addComponent( compusername ); } int retVal = aDlg->exec(); @@ -2771,7 +2833,8 @@ bool QAD_Desktop::loadComponent(QString Component) QString QAD_Desktop::changeXmlInputSourceData(QString theData, QString theComponent) { - if ( theComponent=="Supervision" ) { + // MESSAGE ( " changeXmlInputSourceData : " << theComponent.latin1() ) + if ( theComponent=="SUPERV" ) { //Supervision main menu item int aItemId = 300; int aPosId = 3; @@ -2780,7 +2843,7 @@ QString QAD_Desktop::changeXmlInputSourceData(QString theData, QString theCompon theData = theData.replace( QRegExp(aStrOld), aStrNew ); } - if ( theComponent == "Visu" ) { + if ( theComponent == "VISU" ) { //Visualization main menu item int aItemId = 401; int aPosId = 3; @@ -2833,44 +2896,44 @@ QString QAD_Desktop::changeXmlInputSourceData(QString theData, QString theCompon theData = theData.replace( QRegExp(aStrOld), aStrNew ); //Numbering main menu item - aItemId = 80; - aPosId = 7; - aStrOld = createString( aItemId, aPosId ); - aStrNew = createString( aItemId, aPosId+1 ); - theData = theData.replace( QRegExp(aStrOld), aStrNew ); +// aItemId = 80; +// aPosId = 7; +// aStrOld = createString( aItemId, aPosId ); +// aStrNew = createString( aItemId, aPosId+1 ); +// theData = theData.replace( QRegExp(aStrOld), aStrNew ); } - if ( theComponent == "Geometry" ) { + if ( theComponent == "GEOM" ) { //New Entity main menu item - int aItemId = 70; + int aItemId = 40; int aPosId = 3; QString aStrOld = createString( aItemId, aPosId ); QString aStrNew = createString( aItemId, aPosId+1 ); theData = theData.replace( QRegExp(aStrOld), aStrNew ); //Operations main menu item - aItemId = 40; + aItemId = 50; aPosId = 4; aStrOld = createString( aItemId, aPosId ); aStrNew = createString( aItemId, aPosId+1 ); theData = theData.replace( QRegExp(aStrOld), aStrNew ); //Repair main menu item - aItemId = 50; + aItemId = 60; aPosId = 5; aStrOld = createString( aItemId, aPosId ); aStrNew = createString( aItemId, aPosId+1 ); theData = theData.replace( QRegExp(aStrOld), aStrNew ); //Measures main menu item - aItemId = 60; + aItemId = 70; aPosId = 6; aStrOld = createString( aItemId, aPosId ); aStrNew = createString( aItemId, aPosId+1 ); theData = theData.replace( QRegExp(aStrOld), aStrNew ); } - if ( theComponent == "Med" ) { + if ( theComponent == "MED" ) { //MED main menu item int aItemId = 90; int aPosId = 3; @@ -3012,6 +3075,9 @@ void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoad { if (myActiveStudy != 0) { if (myActiveComp.compare(component)!=0) { + // deactivate previous component + deactivateComponent(); + if (!myXmlHandler->myIdList.IsEmpty()) clearMenus(); if ( myCombo->currentText() != component ) myCombo->setCurrentText( component ); @@ -3075,8 +3141,13 @@ void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoad } } } else if (component.compare(QString("Salome"))!= 0) { - - SALOMEGUI_ActivateComponentDlg aDlg( this ); + + QPixmap pm; + for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) { + if ( aButton->textLabel().compare( component ) == 0 ) + pm = aButton->iconSet().pixmap(); + } + SALOMEGUI_ActivateComponentDlg aDlg( this, component, pm ); int res = aDlg.exec(); switch ( res ) @@ -3239,39 +3310,52 @@ void QAD_Desktop::definePopup(QString & theContext, } } + /*! - Create popup + Copy popup menu [ static ] */ -void QAD_Desktop::createPopup(QPopupMenu* popupFather, QPopupMenu* popup, - QString text, int popupID, bool separator) -{ - QMenuItem* item = popup->findItem(popupID); - if (item) { - QPopupMenu* popupChild = item->popup(); - if ( popupChild ) { - QPopupMenu* newPopup = new QPopupMenu; - int count = popupChild->count(); - // add items at the top of - for (int i = count - 1; i >= 0; i--) { - int j = popupChild->idAt(i); - QString text = popupChild->text(j); - createPopup( newPopup, popupChild, text, j); +static void makePopup( QPopupMenu* popup, QPopupMenu* fromPopup, QAD_Desktop* receiver ) +{ + // safe check + if ( !popup || !fromPopup ) + return; + // iterator through all popup items + for ( int i = fromPopup->count()-1; i >= 0; i-- ) { + int cmdId = fromPopup->idAt( i ); + QMenuItem* item = fromPopup->findItem( cmdId ); + if ( item ) { + // if item is a separator + if ( item->isSeparator() ) { + popup->insertSeparator( 0 ); + } + else { + QIconSet* iconSet = item->iconSet(); + QKeySequence accel = fromPopup->accel( cmdId ); + + QPopupMenu* popupChild = item->popup(); + // if item is a popup + if ( popupChild && popupChild != fromPopup ) { + QPopupMenu* newPopup = new QPopupMenu( popup ); + if ( iconSet ) + popup->insertItem( *iconSet, item->text(), newPopup, cmdId, 0 ); + else + popup->insertItem( item->text(), newPopup, cmdId, 0 ); + makePopup( newPopup, popupChild, receiver ); + } + // if item is a command + else { + if ( iconSet ) + popup->insertItem( *iconSet, item->text(), cmdId, 0 ); + else + popup->insertItem( item->text(), cmdId, 0 ); + popup->connectItem( cmdId, receiver, SLOT( onDispatch( int ) ) ); + } + popup->setAccel( accel, cmdId ); } - popupFather->insertItem(popup->text(popupID), - newPopup, popupID, 0); - } else { - if ( !text.isNull() ) { - popupFather->insertItem(popup->text(popupID), - this, - SLOT( onDispatch(int) ), 0, popupID, 0);// try adding item at the top - } /*else if ( separator ) - popupFather->insertTearOffHandle(-1, 0);*/ - else - popupFather->insertSeparator(0); } } } - + /*! Create popup */ @@ -3280,34 +3364,8 @@ void QAD_Desktop::createPopup(QPopupMenu* popup, const QString & theContext, { if ( !myActiveComp.isEmpty() && getOperatorMenus()->createPopupMenu(theContext,theParent,theObject) != NULL ) { - QPopupMenu* aPopup = getOperatorMenus()->createPopupMenu(theContext,theParent,theObject)->getPopup(); - int count = aPopup->count(); - - //for (int i = 0; i < count; i++) { - for (int i = count - 1; i >= 0; i--) { - int id = aPopup->idAt(i); - QString text = aPopup->text(id); - //QString mes("Inserting popup menu item loaded from XML: "); - //mes += text; - //MESSAGE ( mes.latin1() ) - if (i==0) - popup->insertItem(aPopup->text(id), - this, - SLOT( onDispatch(int) ), 0, id, 0);// try adding item at the top - else - createPopup( popup, aPopup, text, id); - } - } //else { - //QString mes("Popup does not exist for given (Context = "); - //mes += theContext; - //mes += ", Parent = "; - //mes += theParent; - //mes += ", Object = "; - //mes += theObject; - //MESSAGE (mes.latin1()) - //popup->clear(); - //} - + makePopup( popup, getOperatorMenus()->createPopupMenu(theContext,theParent,theObject)->getPopup(), this ); + } // IAPP Popup // Should be moved to SALOMEGUI_Application::onCreatePopup()... if ( myActiveComp.isEmpty() ) { @@ -3327,10 +3385,11 @@ void QAD_Desktop::createPopup(QPopupMenu* popup, const QString & theContext, } } } - + } typedef bool activeStudyChanged(QAD_Desktop*); +typedef void deactivate(); void QAD_Desktop::onActiveStudyChanged() { @@ -3343,6 +3402,17 @@ void QAD_Desktop::onActiveStudyChanged() } } +void QAD_Desktop::deactivateComponent() +{ + if (!myActiveComp.isEmpty()) { + OSD_Function osdF = mySharedLibrary.DlSymb("deactivate"); + if ( osdF != NULL ) { + deactivate (*f1) = (void (*)()) osdF; + (*f1)(); + } + } +} + typedef bool customP(QAD_Desktop*, QPopupMenu*, const QString & theContext, const QString & theParent, const QString & theObject); /*! @@ -3577,6 +3647,7 @@ void QAD_Desktop::onViewerOCC() QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() ); if (c.isValid()) { + /* VSR : PAL5420 --------------------------------------------------- if ( myActiveApp ) { QList& studies = myActiveApp->getStudies(); for ( QAD_Study* study = studies.first(); study; study = studies.next() ) { @@ -3589,6 +3660,7 @@ void QAD_Desktop::onViewerOCC() } } } + VSR : PAL5420 --------------------------------------------------- */ QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorRed", c.red() ); QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorGreen", c.green() ); QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorBlue", c.blue() ); @@ -3612,6 +3684,7 @@ void QAD_Desktop::onGraphSupervisor() QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() ); if (c.isValid()) { + /* VSR : PAL5420 --------------------------------------------------- if ( myActiveApp ) { QList& studies = myActiveApp->getStudies(); for ( QAD_Study* study = studies.first(); study; study = studies.next() ) { @@ -3624,7 +3697,7 @@ void QAD_Desktop::onGraphSupervisor() } } } - + VSR : PAL5420 --------------------------------------------------- */ QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorRed", c.red() ); QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorGreen", c.green() ); QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorBlue", c.blue() ); @@ -3648,6 +3721,7 @@ void QAD_Desktop::onViewerVTK() QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() ); if (c.isValid()) { + /* VSR : PAL5420 --------------------------------------------------- if ( myActiveApp ) { QList& studies = myActiveApp->getStudies(); for ( QAD_Study* study = studies.first(); study; study = studies.next() ) { @@ -3660,7 +3734,7 @@ void QAD_Desktop::onViewerVTK() } } } - + VSR : PAL5420 --------------------------------------------------- */ QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorRed", c.red() ); QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorGreen", c.green() ); QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorBlue", c.blue() ); @@ -3680,12 +3754,13 @@ void QAD_Desktop::onPlot2d() color = QColor( bgRed, bgGreen, bgBlue ); } else { - color = QColor(0, 0, 0); + color = QColor(255, 255, 255); } color = QColorDialog::getColor( color, QAD_Application::getDesktop() ); if ( color.isValid() ) { + /* VSR : PAL5420 --------------------------------------------------- if ( myActiveApp ) { QList& studies = myActiveApp->getStudies(); for ( QAD_Study* study = studies.first(); study; study = studies.next() ) { @@ -3698,6 +3773,7 @@ void QAD_Desktop::onPlot2d() } } } + VSR : PAL5420 --------------------------------------------------- */ QStringList bgData; bgData.append( QString::number( color.red() ) ); bgData.append( QString::number( color.green() ) ); @@ -3818,6 +3894,85 @@ void QAD_Desktop::onUndoLevel() } } +/* Update status bar for File menu items */ +void QAD_Desktop::onFilePopupStatusText( int id ) +{ + QString component = getActiveComponent(); + + if (component != "") { + //one of the modules is active now + int importId = myFilePopup.idAt(8); + int exportId = myFilePopup.idAt(9); + + 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 == exportId) + putInfo( tr("PRP_DESK_FILE_IMPORTTABLE") ); + } + 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(4); + + if (id == DispModeId) + putInfo( tr("PRP_DESK_VIEW_DISPLAYMODE") ); + if (id == updateId) + putInfo( tr("PRP_DESK_VIEW_UPDATE") ); + } + } +} + /********************************************************************* ** Class: AppSelectionDlg ** Descr: Dialog for the selection of the application when several diff --git a/src/SALOMEGUI/QAD_Desktop.h b/src/SALOMEGUI/QAD_Desktop.h index 56f8a7907..2f1fab179 100644 --- a/src/SALOMEGUI/QAD_Desktop.h +++ b/src/SALOMEGUI/QAD_Desktop.h @@ -39,6 +39,7 @@ #include "SALOME_NamingService.hxx" #include "SALOME_LifeCycleCORBA.hxx" +#include "SALOME_Selection.h" // IDL Headers #include @@ -71,7 +72,7 @@ class QAD_EXPORT QAD_Desktop : public QMainWindow protected: //NRI - unused - : enum ComponentType {GEOM, MESH, SOLVER, DATA, VISU, OTHER} ; - enum { FileNewId = 0, FileOpenId, FileLoadId, FileCloseId, FileSaveId, FileSaveAsId, FilePropsId, FileExitId, + enum { FileNewId = -1000, FileOpenId, FileLoadId, FileCloseId, FileSaveId, FileSaveAsId, FilePropsId, FileExitId, ViewStatusBarId, SelectionPointId, SelectionEdgeId, SelectionCellId, SelectionActorId, PrefViewerOCCId, PrefViewerVTKId, PrefGraphSupervisorId, PrefViewerPlot2dId, @@ -86,7 +87,8 @@ protected: WindowNew3dId, ViewOCCId, ViewVTKId, ViewPlot2dId, //NRI : SAL2214 WindowCascadeId, WindowTileId, - HelpContentsId, HelpSearchId, HelpWhatsThisId, HelpAboutId }; + HelpContentsId, HelpContentsModuleId, + HelpSearchId, HelpWhatsThisId, HelpAboutId }; enum UpdateCommand { ActivateApp, DeactivateApp }; /* Desktop can be created only by application */ @@ -114,16 +116,13 @@ public: void definePopup(QString & theContext, QString & theParent, QString & theObject ); - - void createPopup(QPopupMenu* popupFather, QPopupMenu* popup, - QString text, int popupID, bool separator = false); void createPopup(QPopupMenu* popup, const QString & theContext, const QString & theParent, const QString & theObject ); void customPopup(QPopupMenu* popup, const QString & theContext, const QString & theParent, const QString & theObject); /* selection mode */ - void SetSelectionMode(int mode, bool activeCompOnly = false); + void SetSelectionMode(Selection_Mode mode, bool activeCompOnly = false); /* desktop */ void showDesktop(); @@ -155,6 +154,7 @@ public: bool loadComponent(QString); QString changeXmlInputSourceData(QString theData, QString theComponent); void activateComponent(const QString& theName, bool isLoadData = true); + void deactivateComponent(); void createStudy(); void setSettings(); @@ -220,6 +220,11 @@ protected slots: virtual void onWindowPopupAboutToShow(); void onWindowsPopupActivated( int id ); void onWindowsPopupStatusText( int id ); + void onHelpModulePopupStatusText(int id); + + void onFilePopupStatusText( int id ); + void onEditPopupStatusText( int id ); + void onViewPopupStatusText( int id ); void onSelectionMode(); @@ -245,8 +250,8 @@ protected slots: void onDeactivateApp(QAD_Application* app); void onHelpContents(); - void onHelpContentsGUI(); - void onHelpContentsTUI(); + void onHelpContentsModule(); + /* void onHelpContentsTUI(); */ /* void onHelpSearch(); */ void onHelpAbout(); @@ -285,11 +290,13 @@ protected: //NRI : SAL2214 QPopupMenu myNewViewPopup; //NRI : SAL2214 + QPopupMenu myHelpContentsModulePopup; + QPopupMenu myToolsPopup; QPopupMenu myPrefPopup; QPopupMenu mySelectionModePopup; QPopupMenu myWindowPopup; /* not customized by an application */ - + ActionMap myStdActions; /* default actions */ QToolBar* myStdToolBar; /* standard toolbar */ QStatusBar* myStatusBar; /* the only status bar */ diff --git a/src/SALOMEGUI/QAD_HelpWindow.cxx b/src/SALOMEGUI/QAD_HelpWindow.cxx index d715bf5df..8f4322541 100644 --- a/src/SALOMEGUI/QAD_HelpWindow.cxx +++ b/src/SALOMEGUI/QAD_HelpWindow.cxx @@ -111,9 +111,9 @@ QAD_HelpWindow::QAD_HelpWindow() /* // look for index.html and set homeDir - // 1. $(SALOME_ROOT_DIR)/doc/index.html - // 2. $(SALOME_ROOT_DIR)/doc/html/index.html - // 3. $(SALOME_ROOT_DIR)/doc/html/html/index.html + // 1. $(KERNEL_ROOT_DIR)/doc/index.html + // 2. $(KERNEL_ROOT_DIR)/doc/html/index.html + // 3. $(KERNEL_ROOT_DIR)/doc/html/html/index.html // 4. /usr/local/doc/html/index.html QCString dir; diff --git a/src/SALOMEGUI/QAD_ObjectBrowser.cxx b/src/SALOMEGUI/QAD_ObjectBrowser.cxx index d72f4c9d3..079462ef3 100644 --- a/src/SALOMEGUI/QAD_ObjectBrowser.cxx +++ b/src/SALOMEGUI/QAD_ObjectBrowser.cxx @@ -717,9 +717,12 @@ void QAD_ObjectBrowser::Update( SALOMEDS::SObject_ptr SO, QString msg; QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); if ( resMgr ) { - if(resMgr->loadResources( QString(aFatherName->Value()) + "GUI", msg )) { - QPixmap icon ( resMgr->loadPixmap( QString(aFatherName->Value()) + "GUI", - tr(aPixmap->GetPixMap()) /*tr( "ICON_OBJBROWSER_" + theComponent )*/ )); + //if(resMgr->loadResources( QString(aFatherName->Value()) + "GUI", msg )) { + if( resMgr->loadResources( QAD_Application::getDesktop()->getComponentName( QString( aFatherName->Value() ) ), msg ) ) { + QPixmap icon ( resMgr->loadPixmap( QAD_Application::getDesktop()->getComponentName( QString( aFatherName->Value() ) ), + tr( aPixmap->GetPixMap() ) /*tr( "ICON_OBJBROWSER_" + theComponent )*/ ) ); + //QPixmap icon ( resMgr->loadPixmap( QString(aFatherName->Value()) + "GUI", + //tr(aPixmap->GetPixMap()) /*tr( "ICON_OBJBROWSER_" + theComponent )*/ )); Item->setPixmap( 0, icon ); } } diff --git a/src/SALOMEGUI/QAD_PyEditor.cxx b/src/SALOMEGUI/QAD_PyEditor.cxx index 4dd3aa333..a125e4fa7 100644 --- a/src/SALOMEGUI/QAD_PyEditor.cxx +++ b/src/SALOMEGUI/QAD_PyEditor.cxx @@ -216,7 +216,7 @@ void QAD_PyEditor::mouseReleaseEvent ( QMouseEvent * e ) */ void QAD_PyEditor::dropEvent (QDropEvent *e) { - INFOS("dropEvent : not handled"); + MESSAGE("dropEvent : not handled"); } /*! diff --git a/src/SALOMEGUI/QAD_ResourceMgr.cxx b/src/SALOMEGUI/QAD_ResourceMgr.cxx index d116c7b33..f6e5b6e8f 100644 --- a/src/SALOMEGUI/QAD_ResourceMgr.cxx +++ b/src/SALOMEGUI/QAD_ResourceMgr.cxx @@ -56,6 +56,7 @@ static const char* RES_DOCS = "docs"; static const char* RES_PIXMAPS = "icons"; static const char* RES_STRINGS = "strings"; static const char* RES_LANGUAGE = "language"; +static const char* RES_FILES = "resources"; static const char* SEPARATOR = ":"; @@ -125,8 +126,11 @@ bool QAD_ResourceMgr::loadResources( const char* prefix, QString &msg ) */ QString resDirs = collectDirs( prefix ); conf.insert( RES_DIR, new QString( resDirs ) ); - QString fileConfig = path( CONFIG_FILE, prefix, 0 ) ; + QString fileConfig = QString( prefix ) + QString( "." ) + QString( CONFIG_FILE ); + fileConfig = path( fileConfig, prefix, 0 ) ; //MESSAGE("QAD_ResourceMgr::loadresources : config : "<= 0; i-- ) { - QString dir = dirList[ i ]; - QString fileString = QAD_Tools::addSlash( dir ) + stFile; - QString fileImage = QAD_Tools::addSlash( dir ) + imagesFile; + QStringList resFiles = conf[ RES_FILES ] ? QStringList::split( SEPARATOR, *( conf[ RES_FILES ] ), false ) : QStringList(); + + // first load main module's resources + QString fileString = path( stFile, prefix, 0 ); + QString fileImage = path( imagesFile, prefix, 0 ); + + if ( !fileString.isEmpty() && settings->load( fileString ) ) { + bLoadString = true; + } + if ( !fileImage.isEmpty() && settings->load( fileImage ) ) { + bLoadImages = true; + } + + // then load additional module's resources if any are given + for ( int j = 0; j < resFiles.count(); j++ ) { + QString stFileAdd = resFiles[j] + "_msg_" + *( conf[ RES_LANGUAGE ] ) + ".qm" ; + QString imagesFileAdd = resFiles[j] + "_" + RES_PIXMAPS + ".qm"; + if ( conf[ RES_STRINGS ] && !conf[ RES_STRINGS ]->isEmpty() ) + stFileAdd = QAD_Tools::addSlash( *conf[ RES_STRINGS ] ) + stFileAdd; + if ( conf[ RES_PIXMAPS ] && !conf[ RES_PIXMAPS ]->isEmpty() ) + imagesFileAdd = QAD_Tools::addSlash( *conf[ RES_PIXMAPS ] ) + imagesFileAdd; - if ( settings->load( fileString ) ) { - bLoadString = true; - } - if ( settings->load( fileImage ) ) { - bLoadImages = true; - } + QString fileStringAdd = path( stFileAdd, prefix, 0 ); + QString fileImageAdd = path( imagesFileAdd, prefix, 0 ); + + if ( !fileStringAdd.isEmpty() ) + settings->load( fileStringAdd ); + if ( !fileImageAdd.isEmpty() ) + settings->load( fileImageAdd ); } - + if ( !bLoadString ) { QString warnMsg; warnMsg.sprintf( "String resources for module %s not found.\n" @@ -241,14 +262,14 @@ QString QAD_ResourceMgr::resources( const char* prefix ) const can be situated The order is following : - _ROOT_DIR/share/salome/resources directory - - CSF_Resources env.var directory ( or directory list ) + - SALOME_Resources env.var directory ( or directory list ) - ${HOME}/.salome/resources directory - KERNEL_ROOT_DIR/share/salome/resources directory */ QString QAD_ResourceMgr::collectDirs( const QString& prefix ) const { QString dirList; - QCString envVar( "CSF_" ); + QCString envVar; QString dir; char* cenv; @@ -270,9 +291,9 @@ QString QAD_ResourceMgr::collectDirs( const QString& prefix ) const } } - // Try CSF_Resources env.var directory ( or directory list ) + // Try SALOME_Resources env.var directory ( or directory list ) if ( !prefix.isEmpty() ) { - envVar = QCString( "CSF_" ) + prefix.latin1() + QCString( "Resources" ); + envVar = QCString( "SALOME_" ) + prefix.latin1() + QCString( "Resources" ); cenv = getenv( ( const char* ) envVar ); if ( cenv ) { dir.sprintf( "%s", cenv ); @@ -357,8 +378,6 @@ QString QAD_ResourceMgr::findFile( const QString& filename, const char* prefix ) */ QString QAD_ResourceMgr::path( const QString& filename, const char* prefix, const char* key ) const { - QString filePath; - ResourceSettings* rs = myRes[ prefix ]; if ( rs ) { StringDict& conf = rs->config(); @@ -369,22 +388,20 @@ QString QAD_ResourceMgr::path( const QString& filename, const char* prefix, cons for ( int i = 0; i < dirList.count(); i++ ) { QString dir = dirList[ i ]; dir = QAD_Tools::addSlash( dir ); - if ( key ) { - QString* where = conf[ key ]; - if ( where ) - dir = dir + QAD_Tools::addSlash( *where ); + if ( key && conf[ key ] ) { + dir = dir + QString( *( conf[ key ] ) ); + dir = QAD_Tools::addSlash( dir ); } dir = dir + filename; QFileInfo fileInfo( dir ); if ( fileInfo.isFile() && fileInfo.exists() ) { - filePath = fileInfo.filePath(); - break; + return fileInfo.filePath(); } } } } //MESSAGE("QAD_ResourceMgr::path : <"< : "< @@ -57,7 +58,7 @@ public: virtual void setBackgroundColor( const QColor& ) = 0; virtual QColor backgroundColor() const = 0; - virtual void SetSelectionMode( int mode ) = 0; + virtual void SetSelectionMode( Selection_Mode mode ) = 0; virtual void onAdjustTrihedron() = 0; diff --git a/src/SALOMEGUI/QAD_WaitCursor.h b/src/SALOMEGUI/QAD_WaitCursor.h index 3d33a2f70..2f5dbe6d9 100644 --- a/src/SALOMEGUI/QAD_WaitCursor.h +++ b/src/SALOMEGUI/QAD_WaitCursor.h @@ -18,19 +18,20 @@ class QAD_EXPORT QAD_WaitCursor { public: // constructor - QAD_WaitCursor() : myStarted(false) { start(); } + QAD_WaitCursor() : myStarted( false ), myDepth( 1 ) { start(); } // destructor - ~QAD_WaitCursor() { stop(); } + ~QAD_WaitCursor() { if ( !myStarted ) { myDepth--; start(); } else { QApplication::restoreOverrideCursor(); } } // sets WAIT cursor if not set yet - void start() { if (!myStarted) { QApplication::setOverrideCursor(Qt::waitCursor); myStarted = true; } } + void start() { if ( !myStarted ) { while( myDepth-- ) QApplication::setOverrideCursor( Qt::waitCursor ); myStarted = true; } myDepth = 0; } // clears WAIT cursor if set - void stop() { if (myStarted) { QApplication::restoreOverrideCursor(); myStarted = false; } } + void stop() { if ( myStarted ) { while( QApplication::overrideCursor() ) { QApplication::restoreOverrideCursor(); myDepth++; } myStarted = false; } } // returns true if WAIT cursor is active bool isStarted() { return myStarted; } private: bool myStarted; + int myDepth; }; #endif diff --git a/src/SALOMEGUI/QAD_msg_en.po b/src/SALOMEGUI/QAD_msg_en.po index e845d78e4..57fafb7b2 100644 --- a/src/SALOMEGUI/QAD_msg_en.po +++ b/src/SALOMEGUI/QAD_msg_en.po @@ -176,8 +176,8 @@ msgid "QAD_Desktop::MEN_DESK_HELP_CONTENTS" msgstr "&Contents" #: QAD_Desktop.cxx:265 -msgid "QAD_Desktop::MEN_DESK_HELP_GUICONTENTS" -msgstr "&GUI Reference" +msgid "QAD_Desktop::MEN_DESK_HELP_MODULECONTENTS" +msgstr "&Module Help" #: QAD_Desktop.cxx:265 msgid "QAD_Desktop::MEN_DESK_HELP_TUICONTENTS" diff --git a/src/SALOMEGUI/SALOMEGUI_ActivateComponentDlg.cxx b/src/SALOMEGUI/SALOMEGUI_ActivateComponentDlg.cxx index 7e326d083..42859b842 100644 --- a/src/SALOMEGUI/SALOMEGUI_ActivateComponentDlg.cxx +++ b/src/SALOMEGUI/SALOMEGUI_ActivateComponentDlg.cxx @@ -11,69 +11,190 @@ using namespace std; #include "SALOMEGUI_ActivateComponentDlg.h" +#include +#include #include -#include -#include -#include -#include +#include +#include +static const char* const default_icon[] = { +"48 48 17 1", +". c None", +"# c #161e4c", +"b c #1d3638", +"e c #2f585b", +"i c #345b5e", +"c c #386266", +"g c #3f7477", +"d c #4d8589", +"m c #519099", +"o c #6abbc1", +"a c #70c9d3", +"f c #79ddea", +"n c #7adff2", +"k c #7ce2f4", +"j c #993550", +"h c #d84b71", +"l c #ef537d", +"................................................", +"................................................", +"................................................", +"................................................", +"................................................", +"................########.########.########......", +"...............#aaaaaa###aaaaaa###aaaaaa##......", +"..............#aaaaaa#b#aaaaaa#b#aaaaaa#c#......", +".............########b########b########cc#......", +".............#dddddd#b#dddddd#b#dddddd#cc#......", +"...........########d########d########d#cc#......", +"..........#aaaaaa###aaaaaa###aaaaaa##d#cc#......", +".........#aaaaaa#b#aaaaaa#b#aaaaaa#c#d#cc#......", +"........########b########e########cc#d#c#.......", +"........#dddddd#b#dddddd#e#ffffff#cc#d####......", +"......########d########d########f#cc###g##......", +".....#aaaaaa###aaaaaa###hhhhhh##f#cc#gg#c#......", +"....#aaaaaa#b#aaaaaa#i#hhhhhh#j#f#cc###cc#......", +"...########b########i########jj#f#c#gg#cc#......", +"...#kkkkkk#b#kkkkkk#i#llllll#jj#f####g#cc#......", +"...#kkkkkk#b#kkkkkk#i#llllll#jj###m##g#cc#......", +"...#knnkkk#b#kkkkkk#i#llllll#jj#mm#c#g#cc#......", +"...#knnkkk#b#kkkkkk#i#llllll#jj###cc#g#c#.......", +"...#kkkkkk#b#kkkkkk#i#llllll#j#dd#cc#g####......", +"...#kkkkkk###kkkkkk###llllll####d#cc###g##......", +"...########g########g########o##d#cc#gg#c#......", +"....#gggggg#b#gggggg#b#oooooo#c#d#cc###cc#......", +"...########b########b########cc#d#c#gg#cc#......", +"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#d####g#cc#......", +"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###g##g#cc#......", +"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#gg#c#g#cc#......", +"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###cc#g#c#.......", +"...#kkkkkk#b#kkkkkk#b#kkkkkk#c#gg#cc#g##........", +"...#kkkkkk###kkkkkk###kkkkkk####g#cc###.........", +"...########g########g########g##g#cc#...........", +"....#gggggg#b#gggggg#b#gggggg#c#g#cc#...........", +"...########b########b########cc#g#c#............", +"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#g##.............", +"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###..............", +"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................", +"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................", +"...#kkkkkk#b#kkkkkk#b#kkkkkk#c#.................", +"...#kkkkkk###kkkkkk###kkkkkk##..................", +"...########.########.########...................", +"................................................", +"................................................", +"................................................", +"................................................"}; -SALOMEGUI_ActivateComponentDlg::SALOMEGUI_ActivateComponentDlg ( QWidget * parent, const char * name, bool modal, WFlags f ) - : QDialog ( parent, "", TRUE, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +//============================================================================================================================== +/*! + * SALOMEGUI_ActivateComponentDlg::SALOMEGUI_ActivateComponentDlg + * + * Constructor + */ +//============================================================================================================================== +SALOMEGUI_ActivateComponentDlg::SALOMEGUI_ActivateComponentDlg ( QWidget * parent, const QString& component, const QPixmap icon ) + : QDialog ( parent, "ActivateModuleDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) { - setSizeGripEnabled ( TRUE ) ; + QPixmap defaultIcon( ( const char** ) default_icon ); setCaption( tr( "CAPTION" ) ); + setSizeGripEnabled( TRUE ); + + QGridLayout* ActivateModuleDlgLayout = new QGridLayout( this ); + ActivateModuleDlgLayout->setMargin( 11 ); ActivateModuleDlgLayout->setSpacing( 6 ); - QVBoxLayout* m_vbL = new QVBoxLayout( this ); - m_vbL->setMargin( 11 ); m_vbL->setSpacing( 6 ); - - QLabel* m_lIcon = new QLabel (this, "m_lDescr"); - QPixmap pm = QMessageBox::standardIcon( QMessageBox::Information ); - m_lIcon->setPixmap( pm ); - m_lIcon->setScaledContents( false ); - m_lIcon->setAlignment( Qt::AlignCenter ); - - QLabel* m_lDescr = new QLabel (this, "m_lDescr"); - m_lDescr->setText ( tr ("ActivateComponent_DESCRIPTION") ); - m_lDescr->setAlignment( Qt::AlignCenter ); - m_lDescr->setMinimumHeight( m_lDescr->sizeHint().height()*5 ); - m_lDescr->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + // Module's name and icon + myComponentFrame = new QFrame( this, "myComponentFrame" ); + myComponentFrame->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ) ); + myComponentFrame->setMinimumHeight( 100 ); + myComponentFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); + + QGridLayout* myComponentFrameLayout = new QGridLayout( myComponentFrame ); + myComponentFrameLayout->setMargin( 11 ); myComponentFrameLayout->setSpacing( 6 ); - QHBoxLayout* m_hl1 = new QHBoxLayout(); - m_hl1->setMargin( 0 ); m_hl1->setSpacing( 6 ); - m_hl1->addWidget( m_lIcon ); - m_hl1->addWidget( m_lDescr ); + // --> icon + myComponentIcon = new QLabel( myComponentFrame, "myComponentIcon" ); + myComponentIcon->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); + myComponentIcon->setPixmap( !icon.isNull() ? icon : defaultIcon ); + myComponentIcon->setScaledContents( false ); + myComponentIcon->setAlignment( AlignCenter ); + // --> name + myComponentLab = new QLabel( component, myComponentFrame, "myComponentLab" ); + QFont fnt = myComponentLab->font(); fnt.setBold( TRUE ); myComponentLab->setFont( fnt ); + myComponentLab->setAlignment( AlignCenter ); - m_pb1 = new QPushButton( tr ("NEW"), this ); - m_pb2 = new QPushButton( tr ("OPEN"), this ); - m_pb3 = new QPushButton( tr ("LOAD"), this ); - m_pb4 = new QPushButton( tr ("CANCEL"), this ); + myComponentFrameLayout->addWidget( myComponentIcon, 0, 0 ); + myComponentFrameLayout->addWidget( myComponentLab, 0, 1 ); - QGridLayout* m_hl2 = new QGridLayout(); - m_hl2->setMargin( 0 ); m_hl2->setSpacing( 6 ); - m_hl2->addWidget( m_pb1, 0, 0 ); - m_hl2->addWidget( m_pb2, 0, 1 ); - m_hl2->addWidget( m_pb3, 0, 2 ); - m_hl2->addColSpacing( 3, 10 ); - m_hl2->setColStretch( 3, 5 ); - m_hl2->addWidget( m_pb4, 0, 4 ); + // Info + QVBoxLayout* infoLayout = new QVBoxLayout(); + infoLayout->setMargin( 0 ); infoLayout->setSpacing( 6 ); + + // --> 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 ); - m_vbL->addLayout( m_hl1 ); - m_vbL->addLayout( m_hl2 ); + infoLayout->addStretch(); + infoLayout->addWidget( myLine1 ); + infoLayout->addWidget( myInfoLabel ); + infoLayout->addWidget( myLine2 ); + infoLayout->addStretch(); + + // Buttons + QHBoxLayout* btnLayout = new QHBoxLayout(); + btnLayout->setMargin( 0 ); btnLayout->setSpacing( 6 ); + + // --> New + myNewBtn = new QPushButton( tr( "NEW" ), this, "myNewBtn" ); + myNewBtn->setDefault( true ); myNewBtn->setAutoDefault( true ); + // --> Open + myOpenBtn = new QPushButton( tr( "OPEN" ), this, "myOpenBtn" ); + myOpenBtn->setAutoDefault( true ); + // --> Load + myLoadBtn = new QPushButton( tr( "LOAD" ), this, "myLoadBtn" ); + myLoadBtn->setAutoDefault( true ); + // --> Cancel + myCancelBtn = new QPushButton( tr( "CANCEL" ), this, "myCancelBtn" ); + myCancelBtn->setAutoDefault( true ); + + btnLayout->addWidget( myNewBtn ); + btnLayout->addWidget( myOpenBtn ); + btnLayout->addWidget( myLoadBtn ); + btnLayout->addStretch(); + btnLayout->addSpacing( 70 ); + btnLayout->addStretch(); + btnLayout->addWidget( myCancelBtn ); + + ActivateModuleDlgLayout->addWidget( myComponentFrame, 0, 0 ); + ActivateModuleDlgLayout->addLayout( infoLayout, 0, 1 ); + ActivateModuleDlgLayout->addMultiCellLayout( btnLayout, 1, 1, 0, 1 ); - connect( m_pb1, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) ); - connect( m_pb2, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) ); - connect( m_pb3, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) ); - connect( m_pb4, SIGNAL( clicked() ), this, SLOT( reject() ) ); + // signals and slots connections + connect( myNewBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) ); + connect( myOpenBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) ); + connect( myLoadBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) ); + connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); } +//============================================================================================================================== +/*! + * SALOMEGUI_ActivateComponentDlg::onButtonClicked + * + * Buttons slot + */ +//============================================================================================================================== void SALOMEGUI_ActivateComponentDlg::onButtonClicked() { QPushButton* btn = ( QPushButton* )sender(); - if ( btn == m_pb1 ) + if ( btn == myNewBtn ) done( 1 ); - if ( btn == m_pb2 ) + if ( btn == myOpenBtn ) done( 2 ); - if ( btn == m_pb3 ) + if ( btn == myLoadBtn ) done( 3 ); } diff --git a/src/SALOMEGUI/SALOMEGUI_ActivateComponentDlg.h b/src/SALOMEGUI/SALOMEGUI_ActivateComponentDlg.h index 17544d0a2..878cb9d08 100644 --- a/src/SALOMEGUI/SALOMEGUI_ActivateComponentDlg.h +++ b/src/SALOMEGUI/SALOMEGUI_ActivateComponentDlg.h @@ -12,23 +12,32 @@ #define SALOMEGUI_ActivateComponentDlg_H #include +#include + +class QFrame; +class QLabel; +class QPushButton; class SALOMEGUI_ActivateComponentDlg: public QDialog { Q_OBJECT public: - SALOMEGUI_ActivateComponentDlg ( QWidget * parent = 0, const char * name = 0, bool modal = FALSE, WFlags f = 0 ) ; + SALOMEGUI_ActivateComponentDlg ( QWidget* parent, const QString& component, const QPixmap icon = QPixmap() ) ; ~SALOMEGUI_ActivateComponentDlg ( ) { }; private slots: void onButtonClicked(); private: - QPushButton* m_pb1; - QPushButton *m_pb2; - QPushButton *m_pb3; - QPushButton *m_pb4; + QFrame* myComponentFrame; + QLabel* myComponentLab; + QLabel* myComponentIcon; + QLabel* myInfoLabel; + QPushButton* myNewBtn; + QPushButton* myOpenBtn; + QPushButton* myLoadBtn; + QPushButton* myCancelBtn; }; #endif diff --git a/src/SALOMEGUI/SALOMEGUI_ExternalBrowserDlg.cxx b/src/SALOMEGUI/SALOMEGUI_ExternalBrowserDlg.cxx index 9ad17ddc1..2cb58f858 100644 --- a/src/SALOMEGUI/SALOMEGUI_ExternalBrowserDlg.cxx +++ b/src/SALOMEGUI/SALOMEGUI_ExternalBrowserDlg.cxx @@ -1,7 +1,7 @@ // 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" diff --git a/src/SALOMEGUI/SALOMEGUI_ExternalBrowserDlg.h b/src/SALOMEGUI/SALOMEGUI_ExternalBrowserDlg.h index 95156994b..f92b559c4 100644 --- a/src/SALOMEGUI/SALOMEGUI_ExternalBrowserDlg.h +++ b/src/SALOMEGUI/SALOMEGUI_ExternalBrowserDlg.h @@ -1,7 +1,7 @@ // File : SALOMEGUI_ExternalBrowserDlg.h // Author : Michael Zorin // Module : SALOME -// $Header: /dn05/salome/CVS/SALOME_ROOT/SALOME/src/SALOMEGUI/SALOMEGUI_ExternalBrowserDlg.h +// $Header$ #ifndef SALOMEGUI_EXTERNAL_BROWSER_DLG_H #define SALOMEGUI_EXTERNAL_BROWSER_DLG_H diff --git a/src/SALOMEGUI/SALOMEGUI_NameDlg.cxx b/src/SALOMEGUI/SALOMEGUI_NameDlg.cxx index 35d4b476f..841e42f9b 100644 --- a/src/SALOMEGUI/SALOMEGUI_NameDlg.cxx +++ b/src/SALOMEGUI/SALOMEGUI_NameDlg.cxx @@ -97,7 +97,8 @@ SALOMEGUI_NameDlg::~SALOMEGUI_NameDlg() void SALOMEGUI_NameDlg::setName( const QString& name ) { myLineEdit->setText( name ); - myLineEdit->selectAll(); + myLineEdit->end(false); + myLineEdit->home(true); } /*! @@ -108,6 +109,13 @@ QString SALOMEGUI_NameDlg::name() return myLineEdit->text(); } +void SALOMEGUI_NameDlg::accept() +{ + if ( name().stripWhiteSpace().isEmpty() ) + return; + QDialog::accept(); +} + /*! Creates modal dialog and returns name entered [ static ] */ diff --git a/src/SALOMEGUI/SALOMEGUI_NameDlg.h b/src/SALOMEGUI/SALOMEGUI_NameDlg.h index 42ec8382d..23fa03eb2 100644 --- a/src/SALOMEGUI/SALOMEGUI_NameDlg.h +++ b/src/SALOMEGUI/SALOMEGUI_NameDlg.h @@ -34,6 +34,9 @@ public: static QString getName( QWidget* parent = 0, const QString& oldName = QString::null ); +protected slots: + void accept(); + private: QPushButton* myButtonOk; QPushButton* myButtonCancel; diff --git a/src/SALOMEGUI/SALOMEGUI_OpenWith.cxx b/src/SALOMEGUI/SALOMEGUI_OpenWith.cxx index 77cde2340..1638bdbb9 100644 --- a/src/SALOMEGUI/SALOMEGUI_OpenWith.cxx +++ b/src/SALOMEGUI/SALOMEGUI_OpenWith.cxx @@ -92,6 +92,7 @@ SALOMEGUI_OpenWith::SALOMEGUI_OpenWith(QWidget* parent, const char* name) connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); connect( ListComponent, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() )); + connect( ListComponent, SIGNAL( doubleClicked( QListBoxItem* ) ), this, SLOT( onDoubleClickEvent( QListBoxItem* ) )); updateButtonState(); } @@ -135,3 +136,9 @@ void SALOMEGUI_OpenWith:: updateButtonState() buttonOk->setEnabled( ListComponent->currentItem() >=0 && ListComponent->currentItem() < ListComponent->count() ) ; } + +void SALOMEGUI_OpenWith::onDoubleClickEvent( QListBoxItem* item ) +{ + if ( item ) + accept(); +} diff --git a/src/SALOMEGUI/SALOMEGUI_OpenWith.h b/src/SALOMEGUI/SALOMEGUI_OpenWith.h index 961dcb8d4..b71ac6e08 100644 --- a/src/SALOMEGUI/SALOMEGUI_OpenWith.h +++ b/src/SALOMEGUI/SALOMEGUI_OpenWith.h @@ -32,6 +32,7 @@ #include class QListBox; +class QListBoxItem; class QCheckBox; class QPushButton; @@ -49,10 +50,11 @@ public: protected slots: void onSelectionChanged(); + void onDoubleClickEvent( QListBoxItem* item ); protected: void updateButtonState(); - + protected: QListBox* ListComponent; QCheckBox* AllwaysCheckBox; diff --git a/src/SALOMEGUI/SALOMEGUI_Swig.cxx b/src/SALOMEGUI/SALOMEGUI_Swig.cxx index 7103d349a..00f6efb08 100644 --- a/src/SALOMEGUI/SALOMEGUI_Swig.cxx +++ b/src/SALOMEGUI/SALOMEGUI_Swig.cxx @@ -374,7 +374,7 @@ bool SALOMEGUI_Swig::IsInCurrentView(const char *Entry) if ((viewId >=0) && (viewId getStudyFrame(viewId)->getRightFrame()->getViewFrame()->getRenderer(); } - if (myRenderer == NULL) INFOS("No VTK Renderer available !"); + if (myRenderer == NULL) MESSAGE("No VTK Renderer available !"); return myRenderer; } */ diff --git a/src/SALOMEGUI/SALOMEGUI_msg_en.po b/src/SALOMEGUI/SALOMEGUI_msg_en.po index 311b6075f..e050c3f4b 100644 --- a/src/SALOMEGUI/SALOMEGUI_msg_en.po +++ b/src/SALOMEGUI/SALOMEGUI_msg_en.po @@ -646,9 +646,15 @@ msgid "MEN_PLOT2D_SETTINGS" msgstr "&Settings" msgid "PRP_PLOT2D_SETTINGS" msgstr "Setups view properties" +msgid "TOT_PLOT2D_CHANGE_BACKGROUND" +msgstr "Change background" +msgid "MEN_PLOT2D_CHANGE_BACKGROUND" +msgstr "Change background..." +msgid "PRP_PLOT2D_CHANGE_BACKGROUND" +msgstr "Change background color" msgid "INF_COORDINATES" -msgstr "Coordinates" +msgstr "Coordinates: X : %1, Y : %2" msgid "SALOMEGUI_SetupCurveDlg::TLT_SETUP_CURVE" msgstr "Setup Curve" @@ -694,7 +700,7 @@ msgid "SALOMEGUI_ActivateComponentDlg::CANCEL" msgstr "&Cancel" msgid "SALOMEGUI_ActivateComponentDlg::ActivateComponent_DESCRIPTION" -msgstr "You need to create, open or load study before." +msgstr "Create, open or load study." msgid "SALOMEGUI_HELP_TITLE" msgstr "SALOME Help" diff --git a/src/SALOMEGUI/SALOME_ListIO.hxx b/src/SALOMEGUI/SALOME_ListIO.hxx index 861a7ac63..e028e243f 100644 --- a/src/SALOMEGUI/SALOME_ListIO.hxx +++ b/src/SALOMEGUI/SALOME_ListIO.hxx @@ -90,8 +90,10 @@ Standard_EXPORT void Clear() ; Standard_EXPORT Standard_Boolean IsEmpty() const; Standard_EXPORT void Prepend(const Handle(SALOME_InteractiveObject)& I) ; Standard_EXPORT void Prepend(SALOME_ListIO& Other) ; +Standard_EXPORT void Prepend(const Handle(SALOME_InteractiveObject)& I, SALOME_ListIteratorOfListIO& It) ; Standard_EXPORT void Append(const Handle(SALOME_InteractiveObject)& I) ; Standard_EXPORT void Append(SALOME_ListIO& Other) ; +Standard_EXPORT void Append(const Handle(SALOME_InteractiveObject)& I, SALOME_ListIteratorOfListIO& It) ; Standard_EXPORT Handle_SALOME_InteractiveObject& First() const; Standard_EXPORT Handle_SALOME_InteractiveObject& Last() const; Standard_EXPORT void RemoveFirst() ; diff --git a/src/SALOMEGUI/SALOME_ListOfFilter.hxx b/src/SALOMEGUI/SALOME_ListOfFilter.hxx index 7b4b9c2ac..1024a2159 100644 --- a/src/SALOMEGUI/SALOME_ListOfFilter.hxx +++ b/src/SALOMEGUI/SALOME_ListOfFilter.hxx @@ -94,8 +94,10 @@ Standard_EXPORT void Clear() ; Standard_EXPORT inline Standard_Boolean IsEmpty() const; Standard_EXPORT void Prepend(const Handle(SALOME_Filter)& I) ; Standard_EXPORT void Prepend(SALOME_ListOfFilter& Other) ; +Standard_EXPORT void Prepend(const Handle(SALOME_Filter)& I, SALOME_ListIteratorOfListOfFilter& It) ; Standard_EXPORT void 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 Handle_SALOME_Filter& First() const; Standard_EXPORT Handle_SALOME_Filter& Last() const; Standard_EXPORT void RemoveFirst() ; diff --git a/src/SALOMEGUI/SALOME_Selection.cxx b/src/SALOMEGUI/SALOME_Selection.cxx index 3e79a6c6d..21fa00996 100644 --- a/src/SALOMEGUI/SALOME_Selection.cxx +++ b/src/SALOMEGUI/SALOME_Selection.cxx @@ -41,6 +41,8 @@ using namespace std; #include "QAD_Desktop.h" #include "utilities.h" +#include + static QList& SALOME_Sel_GetSelections() { static QList Selections; @@ -59,7 +61,7 @@ SALOME_Selection::SALOME_Selection(const QString& aName) : { myFilters.Clear(); myIObjects.Clear(); - mySelectionMode = 4; /*Actor*/ + mySelectionMode = ActorSelection; /*4*/ mySelActiveCompOnly = false; QAD_Desktop* aDesktop = QAD_Application::getDesktop(); @@ -328,13 +330,13 @@ bool SALOME_Selection::IsOk(const Handle(SALOME_InteractiveObject)& anObj) return true; } -void SALOME_Selection::SetSelectionMode(int mode, bool activeCompOnly) +void SALOME_Selection::SetSelectionMode(Selection_Mode mode, bool activeCompOnly) { mySelectionMode = mode; mySelActiveCompOnly = activeCompOnly; } -int SALOME_Selection::SelectionMode() +Selection_Mode SALOME_Selection::SelectionMode() { return mySelectionMode; } @@ -378,7 +380,7 @@ bool SALOME_Selection::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& bool modeShift, bool update) { - MESSAGE ( " SALOME_Selection::AddOrRemoveIndex " << index << " - " << modeShift ) + MESSAGE ( " SALOME_Selection::AddOrRemoveIndex " << index << " - " << modeShift ); QAD_Desktop* myDesktop = (QAD_Desktop*) QAD_Application::getDesktop(); QAD_Study* myActiveStudy = myDesktop->getActiveStudy(); @@ -412,6 +414,86 @@ bool SALOME_Selection::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& return false; } +bool SALOME_Selection::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, + const TColStd_MapOfInteger& theIndices, + bool modeShift, + bool update) +{ + QAD_Desktop* myDesktop = (QAD_Desktop*) QAD_Application::getDesktop(); + QAD_Study* myActiveStudy = myDesktop->getActiveStudy(); + + if ( !myMapIOSubIndex.IsBound( IObject ) ) { + TColStd_MapOfInteger Empty; + myMapIOSubIndex.Bind( IObject, Empty ); + } + TColStd_MapOfInteger& MapIndex = myMapIOSubIndex.ChangeFind( IObject ); + TColStd_MapIteratorOfMapOfInteger It; + It.Initialize(theIndices); + + bool add = true; + + if (MapIndex.Contains(It.Key())) + { + if (!modeShift) return add; + add = false; + } + else if (!modeShift) + MapIndex.Clear(); + + if (add) + for(;It.More();It.Next()) + MapIndex.Add(It.Key()); + else + for(;It.More();It.Next()) + MapIndex.Remove(It.Key()); + + + myActiveStudy->highlight( IObject, true, update ); + if ( MapIndex.IsEmpty() ) myMapIOSubIndex.UnBind( IObject ); + emit currentSelectionChanged(); + + return add; +} + +bool SALOME_Selection::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, + const std::vector& theIndices, + bool modeShift, + bool update) +{ + QAD_Desktop* myDesktop = (QAD_Desktop*) QAD_Application::getDesktop(); + QAD_Study* myActiveStudy = myDesktop->getActiveStudy(); + + if ( !myMapIOSubIndex.IsBound( IObject ) ) { + TColStd_MapOfInteger Empty; + myMapIOSubIndex.Bind( IObject, Empty ); + } + TColStd_MapOfInteger& MapIndex = myMapIOSubIndex.ChangeFind( IObject ); + + bool add = true; + + if (MapIndex.Contains(theIndices[0])) + { + if (!modeShift) return add; + add = false; + } + else if (!modeShift) + MapIndex.Clear(); + + if (add) + for (int i=0; ihighlight( IObject, true, update ); + if ( MapIndex.IsEmpty() ) + myMapIOSubIndex.UnBind( IObject ); + emit currentSelectionChanged(); + + return add; +} + void SALOME_Selection::RemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, int index ) { if ( myMapIOSubIndex.IsBound( IObject ) ) { diff --git a/src/SALOMEGUI/SALOME_Selection.h b/src/SALOMEGUI/SALOME_Selection.h index 6c0eca8a6..0058a1984 100644 --- a/src/SALOMEGUI/SALOME_Selection.h +++ b/src/SALOMEGUI/SALOME_Selection.h @@ -43,11 +43,23 @@ // Open CASCADE Include #include +#include + +enum Selection_Mode { + NodeSelection, + CellSelection, + EdgeOfCellSelection, + EdgeSelection, + FaceSelection, + VolumeSelection, + ActorSelection }; + class SALOME_Selection : public QObject { Q_OBJECT public: + SALOME_Selection(const QString& aName); ~SALOME_Selection(); @@ -78,8 +90,8 @@ public: bool IsOk( const Handle(SALOME_InteractiveObject)& IObject ) ; - void SetSelectionMode(int mode, bool activeCompOnly = false); - int SelectionMode(); + void SetSelectionMode(Selection_Mode mode, bool activeCompOnly = false); + Selection_Mode SelectionMode(); bool IsSelectActiveCompOnly() const; bool HasIndex( const Handle(SALOME_InteractiveObject)& IObject ); @@ -87,6 +99,8 @@ public: TColStd_MapOfInteger& theIndex ); bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, int index, bool modeShift, bool update=true ); + bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, const TColStd_MapOfInteger& theIndices, bool modeShift, bool update=true ); + bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, const std::vector& theIndices, bool modeShift, bool update=true ); void RemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, int index ); bool IsIndexSelected(const Handle(SALOME_InteractiveObject)& IObject, int index); @@ -100,7 +114,7 @@ private: SALOME_DataMapOfIOMapOfInteger myMapIOSubIndex; - int mySelectionMode; + Selection_Mode mySelectionMode; bool mySelActiveCompOnly; }; diff --git a/src/SALOME_PY/SalomePy.cxx b/src/SALOME_PY/SalomePy.cxx index 494692324..017c54647 100644 --- a/src/SALOME_PY/SalomePy.cxx +++ b/src/SALOME_PY/SalomePy.cxx @@ -125,7 +125,7 @@ void initlibSalomePy() if ((viewId >=0) && (viewId getStudyFrame(viewId)->getRightFrame()->getViewFrame())->getRenderer(); } - if (renderer == NULL) INFOS("No VTK Renderer available !"); + if (renderer == NULL) MESSAGE("No VTK Renderer available !"); //san:T3.13 - move getRenderer() implementation here MESSAGE("---"); diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUI.cxx b/src/SALOME_PYQT/SALOME_PYQT_GUI.cxx index 6d6e6b92a..dc3ff8b41 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUI.cxx +++ b/src/SALOME_PYQT/SALOME_PYQT_GUI.cxx @@ -90,7 +90,7 @@ static void initInterp(int StudyID) module=PyImport_ImportModule((char*)_moduleName.c_str()); if(module == NULL) { - INFOS ( " Problem... " ); + MESSAGE ( " Problem... " ); PyErr_Print(); interp->quit(); return; diff --git a/src/SALOME_SWIG/batchmode_salome.py b/src/SALOME_SWIG/batchmode_salome.py index 463aff9be..a6a7753ed 100644 --- a/src/SALOME_SWIG/batchmode_salome.py +++ b/src/SALOME_SWIG/batchmode_salome.py @@ -57,14 +57,30 @@ class SalomeGUI(SALOMEGUI_Swig): #-------------------------------------------------------------------------- def IDToObject(id): + myObj = None mySO = myStudy.FindObjectID(id); - print id - Builder = myStudy.NewBuilder() - anAttr = Builder.FindOrCreateAttribute(mySO, "AttributeIOR") - AtIOR = anAttr._narrow(SALOMEDS.AttributeIOR) - myObj = orb.string_to_object(AtIOR.Value()) + if mySO is not None: + ok, anAttr = mySO.FindAttribute("AttributeIOR") + if ok: + AtIOR = anAttr._narrow(SALOMEDS.AttributeIOR) + if AtIOR.Value() != "": + myObj = orb.string_to_object(AtIOR.Value()) return myObj +def ObjectToSObject(obj): + mySO = None + if obj is not None: + ior = orb.object_to_string(obj) + if ior != "": + mySO = myStudy.FindObjectIOR(ior) + return mySO + +def ObjectToID(obj): + mySO = ObjectToSObject(obj) + if mySO: + return mySO.GetID() + return "" + def IDToSObject(id): mySO = myStudy.FindObjectID(id); return mySO diff --git a/src/SALOME_SWIG/salome.py b/src/SALOME_SWIG/salome.py index 92a99f11f..9d45865db 100644 --- a/src/SALOME_SWIG/salome.py +++ b/src/SALOME_SWIG/salome.py @@ -99,13 +99,30 @@ class SalomeGUI(SALOMEGUI_Swig): #-------------------------------------------------------------------------- def IDToObject(id): + myObj = None mySO = myStudy.FindObjectID(id); - Builder = myStudy.NewBuilder() - anAttr = Builder.FindOrCreateAttribute(mySO, "AttributeIOR") - AtIOR = anAttr._narrow(SALOMEDS.AttributeIOR) - myObj = orb.string_to_object(AtIOR.Value()) + if mySO is not None: + ok, anAttr = mySO.FindAttribute("AttributeIOR") + if ok: + AtIOR = anAttr._narrow(SALOMEDS.AttributeIOR) + if AtIOR.Value() != "": + myObj = orb.string_to_object(AtIOR.Value()) return myObj +def ObjectToSObject(obj): + mySO = None + if obj is not None: + ior = orb.object_to_string(obj) + if ior != "": + mySO = myStudy.FindObjectIOR(ior) + return mySO + +def ObjectToID(obj): + mySO = ObjectToSObject(obj) + if mySO: + return mySO.GetID() + return "" + def IDToSObject(id): mySO = myStudy.FindObjectID(id); return mySO diff --git a/src/SALOME_SWIG/salome_test.py b/src/SALOME_SWIG/salome_test.py index 31b7f308f..6fa96a9f7 100644 --- a/src/SALOME_SWIG/salome_test.py +++ b/src/SALOME_SWIG/salome_test.py @@ -59,6 +59,8 @@ print print "============= Test SMESH =============================" print +import StdMeshers + comp = catalog.GetComponent("SMESH") if comp is None: raise RuntimeError,"Component SMESH not found in Module Catalog." @@ -68,11 +70,11 @@ if comp is None: raise RuntimeError,"Component MED not found in Module Catalog." import SMESH -import smeshpy geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") myBuilder = salome.myStudy.NewBuilder() +smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") smeshgui = salome.ImportComponentGUI("SMESH") smeshgui.Init(salome.myStudyId); @@ -113,138 +115,107 @@ name = geompy.SubShapeName( edge._get_Name(), face._get_Name() ) print name idedge=geompy.addToStudyInFather(face,edge,name) -# ---- launch SMESH, init a Mesh with the box -gen=smeshpy.smeshpy() -mesh=gen.Init(idbox) -idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) ) -smeshgui.SetName(idmesh, "Meshbox"); -smeshgui.SetShape(idbox, idmesh); +# ---- SMESH # ---- create Hypothesis print "-------------------------- create Hypothesis" print "-------------------------- LocalLength" -hyp1=gen.CreateHypothesis("LocalLength") -hypLen1 = hyp1._narrow(SMESH.SMESH_LocalLength) +hypLen1 = smesh.CreateHypothesis( "LocalLength", "libStdMeshersEngine.so" ) hypLen1.SetLength(100) print hypLen1.GetName() print hypLen1.GetId() print hypLen1.GetLength() -idlength = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypLen1) ); -smeshgui.SetName(idlength, "Local_Length_100"); +smeshgui.SetName(salome.ObjectToID(hypLen1), "Local_Length_100") print "-------------------------- NumberOfSegments" -hyp2=gen.CreateHypothesis("NumberOfSegments") -hypNbSeg1=hyp2._narrow(SMESH.SMESH_NumberOfSegments) +hypNbSeg1= smesh.CreateHypothesis( "NumberOfSegments", "libStdMeshersEngine.so" ) hypNbSeg1.SetNumberOfSegments(7) print hypNbSeg1.GetName() print hypNbSeg1.GetId() print hypNbSeg1.GetNumberOfSegments() -idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg1) ); -smeshgui.SetName(idseg, "NumberOfSegments_7"); +smeshgui.SetName(salome.ObjectToID(hypNbSeg1), "NumberOfSegments_7") print "-------------------------- MaxElementArea" -hyp3=gen.CreateHypothesis("MaxElementArea") -hypArea1=hyp3._narrow(SMESH.SMESH_MaxElementArea) +hypArea1 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" ) hypArea1.SetMaxElementArea(2500) print hypArea1.GetName() print hypArea1.GetId() print hypArea1.GetMaxElementArea() -idarea1 = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea1) ); -smeshgui.SetName(idarea1, "MaxElementArea_2500"); +smeshgui.SetName(salome.ObjectToID(hypArea1), "MaxElementArea_2500") print "-------------------------- MaxElementArea" -hyp3=gen.CreateHypothesis("MaxElementArea") -hypArea2=hyp3._narrow(SMESH.SMESH_MaxElementArea) +hypArea2 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" ) hypArea2.SetMaxElementArea(500) print hypArea2.GetName() print hypArea2.GetId() print hypArea2.GetMaxElementArea() -idarea2 = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea2) ); -smeshgui.SetName(idarea2, "MaxElementArea_500"); +smeshgui.SetName(salome.ObjectToID(hypArea2), "MaxElementArea_500") print "-------------------------- Regular_1D" -alg1=gen.CreateHypothesis("Regular_1D") -algo1=alg1._narrow(SMESH.SMESH_Algo) -listHyp=algo1.GetCompatibleHypothesis() +algoReg = smesh.CreateHypothesis( "Regular_1D", "libStdMeshersEngine.so" ) +listHyp=algoReg.GetCompatibleHypothesis() for hyp in listHyp: print hyp -algoReg=alg1._narrow(SMESH.SMESH_Regular_1D) print algoReg.GetName() print algoReg.GetId() -idreg = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(algoReg) ); -smeshgui.SetName(idreg, "Regular_1D"); +smeshgui.SetName(salome.ObjectToID(algoReg), "Regular_1D" ) print "-------------------------- MEFISTO_2D" -alg2=gen.CreateHypothesis("MEFISTO_2D") -algo2=alg2._narrow(SMESH.SMESH_Algo) -listHyp=algo2.GetCompatibleHypothesis() +algoMef = smesh.CreateHypothesis( "MEFISTO_2D", "libStdMeshersEngine.so" ) +listHyp=algoMef.GetCompatibleHypothesis() for hyp in listHyp: print hyp -algoMef=alg2._narrow(SMESH.SMESH_MEFISTO_2D) print algoMef.GetName() print algoMef.GetId() -idmef = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(algoMef) ); -smeshgui.SetName(idmef, "MEFISTO_2D"); +smeshgui.SetName(salome.ObjectToID(algoMef), "MEFISTO_2D" ) + +# ---- add hypothesis to box + +print "-------------------------- add hypothesis to box" +box=salome.IDToObject(idbox) +mesh = smesh.CreateMesh(box) + +smeshgui.SetName( salome.ObjectToID(mesh), "MeshBox" ); + +ret=mesh.AddHypothesis(box,algoReg) +print ret +ret=mesh.AddHypothesis(box,algoMef) +print ret + + +ret=mesh.AddHypothesis(box,hypNbSeg1) +print ret +ret=mesh.AddHypothesis(box,hypArea1) +print ret + # ---- add hypothesis to edge print "-------------------------- add hypothesis to edge" edge=salome.IDToObject(idedge) -submesh=mesh.GetElementsOnShape(edge) +submesh=mesh.GetSubMesh(edge, "SubMeshEdge") + ret=mesh.AddHypothesis(edge,algoReg) print ret ret=mesh.AddHypothesis(edge,hypLen1) print ret -idsm1 = smeshgui.AddSubMeshOnShape( idmesh, - idedge, - salome.orb.object_to_string(submesh), - ShapeTypeEdge ) -smeshgui.SetName(idsm1, "SubMeshEdge") -smeshgui.SetAlgorithms( idsm1, idreg ); -smeshgui.SetHypothesis( idsm1, idlength ); - print "-------------------------- add hypothesis to face" face=salome.IDToObject(idface) -submesh=mesh.GetElementsOnShape(face) -ret=mesh.AddHypothesis(face,hypArea2) -print ret - -idsm2 = smeshgui.AddSubMeshOnShape( idmesh, - idface, - salome.orb.object_to_string(submesh), - ShapeTypeFace ) -smeshgui.SetName(idsm2, "SubMeshFace") -smeshgui.SetHypothesis( idsm2, idarea2 ); +submesh = mesh.GetSubMesh(face, "SubMeshFace") -# ---- add hypothesis to box - -print "-------------------------- add hypothesis to box" -box=salome.IDToObject(idbox) -submesh=mesh.GetElementsOnShape(box) -ret=mesh.AddHypothesis(box,algoReg) -print ret -ret=mesh.AddHypothesis(box,hypNbSeg1) -print ret -ret=mesh.AddHypothesis(box,algoMef) -print ret -ret=mesh.AddHypothesis(box,hypArea1) +ret=mesh.AddHypothesis(face,hypArea2) print ret -smeshgui.SetAlgorithms( idmesh, idreg ); -smeshgui.SetHypothesis( idmesh, idseg ); -smeshgui.SetAlgorithms( idmesh, idmef ); -smeshgui.SetHypothesis( idmesh, idarea1 ); - -gen.Compute(mesh, idbox) +smesh.Compute(mesh, box) sg.updateObjBrowser(1); print @@ -460,8 +431,8 @@ import VISU import visu_gui -medFile = "pointe.med" -medFile = os.getenv('KERNEL_ROOT_DIR') + '/examples/' + medFile +medFileName = "pointe.med" +medFile = os.getenv('KERNEL_ROOT_DIR') + '/examples/' + medFileName print "Load ", medFile studyCurrent = salome.myStudyName @@ -473,10 +444,11 @@ try: if os.access(medFile, os.R_OK) : if not os.access(medFile, os.W_OK) : import random - medFileNew = "/tmp/" + str(random.randint(0,1000000)) + "_" + medfile + medFileNew = "/tmp/" + str(random.randint(0,1000000)) + "_" + medFileName print " -- Copy " + medFile + " to " + medFileNew os.system("cp "+ medFile + " " + medFileNew) medFile = medFileNew + os.system("chmod 755 " + medFile) if os.access(medFile, os.W_OK) : med_comp.readStructFileWithFieldType(medFile,studyCurrent) diff --git a/src/SUPERVGraph/SUPERVGraph_ViewFrame.cxx b/src/SUPERVGraph/SUPERVGraph_ViewFrame.cxx index 01fa60ce2..7a73fff3e 100644 --- a/src/SUPERVGraph/SUPERVGraph_ViewFrame.cxx +++ b/src/SUPERVGraph/SUPERVGraph_ViewFrame.cxx @@ -249,7 +249,7 @@ QColor SUPERVGraph_ViewFrame::backgroundColor() const } -void SUPERVGraph_ViewFrame::SetSelectionMode( int mode ) +void SUPERVGraph_ViewFrame::SetSelectionMode( Selection_Mode mode ) { MESSAGE ( "SUPERVGraph_ViewFrame::SetSelectionMode" ) } diff --git a/src/SUPERVGraph/SUPERVGraph_ViewFrame.h b/src/SUPERVGraph/SUPERVGraph_ViewFrame.h index 8c62cc436..42aeafdf3 100644 --- a/src/SUPERVGraph/SUPERVGraph_ViewFrame.h +++ b/src/SUPERVGraph/SUPERVGraph_ViewFrame.h @@ -34,6 +34,7 @@ #include "QAD_Application.h" #include "SALOME_InteractiveObject.hxx" +#include "SALOME_Selection.h" class QAD_EXPORT SUPERVGraph_View: public QWidget, public QAD_PopupClientServer{ Q_OBJECT; @@ -62,7 +63,7 @@ class QAD_EXPORT SUPERVGraph_ViewFrame : public QAD_ViewFrame { void setBackgroundColor( const QColor& ); QColor backgroundColor() const; - void SetSelectionMode( int mode ); + void SetSelectionMode( Selection_Mode mode ); void onAdjustTrihedron( ); diff --git a/src/Session/SALOME_Session_QThread.cxx b/src/Session/SALOME_Session_QThread.cxx index 8531be10f..9229ba274 100644 --- a/src/Session/SALOME_Session_QThread.cxx +++ b/src/Session/SALOME_Session_QThread.cxx @@ -44,7 +44,8 @@ using namespace std; #include "QAD_ResourceMgr.h" #include - +#include "Utils_CatchSignals.h" +#include "Utils_CorbaException.hxx" #include #include CORBA_SERVER_HEADER(SALOMEDS) @@ -63,24 +64,24 @@ SALOME_Session_QThread::SALOME_Session_QThread(int argc, char ** argv) : QThread _NS = 0 ; } ; + //============================================================================= /*! run * Creates one QApplication for the all the session life. * Executes the Qt main window of the GUI on a separate thread */ //============================================================================= - void SALOME_Session_QThread::run() { if (_qappl == 0) { _qappl = new QApplication(_argc, _argv ); - INFOS("creation QApplication"); + MESSAGE("creation QApplication"); } QAD_ASSERT ( QObject::connect(_qappl, SIGNAL(lastWindowClosed()), _qappl, SLOT(quit()) ) ); _mw = new SALOMEGUI_Application ( "MDTV-Standard", "HDF", "hdf" ); - INFOS("creation SALOMEGUI_Application"); + MESSAGE("creation SALOMEGUI_Application"); if ( !SALOMEGUI_Application::addToDesktop ( _mw, _NS ) ) { @@ -100,26 +101,59 @@ void SALOME_Session_QThread::run() _qappl->setPalette( QAD_Application::getPalette() ); + Utils_CatchSignals aCatch; + aCatch.Activate(); + /* Run 'SALOMEGUI' application */ QAD_Application::run(); - + // T2.12 - catch exceptions thrown on attempts to modified a locked study while (1) { try { - MESSAGE("run(): starting the main event loop") + MESSAGE("run(): starting the main event loop"); _ret = _qappl->exec(); break; } + catch (SALOME::SALOME_Exception& e) { + INFOS("run(): SALOME::SALOME_Exception is caught"); + QApplication::restoreOverrideCursor(); + QAD_MessageBox::error1 ( (QWidget*)QAD_Application::getDesktop(), + QObject::tr("ERR_ERROR"), + QObject::tr("ERR_APP_EXCEPTION")+ QObject::tr(" SALOME::SALOME_Exception is caught") , + QObject::tr("BUT_OK") ); + + } catch(SALOMEDS::StudyBuilder::LockProtection&) { - MESSAGE("run(): An attempt to modify a locked study has not been handled by QAD_Operation") + INFOS("run(): An attempt to modify a locked study has not been handled by QAD_Operation"); QApplication::restoreOverrideCursor(); QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(), - QObject::tr("WRN_WARNING"), - QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK") ); + } + catch (const CORBA::Exception& e) { + CORBA::Any tmp; + tmp<<= e; + CORBA::TypeCode_var tc = tmp.type(); + const char *p = tc->name(); + INFOS ("run(): CORBA exception of the kind : "<createConfigFile(true); diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 2b00367c2..5294abd94 100644 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -103,7 +103,7 @@ int main(int argc, char **argv) } catch( CORBA::COMM_FAILURE& ) { - MESSAGE( "Session Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); + INFOS( "Session Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); } if(!CORBA::is_nil(inc)) { @@ -119,11 +119,11 @@ int main(int argc, char **argv) object = inc->resolve(name); } catch(CosNaming::NamingContext::NotFound) - { MESSAGE( "Session Server: Logger Server wasn't found" ); + { INFOS( "Session Server: Logger Server wasn't found" ); } catch(...) { - MESSAGE( "Session Server: Unknown exception" ); + INFOS( "Session Server: Unknown exception" ); } if (!CORBA::is_nil(object)) { diff --git a/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx b/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx index 5c774aa8e..557ca8fb1 100644 --- a/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx +++ b/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx @@ -123,8 +123,6 @@ ToolsGUI_CatalogGeneratorDlg::ToolsGUI_CatalogGeneratorDlg( QWidget* parent, con myVersionEdit->setMinimumSize( myMinimumSize ); QStringList aList = QStringList::split(QRegExp("\\s+"),tr( "INF_VERSION" )); myVersionEdit->setText(aList.last()); - QDoubleValidator *validator = new QDoubleValidator(myVersionEdit); - myVersionEdit->setValidator(validator); myPngEdit = new QLineEdit(supplGrp , "myCompIcon" ); myPngEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); diff --git a/src/TestContainer/TestContainer.cxx b/src/TestContainer/TestContainer.cxx index d1f1c35bb..d80c8f924 100644 --- a/src/TestContainer/TestContainer.cxx +++ b/src/TestContainer/TestContainer.cxx @@ -98,7 +98,7 @@ int main (int argc, char * argv[]) } catch( CORBA::COMM_FAILURE& ) { - MESSAGE( "Test Container: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ) + INFOS( "Test Container: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ) } if(!CORBA::is_nil(inc)) { @@ -115,11 +115,11 @@ int main (int argc, char * argv[]) } catch(CosNaming::NamingContext::NotFound) { - MESSAGE( "Test Container: Logger Server wasn't found" ); + INFOS( "Test Container: Logger Server wasn't found" ); } catch(...) { - MESSAGE( "Test Container: Unknown exception" ); + INFOS( "Test Container: Unknown exception" ); } if (!CORBA::is_nil(object)) { @@ -147,14 +147,14 @@ int main (int argc, char * argv[]) for (int iter = 0; iter < 3 ; iter++) { - INFOS("----------------------------------------------------" << iter); - string dirn = getenv("SALOME_ROOT_DIR"); + MESSAGE("----------------------------------------------------" << iter); + string dirn = getenv("KERNEL_ROOT_DIR"); dirn += "/lib/salome/libSalomeTestComponentEngine.so"; obj = iGenFact->load_impl("SalomeTestComponent",dirn.c_str()); m1 = Engines::TestComponent::_narrow(obj); - INFOS("recup m1"); + MESSAGE("recup m1"); SCRUTE(m1->instanceName()); - INFOS("Coucou " << m1->Coucou(1L)); + MESSAGE("Coucou " << m1->Coucou(1L)); iGenFact->remove_impl(m1) ; //iGenFact->finalize_removal() ; // unpredictable results ... sleep(5); diff --git a/src/TestContainer/TestLogger.cxx b/src/TestContainer/TestLogger.cxx index a844dc7a7..8b73720de 100644 --- a/src/TestContainer/TestLogger.cxx +++ b/src/TestContainer/TestLogger.cxx @@ -36,7 +36,7 @@ using namespace std; int main (int argc, char * argv[]) { - INFOS("It's OK"); + MESSAGE("It's OK"); return 0; } diff --git a/src/Utils/Makefile.in b/src/Utils/Makefile.in index 86ebc70ef..fbbd1527f 100644 --- a/src/Utils/Makefile.in +++ b/src/Utils/Makefile.in @@ -45,7 +45,9 @@ EXPORT_HEADERS= \ Utils_ORB_INIT.hxx \ Utils_Identity.hxx \ Utils_SINGLETON.hxx \ - Utils_DESTRUCTEUR_GENERIQUE.hxx + Utils_DESTRUCTEUR_GENERIQUE.hxx \ + Utils_ExceptHandlers.hxx \ + Utils_CatchSignals.h EXPORT_PYSCRIPTS = Utils_Identity.py SALOME_utilities.py # Libraries targets @@ -55,9 +57,13 @@ LIB_SRC = OpUtil.cxx Utils_Timer.cxx duplicate.cxx \ Utils_CommException.cxx \ Utils_SALOME_Exception.cxx \ Utils_Identity.cxx Utils_ORB_INIT.cxx \ - Utils_DESTRUCTEUR_GENERIQUE.cxx + Utils_DESTRUCTEUR_GENERIQUE.cxx \ + Utils_ExceptHandlers.cxx \ + Utils_CatchSignals.cxx -LDFLAGS+= +LIB_SERVER_IDL = SALOME_Exception.idl + +LDFLAGS+= -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/Utils/Utils_CorbaException.hxx b/src/Utils/Utils_CorbaException.hxx index 8bffa2d18..d785f16d1 100644 --- a/src/Utils/Utils_CorbaException.hxx +++ b/src/Utils/Utils_CorbaException.hxx @@ -45,4 +45,22 @@ throw SALOME::SALOME_Exception(ExDescription); \ } +#include +//Dump the CORBA exception type. +static ostream& operator<<(ostream& os, const CORBA::Exception& e) +{ + CORBA::Any tmp; + tmp<<= e; + CORBA::TypeCode_var tc = tmp.type(); + const char *p = tc->name(); + os<<"CORBA Exception was catch of the kind : "; + if ( *p != '\0' ) { + os<id(); + } + + return os; +} #endif diff --git a/src/Utils/Utils_ORB_INIT.cxx b/src/Utils/Utils_ORB_INIT.cxx index 0da127b34..bd8e5965f 100644 --- a/src/Utils/Utils_ORB_INIT.cxx +++ b/src/Utils/Utils_ORB_INIT.cxx @@ -49,21 +49,24 @@ ORB_INIT::~ORB_INIT() CORBA::ORB_var &ORB_INIT::operator() ( int argc , char **argv ) throw( CommException ) { - if ( CORBA::is_nil( _orb ) ) - { - try - { - // const char* options[][2] = { { "giopMaxMsgSize", "104857600" }, { 0, 0 } }; - // _orb = CORBA::ORB_init( argc , argv , "omniORB4", options) ; - _orb = CORBA::ORB_init( argc , argv ) ; - //set GIOP message size equal to 50Mb for transferring brep shapes as - //sequence of bytes using C++ streams - omniORB::MaxMessageSize(100*1024*1024); - } - catch( const CORBA::Exception &ex ) - { - throw CommException( "Unable to create an ORB connexion" ) ; - } - } - return _orb ; + try { + if ( CORBA::is_nil( _orb ) ) + { + try + { + // const char* options[][2] = { { "giopMaxMsgSize", "104857600" }, { 0, 0 } }; + // _orb = CORBA::ORB_init( argc , argv , "omniORB4", options) ; + _orb = CORBA::ORB_init( argc , argv ) ; + //set GIOP message size equal to 50Mb for transferring brep shapes as + //sequence of bytes using C++ streams + omniORB::MaxMessageSize(100*1024*1024); + } + catch( const CORBA::Exception &ex ) + { + throw CommException( "Unable to create an ORB connexion" ) ; + } + } + return _orb ; + } catch ( CommException& e) {throw e;} + catch (...) { throw CommException( "ORB_INIT::operator() : Unknown exception was caught" ) ;} } diff --git a/src/Utils/Utils_SALOME_Exception.hxx b/src/Utils/Utils_SALOME_Exception.hxx index f7e9a3a67..d368ed867 100644 --- a/src/Utils/Utils_SALOME_Exception.hxx +++ b/src/Utils/Utils_SALOME_Exception.hxx @@ -29,10 +29,11 @@ #if !defined( __Utils_SALOME_Exception_hxx__ ) #define __Utils_SALOME_Exception_hxx__ -using namespace std; # include # include +using namespace std; + # define LOCALIZED(message) #message , __FILE__ , __LINE__ class SALOME_Exception : public exception diff --git a/src/Utils/utilities.h b/src/Utils/utilities.h index 015e84e58..91a5be11c 100644 --- a/src/Utils/utilities.h +++ b/src/Utils/utilities.h @@ -37,8 +37,8 @@ /* --- INFOS is always defined (without _DEBUG_): to be used for warnings, with release version --- */ -#define INFOS(msg) {SLog.putMessage(SLog<<__FILE__<<" ["<<__LINE__<<"] : "< #include +#ifdef _DEBUG_ +static int MYDEBUG = 0; +static int MYDEBUGWITHFILES = 0; +#else +static int MYDEBUG = 0; +static int MYDEBUGWITHFILES = 0; +#endif + vtkCxxRevisionMacro(SALOME_GeometryFilter, "$Revision$"); vtkStandardNewMacro(SALOME_GeometryFilter); -SALOME_GeometryFilter::SALOME_GeometryFilter(): myShowInside(0) +SALOME_GeometryFilter::SALOME_GeometryFilter(): + myShowInside(0), + myStoreMapping(0) {} + SALOME_GeometryFilter::~SALOME_GeometryFilter() {} + void SALOME_GeometryFilter::Execute() { vtkDataSet *input= this->GetInput(); @@ -71,6 +83,26 @@ void SALOME_GeometryFilter::Execute() vtkGeometryFilter::Execute(); } + +void SALOME_GeometryFilter::SetStoreMapping(int theStoreMapping){ + myStoreMapping = theStoreMapping; + this->Modified(); +} + + +vtkIdType SALOME_GeometryFilter::GetObjId(int theVtkID){ + if(myVTK2ObjIds.empty() || theVtkID > myVTK2ObjIds.size()) return -1; + return myVTK2ObjIds.at(theVtkID); +} + + +SALOME_GeometryFilter::TVectorId SALOME_GeometryFilter::GetVtkId(int theObjID){ + TVectorId aVect; + if(myObj2VTKIds.empty() || theObjID > myObj2VTKIds.size()) return aVect; + return myObj2VTKIds.at(theObjID); +} + + void SALOME_GeometryFilter::UnstructuredGridExecute() { vtkUnstructuredGrid *input= (vtkUnstructuredGrid *)this->GetInput(); @@ -95,7 +127,7 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() vtkIdType newCellId; int faceId, *faceVerts, numFacePts; float *x; - int PixelConvert[4]; + int PixelConvert[4], aNewPts[VTK_CELL_SIZE]; // ghost cell stuff unsigned char updateLevel = (unsigned char)(output->GetUpdateGhostLevel()); unsigned char *cellGhostLevels = 0; @@ -150,14 +182,15 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() outputCD->CopyAllocate(cd,numCells,numCells/2); - Verts = vtkCellArray::New(); - Verts->Allocate(numCells/4+1,numCells); - Lines = vtkCellArray::New(); - Lines->Allocate(numCells/4+1,numCells); - Polys = vtkCellArray::New(); - Polys->Allocate(numCells/4+1,numCells); - Strips = vtkCellArray::New(); - Strips->Allocate(numCells/4+1,numCells); + output->Allocate(numCells/4+1,numCells); + //Verts = vtkCellArray::New(); + //Verts->Allocate(numCells/4+1,numCells); + //Lines = vtkCellArray::New(); + //Lines->Allocate(numCells/4+1,numCells); + //Polys = vtkCellArray::New(); + //Polys->Allocate(numCells/4+1,numCells); + //Strips = vtkCellArray::New(); + //Strips->Allocate(numCells/4+1,numCells); // Loop over the cells determining what's visible if (!allVisible) @@ -195,6 +228,11 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() // Loop over all cells now that visibility is known // (Have to compute visibility first for 3D cell boundarys) int progressInterval = numCells/20 + 1; + if(myStoreMapping){ + myVTK2ObjIds.clear(); myObj2VTKIds.clear(); //apo + myVTK2ObjIds.reserve(numCells); + myObj2VTKIds.resize(numCells); + } for (cellId=0, Connectivity->InitTraversal(); Connectivity->GetNextCell(npts,pts); cellId++) @@ -216,45 +254,62 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() { //special code for nonlinear cells - rarely occurs, so right now it //is slow. - switch (input->GetCellType(cellId)) + vtkIdType aCellType = input->GetCellType(cellId); + switch (aCellType) { case VTK_EMPTY_CELL: break; case VTK_VERTEX: case VTK_POLY_VERTEX: - newCellId = Verts->InsertNextCell(npts,pts); + newCellId = output->InsertNextCell(aCellType,npts,pts); + if(myStoreMapping){ + myVTK2ObjIds.push_back(cellId); //apo + myObj2VTKIds[cellId].push_back(newCellId); + } outputCD->CopyData(cd,cellId,newCellId); break; case VTK_LINE: case VTK_POLY_LINE: - newCellId = Lines->InsertNextCell(npts,pts); + newCellId = output->InsertNextCell(VTK_LINE,npts,pts); + if(myStoreMapping){ + myVTK2ObjIds.push_back(cellId); //apo + myObj2VTKIds[cellId].push_back(newCellId); + } outputCD->CopyData(cd,cellId,newCellId); break; case VTK_TRIANGLE: case VTK_QUAD: case VTK_POLYGON: - newCellId = Polys->InsertNextCell(npts,pts); + newCellId = output->InsertNextCell(aCellType,npts,pts); + if(myStoreMapping){ + myVTK2ObjIds.push_back(cellId); //apo + myObj2VTKIds[cellId].push_back(newCellId); + } outputCD->CopyData(cd,cellId,newCellId); break; case VTK_TRIANGLE_STRIP: - newCellId = Strips->InsertNextCell(npts,pts); + newCellId = output->InsertNextCell(aCellType,npts,pts); + if(myStoreMapping){ + myVTK2ObjIds.push_back(cellId); //apo + myObj2VTKIds[cellId].push_back(newCellId); + } outputCD->CopyData(cd,cellId,newCellId); break; case VTK_PIXEL: - newCellId = Polys->InsertNextCell(npts); - for ( i=0; i < npts; i++) - { - Polys->InsertCellPoint(pts[PixelConvert[i]]); - } - outputCD->CopyData(cd,cellId,newCellId); + newCellId = output->InsertNextCell(aCellType,npts,pts); + if(myStoreMapping){ + myVTK2ObjIds.push_back(cellId); //apo + myObj2VTKIds[cellId].push_back(newCellId); + } + outputCD->CopyData(cd,cellId,newCellId); break; - case VTK_TETRA: + case VTK_TETRA: { for (faceId = 0; faceId < 4; faceId++) { faceIds->Reset(); @@ -263,21 +318,26 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() faceIds->InsertNextId(pts[faceVerts[1]]); faceIds->InsertNextId(pts[faceVerts[2]]); numFacePts = 3; + aCellType = VTK_TRIANGLE; input->GetCellNeighbors(cellId, faceIds, cellIds); if ( cellIds->GetNumberOfIds() <= 0 || myShowInside == 1 || (!allVisible && !cellVis[cellIds->GetId(0)]) ) { - newCellId = Polys->InsertNextCell(numFacePts); for ( i=0; i < numFacePts; i++) { - Polys->InsertCellPoint(pts[faceVerts[i]]); + aNewPts[i] = pts[faceVerts[i]]; } + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping){ + myVTK2ObjIds.push_back(cellId); //apo + myObj2VTKIds[cellId].push_back(newCellId); + } outputCD->CopyData(cd,cellId,newCellId); } } break; - - case VTK_VOXEL: + } + case VTK_VOXEL: { for (faceId = 0; faceId < 6; faceId++) { faceIds->Reset(); @@ -287,21 +347,26 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() faceIds->InsertNextId(pts[faceVerts[2]]); faceIds->InsertNextId(pts[faceVerts[3]]); numFacePts = 4; + aCellType = VTK_QUAD; input->GetCellNeighbors(cellId, faceIds, cellIds); if ( cellIds->GetNumberOfIds() <= 0 || myShowInside == 1 || (!allVisible && !cellVis[cellIds->GetId(0)]) ) { - newCellId = Polys->InsertNextCell(numFacePts); for ( i=0; i < numFacePts; i++) { - Polys->InsertCellPoint(pts[faceVerts[PixelConvert[i]]]); + aNewPts[i] = pts[faceVerts[PixelConvert[i]]]; } + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping){ + myVTK2ObjIds.push_back(cellId); //apo + myObj2VTKIds[cellId].push_back(newCellId); + } outputCD->CopyData(cd,cellId,newCellId); } } break; - - case VTK_HEXAHEDRON: + } + case VTK_HEXAHEDRON: { for (faceId = 0; faceId < 6; faceId++) { faceIds->Reset(); @@ -311,21 +376,26 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() faceIds->InsertNextId(pts[faceVerts[2]]); faceIds->InsertNextId(pts[faceVerts[3]]); numFacePts = 4; + aCellType = VTK_QUAD; input->GetCellNeighbors(cellId, faceIds, cellIds); if ( cellIds->GetNumberOfIds() <= 0 || myShowInside == 1 || (!allVisible && !cellVis[cellIds->GetId(0)]) ) { - newCellId = Polys->InsertNextCell(numFacePts); for ( i=0; i < numFacePts; i++) { - Polys->InsertCellPoint(pts[faceVerts[i]]); + aNewPts[i] = pts[faceVerts[i]]; } + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping){ + myVTK2ObjIds.push_back(cellId); //apo + myObj2VTKIds[cellId].push_back(newCellId); + } outputCD->CopyData(cd,cellId,newCellId); } } break; - - case VTK_WEDGE: + } + case VTK_WEDGE: { for (faceId = 0; faceId < 5; faceId++) { faceIds->Reset(); @@ -334,26 +404,32 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() faceIds->InsertNextId(pts[faceVerts[1]]); faceIds->InsertNextId(pts[faceVerts[2]]); numFacePts = 3; + aCellType = VTK_TRIANGLE; if (faceVerts[3] >= 0) { faceIds->InsertNextId(pts[faceVerts[3]]); numFacePts = 4; + aCellType = VTK_QUAD; } input->GetCellNeighbors(cellId, faceIds, cellIds); if ( cellIds->GetNumberOfIds() <= 0 || myShowInside == 1 || (!allVisible && !cellVis[cellIds->GetId(0)]) ) { - newCellId = Polys->InsertNextCell(numFacePts); for ( i=0; i < numFacePts; i++) { - Polys->InsertCellPoint(pts[faceVerts[i]]); + aNewPts[i] = pts[faceVerts[i]]; } + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping){ + myVTK2ObjIds.push_back(cellId); //apo + myObj2VTKIds[cellId].push_back(newCellId); + } outputCD->CopyData(cd,cellId,newCellId); } } break; - - case VTK_PYRAMID: + } + case VTK_PYRAMID: { for (faceId = 0; faceId < 5; faceId++) { faceIds->Reset(); @@ -362,104 +438,70 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() faceIds->InsertNextId(pts[faceVerts[1]]); faceIds->InsertNextId(pts[faceVerts[2]]); numFacePts = 3; + aCellType = VTK_TRIANGLE; if (faceVerts[3] >= 0) { faceIds->InsertNextId(pts[faceVerts[3]]); numFacePts = 4; + aCellType = VTK_QUAD; } input->GetCellNeighbors(cellId, faceIds, cellIds); if ( cellIds->GetNumberOfIds() <= 0 || myShowInside == 1 || (!allVisible && !cellVis[cellIds->GetId(0)]) ) { - newCellId = Polys->InsertNextCell(numFacePts); for ( i=0; i < numFacePts; i++) { - Polys->InsertCellPoint(pts[faceVerts[i]]); + aNewPts[i] = pts[faceVerts[i]]; } + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping){ + myVTK2ObjIds.push_back(cellId); //apo + myObj2VTKIds[cellId].push_back(newCellId); + } outputCD->CopyData(cd,cellId,newCellId); } } break; - + } //Quadratic cells case VTK_QUADRATIC_EDGE: case VTK_QUADRATIC_TRIANGLE: case VTK_QUADRATIC_QUAD: case VTK_QUADRATIC_TETRA: case VTK_QUADRATIC_HEXAHEDRON: - { - vtkGenericCell *cell = vtkGenericCell::New(); - input->GetCell(cellId,cell); - vtkIdList *pts = vtkIdList::New(); - vtkPoints *coords = vtkPoints::New(); - vtkIdList *cellIds = vtkIdList::New(); - vtkIdType newCellId; - - if ( cell->GetCellDimension() == 1 ) - { - cell->Triangulate(0,pts,coords); - for (i=0; i < pts->GetNumberOfIds(); i+=2) - { - newCellId = Lines->InsertNextCell(2); - Lines->InsertCellPoint(pts->GetId(i)); - Lines->InsertCellPoint(pts->GetId(i+1)); - outputCD->CopyData(cd,cellId,newCellId); - } - } - else if ( cell->GetCellDimension() == 2 ) - { - cell->Triangulate(0,pts,coords); - for (i=0; i < pts->GetNumberOfIds(); i+=3) - { - newCellId = Lines->InsertNextCell(2); - Polys->InsertCellPoint(pts->GetId(i)); - Polys->InsertCellPoint(pts->GetId(i+1)); - Polys->InsertCellPoint(pts->GetId(i+2)); - outputCD->CopyData(cd,cellId,newCellId); - } - } - else //3D nonlinear cell - { - vtkCell *face; - for (int j=0; j < cell->GetNumberOfFaces(); j++) - { - face = cell->GetFace(j); - input->GetCellNeighbors(cellId, face->PointIds, cellIds); - if ( cellIds->GetNumberOfIds() <= 0) - { - face->Triangulate(0,pts,coords); - for (i=0; i < pts->GetNumberOfIds(); i+=3) - { - newCellId = Lines->InsertNextCell(2); - Polys->InsertCellPoint(pts->GetId(i)); - Polys->InsertCellPoint(pts->GetId(i+1)); - Polys->InsertCellPoint(pts->GetId(i+2)); - outputCD->CopyData(cd,cellId,newCellId); - } - } - } - } //3d cell - cellIds->Delete(); - coords->Delete(); - pts->Delete(); - cell->Delete(); - } + break; //done with quadratic cells } //switch } //if visible } //for all cells + if(MYDEBUG && myStoreMapping){ + for(int i = 0, iEnd = myVTK2ObjIds.size(); i < iEnd; i++){ + cout<SetVerts(Verts); - Verts->Delete(); - output->SetLines(Lines); - Lines->Delete(); - output->SetPolys(Polys); - Polys->Delete(); - output->SetStrips(Strips); - Strips->Delete(); + //output->SetVerts(Verts); + //Verts->Delete(); + //output->SetLines(Lines); + //Lines->Delete(); + //output->SetPolys(Polys); + //Polys->Delete(); + //output->SetStrips(Strips); + //Strips->Delete(); output->Squeeze(); diff --git a/src/VTKFilter/SALOME_GeometryFilter.h b/src/VTKFilter/SALOME_GeometryFilter.h index f6edf6b78..bce9d27d7 100644 --- a/src/VTKFilter/SALOME_GeometryFilter.h +++ b/src/VTKFilter/SALOME_GeometryFilter.h @@ -24,13 +24,14 @@ // File : SALOME_GeometryFilter.h // Author : Michael ZORIN // Module : SALOME -// $Header: /dn05/salome/CVS/SALOME_ROOT/SALOME/src/OBJECT/SALOME_GeometryFilter.h +// $Header$ #ifndef __SALOME_GeometryFilter_h #define __SALOME_GeometryFilter_h #include +#include class SALOME_GeometryFilter : public vtkGeometryFilter { @@ -40,6 +41,13 @@ public: void SetInside(int theShowInside); int GetInside(); + void SetStoreMapping(int theStoreMapping); + int GetStoreMapping(){ return myStoreMapping;} + + typedef std::vector TVectorId; + virtual vtkIdType GetObjId(int theVtkID); + virtual TVectorId GetVtkId(int theObjID); + protected: SALOME_GeometryFilter(); ~SALOME_GeometryFilter(); @@ -48,7 +56,12 @@ protected: void UnstructuredGridExecute(); private: - int myShowInside; + int myShowInside; + + int myStoreMapping; + TVectorId myVTK2ObjIds; + typedef std::vector TVecVectorId; + TVecVectorId myObj2VTKIds; }; #endif diff --git a/src/VTKFilter/SALOME_PassThroughFilter.cxx b/src/VTKFilter/SALOME_PassThroughFilter.cxx index 3557b6259..f1ee7c5e9 100644 --- a/src/VTKFilter/SALOME_PassThroughFilter.cxx +++ b/src/VTKFilter/SALOME_PassThroughFilter.cxx @@ -27,65 +27,31 @@ #include "SALOME_PassThroughFilter.h" -#include "SALOME_GeometryFilter.h" +#include +#include #include -#include #include -#include -#include -#include - -using namespace std; +vtkCxxRevisionMacro(SALOME_PassThroughFilter, "$Revision$"); vtkStandardNewMacro(SALOME_PassThroughFilter); -SALOME_PassThroughFilter::SALOME_PassThroughFilter(){ - this->vtkProcessObject::SetNthInput(0, NULL); - myGeomFilter = SALOME_GeometryFilter::New(); -} - -SALOME_PassThroughFilter::~SALOME_PassThroughFilter(){ - myGeomFilter->Delete(); -} - -void SALOME_PassThroughFilter::Execute(){ +void SALOME_PassThroughFilter::Execute() +{ vtkDataSet *input = static_cast(this->GetInput()); vtkDataSet *output = static_cast(this->GetOutput()); + + // This has to be here because it initialized all field datas. output->CopyStructure( input ); + + // Pass all. (data object's field data is passed by the + // superclass after this method) output->GetPointData()->PassData( input->GetPointData() ); output->GetCellData()->PassData( input->GetCellData() ); -} - -void SALOME_PassThroughFilter::SetInput(vtkDataSet *input){ - myGeomFilter->SetInput(input); - vtkDataSet *oldInput = this->GetInput(); - if(oldInput != NULL) - if(input == NULL || oldInput->GetDataObjectType() != input->GetDataObjectType()){ - vtkWarningMacro("Changing input type. Deleting output"); - this->SetOutput(NULL); - } - if (input != NULL && this->vtkSource::GetOutput(0) == NULL){ - this->vtkSource::SetNthOutput(0, input->NewInstance()); - this->Outputs[0]->ReleaseData(); - this->Outputs[0]->Delete(); - } - this->vtkProcessObject::SetNthInput(0, input); } -vtkPolyData *SALOME_PassThroughFilter::GetPolyDataOutput() { - vtkDataSet *ds = this->GetOutput(); - if(!ds) return NULL; - if(ds->GetDataObjectType() == VTK_POLY_DATA) return (vtkPolyData *)ds; - myGeomFilter->SetInput(this->GetOutput()); - return myGeomFilter->GetOutput(); -} - -void SALOME_PassThroughFilter::SetInside(int theShowInside){ - myGeomFilter->SetInside(theShowInside); - Modified(); -} -int SALOME_PassThroughFilter::GetInside(){ - return myGeomFilter->GetInside(); +void SALOME_PassThroughFilter::PrintSelf(ostream& os, vtkIndent indent) +{ + this->Superclass::PrintSelf(os,indent); } diff --git a/src/VTKFilter/SALOME_PassThroughFilter.h b/src/VTKFilter/SALOME_PassThroughFilter.h index 51e1124e5..bc625a8d3 100644 --- a/src/VTKFilter/SALOME_PassThroughFilter.h +++ b/src/VTKFilter/SALOME_PassThroughFilter.h @@ -31,27 +31,25 @@ #include -class SALOME_GeometryFilter; - -class SALOME_PassThroughFilter : public vtkDataSetToDataSetFilter{ - public: - vtkTypeMacro(SALOME_PassThroughFilter,vtkDataSetToDataSetFilter); +class SALOME_PassThroughFilter : public vtkDataSetToDataSetFilter +{ +public: + vtkTypeRevisionMacro(SALOME_PassThroughFilter,vtkDataSetToDataSetFilter); + void PrintSelf(ostream& os, vtkIndent indent); + + // Description: + // Create a new SALOME_PassThroughFilter. static SALOME_PassThroughFilter *New(); - void SetInput(vtkDataSet *input); - vtkPolyData *GetPolyDataOutput(); - void SetInside(int theShowInside); - int GetInside(); +protected: - protected: - SALOME_PassThroughFilter(); - virtual ~SALOME_PassThroughFilter(); - void Execute(); + SALOME_PassThroughFilter() {}; + virtual ~SALOME_PassThroughFilter() {}; - SALOME_GeometryFilter* myGeomFilter; + void Execute(); - private: +private: SALOME_PassThroughFilter(const SALOME_PassThroughFilter&); // Not implemented. void operator=(const SALOME_PassThroughFilter&); // Not implemented. }; diff --git a/src/VTKViewer/Makefile.in b/src/VTKViewer/Makefile.in index 0733c58b9..40ca16b52 100644 --- a/src/VTKViewer/Makefile.in +++ b/src/VTKViewer/Makefile.in @@ -38,7 +38,8 @@ VPATH=.:@srcdir@:$(top_builddir)/inc:$(top_builddir)/idl EXPORT_HEADERS= VTKViewer_RenderWindow.h \ VTKViewer_ViewFrame.h \ VTKViewer_RenderWindowInteractor.h \ - VTKViewer_InteractorStyleSALOME.h + VTKViewer_InteractorStyleSALOME.h \ + VTKViewer_Filter.h # Libraries targets LIB = libVTKViewer.la @@ -49,7 +50,10 @@ LIB_SRC= VTKViewer.cxx \ VTKViewer_InteractorStyleSALOME.cxx \ VTKViewer_Trihedron.cxx \ VTKViewer_VectorText.cxx \ - VTKViewer_Utilities.cxx + VTKViewer_RectPicker.cxx \ + VTKViewer_CellRectPicker.cxx \ + VTKViewer_Utilities.cxx \ + VTKViewer_Filter.cxx LIB_MOC = \ VTKViewer.h \ diff --git a/src/VTKViewer/VTKViewer_InteractorStyleSALOME.cxx b/src/VTKViewer/VTKViewer_InteractorStyleSALOME.cxx index 329e055ac..8e6319976 100644 --- a/src/VTKViewer/VTKViewer_InteractorStyleSALOME.cxx +++ b/src/VTKViewer/VTKViewer_InteractorStyleSALOME.cxx @@ -27,9 +27,12 @@ // $Header$ #include "VTKViewer_InteractorStyleSALOME.h" +#include "VTKViewer_RenderWindowInteractor.h" #include "VTKViewer_RenderWindow.h" #include "VTKViewer_Utilities.h" #include "VTKViewer_Trihedron.h" +#include "VTKViewer_RectPicker.h" +#include "VTKViewer_CellRectPicker.h" #include "QAD_Config.h" #include "QAD_Application.h" @@ -52,7 +55,6 @@ #include #include #include -#include #include //VRV: porting on Qt 3.0.5 @@ -61,6 +63,8 @@ #endif //VRV: porting on Qt 3.0.5 +#include "utilities.h" + using namespace std; extern int SetVisibility(vtkActorCollection* theCollection, int theParam); @@ -78,6 +82,12 @@ VTKViewer_InteractorStyleSALOME::VTKViewer_InteractorStyleSALOME() this->RadianToDegree = 180.0 / vtkMath::Pi(); this->ForcedState = VTK_INTERACTOR_STYLE_CAMERA_NONE; loadCursors(); + + myPActor = vtkActor::New(); + myPActor->PickableOff(); + myPActor->GetProperty()->SetColor(0,1,1); + myPActor->GetProperty()->SetLineWidth(5); + myPActor->GetProperty()->SetPointSize(5); } //---------------------------------------------------------------------------- @@ -85,6 +95,15 @@ VTKViewer_InteractorStyleSALOME::~VTKViewer_InteractorStyleSALOME() { } +//---------------------------------------------------------------------------- +void VTKViewer_InteractorStyleSALOME::setPreselectionProp(const double& theRed, const double& theGreen, + const double& theBlue, const int& theWidth) +{ + myPActor->GetProperty()->SetColor(theRed, theGreen, theBlue); + myPActor->GetProperty()->SetLineWidth(theWidth); + myPActor->GetProperty()->SetPointSize(theWidth); +} + //---------------------------------------------------------------------------- void VTKViewer_InteractorStyleSALOME::setTriedron(VTKViewer_Trihedron* theTrihedron){ m_Trihedron = theTrihedron; @@ -515,8 +534,7 @@ void VTKViewer_InteractorStyleSALOME::startFitArea() void VTKViewer_InteractorStyleSALOME::ViewFitAll() { int aTriedronWasVisible = false; if(m_Trihedron){ - aTriedronWasVisible = - m_Trihedron->GetVisibility() == VTKViewer_Trihedron::eOn; + aTriedronWasVisible = m_Trihedron->GetVisibility() == VTKViewer_Trihedron::eOn; if(aTriedronWasVisible) m_Trihedron->VisibilityOff(); } @@ -529,6 +547,7 @@ void VTKViewer_InteractorStyleSALOME::ViewFitAll() { } if(aTriedronWasVisible) m_Trihedron->VisibilityOn(); else m_Trihedron->VisibilityOff(); + ::ResetCameraClippingRange(CurrentRenderer); } @@ -723,7 +742,7 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() // VSV: LOD actor activisation // rwi->GetRenderWindow()->SetDesiredUpdateRate(rwi->GetStillUpdateRate()); - int aSelectionMode = aSel->SelectionMode(); + Selection_Mode aSelectionMode = aSel->SelectionMode(); bool aSelActiveCompOnly = aSel->IsSelectActiveCompOnly(); switch (State) { @@ -767,16 +786,17 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() if ( rwi->GetPicker()->IsA("vtkCellPicker") ) { vtkCellPicker* picker; if ( (picker = vtkCellPicker::SafeDownCast(rwi->GetPicker())) ) { - MESSAGE ( " CellId : " << picker->GetCellId() ); - if ( picker->GetCellId() >= 0 ) { + int aVtkId = picker->GetCellId(); + // INFOS ( " CellId : " << aVtkId ); + if ( aVtkId >= 0 ) { vtkActor* ac = picker->GetActor(); if ( ac->IsA("SALOME_Actor") ) { SALOME_Actor* SActor = SALOME_Actor::SafeDownCast( ac ); - MESSAGE ( " NAME Actor : " << SActor->getName() ); + INFOS ( " NAME Actor : " << SActor->getName() << ", CellId : " << aVtkId ); - //Cell selection //////////////////////////////////// NB - if ( aSelectionMode == 3 ) { - if ( SActor->hasIO() ) { + //Cell selection /////////////////////////////// NB + if ( aSelectionMode == CellSelection ) { + if ( SActor->hasIO() && isValid( SActor, aVtkId, aSelectionMode ) ) { Handle(SALOME_InteractiveObject) IO = SActor->getIO(); // Look in the current selection SALOME_ListIteratorOfListIO It(aSel->StoredIObjects()); @@ -789,91 +809,135 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() break; } } - if(IsSelected) { - // This IO is already in the selection - //if(shift) { - bool add = aSel->AddOrRemoveIndex( IO, picker->GetCellId(), myShiftState, false ); - //Sel->RemoveIObject(IO); - //} + + int anObjId = SActor->GetObjId(aVtkId); + std::vector aVtkList; + if (anObjId != -1) { + aVtkList = SActor->GetVtkId(anObjId); + } + + if (IsSelected) { + // This IO is already in the selection + if (aVtkList.size() > 0) + bool add = aSel->AddOrRemoveIndex( IO, aVtkList, myShiftState, false ); + else + bool add = aSel->AddOrRemoveIndex( IO, aVtkId, myShiftState, false ); } else { - if(!myShiftState) { - this->HighlightProp( NULL ); - aSel->ClearIObjects(); - } - bool add = aSel->AddOrRemoveIndex( IO, picker->GetCellId(), myShiftState, false ); - aSel->AddIObject( IO, false ); + if (!myShiftState) { + this->HighlightProp( NULL ); + aSel->ClearIObjects(); + } + if (aVtkList.size() > 0) + bool add = aSel->AddOrRemoveIndex( IO, aVtkList, myShiftState, false ); + else + bool add = aSel->AddOrRemoveIndex( IO, aVtkId, myShiftState, false ); + aSel->AddIObject( IO, false ); } } } - //Edge selection ////////////////////////// NB - else if ( aSelectionMode == 2 ) { - if(SActor->hasIO()){ - Handle(SALOME_InteractiveObject) IO = SActor->getIO(); - float pickPosition[3],pcoords[3],closestPoint[3],weights[3],dist1=1000000.0,dist2=0; - int subId,edgeId=-10,pickedID,result; - pickedID = picker->GetCellId(); - picker->GetPickPosition(pickPosition); - if (vtkDataSet* UGrid = SActor->GetMapper()->GetInput()){ - if (vtkCell* pickedCell = UGrid->GetCell(pickedID)){ - edgeId = -1; - for (int i = 0, iEnd = pickedCell->GetNumberOfEdges(); i < iEnd; i++){ - vtkCell* edge = pickedCell->GetEdge(i); - if(vtkLine* line = vtkLine::SafeDownCast(edge)){ - result = line->EvaluatePosition(pickPosition,closestPoint,subId,pcoords,dist2,weights); - if (dist2 < dist1) { - dist1 = dist2; - edgeId = i; + //Edge, Face, Volume and EdgeOfCell selection ////////////////////////// NB + else if ( aSelectionMode == EdgeSelection || + aSelectionMode == FaceSelection || + aSelectionMode == VolumeSelection || + aSelectionMode == EdgeOfCellSelection ) { + if ( SActor->hasIO() && isValid( SActor, aVtkId, aSelectionMode ) ) { + Handle(SALOME_InteractiveObject) IO = SActor->getIO(); + if (vtkDataSet* UGrid = SActor->GetMapper()->GetInput()) { + if (vtkCell* pickedCell = UGrid->GetCell(aVtkId)) { + bool result = false; + int edgeId = -1; + int anObjId = SActor->GetObjId(aVtkId); + std::vector aVtkList; + if (anObjId > -1) + aVtkList = SActor->GetVtkId(anObjId); + + if (aSelectionMode == EdgeSelection) { + if ( SActor->GetObjDimension( anObjId ) == 1 ) + result = true; + } + else if ( aSelectionMode == FaceSelection ) { + if ( SActor->GetObjDimension( anObjId ) == 2 ) + result = true; + } + else if (aSelectionMode == VolumeSelection) { + if ( SActor->GetObjDimension( anObjId ) == 3 ) + result = true; + } + else { + float pickPosition[3]; + picker->GetPickPosition(pickPosition); + float distMin = 1000000.0, dist = 0; + for (int i = 0, iEnd = pickedCell->GetNumberOfEdges(); i < iEnd; i++){ + vtkCell* edge = pickedCell->GetEdge(i); + if (vtkLine* line = vtkLine::SafeDownCast(edge)){ + float pcoords[3],closestPoint[3],weights[3]; + int subId; + line->EvaluatePosition(pickPosition,closestPoint,subId,pcoords,dist,weights); + if (dist < distMin) { + distMin = dist; + edgeId = i; + } } } + if (edgeId != -1 || pickedCell->GetCellDimension() == 1) + result = true; + INFOS("edgeID transformed = "<GetPicker())) ) { - MESSAGE ( " PointId : " << picker->GetPointId() ); + INFOS ( " PointId : " << picker->GetPointId() ); if ( picker->GetPointId() >= 0 ) { vtkActor* ac = picker->GetActor(); if ( ac->IsA("SALOME_Actor") ) { SALOME_Actor* SActor = SALOME_Actor::SafeDownCast( ac ); - MESSAGE ( " NAME Actor : " << SActor->getName() ); + INFOS ( " NAME Actor : " << SActor->getName() ); if ( SActor->hasIO() ) { Handle(SALOME_InteractiveObject) IO = SActor->getIO(); -/* if (IO.IsNull()) + /* + if (IO.IsNull()) break; if (aSelActiveCompOnly && - strcmp(aActiveComponent->ComponentDataType(), IO->getComponentDataType()) != 0) { + strcmp(aActiveComponent->ComponentDataType(), + IO->getComponentDataType()) != 0) { break; - }*/ + } + */ // Look in the current selection SALOME_ListIteratorOfListIO It(aSel->StoredIObjects()); Standard_Boolean IsSelected = false; @@ -949,13 +1013,13 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() } } } - rwi->EndPickCallback(); } + rwi->EndPickCallback(); } else { //processing rectangle selection - SALOMEDS::SComponent_var aActiveComponent = SALOMEDS::SComponent:: - _narrow(aActiveStudy->getStudyDocument()-> - FindObject(QAD_Application::getDesktop()->getActiveComponent())); + SALOMEDS::SComponent_var aActiveComponent = + SALOMEDS::SComponent::_narrow(aActiveStudy->getStudyDocument()-> + FindObject(QAD_Application::getDesktop()->getActiveComponent())); if(aSelActiveCompOnly && aActiveComponent->_is_nil()) return; rwi->StartPickCallback(); @@ -966,7 +1030,7 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() } // Compute bounds - vtkCamera *cam = this->CurrentRenderer->GetActiveCamera(); + // vtkCamera *cam = this->CurrentRenderer->GetActiveCamera(); QRect rect(myPoint, myOtherPoint); rect = rect.normalize(); int w, h, x, y; @@ -978,7 +1042,7 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() y2 = h - rect.bottom() - 1; switch (aSelectionMode) { - case 1: // Nodes selection + case NodeSelection: // Nodes selection { if (! rwi->GetPicker()->IsA("vtkPointPicker") ) break; vtkPointPicker* aPointPicker = vtkPointPicker::SafeDownCast(rwi->GetPicker()); @@ -999,7 +1063,8 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() if (IO.IsNull()) continue; if (aSelActiveCompOnly && - strcmp(aActiveComponent->ComponentDataType(), IO->getComponentDataType()) != 0) { + strcmp(aActiveComponent->ComponentDataType(), + IO->getComponentDataType()) != 0) { continue; } @@ -1015,6 +1080,8 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() continue; } if (aDataSet) { + + std::vector anIndices; for (int i=0; i < aDataSet->GetNumberOfPoints(); i++) { float* aPoint; aPoint = aDataSet->GetPoint(i); @@ -1024,12 +1091,21 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() aPoint[1], aPoint[2], aDisp); aPointPicker->Pick(aDisp[0], aDisp[1], 0.0, CurrentRenderer); - if ( aPointPicker->GetPointId() >= 0) { // && (!aSel->IsIndexSelected(IO, aPointPicker->GetPointId()))) { - aSel->AddOrRemoveIndex(IO, aPointPicker->GetPointId(), true, false); - aSel->AddIObject(IO, false); - } + + int pid = aPointPicker->GetPointId(); + if ( pid >= 0) { // && (!aSel->IsIndexSelected(IO, aPointPicker->GetPointId()))) { + std::vector::iterator found = + find(anIndices.begin(), anIndices.end(), pid); + if (found == anIndices.end()) + anIndices.push_back(pid); + } } } + if (!anIndices.empty()) { + aSel->AddOrRemoveIndex(IO, anIndices, true, false); + aSel->AddIObject(IO, false); + anIndices.clear(); + } } } } @@ -1037,91 +1113,140 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() } } break; - case 2: // edges selection - case 3: // triangles selection + case CellSelection: + case EdgeOfCellSelection: + case EdgeSelection: + case FaceSelection: + case VolumeSelection: { - aSel->SetSelectionMode(aSelectionMode,true); - if (!rwi->GetPicker()->IsA("vtkCellPicker") ) break; - vtkCellPicker* aCellPicker = vtkCellPicker::SafeDownCast(rwi->GetPicker()); - vtkActorCollection* aListActors = this->CurrentRenderer->GetActors(); - aListActors->InitTraversal(); + VTKViewer_CellRectPicker* picker = VTKViewer_CellRectPicker::New(); + picker->SetTolerance(0.001); + picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer); + + vtkActorCollection* aListActors = picker->GetActors(); vtkActor* aActor; - for (int k = 0, kEnd = aListActors->GetNumberOfItems(); k < kEnd; k++){ - vtkActor* aActor = aListActors->GetNextActor(); - if (vtkActor* aActor = aListActors->GetNextActor()){ - if (aActor->GetVisibility() == 0) continue; - if(SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aActor)) { - if(SActor->hasIO()) { - Handle(SALOME_InteractiveObject) IO = SActor->getIO(); - if(IO.IsNull()) continue; - if(aSelActiveCompOnly) { - if(strcmp(aActiveComponent->ComponentDataType(),IO->getComponentDataType()) != 0) - continue; + aListActors->InitTraversal(); + while(aActor = aListActors->GetNextActor()) { + if (aActor->IsA("SALOME_Actor")) { + SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor); + if (aSActor->hasIO()) { + Handle(SALOME_InteractiveObject) aIO = aSActor->getIO(); + // INFOS ( " NAME Object : " << aIO->getName() << " from " << aIO->getComponentDataType() ); + if (aSelActiveCompOnly && + strcmp(aActiveComponent->ComponentDataType(), + aIO->getComponentDataType()) != 0) { + continue; + } + VTKViewer_CellDataSet cellList = picker->GetCellData(aActor); + if ( !cellList.empty() ) { + INFOS ( " NAME Actor : " << aSActor->getName() ); + std::vector anIndexes; + if (aSelectionMode == CellSelection) { + VTKViewer_CellDataSet::iterator it; + for (it = cellList.begin(); it != cellList.end(); ++it) { + int aCellId = (*it).cellId; + if ( !isValid( aSActor, aCellId, aSelectionMode ) ) + continue; + + int aObjId = aSActor->GetObjId(aCellId); + std::vector aVtkList; + if ( aObjId != -1 ) + aVtkList = aSActor->GetVtkId(aObjId); + + if (aVtkList.size() > 0) { + std::vector::iterator it; + for (it = aVtkList.begin(); it != aVtkList.end(); ++it) { + std::vector::iterator found = + find(anIndexes.begin(), anIndexes.end(), *it); + if (found == anIndexes.end()) + anIndexes.push_back(*it); + } + } + else + anIndexes.push_back(aCellId); + } } - if(vtkDataSet* aDataSet = SActor->GetMapper()->GetInput()){ - for(int i = 0, iEnd = aDataSet->GetNumberOfCells(); i < iEnd; i++){ - if(vtkCell* aCell = aDataSet->GetCell(i)){ - if(IsInRect(aCell, x1, y1, x2, y2)){ - float* aBounds = aCell->GetBounds(); - float aCenter[3]; - aCenter[0] =(aBounds[0] + aBounds[1])/2; // Center X - aCenter[1] =(aBounds[2] + aBounds[3])/2; // Center Y - aCenter[2] =(aBounds[4] + aBounds[5])/2; // Center Z - float aDisp[3]; - ComputeWorldToDisplay(aCenter[0],aCenter[1],aCenter[2],aDisp); - aCellPicker->Pick(aDisp[0], aDisp[1], 0.0, CurrentRenderer); - if(aCellPicker->GetCellId() >= 0 && !aSel->IsIndexSelected(IO,aCellPicker->GetCellId())){ - aSel->AddOrRemoveIndex( IO, aCellPicker->GetCellId(), true, false); - aSel->AddIObject( IO, false ); + else { + if ( vtkDataSet* aDataSet = aSActor->GetMapper()->GetInput() ) { + VTKViewer_CellDataSet::iterator it; + for ( it = cellList.begin(); it != cellList.end(); ++it ) { + int aCellId = (*it).cellId; + + if ( !isValid( aSActor, aCellId, aSelectionMode ) ) + continue; + + int aObjId = aSActor->GetObjId(aCellId); + std::vector aVtkList; + if (aObjId != -1) + aVtkList = aSActor->GetVtkId(aObjId); + bool result = false; + if (vtkCell* aCell = aDataSet->GetCell(aCellId)) { + if ( aSelectionMode == EdgeSelection ) { + if ( aSActor->GetObjDimension( aObjId ) == 1 ) + result = true; + } + else if ( aSelectionMode == FaceSelection ) { + if ( aSActor->GetObjDimension( aObjId ) == 2 ) + result = true; + } + else if ( aSelectionMode == VolumeSelection ) { + if ( aSActor->GetObjDimension( aObjId ) == 3 ) + result = true; } } + if ( result ) { + if (aVtkList.size() > 0) { + std::vector::iterator it; + for (it = aVtkList.begin(); it != aVtkList.end(); ++it) { + std::vector::iterator found = + find(anIndexes.begin(), anIndexes.end(), *it); + if (found == anIndexes.end()) + anIndexes.push_back(*it); + } + } + else + anIndexes.push_back(aCellId); + } } } } + aSel->AddOrRemoveIndex(aIO, anIndexes, true, false); + aSel->AddIObject(aIO, false); } } } } } - break; - case 4: // objects selection + break; + case ActorSelection: // objects selection { - vtkActorCollection* aListActors = this->CurrentRenderer->GetActors(); - aListActors->InitTraversal(); + VTKViewer_RectPicker* picker = VTKViewer_RectPicker::New(); + picker->SetTolerance(0.001); + picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer); + + vtkActorCollection* aListActors = picker->GetActors(); vtkActor* aActor; SALOME_ListIO aListIO; - for (int k = 0; k < aListActors->GetNumberOfItems(); k++) { - aActor = aListActors->GetNextActor(); - if (aActor) { - if (aActor->GetVisibility() == 0) - continue; - if ( aActor->IsA("SALOME_Actor") ) { - SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor); - if ( aSActor->hasIO() && IsInRect(aSActor, x1, y1, x2, y2)) { - Handle(SALOME_InteractiveObject) aIO = aSActor->getIO(); - if (aIO.IsNull()) - continue; - if (aSelActiveCompOnly && - strcmp(aActiveComponent->ComponentDataType(), aIO->getComponentDataType()) != 0) { - continue; - } - if (aListIO.IsEmpty()) { - aListIO.Append( aIO ); - } else { - SALOME_ListIteratorOfListIO It(aListIO); - bool isStored = false; - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IOS = It.Value(); - if( aIO->isSame(IOS) ) { - aIO = IOS; //Added by SRN, fix SAL1307 - isStored = true; - break; - } + aListActors->InitTraversal(); + while(aActor = aListActors->GetNextActor()) { + if (aActor->IsA("SALOME_Actor")) { + SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor); + if (aSActor->hasIO()) { + Handle(SALOME_InteractiveObject) aIO = aSActor->getIO(); + bool isStored = false; + if (!aListIO.IsEmpty()) { + SALOME_ListIteratorOfListIO It(aListIO); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IOS = It.Value(); + if( aIO->isSame(IOS) ) { + aIO = IOS; //Added by SRN, fix SAL1307 + isStored = true; + break; } - if (!isStored) - aListIO.Append( aIO ); } } + if (!isStored) + aListIO.Append(aIO); } } } @@ -1223,12 +1348,21 @@ void VTKViewer_InteractorStyleSALOME::onOperation(QPoint mousePos) this->LastPos[1] = h - mousePos.y() - 1; } +// called when selection mode changed (!put necessary initialization here!) +void VTKViewer_InteractorStyleSALOME::OnSelectionModeChanged() +{ + myPActor->VisibilityOff(); +} + // called when user moves mouse inside viewer window and there is no active viewer operation // (!put necessary processing here!) void VTKViewer_InteractorStyleSALOME::onCursorMove(QPoint mousePos) { // processing highlighting - QAD_Study* myActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + QAD_Study* anActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOME_Selection* Sel = SALOME_Selection::Selection( anActiveStudy->getSelection() ); + + Selection_Mode aSelectionMode = Sel->SelectionMode(); + myPActor->VisibilityOff(); vtkRenderWindowInteractor *rwi = this->Interactor; int w, h, x, y; @@ -1238,8 +1372,140 @@ void VTKViewer_InteractorStyleSALOME::onCursorMove(QPoint mousePos) { this->FindPokedRenderer(x,y); rwi->StartPickCallback(); rwi->GetPicker()->Pick(x, y, 0.0, this->CurrentRenderer); + + if (rwi->GetPicker()->IsA("vtkCellPicker")) { + vtkCellPicker* picker = vtkCellPicker::SafeDownCast(rwi->GetPicker()); + int aVtkId = picker->GetCellId(); + // INFOS ( " Preselected CellId : " << picker->GetCellId() ); + if ( aVtkId >= 0 ) { + vtkActor* ac = picker->GetActor(); + if ( ac->IsA("SALOME_Actor") ) { + SALOME_Actor* SActor = SALOME_Actor::SafeDownCast( ac ); + // INFOS ( " NAME Actor : " << SActor->getName() ); + + if (rwi->IsA("VTKViewer_RenderWindowInteractor")) { + VTKViewer_RenderWindowInteractor* aRWI = + VTKViewer_RenderWindowInteractor::SafeDownCast(rwi); + + //Cell selection //////////////////////////////////// NB + if ( aSelectionMode == CellSelection ) + { + if ( SActor->hasIO() && isValid( SActor, aVtkId, CellSelection ) ) + { + int anObjId = SActor->GetObjId(aVtkId); + std::vector aVtkList; + if (anObjId != -1) + aVtkList = SActor->GetVtkId(anObjId); + + if (aVtkList.size() > 0) + aRWI->setCellData(SActor->getIO(), aVtkList, myPActor); + else + aRWI->setCellData(SActor->getIO(), aVtkId, myPActor); + + this->CurrentRenderer->AddActor(myPActor); + myPActor->GetProperty()->SetRepresentationToSurface(); + myPActor->VisibilityOn(); + } + } + + //Edge, Face, Volume and EdgeOfCell selection ////////////////////////// NB + else if ( aSelectionMode == EdgeSelection || + aSelectionMode == FaceSelection || + aSelectionMode == VolumeSelection || + aSelectionMode == EdgeOfCellSelection ) { + if ( SActor->hasIO() && isValid( SActor, aVtkId, aSelectionMode ) ) + { + if (vtkDataSet* UGrid = SActor->GetMapper()->GetInput()) { + if (vtkCell* pickedCell = UGrid->GetCell(aVtkId)) { + bool result = false; + int edgeId = -1; + int anObjId = SActor->GetObjId(aVtkId); + std::vector aVtkList; + if (anObjId > -1) + aVtkList = SActor->GetVtkId(anObjId); + + if ( aSelectionMode == EdgeSelection ) { + if ( SActor->GetObjDimension( anObjId ) == 1 ) + result = true; + } + else if ( aSelectionMode == FaceSelection ) { + if ( SActor->GetObjDimension( anObjId ) == 2 ) + result = true; + } + else if ( aSelectionMode == VolumeSelection ) { + if ( SActor->GetObjDimension( anObjId ) == 3 ) + result = true; + } + else { + float pickPosition[3]; + picker->GetPickPosition(pickPosition); + float distMin = 1000000.0, dist = 0; + for (int i = 0, iEnd = pickedCell->GetNumberOfEdges(); i < iEnd; i++){ + vtkCell* edge = pickedCell->GetEdge(i); + if(vtkLine* line = vtkLine::SafeDownCast(edge)){ + float pcoords[3],closestPoint[3],weights[3]; + int subId; + line->EvaluatePosition(pickPosition,closestPoint,subId,pcoords,dist,weights); + if (dist < distMin) { + distMin = dist; + edgeId = i; + } + } + } + if (edgeId != -1 || pickedCell->GetCellDimension() == 1) + result = true; + // INFOS("edgeID transformed = "<CurrentRenderer->RemoveActor(myPActor); + if (edgeId == -1) { + if (aVtkList.size() > 0) + aRWI->setCellData(SActor->getIO(), aVtkList, myPActor); + else + aRWI->setCellData(SActor->getIO(), aVtkId, myPActor); + } + else + aRWI->setEdgeData(SActor->getIO(), aVtkId, -edgeId-1, myPActor); + + this->CurrentRenderer->AddActor(myPActor); + myPActor->GetProperty()->SetRepresentationToSurface(); + myPActor->VisibilityOn(); + } + } + } + } + } + } + } + } + } + else if (rwi->GetPicker()->IsA("vtkPointPicker")) { + vtkPointPicker* picker = vtkPointPicker::SafeDownCast(rwi->GetPicker()); + // INFOS ( " Preselected PointId : " << picker->GetPointId() ); + if (picker->GetPointId() >= 0) { + vtkActor* ac = picker->GetActor(); + if ( ac->IsA("SALOME_Actor") ) { + SALOME_Actor* SActor = SALOME_Actor::SafeDownCast( ac ); + // INFOS ( " NAME Actor : " << SActor->getName() ); - if ( rwi->GetPicker()->IsA("vtkPicker") ) { + if (rwi->IsA("VTKViewer_RenderWindowInteractor")) { + VTKViewer_RenderWindowInteractor* aRWI = + VTKViewer_RenderWindowInteractor::SafeDownCast(rwi); + + if ( SActor->hasIO() ) { + myPActor->VisibilityOff(); + this->CurrentRenderer->RemoveActor(myPActor); + aRWI->setPointData(SActor->getIO(), picker->GetPointId(), myPActor); + this->CurrentRenderer->AddActor(myPActor); + myPActor->GetProperty()->SetRepresentationToSurface(); + myPActor->VisibilityOn(); + } + } + } + } + } + else if ( rwi->GetPicker()->IsA("vtkPicker") ) { vtkPicker* picker = vtkPicker::SafeDownCast(rwi->GetPicker()); vtkActor* ac = picker->GetActor(); @@ -1282,7 +1548,7 @@ void VTKViewer_InteractorStyleSALOME::onCursorMove(QPoint mousePos) { } ac = theActors->GetNextActor(); } - // MESSAGE ( " NAME PREVIEW " << SActor->getName() ); + // INFOS ( " NAME PREVIEW " << SActor->getName() ); } } } @@ -1301,6 +1567,9 @@ void VTKViewer_InteractorStyleSALOME::onCursorMove(QPoint mousePos) { } } } + rwi->EndPickCallback(); + rwi->Render(); + this->LastPos[0] = x; this->LastPos[1] = y; } @@ -1425,3 +1694,59 @@ bool VTKViewer_InteractorStyleSALOME::IsInRect(float* thePoint, return ((aPnt[0]>left) && (aPnt[0]bottom) && (aPnt[1]GetMapper()->GetInput(); + if ( aUGrid != 0 ) + { + vtkCell* aCell = aUGrid->GetCell( theId ); + if ( aCell != 0 ) + { + int nbPoints = aCell->GetNumberOfPoints(); + if ( nbPoints == 2 ) + return myEdgeFilter.IsNull() || myEdgeFilter->IsValid( theActor, theId ); + else + return myFaceFilter.IsNull() || myFaceFilter->IsValid( theActor, theId ); + + return true; + } + } + return false; + } + else if ( theSelMode == FaceSelection ) + return myFaceFilter.IsNull() || myFaceFilter->IsValid( theActor, theId ); + else if ( theSelMode == EdgeSelection ) + return myEdgeFilter.IsNull() || myEdgeFilter->IsValid( theActor, theId ); + + return true; +} diff --git a/src/VTKViewer/VTKViewer_InteractorStyleSALOME.h b/src/VTKViewer/VTKViewer_InteractorStyleSALOME.h index 62438e91e..ce55fdfc8 100644 --- a/src/VTKViewer/VTKViewer_InteractorStyleSALOME.h +++ b/src/VTKViewer/VTKViewer_InteractorStyleSALOME.h @@ -33,6 +33,8 @@ #include #include #include "SALOME_Actor.h" +#include "VTKViewer_Filter.h" +#include "SALOME_Selection.h" class VTKViewer_Trihedron; @@ -55,6 +57,8 @@ class VTKViewer_InteractorStyleSALOME : public QObject, public vtkInteractorStyl static VTKViewer_InteractorStyleSALOME *New(); void setTriedron(VTKViewer_Trihedron* theTrihedron); + void setPreselectionProp(const double& theRed = 0, const double& theGreen = 1, + const double& theBlue = 1, const int& theWidth = 5); vtkTypeMacro(VTKViewer_InteractorStyleSALOME, vtkObject); void PrintSelf(ostream& os, vtkIndent indent); @@ -68,8 +72,15 @@ class VTKViewer_InteractorStyleSALOME : public QObject, public vtkInteractorStyl void OnRightButtonDown(int ctrl, int shift, int x, int y); void OnRightButtonUp (int ctrl, int shift, int x, int y); + void OnSelectionModeChanged(); + void ViewFitAll(); + void SetEdgeFilter( const Handle(VTKViewer_Filter)& ); + void SetFaceFilter( const Handle(VTKViewer_Filter)& ); + void RemoveFaceFilter(); + void RemoveEdgeFilter(); + protected: VTKViewer_InteractorStyleSALOME(); ~VTKViewer_InteractorStyleSALOME(); @@ -93,12 +104,15 @@ class VTKViewer_InteractorStyleSALOME : public QObject, public vtkInteractorStyl const int left, const int top, const int right, const int bottom); + bool isValid( SALOME_Actor* theActor, const int theCellId, const Selection_Mode theSelMode ); + int State; float MotionFactor; float RadianToDegree; // constant: for conv from deg to rad double myScale; SALOME_Actor* preview; + vtkActor* myPActor; public: bool eventFilter(QObject* object, QEvent* event); @@ -123,26 +137,30 @@ protected: void setCursor(const int operation); protected: - QCursor myDefCursor; - QCursor myPanCursor; - QCursor myZoomCursor; - QCursor myRotateCursor; - QCursor mySpinCursor; - QCursor myHandCursor; - QCursor myGlobalPanCursor; - QPoint myPoint; - QPoint myOtherPoint; - bool myCursorState; - bool myShiftState; - int ForcedState; - VTKViewer_Trihedron* m_Trihedron; - - QWidget* myGUIWindow; + QCursor myDefCursor; + QCursor myPanCursor; + QCursor myZoomCursor; + QCursor myRotateCursor; + QCursor mySpinCursor; + QCursor myHandCursor; + QCursor myGlobalPanCursor; + QPoint myPoint; + QPoint myOtherPoint; + bool myCursorState; + bool myShiftState; + int ForcedState; + + VTKViewer_Trihedron* m_Trihedron; + + QWidget* myGUIWindow; + + Handle(VTKViewer_Filter) myEdgeFilter; + Handle(VTKViewer_Filter) myFaceFilter; // members from old version - double DeltaElevation; - double DeltaAzimuth; - int LastPos[2]; + double DeltaElevation; + double DeltaAzimuth; + int LastPos[2]; }; #endif diff --git a/src/VTKViewer/VTKViewer_RenderWindow.cxx b/src/VTKViewer/VTKViewer_RenderWindow.cxx index 7712ec01e..46e3dba3f 100644 --- a/src/VTKViewer/VTKViewer_RenderWindow.cxx +++ b/src/VTKViewer/VTKViewer_RenderWindow.cxx @@ -194,8 +194,10 @@ void VTKViewer_RenderWindow::onChangeBackgroundColor() QColor selColor = QColorDialog::getColor ( QColor(int(backint[0]*255), int(backint[1]*255), int(backint[2]*255)), NULL ); if ( selColor.isValid() ) { theRenderer->SetBackground( selColor.red()/255., selColor.green()/255., selColor.blue()/255. ); + /* VSR : PAL5420 --------------------------------------------------- QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorRed", selColor.red() ); QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorGreen", selColor.green() ); QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorBlue", selColor.blue() ); + VSR : PAL5420 --------------------------------------------------- */ } } diff --git a/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx b/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx index 2e4ce4b96..9658ef5e5 100644 --- a/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx +++ b/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx @@ -33,7 +33,7 @@ #include "QAD_Application.h" #include "QAD_Desktop.h" -#include "SALOME_Selection.h" +//#include "SALOME_Selection.h" #include "SALOME_Actor.h" #include @@ -147,6 +147,9 @@ void VTKViewer_RenderWindowInteractor::Initialize() { // this->Initialized = 1 ; + myTolNodes = 0.025; + myTolItems = 0.001; + Cell_Actor = vtkActor::New(); Cell_Actor->PickableOff(); Cell_Actor->GetProperty()->SetColor(1,1,0); @@ -175,32 +178,63 @@ void VTKViewer_RenderWindowInteractor::SetInteractorStyle(vtkInteractorObserver } -void VTKViewer_RenderWindowInteractor::SetSelectionMode(int mode) +void VTKViewer_RenderWindowInteractor::SetSelectionMode(Selection_Mode mode) { Cell_Actor->VisibilityOff(); Edge_Actor->VisibilityOff(); Point_Actor->VisibilityOff(); selectionmode = mode; - if ( mode == 1 ) { + if ( mode == NodeSelection ) { vtkPointPicker* thepicker = vtkPointPicker::New(); - // thepicker->SetTolerance(0.001); + thepicker->SetTolerance(myTolNodes); this->SetPicker(thepicker); - } else if ( mode == 2 ) { + } else if ( mode == EdgeOfCellSelection ) { vtkCellPicker* thepicker = vtkCellPicker::New(); - thepicker->SetTolerance(0.001); + thepicker->SetTolerance(myTolItems); this->SetPicker(thepicker); - } else if ( mode == 3 ) { + } else if ( mode == CellSelection || mode == EdgeSelection || + mode == FaceSelection || mode == VolumeSelection ) { vtkCellPicker* thepicker = vtkCellPicker::New(); - thepicker->SetTolerance(0.001); + thepicker->SetTolerance(myTolItems); this->SetPicker(thepicker); - } else if ( mode == 4 ) { + } else if ( mode == ActorSelection ) { vtkPicker* thepicker = vtkPicker::New(); - thepicker->SetTolerance(0.001); + thepicker->SetTolerance(myTolItems); this->SetPicker(thepicker); } + + VTKViewer_InteractorStyleSALOME* Style = 0; + if (this->InteractorStyle->IsA("VTKViewer_InteractorStyleSALOME")) + Style = VTKViewer_InteractorStyleSALOME::SafeDownCast(this->InteractorStyle); + else + return; + Style->OnSelectionModeChanged(); } +void VTKViewer_RenderWindowInteractor::SetSelectionProp(const double& theRed, const double& theGreen, + const double& theBlue, const int& theWidth) +{ + Cell_Actor->GetProperty()->SetColor(theRed, theGreen, theBlue); + Cell_Actor->GetProperty()->SetLineWidth(theWidth); + + Point_Actor->GetProperty()->SetColor(theRed, theGreen, theBlue); + Point_Actor->GetProperty()->SetPointSize(theWidth); +} + +void VTKViewer_RenderWindowInteractor::SetSelectionTolerance(const double& theTolNodes, const double& theTolItems) +{ + myTolNodes = theTolNodes; + myTolItems = theTolItems; + if (this->GetPicker()->IsA("vtkPointPicker")) { + vtkPointPicker* picker = vtkPointPicker::SafeDownCast(this->GetPicker()); + picker->SetTolerance(theTolNodes); + } + else if (this->GetPicker()->IsA("vtkPicker")) { + vtkPicker* picker = vtkPicker::SafeDownCast(this->GetPicker()); + picker->SetTolerance(theTolItems); + } +} void VTKViewer_RenderWindowInteractor::Enable() { // @@ -604,13 +638,31 @@ void VTKViewer_RenderWindowInteractor::DisplayAll() emit RenderWindowModified() ; } +void VTKViewer_RenderWindowInteractor::Erase( SALOME_Actor* SActor, bool update) +{ + SActor->SetVisibility( false ); + + // Erase dependent actors + vtkActorCollection* theChildActors = vtkActorCollection::New(); + SActor->GetChildActors(theChildActors); + + theChildActors->InitTraversal(); + vtkActor *ac = theChildActors->GetNextActor(); + while(!(ac==NULL)) { + ac->SetVisibility( false ); + ac = theChildActors->GetNextActor(); + } + + if (update) + emit RenderWindowModified(); +} + void VTKViewer_RenderWindowInteractor::Erase(const Handle(SALOME_InteractiveObject)& IObject, bool update) { vtkRenderer* aren; for (this->RenderWindow->GetRenderers()->InitTraversal(); (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) { vtkActorCollection* theActors = aren->GetActors(); - vtkActorCollection* theChildActors = vtkActorCollection::New(); theActors->InitTraversal(); vtkActor *ac = theActors->GetNextActor(); while(!(ac==NULL)) { @@ -618,21 +670,12 @@ void VTKViewer_RenderWindowInteractor::Erase(const Handle(SALOME_InteractiveObje SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ); if ( anActor->hasIO() ) { if ( IObject->isSame( anActor->getIO() ) ) { - anActor->SetVisibility( false ); - anActor->GetChildActors(theChildActors); + Erase(anActor, false); } } } ac = theActors->GetNextActor(); } - - // Erase dependent actors - theChildActors->InitTraversal(); - ac = theChildActors->GetNextActor(); - while(!(ac==NULL)) { - ac->SetVisibility( false ); - ac = theChildActors->GetNextActor(); - } } if (update) emit RenderWindowModified() ; @@ -828,14 +871,14 @@ bool VTKViewer_RenderWindowInteractor::unHighlightAll(){ aRenColl->InitTraversal(); while(vtkRenderer* aRen = this->RenderWindow->GetRenderers()->GetNextItem()){ vtkActorCollection* theActors = aRen->GetActors(); - theActors->InitTraversal(); if(theActors->IsItemPresent(Point_Actor)) aRen->RemoveActor(Point_Actor); if(theActors->IsItemPresent(Edge_Actor)) aRen->RemoveActor(Edge_Actor); if(theActors->IsItemPresent(Cell_Actor)) aRen->RemoveActor(Cell_Actor); - vtkActor *anActor = theActors->GetNextActor(); + + theActors->InitTraversal(); while(vtkActor *anAct = theActors->GetNextActor()) { if(SALOME_Actor* anActor = SALOME_Actor::SafeDownCast(anAct)){ if(anActor->hasIO()){ @@ -995,43 +1038,54 @@ bool VTKViewer_RenderWindowInteractor::highlight(const Handle(SALOME_Interactive vtkActor *theActor, bool hilight, bool update ) { if(MapIndex.Extent() == 0) return false; - vtkRenderer* aRen; - this->RenderWindow->GetRenderers()->InitTraversal(); - for (; aRen = this->RenderWindow->GetRenderers()->GetNextItem(); ) { - vtkActorCollection* anActorColl = aRen->GetActors(); - if ( anActorColl->IsItemPresent(theActor) != 0 ) - aRen->RemoveActor(theActor); - anActorColl->InitTraversal(); - vtkActor *ac = NULL; - for(; (ac = anActorColl->GetNextActor()) != NULL; ){ - if(ac->IsA("SALOME_Actor")){ - SALOME_Actor* anActor = SALOME_Actor::SafeDownCast(ac); - if(anActor->hasIO()){ - if(IObject->isSame(anActor->getIO())){ - if(vtkPolyData* aSourcePolyData = anActor->GetPolyDataInput()){ - vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New(); - (*theFun)(aSourcePolyData,aMapper,MapIndex); - theActor->SetMapper(aMapper); - aMapper->Delete(); - if(anActorColl->IsItemPresent(theActor) == 0) - aRen->AddActor(theActor); - if(hilight) - theActor->VisibilityOn(); - else - theActor->VisibilityOff(); - break; - } - } - } - } - } + vtkRenderer* aRen = GetRenderer(); + vtkActorCollection* anActorColl = aRen->GetActors(); + if ( anActorColl->IsItemPresent(theActor) != 0 ) + aRen->RemoveActor(theActor); + + if (hilight) { + setActorData(IObject, MapIndex, theFun, theActor); + aRen->AddActor(theActor); + theActor->VisibilityOn(); + } + else { + theActor->VisibilityOff(); } + if(update){ this->RenderWindow->Render(); emit RenderWindowModified() ; } + return false; } + +void VTKViewer_RenderWindowInteractor::setActorData(const Handle(SALOME_InteractiveObject)& IObject, + const TColStd_MapOfInteger& MapIndex, + VTKViewer_RenderWindowInteractor::TCreateMapperFun theFun, + vtkActor* theActor) +{ + vtkActorCollection* anActorColl = GetRenderer()->GetActors(); + anActorColl->InitTraversal(); + vtkActor *ac = NULL; + while ((ac = anActorColl->GetNextActor()) != NULL) { + if (ac->IsA("SALOME_Actor")){ + SALOME_Actor* anActor = SALOME_Actor::SafeDownCast(ac); + if (anActor->hasIO()) { + if (IObject->isSame(anActor->getIO())) { + if (vtkPolyData* aSourcePolyData = anActor->GetPolyDataInput()) { + vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New(); + (*theFun)(aSourcePolyData,aMapper,MapIndex); + theActor->SetMapper(aMapper); + aMapper->Delete(); + break; + } + } + } + } + } +} + static void CellCreateMapper(vtkPolyData *theSourcePolyData, vtkPolyDataMapper* theMapper, const TColStd_MapOfInteger& theMapIndex) @@ -1041,7 +1095,7 @@ static void CellCreateMapper(vtkPolyData *theSourcePolyData, vtkPolyDataMapper* vtkIdList *ptIds = vtkIdList::New(); ptIds->Allocate(theSourcePolyData->GetMaxCellSize()); - vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New(); + // vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New(); aPolyData->SetPoints(theSourcePolyData->GetPoints()); TColStd_MapIteratorOfMapOfInteger ite(theMapIndex); int aNbOfParts = theSourcePolyData->GetNumberOfCells(); @@ -1068,6 +1122,23 @@ bool VTKViewer_RenderWindowInteractor::highlightCell(const Handle(SALOME_Interac { return highlight(IObject,MapIndex,&CellCreateMapper,Cell_Actor,hilight,update); } + +void VTKViewer_RenderWindowInteractor::setCellData(const Handle(SALOME_InteractiveObject)& IObject, + const int& theIndex, vtkActor* theActor ) +{ + TColStd_MapOfInteger MapIndex; MapIndex.Add(theIndex); + return setActorData(IObject,MapIndex,&CellCreateMapper,theActor); +} + +void VTKViewer_RenderWindowInteractor::setCellData(const Handle(SALOME_InteractiveObject)& IObject, + const std::vector& theIndexes, vtkActor* theActor ) +{ + TColStd_MapOfInteger MapIndex; + std::vector::const_iterator it; + for (it = theIndexes.begin(); it != theIndexes.end(); ++it) + MapIndex.Add(*it); + return setActorData(IObject,MapIndex,&CellCreateMapper,theActor); +} static void PointCreateMapper(vtkPolyData *theSourcePolyData, vtkPolyDataMapper* theMapper, @@ -1101,6 +1172,14 @@ bool VTKViewer_RenderWindowInteractor::highlightPoint(const Handle(SALOME_Intera { return highlight(IObject,MapIndex,&PointCreateMapper,Point_Actor,hilight,update); } + + +void VTKViewer_RenderWindowInteractor::setPointData(const Handle(SALOME_InteractiveObject)& IObject, + const int& theIndex, vtkActor* theActor ) +{ + TColStd_MapOfInteger MapIndex; MapIndex.Add(theIndex); + return setActorData(IObject,MapIndex,&PointCreateMapper,theActor); +} static void EdgeCreateMapper(vtkPolyData *theSourcePolyData, vtkPolyDataMapper* theMapper, @@ -1160,3 +1239,11 @@ bool VTKViewer_RenderWindowInteractor::highlightEdge( const Handle(SALOME_Intera { return highlight(IObject,MapIndex,&EdgeCreateMapper,Edge_Actor,hilight,update); } + +void VTKViewer_RenderWindowInteractor::setEdgeData(const Handle(SALOME_InteractiveObject)& IObject, + const int& theCellIndex, const int& theEdgeIndex, + vtkActor* theActor ) +{ + TColStd_MapOfInteger MapIndex; MapIndex.Add(theCellIndex); MapIndex.Add(theEdgeIndex); + return setActorData(IObject,MapIndex,&EdgeCreateMapper,theActor); +} diff --git a/src/VTKViewer/VTKViewer_RenderWindowInteractor.h b/src/VTKViewer/VTKViewer_RenderWindowInteractor.h index e5fa40885..3a22e676a 100644 --- a/src/VTKViewer/VTKViewer_RenderWindowInteractor.h +++ b/src/VTKViewer/VTKViewer_RenderWindowInteractor.h @@ -34,6 +34,7 @@ #include "SALOME_InteractiveObject.hxx" #include "SALOME_Actor.h" +#include "SALOME_Selection.h" // QT Includes #include @@ -141,8 +142,20 @@ public: bool isVisible( const Handle(SALOME_InteractiveObject)& IObject); void rename(const Handle(SALOME_InteractiveObject)& IObject, QString newName); - - void SetSelectionMode(int mode); + void SetSelectionMode(Selection_Mode mode); + void SetSelectionProp(const double& theRed = 1, const double& theGreen = 1, + const double& theBlue = 0, const int& theWidth = 5); + void SetSelectionTolerance(const double& theTolNodes = 0.025, const double& theTolCell = 0.001); + + void setCellData(const Handle(SALOME_InteractiveObject)& IObject, + const int& theIndex, vtkActor* theActor ); + void setCellData(const Handle(SALOME_InteractiveObject)& IObject, + const std::vector& theIndexes, vtkActor* theActor ); + void setEdgeData(const Handle(SALOME_InteractiveObject)& IObject, + const int& theCellIndex, const int& theEdgeIndex, + vtkActor* theActor ); //NB + void setPointData(const Handle(SALOME_InteractiveObject)& IObject, + const int& theIndex, vtkActor* theActor ); // Displaymode management int GetDisplayMode(); @@ -167,6 +180,7 @@ public: void Display(const Handle(SALOME_InteractiveObject)& IObject, bool immediatly=true); void Display( SALOME_Actor* SActor, bool immediatly = true ); + void Erase( SALOME_Actor* SActor, bool immediatly = true ); // Transparency void SetTransparency(const Handle(SALOME_InteractiveObject)& IObject,float trans); @@ -196,6 +210,9 @@ public: bool highlight(const Handle(SALOME_InteractiveObject)& IObject, const TColStd_MapOfInteger& MapIndex, TCreateMapperFun theFun, vtkActor *theActor, bool hilight, bool update ); + void setActorData(const Handle(SALOME_InteractiveObject)& IObject, + const TColStd_MapOfInteger& MapIndex, TCreateMapperFun theFun, + vtkActor *theActor ); // Timer used during various mouse events to figure // out mouse movements. @@ -205,7 +222,7 @@ public: int displaymode; //NRI: Selection mode - int selectionmode; + Selection_Mode selectionmode; vtkActor* Point_Actor; vtkActor* Edge_Actor; //NB vtkActor* Cell_Actor; @@ -243,6 +260,8 @@ public: private: QWidget* myGUIWindow; + double myTolNodes; + double myTolItems; }; #endif diff --git a/src/VTKViewer/VTKViewer_Trihedron.cxx b/src/VTKViewer/VTKViewer_Trihedron.cxx index be2d18894..9a278d4a6 100644 --- a/src/VTKViewer/VTKViewer_Trihedron.cxx +++ b/src/VTKViewer/VTKViewer_Trihedron.cxx @@ -63,6 +63,7 @@ public: protected: VTKViewer_UnScaledActor(); + ~VTKViewer_UnScaledActor(){} int mySize; }; @@ -82,8 +83,12 @@ void VTKViewer_UnScaledActor::Render(vtkRenderer *theRenderer){ float aWinDiag = sqrt(float(aSize[0]*aSize[0]+aSize[1]*aSize[1])); vtkDataSet* aDataSet = GetMapper()->GetInput(); float aLength = aDataSet->GetLength(); + float aPrecision = 1.0E-3; + float anOldScale = GetScale()[0]; float aScale = mySize*aWorldDiag/aWinDiag/aLength*sqrt(float(aSize[0])/float(aSize[1])); - SetScale(aScale); + if(fabs(aScale - anOldScale)/aScale > aPrecision){ + SetScale(aScale); + } } vtkFollower::Render(theRenderer); } @@ -94,6 +99,50 @@ void VTKViewer_UnScaledActor::SetSize(int theSize){ //============================================================================== +class VTKViewer_LineActor: public vtkFollower{ + VTKViewer_LineActor(const VTKViewer_LineActor&); + +public: + vtkTypeMacro(VTKViewer_LineActor,vtkFollower); + static VTKViewer_LineActor *New(); + + void SetLabelActor(VTKViewer_UnScaledActor* theLabelActor); + void SetArrowActor(VTKViewer_UnScaledActor* theLabelActor); + virtual void Render(vtkRenderer *theRenderer); + +protected: + VTKViewer_LineActor(){ + LabelActor = NULL; + ArrowActor = NULL; + } + ~VTKViewer_LineActor(){ + SetLabelActor(NULL); + SetArrowActor(NULL); + } + + VTKViewer_UnScaledActor* LabelActor; + VTKViewer_UnScaledActor* ArrowActor; +}; + +vtkStandardNewMacro(VTKViewer_LineActor); + +vtkCxxSetObjectMacro(VTKViewer_LineActor,LabelActor,VTKViewer_UnScaledActor); +vtkCxxSetObjectMacro(VTKViewer_LineActor,ArrowActor,VTKViewer_UnScaledActor); + +void VTKViewer_LineActor::Render(vtkRenderer *theRenderer){ + if(LabelActor && LabelActor->GetVisibility()){ + LabelActor->Modified(); + LabelActor->Render(theRenderer); + } + if(ArrowActor && ArrowActor->GetVisibility()){ + ArrowActor->Modified(); + ArrowActor->Render(theRenderer); + } + vtkFollower::Render(theRenderer); +} + +//============================================================================== + // The base class for concreate Axis // Its only duty is to give correct initialization and destruction // of its pipe-lines @@ -106,9 +155,10 @@ protected: vtkTypeMacro(VTKViewer_Axis,vtkObject); virtual void AddToRender(vtkRenderer* theRenderer){ + //Order of the calls are important + theRenderer->AddActor(myLineActor); theRenderer->AddActor(myLabelActor); theRenderer->AddActor(myArrowActor); - theRenderer->AddActor(myLineActor); } virtual void SetVisibility(VTKViewer_Trihedron::TVisibility theVis); @@ -140,7 +190,8 @@ protected: VTKViewer_Trihedron::TVisibility myVisibility; float myDir[3], myRot[3]; - vtkActor *myLineActor; + VTKViewer_LineActor *myLineActor; + //vtkActor *myLineActor; VTKViewer_UnScaledActor *myArrowActor; VTKViewer_UnScaledActor *myLabelActor; @@ -158,7 +209,7 @@ VTKViewer_Axis::VTKViewer_Axis(){ myMapper[0] = vtkPolyDataMapper::New(); myMapper[0]->SetInput(myLineSource->GetOutput()); - myLineActor = vtkActor::New(); + myLineActor = VTKViewer_LineActor::New(); myLineActor->SetMapper(myMapper[0]); myLineActor->PickableOff(); @@ -176,6 +227,8 @@ VTKViewer_Axis::VTKViewer_Axis(){ myArrowActor->SetSize(aArrowActorSize); myArrowActor->PickableOff(); + myLineActor->SetArrowActor(myArrowActor); + // Initialize the Label pipe-line representation myVectorText = VTKViewer_VectorText::New(); @@ -187,6 +240,9 @@ VTKViewer_Axis::VTKViewer_Axis(){ static int aLabelActorSize = 12; myLabelActor->SetSize(aLabelActorSize); myLabelActor->PickableOff(); + //myLabelActor->DebugOn(); + + myLineActor->SetLabelActor(myLabelActor); // Initialise visibility param. myVisibility = VTKViewer_Trihedron::eOn; @@ -379,12 +435,3 @@ int VTKViewer_Trihedron::GetVisibleActorCount(vtkRenderer* theRenderer){ //SetVisibility(aVis); return aCount; } - -void VTKViewer_Trihedron::Render(vtkRenderer* theRenderer){ - for(int i = 0; i < 3; i++) - { - myAxis[i]->GetLabel()->Render(theRenderer); - myAxis[i]->GetArrow()->Render(theRenderer); - } -} - diff --git a/src/VTKViewer/VTKViewer_Trihedron.h b/src/VTKViewer/VTKViewer_Trihedron.h index 056ea158f..d53a602c3 100644 --- a/src/VTKViewer/VTKViewer_Trihedron.h +++ b/src/VTKViewer/VTKViewer_Trihedron.h @@ -58,8 +58,6 @@ class VTKViewer_Trihedron : public vtkObject{ virtual int GetVisibleActorCount(vtkRenderer* theRenderer); - virtual void Render(vtkRenderer *theRenderer); - protected: vtkActorCollection* myPresent; VTKViewer_Axis* myAxis[3]; diff --git a/src/VTKViewer/VTKViewer_Utilities.cxx b/src/VTKViewer/VTKViewer_Utilities.cxx index ce64a1e4c..b8b61997f 100644 --- a/src/VTKViewer/VTKViewer_Utilities.cxx +++ b/src/VTKViewer/VTKViewer_Utilities.cxx @@ -52,7 +52,7 @@ void ResetCamera(vtkRenderer* theRenderer, int theUsingZeroFocalPoint){ if ( theRenderer->GetActiveCamera() != NULL ) theRenderer->GetActiveCamera()->GetViewPlaneNormal(vn); else{ - INFOS("Trying to reset non-existant camera"); + MESSAGE("Trying to reset non-existant camera"); return; } diff --git a/src/VTKViewer/VTKViewer_ViewFrame.cxx b/src/VTKViewer/VTKViewer_ViewFrame.cxx index 8f9e8e286..b68158db7 100644 --- a/src/VTKViewer/VTKViewer_ViewFrame.cxx +++ b/src/VTKViewer/VTKViewer_ViewFrame.cxx @@ -34,7 +34,6 @@ #include "SALOME_Transform.h" #include "SALOME_TransformFilter.h" -#include "SALOME_PassThroughFilter.h" #include "SALOME_GeometryFilter.h" #include "QAD_Settings.h" @@ -168,10 +167,10 @@ void VTKViewer_ViewFrame::onAdjustTrihedron(){ float aSize = m_Triedron->GetSize(); float aNewSize = aLength*aSizeInPercents/100.0; // if the new trihedron size have sufficient difference, then apply the value - if(fabs(aNewSize-aSize) > aSize*EPS_SIZE || fabs(aNewSize-aSize) > aNewSize*EPS_SIZE) + if(fabs(aNewSize-aSize) > aSize*EPS_SIZE || fabs(aNewSize-aSize) > aNewSize*EPS_SIZE){ m_Triedron->SetSize(aNewSize); + } } - m_Triedron->Render(m_Renderer); ::ResetCameraClippingRange(m_Renderer); } @@ -350,7 +349,7 @@ QColor VTKViewer_ViewFrame::backgroundColor() const } -void VTKViewer_ViewFrame::SetSelectionMode( int mode ) +void VTKViewer_ViewFrame::SetSelectionMode( Selection_Mode mode ) { m_RWInteractor->SetSelectionMode( mode ); } @@ -371,31 +370,33 @@ void VTKViewer_ViewFrame::highlight( const Handle(SALOME_InteractiveObject)& IOb { QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); SALOME_Selection* Sel = SALOME_Selection::Selection( ActiveStudy->getSelection() ); - if ( Sel->SelectionMode() == 4 ) - m_RWInteractor->highlight(IObject, highlight, update); - else if ( Sel->SelectionMode() == 3 ) { - m_RWInteractor->highlight(IObject, highlight, update); + m_RWInteractor->highlight(IObject, highlight, update); + + switch (Sel->SelectionMode()) { + case NodeSelection: if ( Sel->HasIndex( IObject ) ) { TColStd_MapOfInteger MapIndex; Sel->GetIndex( IObject, MapIndex ); - m_RWInteractor->highlightCell(IObject, highlight, MapIndex, update); + m_RWInteractor->highlightPoint(IObject, highlight, MapIndex, update); } - } - else if ( Sel->SelectionMode() == 2 ) { - m_RWInteractor->highlight(IObject, highlight, update); + break; + case EdgeOfCellSelection: if ( Sel->HasIndex( IObject ) ) { TColStd_MapOfInteger MapIndex; Sel->GetIndex( IObject, MapIndex ); m_RWInteractor->highlightEdge(IObject, highlight, MapIndex, update); } - } - else if ( Sel->SelectionMode() == 1 ) { - m_RWInteractor->highlight(IObject, highlight, update); + break; + case CellSelection: + case EdgeSelection: + case FaceSelection: + case VolumeSelection: if ( Sel->HasIndex( IObject ) ) { TColStd_MapOfInteger MapIndex; Sel->GetIndex( IObject, MapIndex ); - m_RWInteractor->highlightPoint(IObject, highlight, MapIndex, update); + m_RWInteractor->highlightCell(IObject, highlight, MapIndex, update); } + break; } } @@ -621,5 +622,3 @@ void VTKViewer_ViewFrame::RemoveActor( SALOME_Actor* theActor, bool update /*=fa theActor->RemoveFromRender(m_Renderer); if(update) Repaint(); } - - diff --git a/src/VTKViewer/VTKViewer_ViewFrame.h b/src/VTKViewer/VTKViewer_ViewFrame.h index 83fc35ab1..5547699fa 100644 --- a/src/VTKViewer/VTKViewer_ViewFrame.h +++ b/src/VTKViewer/VTKViewer_ViewFrame.h @@ -58,7 +58,7 @@ class QAD_EXPORT VTKViewer_ViewFrame : public QAD_ViewFrame{ void setBackgroundColor( const QColor& ); QColor backgroundColor() const; - void SetSelectionMode( int mode ); + void SetSelectionMode( Selection_Mode mode ); /* popup management */ void setPopupServer( QAD_Application* );