-THIS IS SALOME - KERNEL VERSION: 1.4.0
+THIS IS SALOME - KERNEL VERSION: 1.4.1
#!/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
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"
# 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.
-#!/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} <<EOF
+ORBInitRef NameService=corbaname::`hostname`:${NSPORT}
+EOF
+ echo ${NSPORT} - Ok
+ break
+ fi
+ echo -n "${NSPORT}; "
+done
+
+if [ $# -ne 0 ] ; then
+ python ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py $*
+else
+ python ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py
+fi
+
+#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --gui --modules=GEOM --xterm --containers=cpp,python --killall
+#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --xterm --containers=cpp,python --killall
#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --logger --xterm
#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --modules=GEOM,SMESH,VISU,SUPERV,MED
#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --help
#!/usr/bin/env python
-usage="""USAGE: runSalome.py [options]
-
-[command line options] :
---help : affichage de l'aide
---gui : lancement du GUI
---logger : redirection des messages dans un fichier
---xterm : les serveurs ouvrent une fenêtre xterm et les messages sont affichés dans cette fenêtre
---modules=module1,module2,... : où modulen est le nom d'un module Salome à charger dans le catalogue
---containers=cpp,python,superv: lancement des containers cpp, python et de supervision
---killall : arrêt des serveurs de salome
-
- La variable d'environnement <modulen>_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 <module>_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
# -----------------------------------------------------------------------------
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):
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 + "; "
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
#
# Lancement Session Loader
#
- if with_gui:
+ if args['gui']:
SessionLoader().run()
#
# (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
#
cataServer=CatalogServer()
- cataServer.setpath(liste_modules)
+ cataServer.setpath(modules_list)
cataServer.run()
#
# 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")
#
#
# Lancement Container C++ local
#
- if with_container_cpp:
+ if 'cpp' in args['containers']:
ContainerCPPServer().run()
#
# Lancement Container Python local
#
- if with_container_python:
+ if 'python' in args['containers']:
ContainerPYServer().run()
#
clt.waitNS("/Containers/" + theComputer + "/FactoryServerPy")
- if with_container_superv:
+ if 'superv' in args['containers']:
#
# Lancement Container Supervision local
# -----------------------------------------------------------------------------
#
+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()
srcdir=@srcdir@
VPATH=.:@srcdir@
-SUBDIRS=html DevelopersGuide
+SUBDIRS= salome
-doc:
+@COMMENCE@
+
+docs:
@@SETX@; for d in $(SUBDIRS); do \
(cd $$d && $(MAKE) $@) || exit 1; \
done
@@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
top_srcdir=@top_srcdir@
top_builddir=..
srcdir=@srcdir@
-VPATH=.:$(srcdir)
+VPATH=.
@COMMENCE@
PY_CLIENT_IDL = $(IDL_FILES)
# we copy all idl file in $(top_builddir)/idl
-inc: $(IDL_FILES:%=$(top_builddir)/idl/%)
+inc: $(top_builddir)/idl/salome $(IDL_FILES:%=$(top_builddir)/idl/salome/%)
-$(IDL_FILES:%=$(top_builddir)/idl/%):$(top_builddir)/idl/%:%
+$(top_builddir)/idl/salome:
+ mkdir $@
+
+$(IDL_FILES:%=$(top_builddir)/idl/salome/%):$(IDL_FILES:%=$(top_srcdir)/idl/%)
# $(CP) $< $@
- cp -f $< $@
+ cp -f $^ $(top_builddir)/idl/salome
lib: pyidl
$(PYTHON_BUILD_SITE):
$(INSTALL) -d $@
-$(PYTHON_BUILD_SITE)/%_idl.py: %.idl
+$(PYTHON_BUILD_SITE)/%_idl.py: $(top_builddir)/idl/salome/%.idl
$(OMNIORB_IDL) $(OMNIORB_IDLPYFLAGS) -C$(PYTHON_BUILD_SITE) $<
install: install-pyidl install-idl
# create directory $(idldir) and copy idl files into it
-install-idl: $(IDL_FILES)
+install-idl: $(IDL_FILES:%=$(top_builddir)/idl/salome/%)
$(INSTALL) -d $(idldir)
- cp -p $^ $(idldir)
+ cp -p -f $^ $(idldir)
-install-pyidl: $(IDL_FILES)
+install-pyidl: $(IDL_FILES:%=$(top_builddir)/idl/salome/%)
$(INSTALL) -d $(PYTHON_SITE_INSTALL)
@for file in $^ dummy; do \
if [ $$file != "dummy" ]; then \
distclean:
-$(RM) *.py
- -$(RM) $(IDL_FILES:%=$(top_builddir)/idl/%)
+ -$(RM) $(IDL_FILES:%=$(top_builddir)/idl/salome/%)
-$(RM) Makefile
*/
SObject FindObjectID (in ID aObjectID);
+/*!
+ Allows to create a %SObject by its ID
+ \param aObjectID This parameter defines the ID of the required object
+ \return The created %SObject
+
+*/
+ SObject CreateObjectID (in ID aObjectID);
/*!
Allows to find a %SObject by IOR of the object belonging to this %SObject.
\param anObjectName This parameter defines the IOR of the object
*/
Callback SetOnRemoveSObject(in Callback theCallback);
+/*!
+ Puts name attribute with the given string value to the given %SObject
+
+ \param theSO Existing SObject to set name attribute.
+ \param theValue The value to be set to the name attribute.
+*/
+ void SetName(in SObject theSO, in string theValue) raises (LockProtection);
+
+/*!
+ Puts comment attribute with the given string value to the given %SObject
+
+ \param theSO Existing SObject to set comment attribute.
+ \param theValue The value to be set to the comment attribute.
+*/
+ void SetComment(in SObject theSO, in string theValue) raises (LockProtection);
+
+/*!
+ Puts IOR attribute with the given string value to the given %SObject
+
+ \param theSO Existing SObject to set IOR attribute.
+ \param theValue The value to be set to the IOR attribute.
+*/
+ void SetIOR(in SObject theSO, in string theValue) raises (LockProtection);
};
//==========================================================================
/return The study containing the given %SObject.
*/
Study GetStudy();
+
+/*! Gets the CORBA object by its own IOR attribute.
+ Returns nil, if can't.
+
+ /return The CORBA object of the %SObject.
+*/
+ Object GetObject();
+
+/*!
+ Returns the name attribute value of this SObject.
+ Returns empty string if there is no name attribute.
+*/
+ string GetName();
+
+/*!
+ Returns the comment attribute value of this SObject.
+ Returns empty string if there is no comment attribute.
+*/
+ string GetComment();
+
+/*!
+ Returns the IOR attribute value of this SObject.
+ Returns empty string if there is no IOR attribute.
+*/
+ string GetIOR();
};
\note <BR>This exception is raised only outside a transaction.
*/
void CheckLocked() raises (LockProtection);
+
+ string Store();
+
+ void Restore(in string theData);
+
+ string Type();
+
+ SObject GetSObject();
};
Attribute allowing to store a real value
*/
//==========================================================================
+
interface AttributeReal : GenericAttribute
{
/*!
<BR><VAR>See also <A href=exemple/Example1.html> an example </A> of this method usage in batchmode of %SALOME application.</VAR>
*/
void SetValue(in double value);
+
};
//==========================================================================
/*! \brief Attribute allowing to store an integer value
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
ListOfServicesParameter ServiceinParameter; /*!< List of input parameters of the services.*/
ListOfServicesParameter ServiceoutParameter; /*!< List of output parameters of the services.*/
boolean Servicebydefault; /*!<True if the service is taken with its defult fields.*/
+ boolean TypeOfNode; /*!<True is the service is a factory node. Otherwise, it's a compute node.*/
} ;
/*!
List of services of the interface.
Sets/gets the icone of the component (for IAPP)
*/
readonly attribute string component_icone;
+
+/*!
+Sets/gets the implementation type of the component : C++ or Python (for IAPP)
+*/
+ readonly attribute boolean implementation_type;
} ;
+
/*! \brief %Module catalog interface
This interface is used for creation of the module catalog in %SALOME application.
VPATH=.:$(srcdir)/salome_adm
-all:
- cp -rf @top_srcdir@/salome_adm @prefix@
+all: resources
-install: all
+install:
+ cp -rf @top_srcdir@/salome_adm @prefix@
bin:
resources :
+ cp -rf @top_srcdir@/salome_adm @top_builddir@
inc:
Kernel_ok=no
AC_ARG_WITH(kernel,
- [ --with-kernel=DIR root directory path of KERNEL installation ],
+ [ --with-kernel=DIR root directory path of KERNEL build or installation],
KERNEL_DIR="$withval",KERNEL_DIR="")
if test "x$KERNEL_DIR" == "x" ; then
else
AC_MSG_WARN("Cannot find compiled Kernel module distribution")
fi
-
+
AC_MSG_RESULT(for Kernel: $Kernel_ok)
])dnl
dnl cascade headers
CPPFLAGS_old="$CPPFLAGS"
- CPPFLAGS="$CPPFLAGS -DLIN -DLINTEL -DCSFDB -DNO_CXX_EXCEPTION -DNo_exception -I$CASROOT/inc -Wno-deprecated"
+ CPPFLAGS="$CPPFLAGS -DLIN -DLINTEL -DCSFDB -DNO_CXX_EXCEPTION -DNo_exception -DHAVE_CONFIG_H -DHAVE_LIMITS_H -I$CASROOT/inc -Wno-deprecated -DHAVE_WOK_CONFIG_H"
CXXFLAGS_old="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -funsigned-char"
if test "x$occ_ok" = xyes ; then
- CAS_CPPFLAGS="-DOCC_VERSION_MAJOR=$OCC_VERSION_MAJOR -DLIN -DLINTEL -DCSFDB -DNO_CXX_EXCEPTION -DNo_exception -I$CASROOT/inc"
+ CAS_CPPFLAGS="-DOCC_VERSION_MAJOR=$OCC_VERSION_MAJOR -DLIN -DLINTEL -DCSFDB -DNO_CXX_EXCEPTION -DNo_exception -DHAVE_CONFIG_H -DHAVE_LIMITS_H -I$CASROOT/inc -DHAVE_WOK_CONFIG_H"
CAS_CXXFLAGS="-funsigned-char"
AC_MSG_CHECKING(for OpenCascade libraries)
LIBS="$LIBS -L$CASROOT/$casdir/lib -lTKernel"
AC_CACHE_VAL(salome_cv_lib_occ,[
AC_TRY_LINK(
+using namespace std;
#include <Standard_Type.hxx>
, size_t size;
const Standard_CString aName="toto";
CXXFLAGS = @CXXFLAGS@
CXX_DEPEND_FLAG = @CXX_DEPEND_FLAG@
+# BOOST Library
+
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+
# JAVA
JAVA_INCLUDES = @JAVA_INCLUDES@
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@
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@
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
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
# 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
@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 \
int argc , char* argv[] ) :
_numInstance(0)
{
+ _pid = (long)getpid();
ActSigIntHandler() ;
int flag )
: _numInstance(0)
{
+ _pid = (long)getpid();
string hostname = GetHostname();
SCRUTE(hostname);
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);
}
}
}
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 ;
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 += " " ;
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 {
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);
}
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() ;
}
}
}
catch (...) {
- MESSAGE( "Container_i::load_impl catched" ) ;
+ INFOS( "Container_i::load_impl catched" ) ;
}
//Jr _numInstanceMutex.lock() ; // lock on the add on handle_map (necessary ?)
exit(0) ;
}
else {
- INFOS(pthread_self() << "SigIntHandler activated") ;
+ MESSAGE(pthread_self() << "SigIntHandler activated") ;
}
}
<< " si_pid " << siginfo->si_pid) ;
if ( _Sleeping ) {
_Sleeping = false ;
- INFOS("SigIntHandler END sleeping.")
MESSAGE("SigIntHandler END sleeping.") ;
return ;
}
}
else {
_Sleeping = true ;
- INFOS("SigIntHandler BEGIN sleeping.")
MESSAGE("SigIntHandler BEGIN sleeping.") ;
int count = 0 ;
while( _Sleeping ) {
sleep( 1 ) ;
count += 1 ;
}
- INFOS("SigIntHandler LEAVE sleeping after " << count << " s.")
MESSAGE("SigIntHandler LEAVE sleeping after " << count << " s.") ;
}
return ;
}
}
+
+// 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()));
+}
#include <iostream>
#include <string>
#include "utilities.h"
+#include "Utils_CatchSignals.h"
using namespace std;
#ifdef CHECKTIME
MESSAGE("SALOME_Registry_Server.cxx - orb->run()");
timer.ShowAbsolute();
#endif
+ Utils_CatchSignals aCatch;
+ aCatch.Activate();
+
orb->run();
+ aCatch.Deactivate();
orb->destroy();
}
catch(CORBA::SystemException&)
if container is None:
MESSAGE( "SALOME_ContainerPy_i::start_impl " + str(containerName) + ".object exists but is not a Container" )
else :
- MESSAGE( "SALOME_ContainerPy_i::start_impl " + str(ContainerName) + ".object found without runSession" )
+ MESSAGE( "SALOME_ContainerPy_i::start_impl " + str(ContainerName) + ".object found without new launch" )
return container
#shstr = os.getenv( "PWD" ) + "/"
#shstr += "runSession ./SALOME_ContainerPy.py "
- shstr = "runSession SALOME_ContainerPy.py "
+ shstr = os.getenv("KERNEL_ROOT_DIR") + "/bin/salome/SALOME_ContainerPy.py ";
+ #shstr = "runSession SALOME_ContainerPy.py "
shstr += ContainerName
# mpv: fix for SAL4731 - allways create new file to write log of server
#include <map>
#include <string>
+using namespace std;
+
class SALOME_NamingService;
class Engines_Container_i: public POA_Engines::Container,
char* machineName();
void ping();
bool Kill_impl() ;
+ char* getHostName();
+ long getPID();
protected:
int _argc ;
char** _argv ;
+ long _pid;
};
using namespace std;
#include "SALOME_DataTypeCatalog_impl.hxx"
+#include "Utils_ExceptHandlers.hxx"
#include <fstream>
+UNEXPECT_CATCH(DTC_NotFound, SALOME_DataTypeCatalog::NotFound);
+
//----------------------------------------------------------------------
// Function : SALOME_DataTypeCatalogImpl
// Purpose : Constructor
const char* type_out)
throw(SALOME_DataTypeCatalog::NotFound)
{
-
+ Unexpect aCatch(DTC_NotFound);
CORBA::Boolean _return_value = false ;
bool _found_in = false;
bool _found_out = false;
SALOME_DataTypeCatalogImpl::GetDataInterfaceRead(const char* type)
throw(SALOME_DataTypeCatalog::NotFound)
{
+ Unexpect aCatch(DTC_NotFound);
char* return_value = NULL;
bool _find = false;
for (unsigned int ind=0; ind < _datatype_list.size();ind++)
SALOME_DataTypeCatalogImpl::GetDataInterfaceWrite(const char* type)
throw(SALOME_DataTypeCatalog::NotFound)
{
+ Unexpect aCatch(DTC_NotFound);
char* return_value = NULL;
bool _find = false;
for (unsigned int ind=0; ind < _datatype_list.size();ind++)
SALOME_DataTypeCatalog::ListOfDataTypeName*
SALOME_DataTypeCatalogImpl::GetDataTypeParents(const char* type) throw(SALOME_DataTypeCatalog::NotFound)
{
+ Unexpect aCatch(DTC_NotFound);
+
bool _find = false ;
SALOME_DataTypeCatalog::ListOfDataTypeName_var _list_data =
if (strcmp(argv[ind],"-help") == 0)
{
- INFOS( "Usage: " << argv[0] << " -common 'path to data type catalog' -ORBInitRef NameService=corbaname::localhost");
+ MESSAGE( "Usage: " << argv[0] << " -common 'path to data type catalog' -ORBInitRef NameService=corbaname::localhost");
_return_value = false ;
}
if (strcmp(argv[ind],"-common") == 0)
using namespace SALOME;
GenericObj_i::GenericObj_i(PortableServer::POA_ptr thePOA): myRefCounter(1){
- INFOS("GenericObj_i::GenericObj_i() - this = "<<this<<
+ MESSAGE("GenericObj_i::GenericObj_i() - this = "<<this<<
"; CORBA::is_nil(thePOA) = "<<CORBA::is_nil(thePOA));
if(CORBA::is_nil(thePOA))
myPOA = PortableServer::RefCountServantBase::_default_POA();
void GenericObj_i::Register(){
- INFOS("GenericObj_i::Register "<<this<<"; myRefCounter = "<<myRefCounter)
+ MESSAGE("GenericObj_i::Register "<<this<<"; myRefCounter = "<<myRefCounter)
++myRefCounter;
}
void GenericObj_i::Destroy(){
- INFOS("GenericObj_i::Destroy "<<this<<"; myRefCounter = "<<myRefCounter)
+ MESSAGE("GenericObj_i::Destroy "<<this<<"; myRefCounter = "<<myRefCounter)
if(--myRefCounter <= 0){
PortableServer::ObjectId_var anObjectId = myPOA->servant_to_id(this);
myPOA->deactivate_object(anObjectId.in());
#include "HDFfile.hxx"
#include <string>
+using namespace std;
+
class HDFConvert
{
private:
/* Exception */
#include <iostream>
+using namespace std;
+
class HDFexception
{
public :
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
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 )
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")
#-------------------------------------------------------------------------
path = Catalog->GetPathPrefix( theComputer );
}
catch (SALOME_ModuleCatalog::NotFound&) {
- MESSAGE("GetPathPrefix(" << theComputer << ") not found!");
+ INFOS("GetPathPrefix(" << theComputer << ") not found!");
path = "" ;
}
SCRUTE( path ) ;
SCRUTE( rsh );
int status = system( rsh.c_str() ) ;
if (status == -1) {
- INFOS("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status -1)") ;
+ MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status -1)") ;
}
else if (status == 217) {
- INFOS("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status 217)") ;
+ MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status 217)") ;
}
else {
int count = 21 ;
aFactoryServer = FindContainer( FactoryServer.c_str() ) ;
}
if ( CORBA::is_nil( aFactoryServer ) ) {
- INFOS("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed") ;
+ MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed") ;
}
else if ( strcmp( theComputer.c_str() , GetHostname().c_str() ) ) {
_FactoryServer = aFactoryServer ;
}
catch (SALOME_ModuleCatalog::NotFound&)
{
- MESSAGE("GetPathPrefix(" << machine << ") not found!"
+ INFOS("GetPathPrefix(" << machine << ") not found!"
<< "trying localhost");
try {
path = compoInfo->GetPathPrefix("localhost") ;
path += "/" ;
}
catch (SALOME_ModuleCatalog::NotFound&) {
- MESSAGE("GetPathPrefix(localhost) not found!") ;
+ INFOS("GetPathPrefix(localhost) not found!") ;
path = "" ;
}
}
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);
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 :
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() ;
}
@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 \
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
CORBA::Boolean componentmultistudy,
const char* icone,
SALOME_ModuleCatalog::ListOfDefInterface list_interfaces,
- ListOfPathPrefix pathes)
+ ListOfPathPrefix pathes,
+ CORBA::Boolean implementationtype)
{
MESSAGE("Component creation")
// Affect component name
// Affect component multistudy
_componentmultistudy = componentmultistudy;
+
+ // Affect component implementation
+ _implementationtype = implementationtype;
// Affect icone
_icone =new char[strlen(icone)+1];
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
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
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 ;
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
throw(SALOME_ModuleCatalog::NotFound)
{
MESSAGE("Begin of GetPathPrefix")
+ Unexpect aCatch( MC_NotFound );
// Variables initialisation
char* _path = NULL;
bool _find = false ;
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
_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();
CORBA::Boolean componentmultistudy,
const char* icone,
SALOME_ModuleCatalog::ListOfDefInterface list_interfaces,
- ListOfPathPrefix pathes);
+ ListOfPathPrefix pathes,
+ CORBA::Boolean implementationtype);
//! standard destructor
virtual ~SALOME_ModuleCatalog_AcomponentImpl();
*/
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 ;
char* _icone;
SALOME_ModuleCatalog::ComponentType _componenttype;
CORBA::Boolean _componentmultistudy;
+ CORBA::Boolean _implementationtype;
SALOME_ModuleCatalog::ListOfDefInterface _list_interfaces;
ListOfPathPrefix _pathes ;
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";
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 ;
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
// Empty temporary structures
_aService.ParserServiceName = "";
+ _aService.ParserTypeOfNode = 1;
_aService.ParserServiceinParameter.resize(0);
_aService.ParserServiceoutParameter.resize(0);
}
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;
ListOfParserServicesParameter ParserServiceinParameter;
ListOfParserServicesParameter ParserServiceoutParameter;
bool ParserServicebydefault;
+ bool ParserTypeOfNode;
} ;
typedef vector<ParserService> ListOfParserServices ;
string Parsercomponenticone;
ListOfDefinitionInterface ParserListInterface;
string Parserconstraint ;
+ bool Parsercomponentimpltype ;
};
typedef vector<ParserComponent> ListOfParserComponent ;
}
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))
{
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))
{
CORBA::Boolean _componentmultistudy = false ; // default initialisation
ListOfPathPrefix _pathes ;
_pathes.resize(0);
+ CORBA::Boolean _implementationtype = true ; // default initialisation
bool find = false ;
// get pathes prefix
_pathes = duplicate_pathes(_personal_path_list);
+ // get implementation type
+ _implementationtype = _personal_module_list[ind].Parsercomponentimpltype;
}
}
_componentmultistudy,
_icone,
_list_interfaces,
- _pathes);
+ _pathes,
+ _implementationtype);
compo = aComponentImpl->_this();
}
// 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());
_componentmultistudy,
_icone,
_list_interfaces,
- _pathes);
+ _pathes,
+ _implementationtype);
compo = aComponentImpl->_this();
}
_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);
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)
"COMP_TYPE" : "",
"COMP_NAME" : "",
"COMP_UNAME" : "",
- "COMP_MULT" : ""
+ "COMP_MULT" : "",
+ "COMP_IMPL" : ""
}
nb_components = 0
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')
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')
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
Les scripts de test se trouvent dans le repertoire
- <SALOME_ROOT>/SALOME/src/ModuleGenerator/tests
+ <KERNEL_SRC>/src/ModuleGenerator/tests
Les fichiers idl servant aux tests se trouvent dans les repertoires
- <SALOME_ROOT>/idl
- <SALOME_ROOT>/SALOME/src/ModuleGenerator/tests
+ <KERNEL_SRC>/idl
+ <KERNEL_SRC>/src/ModuleGenerator/tests
_temp_context =
_current_context->bind_new_context(_context_name);
_current_context = _temp_context;
- //MESSAGE("This context was'nt created, it's now done");
+ //INFOS("This context was'nt created, it's now done");
}
}
}
_temp_context =
_current_context->bind_new_context(_context_name);
_current_context = _temp_context;
- MESSAGE("This context was'nt created, it's now done");
+ INFOS("This context was'nt created, it's now done");
}
}
}
_return_code = false;
CosNaming::Name n = ex.rest_of_name;
if (ex.why == CosNaming::NamingContext::missing_node)
- MESSAGE( "Change_Directory() : " << (char *) n[0].id
+ INFOS( "Change_Directory() : " << (char *) n[0].id
<< " (" << (char *) n[0].kind << ") not found")
if (ex.why == CosNaming::NamingContext::not_context)
- MESSAGE("Change_Directory() : " << (char *) n[0].id
+ INFOS("Change_Directory() : " << (char *) n[0].id
<< " (" << (char *) n[0].kind
<< ") is not a context" )
if (ex.why == CosNaming::NamingContext::not_object)
- MESSAGE( "Change_Directory() : " << (char *) n[0].id
+ INFOS( "Change_Directory() : " << (char *) n[0].id
<< " (" << (char *) n[0].kind
<< ") is not an object" )
}
catch(CosNaming::NamingContext::CannotProceed&)
{
_return_code = false;
- MESSAGE( "!!!Change_Directory() : CosNaming::NamingContext::CannotProceed" )
+ INFOS( "!!!Change_Directory() : CosNaming::NamingContext::CannotProceed" )
}
catch(CosNaming::NamingContext::InvalidName&)
{
_return_code = false;
- MESSAGE( "!!!Change_Directory() : CosNaming::NamingContext::InvalidName" )
+ INFOS( "!!!Change_Directory() : CosNaming::NamingContext::InvalidName" )
}
catch(CORBA::COMM_FAILURE&)
{
_return_code = false;
- MESSAGE( "!!!Change_Directory() :CORBA::COMM_FAILURE : unable to contact"
+ INFOS( "!!!Change_Directory() :CORBA::COMM_FAILURE : unable to contact"
<< "the naming service")
throw ServiceUnreachable();
}
}
catch(CORBA::COMM_FAILURE&)
{
- MESSAGE("!!!Current_Directory(): CORBA::COMM_FAILURE : unable to contact"
+ INFOS("!!!Current_Directory(): CORBA::COMM_FAILURE : unable to contact"
<< " the naming service" )
throw ServiceUnreachable();
}
}
catch (ServiceUnreachable&)
{
- MESSAGE( "!!!list(): ServiceUnreachable" )
+ INFOS( "!!!list(): ServiceUnreachable" )
throw ServiceUnreachable();
}
{
CosNaming::Name n = ex.rest_of_name;
if (ex.why == CosNaming::NamingContext::missing_node)
- MESSAGE( "Destroy_Name() : " << (char *) n[0].id
+ INFOS( "Destroy_Name() : " << (char *) n[0].id
<< " (" << (char *) n[0].kind << ") not found" )
if (ex.why == CosNaming::NamingContext::not_context)
- MESSAGE( "Destroy_Name() : " << (char *) n[0].id
+ INFOS( "Destroy_Name() : " << (char *) n[0].id
<< " (" << (char *) n[0].kind
<< ") is not a context" )
if (ex.why == CosNaming::NamingContext::not_object)
- MESSAGE( "Destroy_Name() : " << (char *) n[0].id
+ INFOS( "Destroy_Name() : " << (char *) n[0].id
<< " (" << (char *) n[0].kind
<< ") is not an object" )
}
catch (CosNaming::NamingContext::InvalidName &)
{
- MESSAGE( "!!!Destroy_Name() : CosNaming::NamingContext::InvalidName" )
+ INFOS( "!!!Destroy_Name() : CosNaming::NamingContext::InvalidName" )
}
catch (CosNaming::NamingContext::CannotProceed &)
{
- MESSAGE( "!!!Destroy_Name(): CosNaming::NamingContext::CannotProceed" )
+ INFOS( "!!!Destroy_Name(): CosNaming::NamingContext::CannotProceed" )
}
catch(CORBA::COMM_FAILURE&)
{
- MESSAGE( "!!!Destroy_Name() : CORBA::COMM_FAILURE : unable to contact"
+ INFOS( "!!!Destroy_Name() : CORBA::COMM_FAILURE : unable to contact"
<< " the naming service")
throw ServiceUnreachable();
}
{
CosNaming::Name n = ex.rest_of_name;
if (ex.why == CosNaming::NamingContext::missing_node)
- MESSAGE( "Destroy_Name() : " << (char *) n[0].id
+ INFOS( "Destroy_Name() : " << (char *) n[0].id
<< " (" << (char *) n[0].kind << ") not found" )
if (ex.why == CosNaming::NamingContext::not_context)
- MESSAGE( "Destroy_Name() : " << (char *) n[0].id
+ INFOS( "Destroy_Name() : " << (char *) n[0].id
<< " (" << (char *) n[0].kind
<< ") is not a context" )
if (ex.why == CosNaming::NamingContext::not_object)
- MESSAGE( "Destroy_Name() : " << (char *) n[0].id
+ INFOS( "Destroy_Name() : " << (char *) n[0].id
<< " (" << (char *) n[0].kind
<< ") is not an object" )
}
catch(CosNaming::NamingContext::CannotProceed&)
{
- MESSAGE( "!!!Destroy_Name() : CosNaming::NamingContext::CannotProceed")
+ INFOS( "!!!Destroy_Name() : CosNaming::NamingContext::CannotProceed")
}
catch(CosNaming::NamingContext::InvalidName&)
{
- MESSAGE( "!!!Destroy_Name() : CosNaming::NamingContext::InvalidName")
+ INFOS( "!!!Destroy_Name() : CosNaming::NamingContext::InvalidName")
}
catch(CORBA::COMM_FAILURE&)
{
- MESSAGE( "!!!Destroy_Name() :CORBA::COMM_FAILURE : unable to contact"
+ INFOS( "!!!Destroy_Name() :CORBA::COMM_FAILURE : unable to contact"
<< " the naming service")
throw ServiceUnreachable();
}
{
CosNaming::Name n = ex.rest_of_name;
if (ex.why == CosNaming::NamingContext::missing_node)
- MESSAGE( "Destroy_Directory() : " << (char *) n[0].id
+ INFOS( "Destroy_Directory() : " << (char *) n[0].id
<< " (" << (char *) n[0].kind << ") not found")
if (ex.why == CosNaming::NamingContext::not_context)
- MESSAGE( "Destroy_Directory() : " << (char *) n[0].id
+ INFOS( "Destroy_Directory() : " << (char *) n[0].id
<< " (" << (char *) n[0].kind
<< ") is not a context" )
if (ex.why == CosNaming::NamingContext::not_object)
- MESSAGE( "Destroy_Directory() : " << (char *) n[0].id
+ INFOS( "Destroy_Directory() : " << (char *) n[0].id
<< " (" << (char *) n[0].kind
<< ") is not an object" )
}
catch (CosNaming::NamingContext::InvalidName &)
{
- MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName" )
+ INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName" )
}
catch (CosNaming::NamingContext::CannotProceed &)
{
- MESSAGE("!!!Destroy_Directory(): CosNaming::NamingContext::CannotProceed" )
+ INFOS("!!!Destroy_Directory(): CosNaming::NamingContext::CannotProceed" )
}
catch(CORBA::COMM_FAILURE&)
{
- MESSAGE( "!!!Destroy_Directory() : CORBA::COMM_FAILURE : unable to contact"
+ INFOS( "!!!Destroy_Directory() : CORBA::COMM_FAILURE : unable to contact"
<< " the naming service" )
throw ServiceUnreachable();
}
{
CosNaming::Name n = ex.rest_of_name;
if (ex.why == CosNaming::NamingContext::missing_node)
- MESSAGE( "Destroy_Directory() : " << (char *) n[0].id
+ INFOS( "Destroy_Directory() : " << (char *) n[0].id
<< " (" << (char *) n[0].kind << ") not found" )
if (ex.why == CosNaming::NamingContext::not_context)
- MESSAGE( "Destroy_Directory() : " << (char *) n[0].id
+ INFOS( "Destroy_Directory() : " << (char *) n[0].id
<< " (" << (char *) n[0].kind
<< ") is not a context" )
if (ex.why == CosNaming::NamingContext::not_object)
- MESSAGE( "Destroy_Directory() : " << (char *) n[0].id
+ INFOS( "Destroy_Directory() : " << (char *) n[0].id
<< " (" << (char *) n[0].kind
<< ") is not an object" )
}
catch (CosNaming::NamingContext::InvalidName &)
{
- MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName" )
+ INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName" )
}
catch (CosNaming::NamingContext::CannotProceed &)
{
- MESSAGE( "!!!Destroy_Directory(): CosNaming::NamingContext::CannotProceed" )
+ INFOS( "!!!Destroy_Directory(): CosNaming::NamingContext::CannotProceed" )
}
catch(CORBA::COMM_FAILURE&)
{
- MESSAGE( "!!!Destroy_Directory() : CORBA::COMM_FAILURE : unable to contact"
+ INFOS( "!!!Destroy_Directory() : CORBA::COMM_FAILURE : unable to contact"
<< " the naming service" )
throw ServiceUnreachable();
}
}
catch(CosNaming::NamingContext::NotEmpty&)
{
- MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::NoEmpty "
+ INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::NoEmpty "
<< Path << " is not empty" )
}
catch(CORBA::COMM_FAILURE&)
{
- MESSAGE( "!!!Destroy_Directory() :CORBA::COMM_FAILURE : "
+ INFOS( "!!!Destroy_Directory() :CORBA::COMM_FAILURE : "
<< "unable to contact the naming service")
throw ServiceUnreachable();
}
{
CosNaming::Name n = ex.rest_of_name;
if (ex.why == CosNaming::NamingContext::missing_node)
- MESSAGE( "Destroy_Directory() : " << (char *) n[0].id
+ INFOS( "Destroy_Directory() : " << (char *) n[0].id
<< " (" << (char *) n[0].kind << ") not found" )
if (ex.why == CosNaming::NamingContext::not_context)
- MESSAGE( "Destroy_Directory() : " << (char *) n[0].id
+ INFOS( "Destroy_Directory() : " << (char *) n[0].id
<< " (" << (char *) n[0].kind
<< ") is not a context" )
if (ex.why == CosNaming::NamingContext::not_object)
- MESSAGE( "Destroy_Directory() : " << (char *) n[0].id
+ INFOS( "Destroy_Directory() : " << (char *) n[0].id
<< " (" << (char *) n[0].kind
<< ") is not an object" )
}
catch(CosNaming::NamingContext::CannotProceed&)
{
- MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::CannotProceed")
+ INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::CannotProceed")
}
catch(CosNaming::NamingContext::InvalidName&)
{
- MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName")
+ INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName")
}
catch(CORBA::COMM_FAILURE&)
{
- MESSAGE( "!!!Destroy_Directory() :CORBA::COMM_FAILURE : unable to contact"
+ INFOS( "!!!Destroy_Directory() :CORBA::COMM_FAILURE : unable to contact"
<< " the naming service")
throw ServiceUnreachable();
}
#include "SALOME_Actor.h"
#include "SALOME_Transform.h"
+#include "SALOME_GeometryFilter.h"
#include "SALOME_TransformFilter.h"
#include "SALOME_PassThroughFilter.h"
-#include "SALOME_GeometryFilter.h"
// SALOME Includes
#include "utilities.h"
#include <vtkObjectFactory.h>
#include <vtkDataSetMapper.h>
#include <vtkPolyDataMapper.h>
-#include <vtkTransformPolyDataFilter.h>
-
-// For test
-#include <vtkMapperCollection.h>
-#include "vtkTimerLog.h"
using namespace std;
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<vtkDataSetMapper*>(theMapper))
- aMapper->SetInput(myPassFilter[3]->GetPolyDataOutput());
+ aMapper->SetInput(myPassFilter.at(anId)->GetOutput());
else if(vtkPolyDataMapper* aMapper = dynamic_cast<vtkPolyDataMapper*>(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();
}
GetProperty()->DeepCopy(myProperty);
break;
default:
+ break;
GetProperty()->SetAmbient(1.0);
GetProperty()->SetDiffuse(0.0);
GetProperty()->SetSpecular(0.0);
}
switch(theMode){
case 3 :
- myPassFilter[0]->SetInside(true);
+ myGeomFilter->SetInside(true);
GetProperty()->SetRepresentation(1);
break;
case 0 :
GetProperty()->SetPointSize(SALOME_POINT_SIZE);
default :
GetProperty()->SetRepresentation(theMode);
- myPassFilter[0]->SetInside(false);
+ myGeomFilter->SetInside(false);
}
myRepresentation = theMode;
}
+
int SALOME_Actor::GetRepresentation(){
return myRepresentation;
}
-
-SALOME_Actor::SALOME_Actor(){
- PreviewProperty = NULL;
- ispreselected = Standard_False;
- myProperty = vtkProperty::New();
- myRepresentation = 2;
- myTransformFilter = SALOME_TransformFilter::New();
- myPassFilter.push_back(SALOME_PassThroughFilter::New());
- myPassFilter.push_back(SALOME_PassThroughFilter::New());
- myPassFilter.push_back(SALOME_PassThroughFilter::New());
- myPassFilter.push_back(SALOME_PassThroughFilter::New());
-}
-
-SALOME_Actor::~SALOME_Actor(){
- myTransformFilter->Delete();
- SetPreviewProperty(NULL);
- for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++)
- if(myPassFilter[i] != NULL){
- myPassFilter[i]->UnRegisterAllOutputs();
- myPassFilter[i]->Delete();
+//=================================================================================
+// function : GetObjDimension
+// purpose : Return object dimension.
+// Virtual method shoulb be redifined by derived classes
+//=================================================================================
+int SALOME_Actor::GetObjDimension( const int theObjId )
+{
+ if ( theObjId < 0 )
+ return 0;
+
+ std::vector<int> aVtkList = GetVtkId( theObjId );
+ int nbVtk = aVtkList.size();
+
+ if ( nbVtk == 0 )
+ return 0;
+ else if ( nbVtk > 1 )
+ return 3;
+ else // nbVtk = 1
+ {
+ if ( vtkDataSet* aGrid = GetMapper()->GetInput() )
+ {
+ if ( vtkCell* aCell = aGrid->GetCell( aVtkList.front() ) )
+ return aCell->GetCellDimension();
}
- myProperty->Delete();
+ }
+ return 0;
}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// SALOME Includes
#include "VTKViewer_Common.h"
#include "SALOME_InteractiveObject.hxx"
-#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
-#include "Handle_SALOME_InteractiveObject.hxx"
-#endif
-#include <vector.h>
+
+#include <vector>
class SALOME_Transform;
+class SALOME_GeometryFilter;
class SALOME_TransformFilter;
class SALOME_PassThroughFilter;
vtkTypeMacro(SALOME_Actor,vtkLODActor);
- // Description:
- // This causes the actor to be rendered. It, in turn, will render the actor`s
- // property and then mapper.
- //virtual void Render(vtkRenderer *, vtkMapper *);
-
- // Description:
- // This method is used internally by the rendering process.
- // We overide the superclass method to properly set the estimated render time.
- //virtual int RenderOpaqueGeometry(vtkViewport *viewport);
-
- // Description:
- // Release any graphics resources that are being consumed by this actor.
- // The parameter window could be used to determine which graphic
- // resources to release.
- //virtual void ReleaseGraphicsResources(vtkWindow *);
-
virtual Standard_Boolean hasIO() { return !myIO.IsNull(); }
virtual Handle_SALOME_InteractiveObject getIO() { return myIO; }
virtual void setIO(const Handle(SALOME_InteractiveObject)& io) { myIO = io; }
virtual void AddToRender(vtkRenderer* theRenderer);
virtual void RemoveFromRender(vtkRenderer* theRenderer);
- virtual vtkPolyData* GetPolyDataInput();
+ typedef std::vector<int> TVectorId;
+ virtual int GetObjId(int theVtkID) { return -1;}
+ virtual TVectorId GetVtkId(int theObjID) { return TVectorId();}
+
+ virtual int GetObjDimension( const int theObjId );
+
virtual void SetMapper(vtkMapper* theMapper);
- virtual void SetTransform(SALOME_Transform* theTransform);
+ virtual vtkPolyData* GetPolyDataInput();
+ virtual void SetTransform(SALOME_Transform* theTransform);
virtual unsigned long int GetMTime();
virtual void SetRepresentation(int theMode);
// Infinitive means actor without size (point for example
// which is not taken into account in calculation of boundaries of the scene
- virtual bool IsInfinitive() { return false; }
+ virtual bool IsInfinitive() { return myIsInfinite; }
protected:
vtkProperty *PreviewProperty;
Standard_Boolean ispreselected;
- Handle_SALOME_InteractiveObject myIO;
+ Handle(SALOME_InteractiveObject) myIO;
Standard_CString myName;
float m_opacity;
Standard_Boolean ishighlighted;
int myDisplayMode;
+ bool myIsInfinite;
- SALOME_Transform *myTransform;
- std::vector<SALOME_PassThroughFilter*> myPassFilter;
+ bool myStoreMapping;
+ SALOME_GeometryFilter *myGeomFilter;
SALOME_TransformFilter *myTransformFilter;
- vtkProperty *myProperty;
+ std::vector<SALOME_PassThroughFilter*> myPassFilter;
+
int myRepresentation;
+ vtkProperty *myProperty;
};
#endif // SALOME_ACTOR_H
#include "OCCViewer_ViewPort.h"
#include "QAD_ViewFrame.h"
+#include "SALOME_Selection.h"
class OCCViewer_Viewer3d;
class QAD_EXPORT OCCViewer_ViewFrame : public QAD_ViewFrame
void setCursor( const QCursor& );
QCursor cursor() const;
- void SetSelectionMode( int mode ) {};
+ void SetSelectionMode( Selection_Mode mode ) {};
/* popup management */
void setPopupServer( QAD_Application* );
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();
}
}
#include <qtoolbar.h>
#include <qtoolbutton.h>
#include <qcursor.h>
+#include <qcolordialog.h>
#include <qwt_math.h>
#include <qwt_plot_canvas.h>
#include <stdlib.h>
fitDataAction->setStatusTip ( tr( "PRP_PLOT2D_FITDATA" ) );
myActions.insert( FitDataId, fitDataAction );
connect( fitDataAction, SIGNAL( activated() ), this, SLOT( onFitData() ) );
+
+ // Change background
+ QActionP* changeBGAction = new QActionP ( tr( "TOT_PLOT2D_CHANGE_BACKGROUND"),
+ tr( "MEN_PLOT2D_CHANGE_BACKGROUND" ), 0, this );
+ fitDataAction->setStatusTip ( tr( "PRP_PLOT2D_CHANGE_BACKGROUND" ) );
+ myActions.insert( ChangeBackgroundId, changeBGAction );
+ connect( changeBGAction, SIGNAL( activated() ), this, SLOT( onChangeBackground() ) );
}
/*!
Gets window's central widget
// settings
myPopup->insertSeparator();
myActions[ SettingsId ]->addTo( myPopup );
+ // Change background
+ myPopup->insertSeparator();
+ myActions[ ChangeBackgroundId ]->addTo( myPopup );
}
}
/*!
*/
QString Plot2d_ViewFrame::getInfo( const QPoint& pnt )
{
- QString info;
- info.sprintf( "X : %g\tY : %g",
- myPlot->invTransform( QwtPlot::xBottom, pnt.x() ),
- myPlot->invTransform( QwtPlot::yLeft, pnt.y() ) );
- info = tr( "INF_COORDINATES" ) + " : " + info;
+ bool xFound = false, yFound = false;
+ double xCoord, yCoord;
+ const QwtScaleDiv* aXscale = myPlot->axisScale( QwtPlot::xBottom );
+ for ( int i = 0; i < aXscale->majCnt(); i++ ) {
+ double majXmark = aXscale->majMark( i );
+ int xmark = myPlot->transform( QwtPlot::xBottom, majXmark );
+ if ( xmark-2 == pnt.x() ) {
+ xCoord = majXmark;
+ xFound = true;
+ MESSAGE("Plot2d_ViewFrame::getInfo : close maj X mark("<<i<<") = "<<majXmark<<" "<<xmark<<" "<<pnt.x());
+ break;
+ }
+ }
+ if ( !xFound ) {
+ for ( int i = 0; i < aXscale->minCnt(); i++ ) {
+ double minXmark = aXscale->minMark( i );
+ int xmark = myPlot->transform( QwtPlot::xBottom, minXmark );
+ if ( xmark-2 == pnt.x() ) {
+ xCoord = minXmark;
+ xFound = true;
+ MESSAGE("Plot2d_ViewFrame::getInfo : close min X mark("<<i<<") = "<<minXmark<<" "<<xmark<<" "<<pnt.x());
+ break;
+ }
+ }
+ }
+ const QwtScaleDiv* aYscale = myPlot->axisScale( QwtPlot::yLeft );
+ for ( int i = 0; i < aYscale->majCnt(); i++ ) {
+ double majYmark = aYscale->majMark( i );
+ int ymark = myPlot->transform( QwtPlot::yLeft, majYmark );
+ if ( ymark-2 == pnt.y() ) {
+ yCoord = majYmark;
+ yFound = true;
+ break;
+ }
+ }
+ if ( !yFound ) {
+ for ( int i = 0; i < aYscale->minCnt(); i++ ) {
+ double minYmark = aYscale->minMark( i );
+ int ymark = myPlot->transform( QwtPlot::yLeft, minYmark );
+ if ( ymark-2 == pnt.y() ) {
+ yCoord = minYmark;
+ yFound = true;
+ break;
+ }
+ }
+ }
+ QString strX = QString::number( xFound ? xCoord : myPlot->invTransform( QwtPlot::xBottom, pnt.x() ) ).stripWhiteSpace();
+ if ( strX == "-0" )
+ strX = "0";
+ QString strY = QString::number( yFound ? yCoord : myPlot->invTransform( QwtPlot::yLeft, pnt.y() ) ).stripWhiteSpace();
+ if ( strY == "-0" )
+ strY = "0";
+ QString info = tr("INF_COORDINATES").arg( strX ).arg( strY );
return info;
}
/*!
}
delete dlg;
}
+/*!
+ Change background color
+*/
+void Plot2d_ViewFrame::onChangeBackground()
+{
+ QColor selColor = QColorDialog::getColor ( backgroundColor(), this );
+ if ( selColor.isValid() ) {
+ setBackgroundColor( selColor );
+ }
+}
/*!
Sets curve type
*/
#include "QAD_Action.h"
#include "Plot2d_Curve.h"
#include "Plot2d_CurveContainer.h"
+#include "SALOME_Selection.h"
#include <qmainwindow.h>
#include <qmap.h>
#include <qintdict.h>
enum { NoOpId, FitAllId, FitAreaId, ZoomId, PanId, DumpId,
ModeXLinearId, ModeXLogarithmicId, ModeYLinearId, ModeYLogarithmicId,
- LegendId, CurvePointsId, CurveLinesId, CurveSplinesId, SettingsId, FitDataId };
+ LegendId, CurvePointsId, CurveLinesId, CurveSplinesId, SettingsId, FitDataId, ChangeBackgroundId };
public:
/* Construction/destruction */
Plot2d_ViewFrame( QWidget* parent, const QString& title = "" );
/* inherited */
ViewType getTypeView() const { return VIEW_PLOT2D; }
QWidget* getViewWidget();
- void SetSelectionMode( int mode ) {}
+ void SetSelectionMode( Selection_Mode mode ) {}
void onAdjustTrihedron( ) {}
/* popup management */
void onCurves();
void onSettings();
void onFitData();
+ void onChangeBackground();
protected slots:
void onLegendClicked( long key );
# include <map>
+using namespace std;
class RegistryService : public POA_Registry::Components //, public PortableServer::RefCountServantBase
{
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() ) {
}
catch( CORBA::COMM_FAILURE& )
{
- MESSAGE( "Ressources Catalog: CORBA::COMM_FAILURE: Unable to contact the Naming Service" );
+ INFOS( "Ressources Catalog: CORBA::COMM_FAILURE: Unable to contact the Naming Service" );
}
if(!CORBA::is_nil(inc))
{
}
catch(CosNaming::NamingContext::NotFound)
{
- MESSAGE( "Ressources Catalog: Logger Server wasn't found" );
+ INFOS( "Ressources Catalog: Logger Server wasn't found" );
}
catch(...)
{
- MESSAGE( "Ressources Catalog: Unknown exception" );
+ INFOS( "Ressources Catalog: Unknown exception" );
}
if (!CORBA::is_nil(object))
{
#include "SALOME_RessourcesCatalog_impl.hxx"
#include <fstream>
+#include "Utils_ExceptHandlers.hxx"
+UNEXPECT_CATCH(RC_NotFound, SALOME_RessourcesCatalog::NotFound);
+
//----------------------------------------------------------------------
// Function : SALOME_RessourcesCatalogImpl
// Purpose : Constructor
SALOME_RessourcesCatalogImpl::GetContainerTypeList(const char* computer)
throw(SALOME_RessourcesCatalog::NotFound)
{
+ Unexpect aCatch(RC_NotFound);
MESSAGE("Begin of GetContainerTypeList");
SALOME_RessourcesCatalog::ListOfContainerType_var _list =
new SALOME_RessourcesCatalog::ListOfContainerType;
throw(SALOME_RessourcesCatalog::NotFound)
{
MESSAGE("Begin of GetComputerInfo");
+ Unexpect aCatch(RC_NotFound);
SALOME_RessourcesCatalog::computer_info_var _computer_info =
new SALOME_RessourcesCatalog::computer_info;
if (strcmp(argv[ind],"-help") == 0)
{
- INFOS( "Usage: " << argv[0] << " -common 'path to ressources catalog' -ORBInitRef NameService=corbaname::localhost");
+ MESSAGE( "Usage: " << argv[0] << " -common 'path to ressources catalog' -ORBInitRef NameService=corbaname::localhost");
_return_value = false ;
}
if (strcmp(argv[ind],"-common") == 0)
// File : Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef _Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile
#define _Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile
// File : Handle_SALOMEDS_LocalIDAttribute.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef _Handle_SALOMEDS_LocalIDAttribute_HeaderFile
#define _Handle_SALOMEDS_LocalIDAttribute_HeaderFile
// File : Handle_SALOMEDS_TargetAttribute.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef _Handle_SALOMEDS_TargetAttribute_HeaderFile
#define _Handle_SALOMEDS_TargetAttribute_HeaderFile
CORBA::String_var Str = CORBA::string_dup(value);
Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str));
}
+
+char* SALOMEDS_AttributeComment_i::Store() {
+ return Value();
+}
+
+void SALOMEDS_AttributeComment_i::Restore(const char* value) {
+ SetValue(value);
+}
char* Value();
void SetValue(const char* value);
-
+
+ char* Store();
+ void Restore(const char*);
+
};
if (value != 0) val = 1;
Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val);
}
+
+char* SALOMEDS_AttributeDrawable_i::Store() {
+ return strdup(IsDrawable()?"1":"0");
+}
+
+void SALOMEDS_AttributeDrawable_i::Restore(const char* value) {
+ SetDrawable(value[0] == '1');
+}
~SALOMEDS_AttributeDrawable_i() {};
CORBA::Boolean IsDrawable();
void SetDrawable(CORBA::Boolean value);
+
+ char* Store();
+ void Restore(const char*);
+
};
if (value != 0) val = 1;
Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val);
}
+
+char* SALOMEDS_AttributeExpandable_i::Store() {
+ return strdup(IsExpandable()?"1":"0");
+}
+
+void SALOMEDS_AttributeExpandable_i::Restore(const char* value) {
+ SetExpandable(value[0] == '1');
+}
~SALOMEDS_AttributeExpandable_i() {};
CORBA::Boolean IsExpandable();
void SetExpandable(CORBA::Boolean value);
+
+ char* Store();
+ void Restore(const char*);
+
};
CheckLocked();
Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(value);
}
+
+char* SALOMEDS_AttributeInteger_i::Store() {
+ char* IntVal = new char[25];
+ sprintf(IntVal, "%d", Value());
+ return IntVal;
+}
+
+void SALOMEDS_AttributeInteger_i::Restore(const char* value) {
+ char *err = NULL;
+ CORBA::Long l = atol(value);
+ SetValue(l);
+}
CORBA::Long Value();
void SetValue(CORBA::Long value);
+
+ char* Store();
+ void Restore(const char*);
+
};
// File : SALOMEDS_AttributeLocalID_i.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
using namespace std;
#include "SALOMEDS_AttributeLocalID_i.hxx"
CheckLocked();
Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(value);
}
+
+char* SALOMEDS_AttributeLocalID_i::Store() {
+ char* IntVal = new char[25];
+ sprintf(IntVal, "%d", Value());
+ return IntVal;
+}
+
+void SALOMEDS_AttributeLocalID_i::Restore(const char* value) {
+ char *err = NULL;
+ CORBA::Long l = atol(value);
+ SetValue(l);
+}
~SALOMEDS_AttributeLocalID_i() {};
CORBA::Long Value();
void SetValue(CORBA::Long value);
+
+ char* Store();
+ void Restore(const char*);
+
};
CORBA::String_var Str = CORBA::string_dup(value);
Handle(TDataStd_Name)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str));
}
+
+char* SALOMEDS_AttributeName_i::Store() {
+ return Value();
+}
+
+void SALOMEDS_AttributeName_i::Restore(const char* value) {
+ SetValue(value);
+}
char* Value();
void SetValue(const char* value);
+
+ char* Store();
+ void Restore(const char*);
+
};
if (value != 0) val = 1;
Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val);
}
+
+char* SALOMEDS_AttributeOpened_i::Store() {
+ return strdup(IsOpened()?"1":"0");
+}
+
+void SALOMEDS_AttributeOpened_i::Restore(const char* value) {
+ SetOpened(value[0] == '1');
+}
~SALOMEDS_AttributeOpened_i() {};
CORBA::Boolean IsOpened();
void SetOpened(CORBA::Boolean value);
+
+ char* Store();
+ void Restore(const char*);
+
};
CORBA::String_var Str = CORBA::string_dup(value);
Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str));
}
+
+char* SALOMEDS_AttributePersistentRef_i::Store() {
+ return Value();
+}
+
+void SALOMEDS_AttributePersistentRef_i::Restore(const char* value) {
+ SetValue(value);
+}
// File : SALOMEDS_AttributePersistentRef_i.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef SALOMEDS_AttributePersistentRef_i_HeaderFile
#define SALOMEDS_AttributePersistentRef_i_HeaderFile
char* Value();
void SetValue(const char* value);
+
+ char* Store();
+ void Restore(const char*);
};
CORBA::String_var Str = CORBA::string_dup(value);
Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str));
}
+
+char* SALOMEDS_AttributePixMap_i::Store() {
+ return GetPixMap();
+}
+
+void SALOMEDS_AttributePixMap_i::Restore(const char* value) {
+ SetPixMap(value);
+}
// File : SALOMEDS_AttributePixMap_i.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef SALOMEDS_AttributePixMap_i_HeaderFile
#define SALOMEDS_AttributePixMap_i_HeaderFile
CORBA::Boolean HasPixMap();
char* GetPixMap();
void SetPixMap(const char* value);
+
+ char* Store();
+ void Restore(const char*);
+
};
CORBA::Boolean SALOMEDS_AttributePythonObject_i::IsScript() {
return Handle(SALOMEDS_PythonObjectAttribute)::DownCast(_myAttr)->IsScript();
}
+
+char* SALOMEDS_AttributePythonObject_i::Store() {
+ CORBA::String_var aString = GetObject();
+ char* aResult = new char[strlen(aString) + 2];
+ aResult[0] = IsScript()?'s':'n';
+ strcpy(aResult+1, aString);
+ return aResult;
+}
+
+void SALOMEDS_AttributePythonObject_i::Restore(const char* value) {
+ char* aString = strdup(value);
+ SetObject(aString + 1, aString[0]=='s');
+}
virtual char* GetObject();
virtual CORBA::Boolean IsScript();
+ virtual char* Store();
+ virtual void Restore(const char*);
+
};
CheckLocked();
Handle(TDataStd_Real)::DownCast(_myAttr)->Set(value);
}
+
+char* SALOMEDS_AttributeReal_i::Store() {
+ char* RealVal = new char[25];
+ sprintf(RealVal, "%f", Value());
+ return RealVal;
+}
+
+void SALOMEDS_AttributeReal_i::Restore(const char* value) {
+ char *err = NULL;
+ CORBA::Double r = strtod(value, &err);
+ if (err != value) SetValue(r);
+}
// File : SALOMEDS_AttributeReal_i.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef SALOMEDS_AttributeReal_i_HeaderFile
#define SALOMEDS_AttributeReal_i_HeaderFile
CORBA::Double Value();
void SetValue(CORBA::Double value);
+
+ char* Store();
+ void Restore(const char*);
+
};
if (value != 0) val = 1;
Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val);
}
+
+char* SALOMEDS_AttributeSelectable_i::Store() {
+ return strdup(IsSelectable()?"1":"0");
+}
+
+void SALOMEDS_AttributeSelectable_i::Restore(const char* value) {
+ SetSelectable(value[0] == '1');
+}
~SALOMEDS_AttributeSelectable_i() {};
CORBA::Boolean IsSelectable();
void SetSelectable(CORBA::Boolean value);
+
+ char* Store();
+ void Restore(const char*);
+
};
{
return Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Length();
}
+
+char* SALOMEDS_AttributeSequenceOfInteger_i::Store() {
+ Handle(SALOMEDS_SequenceOfIntegerAttribute) CasCadeSeq = Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr);
+ Standard_Integer aLength = CasCadeSeq->Length();
+ char* aResult = new char[aLength * 25];
+ aResult[0] = 0;
+ Standard_Integer aPosition = 0;
+ for (int i = 1; i <= aLength; i++) {
+ sprintf(aResult + aPosition , "%d ", CasCadeSeq->Value(i));
+ aPosition += strlen(aResult + aPosition);
+ }
+ return aResult;
+}
+
+void SALOMEDS_AttributeSequenceOfInteger_i::Restore(const char* value) {
+ Handle(TColStd_HSequenceOfInteger) CasCadeSeq = new TColStd_HSequenceOfInteger;
+
+ char* aCopy = strdup(value);
+ char* adr = strtok(aCopy, " ");
+ while (adr) {
+ CORBA::Long l = atol(adr);
+ CasCadeSeq->Append(l);
+ adr = strtok(NULL, " ");
+ }
+ delete(aCopy);
+ Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Assign(CasCadeSeq);
+}
void ChangeValue(CORBA::Long index, CORBA::Long value);
CORBA::Long Value(CORBA::Short index);
CORBA::Long Length();
+
+ char* Store();
+ void Restore(const char*);
+
};
#endif
{
return Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Length();
}
+
+char* SALOMEDS_AttributeSequenceOfReal_i::Store() {
+ Handle(SALOMEDS_SequenceOfRealAttribute) CasCadeSeq = Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr);
+ Standard_Integer aLength = CasCadeSeq->Length();
+ char* aResult = new char[aLength * 25];
+ aResult[0] = 0;
+ Standard_Integer aPosition = 0;
+ for (int i = 1; i <= aLength; i++) {
+ sprintf(aResult + aPosition , "%f ", CasCadeSeq->Value(i));
+ aPosition += strlen(aResult + aPosition);
+ }
+ return aResult;
+}
+
+void SALOMEDS_AttributeSequenceOfReal_i::Restore(const char* value) {
+ Handle(TColStd_HSequenceOfReal) CasCadeSeq = new TColStd_HSequenceOfReal;
+
+ char* aCopy = strdup(value);
+ char* adr = strtok(aCopy, " ");
+ char *err = NULL;
+ while (adr) {
+ CORBA::Double r = strtod(adr, &err);
+ if (err == adr) break;
+ else CasCadeSeq->Append(r);
+ adr = strtok(NULL, " ");
+ }
+ delete(aCopy);
+ Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Assign(CasCadeSeq);
+}
void ChangeValue(CORBA::Long index, CORBA::Double value);
CORBA::Double Value(CORBA::Short index);
CORBA::Long Length();
+
+ char* Store();
+ void Restore(const char*);
};
void SALOMEDS_AttributeStudyProperties_i::SetUserName(const char* theName) {
CheckLocked();
Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
- CORBA::String_var Str = CORBA::string_dup(theName);
- aProp->SetFirstName(TCollection_ExtendedString(Str));
+ aProp->SetFirstName(TCollection_ExtendedString(strdup(theName)));
}
char* SALOMEDS_AttributeStudyProperties_i::GetUserName() {
CORBA::Long theYear) {
CheckLocked();
Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
- aProp->SetUserName(CORBA::string_dup(theName));
+ aProp->SetUserName(strdup(theName));
aProp->SetModificationDate((int)theMinute, (int)theHour, (int)theDay, (int)theMonth, (int)theYear);
}
void SALOMEDS_AttributeStudyProperties_i::GetModificationsList(SALOMEDS::StringSeq_out theNames,
(*theYears)[a] = aYears->Value(a + 1 + ((theWithCreator)?0:1));
}
}
+
+char* SALOMEDS_AttributeStudyProperties_i::Store() {
+ Handle(TColStd_HSequenceOfExtendedString) aNames;
+ Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears;
+ Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
+ aNames = aProp->GetUserNames();
+ aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears);
+
+ int aLength, anIndex;
+ for(aLength = 0, anIndex = aNames->Length(); anIndex > 0; anIndex--) aLength += aNames->Value(anIndex).Length() + 1;
+
+ char* aProperty = new char[3 + aLength + 12 * aNames->Length()];
+
+ sprintf(aProperty,"%c%c", strlen(GetCreationMode())?GetCreationMode()[0]:'0', IsLocked()?'l':'u');
+
+ aLength = aNames->Length();
+ int a = 2;
+ for(anIndex = 1; anIndex <= aLength; anIndex++) {
+ sprintf(&(aProperty[a]),"%2d%2d%2d%2d%4d%s",
+ (int)(aMinutes->Value(anIndex)),
+ (int)(aHours->Value(anIndex)),
+ (int)(aDays->Value(anIndex)),
+ (int)(aMonths->Value(anIndex)),
+ (int)(aYears->Value(anIndex)),
+ (char*)(TCollection_AsciiString(aNames->Value(anIndex)).ToCString()));
+ a = strlen(aProperty);
+ aProperty[a++] = 1;
+ }
+ aProperty[a] = 0;
+ return aProperty;
+}
+
+void SALOMEDS_AttributeStudyProperties_i::Restore(const char* value) {
+ char* aCopy = strdup(value);
+ if (aCopy[0] == 'f') SetCreationMode("from scratch");
+ else if (aCopy[0] == 'c') SetCreationMode("copy from");
+ else SetCreationMode("none");
+
+ int anIndex;
+ for(anIndex = 2; anIndex + 2 < strlen(value) ;) {
+ char str[10];
+ Standard_Integer aMinute, aHour, aDay, aMonth, aYear;
+ str[0] = aCopy[anIndex++];
+ str[1] = aCopy[anIndex++];
+ str[2] = 0;
+ aMinute = atoi(str);
+ str[0] = aCopy[anIndex++];
+ str[1] = aCopy[anIndex++];
+ aHour = atoi(str);
+ str[0] = aCopy[anIndex++];
+ str[1] = aCopy[anIndex++];
+ aDay = atoi(str);
+ str[0] = aCopy[anIndex++];
+ str[1] = aCopy[anIndex++];
+ aMonth = atoi(str);
+ str[0] = aCopy[anIndex++];
+ str[1] = aCopy[anIndex++];
+ str[2] = aCopy[anIndex++];
+ str[3] = aCopy[anIndex++];
+ str[4] = 0;
+ aYear = atoi(str);
+
+ int aNameSize;
+ for(aNameSize = 0; aCopy[anIndex+aNameSize]!=1; aNameSize++);
+ char *aName = new char[aNameSize+1];
+ strncpy(aName, &(aCopy[anIndex]), aNameSize);
+ aName[aNameSize] = 0;
+ SetModification(aName, aMinute,aHour,aDay,aMonth,aYear);
+ delete(aName);
+ anIndex += aNameSize + 1;
+ }
+ if (aCopy[1] == 'l') {
+ SetLocked(Standard_True);
+ }
+ SetModified(0);
+ delete(aCopy);
+}
SALOMEDS::LongSeq_out theMonths,
SALOMEDS::LongSeq_out theYears,
CORBA::Boolean theWithCreator);
+
+ char* Store();
+ void Restore(const char*);
+
};
#include <TColStd_HSequenceOfInteger.hxx>
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx>
+#include "Utils_ExceptHandlers.hxx"
+#include <stdexcept>
#include <strstream>
#include <string>
#define SEPARATOR '\1'
+UNEXPECT_CATCH(ATI_IncorrectIndex, SALOMEDS::AttributeTableOfInteger::IncorrectIndex);
+UNEXPECT_CATCH(ATI_IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength);
+
static TCollection_ExtendedString getUnit(TCollection_ExtendedString theString)
{
TCollection_ExtendedString aString(theString);
void SALOMEDS_AttributeTableOfInteger_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
{
+ Unexpect aCatch (ATI_IncorrectIndex);
CheckLocked();
Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
void SALOMEDS_AttributeTableOfInteger_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength)
{
+ Unexpect aCatch (ATI_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
{
+ Unexpect aCatch (ATI_IncorrectIndex);
CheckLocked();
Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength)
{
+ Unexpect aCatch(ATI_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
void SALOMEDS_AttributeTableOfInteger_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
{
+ Unexpect aCatch (ATI_IncorrectIndex);
CheckLocked();
Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
void SALOMEDS_AttributeTableOfInteger_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength)
{
+ Unexpect aCatch (ATI_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
void SALOMEDS_AttributeTableOfInteger_i::AddRow(const SALOMEDS::LongSeq& theData)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength)
{
+ Unexpect aCatch(ATI_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
void SALOMEDS_AttributeTableOfInteger_i::SetRow(CORBA::Long theRow, const SALOMEDS::LongSeq& theData)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
{
+ Unexpect aCatch(ATI_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetRow(CORBA::Long theRow)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
{
+ Unexpect aCatch(ATI_IncorrectIndex);
Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
void SALOMEDS_AttributeTableOfInteger_i::AddColumn(const SALOMEDS::LongSeq& theData)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength)
{
+ Unexpect aCatch(ATI_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
void SALOMEDS_AttributeTableOfInteger_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::LongSeq& theData)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
{
+ Unexpect aCatch(ATI_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumn(CORBA::Long theColumn)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
{
+ Unexpect aCatch(ATI_IncorrectIndex);
Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
void SALOMEDS_AttributeTableOfInteger_i::PutValue(CORBA::Long theValue, CORBA::Long theRow, CORBA::Long theColumn)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
{
+ Unexpect aCatch(ATI_IncorrectIndex);
CheckLocked();
Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn)
throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
{
+ Unexpect aCatch(ATI_IncorrectIndex);
Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
return aStreamFile._retn();
}
+char* SALOMEDS_AttributeTableOfInteger_i::Store() {
+ Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+
+ ostrstream ostr;
+ aTable->ConvertToString(ostr);
+ string aString = ostr.rdbuf()->str();
+
+ CORBA::String_var aBuffer = CORBA::string_dup(aString.c_str());
+ return aBuffer._retn();
+}
+
+void SALOMEDS_AttributeTableOfInteger_i::Restore(const char* value) {
+ Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+
+ istrstream aStream(value, strlen(value));
+ aTable->RestoreFromString(aStream);
+}
virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream);
virtual SALOMEDS::TMPFile* SaveToFile();
+
+ virtual char* Store();
+ virtual void Restore(const char*);
+
};
#endif
#include <strstream>
#include <string>
+#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)
void SALOMEDS_AttributeTableOfReal_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle)
throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
{
+ Unexpect aCatch (ATR_IncorrectIndex);
CheckLocked();
Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
void SALOMEDS_AttributeTableOfReal_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles)
throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength)
{
+ Unexpect aCatch (ATR_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
void SALOMEDS_AttributeTableOfReal_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle)
throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
{
+ Unexpect aCatch (ATR_IncorrectIndex);
CheckLocked();
Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
void SALOMEDS_AttributeTableOfReal_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles)
throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength)
{
+ Unexpect aCatch(ATR_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
void SALOMEDS_AttributeTableOfReal_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit)
throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
{
+ Unexpect aCatch (ATR_IncorrectIndex);
CheckLocked();
Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
void SALOMEDS_AttributeTableOfReal_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits)
throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength)
{
+ Unexpect aCatch (ATR_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
void SALOMEDS_AttributeTableOfReal_i::AddRow(const SALOMEDS::DoubleSeq& theData)
throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength)
{
+ Unexpect aCatch(ATR_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
void SALOMEDS_AttributeTableOfReal_i::SetRow(CORBA::Long theRow, const SALOMEDS::DoubleSeq& theData)
throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectIndex)
{
+ Unexpect aCatch(ATR_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetRow(CORBA::Long theRow)
throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
{
+ Unexpect aCatch(ATR_IncorrectIndex);
Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
void SALOMEDS_AttributeTableOfReal_i::AddColumn(const SALOMEDS::DoubleSeq& theData)
throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength)
{
+ Unexpect aCatch(ATR_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
void SALOMEDS_AttributeTableOfReal_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::DoubleSeq& theData)
throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectIndex)
{
+ Unexpect aCatch(ATR_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetColumn(CORBA::Long theColumn)
throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
{
+ Unexpect aCatch(ATR_IncorrectIndex);
Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
void SALOMEDS_AttributeTableOfReal_i::PutValue(CORBA::Double theValue, CORBA::Long theRow, CORBA::Long theColumn)
throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
{
+ Unexpect aCatch(ATR_IncorrectIndex);
CheckLocked();
Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
CORBA::Double SALOMEDS_AttributeTableOfReal_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn)
throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
{
+ Unexpect aCatch(ATR_IncorrectIndex);
Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
return aStreamFile._retn();
}
+char* SALOMEDS_AttributeTableOfReal_i::Store() {
+ Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+
+ ostrstream ostr;
+ aTable->ConvertToString(ostr);
+ string aString = ostr.rdbuf()->str();
+
+ CORBA::String_var aBuffer = CORBA::string_dup(aString.c_str());
+ return aBuffer._retn();
+}
+
+void SALOMEDS_AttributeTableOfReal_i::Restore(const char* value) {
+ Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
+
+ istrstream aStream(value, strlen(value));
+ aTable->RestoreFromString(aStream);
+}
virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream);
virtual SALOMEDS::TMPFile* SaveToFile();
+
+ virtual char* Store();
+ virtual void Restore(const char*);
+
};
#endif
#include <strstream>
#include <string>
+#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)
void SALOMEDS_AttributeTableOfString_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle)
throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
{
+ Unexpect aCatch(ATS_IncorrectIndex);
CheckLocked();
Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
void SALOMEDS_AttributeTableOfString_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles)
throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength)
{
+ Unexpect aCatch(ATS_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
void SALOMEDS_AttributeTableOfString_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle)
throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
{
+ Unexpect aCatch(ATS_IncorrectIndex);
CheckLocked();
Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
void SALOMEDS_AttributeTableOfString_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles)
throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength)
{
+ Unexpect aCatch(ATS_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
void SALOMEDS_AttributeTableOfString_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit)
throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
{
+ Unexpect aCatch(ATS_IncorrectIndex);
CheckLocked();
Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
void SALOMEDS_AttributeTableOfString_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits)
throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength)
{
+ Unexpect aCatch(ATS_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
void SALOMEDS_AttributeTableOfString_i::AddRow(const SALOMEDS::StringSeq& theData)
throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength)
{
+ Unexpect aCatch(ATS_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
void SALOMEDS_AttributeTableOfString_i::SetRow(CORBA::Long theRow, const SALOMEDS::StringSeq& theData)
throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectIndex)
{
+ Unexpect aCatch(ATS_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRow(CORBA::Long theRow)
throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
{
+ Unexpect aCatch(ATS_IncorrectIndex);
Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
void SALOMEDS_AttributeTableOfString_i::AddColumn(const SALOMEDS::StringSeq& theData)
throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength)
{
+ Unexpect aCatch(ATS_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
void SALOMEDS_AttributeTableOfString_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::StringSeq& theData)
throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectIndex)
{
+ Unexpect aCatch(ATS_IncorrectArgumentLength);
CheckLocked();
Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetColumn(CORBA::Long theColumn)
throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
{
+ Unexpect aCatch(ATS_IncorrectIndex);
Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
void SALOMEDS_AttributeTableOfString_i::PutValue(const char* theValue, CORBA::Long theRow, CORBA::Long theColumn)
throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
{
+ Unexpect aCatch(ATS_IncorrectIndex);
CheckLocked();
Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
char* aValue = CORBA::string_dup(theValue);
char* SALOMEDS_AttributeTableOfString_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn)
throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
{
+ Unexpect aCatch(ATS_IncorrectIndex);
Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
return aStreamFile._retn();
}
+char* SALOMEDS_AttributeTableOfString_i::Store() {
+ Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+
+ ostrstream ostr;
+ aTable->ConvertToString(ostr);
+ string aString = ostr.rdbuf()->str();
+
+ CORBA::String_var aBuffer = CORBA::string_dup(aString.c_str());
+ return aBuffer._retn();
+}
+
+void SALOMEDS_AttributeTableOfString_i::Restore(const char* value) {
+ Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
+
+ istrstream aStream(value, strlen(value));
+ aTable->RestoreFromString(aStream);
+}
virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream);
virtual SALOMEDS::TMPFile* SaveToFile();
+
+ char* Store();
+ void Restore(const char*);
+
};
#endif
// File : SALOMEDS_AttributeTarget_i.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
using namespace std;
#include "SALOMEDS_AttributeTarget_i.hxx"
anArray->SetValue(3, value.B);
Handle(SALOMEDS_TextColorAttribute)::DownCast(_myAttr)->ChangeArray(anArray);
}
+
+char* SALOMEDS_AttributeTextColor_i::Store() {
+ SALOMEDS::Color aColor = TextColor();
+ char *Val = new char[75];
+ sprintf(Val, "%f %f %f", (float)aColor.R, (float)aColor.G, (float)aColor.B);
+ return Val;
+}
+
+void SALOMEDS_AttributeTextColor_i::Restore(const char* value) {
+ SALOMEDS::Color aColor;
+ float r, g, b;
+ sscanf(value, "%f %f %f", &r, &g, &b);
+ aColor.R = r;
+ aColor.G = g;
+ aColor.B = b;
+ SetTextColor(aColor);
+}
// File : SALOMEDS_AttributeTextColor_i.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef SALOMEDS_AttributeTextColor_i_HeaderFile
#define SALOMEDS_AttributeTextColor_i_HeaderFile
SALOMEDS::Color TextColor();
void SetTextColor(const SALOMEDS::Color& value);
+
+ char* Store();
+ void Restore(const char*);
+
};
anArray->SetValue(3, value.B);
Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(_myAttr)->ChangeArray(anArray);
}
+
+char* SALOMEDS_AttributeTextHighlightColor_i::Store() {
+ SALOMEDS::Color aColor = TextHighlightColor();
+ char *Val = new char[75];
+ sprintf(Val, "%f %f %f", (float)aColor.R, (float)aColor.G, (float)aColor.B);
+ return Val;
+}
+
+void SALOMEDS_AttributeTextHighlightColor_i::Restore(const char* value) {
+ SALOMEDS::Color aColor;
+ float r, g, b;
+ sscanf(value, "%f %f %f", &r, &g, &b);
+ aColor.R = r;
+ aColor.G = g;
+ aColor.B = b;
+ SetTextHighlightColor(aColor);
+}
// File : SALOMEDS_AttributeTextHighlightColor_i.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef SALOMEDS_AttributeTextHighlightColor_i_HeaderFile
#define SALOMEDS_AttributeTextHighlightColor_i_HeaderFile
SALOMEDS::Color TextHighlightColor();
void SetTextHighlightColor(const SALOMEDS::Color& value);
+
+ char* Store();
+ void Restore(const char*);
+
};
// File : SALOMEDS_AttributeTreeNode_i.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
using namespace std;
#include "SALOMEDS_AttributeTreeNode_i.hxx"
#include "SALOMEDS_SObject_i.hxx"
#include "utilities.h"
+#include <TDocStd_Document.hxx>
+#include <TDF_Tool.hxx>
static Handle(TDataStd_TreeNode) GetNode(SALOMEDS::AttributeTreeNode_ptr value,
const Handle(TDataStd_TreeNode)& aNode) {
TDF_Tool::Entry(_myAttr->Label(),aLabelName);
return CORBA::String_var(CORBA::string_dup(aLabelName.ToCString()))._retn();
}
+
+char* SALOMEDS_AttributeTreeNode_i::Store() {
+ char* aStr[4];
+
+ if (HasFather()) aStr[0] = GetFather()->Label(); else aStr[0] = "!";
+ if (HasPrevious()) aStr[1] = GetPrevious()->Label(); else aStr[1] = "!";
+ if (HasNext()) aStr[2] = GetNext()->Label(); else aStr[2] = "!";
+ if (HasFirst()) aStr[3] = GetFirst()->Label(); else aStr[3] = "!";
+
+ int aLength = 4;
+ aLength += strlen(aStr[0]) + strlen(aStr[1]) + strlen(aStr[2]) + strlen(aStr[3]);
+ CORBA::String_var aResult = new char[aLength];
+ sprintf(aResult, "%s %s %s %s", aStr[0], aStr[1], aStr[2], aStr[3]);
+ return aResult._retn();
+}
+
+void SALOMEDS_AttributeTreeNode_i::Restore(const char* value) {
+ Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr);
+ Handle(TDF_Data) DF = TDocStd_Document::Get(_myAttr->Label())->GetData();
+
+ char* aCopy = strdup(value);
+ char* adr = strtok(aCopy, " ");
+
+ TDF_Label aLabel;
+ Handle(TDataStd_TreeNode) aDepNode;
+
+ if (adr && adr[0] != '!') {
+ TDF_Tool::Label(DF, adr, aLabel, 1);
+ if (!aLabel.FindAttribute(aNode->ID(), aDepNode)) aDepNode = TDataStd_TreeNode::Set(aLabel, aNode->ID());
+ aNode->SetFather(aDepNode);
+ }
+
+ adr = strtok(NULL, " ");
+ if (adr && adr[0] != '!') {
+ TDF_Tool::Label(DF, adr, aLabel, 1);
+ if (!aLabel.FindAttribute(aNode->ID(), aDepNode)) aDepNode = TDataStd_TreeNode::Set(aLabel, aNode->ID());
+ aNode->SetPrevious(aDepNode);
+ }
+
+ adr = strtok(NULL, " ");
+ if (adr && adr[0] != '!') {
+ TDF_Tool::Label(DF, adr, aLabel, 1);
+ if (!aLabel.FindAttribute(aNode->ID(), aDepNode)) aDepNode = TDataStd_TreeNode::Set(aLabel, aNode->ID());
+ aNode->SetNext(aDepNode);
+ }
+
+ adr = strtok(NULL, " ");
+ if (adr && adr[0] != '!') {
+ TDF_Tool::Label(DF, adr, aLabel, 1);
+ if (!aLabel.FindAttribute(aNode->ID(), aDepNode)) aDepNode = TDataStd_TreeNode::Set(aLabel, aNode->ID());
+ aNode->SetFirst(aDepNode);
+ }
+}
CORBA::Boolean IsFather(SALOMEDS::AttributeTreeNode_ptr value);
CORBA::Boolean IsChild(SALOMEDS::AttributeTreeNode_ptr value);
char* Label();
+
+ char* Store();
+ void Restore(const char*);
+
};
#endif
// File : SALOMEDS_AttributeName_i.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
using namespace std;
#include "SALOMEDS_AttributeUserID_i.hxx"
CORBA::String_var Str = CORBA::string_dup(value);
Handle(TDataStd_UAttribute)::DownCast(_myAttr)->SetID(Standard_GUID(Standard_CString(Str)));
}
+
+char* SALOMEDS_AttributeUserID_i::Store() {
+ return "";
+}
+
+void SALOMEDS_AttributeUserID_i::Restore(const char* value) {
+}
static Standard_GUID SALOMEDS_DefaultUserAttributeID ("FFFFFFFF-D9CD-11d6-945D-1050DA506788");
return SALOMEDS_DefaultUserAttributeID;
}
+
+ char* Store();
+ void Restore(const char*);
+
};
SALOMEDS_BasicAttribute_i* BasicAttributeFactory::Create(const char* type)
throw (SALOME_Exception)
{
- if (!strcmp(type,"AttReal"))
- {
- SALOMEDS_AttReal_i *A = new SALOMEDS_AttReal_i();
- return A;
- }
- else if(!strcmp(type,"AttLong"))
- {
- SALOMEDS_AttLong_i *A = new SALOMEDS_AttLong_i();
- return A;
- }
- else throw(SALOME_Exception(LOCALIZED("bad attribute type name")));
-
+ try {
+ if (!strcmp(type,"AttReal"))
+ {
+ SALOMEDS_AttReal_i *A = new SALOMEDS_AttReal_i();
+ return A;
+ }
+ else if(!strcmp(type,"AttLong"))
+ {
+ SALOMEDS_AttLong_i *A = new SALOMEDS_AttLong_i();
+ return A;
+ }
+ else throw(SALOME_Exception(LOCALIZED("bad attribute type name")));
+ } catch (...) {throw(SALOME_Exception(LOCALIZED("Unexpected exception was caught")));}
}
// File : SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef _SALOMEDS_DataMapIteratorOfDataMapStringLabel_HeaderFile
#define _SALOMEDS_DataMapIteratorOfDataMapStringLabel_HeaderFile
// File : SALOMEDS_DataMapIteratorOfDataMapStringLabel_0.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
using namespace std;
#include "SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx"
// File : SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef _SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile
#define _SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile
// File : Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel_0.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
using namespace std;
#include "SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx"
// File : SALOMEDS_DataMapStringLabel.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef _SALOMEDS_DataMapStringLabel_HeaderFile
#define _SALOMEDS_DataMapStringLabel_HeaderFile
// File : SALOMEDS_DataMapStringLabel_0.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
using namespace std;
#include "SALOMEDS_DataMapStringLabel.hxx"
// File : SALOMEDS_DrawableAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
using namespace std;
#include "SALOMEDS_DrawableAttribute.ixx"
// File : SALOMEDS_ExpandableAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
using namespace std;
#include "SALOMEDS_ExpandableAttribute.ixx"
// File : SALOMEDS_ExternalFileDef.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#include "SALOMEDS_ExternalFileDef.ixx"
#include <TDataStd_Comment.hxx>
// File : SALOMEDS_FileType.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#include "SALOMEDS_FileType.ixx"
#include <TDataStd_Comment.hxx>
// $Header$
using namespace std;
+
+#include <TDataStd_TreeNode.hxx>
+#include <TDataStd_UAttribute.hxx>
+
+#include "SALOMEDS_AttributeDrawable_i.hxx"
+#include "SALOMEDS_AttributeSelectable_i.hxx"
+#include "SALOMEDS_AttributeOpened_i.hxx"
+#include "SALOMEDS_AttributeTextColor_i.hxx"
+#include "SALOMEDS_AttributeTextHighlightColor_i.hxx"
+#include "SALOMEDS_AttributePixMap_i.hxx"
+#include "SALOMEDS_AttributeExpandable_i.hxx"
+#include "SALOMEDS_AttributeLocalID_i.hxx"
+#include "SALOMEDS_AttributeTarget_i.hxx"
+#include "SALOMEDS_AttributeTableOfInteger_i.hxx"
+#include "SALOMEDS_AttributeTableOfReal_i.hxx"
+#include "SALOMEDS_AttributeTableOfString_i.hxx"
+#include "SALOMEDS_AttributeStudyProperties_i.hxx"
+#include "SALOMEDS_AttributePythonObject_i.hxx"
+#include "SALOMEDS_AttributeTreeNode_i.hxx"
+#include "SALOMEDS_AttributeUserID_i.hxx"
+#include "SALOMEDS_AttributeExternalFileDef_i.hxx"
+#include "SALOMEDS_AttributeFileType_i.hxx"
#include "SALOMEDS_StudyBuilder_i.hxx"
+#include "SALOMEDS_SequenceOfRealAttribute.hxx"
+#include "SALOMEDS_SequenceOfIntegerAttribute.hxx"
+#include "SALOMEDS_IORAttribute.hxx"
+#include "SALOMEDS_PersRefAttribute.hxx"
+#include "SALOMEDS_DrawableAttribute.hxx"
+#include "SALOMEDS_SelectableAttribute.hxx"
+#include "SALOMEDS_ExpandableAttribute.hxx"
+#include "SALOMEDS_OpenedAttribute.hxx"
+#include "SALOMEDS_TextColorAttribute.hxx"
+#include "SALOMEDS_TextHighlightColorAttribute.hxx"
+#include "SALOMEDS_PixMapAttribute.hxx"
+#include "SALOMEDS_LocalIDAttribute.hxx"
+#include "SALOMEDS_PythonObjectAttribute.hxx"
+#include "SALOMEDS_TargetAttribute.hxx"
+#include "SALOMEDS_StudyPropertiesAttribute.hxx"
+#include "SALOMEDS_TableOfIntegerAttribute.hxx"
+#include "SALOMEDS_TableOfRealAttribute.hxx"
+#include "SALOMEDS_TableOfStringAttribute.hxx"
+#include "SALOMEDS_ExternalFileDef.hxx"
+#include "SALOMEDS_FileType.hxx"
+#include "Utils_ExceptHandlers.hxx"
+#define RegisteredAttributes 26
+
+UNEXPECT_CATCH(GALockProtection, SALOMEDS::GenericAttribute::LockProtection);
+
+const char AttributesTypeNames[RegisteredAttributes][30] = {
+ "AttributeReal", "AttributeInteger",
+ "AttributeSequenceOfReal", "AttributeSequenceOfInteger",
+ "AttributeName", "AttributeComment",
+ "AttributeIOR", "AttributePersistentRef",
+ "AttributeDrawable", "AttributeSelectable",
+ "AttributeExpandable", "AttributeOpened",
+ "AttributeTextColor", "AttributeTextHighlightColor", "AttributePixMap",
+ "AttributeTreeNode", "AttributeLocalID",
+ "AttributeTarget",
+ "AttributeTableOfInteger", "AttributeTableOfReal", "AttributeTableOfString",
+ "AttributeStudyProperties",
+ "AttributePythonObject",
+ "AttributeUserID",
+ "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)){
char* IOR = CORBA::string_dup(ch.ToCString());
CORBA::Object_var obj = _myOrb->string_to_object(IOR);
SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj);
- // ASSERT(!CORBA::is_nil(aStudy));
+// ASSERT(!CORBA::is_nil(aStudy));
if (aStudy->NewBuilder()->HasOpenCommand()) return;
if (aStudy->GetProperties()->IsLocked()) {
- // INFOS("Locked document modification !!!");
+// MESSAGE("Locked document modification !!!");
throw SALOMEDS::GenericAttribute::LockProtection();
}
}
}
}
+
+SALOMEDS::SObject_ptr SALOMEDS_GenericAttribute_i::GetSObject() {
+ if (_myAttr.IsNull() || _myAttr->Label().IsNull()) return SALOMEDS::SObject::_nil();
+ SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (_myAttr->Label(),_myOrb);
+ SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this());
+ return so._retn();
+}
+
+Standard_GUID SALOMEDS_GenericAttribute_i::GetGUID(const char* theType) {
+ Standard_Integer i;
+ for(i = 0; i < RegisteredAttributes; i++) {
+ if (strcmp(AttributesTypeNames[i], theType) == 0) return AttributesGUIDs[i];
+ }
+
+ if (strncmp(theType, "AttributeTreeNodeGUID",21) == 0) {
+ char* aGUIDString = new char[40];
+ sprintf(aGUIDString, &(theType[21]));
+ Standard_GUID aGUID = Standard_GUID(aGUIDString); // create tree node GUID by name
+ delete(aGUIDString);
+ return aGUID;
+ }
+ return Standard_GUID();
+}
+
+char* SALOMEDS_GenericAttribute_i::Type() {
+ if (_myAttr.IsNull()) return "";
+ int i;
+ for(i = 0; i < RegisteredAttributes; i++) {
+ if (_myAttr->ID() == AttributesGUIDs[i]) {
+ CORBA::String_var aString(AttributesTypeNames[i]);
+ return aString._retn();
+ }
+ }
+ Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr);
+ if (!aNode.IsNull()) {
+ char* aNodeName = new char[60];
+ char aGUID[40];
+ aNode->ID().ToCString(aGUID);
+ sprintf(aNodeName, "AttributeTreeNodeGUID%s",aGUID);
+ return aNodeName;
+ }
+
+ Handle(TDataStd_UAttribute) aUAttr = Handle(TDataStd_UAttribute)::DownCast(_myAttr);
+ if (!aUAttr.IsNull()) {
+ char* aUAttrName = new char[60];
+ char aGUID[40];
+ aUAttr->ID().ToCString(aGUID);
+ sprintf(aUAttrName, "AttributeUserID_%s",aGUID);
+ return aUAttrName;
+ }
+
+ return "";
+}
+
+SALOMEDS::GenericAttribute_ptr SALOMEDS_GenericAttribute_i::CreateAttribute(CORBA::ORB_ptr theOrb,
+ const Handle(TDF_Attribute)& theAttr) {
+
+ __ReturnCORBAAttribute(TDataStd_Real, AttributeReal);
+ __ReturnCORBAAttribute(TDataStd_Integer, AttributeInteger);
+ __ReturnCORBAAttribute(SALOMEDS_SequenceOfRealAttribute, AttributeSequenceOfReal);
+ __ReturnCORBAAttribute(SALOMEDS_SequenceOfIntegerAttribute, AttributeSequenceOfInteger);
+ __ReturnCORBAAttribute(TDataStd_Name, AttributeName);
+ __ReturnCORBAAttribute(TDataStd_Comment, AttributeComment);
+ __ReturnCORBAAttribute(SALOMEDS_IORAttribute, AttributeIOR);
+ __ReturnCORBAAttribute(SALOMEDS_PersRefAttribute, AttributePersistentRef);
+ __ReturnCORBAAttribute(SALOMEDS_DrawableAttribute, AttributeDrawable);
+ __ReturnCORBAAttribute(SALOMEDS_SelectableAttribute, AttributeSelectable);
+ __ReturnCORBAAttribute(SALOMEDS_ExpandableAttribute, AttributeExpandable);
+ __ReturnCORBAAttribute(SALOMEDS_OpenedAttribute, AttributeOpened);
+ __ReturnCORBAAttribute(SALOMEDS_TextColorAttribute, AttributeTextColor);
+ __ReturnCORBAAttribute(SALOMEDS_TextHighlightColorAttribute, AttributeTextHighlightColor);
+ __ReturnCORBAAttribute(SALOMEDS_PixMapAttribute, AttributePixMap);
+ __ReturnCORBAAttribute(SALOMEDS_LocalIDAttribute, AttributeLocalID);
+ __ReturnCORBAAttribute(SALOMEDS_TargetAttribute, AttributeTarget);
+ __ReturnCORBAAttribute(SALOMEDS_TableOfIntegerAttribute, AttributeTableOfInteger);
+ __ReturnCORBAAttribute(SALOMEDS_TableOfRealAttribute, AttributeTableOfReal);
+ __ReturnCORBAAttribute(SALOMEDS_TableOfStringAttribute, AttributeTableOfString);
+ __ReturnCORBAAttribute(SALOMEDS_StudyPropertiesAttribute, AttributeStudyProperties);
+ __ReturnCORBAAttribute(SALOMEDS_PythonObjectAttribute, AttributePythonObject);
+ __ReturnCORBAAttribute(SALOMEDS_ExternalFileDef, AttributeExternalFileDef);
+ __ReturnCORBAAttribute(SALOMEDS_FileType, AttributeFileType);
+
+ Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(theAttr);
+ if (!aNode.IsNull()) {
+ SALOMEDS_AttributeTreeNode_i* Attr = new SALOMEDS_AttributeTreeNode_i(aNode, theOrb); \
+ return Attr->AttributeTreeNode::_this(); \
+ }
+
+ Handle(TDataStd_UAttribute) aUAttr = Handle(TDataStd_UAttribute)::DownCast(theAttr);
+ if (!aUAttr.IsNull()) {
+ SALOMEDS_AttributeUserID_i* Attr = new SALOMEDS_AttributeUserID_i(aUAttr, theOrb); \
+ return Attr->AttributeUserID::_this(); \
+ }
+ return SALOMEDS::GenericAttribute::_nil();
+}
#include CORBA_SERVER_HEADER(SALOMEDS)
#include <TDF_Attribute.hxx>
#include "SALOMEDS_SObject_i.hxx"
-#include "SALOMEDS_IORAttribute.hxx"
class SALOMEDS_GenericAttribute_i: public POA_SALOMEDS::GenericAttribute,
public PortableServer::RefCountServantBase {
SALOMEDS_GenericAttribute_i() {};
void CheckLocked() throw (SALOMEDS::GenericAttribute::LockProtection);
+
+ char* Store() {return "";};
+
+ void Restore(const char*) {};
- ~SALOMEDS_GenericAttribute_i() {};
+ char* Type();
-// CORBA::Boolean GetPtr(SALOMEDS::SObject_out so) {
-// SALOMEDS_SObject_i* sob_impl = new SALOMEDS_SObject_i(_myAttr->Label(), _myOrb);
-// SALOMEDS::SObject_var sob = sob_impl->_this();
-// return sob._retn();
-// };
+ SALOMEDS::SObject_ptr GetSObject();
+
+ ~SALOMEDS_GenericAttribute_i() {};
+ static Standard_GUID GetGUID(const char* theType);
+ static SALOMEDS::GenericAttribute_ptr CreateAttribute(CORBA::ORB_ptr theOrb, const Handle(TDF_Attribute)& theAttr);
};
+// defines for creation attributes objects
+
+//cout<<"*** Create new CORBA attribute for "<<#CORBA_Name<<endl;
+#define __ReturnCORBAAttribute(OCAF_Name, CORBA_Name) if (theAttr->ID() == OCAF_Name::GetID()) { \
+ SALOMEDS_##CORBA_Name##_i* Attr = new SALOMEDS_##CORBA_Name##_i(Handle(OCAF_Name)::DownCast(theAttr), theOrb); \
+ return Attr->CORBA_Name::_this(); \
+ }
+
+//cout<<"Create New Attribute "<<#CORBA_Name<<endl;
+#define __FindOrCreateAttribute(OCAF_Name, CORBA_Name) if (strcmp(aTypeOfAttribute, #CORBA_Name) == 0) { \
+ Handle(OCAF_Name) anAttr; \
+ if (!Lab.FindAttribute(OCAF_Name::GetID(), anAttr)) { \
+ anAttr = new OCAF_Name; \
+ Lab.AddAttribute(anAttr); \
+ } \
+ SALOMEDS_##CORBA_Name##_i* Attr = new SALOMEDS_##CORBA_Name##_i(anAttr, _orb); \
+ return Attr->CORBA_Name::_this(); \
+ }
+
+//cout<<"Create New Attribute "<<#CORBA_Name<<endl;
+#define __FindOrCreateAttributeLocked(OCAF_Name, CORBA_Name) if (strcmp(aTypeOfAttribute, #CORBA_Name) == 0) { \
+ Handle(OCAF_Name) anAttr; \
+ if (!Lab.FindAttribute(OCAF_Name::GetID(), anAttr)) { \
+ CheckLocked(); \
+ anAttr = new OCAF_Name; \
+ Lab.AddAttribute(anAttr); \
+ } \
+ SALOMEDS_##CORBA_Name##_i* Attr = new SALOMEDS_##CORBA_Name##_i(anAttr, _orb); \
+ return Attr->CORBA_Name::_this(); \
+ }
+
#endif
// File : SALOMEDS_LocalIDAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
using namespace std;
#include "SALOMEDS_LocalIDAttribute.ixx"
// File : SALOMEDS_LocalIDAttribute.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef _SALOMEDS_LocalIDAttribute_HeaderFile
#define _SALOMEDS_LocalIDAttribute_HeaderFile
// File : SALOMEDS_LocalIDAttribute.ixx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#include "SALOMEDS_LocalIDAttribute.jxx"
// File : SALOMEDS_LocalIDAttribute.jxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef _Standard_GUID_HeaderFile
#include <Standard_GUID.hxx>
// File : SALOMEDS_OpenedAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
using namespace std;
#include "SALOMEDS_OpenedAttribute.ixx"
// File : SALOMEDS_PixMapAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
using namespace std;
#include "SALOMEDS_PixMapAttribute.ixx"
#include "SALOMEDS_SObject_i.hxx"
//SALOMEDS Headers
#include "SALOMEDS_SComponent_i.hxx"
+#include "SALOMEDS_GenericAttribute_i.hxx"
#include "SALOMEDS_IORAttribute.hxx"
-#include "SALOMEDS_PersRefAttribute.hxx"
-#include "SALOMEDS_SequenceOfRealAttribute.hxx"
-#include "SALOMEDS_SequenceOfIntegerAttribute.hxx"
-#include "SALOMEDS_TableOfRealAttribute.hxx"
-#include "SALOMEDS_TableOfIntegerAttribute.hxx"
-#include "SALOMEDS_IORAttribute.hxx"
-#include "SALOMEDS_PersRefAttribute.hxx"
-#include "SALOMEDS_StudyPropertiesAttribute.hxx"
-#include "SALOMEDS_PythonObjectAttribute.hxx"
-#include "SALOMEDS_AttributePersistentRef_i.hxx"
-#include "SALOMEDS_AttributeIOR_i.hxx"
-#include "SALOMEDS_AttributeComment_i.hxx"
-#include "SALOMEDS_AttributeExternalFileDef_i.hxx"
-#include "SALOMEDS_AttributeFileType_i.hxx"
-#include "SALOMEDS_AttributeName_i.hxx"
-#include "SALOMEDS_AttributeSequenceOfInteger_i.hxx"
-#include "SALOMEDS_AttributeSequenceOfReal_i.hxx"
-#include "SALOMEDS_AttributeInteger_i.hxx"
-#include "SALOMEDS_AttributeReal_i.hxx"
-#include "SALOMEDS_AttributeDrawable_i.hxx"
-#include "SALOMEDS_AttributeSelectable_i.hxx"
-#include "SALOMEDS_AttributeExpandable_i.hxx"
-#include "SALOMEDS_AttributeOpened_i.hxx"
-#include "SALOMEDS_AttributeTextColor_i.hxx"
-#include "SALOMEDS_AttributeTextHighlightColor_i.hxx"
-#include "SALOMEDS_AttributePixMap_i.hxx"
-#include "SALOMEDS_AttributeTreeNode_i.hxx"
-#include "SALOMEDS_AttributeLocalID_i.hxx"
-#include "SALOMEDS_AttributeUserID_i.hxx"
-#include "SALOMEDS_AttributeTarget_i.hxx"
-#include "SALOMEDS_AttributeTableOfInteger_i.hxx"
-#include "SALOMEDS_AttributeTableOfReal_i.hxx"
-#include "SALOMEDS_AttributeTableOfString_i.hxx"
-#include "SALOMEDS_AttributeStudyProperties_i.hxx"
-#include "SALOMEDS_AttributePythonObject_i.hxx"
#include <TDF_AttributeIterator.hxx>
-//============================================================================
-/*! 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 :
ASSERT(!CORBA::is_nil(Study));
return SALOMEDS::Study::_duplicate(Study); //return Study = abort...
}
- INFOS("Problem GetStudy");
+ MESSAGE("Problem GetStudy");
return SALOMEDS::Study::_nil();
}
const char* aTypeOfAttribute)
{
Handle(TDF_Attribute) anAttr;
- Standard_Boolean found = _lab.FindAttribute(SALOMEDS_SObject_i::ReturnGUIDForAttribute(aTypeOfAttribute), anAttr);
- if (found) {
- if (strcmp(aTypeOfAttribute, "AttributeReal") == 0 ) {
- SALOMEDS_AttributeReal_i* Attr = new SALOMEDS_AttributeReal_i(Handle(TDataStd_Real)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeReal::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeInteger") == 0 ) {
- SALOMEDS_AttributeInteger_i* Attr = new SALOMEDS_AttributeInteger_i(Handle(TDataStd_Integer)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeInteger::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfReal") == 0 ) {
- SALOMEDS_AttributeSequenceOfReal_i* Attr = new SALOMEDS_AttributeSequenceOfReal_i(Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeSequenceOfReal::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfInteger") == 0 ) {
- SALOMEDS_AttributeSequenceOfInteger_i* Attr = new SALOMEDS_AttributeSequenceOfInteger_i(Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeSequenceOfInteger::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeName") == 0 ) {
- SALOMEDS_AttributeName_i* Attr = new SALOMEDS_AttributeName_i(Handle(TDataStd_Name)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeName::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeComment") == 0 ) {
- SALOMEDS_AttributeComment_i* Attr = new SALOMEDS_AttributeComment_i(Handle(TDataStd_Comment)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeComment::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeExternalFileDef") == 0 ) {
- SALOMEDS_AttributeExternalFileDef_i* Attr = new SALOMEDS_AttributeExternalFileDef_i(Handle(SALOMEDS_ExternalFileDef)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeExternalFileDef::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeFileType") == 0 ) {
- SALOMEDS_AttributeFileType_i* Attr = new SALOMEDS_AttributeFileType_i(Handle(SALOMEDS_FileType)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeFileType::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0 ) {
- SALOMEDS_AttributeIOR_i* Attr = new SALOMEDS_AttributeIOR_i(Handle(SALOMEDS_IORAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeIOR::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributePersistentRef") == 0 ) {
- SALOMEDS_AttributePersistentRef_i* Attr = new SALOMEDS_AttributePersistentRef_i(Handle(SALOMEDS_PersRefAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributePersistentRef::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeDrawable") == 0 ) {
- SALOMEDS_AttributeDrawable_i* Attr = new SALOMEDS_AttributeDrawable_i(Handle(SALOMEDS_DrawableAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeDrawable::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeSelectable") == 0 ) {
- SALOMEDS_AttributeSelectable_i* Attr= new SALOMEDS_AttributeSelectable_i(Handle(SALOMEDS_SelectableAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeSelectable::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeExpandable") == 0 ) {
- SALOMEDS_AttributeExpandable_i* Attr = new SALOMEDS_AttributeExpandable_i(Handle(SALOMEDS_ExpandableAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeExpandable::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeOpened") == 0 ) {
- SALOMEDS_AttributeOpened_i* Attr= new SALOMEDS_AttributeOpened_i(Handle(SALOMEDS_OpenedAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeOpened::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeTextColor") == 0 ) {
- SALOMEDS_AttributeTextColor_i* Attr= new SALOMEDS_AttributeTextColor_i(Handle(SALOMEDS_TextColorAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTextColor::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeTextHighlightColor") == 0 ) {
- SALOMEDS_AttributeTextHighlightColor_i* Attr= new SALOMEDS_AttributeTextHighlightColor_i(Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTextHighlightColor::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributePixMap") == 0 ) {
- SALOMEDS_AttributePixMap_i* Attr= new SALOMEDS_AttributePixMap_i(Handle(SALOMEDS_PixMapAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributePixMap::_this();
- return Standard_True;
- }
- else if (strncmp(aTypeOfAttribute, "AttributeTreeNode",17) == 0 ) {
- SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTreeNode::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeLocalID") == 0 ) {
- SALOMEDS_AttributeLocalID_i* Attr= new SALOMEDS_AttributeLocalID_i(Handle(SALOMEDS_LocalIDAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeLocalID::_this();
- return Standard_True;
- }
- else if (strncmp(aTypeOfAttribute, "AttributeUserID",15) == 0 ) {
- SALOMEDS_AttributeUserID_i* Attr= new SALOMEDS_AttributeUserID_i(Handle(TDataStd_UAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeUserID::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeTarget") == 0 ) {
- SALOMEDS_AttributeTarget_i* Attr= new SALOMEDS_AttributeTarget_i(Handle(SALOMEDS_TargetAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTarget::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeTableOfInteger") == 0 ) {
- SALOMEDS_AttributeTableOfInteger_i* Attr = new SALOMEDS_AttributeTableOfInteger_i(Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTableOfInteger::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeTableOfReal") == 0 ) {
- SALOMEDS_AttributeTableOfReal_i* Attr = new SALOMEDS_AttributeTableOfReal_i(Handle(SALOMEDS_TableOfRealAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTableOfReal::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeTableOfString") == 0 ) {
- SALOMEDS_AttributeTableOfString_i* Attr = new SALOMEDS_AttributeTableOfString_i(Handle(SALOMEDS_TableOfStringAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTableOfString::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeStudyProperties") == 0 ) {
- SALOMEDS_AttributeStudyProperties_i* Attr = new SALOMEDS_AttributeStudyProperties_i(Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeStudyProperties::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributePythonObject") == 0 ) {
- SALOMEDS_AttributePythonObject_i* Attr = new SALOMEDS_AttributePythonObject_i(Handle(SALOMEDS_PythonObjectAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributePythonObject::_this();
- return Standard_True;
- }
- } else return Standard_False;
+ if (_lab.FindAttribute(SALOMEDS_GenericAttribute_i::GetGUID(aTypeOfAttribute), anAttr)) {
+ anAttribute = SALOMEDS::GenericAttribute::_duplicate(SALOMEDS_GenericAttribute_i::CreateAttribute(_orb, anAttr));
+ return Standard_True;
+ }
+ return Standard_False;
}
//============================================================================
{
Standard_Integer NumAttr = _lab.NbAttributes();
SALOMEDS::ListOfAttributes_var SeqOfAttr = new SALOMEDS::ListOfAttributes;
- SeqOfAttr->length(NumAttr);
+ //SeqOfAttr->length(NumAttr);
if (NumAttr != 0) {
Standard_Integer i = 0;
for(TDF_AttributeIterator iter(_lab);iter.More();iter.Next()) {
Handle(TDF_Attribute) anAttr = iter.Value();
- SALOMEDS::GenericAttribute_var anAttribute;
- if (ReturnGUIDForAttribute("AttributeReal") == anAttr->ID()) {
- SALOMEDS_AttributeReal_i* Attr= new SALOMEDS_AttributeReal_i(Handle(TDataStd_Real)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeReal::_this();
- }
- else if (ReturnGUIDForAttribute("AttributeInteger") == anAttr->ID()) {
- SALOMEDS_AttributeInteger_i* Attr= new SALOMEDS_AttributeInteger_i(Handle(TDataStd_Integer)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeInteger::_this();
- }
- else if (ReturnGUIDForAttribute("AttributeSequenceOfReal") == anAttr->ID()) {
- SALOMEDS_AttributeSequenceOfReal_i* Attr= new SALOMEDS_AttributeSequenceOfReal_i(Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeSequenceOfReal::_this();
- }
- else if (ReturnGUIDForAttribute("AttributeSequenceOfInteger") == anAttr->ID()) {
- SALOMEDS_AttributeSequenceOfInteger_i* Attr= new SALOMEDS_AttributeSequenceOfInteger_i(Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeSequenceOfInteger::_this();
- }
- else if (ReturnGUIDForAttribute("AttributeName") == anAttr->ID()) {
- SALOMEDS_AttributeName_i* Attr= new SALOMEDS_AttributeName_i(Handle(TDataStd_Name)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeName::_this();
- }
- else if (ReturnGUIDForAttribute("AttributeComment") == anAttr->ID()) {
- SALOMEDS_AttributeComment_i* Attr= new SALOMEDS_AttributeComment_i(Handle(TDataStd_Comment)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeComment::_this();
- }
- else if (ReturnGUIDForAttribute("AttributeExternalFileDef") == anAttr->ID()) {
- SALOMEDS_AttributeExternalFileDef_i* Attr= new SALOMEDS_AttributeExternalFileDef_i(Handle(SALOMEDS_ExternalFileDef)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeExternalFileDef::_this();
- }
- else if (ReturnGUIDForAttribute("AttributeFileType") == anAttr->ID()) {
- SALOMEDS_AttributeFileType_i* Attr= new SALOMEDS_AttributeFileType_i(Handle(SALOMEDS_FileType)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeFileType::_this();
- }
- else if (ReturnGUIDForAttribute("AttributeIOR") == anAttr->ID()) {
- SALOMEDS_AttributeIOR_i* Attr= new SALOMEDS_AttributeIOR_i(Handle(SALOMEDS_IORAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeIOR::_this();
- }
- else if (ReturnGUIDForAttribute("AttributePersistentRef") == anAttr->ID()) {
- SALOMEDS_AttributePersistentRef_i* Attr= new SALOMEDS_AttributePersistentRef_i(Handle(SALOMEDS_PersRefAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributePersistentRef::_this();
+ SALOMEDS::GenericAttribute_var anAttribute = SALOMEDS_GenericAttribute_i::CreateAttribute(_orb, anAttr);
+ if (!CORBA::is_nil(anAttribute)) {
+ SeqOfAttr->length(++i);
+ SeqOfAttr[i - 1] = anAttribute;
}
- else if (ReturnGUIDForAttribute("AttributeDrawable") == anAttr->ID()) {
- SALOMEDS_AttributeDrawable_i* Attr= new SALOMEDS_AttributeDrawable_i(Handle(SALOMEDS_DrawableAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeDrawable::_this();
- }
- else if (ReturnGUIDForAttribute("AttributeSelectable") == anAttr->ID()) {
- SALOMEDS_AttributeSelectable_i* Attr= new SALOMEDS_AttributeSelectable_i(Handle(SALOMEDS_SelectableAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeSelectable::_this();
- }
- else if (ReturnGUIDForAttribute("AttributeExpandable") == anAttr->ID()) {
- SALOMEDS_AttributeExpandable_i* Attr= new SALOMEDS_AttributeExpandable_i(Handle(SALOMEDS_ExpandableAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeExpandable::_this();
- }
- else if (ReturnGUIDForAttribute("AttributeOpened") == anAttr->ID()) {
- SALOMEDS_AttributeOpened_i* Attr= new SALOMEDS_AttributeOpened_i(Handle(SALOMEDS_OpenedAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeOpened::_this();
- }
- else if (ReturnGUIDForAttribute("AttributeTextColor") == anAttr->ID()) {
- SALOMEDS_AttributeTextColor_i* Attr= new SALOMEDS_AttributeTextColor_i(Handle(SALOMEDS_TextColorAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTextColor::_this();
- }
- else if (ReturnGUIDForAttribute("AttributeTextHighlightColor") == anAttr->ID()) {
- SALOMEDS_AttributeTextHighlightColor_i* Attr= new SALOMEDS_AttributeTextHighlightColor_i(Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTextHighlightColor::_this();
- }
- else if (ReturnGUIDForAttribute("AttributePixMap") == anAttr->ID()) {
- SALOMEDS_AttributePixMap_i* Attr= new SALOMEDS_AttributePixMap_i(Handle(SALOMEDS_PixMapAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributePixMap::_this();
- }
- else if (ReturnGUIDForAttribute("AttributeTreeNode") == anAttr->ID()) {
- SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTreeNode::_this();
- }
- else if (ReturnGUIDForAttribute("AttributeLocalID") == anAttr->ID()) {
- SALOMEDS_AttributeLocalID_i* Attr= new SALOMEDS_AttributeLocalID_i(Handle(SALOMEDS_LocalIDAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeLocalID::_this();
- }
- else if (ReturnGUIDForAttribute("AttributeTarget") == anAttr->ID()) {
- SALOMEDS_AttributeTarget_i* Attr= new SALOMEDS_AttributeTarget_i(Handle(SALOMEDS_TargetAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTarget::_this();
- }
- else if (ReturnGUIDForAttribute("AttributeTableOfInteger") == anAttr->ID()) {
- SALOMEDS_AttributeTableOfInteger_i* Attr= new SALOMEDS_AttributeTableOfInteger_i(Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTableOfInteger::_this();
- }
- else if (ReturnGUIDForAttribute("AttributeTableOfReal") == anAttr->ID()) {
- SALOMEDS_AttributeTableOfReal_i* Attr= new SALOMEDS_AttributeTableOfReal_i(Handle(SALOMEDS_TableOfRealAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTableOfReal::_this();
- }
- else if (ReturnGUIDForAttribute("AttributeTableOfString") == anAttr->ID()) {
- SALOMEDS_AttributeTableOfString_i* Attr= new SALOMEDS_AttributeTableOfString_i(Handle(SALOMEDS_TableOfStringAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTableOfString::_this();
- }
- else if (ReturnGUIDForAttribute("AttributeStudyProperties") == anAttr->ID()) {
- SALOMEDS_AttributeStudyProperties_i* Attr= new SALOMEDS_AttributeStudyProperties_i(Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeStudyProperties::_this();
- }
- else if (ReturnGUIDForAttribute("AttributePythonObject") == anAttr->ID()) {
- SALOMEDS_AttributePythonObject_i* Attr= new SALOMEDS_AttributePythonObject_i(Handle(SALOMEDS_PythonObjectAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributePythonObject::_this();
- }
- else if (!Handle(TDataStd_UAttribute)::DownCast(anAttr).IsNull()) {
- SALOMEDS_AttributeUserID_i* Attr= new SALOMEDS_AttributeUserID_i(Handle(TDataStd_UAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeUserID::_this();
- }
- else if (!Handle(TDataStd_TreeNode)::DownCast(anAttr).IsNull()) {
- SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTreeNode::_this();
- } else {
- // references attributes, for an example, never returns
- continue;
- }
-
- SeqOfAttr[i] = anAttribute;
- i++;
}
}
return SeqOfAttr._retn();
{
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();
+}
virtual void Name(const char*);
virtual SALOMEDS::ListOfAttributes* GetAllAttributes();
+ virtual CORBA::Object_ptr GetObject();
+
+ virtual char* GetName();
+ virtual char* GetComment();
+ virtual char* GetIOR();
virtual CORBA::Short Tag();
static char* AttributeIDToType(Standard_GUID);
static Standard_GUID ReturnGUIDForAttribute(const char* aTypeOfAttribute);
-
};
#endif
// File : SALOMEDS_SelectableAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
using namespace std;
#include "SALOMEDS_SelectableAttribute.ixx"
// File : SALOMEDS_SequenceOfIntegerAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
using namespace std;
#include "SALOMEDS_SequenceOfIntegerAttribute.ixx"
// File : SALOMEDS_SequenceOfRealAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
using namespace std;
#include "SALOMEDS_SequenceOfRealAttribute.ixx"
#include "SALOMEDS_TargetAttribute.hxx"
#include "SALOMEDS_StudyPropertiesAttribute.hxx"
#include "SALOMEDS_PythonObjectAttribute.hxx"
+#include "SALOMEDS_ExternalFileDef.hxx"
+#include "SALOMEDS_FileType.hxx"
#include <TDF_ChildIterator.hxx>
#include <TDF_Label.hxx>
#include <TDataStd_Name.hxx>
#include <TDataStd_Comment.hxx>
#include <TDataStd_UAttribute.hxx>
+#include <TDataStd_Real.hxx>
#include <TDF_Tool.hxx>
#include <TDF_Reference.hxx>
#include <TDF_Data.hxx>
#include <TDF_ListIteratorOfAttributeList.hxx>
#include "SALOMEDS_AttributePersistentRef_i.hxx"
#include "SALOMEDS_AttributeIOR_i.hxx"
-#include "SALOMEDS_AttributeComment_i.hxx"
#include "SALOMEDS_AttributeExternalFileDef_i.hxx"
#include "SALOMEDS_AttributeFileType_i.hxx"
+#include "SALOMEDS_AttributeComment_i.hxx"
#include "SALOMEDS_AttributeName_i.hxx"
#include "SALOMEDS_AttributeSequenceOfInteger_i.hxx"
#include "SALOMEDS_AttributeSequenceOfReal_i.hxx"
#include "SALOMEDS_AttributePythonObject_i.hxx"
#include "SALOMEDS_Tool.hxx"
#include "Utils_CorbaException.hxx"
+#include "Utils_ExceptHandlers.hxx"
#include <HDFOI.hxx>
#include <stdlib.h>
#define DIRECTORYID 16661
#define FILELOCALID 26662
+UNEXPECT_CATCH(SBSalomeException, SALOME::SALOME_Exception);
+UNEXPECT_CATCH(SBLockProtection, SALOMEDS::StudyBuilder::LockProtection);
//============================================================================
/*! Function : constructor
* Purpose :
imax++;
TDF_Label NL = L.FindChild(imax);
-// TDataStd_Comment::Set(NL,Standard_CString(DataType));
- TDataStd_Comment::Set(NL,Standard_CString(strdup(DataType)));
+ TDataStd_Comment::Set(NL,Standard_CString(DataType));
+ // TDataStd_Comment::Set(NL,Standard_CString(CORBA::string_dup(DataType)));
SALOMEDS_SComponent_i * so_servant = new SALOMEDS_SComponent_i (NL,_orb);
SALOMEDS::SComponent_var so;
TDF_Label Lab;
ASSERT(!CORBA::is_nil(aComponent));
CORBA::String_var compid = aComponent->GetID();
- TDF_Tool::Label(_doc->GetData(),strdup(compid),Lab);
+ TDF_Tool::Label(_doc->GetData(),compid,Lab);
//add IOR definition
ASSERT(!CORBA::is_nil(IOR));
CORBA::String_var iorstr = _orb->object_to_string(IOR);
- SALOMEDS_IORAttribute::Set(Lab,strdup(iorstr),_orb);
+ SALOMEDS_IORAttribute::Set(Lab,(char*)iorstr,_orb);
}
ASSERT(!CORBA::is_nil(theFatherObject));
CORBA::String_var fatherid = theFatherObject->GetID();
- TDF_Tool::Label(_doc->GetData(),strdup(fatherid),Lab);
+ TDF_Tool::Label(_doc->GetData(),fatherid,Lab);
//Create a new label
//YFR DEBUG : 13/02/2002 TDF_Label NewLab = Lab.NewChild();
ASSERT(!CORBA::is_nil(theFatherObject));
CORBA::String_var fatherid = theFatherObject->GetID();
- TDF_Tool::Label(_doc->GetData(),strdup(fatherid),Lab);
+ TDF_Tool::Label(_doc->GetData(),fatherid,Lab);
//Create or find label
TDF_Label NewLab = Lab.FindChild(atag,1);
Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects
if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr))
- SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(strdup(TCollection_AsciiString(anAttr->Get()).ToCString()));
+ SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
Lab.ForgetAllAttributes();
}
}
Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects
if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr))
- SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(strdup(TCollection_AsciiString(anAttr->Get()).ToCString()));
+ SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
- TDF_ChildIterator it(Lab);
+ TDF_ChildIterator it(Lab, Standard_True);
for(;it.More();it.Next()) {
TDF_Label aLabel = it.Value();
if (aLabel.FindAttribute(TDF_Reference::GetID(), aReference)) {
}
Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects
if (aLabel.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr))
- SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(strdup(TCollection_AsciiString(anAttr->Get()).ToCString()));
+ SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
}
Lab.ForgetAllAttributes(Standard_True);
CORBA::String_var ior_string = driver->LocalPersistentIDToIOR(so, persistent_string, isMultiFile, isASCII);
- TCollection_ExtendedString value(strdup(ior_string ));
+ TCollection_ExtendedString value(ior_string);
SALOMEDS_IORAttribute::Set (current,value,orb);
//TCollection_AsciiString anEntry;TDF_Tool::Entry (current,anEntry); //SRN: No use here
void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO,
SALOMEDS::Driver_ptr aDriver) throw(SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SBSalomeException);
TDF_Label Lab;
ASSERT(!CORBA::is_nil(anSCO));
CORBA::String_var scoid = anSCO->GetID();
- TDF_Tool::Label(_doc->GetData(),strdup(scoid),Lab);
+ TDF_Tool::Label(_doc->GetData(),scoid,Lab);
Handle(TDF_Attribute) Att;
-
+
//Find the current Url of the study
if (_doc->Main().FindAttribute(SALOMEDS_PersRefAttribute::GetID(),Att)) {
int aLocked = anSCO->GetStudy()->GetProperties()->IsLocked();
if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(false);
-
+
TCollection_ExtendedString Res = Handle(TDataStd_Comment)::DownCast(Att)->Get();
Handle(TDataStd_Comment) type;
DataType = type->Get();
else
MESSAGE("No Data Type");
-
+
// associate the driver to the SComponent
ASSERT(!CORBA::is_nil(aDriver));
// mpv 06.03.2003: SAL1927 - if component data if already loaded, it is not necessary to do it again
return;
}
DefineComponentInstance (anSCO, aDriver);
-
+
TCollection_AsciiString aHDFPath(Res);
-
+
char* aHDFUrl;
bool isASCII = false;
if (HDFascii::isASCII(aHDFPath.ToCString())) {
sprintf(aHDFUrl, "%shdf_from_ascii.hdf", aResultPath);
delete(aResultPath);
} else {
- aHDFUrl = strdup(aHDFPath.ToCString());
+ aHDFUrl = CORBA::string_dup(aHDFPath.ToCString());
}
//Open the Study HDF file
HDFfile *hdf_file = new HDFfile(aHDFUrl);
-
+
char aMultifileState[2];
char ASCIIfileState[2];
try {
hdf_group->OpenOnDisk();
HDFgroup *hdf_sco_group = new HDFgroup(scoid, hdf_group);
hdf_sco_group->OpenOnDisk();
-
+
SALOMEDS::TMPFile_var aStreamFile;
if (hdf_sco_group->ExistInternalObject("FILE_STREAM")) {
HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group);
HDFdataset *multifile_hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group);
multifile_hdf_dataset->OpenOnDisk();
multifile_hdf_dataset->ReadFromDisk(aMultifileState);
-
+
HDFdataset *ascii_hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group);
ascii_hdf_dataset->OpenOnDisk();
ascii_hdf_dataset->ReadFromDisk(ASCIIfileState);
-
+
// set path without file name from URL
int aFileNameSize = Res.Length();
char* aDir = new char[aFileNameSize];
aDir[aCounter+1] = 0;
break;
}
-
+
CORBA::Boolean aResult = (ASCIIfileState[0]=='A')?
aDriver->LoadASCII(anSCO, aStreamFile.in(), aDir, aMultifileState[0]=='M'):
- aDriver->Load(anSCO, aStreamFile.in(), aDir, aMultifileState[0]=='M');
+ aDriver->Load(anSCO, aStreamFile.in(), aDir, aMultifileState[0]=='M');
if(!aResult) {
RemoveAttribute( anSCO, "AttributeIOR" );
if (isASCII) {
SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
aFilesToRemove->length(1);
- aFilesToRemove[0] = strdup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))]));
+ aFilesToRemove[0] = CORBA::string_dup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))]));
SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true);
}
delete aHDFUrl;
MESSAGE("Can't load component");
THROW_SALOME_CORBA_EXCEPTION("Unable to load component data",SALOME::BAD_PARAM);
-// throw HDFexception("Unable to load component");
+ // throw HDFexception("Unable to load component");
}
-
+
delete(aDir);
multifile_hdf_dataset->CloseOnDisk();
hdf_group = 0;
hdf_file->CloseOnDisk();
delete hdf_file;
-
+
if (isASCII) {
SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
aFilesToRemove->length(1);
- aFilesToRemove[0] = strdup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))]));
+ aFilesToRemove[0] = CORBA::string_dup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))]));
SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true);
}
delete aHDFUrl;
}
catch (HDFexception) {
- MESSAGE("No persistent file Name");
+ INFOS("No persistent file Name");
delete hdf_file;
if (isASCII) {
SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
aFilesToRemove->length(1);
- aFilesToRemove[0] = strdup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))]));
+ aFilesToRemove[0] = CORBA::string_dup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))]));
SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true);
}
delete aHDFUrl;
try {
Translate_persistentID_to_IOR (Lab,aDriver,_orb, aMultifileState[0]=='M', ASCIIfileState[0] == 'A');
} catch (SALOME::SALOME_Exception) {
- MESSAGE("Can't translate PersRef to IOR");
+ INFOS("Can't translate PersRef to IOR");
if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true);
THROW_SALOME_CORBA_EXCEPTION("Unable to convert component persistent data to the transient",SALOME::BAD_PARAM);
-// throw HDFexception("Unable to load component data");
+ // throw HDFexception("Unable to load component data");
}
if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true);
} else
MESSAGE ( "This function is not yet implemented");
}
-//============================================================================
-/*! Function : AddAttribute
- * Purpose :
- */
-//============================================================================
-/*
-void SALOMEDS_StudyBuilder_i::AddAttribute(SALOMEDS::SObject_ptr anObject,
- SALOMEDS::AttributeType aType,
- const char * AttributeValue )
-{
- TDF_Label Lab;
- ASSERT(!CORBA::is_nil(anObject));
- CORBA::String_var anobid = anObject->GetID();
- TDF_Tool::Label(_doc->GetData(),strdup(anobid),Lab);
-
- TCollection_ExtendedString Value(strdup(AttributeValue));
-
- Standard_GUID ID = SALOMEDS_SObject_i::TypeToAttributeID(aType);
-
- if (ID == TDataStd_Name::GetID()) TDataStd_Name::Set (Lab,Value);
- else if (ID == TDataStd_Comment::GetID()) TDataStd_Comment::Set (Lab,Value);
- else if (ID == SALOMEDS_IORAttribute::GetID()) SALOMEDS_IORAttribute::Set (Lab,Value);
- else if (ID == SALOMEDS_PersRefAttribute::GetID()) SALOMEDS_PersRefAttribute::Set(Lab,Value);
-}
-*/
//============================================================================
/*! Function : FindOrCreateAttribute
* Purpose : Add attribute of given type to SObject, if there is attribute of such type, returns
* existing one
*/
//============================================================================
-
SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SALOMEDS::SObject_ptr anObject,
const char* aTypeOfAttribute)
{
TDF_Label Lab;
ASSERT(!CORBA::is_nil(anObject));
CORBA::String_var anobid = anObject->GetID();
- TDF_Tool::Label(_doc->GetData(),strdup(anobid),Lab);
-
- if (strcmp(aTypeOfAttribute, "AttributeReal") == 0 ) {
- Handle(TDataStd_Real) anAttr;
- if (!Lab.FindAttribute(TDataStd_Real::GetID(), anAttr)) {
- CheckLocked();
- anAttr = new TDataStd_Real;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributeReal_i* aRealAttr = new SALOMEDS_AttributeReal_i(anAttr, _orb);
- SALOMEDS::AttributeReal_var aRA = aRealAttr->AttributeReal::_this();
- return aRA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributeInteger") == 0 ) {
- Handle(TDataStd_Integer) anAttr;
- if (!Lab.FindAttribute(TDataStd_Integer::GetID(), anAttr)) {
- CheckLocked();
- anAttr = new TDataStd_Integer;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributeInteger_i* aIntAttr = new SALOMEDS_AttributeInteger_i(anAttr, _orb);
- SALOMEDS::AttributeInteger_var aIA = aIntAttr->AttributeInteger::_this();
- return aIA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfReal") == 0 ) {
- Handle(SALOMEDS_SequenceOfRealAttribute) anAttr;
- if (!Lab.FindAttribute(SALOMEDS_SequenceOfRealAttribute::GetID(), anAttr)) {
- CheckLocked();
- anAttr = new SALOMEDS_SequenceOfRealAttribute;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributeSequenceOfReal_i* aSeqRealAttr = new SALOMEDS_AttributeSequenceOfReal_i(anAttr, _orb);
- SALOMEDS::AttributeSequenceOfReal_var aSRA = aSeqRealAttr->AttributeSequenceOfReal::_this();
- return aSRA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfInteger") == 0 ) {
- Handle(SALOMEDS_SequenceOfIntegerAttribute) anAttr;
- if (!Lab.FindAttribute(SALOMEDS_SequenceOfIntegerAttribute::GetID(), anAttr)) {
- CheckLocked();
- anAttr = new SALOMEDS_SequenceOfIntegerAttribute;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributeSequenceOfInteger_i* aSeqIntegerAttr = new SALOMEDS_AttributeSequenceOfInteger_i(anAttr, _orb);
- SALOMEDS::AttributeSequenceOfInteger_var aSIA = aSeqIntegerAttr->AttributeSequenceOfInteger::_this();
- return aSIA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributeName") == 0 ) {
- Handle(TDataStd_Name) anAttr;
- if (!Lab.FindAttribute(TDataStd_Name::GetID(), anAttr)) {
- CheckLocked();
- anAttr = new TDataStd_Name;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributeName_i* aNameAttr = new SALOMEDS_AttributeName_i(anAttr, _orb);
- SALOMEDS::AttributeName_var aSNA = aNameAttr->AttributeName::_this();
- return aSNA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributeComment") == 0 ) {
- Handle(TDataStd_Comment) anAttr;
- if (!Lab.FindAttribute(TDataStd_Comment::GetID(), anAttr)) {
- CheckLocked();
- anAttr = new TDataStd_Comment;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributeComment_i* aCommentAttr = new SALOMEDS_AttributeComment_i(anAttr, _orb);
- SALOMEDS::AttributeComment_var aCA = aCommentAttr->AttributeComment::_this();
- return aCA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributeExternalFileDef") == 0 ) {
- Handle(SALOMEDS_ExternalFileDef) anAttr;
- if (!Lab.FindAttribute(SALOMEDS_ExternalFileDef::GetID(), anAttr)) {
- anAttr = new SALOMEDS_ExternalFileDef;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributeExternalFileDef_i* anExternalFileDefAttr = new SALOMEDS_AttributeExternalFileDef_i(anAttr, _orb);
- SALOMEDS::AttributeExternalFileDef_var aCA = anExternalFileDefAttr->AttributeExternalFileDef::_this();
- return aCA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributeFileType") == 0 ) {
- Handle(SALOMEDS_FileType) anAttr;
- if (!Lab.FindAttribute(SALOMEDS_FileType::GetID(), anAttr)) {
- anAttr = new SALOMEDS_FileType;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributeFileType_i* anFileTypeAttr = new SALOMEDS_AttributeFileType_i(anAttr, _orb);
- SALOMEDS::AttributeFileType_var aCA = anFileTypeAttr->AttributeFileType::_this();
- return aCA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0 ) {
- Handle(SALOMEDS_IORAttribute) anAttr;
- if (!Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)) {
- CheckLocked();
- anAttr = new SALOMEDS_IORAttribute;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributeIOR_i* aIORAttr = new SALOMEDS_AttributeIOR_i(anAttr, _orb);
- SALOMEDS::AttributeIOR_var aIA = aIORAttr->AttributeIOR::_this();
- return aIA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributePersistentRef") == 0 ) {
- Handle(SALOMEDS_PersRefAttribute) anAttr;
- if (!Lab.FindAttribute(SALOMEDS_PersRefAttribute::GetID(), anAttr)) {
- anAttr = new SALOMEDS_PersRefAttribute;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributePersistentRef_i* aPerRefAttr = new SALOMEDS_AttributePersistentRef_i(anAttr, _orb);
- SALOMEDS::AttributePersistentRef_var aPRA = aPerRefAttr->AttributePersistentRef::_this();
- return aPRA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributeDrawable") == 0 ) {
- Handle(SALOMEDS_DrawableAttribute) anAttr;
- if (!Lab.FindAttribute(SALOMEDS_DrawableAttribute::GetID(), anAttr)) {
- anAttr = new SALOMEDS_DrawableAttribute;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributeDrawable_i* aDrawableAttr = new SALOMEDS_AttributeDrawable_i(anAttr, _orb);
- SALOMEDS::AttributeDrawable_var aDrawA = aDrawableAttr->AttributeDrawable::_this();
- return aDrawA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributeSelectable") == 0 ) {
- Handle(SALOMEDS_SelectableAttribute) anAttr;
- if (!Lab.FindAttribute(SALOMEDS_SelectableAttribute::GetID(), anAttr)) {
- anAttr = new SALOMEDS_SelectableAttribute;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributeSelectable_i* aSelectableAttr = new SALOMEDS_AttributeSelectable_i(anAttr, _orb);
- SALOMEDS::AttributeSelectable_var aSelA = aSelectableAttr->AttributeSelectable::_this();
- return aSelA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributeExpandable") == 0 ) {
- Handle(SALOMEDS_ExpandableAttribute) anAttr;
- if (!Lab.FindAttribute(SALOMEDS_ExpandableAttribute::GetID(), anAttr)) {
- anAttr = new SALOMEDS_ExpandableAttribute;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributeExpandable_i* aExpandableAttr = new SALOMEDS_AttributeExpandable_i(anAttr, _orb);
- SALOMEDS::AttributeExpandable_var aExpA = aExpandableAttr->AttributeExpandable::_this();
- return aExpA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributeOpened") == 0 ) {
- Handle(SALOMEDS_OpenedAttribute) anAttr;
- if (!Lab.FindAttribute(SALOMEDS_OpenedAttribute::GetID(), anAttr)) {
- anAttr = new SALOMEDS_OpenedAttribute;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributeOpened_i* aOpenedAttr = new SALOMEDS_AttributeOpened_i(anAttr, _orb);
- SALOMEDS::AttributeOpened_var aOpenA = aOpenedAttr->AttributeOpened::_this();
- return aOpenA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributeTextColor") == 0 ) {
- Handle(SALOMEDS_TextColorAttribute) anAttr;
- if (!Lab.FindAttribute(SALOMEDS_TextColorAttribute::GetID(), anAttr)) {
- CheckLocked();
- anAttr = new SALOMEDS_TextColorAttribute;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributeTextColor_i* aTextColorAttr = new SALOMEDS_AttributeTextColor_i(anAttr, _orb);
- SALOMEDS::AttributeTextColor_var aTCA = aTextColorAttr->AttributeTextColor::_this();
- return aTCA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributeTextHighlightColor") == 0 ) {
- Handle(SALOMEDS_TextHighlightColorAttribute) anAttr;
- if (!Lab.FindAttribute(SALOMEDS_TextHighlightColorAttribute::GetID(), anAttr)) {
- CheckLocked();
- anAttr = new SALOMEDS_TextHighlightColorAttribute;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributeTextHighlightColor_i* aTextHighlightColorAttr = new SALOMEDS_AttributeTextHighlightColor_i(anAttr, _orb);
- SALOMEDS::AttributeTextHighlightColor_var aTHCA = aTextHighlightColorAttr->AttributeTextHighlightColor::_this();
- return aTHCA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributePixMap") == 0 ) {
- Handle(SALOMEDS_PixMapAttribute) anAttr;
- if (!Lab.FindAttribute(SALOMEDS_PixMapAttribute::GetID(), anAttr)) {
- CheckLocked();
- anAttr = new SALOMEDS_PixMapAttribute;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributePixMap_i* aPixMapAttr = new SALOMEDS_AttributePixMap_i(anAttr, _orb);
- SALOMEDS::AttributePixMap_var aPMA = aPixMapAttr->AttributePixMap::_this();
- return aPMA._retn();
- }
- else if (strncmp(aTypeOfAttribute, "AttributeTreeNode",17) == 0 ) {
+ TDF_Tool::Label(_doc->GetData(),anobid,Lab);
+
+ __FindOrCreateAttributeLocked(TDataStd_Real, AttributeReal)
+ __FindOrCreateAttributeLocked(TDataStd_Integer, AttributeInteger)
+ __FindOrCreateAttributeLocked(SALOMEDS_SequenceOfRealAttribute, AttributeSequenceOfReal)
+ __FindOrCreateAttributeLocked(SALOMEDS_SequenceOfIntegerAttribute, AttributeSequenceOfInteger)
+ __FindOrCreateAttributeLocked(TDataStd_Name, AttributeName)
+ __FindOrCreateAttributeLocked(TDataStd_Comment, AttributeComment)
+ __FindOrCreateAttributeLocked(SALOMEDS_IORAttribute, AttributeIOR)
+ __FindOrCreateAttributeLocked(SALOMEDS_PixMapAttribute, AttributePixMap)
+ __FindOrCreateAttributeLocked(SALOMEDS_LocalIDAttribute, AttributeLocalID)
+ __FindOrCreateAttributeLocked(SALOMEDS_TableOfIntegerAttribute, AttributeTableOfInteger)
+ __FindOrCreateAttributeLocked(SALOMEDS_TableOfRealAttribute, AttributeTableOfReal)
+ __FindOrCreateAttributeLocked(SALOMEDS_TableOfStringAttribute, AttributeTableOfString)
+ __FindOrCreateAttributeLocked(SALOMEDS_PythonObjectAttribute, AttributePythonObject)
+
+ __FindOrCreateAttribute(SALOMEDS_PersRefAttribute, AttributePersistentRef)
+ __FindOrCreateAttribute(SALOMEDS_DrawableAttribute, AttributeDrawable)
+ __FindOrCreateAttribute(SALOMEDS_SelectableAttribute, AttributeSelectable)
+ __FindOrCreateAttribute(SALOMEDS_ExpandableAttribute, AttributeExpandable)
+ __FindOrCreateAttribute(SALOMEDS_OpenedAttribute, AttributeOpened)
+ __FindOrCreateAttribute(SALOMEDS_TextColorAttribute, AttributeTextColor)
+ __FindOrCreateAttribute(SALOMEDS_TextHighlightColorAttribute, AttributeTextHighlightColor)
+ __FindOrCreateAttribute(SALOMEDS_TargetAttribute, AttributeTarget)
+ __FindOrCreateAttribute(SALOMEDS_StudyPropertiesAttribute, AttributeStudyProperties)
+ __FindOrCreateAttribute(SALOMEDS_ExternalFileDef, AttributeExternalFileDef)
+ __FindOrCreateAttribute(SALOMEDS_FileType, AttributeFileType)
+
+ if (strncmp(aTypeOfAttribute, "AttributeTreeNode",17) == 0 ) {
Standard_GUID aTreeNodeGUID;
- if (strcmp(aTypeOfAttribute, "AttributeTreeNode") == 0)
+ if (strcmp(aTypeOfAttribute, "AttributeTreeNode") == 0) {
aTreeNodeGUID = TDataStd_TreeNode::GetDefaultTreeID();
- else {
+ } else {
char* aGUIDString = new char[40];
sprintf(aGUIDString, &(aTypeOfAttribute[21]));
- Standard_GUID aGUID = Standard_GUID(aGUIDString); // create tree node GUID by name
+ aTreeNodeGUID = Standard_GUID(aGUIDString); // create tree node GUID by name
delete(aGUIDString);
}
Handle(TDataStd_TreeNode) anAttr;
anAttr = TDataStd_TreeNode::Set(Lab, aTreeNodeGUID);
}
SALOMEDS_AttributeTreeNode_i* aTreeNodeAttr = new SALOMEDS_AttributeTreeNode_i(anAttr, _orb);
- SALOMEDS::AttributeTreeNode_var aTNA = aTreeNodeAttr->AttributeTreeNode::_this();
- return aTNA._retn();
+ return aTreeNodeAttr->AttributeTreeNode::_this();
}
- else if (strncmp(aTypeOfAttribute, "AttributeUserID",15) == 0 ) {
+
+ if (strncmp(aTypeOfAttribute, "AttributeUserID",15) == 0 ) {
Handle(TDataStd_UAttribute) anAttr;
if (!Lab.FindAttribute(SALOMEDS_AttributeUserID_i::DefaultID(), anAttr)) {
CheckLocked();
anAttr = TDataStd_UAttribute::Set(Lab, SALOMEDS_AttributeUserID_i::DefaultID());
}
SALOMEDS_AttributeUserID_i* aUAttr = new SALOMEDS_AttributeUserID_i(anAttr, _orb);
- SALOMEDS::AttributeUserID_var aUA = aUAttr->AttributeUserID::_this();
- return aUA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributeLocalID") == 0 ) {
- Handle(SALOMEDS_LocalIDAttribute) anAttr;
- if (!Lab.FindAttribute(SALOMEDS_LocalIDAttribute::GetID(), anAttr)) {
- CheckLocked();
- anAttr = new SALOMEDS_LocalIDAttribute;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributeLocalID_i* aLIDAttr = new SALOMEDS_AttributeLocalID_i(anAttr, _orb);
- SALOMEDS::AttributeLocalID_var aLIDA = aLIDAttr->AttributeLocalID::_this();
- return aLIDA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributeTarget") == 0 ) {
- Handle(SALOMEDS_TargetAttribute) anAttr;
- if (!Lab.FindAttribute(SALOMEDS_TargetAttribute::GetID(), anAttr)) {
- anAttr = new SALOMEDS_TargetAttribute;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributeTarget_i* aLIDAttr = new SALOMEDS_AttributeTarget_i(anAttr, _orb);
- SALOMEDS::AttributeTarget_var aLIDA = aLIDAttr->AttributeTarget::_this();
- return aLIDA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributeTableOfInteger") == 0 ) {
- Handle(SALOMEDS_TableOfIntegerAttribute) anAttr;
- if (!Lab.FindAttribute(SALOMEDS_TableOfIntegerAttribute::GetID(), anAttr)) {
- CheckLocked();
- anAttr = new SALOMEDS_TableOfIntegerAttribute;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributeTableOfInteger_i* aTabIntegerAttr = new SALOMEDS_AttributeTableOfInteger_i(anAttr, _orb);
- SALOMEDS::AttributeTableOfInteger_var aTIA = aTabIntegerAttr->AttributeTableOfInteger::_this();
- return aTIA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributeTableOfReal") == 0 ) {
- Handle(SALOMEDS_TableOfRealAttribute) anAttr;
- if (!Lab.FindAttribute(SALOMEDS_TableOfRealAttribute::GetID(), anAttr)) {
- CheckLocked();
- anAttr = new SALOMEDS_TableOfRealAttribute;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributeTableOfReal_i* aTabRealAttr = new SALOMEDS_AttributeTableOfReal_i(anAttr, _orb);
- SALOMEDS::AttributeTableOfReal_var aTRA = aTabRealAttr->AttributeTableOfReal::_this();
- return aTRA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributeTableOfString") == 0 ) {
- Handle(SALOMEDS_TableOfStringAttribute) anAttr;
- if (!Lab.FindAttribute(SALOMEDS_TableOfStringAttribute::GetID(), anAttr)) {
- CheckLocked();
- anAttr = new SALOMEDS_TableOfStringAttribute;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributeTableOfString_i* aTabStringAttr = new SALOMEDS_AttributeTableOfString_i(anAttr, _orb);
- SALOMEDS::AttributeTableOfString_var aTRA = aTabStringAttr->AttributeTableOfString::_this();
- return aTRA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributeStudyProperties") == 0 ) {
- Handle(SALOMEDS_StudyPropertiesAttribute) anAttr;
- if (!Lab.FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) {
- CheckLocked();
- if (!Lab.FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) {
- anAttr = new SALOMEDS_StudyPropertiesAttribute;
- Lab.AddAttribute(anAttr);
- anAttr->SetModified(0);
- }
- }
- SALOMEDS_AttributeStudyProperties_i* aStPropAttr = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb);
- SALOMEDS::AttributeStudyProperties_var aSPA = aStPropAttr->AttributeStudyProperties::_this();
- return aSPA._retn();
- }
- else if (strcmp(aTypeOfAttribute, "AttributePythonObject") == 0 ) {
- Handle(SALOMEDS_PythonObjectAttribute) anAttr;
- if (!Lab.FindAttribute(SALOMEDS_PythonObjectAttribute::GetID(), anAttr)) {
- CheckLocked();
- anAttr = new SALOMEDS_PythonObjectAttribute;
- Lab.AddAttribute(anAttr);
- }
- SALOMEDS_AttributePythonObject_i* aPObjAttr = new SALOMEDS_AttributePythonObject_i(anAttr, _orb);
- SALOMEDS::AttributePythonObject_var aPOA = aPObjAttr->AttributePythonObject::_this();
- return aPOA._retn();
+ return aUAttr->AttributeUserID::_this();
}
+ return SALOMEDS::GenericAttribute::_nil();
}
//============================================================================
TDF_Label Lab;
ASSERT(!CORBA::is_nil(anObject));
CORBA::String_var anobid = anObject->GetID();
- TDF_Tool::Label(_doc->GetData(),strdup(anobid),Lab);
+ TDF_Tool::Label(_doc->GetData(),anobid,Lab);
Handle(TDF_Attribute) anAttr;
- Standard_Boolean found = Lab.FindAttribute(SALOMEDS_SObject_i::ReturnGUIDForAttribute(aTypeOfAttribute), anAttr);
- if (found) {
- if (strcmp(aTypeOfAttribute, "AttributeReal") == 0 ) {
- SALOMEDS_AttributeReal_i* Attr= new SALOMEDS_AttributeReal_i(Handle(TDataStd_Real)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeReal::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeInteger") == 0 ) {
- SALOMEDS_AttributeInteger_i* Attr= new SALOMEDS_AttributeInteger_i(Handle(TDataStd_Integer)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeInteger::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfReal") == 0 ) {
- SALOMEDS_AttributeSequenceOfReal_i* Attr= new SALOMEDS_AttributeSequenceOfReal_i(Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeSequenceOfReal::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfInteger") == 0 ) {
- SALOMEDS_AttributeSequenceOfInteger_i* Attr= new SALOMEDS_AttributeSequenceOfInteger_i(Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeSequenceOfInteger::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeName") == 0 ) {
- SALOMEDS_AttributeName_i* Attr= new SALOMEDS_AttributeName_i(Handle(TDataStd_Name)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeName::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeComment") == 0 ) {
- SALOMEDS_AttributeComment_i* Attr= new SALOMEDS_AttributeComment_i(Handle(TDataStd_Comment)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeComment::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeExternalFileDef") == 0 ) {
- SALOMEDS_AttributeExternalFileDef_i* Attr= new SALOMEDS_AttributeExternalFileDef_i(Handle(SALOMEDS_ExternalFileDef)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeExternalFileDef::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeFileType") == 0 ) {
- SALOMEDS_AttributeFileType_i* Attr= new SALOMEDS_AttributeFileType_i(Handle(SALOMEDS_FileType)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeFileType::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0 ) {
- SALOMEDS_AttributeIOR_i* Attr= new SALOMEDS_AttributeIOR_i(Handle(SALOMEDS_IORAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeIOR::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributePersistentRef") == 0 ) {
- SALOMEDS_AttributePersistentRef_i* Attr= new SALOMEDS_AttributePersistentRef_i(Handle(SALOMEDS_PersRefAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributePersistentRef::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeDrawable") == 0 ) {
- SALOMEDS_AttributeDrawable_i* Attr= new SALOMEDS_AttributeDrawable_i(Handle(SALOMEDS_DrawableAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeDrawable::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeSelectable") == 0 ) {
- SALOMEDS_AttributeSelectable_i* Attr= new SALOMEDS_AttributeSelectable_i(Handle(SALOMEDS_SelectableAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeSelectable::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeExpandable") == 0 ) {
- SALOMEDS_AttributeExpandable_i* Attr= new SALOMEDS_AttributeExpandable_i(Handle(SALOMEDS_ExpandableAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeExpandable::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeOpened") == 0 ) {
- SALOMEDS_AttributeOpened_i* Attr= new SALOMEDS_AttributeOpened_i(Handle(SALOMEDS_OpenedAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeOpened::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeTextColor") == 0 ) {
- SALOMEDS_AttributeTextColor_i* Attr= new SALOMEDS_AttributeTextColor_i(Handle(SALOMEDS_TextColorAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTextColor::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeTextHighlightColor") == 0 ) {
- SALOMEDS_AttributeTextHighlightColor_i* Attr= new SALOMEDS_AttributeTextHighlightColor_i(Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTextHighlightColor::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributePixMap") == 0 ) {
- SALOMEDS_AttributePixMap_i* Attr= new SALOMEDS_AttributePixMap_i(Handle(SALOMEDS_PixMapAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributePixMap::_this();
- return Standard_True;
- }
- else if (strncmp(aTypeOfAttribute, "AttributeTreeNode",17) == 0 ) {
- SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTreeNode::_this();
- return Standard_True;
- }
- else if (strncmp(aTypeOfAttribute, "AttributeUserID",15) == 0 ) {
- SALOMEDS_AttributeUserID_i* Attr= new SALOMEDS_AttributeUserID_i(Handle(TDataStd_UAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeUserID::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeLocalID") == 0 ) {
- SALOMEDS_AttributeLocalID_i* Attr= new SALOMEDS_AttributeLocalID_i(Handle(SALOMEDS_LocalIDAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeLocalID::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeTarget") == 0 ) {
- SALOMEDS_AttributeTarget_i* Attr= new SALOMEDS_AttributeTarget_i(Handle(SALOMEDS_TargetAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTarget::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeTableOfInteger") == 0 ) {
- SALOMEDS_AttributeTableOfInteger_i* Attr= new SALOMEDS_AttributeTableOfInteger_i(Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTableOfInteger::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeTableOfReal") == 0 ) {
- SALOMEDS_AttributeTableOfReal_i* Attr= new SALOMEDS_AttributeTableOfReal_i(Handle(SALOMEDS_TableOfRealAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTableOfReal::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeTableOfString") == 0 ) {
- SALOMEDS_AttributeTableOfString_i* Attr= new SALOMEDS_AttributeTableOfString_i(Handle(SALOMEDS_TableOfStringAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeTableOfString::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributeStudyProperties") == 0 ) {
- SALOMEDS_AttributeStudyProperties_i* Attr= new SALOMEDS_AttributeStudyProperties_i(Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributeStudyProperties::_this();
- return Standard_True;
- }
- else if (strcmp(aTypeOfAttribute, "AttributePythonObject") == 0 ) {
- SALOMEDS_AttributePythonObject_i* Attr= new SALOMEDS_AttributePythonObject_i(Handle(SALOMEDS_PythonObjectAttribute)::DownCast(anAttr), _orb);
- anAttribute = Attr->AttributePythonObject::_this();
- return Standard_True;
- }
- } else return Standard_False;
+ if (Lab.FindAttribute(SALOMEDS_GenericAttribute_i::GetGUID(aTypeOfAttribute), anAttr)) {
+ anAttribute = SALOMEDS::GenericAttribute::_duplicate(SALOMEDS_GenericAttribute_i::CreateAttribute(_orb, anAttr));
+ return Standard_True;
+ }
+ return Standard_False;
}
//============================================================================
TDF_Label Lab;
ASSERT(!CORBA::is_nil(anObject));
CORBA::String_var anobid = anObject->GetID();
- TDF_Tool::Label(_doc->GetData(),strdup(anobid),Lab);
+ TDF_Tool::Label(_doc->GetData(),anobid,Lab);
if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0) { // postponed removing of CORBA objects
Handle(SALOMEDS_IORAttribute) anAttr;
if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr))
- SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(strdup(TCollection_AsciiString(anAttr->Get()).ToCString()));
+ SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
else return;
}
- Lab.ForgetAttribute (SALOMEDS_SObject_i::ReturnGUIDForAttribute(aTypeOfAttribute));
+ Lab.ForgetAttribute (SALOMEDS_GenericAttribute_i::GetGUID(aTypeOfAttribute));
}
//============================================================================
TDF_Label Lab;
ASSERT(!CORBA::is_nil(me));
CORBA::String_var meid = me->GetID();
- TDF_Tool::Label(_doc->GetData(),strdup(meid),Lab);
+ TDF_Tool::Label(_doc->GetData(),meid,Lab);
TDF_Label RefLab;
ASSERT(!CORBA::is_nil(theReferencedObject));
CORBA::String_var roid = theReferencedObject->GetID();
- TDF_Tool::Label(_doc->GetData(),strdup(roid),RefLab);
+ TDF_Tool::Label(_doc->GetData(),roid,RefLab);
TDF_Reference::Set(Lab,RefLab);
SALOMEDS_TargetAttribute::Set(RefLab)->Append(Lab);
- if(!CORBA::is_nil(_callbackOnRemove)) _callbackOnRemove->OnRemoveSObject(me);
+ if(!CORBA::is_nil(_callbackOnRemove) && Lab.IsDescendant(_doc->Main())) _callbackOnRemove->OnRemoveSObject(me);
}
TDF_Label aLabel;
ASSERT(!CORBA::is_nil(anObject));
CORBA::String_var anEntry = anObject->GetID();
- TDF_Tool::Label(_doc->GetData(), strdup(anEntry), aLabel);
+ TDF_Tool::Label(_doc->GetData(), anEntry, aLabel);
TDataStd_UAttribute::Set(aLabel, (char*)theGUID);
}
TDF_Label aLabel;
ASSERT(!CORBA::is_nil(anObject));
CORBA::String_var anEntry = anObject->GetID();
- TDF_Tool::Label(_doc->GetData(), strdup(anEntry), aLabel);
+ TDF_Tool::Label(_doc->GetData(), anEntry, aLabel);
return aLabel.IsAttribute((char*)theGUID);
}
//============================================================================
void SALOMEDS_StudyBuilder_i::CommitCommand() throw (SALOMEDS::StudyBuilder::LockProtection)
{
+ Unexpect aCatch(SBLockProtection);
Handle(SALOMEDS_StudyPropertiesAttribute) anAttr;
if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) {
anAttr = new SALOMEDS_StudyPropertiesAttribute;
_doc->Main().AddAttribute(anAttr);
}
if (anAttr->IsLocked() && !anAttr->IsLockChanged(true)) {
- INFOS("Locked document modification !!!");
+ MESSAGE("Locked document modification !!!");
AbortCommand();
throw SALOMEDS::StudyBuilder::LockProtection();
} else {
//============================================================================
void SALOMEDS_StudyBuilder_i::Undo() throw (SALOMEDS::StudyBuilder::LockProtection)
{
+ Unexpect aCatch(SBLockProtection);
Handle(SALOMEDS_StudyPropertiesAttribute) anAttr;
if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) {
anAttr = new SALOMEDS_StudyPropertiesAttribute;
_doc->Main().AddAttribute(anAttr);
}
if (anAttr->IsLocked()) {
- INFOS("Locked document modification !!!");
+ MESSAGE("Locked document modification !!!");
throw SALOMEDS::StudyBuilder::LockProtection();
} else {
SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->UndoPostponed(1);
//============================================================================
void SALOMEDS_StudyBuilder_i::Redo() throw (SALOMEDS::StudyBuilder::LockProtection)
{
- Handle(SALOMEDS_StudyPropertiesAttribute) anAttr;
- if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) {
- anAttr = new SALOMEDS_StudyPropertiesAttribute;
- _doc->Main().AddAttribute(anAttr);
- }
-
+ Unexpect aCatch(SBLockProtection);
+ Handle(SALOMEDS_StudyPropertiesAttribute) anAttr;
+ if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) {
+ anAttr = new SALOMEDS_StudyPropertiesAttribute;
+ _doc->Main().AddAttribute(anAttr);
+ }
+
if (anAttr->IsLocked()) {
- INFOS("Locked document modification !!!");
+ MESSAGE("Locked document modification !!!");
throw SALOMEDS::StudyBuilder::LockProtection();
} else {
_doc->Redo();
SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->UndoPostponed(-1);
anAttr->SetModified(anAttr->GetModified()+1);
}
-}
+ }
//============================================================================
/*! Function : GetAvailableUndos
return aRet;
}
+//============================================================================
+/*! Function : CheckLocked
+ * Purpose :
+ */
+//============================================================================
void SALOMEDS_StudyBuilder_i::CheckLocked() throw (SALOMEDS::StudyBuilder::LockProtection) {
+ Unexpect aCatch(SBLockProtection);
if (_doc->HasOpenCommand()) return;
Handle(SALOMEDS_StudyPropertiesAttribute) anAttr;
if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) {
anAttr = new SALOMEDS_StudyPropertiesAttribute;
_doc->Main().AddAttribute(anAttr);
- }
+ }
if (anAttr->IsLocked()) throw SALOMEDS::StudyBuilder::LockProtection();
}
+
+//============================================================================
+/*! Function : SetName
+ * Purpose :
+ */
+//============================================================================
+void SALOMEDS_StudyBuilder_i::SetName(SALOMEDS::SObject_ptr theSO, const char* theValue)
+ throw(SALOMEDS::StudyBuilder::LockProtection)
+{
+ Unexpect aCatch(SBLockProtection);
+ CheckLocked();
+ //Find label
+ TDF_Label aLabel;
+ ASSERT(!CORBA::is_nil(theSO));
+ CORBA::String_var aSOID = theSO->GetID();
+ TDF_Tool::Label(_doc->GetData(), aSOID, aLabel);
+ TDataStd_Name::Set(aLabel, (char*)theValue);
+}
+
+//============================================================================
+/*! Function : SetComment
+ * Purpose :
+ */
+//============================================================================
+void SALOMEDS_StudyBuilder_i::SetComment(SALOMEDS::SObject_ptr theSO, const char* theValue)
+ throw(SALOMEDS::StudyBuilder::LockProtection)
+{
+ Unexpect aCatch(SBLockProtection);
+ CheckLocked();
+ //Find label
+ TDF_Label aLabel;
+ ASSERT(!CORBA::is_nil(theSO));
+ CORBA::String_var aSOID = theSO->GetID();
+ TDF_Tool::Label(_doc->GetData(), aSOID, aLabel);
+ TDataStd_Comment::Set(aLabel, (char*)theValue);
+}
+
+//============================================================================
+/*! Function : SetIOR
+ * Purpose :
+ */
+//============================================================================
+void SALOMEDS_StudyBuilder_i::SetIOR(SALOMEDS::SObject_ptr theSO, const char* theValue)
+ throw(SALOMEDS::StudyBuilder::LockProtection)
+{
+ Unexpect aCatch(SBLockProtection);
+ CheckLocked();
+ //Find label
+ TDF_Label aLabel;
+ ASSERT(!CORBA::is_nil(theSO));
+ CORBA::String_var aSOID = theSO->GetID();
+ TDF_Tool::Label(_doc->GetData(), aSOID, aLabel);
+ SALOMEDS_IORAttribute::Set(aLabel, TCollection_ExtendedString((char*)theValue), _orb);
+}
virtual SALOMEDS::Callback_ptr SetOnAddSObject(SALOMEDS::Callback_ptr theCallback);
virtual SALOMEDS::Callback_ptr SetOnRemoveSObject(SALOMEDS::Callback_ptr theCallback);
+
+ virtual void SetName(SALOMEDS::SObject_ptr theSO, const char* theValue) throw(SALOMEDS::StudyBuilder::LockProtection);
+ virtual void SetComment(SALOMEDS::SObject_ptr theSO, const char* theValue) throw(SALOMEDS::StudyBuilder::LockProtection);
+ virtual void SetIOR(SALOMEDS::SObject_ptr theSO, const char* theValue) throw(SALOMEDS::StudyBuilder::LockProtection);
};
#endif
#include <SALOME_GenericObj_i.hh>
+#include "Utils_ExceptHandlers.hxx"
+
+UNEXPECT_CATCH(SalomeException,SALOME::SALOME_Exception);
+UNEXPECT_CATCH(LockProtection, SALOMEDS::StudyBuilder::LockProtection);
+
#define USE_CASE_LABEL_ID "0:2"
#define AUTO_SAVE_GUID "128268A3-71C9-4036-89B1-F81BD6A4FCF2"
#define AUTO_SAVE_TAG "0:8"
//===========================================================================
//Function : LoadAttributes
//===========================================================================
-static void ReadAttributes(Handle(TDF_Data)& DF,
- TDF_Label& Lab,
+static void ReadAttributes(SALOMEDS::Study_ptr theStudy,
+ SALOMEDS::SObject_ptr aSO,
HDFdataset* hdf_dataset)
{
hdf_dataset->OpenOnDisk();
-
- if (hdf_dataset->GetType() == HDF_STRING) {
-
- if (!strncmp(hdf_dataset->GetName(),"AttributeTreeNode",17)) {
- MESSAGE("Create a Attribute : AttributeTreeNode");
- char current_strings[5][hdf_dataset->GetSize()/5];
- 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 :"<<current_string);
- Handle(SALOMEDS_StudyPropertiesAttribute) aProp = SALOMEDS_StudyPropertiesAttribute::Set (Lab);
- switch (current_string[0]) {
- case 'f': aProp->SetCreationMode(1);break;
- case 'c': aProp->SetCreationMode(2);break;
- }
+ char* current_string = new char[hdf_dataset->GetSize()];
+ hdf_dataset->ReadFromDisk(current_string);
- int anIndex;
- for(anIndex = 2; anIndex + 2 < size ;) {
- char str[10];
- Standard_Integer aMinute, aHour, aDay, aMonth, aYear;
- str[0] = current_string[anIndex++];
- str[1] = current_string[anIndex++];
- str[2] = 0;
- aMinute = atoi(str);
- str[0] = current_string[anIndex++];
- str[1] = current_string[anIndex++];
- aHour = atoi(str);
- str[0] = current_string[anIndex++];
- str[1] = current_string[anIndex++];
- aDay = atoi(str);
- str[0] = current_string[anIndex++];
- str[1] = current_string[anIndex++];
- aMonth = atoi(str);
- str[0] = current_string[anIndex++];
- str[1] = current_string[anIndex++];
- str[2] = current_string[anIndex++];
- str[3] = current_string[anIndex++];
- str[4] = 0;
- aYear = atoi(str);
- aProp->SetModificationDate(aMinute,aHour,aDay,aMonth,aYear);
-
- int aNameSize;
- for(aNameSize = 0; current_string[anIndex+aNameSize]!=1; aNameSize++);
- char *aName = new char[aNameSize+1];
- strncpy(aName, &(current_string[anIndex]), aNameSize);
- aName[aNameSize] = 0;
- aProp->SetUserName(TCollection_ExtendedString(aName));
- delete(aName);
- anIndex += aNameSize + 1;
- if (current_string[1] == 'l') {
- aProp->SetLocked(Standard_True);
- aProp->IsLockChanged(true);
- }
- aProp->SetModified(0);
- }
- }
- else if (!strcmp(hdf_dataset->GetName(),"AttributePythonObject")) {
- MESSAGE("Create an Attribute : AttributePythonObject");
- Handle(SALOMEDS_PythonObjectAttribute) anObj = SALOMEDS_PythonObjectAttribute::Set(Lab);
- Standard_Boolean aScript = (current_string[0] == 's')?Standard_True:Standard_False;
- anObj->SetObject((char *)(current_string+1), aScript);
- }
- else {
- MESSAGE(hdf_dataset->GetName());
- MESSAGE("LoadAttributes: unknown types");
- }
- }
- }
- if (hdf_dataset->GetType() == HDF_FLOAT64) {
- if (!strcmp(hdf_dataset->GetName(),"AttributeSequenceOfReal")) {
- MESSAGE("Create a Attribute : AttributeSequenceOfReal");
- int size = hdf_dataset->GetSize();
- hdf_float64* val = new hdf_float64[size];
- hdf_dataset->ReadFromDisk(val);
- Handle(TColStd_HSequenceOfReal) SeqReal = new TColStd_HSequenceOfReal;
- for (Standard_Integer i = 0; i < size; i++) {
- SeqReal->Append(val[i]);
-// MESSAGE( val[i] << " restored" );
- }
- SALOMEDS_SequenceOfRealAttribute::Set (Lab);
- Handle(SALOMEDS_SequenceOfRealAttribute) Attr;
- Handle(TDF_Attribute) Att;
- Lab.FindAttribute(SALOMEDS_SequenceOfRealAttribute::GetID(),Att);
- Attr = Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(Att);
- Attr->Assign(SeqReal);
- } else
- if (!strcmp(hdf_dataset->GetName(),"AttributeTextColor")) {
- MESSAGE("Create a Attribute : AttributeTextColor");
- hdf_float64 val[3];
- hdf_dataset->ReadFromDisk(val);
- Handle(SALOMEDS_TextColorAttribute) TC = new SALOMEDS_TextColorAttribute;
- Lab.AddAttribute(TC);
- TC->SetValue(1, val[0]);
- TC->SetValue(2, val[1]);
- TC->SetValue(3, val[2]);
- } else
- if (!strcmp(hdf_dataset->GetName(),"AttributeTextHighlightColor")) {
- MESSAGE("Create a Attribute : AttributeTextHighlightColor");
- hdf_float64 val[3];
- hdf_dataset->ReadFromDisk(val);
- Handle(SALOMEDS_TextHighlightColorAttribute) TC = new SALOMEDS_TextHighlightColorAttribute;
- Lab.AddAttribute(TC);
- TC->SetValue(1, val[0]);
- TC->SetValue(2, val[1]);
- TC->SetValue(3, val[2]);
- }else {
- MESSAGE(hdf_dataset->GetName());
- MESSAGE("LoadAttributes: unknown types");
- }
+ if (!strcmp(hdf_dataset->GetName(),"COMPONENTDATATYPE")) {
+ anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, "AttributeComment");
+ } else if (!strcmp(hdf_dataset->GetName(),"Reference")) {
+ theStudy->NewBuilder()->Addreference(aSO, theStudy->CreateObjectID(current_string));
+ delete(current_string);
+ hdf_dataset->CloseOnDisk();
+ return;
+ } else {
+ MESSAGE("Read attribute "<<hdf_dataset->GetName())
+ anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, hdf_dataset->GetName());
}
- if (hdf_dataset->GetType() == HDF_INT32) {
- if (!strcmp(hdf_dataset->GetName(),"AttributeSequenceOfInteger")) {
- MESSAGE("Create a OCAF Attribute : AttributeSequenceOfInteger");
- int size = hdf_dataset->GetSize();
- hdf_int32* val = new hdf_int32[size];
- hdf_dataset->ReadFromDisk(val);
- Handle(TColStd_HSequenceOfInteger) SeqInt = new TColStd_HSequenceOfInteger;
- for (Standard_Integer i = 0; i < size; i++) {
- SeqInt->Append(val[i]);
-// MESSAGE( val[i] << " restored" );
- }
- SALOMEDS_SequenceOfIntegerAttribute::Set (Lab);
- Handle(SALOMEDS_SequenceOfIntegerAttribute) Attr;
- Handle(TDF_Attribute) Att;
- Lab.FindAttribute(SALOMEDS_SequenceOfIntegerAttribute::GetID(),Att);
- Attr = Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(Att);
- Attr->Assign(SeqInt);
- }
- else {
- MESSAGE(hdf_dataset->GetName());
- MESSAGE("LoadAttributes: unknown types");
- }
+
+ if (!CORBA::is_nil(anAttr)) {
+ anAttr->Restore(current_string);
+ MESSAGE("Restoring attribute "<<hdf_dataset->GetName()<<" by string '"<<current_string<<"' done")
+ } else {
+ MESSAGE(hdf_dataset->GetName());
+ MESSAGE("LoadAttributes: unknown types");
}
+ delete(current_string);
hdf_dataset->CloseOnDisk();
}
//============================================================================
//Function : BuildlTree
//============================================================================
-static void BuildTree (Handle(TDF_Data)& DF,HDFgroup* hdf_current_group)
+static void BuildTree (SALOMEDS::Study_ptr theStudy,HDFgroup* hdf_current_group)
{
hdf_current_group->OpenOnDisk();
- TDF_Label Lab;
- Standard_CString Entry = hdf_current_group->GetName();
+ SALOMEDS::SObject_var aSO;
+ char* Entry = hdf_current_group->GetName();
if (strcmp(Entry,"STUDY_STRUCTURE") == 0) {
MESSAGE("find the root of the document");
- Lab = DF->Root().FindChild(1,Standard_True);
+ aSO = theStudy->CreateObjectID("0:1");
}
else {
- TDF_Tool::Label (DF,Entry,Lab,1);
+ aSO = theStudy->CreateObjectID(Entry);
MESSAGE("BuildTree : Create a new label"<<Entry);
}
char name[HDF_NAME_MAX_LEN+1];
if (type == HDF_DATASET) {
MESSAGE("--> Dataset: Internal Object Name : " << name);
HDFdataset* new_dataset = new HDFdataset(name,hdf_current_group);
- ReadAttributes (DF,Lab,new_dataset);
+ ReadAttributes(theStudy,aSO,new_dataset);
new_dataset = 0; // will be deleted by father destructor
}
else if (type == HDF_GROUP) {
MESSAGE( "--> Group: Internal Object Name : " << name);
HDFgroup* new_group = new HDFgroup(name,hdf_current_group);
- BuildTree (DF,new_group);
+ BuildTree (theStudy, new_group);
new_group = 0; // will be deleted by father destructor
}
}
SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* aUrl)
throw(SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SalomeException);
MESSAGE("Begin of SALOMEDS_StudyManager_i::Open");
// open the HDFFile
HDFfile *hdf_file =0;
Handle(TDF_Data) DF = Doc->GetData();
try {
- BuildTree (DF,hdf_group_study_structure);
+ BuildTree (Study,hdf_group_study_structure);
}
catch (HDFexception)
{
*/
//============================================================================
static void SaveAttributes(SALOMEDS::SObject_ptr SO, HDFgroup *hdf_group_sobject) {
- HDFdataset *hdf_dataset = 0;
+ int a;
hdf_size size[1];
- hdf_int32 name_len = 0;
- SALOMEDS::GenericAttribute_var SObj;
- if(SO->FindAttribute(SObj, "AttributeComment"))
- {
- SALOMEDS::AttributeComment_var Comment = SALOMEDS::AttributeComment::_narrow(SObj);
- CORBA::String_var Val = Comment->Value();
- name_len = (hdf_int32) strlen(Val);
- size[0] = name_len +1 ;
- hdf_dataset = new HDFdataset("AttributeComment",hdf_group_sobject,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(Val);
- MESSAGE("attribute comment " << Val << " wrote on file");
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- }
- // Attribute SALOMEDS::PersistentRef
- if(SO->FindAttribute(SObj, "AttributePersistentRef"))
- {
- SALOMEDS::AttributePersistentRef_var PersRef = SALOMEDS::AttributePersistentRef::_narrow(SObj);
- CORBA::String_var Val = PersRef->Value();
- name_len = (hdf_int32) strlen(Val);
- size[0] = name_len +1 ;
- hdf_dataset = new HDFdataset("AttributePersistentRef",hdf_group_sobject,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(Val);
- MESSAGE("attribute persistentref " << Val << " wrote on file");
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- }
- // Attribute SALOMEDS::Name
- if(SO->FindAttribute(SObj, "AttributeName"))
- {
- SALOMEDS::AttributeName_var NameRef = SALOMEDS::AttributeName::_narrow(SObj);
- CORBA::String_var Val = NameRef->Value();
- name_len = (hdf_int32) strlen(Val);
- size[0] = name_len +1 ;
- hdf_dataset = new HDFdataset("AttributeName",hdf_group_sobject,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(Val);
- MESSAGE("attribute name " << Val << " wrote on file");
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- }
- if(SO->FindAttribute(SObj, "AttributeReal"))
- {
- char RealVal[25];
- SALOMEDS::AttributeReal_var RealRef = SALOMEDS::AttributeReal::_narrow(SObj);
- sprintf(RealVal, "%f", RealRef->Value());
- name_len = (hdf_int32) strlen(RealVal);
- size[0] = name_len +1 ;
- hdf_dataset = new HDFdataset("AttributeReal",hdf_group_sobject,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(RealVal);
- MESSAGE("attribute Real " << RealVal << " wrote on file");
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- }
- if(SO->FindAttribute(SObj, "AttributeInteger"))
- {
- char IntVal[25];
- SALOMEDS::AttributeInteger_var IntRef = SALOMEDS::AttributeInteger::_narrow(SObj);
- sprintf(IntVal, "%d", IntRef->Value());
- name_len = (hdf_int32) strlen(IntVal);
- size[0] = name_len +1 ;
- hdf_dataset = new HDFdataset("AttributeInteger",hdf_group_sobject,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(IntVal);
- MESSAGE("attribute Real " << IntVal << " wrote on file");
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- }
-
- if(SO->FindAttribute(SObj, "AttributeSequenceOfReal"))
- {
- SALOMEDS::AttributeSequenceOfReal_var RealSeq = SALOMEDS::AttributeSequenceOfReal::_narrow(SObj);
- size[0] = RealSeq->Length();
- SALOMEDS::DoubleSeq_var DS = RealSeq->CorbaSequence();
- hdf_dataset = new HDFdataset("AttributeSequenceOfReal",hdf_group_sobject,HDF_FLOAT64,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_float64 *data = new hdf_float64[RealSeq->Length()];
- for (Standard_Integer i = 0; i < RealSeq->Length(); i++) {
- MESSAGE("Value = " << i << " = " << DS[i] << " wrote on file");
- data[i] = DS[i];
- }
- hdf_dataset->WriteOnDisk(data);
- // delete data;
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- }
- if(SO->FindAttribute(SObj, "AttributeSequenceOfInteger"))
- {
- SALOMEDS::AttributeSequenceOfInteger_var IntSeq = SALOMEDS::AttributeSequenceOfInteger::_narrow(SObj);
- size[0] = IntSeq->Length();
- SALOMEDS::LongSeq_var LS = IntSeq->CorbaSequence();
- hdf_dataset = new HDFdataset("AttributeSequenceOfInteger",hdf_group_sobject,HDF_INT32,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_int32 *data = new hdf_int32[IntSeq->Length()];
- for (Standard_Integer i = 0; i < IntSeq->Length(); i++) {
- MESSAGE("Value = " << i << " = " << LS[i] << " wrote on file");
- data[i] = LS[i];
- }
- hdf_dataset->WriteOnDisk(data);
- hdf_dataset->CloseOnDisk();
- // delete data;
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- }
- if(SO->FindAttribute(SObj, "AttributeDrawable"))
- {
- char IntVal[25];
- SALOMEDS::AttributeDrawable_var DrRef = SALOMEDS::AttributeDrawable::_narrow(SObj);
- sprintf(IntVal, "%d", DrRef->IsDrawable());
- name_len = (hdf_int32) strlen(IntVal);
- size[0] = name_len +1 ;
- hdf_dataset = new HDFdataset("AttributeDrawable",hdf_group_sobject,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(IntVal);
- MESSAGE("attribute Drawable " << IntVal << " wrote on file");
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- }
- if(SO->FindAttribute(SObj, "AttributeSelectable"))
- {
- char IntVal[25];
- SALOMEDS::AttributeSelectable_var SelRef = SALOMEDS::AttributeSelectable::_narrow(SObj);
- sprintf(IntVal, "%d", SelRef->IsSelectable());
- name_len = (hdf_int32) strlen(IntVal);
- size[0] = name_len +1 ;
- hdf_dataset = new HDFdataset("AttributeSelectable",hdf_group_sobject,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(IntVal);
- MESSAGE("attribute Selectable " << IntVal << " wrote on file");
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- }
- if(SO->FindAttribute(SObj, "AttributeExpandable"))
- {
- char IntVal[25];
- SALOMEDS::AttributeExpandable_var ExRef = SALOMEDS::AttributeExpandable::_narrow(SObj);
- sprintf(IntVal, "%d", ExRef->IsExpandable());
- name_len = (hdf_int32) strlen(IntVal);
- size[0] = name_len +1 ;
- hdf_dataset = new HDFdataset("AttributeExpandable",hdf_group_sobject,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(IntVal);
- MESSAGE("attribute Expandable " << IntVal << " wrote on file");
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- }
- if(SO->FindAttribute(SObj, "AttributeOpened"))
- {
- char IntVal[25];
- SALOMEDS::AttributeOpened_var OpRef = SALOMEDS::AttributeOpened::_narrow(SObj);
- sprintf(IntVal, "%d", OpRef->IsOpened());
- name_len = (hdf_int32) strlen(IntVal);
- size[0] = name_len +1 ;
- hdf_dataset = new HDFdataset("AttributeOpened",hdf_group_sobject,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(IntVal);
- MESSAGE("attribute Opened " << IntVal << " wrote on file");
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- }
- if(SO->FindAttribute(SObj, "AttributeTextColor"))
- {
- SALOMEDS::AttributeTextColor_var TextRef = SALOMEDS::AttributeTextColor::_narrow(SObj);
- size[0] = 3;
- hdf_float64 data[3];
- SALOMEDS::Color C = TextRef->TextColor();
- data[0] = C.R;
- data[1] = C.G;
- data[2] = C.B;
- hdf_dataset = new HDFdataset("AttributeTextColor",hdf_group_sobject,HDF_FLOAT64,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(data);
- MESSAGE("attribute AttributeTextColor wrote on file");
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- }
- if(SO->FindAttribute(SObj, "AttributeTextHighlightColor"))
- {
- SALOMEDS::AttributeTextHighlightColor_var TextRef = SALOMEDS::AttributeTextHighlightColor::_narrow(SObj);
- size[0] = 3;
- hdf_float64 data[3];
- SALOMEDS::Color C = TextRef->TextHighlightColor();
- data[0] = C.R;
- data[1] = C.G;
- data[2] = C.B;
- hdf_dataset = new HDFdataset("AttributeTextHighlightColor",hdf_group_sobject,HDF_FLOAT64,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(data);
- MESSAGE("attribute AttributeTextHighlightColor wrote on file");
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- }
- if(SO->FindAttribute(SObj, "AttributePixMap"))
- {
- SALOMEDS::AttributePixMap_var PMRef = SALOMEDS::AttributePixMap::_narrow(SObj);
- if (PMRef->HasPixMap()) {
- CORBA::String_var Val = PMRef->GetPixMap();
- name_len = (hdf_int32) strlen(Val);
- size[0] = name_len +1 ;
- hdf_dataset = new HDFdataset("AttributePixMap",hdf_group_sobject,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(Val);
- MESSAGE("attribute PixMap " << Val << " wrote on file");
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- }
- }
- if(SO->FindAttribute(SObj, "AttributeLocalID"))
- {
- char IntVal[25];
- SALOMEDS::AttributeLocalID_var LIDRef = SALOMEDS::AttributeLocalID::_narrow(SObj);
- sprintf(IntVal, "%d", LIDRef->Value());
- name_len = (hdf_int32) strlen(IntVal);
- size[0] = name_len +1 ;
- hdf_dataset = new HDFdataset("AttributeLocalID",hdf_group_sobject,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(IntVal);
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- MESSAGE("attribute AttributeLocalID wrote on file");
- }
- if(SO->FindAttribute(SObj, "AttributeTableOfInteger"))
- {
- SALOMEDS::AttributeTableOfInteger_var IntTab = SALOMEDS::AttributeTableOfInteger::_narrow(SObj);
- SALOMEDS::TMPFile_var aStream = IntTab->SaveToFile();
-
- hdf_size aHDFSize[1];
- aHDFSize[0] = aStream->length();
-
- HDFdataset *hdf_dataset = new HDFdataset("AttributeTableOfInteger",hdf_group_sobject, HDF_STRING, aHDFSize, 1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk((unsigned char*) &aStream[0]); //Save the stream in the HDF file
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
-
- MESSAGE("attribute AttributeTableOfInteger wrote on file");
- }
- if(SO->FindAttribute(SObj, "AttributeTableOfReal"))
- {
- SALOMEDS::AttributeTableOfReal_var RealTab = SALOMEDS::AttributeTableOfReal::_narrow(SObj);
- SALOMEDS::TMPFile_var aStream = RealTab->SaveToFile();
-
- hdf_size aHDFSize[1];
- aHDFSize[0] = aStream->length();
-
- HDFdataset *hdf_dataset = new HDFdataset("AttributeTableOfReal",hdf_group_sobject, HDF_STRING, aHDFSize, 1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk((unsigned char*) &aStream[0]); //Save the stream in the HDF file
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
-
- MESSAGE("attribute AttributeTableOfReal wrote on file")
- }
- if(SO->FindAttribute(SObj, "AttributeTableOfString"))
- {
- SALOMEDS::AttributeTableOfString_var StrTab = SALOMEDS::AttributeTableOfString::_narrow(SObj);
- SALOMEDS::TMPFile_var aStream = StrTab->SaveToFile();
-
- hdf_size aHDFSize[1];
- aHDFSize[0] = aStream->length();
-
- HDFdataset *hdf_dataset = new HDFdataset("AttributeTableOfString",hdf_group_sobject, HDF_STRING, aHDFSize, 1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk((unsigned char*) &aStream[0]); //Save the stream in the HDF file
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
-
- MESSAGE("attribute AttributeTableOfString wrote on file")
- }
- if(SO->FindAttribute(SObj, "AttributePythonObject"))
- {
- SALOMEDS::AttributePythonObject_var anObj = SALOMEDS::AttributePythonObject::_narrow(SObj);
- char* aSeq = CORBA::string_dup(anObj->GetObject());
- int aLen = strlen(aSeq);
- char* aString = new char[aLen+2];
- aString[0] = anObj->IsScript()?'s':'n';
- for(int i = 0; i < aLen; i++) aString[i+1] = aSeq[i];
- aString[aLen+1] = 0;
- size[0] = aLen+2 ;
- hdf_dataset = new HDFdataset("AttributePythonObject",hdf_group_sobject,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(aString);
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- MESSAGE("attribute AttributePythonObject wrote on file");
- }
-
-// Reference
- SALOMEDS::SObject_var RefSO;
- if(SO->ReferencedObject(RefSO))
- {
- CORBA::String_var attribute_reference = strdup(RefSO->GetID());
- name_len = (hdf_int32) strlen(attribute_reference);
- size[0] = name_len +1 ;
- hdf_dataset = new HDFdataset("Reference",hdf_group_sobject,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(attribute_reference);
- MESSAGE("attribute reference " << attribute_reference << " wrote on file");
- hdf_dataset->CloseOnDisk();
- hdf_dataset =0; // will be deleted by father hdf object destructor
- }
-
-// TreeNodeAttributes with not constant GUID
SALOMEDS::ListOfAttributes_var anAttrList = SO->GetAllAttributes();
- int anIndex, aLength = anAttrList->length();
- for(anIndex = 0; anIndex<aLength; anIndex++) {
- SALOMEDS::AttributeUserID_var UAttr = SALOMEDS::AttributeUserID::_narrow(anAttrList[anIndex]);
- if (!UAttr->_is_nil()) {
- char* Val = UAttr->Value();
- name_len = (hdf_int32) strlen(Val);
- size[0] = name_len + 1;
- char* aDataSetName = new char[60];
- sprintf(aDataSetName, "AttributeUserID_%s",Val);
- hdf_dataset = new HDFdataset(aDataSetName,hdf_group_sobject,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(Val);
- MESSAGE("attribute UesrID " << Val << " wrote on file");
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- delete(aDataSetName);
- continue;
- }
+ for(a = anAttrList->length() - 1; a >= 0; a--) {
+ if (strcmp(anAttrList[a]->Type(), "AttributeIOR") == 0) continue; // never write AttributeIOR to file
+ if (strcmp(anAttrList[a]->Type(), "AttributeExternalFileDef") == 0) continue; // never write ExternalFileDef to file
+ if (strcmp(anAttrList[a]->Type(), "AttributeFileType") == 0) continue; // never write FileType to file
+ CORBA::String_var aSaveStr = strdup(anAttrList[a]->Store());
+ size[0] = (hdf_int32) strlen(aSaveStr) + 1;
+ HDFdataset *hdf_dataset = new HDFdataset(anAttrList[a]->Type(),hdf_group_sobject,HDF_STRING,size,1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk(aSaveStr);
+ hdf_dataset->CloseOnDisk();
+ //cout<<"********** Write Attribute "<<anAttrList[a]->Type()<<" : "<<aSaveStr<<" done"<<endl;
+ hdf_dataset=0; //will be deleted by hdf_sco_group destructor
+ }
- SALOMEDS::AttributeTreeNode_var TNRef = SALOMEDS::AttributeTreeNode::_narrow(anAttrList[anIndex]);
- if (!TNRef->_is_nil()) {
- hdf_size TNsize[2];
- int maxSize,index;
- CORBA::String_var Val[5];
-
- if (TNRef->HasFather()) Val[0] = TNRef->GetFather()->Label(); else Val[0] = "\0";
- maxSize = strlen(Val[0]);
- if (TNRef->HasPrevious()) Val[1] = TNRef->GetPrevious()->Label(); else Val[1] = "\0";
- maxSize = Max(maxSize,strlen(Val[1]));
- if (TNRef->HasNext()) Val[2] = TNRef->GetNext()->Label(); else Val[2] = "\0";
- maxSize = Max(maxSize,strlen(Val[2]));
- if (TNRef->HasFirst()) Val[3] = TNRef->GetFirst()->Label(); else Val[3] = "\0";
- maxSize = Max(maxSize,strlen(Val[3]));
- Val[4] = TNRef->GetTreeID();
- maxSize = Max(maxSize,strlen(Val[4]));
-
- TNsize[0]=5;
- TNsize[1]=maxSize+1;
- char Data[5][maxSize+1];
- for(index=0;index<5;index++) {
- strcpy(Data[index],Val[index]);
- for(int a = strlen(Data[index]) + 1; a < maxSize; a++) Data[index][a] = ' '; // mpv: for ASCII format
- }
-
- char* aDataSetName = new char[60];
- sprintf(aDataSetName, "AttributeTreeNodeGUID%s",TNRef->GetTreeID());
- hdf_dataset = new HDFdataset(aDataSetName,hdf_group_sobject,HDF_STRING,TNsize,2);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(Data);
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- MESSAGE("attribute AttributeTreeNode with various GUID wrote on file:");
- MESSAGE(aDataSetName);
- delete(aDataSetName);
- }
+ // Reference attribute has no CORBA attribute representation, so, GetAllAttributes can not return this attribute
+ SALOMEDS::SObject_var RefSO;
+ if(SO->ReferencedObject(RefSO)) {
+ CORBA::String_var attribute_reference = strdup(RefSO->GetID());
+ size[0] = strlen(attribute_reference) + 1 ;
+ HDFdataset *hdf_dataset = new HDFdataset("Reference",hdf_group_sobject,HDF_STRING,size,1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk(attribute_reference);
+ hdf_dataset->CloseOnDisk();
+ hdf_dataset =0; // will be deleted by father hdf object destructor
}
}
SALOMEDS::SObject_var SO = itchild->Value();
// mpv: don't save empty labels
- if (SO->GetAllAttributes()->length() == 0) {
+ if (SO->GetAllAttributes()->length() == 0 && !SO->ReferencedObject(RefSO)) {
SALOMEDS::ChildIterator_var subchild = aStudy->NewChildIterator(SC);
if (!subchild->More()) {
continue;
subchild->InitEx(true);
bool anEmpty = true;
for (; subchild->More() && anEmpty; subchild->Next())
- if (subchild->Value()->GetAllAttributes()->length() != 0) anEmpty = false;
+ if (subchild->Value()->GetAllAttributes()->length() != 0 ||
+ subchild->Value()->ReferencedObject(RefSO)) anEmpty = false;
if (anEmpty) {
continue;
}
SALOMEDS::SObject_ptr SALOMEDS_StudyManager_i::Paste(SALOMEDS::SObject_ptr theObject)
throw(SALOMEDS::StudyBuilder::LockProtection)
{
+ Unexpect aCatch(LockProtection);
SALOMEDS::Study_var aStudy = theObject->GetStudy();
// if study is locked, then paste can't be done
{
// Convert aSO->GetID in TDF_Label.
TDF_Label Lab;
- TDF_Tool::Label(_doc->GetData(), strdup(anObjectID), Lab);
+ TDF_Tool::Label(_doc->GetData(), (char*)anObjectID, Lab);
+
+ if (Lab.IsNull()) return SALOMEDS::SObject::_nil();
+ SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (Lab,_orb);
+ SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this());
+ return so;
+
+}
+
+//============================================================================
+/*! Function : CreateObjectID
+ * Purpose : Creates an Object with ID = anObjectID
+ */
+//============================================================================
+SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
+{
+ // Convert aSO->GetID in TDF_Label.
+ TDF_Label Lab;
+ TDF_Tool::Label(_doc->GetData(), (char*)anObjectID, Lab, Standard_True);
if (Lab.IsNull()) return SALOMEDS::SObject::_nil();
SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (Lab,_orb);
RefSO = _FindObjectIOR(SC,anObjectIOR, _find);
}
}
- if (!RefSO->_is_nil()) INFOS("SALOMEDS_Study_i::FindObjectIOR: found label with old methods");
+ if (!RefSO->_is_nil()) MESSAGE("SALOMEDS_Study_i::FindObjectIOR: found label with old methods");
return RefSO;
}
{
//Convert aSO->GetID in TDF_Label.
TDF_Label Lab;
- TDF_Tool::Label(_doc->GetData(), strdup(aSO->GetID()), Lab);
+ TDF_Tool::Label(_doc->GetData(), aSO->GetID(), Lab);
//Create iterator
SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(Lab,_orb);
ASSERT(!CORBA::is_nil(aStudy));
return SALOMEDS::Study::_duplicate(aStudy);
} else {
- INFOS("GetStudy: Problem to get study");
+ MESSAGE("GetStudy: Problem to get study");
}
return SALOMEDS::Study::_nil();
}
if (!CORBA::is_nil(obj)) {
SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj) ;
if (!CORBA::is_nil(aGeneric)) {
- TCollection_AsciiString anIOR(strdup(theIOR));
+ TCollection_AsciiString anIOR((char*)theIOR);
anIOR.Prepend("d");
myPostponedIORs.Append(anIOR); // add prefix: deleted
myNbPostponed.SetValue(myNbPostponed.Length(), myNbPostponed.Last() + 1);
if (!CORBA::is_nil(obj)) {
SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj) ;
if (!CORBA::is_nil(aGeneric)) {
- TCollection_AsciiString anIOR(strdup(theIOR));
+ TCollection_AsciiString anIOR((char*)theIOR);
anIOR.Prepend("c");
myPostponedIORs.Append(anIOR); // add prefix: created
myNbPostponed.SetValue(myNbPostponed.Length(), myNbPostponed.Last() + 1);
for(anIndex = anOld + 1; anIndex <= aNew; anIndex++) {
TCollection_AsciiString anIOR = myPostponedIORs(anIndex);
if (anIOR.Value(1) == 'c') {
- CORBA::Object_var obj = _orb->string_to_object(strdup(anIOR.Split(1).ToCString()));
+ CORBA::Object_var obj = _orb->string_to_object(anIOR.Split(1).ToCString());
SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
}
for(anIndex = 1; anIndex <= anOld; anIndex++) {
TCollection_AsciiString anIOR = myPostponedIORs(anIndex);
if (anIOR.Value(1) == 'd') {
- CORBA::Object_var obj = _orb->string_to_object(strdup(anIOR.Split(1).ToCString()));
+ CORBA::Object_var obj = _orb->string_to_object(anIOR.Split(1).ToCString());
SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
}
TDF_ChildIDIterator anIter(_doc->GetData()->Root(), SALOMEDS_IORAttribute::GetID(), Standard_True);
for(; anIter.More(); anIter.Next()) {
Handle(SALOMEDS_IORAttribute) anAttr = Handle(SALOMEDS_IORAttribute)::DownCast(anIter.Value());
- CORBA::String_var anIOR = strdup(TCollection_AsciiString(anAttr->Get()).ToCString());
+ CORBA::String_var anIOR = CORBA::string_dup(TCollection_AsciiString(anAttr->Get()).ToCString());
try {
CORBA::Object_var obj = _orb->string_to_object(anIOR);
SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
*/
virtual SALOMEDS::SObject_ptr FindObjectID(const char* anObjectID);
+ //! method to Create an Object with ID = anObjectID
+ /*!
+ \param anObjectID char* arguments
+ \return SObject_ptr arguments, the object found
+ */
+ virtual SALOMEDS::SObject_ptr CreateObjectID(const char* anObjectID);
+
//! method to Find an Object with ID = anObjectIOR
/*!
\param anObjectIOR char* arguments
*/
virtual void URL(const char* url);
-
virtual CORBA::Short StudyId();
virtual void StudyId(CORBA::Short id);
// File : SALOMEDS_TargetAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
using namespace std;
#include "SALOMEDS_TargetAttribute.ixx"
// File : SALOMEDS_TargetAttribute.hxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef _SALOMEDS_TargetAttribute_HeaderFile
#define _SALOMEDS_TargetAttribute_HeaderFile
// File : SALOMEDS_TargetAttribute.ixx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#include "SALOMEDS_TargetAttribute.jxx"
// File : SALOMEDS_TargetAttribute.jxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
#ifndef _Standard_GUID_HeaderFile
#include <Standard_GUID.hxx>
// File : SALOMEDS_TextColorAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
using namespace std;
#include "SALOMEDS_TextColorAttribute.ixx"
// File : SALOMEDS_TextHighlightColorAttribute.cxx
// Author : Yves FRICAUD
// Module : SALOME
-// $Header:
+// $Header$
using namespace std;
#include "SALOMEDS_TextHighlightColorAttribute.ixx"
#---------------
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"
#: 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"
#ifndef _PYINTERP_BASE_H_
#define _PYINTERP_BASE_H_
-using namespace std;
#include <iostream>
#include <Python.h>
#include <list>
#include <string>
+using namespace std;
+
#define TOP_HISTORY_PY "--- top of history ---"
#define BEGIN_HISTORY_PY "--- begin of history ---"
ActionMap() {}
~ActionMap()
{
- QMapIterator<unsigned int, QActionP*> it;
+ QMapIterator<int, QActionP*> it;
for ( it = myMap.begin(); it != myMap.end(); it++ ) delete (QActionP*)it.data();
myMap.clear();
}
- bool isEmpty() { return myMap.isEmpty(); }
- void insert( const unsigned int id, QActionP* action ) { myMap[id] = action; }
- QActionP* at( const unsigned int id ) { return myMap[id]; }
+ bool isEmpty() { return myMap.isEmpty(); }
+ void insert( const int id, QActionP* action ) { myMap[id] = action; }
+ QActionP* at( const int id ) { return myMap[id]; }
void clear() { myMap.clear(); }
- QActionP*& operator[] (const unsigned int id) { return myMap[id]; }
- bool hasAction( const unsigned int id ) { return myMap.contains(id); }
+ QActionP*& operator[] (const int id) { return myMap[id]; }
+ bool hasAction( const int id ) { return myMap.contains(id); }
private:
- QMap<unsigned int, QActionP*> myMap;
+ QMap<int, QActionP*> myMap;
};
myActiveStudy = study;
- /* notification */
- onActiveStudyChanged( oldActiveStudy, myActiveStudy );
-
+ // VSR : call app activate before informing modules that active study is changed ===>
/* application activated */
emit appActivated( this );
+
+ /* notification */
+ onActiveStudyChanged( oldActiveStudy, myActiveStudy );
+ // VSR : call app activate before informing modules that active study is changed <===
}
/*!
{
// MESSAGE ("QAD_Application::onStudyDeactivated init. ");
QAD_ASSERT_DEBUG_ONLY ( myActiveStudy == study );
- myActiveStudy->onStudyDeactivated();
- myActiveStudy = 0;
+ if ( study )
+ study->onStudyDeactivated();
// MESSAGE ("QAD_Application::onStudyDeactivated done. ");
}
/** Gets directory of the local configuration file. */
QDir getConfigDir() const { return configDir; }
- /** Sets directory of SALOME_ROOT. */
+ /** Sets directory of KERNEL_ROOT. */
void setPrgDir(QDir _prgDir) { prgDir=_prgDir; }
- /** Gets directory of SALOME_ROOT. */
+ /** Gets directory of KERNEL_ROOT. */
QDir getPrgDir() const { return prgDir; }
bool createConfigFile( bool overwrite=false );
#include "SALOMEGUI_TrihedronSizeDlg.h"
#include "SALOMEGUI_ExternalBrowserDlg.h"
#include "SALOMEGUI_LoadStudiesDlg.h"
-#include "SALOME_Selection.h"
+//#include "SALOME_Selection.h"
#include "SALOME_InteractiveObject.hxx"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "SALOMEGUI_AboutDlg.h"
#include <qdatetime.h>
#include <qthread.h>
+#include <qstringlist.h>
+
#if QT_VERSION > 300
#include <qlistbox.h>
#include <qregexp.h>
tr("INF_RESOURCES");
//QMessageBox::warning( this, tr("WRN_WARNING"), errMsg, tr ("BUT_OK") );
}
-
- if ( !QString(list_composants[ind].modulename).isEmpty() )
- myCombo->insertItem( strdup(list_composants[ind].moduleusername) );
-
+ if ( ( resDir || moduleusername == "Salome" ) && !modulename.isEmpty() ) // VSR: Force "Salome" component to appear in the combo box
+ myCombo->insertItem( moduleusername );
}
myCombo->adjustSize();
//NRI : SAL2214
myNewViewPopup.clear();
//NRI : SAL2214
+ myHelpContentsModulePopup.clear();
myToolsPopup.clear();
myPrefPopup.clear();
myStdActions.clear();
exitAction->addTo( &myFilePopup );
myStdActions.insert ( FileExitId, exitAction );
+ QAD_ASSERT( connect( &myFilePopup, SIGNAL(highlighted( int )),
+ this, SLOT(onFilePopupStatusText( int )) ));
+
+
/* 'Edit' actions : provided by application only */
myEditPos = 0;
+ QAD_ASSERT( connect( &myEditPopup, SIGNAL(highlighted( int )),
+ this, SLOT(onEditPopupStatusText( int )) ));
+
/* 'View' actions */
/* toolbars popup menu */
myViewPopup.insertItem( tr("MEN_DESK_VIEW_TOOLBARS"), &myToolBarsPopup );
myViewPos = myViewPopup.count();
+ QAD_ASSERT( connect( &myViewPopup, SIGNAL(highlighted( int )),
+ this, SLOT(onViewPopupStatusText( int )) ));
+
/* Parse xml file */
QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
if ( resMgr ) {
/* 'Help' actions
*/
/* contents */
- QActionP* helpContentsAction = new QActionP( "", tr("MEN_DESK_HELP_CONTENTS"), Key_F1, this );
- helpContentsAction->setStatusTip ( tr("PRP_DESK_HELP_CONTENTS") );
- QAD_ASSERT(connect( helpContentsAction, SIGNAL(activated()),
- this, SLOT( onHelpContents() )));
- helpContentsAction->addTo( &myHelpPopup );
- myStdActions.insert( HelpContentsId , helpContentsAction );
+ // MZN : Commented
+ // QActionP* helpContentsAction = new QActionP( "", tr("MEN_DESK_HELP_CONTENTS"), Key_F1, this );
+ // helpContentsAction->setStatusTip ( tr("PRP_DESK_HELP_CONTENTS") );
+// QAD_ASSERT(connect( helpContentsAction, SIGNAL(activated()),
+// this, SLOT( onHelpContents() )));
+// helpContentsAction->addTo( &myHelpPopup );
+// myStdActions.insert( HelpContentsId , helpContentsAction );
- id = myHelpPopup.insertSeparator();
+// id = myHelpPopup.insertSeparator();
/* GUI contents */
- // NRI : Temporary commented
+ myHelpPopup.insertItem( tr("MEN_DESK_HELP_MODULECONTENTS"), &myHelpContentsModulePopup, HelpContentsModuleId);
+ bool toEnable = false;
+
+ CORBA::Object_var objVarN = myNameService->Resolve("/Kernel/ModulCatalog");
+ myCatalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
+
+ SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants =
+ myCatalogue->GetComponentIconeList();
+
+ for (unsigned int ind = 0; ind < list_composants->length(); ind++) {
+ QString aModuleName = strdup(list_composants[ind].modulename) ;
+ QString dir;
+ if (dir = getenv( aModuleName + "_ROOT_DIR")) {
+ dir = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + "doc/salome/" );
+ QString aFileName = aModuleName + "_index.html";
+ if ( QFileInfo( dir + aFileName ).exists() ) {
+ QString aModuleUserName = strdup(list_composants[ind].moduleusername) ;
+ if ( aModuleUserName == "Salome" ) aModuleUserName = "Kernel" ;
+ QActionP* moduleHelpAction = new QActionP( "", aModuleUserName + " Help" , 0, this, aModuleName);
+ QAD_ASSERT(connect( moduleHelpAction, SIGNAL(activated()), this, SLOT(onHelpContentsModule() )));
+ moduleHelpAction->addTo( &myHelpContentsModulePopup );
+ if (!toEnable) toEnable = true;
+ }
+ }
+ }
+
+ myHelpContentsModulePopup.setEnabled(toEnable);
+
+ // NRI : Temporary commented
// QActionP* helpContentsActionGUI = new QActionP( "", tr("MEN_DESK_HELP_GUICONTENTS"), 0, this );
// helpContentsActionGUI->setStatusTip ( tr("PRP_DESK_HELP_GUICONTENTS") );
// helpContentsActionGUI->addTo( &myHelpPopup );
// myStdActions.insert( HelpContentsId , helpContentsActionGUI );
+
/* TUI contents */
+ /*
QActionP* helpContentsActionTUI = new QActionP( "", tr("MEN_DESK_HELP_TUICONTENTS"), 0, this );
helpContentsActionTUI->setStatusTip ( tr("PRP_DESK_HELP_TUICONTENTS") );
QAD_ASSERT(connect( helpContentsActionTUI, SIGNAL(activated()),
this, SLOT( onHelpContentsTUI() )));
helpContentsActionTUI->addTo( &myHelpPopup );
myStdActions.insert( HelpContentsId , helpContentsActionTUI );
+ */
+
+
+ // Provide status tip for Module help menu item
+ QAD_ASSERT( connect( &myHelpPopup, SIGNAL(highlighted( int )), this,
+ SLOT(onHelpModulePopupStatusText( int )) ));
+
/* search */
// QActionP* helpSearchAction = new QActionP( "", tr("MEN_DESK_HELP_SEARCH"), 0, this );
*/
bool QAD_Desktop::onCloseStudy()
{
- bool close = this->onCloseStudy ( myActiveStudy, true );
- if ( close && !myXmlHandler->myIdList.IsEmpty() ) {
- clearMenus();
- myActiveComp = "";
- myCombo->setCurrentItem (0);
- for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
- aButton->setOn(false);
- }
- }
+ bool close = this->onCloseStudy ( getActiveStudy(), true );
return close;
}
/* close active component */
if (!myXmlHandler->myIdList.IsEmpty())
{
+ deactivateComponent();
clearMenus();
myActiveComp="";
myCombo->setCurrentItem (0);
{
const QActionP* obj = (QActionP*) sender();
- int SelectionMode = 4;
+ Selection_Mode SelectionMode = ActorSelection;
if ( obj == myStdActions.at(SelectionActorId) ) {
- SelectionMode = 4;
+ SelectionMode = ActorSelection;
if ( obj->isOn() ) {
myStdActions.at(SelectionCellId)->setOn(false);
myStdActions.at(SelectionEdgeId)->setOn(false);
myStdActions.at(SelectionActorId)->setOn(true);
} else if ( obj == myStdActions.at(SelectionCellId) ) {
- SelectionMode = 3;
+ SelectionMode = CellSelection;
if ( obj->isOn() ) {
myStdActions.at(SelectionActorId)->setOn(false);
myStdActions.at(SelectionEdgeId)->setOn(false);
myStdActions.at(SelectionActorId)->setOn(true);
} else if ( obj == myStdActions.at(SelectionEdgeId) ) {
- SelectionMode = 2;
+ SelectionMode = EdgeOfCellSelection;
if ( obj->isOn() ) {
myStdActions.at(SelectionActorId)->setOn(false);
myStdActions.at(SelectionCellId)->setOn(false);
myStdActions.at(SelectionActorId)->setOn(true);
} else if ( obj == myStdActions.at(SelectionPointId) ) {
- SelectionMode = 1;
+ SelectionMode = NodeSelection;
if ( obj->isOn() ) {
myStdActions.at(SelectionEdgeId)->setOn(false);
myStdActions.at(SelectionCellId)->setOn(false);
/*!
Called on 'View\Selection Mode'
*/
-void QAD_Desktop::SetSelectionMode(int mode, bool activeCompOnly)
+void QAD_Desktop::SetSelectionMode(Selection_Mode mode, bool activeCompOnly)
{
switch (mode) {
- case 1:
+ case NodeSelection:
{
myStdActions.at(SelectionEdgeId)->setOn(false);
myStdActions.at(SelectionCellId)->setOn(false);
myStdActions.at(SelectionPointId)->setOn(true);
break;
}
- case 2:
+ case EdgeOfCellSelection:
{
myStdActions.at(SelectionActorId)->setOn(false);
myStdActions.at(SelectionCellId)->setOn(false);
myStdActions.at(SelectionEdgeId)->setOn(true);
break;
}
- case 3:
- {
+ case CellSelection:
+ case EdgeSelection:
+ case FaceSelection:
+ case VolumeSelection:
+ {
myStdActions.at(SelectionActorId)->setOn(false);
myStdActions.at(SelectionEdgeId)->setOn(false);
myStdActions.at(SelectionPointId)->setOn(false);
myStdActions.at(SelectionCellId)->setOn(true);
break;
}
- case 4:
+ case ActorSelection:
{
myStdActions.at(SelectionCellId)->setOn(false);
myStdActions.at(SelectionEdgeId)->setOn(false);
};
+// Provide status tip for GUI help menu item
+
+void QAD_Desktop::onHelpModulePopupStatusText(int id)
+{
+ int Id = myHelpPopup.idAt( 0 ); // HelpContentsModuleId
+ // MESSAGE ( "myHelpContentsModulePopup : " << id << "-" << Id)
+ if (id == Id)
+ putInfo("Shows the help contents of each module");
+}
+
/*!
Called on 'help\contents'
*/
}
/*!
- Called on 'help\GUI Reference'
+ Called on 'Module Help Reference'
*/
-void QAD_Desktop::onHelpContentsGUI()
-{
-// QCString dir;
-// QString root;
-// QString homeDir;
+void QAD_Desktop::onHelpContentsModule()
+{
+ const QActionP* obj = (QActionP*) sender();
-// if ( (dir = getenv("KERNEL_ROOT_DIR")) ) {
-// root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + "doc" );
-// root = QAD_Tools::addSlash( root + "guihtml" );
-// root = QAD_Tools::addSlash( root + "guihtml" );
-// if ( QFileInfo( root + "salomedoc.html" ).exists() ) {
-// homeDir = root;
-// }
-// }
-// if ( root.isEmpty() ) {
-// if ( QFileInfo( "/usr/local/doc/guihtml/salomedoc.html" ).exists() ) {
-// homeDir = "/usr/local/doc/guihtml/";
-// }
-// }
-// if ( root.isEmpty() )
-// root = "./doc/";
-// QString helpFile = QFileInfo( homeDir + "salomedoc.html" ).absFilePath();
-// QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
-// QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
+ QString aComponentName = obj->name();
+ QString aFileName = aComponentName + "_index.html";
+
+ QCString dir;
+ QString root;
+ QString homeDir;
+ if (dir = getenv( aComponentName + "_ROOT_DIR")) {
+ root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("doc") + QAD_Tools::addSlash("salome") );
+ if ( QFileInfo( root + aFileName ).exists() ) {
+ homeDir = root;
+ } else {
+ QMessageBox::warning( this, tr("WRN_WARNING"),
+ QString( "%1"+ aFileName + " doesn't exist." ).arg(root), tr ("BUT_OK") );
+ return;
+ }
+ }
+
+ QString helpFile = QFileInfo( homeDir + aFileName ).absFilePath();
+ QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
+ QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
-// RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
-// rs->start();
-
+ RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
+ rs->start();
}
/*!
Called on 'help\TUI Reference'
*/
+
+/* Commented
void QAD_Desktop::onHelpContentsTUI()
{
if (myActiveComp == "")
QString root;
QString homeDir;
if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) {
- root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + QAD_Tools::addSlash("doc") + "html" );
+ root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("doc") + "html" );
if ( QFileInfo( root + "index.html" ).exists() ) {
homeDir = root;
- } else {
+ } else if (QFileInfo( root + "html/index.html" ).exists())
+ homeDir = root + QAD_Tools::addSlash("html");
+ else {
QMessageBox::warning( this, tr("WRN_WARNING"),
QString( "%1index.html doesn't exist." ).arg(root), tr ("BUT_OK") );
return;
}
}
-
+
QString helpFile = QFileInfo( homeDir + "index.html" ).absFilePath();
QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
rs->start();
}
+*/
+
// /*!
// Called on 'help\search'
*/
void QAD_Desktop::onWindowsPopupStatusText( int id )
{
- int cascadeId = myWindowPopup.idAt( 0 );
- int tileId = myWindowPopup.idAt( 1 );
+ int cascadeId = myWindowPopup.idAt( 1 );
+ int tileId = myWindowPopup.idAt( 2 );
if ( id == cascadeId || id == tileId )
- return;
+ return;
putInfo( tr("PRP_DESK_WINDOW_ACTIVATE") );
}
} else if ( list_type_composants->length() > 1 ) {
SALOMEGUI_OpenWith* aDlg = new SALOMEGUI_OpenWith( this );
for (unsigned int ind = 0; ind < list_type_composants->length();ind++) {
- 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();
QString QAD_Desktop::changeXmlInputSourceData(QString theData, QString theComponent)
{
- if ( theComponent=="Supervision" ) {
+ // MESSAGE ( " changeXmlInputSourceData : " << theComponent.latin1() )
+ if ( theComponent=="SUPERV" ) {
//Supervision main menu item
int aItemId = 300;
int aPosId = 3;
theData = theData.replace( QRegExp(aStrOld), aStrNew );
}
- if ( theComponent == "Visu" ) {
+ if ( theComponent == "VISU" ) {
//Visualization main menu item
int aItemId = 401;
int aPosId = 3;
theData = theData.replace( QRegExp(aStrOld), aStrNew );
//Numbering main menu item
- aItemId = 80;
- aPosId = 7;
- aStrOld = createString( aItemId, aPosId );
- aStrNew = createString( aItemId, aPosId+1 );
- theData = theData.replace( QRegExp(aStrOld), aStrNew );
+// aItemId = 80;
+// aPosId = 7;
+// aStrOld = createString( aItemId, aPosId );
+// aStrNew = createString( aItemId, aPosId+1 );
+// theData = theData.replace( QRegExp(aStrOld), aStrNew );
}
- if ( theComponent == "Geometry" ) {
+ if ( theComponent == "GEOM" ) {
//New Entity main menu item
- int aItemId = 70;
+ int aItemId = 40;
int aPosId = 3;
QString aStrOld = createString( aItemId, aPosId );
QString aStrNew = createString( aItemId, aPosId+1 );
theData = theData.replace( QRegExp(aStrOld), aStrNew );
//Operations main menu item
- aItemId = 40;
+ aItemId = 50;
aPosId = 4;
aStrOld = createString( aItemId, aPosId );
aStrNew = createString( aItemId, aPosId+1 );
theData = theData.replace( QRegExp(aStrOld), aStrNew );
//Repair main menu item
- aItemId = 50;
+ aItemId = 60;
aPosId = 5;
aStrOld = createString( aItemId, aPosId );
aStrNew = createString( aItemId, aPosId+1 );
theData = theData.replace( QRegExp(aStrOld), aStrNew );
//Measures main menu item
- aItemId = 60;
+ aItemId = 70;
aPosId = 6;
aStrOld = createString( aItemId, aPosId );
aStrNew = createString( aItemId, aPosId+1 );
theData = theData.replace( QRegExp(aStrOld), aStrNew );
}
- if ( theComponent == "Med" ) {
+ if ( theComponent == "MED" ) {
//MED main menu item
int aItemId = 90;
int aPosId = 3;
{
if (myActiveStudy != 0) {
if (myActiveComp.compare(component)!=0) {
+ // deactivate previous component
+ deactivateComponent();
+
if (!myXmlHandler->myIdList.IsEmpty()) clearMenus();
if ( myCombo->currentText() != component )
myCombo->setCurrentText( component );
}
}
} else if (component.compare(QString("Salome"))!= 0) {
-
- SALOMEGUI_ActivateComponentDlg aDlg( this );
+
+ QPixmap pm;
+ for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
+ if ( aButton->textLabel().compare( component ) == 0 )
+ pm = aButton->iconSet().pixmap();
+ }
+ SALOMEGUI_ActivateComponentDlg aDlg( this, component, pm );
int res = aDlg.exec();
switch ( res )
}
}
+
/*!
- Create popup
+ Copy popup menu [ static ]
*/
-void QAD_Desktop::createPopup(QPopupMenu* popupFather, QPopupMenu* popup,
- QString text, int popupID, bool separator)
-{
- QMenuItem* item = popup->findItem(popupID);
- if (item) {
- QPopupMenu* popupChild = item->popup();
- if ( popupChild ) {
- QPopupMenu* newPopup = new QPopupMenu;
- int count = popupChild->count();
- // add items at the top of <popupFather>
- for (int i = count - 1; i >= 0; i--) {
- int j = popupChild->idAt(i);
- QString text = popupChild->text(j);
- createPopup( newPopup, popupChild, text, j);
+static void makePopup( QPopupMenu* popup, QPopupMenu* fromPopup, QAD_Desktop* receiver )
+{
+ // safe check
+ if ( !popup || !fromPopup )
+ return;
+ // iterator through all popup items
+ for ( int i = fromPopup->count()-1; i >= 0; i-- ) {
+ int cmdId = fromPopup->idAt( i );
+ QMenuItem* item = fromPopup->findItem( cmdId );
+ if ( item ) {
+ // if item is a separator
+ if ( item->isSeparator() ) {
+ popup->insertSeparator( 0 );
+ }
+ else {
+ QIconSet* iconSet = item->iconSet();
+ QKeySequence accel = fromPopup->accel( cmdId );
+
+ QPopupMenu* popupChild = item->popup();
+ // if item is a popup
+ if ( popupChild && popupChild != fromPopup ) {
+ QPopupMenu* newPopup = new QPopupMenu( popup );
+ if ( iconSet )
+ popup->insertItem( *iconSet, item->text(), newPopup, cmdId, 0 );
+ else
+ popup->insertItem( item->text(), newPopup, cmdId, 0 );
+ makePopup( newPopup, popupChild, receiver );
+ }
+ // if item is a command
+ else {
+ if ( iconSet )
+ popup->insertItem( *iconSet, item->text(), cmdId, 0 );
+ else
+ popup->insertItem( item->text(), cmdId, 0 );
+ popup->connectItem( cmdId, receiver, SLOT( onDispatch( int ) ) );
+ }
+ popup->setAccel( accel, cmdId );
}
- popupFather->insertItem(popup->text(popupID),
- newPopup, popupID, 0);
- } else {
- if ( !text.isNull() ) {
- popupFather->insertItem(popup->text(popupID),
- this,
- SLOT( onDispatch(int) ), 0, popupID, 0);// try adding item at the top
- } /*else if ( separator )
- popupFather->insertTearOffHandle(-1, 0);*/
- else
- popupFather->insertSeparator(0);
}
}
}
-
+
/*!
Create popup
*/
{
if ( !myActiveComp.isEmpty() &&
getOperatorMenus()->createPopupMenu(theContext,theParent,theObject) != NULL ) {
- QPopupMenu* aPopup = getOperatorMenus()->createPopupMenu(theContext,theParent,theObject)->getPopup();
- int count = aPopup->count();
-
- //for (int i = 0; i < count; i++) {
- for (int i = count - 1; i >= 0; i--) {
- int id = aPopup->idAt(i);
- QString text = aPopup->text(id);
- //QString mes("Inserting popup menu item loaded from XML: ");
- //mes += text;
- //MESSAGE ( mes.latin1() )
- if (i==0)
- popup->insertItem(aPopup->text(id),
- this,
- SLOT( onDispatch(int) ), 0, id, 0);// try adding item at the top
- else
- createPopup( popup, aPopup, text, id);
- }
- } //else {
- //QString mes("Popup does not exist for given (Context = ");
- //mes += theContext;
- //mes += ", Parent = ";
- //mes += theParent;
- //mes += ", Object = ";
- //mes += theObject;
- //MESSAGE (mes.latin1())
- //popup->clear();
- //}
-
+ makePopup( popup, getOperatorMenus()->createPopupMenu(theContext,theParent,theObject)->getPopup(), this );
+ }
// IAPP Popup
// Should be moved to SALOMEGUI_Application::onCreatePopup()...
if ( myActiveComp.isEmpty() ) {
}
}
}
-
+
}
typedef bool activeStudyChanged(QAD_Desktop*);
+typedef void deactivate();
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);
/*!
QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
if (c.isValid()) {
+ /* VSR : PAL5420 ---------------------------------------------------
if ( myActiveApp ) {
QList<QAD_Study>& studies = myActiveApp->getStudies();
for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
}
}
}
+ VSR : PAL5420 --------------------------------------------------- */
QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorRed", c.red() );
QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorGreen", c.green() );
QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorBlue", c.blue() );
QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
if (c.isValid()) {
+ /* VSR : PAL5420 ---------------------------------------------------
if ( myActiveApp ) {
QList<QAD_Study>& studies = myActiveApp->getStudies();
for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
}
}
}
-
+ VSR : PAL5420 --------------------------------------------------- */
QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorRed", c.red() );
QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorGreen", c.green() );
QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorBlue", c.blue() );
QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
if (c.isValid()) {
+ /* VSR : PAL5420 ---------------------------------------------------
if ( myActiveApp ) {
QList<QAD_Study>& studies = myActiveApp->getStudies();
for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
}
}
}
-
+ VSR : PAL5420 --------------------------------------------------- */
QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorRed", c.red() );
QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorGreen", c.green() );
QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorBlue", c.blue() );
color = QColor( bgRed, bgGreen, bgBlue );
}
else {
- color = QColor(0, 0, 0);
+ color = QColor(255, 255, 255);
}
color = QColorDialog::getColor( color, QAD_Application::getDesktop() );
if ( color.isValid() ) {
+ /* VSR : PAL5420 ---------------------------------------------------
if ( myActiveApp ) {
QList<QAD_Study>& studies = myActiveApp->getStudies();
for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
}
}
}
+ VSR : PAL5420 --------------------------------------------------- */
QStringList bgData;
bgData.append( QString::number( color.red() ) );
bgData.append( QString::number( color.green() ) );
}
}
+/* Update status bar for File menu items */
+void QAD_Desktop::onFilePopupStatusText( int id )
+{
+ QString component = getActiveComponent();
+
+ if (component != "") {
+ //one of the modules is active now
+ int importId = myFilePopup.idAt(8);
+ int exportId = myFilePopup.idAt(9);
+
+ 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
#include "SALOME_NamingService.hxx"
#include "SALOME_LifeCycleCORBA.hxx"
+#include "SALOME_Selection.h"
// IDL Headers
#include <SALOMEconfig.h>
protected:
//NRI - unused - : enum ComponentType {GEOM, MESH, SOLVER, DATA, VISU, OTHER} ;
- enum { FileNewId = 0, FileOpenId, FileLoadId, FileCloseId, FileSaveId, FileSaveAsId, FilePropsId, FileExitId,
+ enum { FileNewId = -1000, FileOpenId, FileLoadId, FileCloseId, FileSaveId, FileSaveAsId, FilePropsId, FileExitId,
ViewStatusBarId,
SelectionPointId, SelectionEdgeId, SelectionCellId, SelectionActorId,
PrefViewerOCCId, PrefViewerVTKId, PrefGraphSupervisorId, PrefViewerPlot2dId,
WindowNew3dId, ViewOCCId, ViewVTKId, ViewPlot2dId,
//NRI : SAL2214
WindowCascadeId, WindowTileId,
- HelpContentsId, HelpSearchId, HelpWhatsThisId, HelpAboutId };
+ HelpContentsId, HelpContentsModuleId,
+ HelpSearchId, HelpWhatsThisId, HelpAboutId };
enum UpdateCommand { ActivateApp, DeactivateApp };
/* Desktop can be created only by application */
void definePopup(QString & theContext,
QString & theParent,
QString & theObject );
-
- void createPopup(QPopupMenu* popupFather, QPopupMenu* popup,
- QString text, int popupID, bool separator = false);
void createPopup(QPopupMenu* popup, const QString & theContext,
const QString & theParent, const QString & theObject );
void customPopup(QPopupMenu* popup, const QString & theContext,
const QString & theParent, const QString & theObject);
/* selection mode */
- void SetSelectionMode(int mode, bool activeCompOnly = false);
+ void SetSelectionMode(Selection_Mode mode, bool activeCompOnly = false);
/* desktop */
void showDesktop();
bool loadComponent(QString);
QString changeXmlInputSourceData(QString theData, QString theComponent);
void activateComponent(const QString& theName, bool isLoadData = true);
+ void deactivateComponent();
void createStudy();
void setSettings();
virtual void onWindowPopupAboutToShow();
void onWindowsPopupActivated( int id );
void onWindowsPopupStatusText( int id );
+ void onHelpModulePopupStatusText(int id);
+
+ void onFilePopupStatusText( int id );
+ void onEditPopupStatusText( int id );
+ void onViewPopupStatusText( int id );
void onSelectionMode();
void onDeactivateApp(QAD_Application* app);
void onHelpContents();
- void onHelpContentsGUI();
- void onHelpContentsTUI();
+ void onHelpContentsModule();
+ /* void onHelpContentsTUI(); */
/* void onHelpSearch(); */
void onHelpAbout();
//NRI : SAL2214
QPopupMenu myNewViewPopup;
//NRI : SAL2214
+ QPopupMenu myHelpContentsModulePopup;
+
QPopupMenu myToolsPopup;
QPopupMenu myPrefPopup;
QPopupMenu mySelectionModePopup;
QPopupMenu myWindowPopup; /* not customized by an application */
-
+
ActionMap myStdActions; /* default actions */
QToolBar* myStdToolBar; /* standard toolbar */
QStatusBar* myStatusBar; /* the only status bar */
/*
// 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;
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 );
}
}
*/
void QAD_PyEditor::dropEvent (QDropEvent *e)
{
- INFOS("dropEvent : not handled");
+ MESSAGE("dropEvent : not handled");
}
/*!
static const char* RES_PIXMAPS = "icons";
static const char* RES_STRINGS = "strings";
static const char* RES_LANGUAGE = "language";
+static const char* RES_FILES = "resources";
static const char* SEPARATOR = ":";
*/
QString resDirs = collectDirs( prefix );
conf.insert( RES_DIR, new QString( resDirs ) );
- QString fileConfig = path( CONFIG_FILE, prefix, 0 ) ;
+ QString fileConfig = QString( prefix ) + QString( "." ) + QString( CONFIG_FILE );
+ fileConfig = path( fileConfig, prefix, 0 ) ;
//MESSAGE("QAD_ResourceMgr::loadresources : config : "<<fileConfig);
+ if ( fileConfig.isEmpty() )
+ fileConfig = path( CONFIG_FILE, prefix, 0 ) ;
if ( !fileConfig.isEmpty() ) {
QFile configFile( fileConfig );
if ( !configFile.exists() || !configFile.open( IO_ReadOnly ) ) {
bool bLoadString = false;
bool bLoadImages = false;
- QStringList dirList = QStringList::split( SEPARATOR, resDirs, false ); // skip empty entries
- for ( int i = dirList.count()-1; i >= 0; i-- ) {
- QString dir = dirList[ i ];
- QString fileString = QAD_Tools::addSlash( dir ) + stFile;
- QString fileImage = QAD_Tools::addSlash( dir ) + imagesFile;
+ QStringList resFiles = conf[ RES_FILES ] ? QStringList::split( SEPARATOR, *( conf[ RES_FILES ] ), false ) : QStringList();
+
+ // first load main module's resources
+ QString fileString = path( stFile, prefix, 0 );
+ QString fileImage = path( imagesFile, prefix, 0 );
+
+ if ( !fileString.isEmpty() && settings->load( fileString ) ) {
+ bLoadString = true;
+ }
+ if ( !fileImage.isEmpty() && settings->load( fileImage ) ) {
+ bLoadImages = true;
+ }
+
+ // then load additional module's resources if any are given
+ for ( int j = 0; j < resFiles.count(); j++ ) {
+ QString stFileAdd = resFiles[j] + "_msg_" + *( conf[ RES_LANGUAGE ] ) + ".qm" ;
+ QString imagesFileAdd = resFiles[j] + "_" + RES_PIXMAPS + ".qm";
+ if ( conf[ RES_STRINGS ] && !conf[ RES_STRINGS ]->isEmpty() )
+ stFileAdd = QAD_Tools::addSlash( *conf[ RES_STRINGS ] ) + stFileAdd;
+ if ( conf[ RES_PIXMAPS ] && !conf[ RES_PIXMAPS ]->isEmpty() )
+ imagesFileAdd = QAD_Tools::addSlash( *conf[ RES_PIXMAPS ] ) + imagesFileAdd;
- if ( settings->load( fileString ) ) {
- bLoadString = true;
- }
- if ( settings->load( fileImage ) ) {
- bLoadImages = true;
- }
+ QString fileStringAdd = path( stFileAdd, prefix, 0 );
+ QString fileImageAdd = path( imagesFileAdd, prefix, 0 );
+
+ if ( !fileStringAdd.isEmpty() )
+ settings->load( fileStringAdd );
+ if ( !fileImageAdd.isEmpty() )
+ settings->load( fileImageAdd );
}
-
+
if ( !bLoadString ) {
QString warnMsg;
warnMsg.sprintf( "String resources for module %s not found.\n"
can be situated
The order is following :
- <prefix>_ROOT_DIR/share/salome/resources directory
- - CSF_<prefix>Resources env.var directory ( or directory list )
+ - SALOME_<prefix>Resources env.var directory ( or directory list )
- ${HOME}/.salome/resources directory
- KERNEL_ROOT_DIR/share/salome/resources directory
*/
QString QAD_ResourceMgr::collectDirs( const QString& prefix ) const
{
QString dirList;
- QCString envVar( "CSF_" );
+ QCString envVar;
QString dir;
char* cenv;
}
}
- // Try CSF_<prefix>Resources env.var directory ( or directory list )
+ // Try SALOME_<prefix>Resources env.var directory ( or directory list )
if ( !prefix.isEmpty() ) {
- envVar = QCString( "CSF_" ) + prefix.latin1() + QCString( "Resources" );
+ envVar = QCString( "SALOME_" ) + prefix.latin1() + QCString( "Resources" );
cenv = getenv( ( const char* ) envVar );
if ( cenv ) {
dir.sprintf( "%s", cenv );
*/
QString QAD_ResourceMgr::path( const QString& filename, const char* prefix, const char* key ) const
{
- QString filePath;
-
ResourceSettings* rs = myRes[ prefix ];
if ( rs ) {
StringDict& conf = rs->config();
for ( int i = 0; i < dirList.count(); i++ ) {
QString dir = dirList[ i ];
dir = QAD_Tools::addSlash( dir );
- if ( key ) {
- QString* where = conf[ key ];
- if ( where )
- dir = dir + QAD_Tools::addSlash( *where );
+ if ( key && conf[ key ] ) {
+ dir = dir + QString( *( conf[ key ] ) );
+ dir = QAD_Tools::addSlash( dir );
}
dir = dir + filename;
QFileInfo fileInfo( dir );
if ( fileInfo.isFile() && fileInfo.exists() ) {
- filePath = fileInfo.filePath();
- break;
+ return fileInfo.filePath();
}
}
}
}
//MESSAGE("QAD_ResourceMgr::path : <"<<filename.latin1()<<"> : "<<filePath.latin1()) ;
- return filePath;
+ return QString::null;
}
/*!
#include "QAD_Application.h"
#include "QAD_StudyFrame.h"
#include "SALOME_InteractiveObject.hxx"
+#include "SALOME_Selection.h"
// QT Include
#include <qmainwindow.h>
virtual void setBackgroundColor( const QColor& ) = 0;
virtual QColor backgroundColor() const = 0;
- virtual void SetSelectionMode( int mode ) = 0;
+ virtual void SetSelectionMode( Selection_Mode mode ) = 0;
virtual void onAdjustTrihedron() = 0;
class QAD_EXPORT QAD_WaitCursor {
public:
// constructor
- QAD_WaitCursor() : myStarted(false) { start(); }
+ QAD_WaitCursor() : myStarted( false ), myDepth( 1 ) { start(); }
// destructor
- ~QAD_WaitCursor() { stop(); }
+ ~QAD_WaitCursor() { if ( !myStarted ) { myDepth--; start(); } else { QApplication::restoreOverrideCursor(); } }
// sets WAIT cursor if not set yet
- void start() { if (!myStarted) { QApplication::setOverrideCursor(Qt::waitCursor); myStarted = true; } }
+ void start() { if ( !myStarted ) { while( myDepth-- ) QApplication::setOverrideCursor( Qt::waitCursor ); myStarted = true; } myDepth = 0; }
// clears WAIT cursor if set
- void stop() { if (myStarted) { QApplication::restoreOverrideCursor(); myStarted = false; } }
+ void stop() { if ( myStarted ) { while( QApplication::overrideCursor() ) { QApplication::restoreOverrideCursor(); myDepth++; } myStarted = false; } }
// returns true if WAIT cursor is active
bool isStarted() { return myStarted; }
private:
bool myStarted;
+ int myDepth;
};
#endif
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"
using namespace std;
#include "SALOMEGUI_ActivateComponentDlg.h"
+#include <qframe.h>
+#include <qlabel.h>
#include <qpushbutton.h>
-#include <qhbuttongroup.h>
-#include <qlayout.h>
-#include <qlabel.h>
-#include <qmessagebox.h>
+#include <qlayout.h>
+#include <qpixmap.h>
+static const char* const default_icon[] = {
+"48 48 17 1",
+". c None",
+"# c #161e4c",
+"b c #1d3638",
+"e c #2f585b",
+"i c #345b5e",
+"c c #386266",
+"g c #3f7477",
+"d c #4d8589",
+"m c #519099",
+"o c #6abbc1",
+"a c #70c9d3",
+"f c #79ddea",
+"n c #7adff2",
+"k c #7ce2f4",
+"j c #993550",
+"h c #d84b71",
+"l c #ef537d",
+"................................................",
+"................................................",
+"................................................",
+"................................................",
+"................................................",
+"................########.########.########......",
+"...............#aaaaaa###aaaaaa###aaaaaa##......",
+"..............#aaaaaa#b#aaaaaa#b#aaaaaa#c#......",
+".............########b########b########cc#......",
+".............#dddddd#b#dddddd#b#dddddd#cc#......",
+"...........########d########d########d#cc#......",
+"..........#aaaaaa###aaaaaa###aaaaaa##d#cc#......",
+".........#aaaaaa#b#aaaaaa#b#aaaaaa#c#d#cc#......",
+"........########b########e########cc#d#c#.......",
+"........#dddddd#b#dddddd#e#ffffff#cc#d####......",
+"......########d########d########f#cc###g##......",
+".....#aaaaaa###aaaaaa###hhhhhh##f#cc#gg#c#......",
+"....#aaaaaa#b#aaaaaa#i#hhhhhh#j#f#cc###cc#......",
+"...########b########i########jj#f#c#gg#cc#......",
+"...#kkkkkk#b#kkkkkk#i#llllll#jj#f####g#cc#......",
+"...#kkkkkk#b#kkkkkk#i#llllll#jj###m##g#cc#......",
+"...#knnkkk#b#kkkkkk#i#llllll#jj#mm#c#g#cc#......",
+"...#knnkkk#b#kkkkkk#i#llllll#jj###cc#g#c#.......",
+"...#kkkkkk#b#kkkkkk#i#llllll#j#dd#cc#g####......",
+"...#kkkkkk###kkkkkk###llllll####d#cc###g##......",
+"...########g########g########o##d#cc#gg#c#......",
+"....#gggggg#b#gggggg#b#oooooo#c#d#cc###cc#......",
+"...########b########b########cc#d#c#gg#cc#......",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#d####g#cc#......",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###g##g#cc#......",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#gg#c#g#cc#......",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###cc#g#c#.......",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#c#gg#cc#g##........",
+"...#kkkkkk###kkkkkk###kkkkkk####g#cc###.........",
+"...########g########g########g##g#cc#...........",
+"....#gggggg#b#gggggg#b#gggggg#c#g#cc#...........",
+"...########b########b########cc#g#c#............",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#g##.............",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###..............",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#c#.................",
+"...#kkkkkk###kkkkkk###kkkkkk##..................",
+"...########.########.########...................",
+"................................................",
+"................................................",
+"................................................",
+"................................................"};
-SALOMEGUI_ActivateComponentDlg::SALOMEGUI_ActivateComponentDlg ( QWidget * parent, const char * name, bool modal, WFlags f )
- : QDialog ( parent, "", TRUE, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+//==============================================================================================================================
+/*!
+ * SALOMEGUI_ActivateComponentDlg::SALOMEGUI_ActivateComponentDlg
+ *
+ * Constructor
+ */
+//==============================================================================================================================
+SALOMEGUI_ActivateComponentDlg::SALOMEGUI_ActivateComponentDlg ( QWidget * parent, const QString& component, const QPixmap icon )
+ : QDialog ( parent, "ActivateModuleDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
- setSizeGripEnabled ( TRUE ) ;
+ QPixmap defaultIcon( ( const char** ) default_icon );
setCaption( tr( "CAPTION" ) );
+ setSizeGripEnabled( TRUE );
+
+ QGridLayout* ActivateModuleDlgLayout = new QGridLayout( this );
+ ActivateModuleDlgLayout->setMargin( 11 ); ActivateModuleDlgLayout->setSpacing( 6 );
- QVBoxLayout* m_vbL = new QVBoxLayout( this );
- m_vbL->setMargin( 11 ); m_vbL->setSpacing( 6 );
-
- QLabel* m_lIcon = new QLabel (this, "m_lDescr");
- QPixmap pm = QMessageBox::standardIcon( QMessageBox::Information );
- m_lIcon->setPixmap( pm );
- m_lIcon->setScaledContents( false );
- m_lIcon->setAlignment( Qt::AlignCenter );
-
- QLabel* m_lDescr = new QLabel (this, "m_lDescr");
- m_lDescr->setText ( tr ("ActivateComponent_DESCRIPTION") );
- m_lDescr->setAlignment( Qt::AlignCenter );
- m_lDescr->setMinimumHeight( m_lDescr->sizeHint().height()*5 );
- m_lDescr->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
+ // Module's name and icon
+ myComponentFrame = new QFrame( this, "myComponentFrame" );
+ myComponentFrame->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ) );
+ myComponentFrame->setMinimumHeight( 100 );
+ myComponentFrame->setFrameStyle( QFrame::Box | QFrame::Sunken );
+
+ QGridLayout* myComponentFrameLayout = new QGridLayout( myComponentFrame );
+ myComponentFrameLayout->setMargin( 11 ); myComponentFrameLayout->setSpacing( 6 );
- QHBoxLayout* m_hl1 = new QHBoxLayout();
- m_hl1->setMargin( 0 ); m_hl1->setSpacing( 6 );
- m_hl1->addWidget( m_lIcon );
- m_hl1->addWidget( m_lDescr );
+ // --> icon
+ myComponentIcon = new QLabel( myComponentFrame, "myComponentIcon" );
+ myComponentIcon->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
+ myComponentIcon->setPixmap( !icon.isNull() ? icon : defaultIcon );
+ myComponentIcon->setScaledContents( false );
+ myComponentIcon->setAlignment( AlignCenter );
+ // --> name
+ myComponentLab = new QLabel( component, myComponentFrame, "myComponentLab" );
+ QFont fnt = myComponentLab->font(); fnt.setBold( TRUE ); myComponentLab->setFont( fnt );
+ myComponentLab->setAlignment( AlignCenter );
- m_pb1 = new QPushButton( tr ("NEW"), this );
- m_pb2 = new QPushButton( tr ("OPEN"), this );
- m_pb3 = new QPushButton( tr ("LOAD"), this );
- m_pb4 = new QPushButton( tr ("CANCEL"), this );
+ myComponentFrameLayout->addWidget( myComponentIcon, 0, 0 );
+ myComponentFrameLayout->addWidget( myComponentLab, 0, 1 );
- QGridLayout* m_hl2 = new QGridLayout();
- m_hl2->setMargin( 0 ); m_hl2->setSpacing( 6 );
- m_hl2->addWidget( m_pb1, 0, 0 );
- m_hl2->addWidget( m_pb2, 0, 1 );
- m_hl2->addWidget( m_pb3, 0, 2 );
- m_hl2->addColSpacing( 3, 10 );
- m_hl2->setColStretch( 3, 5 );
- m_hl2->addWidget( m_pb4, 0, 4 );
+ // Info
+ QVBoxLayout* infoLayout = new QVBoxLayout();
+ infoLayout->setMargin( 0 ); infoLayout->setSpacing( 6 );
+
+ // --> 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 );
}
#define SALOMEGUI_ActivateComponentDlg_H
#include <qdialog.h>
+#include <qpixmap.h>
+
+class QFrame;
+class QLabel;
+class QPushButton;
class SALOMEGUI_ActivateComponentDlg: public QDialog
{
Q_OBJECT
public:
- SALOMEGUI_ActivateComponentDlg ( QWidget * parent = 0, const char * name = 0, bool modal = FALSE, WFlags f = 0 ) ;
+ SALOMEGUI_ActivateComponentDlg ( QWidget* parent, const QString& component, const QPixmap icon = QPixmap() ) ;
~SALOMEGUI_ActivateComponentDlg ( ) { };
private slots:
void onButtonClicked();
private:
- QPushButton* m_pb1;
- QPushButton *m_pb2;
- QPushButton *m_pb3;
- QPushButton *m_pb4;
+ QFrame* myComponentFrame;
+ QLabel* myComponentLab;
+ QLabel* myComponentIcon;
+ QLabel* myInfoLabel;
+ QPushButton* myNewBtn;
+ QPushButton* myOpenBtn;
+ QPushButton* myLoadBtn;
+ QPushButton* myCancelBtn;
};
#endif
// 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"
// 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
void SALOMEGUI_NameDlg::setName( const QString& name )
{
myLineEdit->setText( name );
- myLineEdit->selectAll();
+ myLineEdit->end(false);
+ myLineEdit->home(true);
}
/*!
return myLineEdit->text();
}
+void SALOMEGUI_NameDlg::accept()
+{
+ if ( name().stripWhiteSpace().isEmpty() )
+ return;
+ QDialog::accept();
+}
+
/*!
Creates modal <Rename> dialog and returns name entered [ static ]
*/
static QString getName( QWidget* parent = 0, const QString& oldName = QString::null );
+protected slots:
+ void accept();
+
private:
QPushButton* myButtonOk;
QPushButton* myButtonCancel;
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
connect( ListComponent, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ));
+ connect( ListComponent, SIGNAL( doubleClicked( QListBoxItem* ) ), this, SLOT( onDoubleClickEvent( QListBoxItem* ) ));
updateButtonState();
}
buttonOk->setEnabled( ListComponent->currentItem() >=0 &&
ListComponent->currentItem() < ListComponent->count() ) ;
}
+
+void SALOMEGUI_OpenWith::onDoubleClickEvent( QListBoxItem* item )
+{
+ if ( item )
+ accept();
+}
#include <qdialog.h>
class QListBox;
+class QListBoxItem;
class QCheckBox;
class QPushButton;
protected slots:
void onSelectionChanged();
+ void onDoubleClickEvent( QListBoxItem* item );
protected:
void updateButtonState();
-
+
protected:
QListBox* ListComponent;
QCheckBox* AllwaysCheckBox;
if ((viewId >=0) && (viewId <nbStudyFrames))
myRenderer = myStudy->getStudyFrame(viewId)->getRightFrame()->getViewFrame()->getRenderer();
}
- if (myRenderer == NULL) INFOS("No VTK Renderer available !");
+ if (myRenderer == NULL) MESSAGE("No VTK Renderer available !");
return myRenderer;
}
*/
msgstr "&Settings"
msgid "PRP_PLOT2D_SETTINGS"
msgstr "Setups view properties"
+msgid "TOT_PLOT2D_CHANGE_BACKGROUND"
+msgstr "Change background"
+msgid "MEN_PLOT2D_CHANGE_BACKGROUND"
+msgstr "Change background..."
+msgid "PRP_PLOT2D_CHANGE_BACKGROUND"
+msgstr "Change background color"
msgid "INF_COORDINATES"
-msgstr "Coordinates"
+msgstr "Coordinates: X : %1, Y : %2"
msgid "SALOMEGUI_SetupCurveDlg::TLT_SETUP_CURVE"
msgstr "Setup Curve"
msgstr "&Cancel"
msgid "SALOMEGUI_ActivateComponentDlg::ActivateComponent_DESCRIPTION"
-msgstr "You need to create, open or load study before."
+msgstr "Create, open or load study."
msgid "SALOMEGUI_HELP_TITLE"
msgstr "SALOME Help"
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() ;
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() ;
#include "QAD_Desktop.h"
#include "utilities.h"
+#include <TColStd_MapIteratorOfMapOfInteger.hxx>
+
static QList<SALOME_Selection>& SALOME_Sel_GetSelections()
{
static QList<SALOME_Selection> Selections;
{
myFilters.Clear();
myIObjects.Clear();
- mySelectionMode = 4; /*Actor*/
+ mySelectionMode = ActorSelection; /*4*/
mySelActiveCompOnly = false;
QAD_Desktop* aDesktop = QAD_Application::getDesktop();
return true;
}
-void SALOME_Selection::SetSelectionMode(int mode, bool activeCompOnly)
+void SALOME_Selection::SetSelectionMode(Selection_Mode mode, bool activeCompOnly)
{
mySelectionMode = mode;
mySelActiveCompOnly = activeCompOnly;
}
-int SALOME_Selection::SelectionMode()
+Selection_Mode SALOME_Selection::SelectionMode()
{
return mySelectionMode;
}
bool modeShift,
bool update)
{
- MESSAGE ( " SALOME_Selection::AddOrRemoveIndex " << index << " - " << modeShift )
+ MESSAGE ( " SALOME_Selection::AddOrRemoveIndex " << index << " - " << modeShift );
QAD_Desktop* myDesktop = (QAD_Desktop*) QAD_Application::getDesktop();
QAD_Study* myActiveStudy = myDesktop->getActiveStudy();
return false;
}
+bool SALOME_Selection::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject,
+ const TColStd_MapOfInteger& theIndices,
+ bool modeShift,
+ bool update)
+{
+ QAD_Desktop* myDesktop = (QAD_Desktop*) QAD_Application::getDesktop();
+ QAD_Study* myActiveStudy = myDesktop->getActiveStudy();
+
+ if ( !myMapIOSubIndex.IsBound( IObject ) ) {
+ TColStd_MapOfInteger Empty;
+ myMapIOSubIndex.Bind( IObject, Empty );
+ }
+ TColStd_MapOfInteger& MapIndex = myMapIOSubIndex.ChangeFind( IObject );
+ TColStd_MapIteratorOfMapOfInteger It;
+ It.Initialize(theIndices);
+
+ bool add = true;
+
+ if (MapIndex.Contains(It.Key()))
+ {
+ if (!modeShift) return add;
+ add = false;
+ }
+ else if (!modeShift)
+ MapIndex.Clear();
+
+ if (add)
+ for(;It.More();It.Next())
+ MapIndex.Add(It.Key());
+ else
+ for(;It.More();It.Next())
+ MapIndex.Remove(It.Key());
+
+
+ myActiveStudy->highlight( IObject, true, update );
+ if ( MapIndex.IsEmpty() ) myMapIOSubIndex.UnBind( IObject );
+ emit currentSelectionChanged();
+
+ return add;
+}
+
+bool SALOME_Selection::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject,
+ const std::vector<int>& theIndices,
+ bool modeShift,
+ bool update)
+{
+ QAD_Desktop* myDesktop = (QAD_Desktop*) QAD_Application::getDesktop();
+ QAD_Study* myActiveStudy = myDesktop->getActiveStudy();
+
+ if ( !myMapIOSubIndex.IsBound( IObject ) ) {
+ TColStd_MapOfInteger Empty;
+ myMapIOSubIndex.Bind( IObject, Empty );
+ }
+ TColStd_MapOfInteger& MapIndex = myMapIOSubIndex.ChangeFind( IObject );
+
+ bool add = true;
+
+ if (MapIndex.Contains(theIndices[0]))
+ {
+ if (!modeShift) return add;
+ add = false;
+ }
+ else if (!modeShift)
+ MapIndex.Clear();
+
+ if (add)
+ for (int i=0; i<theIndices.size();i++)
+ MapIndex.Add(theIndices[i]);
+ else
+ for (int i=0; i<theIndices.size();i++)
+ MapIndex.Remove(theIndices[i]);
+
+ myActiveStudy->highlight( IObject, true, update );
+ if ( MapIndex.IsEmpty() )
+ myMapIOSubIndex.UnBind( IObject );
+ emit currentSelectionChanged();
+
+ return add;
+}
+
void SALOME_Selection::RemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, int index )
{
if ( myMapIOSubIndex.IsBound( IObject ) ) {
// Open CASCADE Include
#include <TColStd_MapOfInteger.hxx>
+#include <vector>
+
+enum Selection_Mode {
+ NodeSelection,
+ CellSelection,
+ EdgeOfCellSelection,
+ EdgeSelection,
+ FaceSelection,
+ VolumeSelection,
+ ActorSelection };
+
class SALOME_Selection : public QObject
{
Q_OBJECT
public:
+
SALOME_Selection(const QString& aName);
~SALOME_Selection();
bool IsOk( const Handle(SALOME_InteractiveObject)& IObject ) ;
- void SetSelectionMode(int mode, bool activeCompOnly = false);
- int SelectionMode();
+ void SetSelectionMode(Selection_Mode mode, bool activeCompOnly = false);
+ Selection_Mode SelectionMode();
bool IsSelectActiveCompOnly() const;
bool HasIndex( const Handle(SALOME_InteractiveObject)& IObject );
TColStd_MapOfInteger& theIndex );
bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, int index, bool modeShift, bool update=true );
+ bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, const TColStd_MapOfInteger& theIndices, bool modeShift, bool update=true );
+ bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, const std::vector<int>& theIndices, bool modeShift, bool update=true );
void RemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, int index );
bool IsIndexSelected(const Handle(SALOME_InteractiveObject)& IObject, int index);
SALOME_DataMapOfIOMapOfInteger myMapIOSubIndex;
- int mySelectionMode;
+ Selection_Mode mySelectionMode;
bool mySelActiveCompOnly;
};
if ((viewId >=0) && (viewId <nbStudyFrames))
renderer = ((VTKViewer_ViewFrame*)myStudy->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("---");
module=PyImport_ImportModule((char*)_moduleName.c_str());
if(module == NULL)
{
- INFOS ( " Problem... " );
+ MESSAGE ( " Problem... " );
PyErr_Print();
interp->quit();
return;
#--------------------------------------------------------------------------
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
#--------------------------------------------------------------------------
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
print "============= Test SMESH ============================="
print
+import StdMeshers
+
comp = catalog.GetComponent("SMESH")
if comp is None:
raise RuntimeError,"Component SMESH not found in Module Catalog."
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);
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
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
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)
}
-void SUPERVGraph_ViewFrame::SetSelectionMode( int mode )
+void SUPERVGraph_ViewFrame::SetSelectionMode( Selection_Mode mode )
{
MESSAGE ( "SUPERVGraph_ViewFrame::SetSelectionMode" )
}
#include "QAD_Application.h"
#include "SALOME_InteractiveObject.hxx"
+#include "SALOME_Selection.h"
class QAD_EXPORT SUPERVGraph_View: public QWidget, public QAD_PopupClientServer{
Q_OBJECT;
void setBackgroundColor( const QColor& );
QColor backgroundColor() const;
- void SetSelectionMode( int mode );
+ void SetSelectionMode( Selection_Mode mode );
void onAdjustTrihedron( );
#include "QAD_ResourceMgr.h"
#include <qlabel.h>
-
+#include "Utils_CatchSignals.h"
+#include "Utils_CorbaException.hxx"
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS)
_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 ) )
{
_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 : "<<p<< " is caught");
+
+ QApplication::restoreOverrideCursor();
+ QAD_MessageBox::error1 ( (QWidget*)QAD_Application::getDesktop(),
+ QObject::tr("ERR_ERROR"),
+ QObject::tr("ERR_APP_EXCEPTION")+ QObject::tr(" CORBA exception ") + QObject::tr(p),
+ QObject::tr("BUT_OK") );
+ }
+ catch(std::exception& e) {
+ INFOS("run(): An exception has been caught");
+ QApplication::restoreOverrideCursor();
+ QAD_MessageBox::error1 ( (QWidget*)QAD_Application::getDesktop(),
+ QObject::tr("ERR_ERROR"),
+ QObject::tr("ERR_APP_EXCEPTION")+ " " +QObject::tr(e.what()),
QObject::tr("BUT_OK") );
}
catch(...) {
- MESSAGE("run(): An exception has been caught")
+ INFOS("run(): An exception has been caught")
QApplication::restoreOverrideCursor();
QAD_MessageBox::error1 ( (QWidget*)QAD_Application::getDesktop(),
QObject::tr("ERR_ERROR"),
QObject::tr("BUT_OK") );
}
}
-
+
+ aCatch.Deactivate();
QString confMsg = "Settings create $HOME/." + QObject::tr("MEN_APPNAME") + "/" + QObject::tr("MEN_APPNAME") + ".conf";
MESSAGE (confMsg )
QAD_CONFIG->createConfigFile(true);
}
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))
{
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))
{
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 ) );
}
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))
{
}
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))
{
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);
int main (int argc, char * argv[])
{
- INFOS("It's OK");
+ MESSAGE("It's OK");
return 0;
}
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
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@
throw SALOME::SALOME_Exception(ExDescription); \
}
+#include <ostream.h>
+//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<<p;
+ }
+ else {
+ os << tc->id();
+ }
+
+ return os;
+}
#endif
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" ) ;}
}
#if !defined( __Utils_SALOME_Exception_hxx__ )
#define __Utils_SALOME_Exception_hxx__
-using namespace std;
# include <exception>
# include <iostream>
+using namespace std;
+
# define LOCALIZED(message) #message , __FILE__ , __LINE__
class SALOME_Exception : public exception
/* --- INFOS is always defined (without _DEBUG_): to be used for warnings, with release version --- */
-#define INFOS(msg) {SLog.putMessage(SLog<<__FILE__<<" ["<<__LINE__<<"] : "<<msg<<endl);}
-#define PYSCRIPT(msg) {SLog.putMessage(SLog<<"---PYSCRIPT--- "<<msg<<endl);}
+#define INFOS(msg) {SLog.putMessage(SLog<<__FILE__<<" ["<<__LINE__<<"] : "<<msg<<endl<<ends);}
+#define PYSCRIPT(msg) {SLog.putMessage(SLog<<"---PYSCRIPT--- "<<msg<<endl<<ends);}
/* --- To print date and time of compilation of current source --- */
SLog<<__FILE__<<" ["<< __LINE__<<"] : "\
<< "COMPILED with " << COMPILER \
<< ", " << __DATE__ \
- << " at " << __TIME__ <<endl); }
+ << " at " << __TIME__ <<endl<<ends); }
#ifdef _DEBUG_
EXPORT_HEADERS = SALOME_Transform.h \
SALOME_TransformFilter.h \
SALOME_PassThroughFilter.h \
- SALOME_GeometryFilter.h
+ SALOME_GeometryFilter.h \
+ SALOME_ExtractUnstructuredGrid.h
# Libraries targets
LIB_SRC = SALOME_Transform.cxx \
SALOME_TransformFilter.cxx \
SALOME_PassThroughFilter.cxx \
- SALOME_GeometryFilter.cxx
+ SALOME_GeometryFilter.cxx \
+ SALOME_ExtractUnstructuredGrid.cxx
# Executables targets
BIN_SRC =
CPPFLAGS+= $(VTK_INCLUDES)
-LDFLAGS+= $(VTK_LIBS)
+LDFLAGS+= $(VTK_LIBS) -lOpUtil
@CONCLUDE@
// File : SALOME_GeometryFilter.cxx
// Author : Michael ZORIN
// Module : SALOME
-// $Header: /dn05/salome/CVS/SALOME_ROOT/SALOME/src/OBJECT/SALOME_GeometryFilter.cxx
+// $Header$
#include "SALOME_GeometryFilter.h"
#include <vtkVoxel.h>
#include <vtkWedge.h>
+#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();
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();
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;
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)
// 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++)
{
//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();
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();
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();
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();
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();
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<<myVTK2ObjIds[i]<<", ";
+ }
+ cout<<"\n";
+ for(int i = 0, iEnd = myObj2VTKIds.size(); i < iEnd; i++){
+ TVectorId& aVectorId = myObj2VTKIds[i];
+ cout<<aVectorId.size()<<": ";
+ for(int j = 0, jEnd = aVectorId.size(); j < jEnd; j++){
+ cout<<aVectorId[j]<<", ";
+ }
+ cout<<"\n";
+ }
+ cout<<"\n";
+ }
+
// Update ourselves and release memory
//
- output->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();
// 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 <vtkGeometryFilter.h>
+#include <vector>
class SALOME_GeometryFilter : public vtkGeometryFilter
{
void SetInside(int theShowInside);
int GetInside();
+ void SetStoreMapping(int theStoreMapping);
+ int GetStoreMapping(){ return myStoreMapping;}
+
+ typedef std::vector<vtkIdType> TVectorId;
+ virtual vtkIdType GetObjId(int theVtkID);
+ virtual TVectorId GetVtkId(int theObjID);
+
protected:
SALOME_GeometryFilter();
~SALOME_GeometryFilter();
void UnstructuredGridExecute();
private:
- int myShowInside;
+ int myShowInside;
+
+ int myStoreMapping;
+ TVectorId myVTK2ObjIds;
+ typedef std::vector<TVectorId> TVecVectorId;
+ TVecVectorId myObj2VTKIds;
};
#endif
#include "SALOME_PassThroughFilter.h"
-#include "SALOME_GeometryFilter.h"
+#include <vtkCellData.h>
+#include <vtkDataSet.h>
#include <vtkObjectFactory.h>
-#include <vtkPointSet.h>
#include <vtkPointData.h>
-#include <vtkCellData.h>
-#include <vtkPoints.h>
-#include <vtkMatrix4x4.h>
-
-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<vtkDataSet*>(this->GetInput());
vtkDataSet *output = static_cast<vtkDataSet*>(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);
}
#include <vtkDataSetToDataSetFilter.h>
-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.
};
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
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 \
// $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"
#include <vtkPolyDataMapper.h>
#include <vtkDataSetCollection.h>
#include <vtkImageData.h>
-#include <vtkFollower.h>
#include <qapplication.h>
//VRV: porting on Qt 3.0.5
#endif
//VRV: porting on Qt 3.0.5
+#include "utilities.h"
+
using namespace std;
extern int SetVisibility(vtkActorCollection* theCollection, int theParam);
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);
}
//----------------------------------------------------------------------------
{
}
+//----------------------------------------------------------------------------
+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;
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();
}
}
if(aTriedronWasVisible) m_Trihedron->VisibilityOn();
else m_Trihedron->VisibilityOff();
+ ::ResetCameraClippingRange(CurrentRenderer);
}
// VSV: LOD actor activisation
// rwi->GetRenderWindow()->SetDesiredUpdateRate(rwi->GetStillUpdateRate());
- int aSelectionMode = aSel->SelectionMode();
+ Selection_Mode aSelectionMode = aSel->SelectionMode();
bool aSelActiveCompOnly = aSel->IsSelectActiveCompOnly();
switch (State) {
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());
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<int> 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<int> 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 = "<<edgeId);
}
- MESSAGE("edgeID transformed = "<<edgeId);
- // Look in the current selection
- SALOME_ListIteratorOfListIO It(aSel->StoredIObjects());
- Standard_Boolean IsSelected = false;
- for(;It.More();It.Next()) {
- Handle(SALOME_InteractiveObject) IOS = It.Value();
- if(IO->isSame(IOS)) {
- IO = IOS; //Added by SRN, fix SAL1307
- IsSelected = true;
- break;
+ if (result) {
+ // Look in the current selection
+ SALOME_ListIteratorOfListIO It(aSel->StoredIObjects());
+ Standard_Boolean IsSelected = false;
+ for(;It.More();It.Next()) {
+ Handle(SALOME_InteractiveObject) IOS = It.Value();
+ if(IO->isSame(IOS)) {
+ IO = IOS; //Added by SRN, fix SAL1307
+ IsSelected = true;
+ break;
+ }
}
+ if (!myShiftState) {
+ this->HighlightProp( NULL );
+ aSel->ClearIObjects();
+ }
+ // aSel->SetSelectionMode(EdgeSelection, true);
+ if (aVtkList.size() > 0)
+ aSel->AddOrRemoveIndex( IO, aVtkList, true, false);
+ else
+ aSel->AddOrRemoveIndex( IO, aVtkId, true, false);
+ if (edgeId >= 0)
+ aSel->AddOrRemoveIndex( IO, -edgeId-1, true, true );
+ aSel->AddIObject( IO, false );
}
- if(!myShiftState) {
- this->HighlightProp( NULL );
- aSel->ClearIObjects();
- }
- aSel->SetSelectionMode(2, true);
- bool add = aSel->AddOrRemoveIndex( IO, pickedID, true, false);
- if(edgeId >= 0)
- add = aSel->AddOrRemoveIndex( IO, -edgeId-1, true, true );
- aSel->AddIObject( IO, false );
}
}
}
}
- } else {
- this->HighlightProp( NULL );
- aSel->ClearIObjects();
}
+ } else {
+ this->HighlightProp( NULL );
+ aSel->ClearIObjects();
}
}
} else if ( rwi->GetPicker()->IsA("vtkPointPicker") ) {
vtkPointPicker* picker;
if ( (picker = vtkPointPicker::SafeDownCast(rwi->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;
}
}
}
- 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();
}
// Compute bounds
- vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
+ // vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
QRect rect(myPoint, myOtherPoint);
rect = rect.normalize();
int w, h, x, y;
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());
if (IO.IsNull())
continue;
if (aSelActiveCompOnly &&
- strcmp(aActiveComponent->ComponentDataType(), IO->getComponentDataType()) != 0) {
+ strcmp(aActiveComponent->ComponentDataType(),
+ IO->getComponentDataType()) != 0) {
continue;
}
continue;
}
if (aDataSet) {
+
+ std::vector<int> anIndices;
for (int i=0; i < aDataSet->GetNumberOfPoints(); i++) {
float* aPoint;
aPoint = aDataSet->GetPoint(i);
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<int>::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();
+ }
}
}
}
}
}
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<int> 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<int> aVtkList;
+ if ( aObjId != -1 )
+ aVtkList = aSActor->GetVtkId(aObjId);
+
+ if (aVtkList.size() > 0) {
+ std::vector<int>::iterator it;
+ for (it = aVtkList.begin(); it != aVtkList.end(); ++it) {
+ std::vector<int>::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<int> 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<int>::iterator it;
+ for (it = aVtkList.begin(); it != aVtkList.end(); ++it) {
+ std::vector<int>::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);
}
}
}
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;
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<int> 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<int> 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 = "<<edgeId);
+ }
+ if (result)
+ {
+ this->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();
}
ac = theActors->GetNextActor();
}
- // MESSAGE ( " NAME PREVIEW " << SActor->getName() );
+ // INFOS ( " NAME PREVIEW " << SActor->getName() );
}
}
}
}
}
}
+ rwi->EndPickCallback();
+ rwi->Render();
+
this->LastPos[0] = x;
this->LastPos[1] = y;
}
return ((aPnt[0]>left) && (aPnt[0]<right) && (aPnt[1]>bottom) && (aPnt[1]<top));
}
+
+void VTKViewer_InteractorStyleSALOME::SetFaceFilter( const Handle(VTKViewer_Filter)& f )
+{
+ myFaceFilter = f;
+}
+
+void VTKViewer_InteractorStyleSALOME::RemoveFaceFilter()
+{
+ myFaceFilter.Nullify();
+}
+
+void VTKViewer_InteractorStyleSALOME::SetEdgeFilter( const Handle(VTKViewer_Filter)& f )
+{
+ myEdgeFilter = f;
+}
+
+void VTKViewer_InteractorStyleSALOME::RemoveEdgeFilter()
+{
+ myEdgeFilter.Nullify();
+}
+
+bool VTKViewer_InteractorStyleSALOME::isValid( SALOME_Actor* theActor,
+ const int theId,
+ const Selection_Mode theSelMode )
+{
+ if ( theSelMode != CellSelection &&
+ theSelMode != FaceSelection &&
+ theSelMode != EdgeSelection )
+ return true;
+
+ if ( theSelMode == CellSelection )
+ {
+ vtkDataSet* aUGrid = theActor->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;
+}
#include <qobject.h>
#include <qcursor.h>
#include "SALOME_Actor.h"
+#include "VTKViewer_Filter.h"
+#include "SALOME_Selection.h"
class VTKViewer_Trihedron;
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);
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();
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);
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
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 --------------------------------------------------- */
}
}
#include "QAD_Application.h"
#include "QAD_Desktop.h"
-#include "SALOME_Selection.h"
+//#include "SALOME_Selection.h"
#include "SALOME_Actor.h"
#include <stdio.h>
//
this->Initialized = 1 ;
+ myTolNodes = 0.025;
+ myTolItems = 0.001;
+
Cell_Actor = vtkActor::New();
Cell_Actor->PickableOff();
Cell_Actor->GetProperty()->SetColor(1,1,0);
}
-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() {
//
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)) {
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() ;
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()){
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)
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();
{
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<int>& theIndexes, vtkActor* theActor )
+{
+ TColStd_MapOfInteger MapIndex;
+ std::vector<int>::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,
{
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,
{
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);
+}
#include "SALOME_InteractiveObject.hxx"
#include "SALOME_Actor.h"
+#include "SALOME_Selection.h"
// QT Includes
#include <qobject.h>
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<int>& 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();
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);
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.
int displaymode;
//NRI: Selection mode
- int selectionmode;
+ Selection_Mode selectionmode;
vtkActor* Point_Actor;
vtkActor* Edge_Actor; //NB
vtkActor* Cell_Actor;
private:
QWidget* myGUIWindow;
+ double myTolNodes;
+ double myTolItems;
};
#endif
protected:
VTKViewer_UnScaledActor();
+ ~VTKViewer_UnScaledActor(){}
int mySize;
};
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);
}
//==============================================================================
+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
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);
VTKViewer_Trihedron::TVisibility myVisibility;
float myDir[3], myRot[3];
- vtkActor *myLineActor;
+ VTKViewer_LineActor *myLineActor;
+ //vtkActor *myLineActor;
VTKViewer_UnScaledActor *myArrowActor;
VTKViewer_UnScaledActor *myLabelActor;
myMapper[0] = vtkPolyDataMapper::New();
myMapper[0]->SetInput(myLineSource->GetOutput());
- myLineActor = vtkActor::New();
+ myLineActor = VTKViewer_LineActor::New();
myLineActor->SetMapper(myMapper[0]);
myLineActor->PickableOff();
myArrowActor->SetSize(aArrowActorSize);
myArrowActor->PickableOff();
+ myLineActor->SetArrowActor(myArrowActor);
+
// Initialize the Label pipe-line representation
myVectorText = VTKViewer_VectorText::New();
static int aLabelActorSize = 12;
myLabelActor->SetSize(aLabelActorSize);
myLabelActor->PickableOff();
+ //myLabelActor->DebugOn();
+
+ myLineActor->SetLabelActor(myLabelActor);
// Initialise visibility param.
myVisibility = VTKViewer_Trihedron::eOn;
//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);
- }
-}
-
virtual int GetVisibleActorCount(vtkRenderer* theRenderer);
- virtual void Render(vtkRenderer *theRenderer);
-
protected:
vtkActorCollection* myPresent;
VTKViewer_Axis* myAxis[3];
if ( theRenderer->GetActiveCamera() != NULL )
theRenderer->GetActiveCamera()->GetViewPlaneNormal(vn);
else{
- INFOS("Trying to reset non-existant camera");
+ MESSAGE("Trying to reset non-existant camera");
return;
}
#include "SALOME_Transform.h"
#include "SALOME_TransformFilter.h"
-#include "SALOME_PassThroughFilter.h"
#include "SALOME_GeometryFilter.h"
#include "QAD_Settings.h"
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);
}
}
-void VTKViewer_ViewFrame::SetSelectionMode( int mode )
+void VTKViewer_ViewFrame::SetSelectionMode( Selection_Mode mode )
{
m_RWInteractor->SetSelectionMode( mode );
}
{
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;
}
}
theActor->RemoveFromRender(m_Renderer);
if(update) Repaint();
}
-
-
void setBackgroundColor( const QColor& );
QColor backgroundColor() const;
- void SetSelectionMode( int mode );
+ void SetSelectionMode( Selection_Mode mode );
/* popup management */
void setPopupServer( QAD_Application* );