-This is the version 2.0.0 of KERNEL
+This is the version 2.1.0 of KERNEL
Previous versions :
- - 1.4.1
+ - 2.0.0
+ - 1.4.1
- 1.3.0
- 1.2.1
showNS.py
# copy header files in common directory
-ifeq ($(HAVE_SSTREAM),yes)
- include_list=include/salome/SALOMEconfig.h
+OWN_CONFIG_H=@OWN_CONFIG_H@
+
+ifeq ($(OWN_CONFIG_H),yes)
+ ifeq ($(HAVE_SSTREAM),yes)
+ include_list=include/salome/SALOMEconfig.h include/salome/config.h
+ else
+ include_list=include/salome/SALOMEconfig.h include/salome/config.h include/salome/sstream
+ endif
else
- include_list=include/salome/SALOMEconfig.h include/salome/sstream
+ ifeq ($(HAVE_SSTREAM),yes)
+ include_list=include/salome/SALOMEconfig.h
+ else
+ include_list=include/salome/SALOMEconfig.h include/salome/sstream
+ endif
endif
inc: idl $(include_list)
cp -p $< $@; \
fi; \
+include/salome/config.h: salome_adm/unix/config.h
+ -$(RM) $@
+ $(LN_S) ../../$< $@
+
include/salome/sstream: salome_adm/unix/sstream
-$(RM) $@
$(LN_S) ../../$< $@
distclean-other:
-$(RM) salome_adm/unix/*~ salome_adm/unix/*% salome_adm/unix/*.bak salome_adm/unix/*.new salome_adm/unix/*.old
-$(RM) salome_adm/unix/make_*
- -$(RM) salome_adm/unix/depend salome_adm/unix/SALOMEconfig.h
+ -$(RM) salome_adm/unix/depend salome_adm/unix/SALOMEconfig.h salome_adm/unix/config.h
-$(RM) config.cache config.log config.status
@MODULE@
-THIS IS SALOME - KERNEL VERSION: 2.0.0
+THIS IS SALOME - KERNEL VERSION: 2.1.0
pass
elif self.space == ["Configuration-list","modules-list","module","plugin"] and "name" in attrs.getNames():
key = str(self.currentModuleName)+"_plugins"
- if not self.opts.has_key("key"):
+ if not self.opts.has_key(key):
self.opts[key]=[]
pass
self.opts[key].append(attrs.getValue("name"))
#!/bin/bash
-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
+searchFreePort() {
+ echo -n "Searching for a free port for naming service: "
+ export NSPORT=2810
+ local limit=$NSPORT
+ let limit=limit+100
+ while [ 1 ]
+ do
+ aRes=`netstat -ltn | grep -E :${NSPORT}`
+ if [ -z "$aRes" ]; then
+ echo ${NSPORT} - Ok
+ local myhost=`hostname`
+ export OMNIORB_CONFIG=${HOME}/.omniORB_${myhost}_${NSPORT}.cfg
+ local initref="NameService=corbaname::"`hostname`":$NSPORT"
+ echo "ORBInitRef $initref" > $OMNIORB_CONFIG
+ break
+ fi
+ echo -n "${NSPORT} "
+ if [[ $NSPORT -eq $limit ]] ; then
+ echo
+ echo "Can't find a free port to launch omniNames"
+ echo "Try to kill the running servers and then launch SALOME again."
+ exit
+ fi
+ let NSPORT=NSPORT+1
+ done
+}
+
+searchFreePort
if [ $# -ne 0 ] ; then
python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py $*
# ---------
# $: ${KERNEL_ROOT_DIR}/bin/salome/runSalome
#
-# parameters read from $HOME/.salome/salome.launch
-# if the config file does not exist, it is created with default values
+# - parameters for launching are taken from $HOME/.salome/salome.launch;
+# - if the config file does not exist, it is created with default values.
#
#
# $: ${KERNEL_ROOT_DIR}/bin/salome/runSalome --modules=GEOM,SMESH,VISU,SUPERV,MED --embedded=registry,study,moduleCatalog,cppContainer --standalone=pyContainer,supervContainer --xterm --killall
#
# parameters from command line supersede those from $HOME/.salome/salome.launch
#
-# Some CORBA servers could be launched in the SALOME_Session_Server
+# Some CORBA servers can be launched in the SALOME_Session_Server's process
# (embedded = same process) or in a separate process (standalone):
# --> registry,study,moduleCatalog,cppContainer
# Other CORBA servers could only be launched in separate process (standalone):
#!/bin/csh -f
-runSalome --gui --modules=GEOM,SMESH,DATA,VISU,SUPERV,MED --containers=cpp,python --killall
+runSalome --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --containers=cpp,python --killall
add_path(os.path.join(plugin_root,"bin",args['appname']), "PATH")
pass
pass
-
+
+# set environment for SUPERV module
+os.environ["ENABLE_MACRO_NODE"]="1"
+
import orbmodule
#
if "GEOM" in modules_list:
print "GEOM OCAF Resources"
os.environ["CSF_GEOMDS_ResourcesDefaults"]=os.path.join(modules_root_dir["GEOM"],"share",args['appname'],"resources")
+ print "GEOM Shape Healing Resources"
+ os.environ["CSF_ShHealingDefaults"]=os.path.join(modules_root_dir["GEOM"],"share",args['appname'],"resources")
if 'study' not in args['embedded']:
SalomeDSServer().run()
<module name="GEOM"/>
<module name="SMESH">
<plugin name="NETGENPlugin"/>
+ <plugin name="GHS3DPlugin"/>
</module>
- <module name="DATA"/>
<module name="VISU"/>
<module name="SUPERV"/>
<module name="MED"/>
touch configure.in_tmp2
find_in . configure.in_tmp2
sed '/^...salome_adm/d' configure.in_tmp2 > configure.in_tmp3
-sed '/configure.in/d' configure.in_tmp3 > configure.in_tmp2
+sed '/configure.in/d;/make_config.in/d' configure.in_tmp3 > configure.in_tmp2
sed 's/.in / /' configure.in_tmp2 >> configure.in_tmp1
echo "])" >> configure.in_tmp1
echo "failed (check file permissions and/or user quotas ...)"
fi
+###############################################################
+# Creating make_config
+#
+if test -f make_config
+then
+ echo -n "Updating 'make_config' script ... "
+else
+ echo -n "Creating 'make_config' script ... "
+fi
+
+if autoconf -o make_config make_config.in
+then
+ echo "done"
+else
+ echo "failed (check file permissions and/or user quotas ...)"
+fi
+
cd ${ORIG_DIR}
echo
-<!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">\r
-\r
-<html>\r
-\r
-<!--(==============================================================)-->\r
-<!--(Document created with RoboEditor. )============================-->\r
-<!--(==============================================================)-->\r
-\r
-<head>\r
-\r
-<title>Running SALOME</title>\r
-\r
-<!--(Meta)==========================================================-->\r
-\r
-<meta http-equiv=content-type content="text/html; charset=windows-1252">\r
-<meta name=generator content="RoboHELP by eHelp Corporation - www.ehelp.com">\r
-<meta name=generator-major-version content=0.1>\r
-<meta name=generator-minor-version content=1>\r
-<meta name=filetype content=kadov>\r
-<meta name=filetype-version content=1>\r
-<meta name=page-count content=1>\r
-<meta name=layout-height content=1118>\r
-<meta name=layout-width content=707>\r
-\r
-\r
-<!--(Links)=========================================================-->\r
-\r
- <link rel='stylesheet' href='../default_ns.css'>\r
-<script type="text/javascript" language="JavaScript" title="WebHelpSplitCss">\r
+<!DOCTYPE doctype PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN">
+<html>
+<head>
+<!--(==============================================================)--><!--(Document created with RoboEditor. )============================--><!--(==============================================================)-->
+ <title>Running SALOME</title>
+ <!--(Meta)==========================================================-->
+
+ <meta http-equiv="content-type"
+ content="text/html; charset=windows-1252">
+
+ <meta name="generator"
+ content="RoboHELP by eHelp Corporation - www.ehelp.com">
+
+ <meta name="generator-major-version" content="0.1">
+
+ <meta name="generator-minor-version" content="1">
+
+ <meta name="filetype" content="kadov">
+
+ <meta name="filetype-version" content="1">
+
+ <meta name="page-count" content="1">
+
+ <meta name="layout-height" content="1118">
+
+ <meta name="layout-width" content="707">
+ <!--(Links)=========================================================-->
+
+ <link rel="stylesheet" href="../default_ns.css">
+
+ <script type="text/javascript" language="JavaScript"
+ title="WebHelpSplitCss">\r
<!--\r
if (navigator.appName !="Netscape")\r
{ document.write("<link rel='stylesheet' href='../default.css'>");}\r
//-->\r
-</script>\r
-<style type="text/css">\r
+ </script>
+ <style type="text/css">\r
<!--\r
h1.whs1 {font-family: 'Times New Roman', serif;}\r
p.whs2 {margin-left: 0px; font-style: italic; color: #000000; font-family: 'Arial Black', sans-serif;}\r
p.whs29 {font-family: 'Times New Roman', serif; margin-left: 80px;}\r
p.whs30 {font-family: 'Courier New', monospace; margin-left: 0px;}\r
-->\r
-</style>\r
-<script type="text/javascript" language="JavaScript">\r
+ </style>
+ <script type="text/javascript" language="JavaScript">\r
<!--\r
if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4))\r
{\r
document.write(strNSS);\r
}\r
//-->\r
-</script>\r
-<script type="text/javascript" language="JavaScript" title="BSSC Special Effects" src="../ehlpdhtm.js"></script><script type="text/javascript" language="JavaScript" title="WebHelpInlineScript">\r
+ </script>
+ <script type="text/javascript" language="JavaScript"
+ title="BSSC Special Effects" src="../ehlpdhtm.js"></script>
+ <script type="text/javascript" language="JavaScript"
+ title="WebHelpInlineScript">\r
<!--\r
function reDo() {\r
if (innerWidth != origWidth || innerHeight != origHeight)\r
}\r
onerror = null; \r
//-->\r
-</script>\r
-<style type="text/css">\r
+ </script>
+ <style type="text/css">\r
<!--\r
div.WebHelpPopupMenu {position:absolute; left:0px; top:0px; z-index:4; visibility:hidden;}\r
-->\r
-</style>\r
-<script type="text/javascript" language="javascript1.2" src="../whmsg.js"></script>\r
-<script type="text/javascript" language="javascript" src="../whver.js"></script>\r
-<script type="text/javascript" language="javascript1.2" src="../whproxy.js"></script>\r
-<script type="text/javascript" language="javascript1.2" src="../whutils.js"></script>\r
-<script type="text/javascript" language="javascript1.2" src="../whtopic.js"></script>\r
-</head>\r
-\r
-<!--(Body)==========================================================-->\r
-\r
-\r
-<body>\r
-\r
+ </style>
+ <script type="text/javascript" language="javascript1.2"
+ src="../whmsg.js"></script>
+ <script type="text/javascript" language="javascript" src="../whver.js"></script>
+ <script type="text/javascript" language="javascript1.2"
+ src="../whproxy.js"></script>
+ <script type="text/javascript" language="javascript1.2"
+ src="../whutils.js"></script>
+ <script type="text/javascript" language="javascript1.2"
+ src="../whtopic.js"></script><!--(Body)==========================================================-->
+</head>
+ <body>
+
<script type="text/javascript" language="javascript1.2">\r
<!--\r
if (window.gbWhTopic)\r
else\r
document.location.reload();\r
//-->\r
-</script>\r
-<h1 class="whs1">Running SALOME</h1>\r
-\r
-<p class="whs2">To launch SALOME:</p>\r
-\r
-<p class="whs3"> </p>\r
-\r
-<p class="whs4">1. Install the SALOME package into a definite \r
- directory (ex. <span style="font-weight: bold;"><B>SALOME</B></span>) on your \r
- hard disk. It is preferable if you use the <a href="installing_salome_pro.htm">special \r
- installation procedure</a> allowing to install the SALOME \r
- platform and all corresponding applications. </p>\r
-\r
-<p class="whs5"> </p>\r
-\r
-<p class="whs6">2.<span style="font-family: 'Courier New', monospace;"> \r
- </span>The installation shell script will create a special file: <b>env.csh</b> \r
- (CShell file) in your <b><i><span style="font-style: normal; font-weight: bold;"><B>SALOME</B></span><span \r
- style="font-weight: normal; font-style: normal;"> </span></i></b>directory. \r
- This file contains all environment variables necessary for launching SALOME \r
- platform with other application products provided with SALOME installation \r
- package. You have a possibility to add one of them into your profile if \r
- you enter in the command console the following:</p>\r
-\r
-<p class="whs6"> </p>\r
-\r
-<p class="whs6"><span style="font-family: 'Courier New', monospace;">source \r
- env.csh </span></p>\r
-\r
-<p class="whs6"> </p>\r
-\r
-<p class="whs7"><img src="../tip1.gif" x-maintain-ratio="TRUE" width="35px" height="37px" border="0" class="img_whs8"> <span style="font-family: 'Times New Roman', serif;">During \r
- the installation procedure you have a possibility <a href="installing_salome_pro.htm#profile">to \r
- set your profile automatically.</a> </span> </p>\r
-\r
-<p class="whs9"> </p>\r
-\r
-<p> </p>\r
-\r
-<p class="whs10">3. Launch SALOME platform, using the following \r
- Python script located in the <span style="font-weight: bold;"><B>SALOME/KERNEL/bin/salome</B></span> \r
- directory:</p>\r
-\r
-<p class="whs11"> </p>\r
-\r
-<ul type="disc" class="whs12">\r
- \r
- <li class=kadov-p><p class="whs10"><span style="font-weight: bold;"><B>runSalome.py</B></span> \r
- [command line options]</p></li>\r
-</ul>\r
-\r
-<p class="whs10"> </p>\r
-\r
-<!--(Table)=========================================================-->\r
-<table x-use-null-cells resizable="no" cellspacing="0" width="96.029%" class="whs13">\r
-<script language='JavaScript'><!--\r
+</script>
+<h1 class="whs1">Running SALOME</h1>
+
+<p class="whs2">To launch SALOME:</p>
+
+<p class="whs3"> </p>
+
+<p class="whs4">1. Install the SALOME package into a definite directory
+(ex. <span style="font-weight: bold;"><b>SALOME</b></span>) on your hard
+disk. It is preferable if you use the <a href="readme.html">special installation
+procedure</a> allowing to install the SALOME platform and all corresponding
+applications. </p>
+
+<p class="whs5"> </p>
+
+<p class="whs6">2.<span style="font-family: 'Courier New',monospace;">
+</span>The installation shell script will create a special file: <b>env.csh</b>
+ (CShell file) in your <b><i><span
+ style="font-style: normal; font-weight: bold;"><b>SALOME</b></span><span
+ style="font-weight: normal; font-style: normal;"> </span></i></b>directory.
+ This file contains all environment variables necessary for launching SALOME
+ platform with other application products provided with SALOME installation
+ package. You have a possibility to add one of them into your profile if
+ you enter in the command console the following:</p>
+
+<p class="whs6"> </p>
+
+<p class="whs6"><span style="font-family: 'Courier New',monospace;">source
+ env.csh </span></p>
+
+<p class="whs6"> </p>
+
+<p class="whs10">3. Launch SALOME platform, using the following Python
+script located in the <span style="font-weight: bold;"><b>SALOME/KERNEL/bin/salome</b></span>
+ directory:</p>
+
+<p class="whs11"> </p>
+
+<ul type="disc" class="whs12">
+ <li class="kadov-p">
+ <p class="whs10"><span style="font-weight: bold;"><b>runSalome.py</b></span>
+ [command line options]</p>
+ </li>
+
+</ul>
+
+<p class="whs10"> </p>
+ <!--(Table)=========================================================-->
+<table x-use-null-cells="" resizable="no" cellspacing="0" width="96%"
+ class="whs13">
+
+ <script language="JavaScript"><!--\r
if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4)) document.write("</table><table x-use-null-cells resizable='no' cellspacing='0' width='96.029%' border='1' bordercolor='silver' bordercolorlight='silver' bordercolordark='silver'>");\r
-//--></script>\r
-<col class="whs14">\r
-<col class="whs15">\r
-\r
-<tr valign="top" class="whs16">\r
-<td bgcolor="#400080" width="214px" class="whs17">\r
-<p class="whs18">Options</td>\r
-<td bgcolor="#400080" width="390px" class="whs19">\r
-<p class="whs18">Description</td></tr>\r
-\r
-<tr valign="top" class="whs16">\r
-<td width="214px" class="whs20">\r
-<p><span style="font-weight: bold;"><B>--help</B></span> <span style="font-style: italic;"><I>or</I></span> \r
- <span style="font-weight: bold;"><B>-h</B></span> </td>\r
-<td width="390px" class="whs21">\r
-<p>print this help</p>\r
-<p> </td></tr>\r
-\r
-<tr valign="top" class="whs16">\r
-<td width="214px" class="whs20">\r
-<p><span style="font-weight: bold;"><B>--gui</B></span> <span style="font-style: italic;"><I>or</I></span> \r
- <span style="font-weight: bold;"><B>-g</B></span> </td>\r
-<td width="390px" class="whs21">\r
-<p>launch with GUI</td></tr>\r
-\r
-<tr valign="top" class="whs16">\r
-<td width="214px" class="whs20">\r
-<p> <span style="font-weight: bold;"><B><a \r
- name=batchmode></a>--terminal</B></span> <span style="font-style: italic;"><I>or \r
- </I></span><span style="font-weight: bold;"><B>-t</B></span> </td>\r
-<td width="390px" class="whs21">\r
-<p>launch without GUI in batch mode</td></tr>\r
-\r
-<tr valign="top" class="whs16">\r
-<td colspan="1" rowspan="1" width="214px" class="whs20">\r
-<p><span style="font-weight: bold;"><B>--logger</B></span> <span style="font-style: italic;"><I>or</I></span> \r
- <span style="font-weight: bold;"><B>-l</B></span> </td>\r
-<td colspan="1" rowspan="1" width="390px" class="whs21">\r
-<p>redirection of log messages into a definite file </td></tr>\r
-\r
-<tr valign="top" class="whs16">\r
-<td colspan="1" rowspan="1" width="214px" class="whs20">\r
-<p><span style="font-weight: bold;"><B>--xterm</B></span> <span style="font-style: italic;"><I>or</I></span> \r
- <span style="font-weight: bold;"><B>-x</B></span> </td>\r
-<td colspan="1" rowspan="1" width="390px" class="whs21">\r
-<p>the servers open an xterm window and log messages are displayed in this \r
- window</td></tr>\r
-\r
-<tr valign="top" class="whs16">\r
-<td colspan="1" rowspan="1" width="214px" class="whs20">\r
-<p><span style="font-weight: bold;"><B>--modules=module1,module2,...</B></span> \r
- <span style="font-style: italic;"><I>or</I></span> <span style="font-weight: bold;"><B>-m=module1,module2,...</B></span></td>\r
-<td colspan="1" rowspan="1" width="390px" class="whs21">\r
-<p>list of SALOME modules which will be loaded into the module catalogue</td></tr>\r
-\r
-<tr valign="top" class="whs16">\r
-<td colspan="1" rowspan="1" width="214px" class="whs22">\r
-<p><span style="font-weight: bold;"><B>--containers=cpp,python,superv</B></span></p>\r
-<p><span style="font-style: italic;"><I>or</I></span> <span style="font-weight: bold;"><B>-c=cpp,python,superv</B></span></td>\r
-<td colspan="1" rowspan="1" width="390px" class="whs23">\r
-<p>launch of cpp, python and supervision containers</td></tr>\r
-\r
-<tr valign="top" class="whs16">\r
-<td colspan="1" rowspan="1" width="214px" class="whs24">\r
-<p><span style="font-weight: bold;"><B>--portkill</B></span> <span style="font-style: italic;"><I>or</I></span> \r
- <span style="font-weight: bold;"><B>-p</B></span></td>\r
-<td colspan="1" rowspan="1" width="390px" class="whs25">\r
-<p>kill SALOME launched with the current port</td></tr>\r
-\r
-<tr valign="top" class="whs16">\r
-<td colspan="1" rowspan="1" width="214px" class="whs26">\r
-<p><span style="font-weight: bold;"><B>--killall</B></span> <span style="font-style: italic;"><I>or</I></span> \r
- <span style="font-weight: bold;"><B>-k</B></span> </td>\r
-<td colspan="1" rowspan="1" width="390px" class="whs27">\r
-<p>kill SALOME</td></tr>\r
-<script language='JavaScript'><!--\r
+//--></script>
+ <col class="whs14"> <col class="whs15"> <tbody>
+ <tr valign="top" class="whs16">
+ <td bgcolor="#400080" width="214" class="whs17">
+ <p class="whs18">Options</p>
+ </td>
+ <td bgcolor="#400080" width="390" class="whs19">
+ <p class="whs18">Description</p>
+ </td>
+ </tr>
+ <tr valign="top" class="whs16">
+ <td width="214" class="whs20">
+ <p><span style="font-weight: bold;"><b>--help</b></span> <span
+ style="font-style: italic;"><i>or</i></span> <span
+ style="font-weight: bold;"><b>-h</b></span> </p>
+ </td>
+ <td width="390" class="whs21">
+ <p>print this help</p>
+
+ <p> </p>
+ </td>
+ </tr>
+ <tr valign="top" class="whs16">
+ <td width="214" class="whs20">
+ <p><span style="font-weight: bold;"><b>--gui</b></span> <span
+ style="font-style: italic;"><i>or</i></span> <span
+ style="font-weight: bold;"><b>-g</b></span> </p>
+ </td>
+ <td width="390" class="whs21">
+ <p>launch with GUI</p>
+ </td>
+ </tr>
+ <tr valign="top" class="whs16">
+ <td width="214" class="whs20">
+ <p> <span style="font-weight: bold;"><b><a name="batchmode"></a>--terminal</b></span>
+ <span style="font-style: italic;"><i>or </i></span><span
+ style="font-weight: bold;"><b>-t</b></span> </p>
+ </td>
+ <td width="390" class="whs21">
+ <p>launch without GUI in batch mode</p>
+ </td>
+ </tr>
+ <tr valign="top" class="whs16">
+ <td colspan="1" rowspan="1" width="214" class="whs20">
+ <p><span style="font-weight: bold;"><b>--logger</b></span> <span
+ style="font-style: italic;"><i>or</i></span> <span
+ style="font-weight: bold;"><b>-l</b></span> </p>
+ </td>
+ <td colspan="1" rowspan="1" width="390" class="whs21">
+ <p>redirection of log messages into a definite file </p>
+ </td>
+ </tr>
+ <tr valign="top" class="whs16">
+ <td colspan="1" rowspan="1" width="214" class="whs20">
+ <p><span style="font-weight: bold;"><b>--xterm</b></span> <span
+ style="font-style: italic;"><i>or</i></span> <span
+ style="font-weight: bold;"><b>-x</b></span> </p>
+ </td>
+ <td colspan="1" rowspan="1" width="390" class="whs21">
+ <p>the servers open an xterm window and log messages are displayed
+in this window</p>
+ </td>
+ </tr>
+ <tr valign="top" class="whs16">
+ <td colspan="1" rowspan="1" width="214" class="whs20">
+ <p><span style="font-weight: bold;"><b>--modules=module1,module2,...</b></span>
+ <span style="font-style: italic;"><i>or</i></span> <span
+ style="font-weight: bold;"><b>-m=module1,module2,...</b></span></p>
+ </td>
+ <td colspan="1" rowspan="1" width="390" class="whs21">
+ <p>list of SALOME modules which will be loaded into the module catalogue</p>
+ </td>
+ </tr>
+ <tr valign="top" class="whs16">
+ <td colspan="1" rowspan="1" width="214" class="whs22">
+ <p><span style="font-weight: bold;"><b>--containers=cpp,python,superv</b></span></p>
+
+ <p><span style="font-style: italic;"><i>or</i></span> <span
+ style="font-weight: bold;"><b>-c=cpp,python,superv</b></span></p>
+ </td>
+ <td colspan="1" rowspan="1" width="390" class="whs23">
+ <p>launch of cpp, python and supervision containers</p>
+ </td>
+ </tr>
+ <tr valign="top" class="whs16">
+ <td colspan="1" rowspan="1" width="214" class="whs24">
+ <p><span style="font-weight: bold;"><b>--portkill</b></span> <span
+ style="font-style: italic;"><i>or</i></span> <span
+ style="font-weight: bold;"><b>-p</b></span></p>
+ </td>
+ <td colspan="1" rowspan="1" width="390" class="whs25">
+ <p>kill SALOME launched with the current port</p>
+ </td>
+ </tr>
+ <tr valign="top" class="whs16">
+ <td colspan="1" rowspan="1" width="214" class="whs26">
+ <p><span style="font-weight: bold;"><b>--killall</b></span> <span
+ style="font-style: italic;"><i>or</i></span> <span
+ style="font-weight: bold;"><b>-k</b></span> </p>
+ </td>
+ <td colspan="1" rowspan="1" width="390" class="whs27">
+ <p>kill SALOME</p>
+ </td>
+ </tr>
+
+ <script language="JavaScript"><!--\r
if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4)) document.write("</table></table><table>");\r
-//--></script>\r
-</table>\r
-\r
-<p class="whs10"> </p>\r
-\r
-<p class="whs28"><img src="../tip1.gif" x-maintain-ratio="TRUE" width="35px" height="37px" border="0" class="img_whs8"><span style="font-weight: normal; font-family: 'Times New Roman', serif;"> \r
- If the </span><span style="font-family: 'Times New Roman', serif;">runSalome.py \r
- </span><span style="font-family: 'Times New Roman', serif; font-weight: normal;">script \r
- is launched without prompting any options, they will be taken by default \r
- from the xml file </span><span style="font-family: 'Times New Roman', serif;">salome.launch</span><span \r
- style="font-family: 'Times New Roman', serif; font-weight: normal;">, \r
- which has been automatically created in your home directory: </span><span \r
- style="font-family: 'Times New Roman', serif;">HOME/.salome/</span><span \r
- style="font-family: 'Times New Roman', serif; font-weight: normal;">. \r
- </span> </p>\r
-\r
-<p class="whs29"> </p>\r
-\r
-<p class="whs29"> </p>\r
-\r
-<p class="whs30">\r
-<a href="javascript:void(0);" onClick="var e; if (parseInt(navigator.appVersion)>=4){e=event;} if (parseInt(navigator.appVersion) >=2 && typeof(PopupMenu_Invoke) == 'function') PopupMenu_Invoke(e,'','About SALOME PRO architecture','about_salome_pro_architecture.htm','Installing SALOME PRO','installing_salome_pro.htm','Introduction to SALOME PRO','introduction_to_salome_pro.htm');return false;" title="Related Topics"><img src="../ss_btn_related_topics.gif" border=0 height=17 width=82 alt="Related Topics"></a></p>\r
-\r
-<p class="whs30"> </p>\r
-\r
-<p class="whs30"> </p>\r
-\r
-<p class="whs30"> </p>\r
-\r
-<script type="text/javascript" language="JavaScript" title="WebHelpRelatedTopics"><!--\r
+//--></script>
+ </tbody>
+</table>
+
+<p class="whs10"> </p>
+
+<p class="whs28"><img src="../tip1.gif" x-maintain-ratio="TRUE"
+ width="35" height="37" border="0" class="img_whs8">
+<span style="font-weight: normal; font-family: 'Times New Roman',serif;">
+ If the </span><span style="font-family: 'Times New Roman',serif;">runSalome.py
+ </span><span
+ style="font-family: 'Times New Roman',serif; font-weight: normal;">script
+ is launched without prompting any options, they will be taken by default
+ from the xml file </span><span
+ style="font-family: 'Times New Roman',serif;">salome.launch</span><span
+ style="font-family: 'Times New Roman',serif; font-weight: normal;">, which
+has been automatically created in your home directory: </span><span
+ style="font-family: 'Times New Roman',serif;">HOME/.salome/</span><span
+ style="font-family: 'Times New Roman',serif; font-weight: normal;">. </span> </p>
+
+<p class="whs29"> </p>
+
+<p class="whs29"> </p>
+
+<p class="whs30"> <a href="javascript:void(0);"
+ onclick="var e; if (parseInt(navigator.appVersion)>=4){e=event;} if (parseInt(navigator.appVersion) >=2 && typeof(PopupMenu_Invoke) == 'function') PopupMenu_Invoke(e,'','About SALOME PRO architecture','about_salome_pro_architecture.htm','Installing SALOME PRO','readme.html','Introduction to SALOME PRO','introduction_to_salome_pro.htm');return false;"
+ title="Related Topics"><img src="../ss_btn_related_topics.gif"
+ border="0" height="17" width="82" alt="Related Topics">
+</a></p>
+
+<p class="whs30"> </p>
+
+<p class="whs30"> </p>
+
+<p class="whs30"> </p>
+
+<script type="text/javascript" language="JavaScript"
+ title="WebHelpRelatedTopics"><!--\r
if (parseInt(navigator.appVersion) >= 3 && typeof (WritePopupMenuLayer) == "function")\r
WritePopupMenuLayer();\r
-//--></script><script type="text/javascript" language="javascript1.2">\r
+//--></script>
+<script type="text/javascript" language="javascript1.2">\r
<!--\r
if (window.writeIntopicBar)\r
writeIntopicBar(0);\r
//-->\r
-</script>\r
-</body>\r
-\r
-</html>\r
+</script> <br>
+</body>
+</html>
<td bgcolor= "lightgreen"><div align="center"><b>return_value = FindObjectID ( aObjectID )</b></div></td>
</tr>
<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>SObject CreateObjectID ( in ID aObjectID )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>return_value = CreateObjectID ( aObjectID )</b></div></td>
+</tr>
+<tr>
<td bgcolor= "lightgreen"><div align="center"><b>SObject FindObjectIOR ( in ID aObjectIOR )</b></div></td>
<td bgcolor= "lightgreen"><div align="center"><b>return_value = FindObjectIOR ( aObjectIOR )</b></div></td>
</tr>
<td bgcolor= "lightgreen"><div align="center"><b>void EnableUseCaseAutoFilling ( in boolean isEnabled )</b></div></td>
<td bgcolor= "lightgreen"><div align="center"><b>EnableUseCaseAutoFilling ( isEnabled )</b></div></td>
</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>void AddPostponed ( in string theIOR )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>AddPostponed ( theIOR )</b></div></td>
+</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>void AddCreatedPostponed ( in string theIOR )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>AddCreatedPostponed ( theIOR )</b></div></td>
+</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>void RemovePostponed ( in long theUndoLimit )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>RemovePostponed ( theUndoLimit )</b></div></td>
+</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>void UndoPostponed ( in long theWay )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>UndoPostponed ( theWay )</b></div></td>
+</tr>
</table><br>
<table width="100%" BORDER>
<tr bgcolor="#FFFFCC">
<td bgcolor= "lightgreen"><div align="center"><b>Addreference ( anObject, theReferencedObject )</b></div></td>
</tr>
<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>void RemoveReference ( in SObject anObject )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>RemoveReference ( anObject )</b></div></td>
+</tr>
+<tr>
<td bgcolor= "lightgreen"><div align="center"><b>void AddDirectory ( in string theName )</b></div></td>
<td bgcolor= "lightgreen"><div align="center"><b>AddDirectory ( theName )</b></div></td>
</tr>
<td bgcolor= "lightgreen"><div align="center"><b>Callback SetOnRemoveSObject ( in Callback theCallback )</b></div></td>
<td bgcolor= "lightgreen"><div align="center"><b>return_value = SetOnRemoveSObject ( theCallback )</b></div></td>
</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>void SetName ( in SObject theSO, in string theValue )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>SetName ( theSO, theValue )</b></div></td>
+</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>void SetComment ( in SObject theSO, in string theValue )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>SetComment ( theSO, theValue )</b></div></td>
+</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>void SetIOR ( in SObject theSO, in string theValue )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>SetIOR ( theSO, theValue )</b></div></td>
+</tr>
</table><br>
<table width="100%" BORDER>
<tr bgcolor="#FFFFCC">
<td bgcolor= "lightgreen"><div align="center"><b>return_value = Tag ( )</b></div></td>
</tr>
<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>short Depth ( )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>return_value = Depth ( )</b></div></td>
+</tr>
+<tr>
<td bgcolor= "lightgreen"><div align="center"><b>boolean FindSubObject ( in long atag, out SObject obj )</b></div></td>
<td bgcolor= "lightgreen"><div align="center"><b>[ return_value, obj ] = FindSubObject ( atag )</b></div></td>
</tr>
<td bgcolor= "lightgreen"><div align="center"><b>Study GetStudy ( )</b></div></td>
<td bgcolor= "lightgreen"><div align="center"><b>return_value = GetStudy ( )</b></div></td>
</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>Object GetObject ( )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>return_value = GetObject ( )</b></div></td>
+</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>string GetName ( )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>return_value = GetName ( )</b></div></td>
+</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>string GetComment ( )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>return_value = GetComment ( )</b></div></td>
+</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>string GetIOR ( )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>return_value = GetIOR ( )</b></div></td>
+</tr>
</table><br>
<table width="100%" BORDER>
<tr bgcolor="#FFFFCC">
<td bgcolor= "lightgreen"><div align="center"><b>void CheckLocked ( )</b></div></td>
<td bgcolor= "lightgreen"><div align="center"><b>CheckLocked ( )</b></div></td>
</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>string Store ( )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>return_value = Store ( )</b></div></td>
+</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>void Restore ( in string theData )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>Restore ( theData )</b></div></td>
+</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>string Type ( )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>return_value = Type ( )</b></div></td>
+</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>SObject GetSObject ( )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>return_value = GetSObject ( )</b></div></td>
+</tr>
</table><br>
<table width="100%" BORDER>
<tr bgcolor="#FFFFCC">
</table><br>
<table width="100%" BORDER>
<tr bgcolor="#FFFFCC">
+<td colspan="11"><font size="+3"><b><div align="center"><i>interface AttributeExternalFileDef</i></div></b></font></td>
+</tr>
+<td width="50%" bgcolor= "lightgreen" ><font size="+2"><div align="center"><b><i>IDL file</i></b></div></font></td>
+<td width="50%" bgcolor= "lightgreen"><font size="+2"><div align="center"><b><i>Python</i></b></div></font></td>
+</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>string Value ( )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>return_value = Value ( )</b></div></td>
+</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>void SetValue ( in string value )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>SetValue ( value )</b></div></td>
+</tr>
+</table><br>
+<table width="100%" BORDER>
+<tr bgcolor="#FFFFCC">
+<td colspan="11"><font size="+3"><b><div align="center"><i>interface AttributeFileType</i></div></b></font></td>
+</tr>
+<td width="50%" bgcolor= "lightgreen" ><font size="+2"><div align="center"><b><i>IDL file</i></b></div></font></td>
+<td width="50%" bgcolor= "lightgreen"><font size="+2"><div align="center"><b><i>Python</i></b></div></font></td>
+</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>string Value ( )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>return_value = Value ( )</b></div></td>
+</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>void SetValue ( in string value )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>SetValue ( value )</b></div></td>
+</tr>
+</table><br>
+<table width="100%" BORDER>
+<tr bgcolor="#FFFFCC">
<td colspan="11"><font size="+3"><b><div align="center"><i>interface AttributeDrawable</i></div></b></font></td>
</tr>
<td width="50%" bgcolor= "lightgreen" ><font size="+2"><div align="center"><b><i>IDL file</i></b></div></font></td>
<td bgcolor= "lightgreen"><div align="center"><b>boolean Kill_impl ( )</b></div></td>
<td bgcolor= "lightgreen"><div align="center"><b>return_value = Kill_impl ( )</b></div></td>
</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>string getHostName ( )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>return_value = getHostName ( )</b></div></td>
+</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>long getPID ( )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>return_value = getPID ( )</b></div></td>
+</tr>
</table><br>
<table width="100%" BORDER>
<tr bgcolor="#FFFFCC">
<td bgcolor= "lightgreen"><div align="center"><b>return_value = GetContainerRef ( )</b></div></td>
</tr>
<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>void setProperties ( in FieldsDict dico )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>setProperties ( dico )</b></div></td>
+</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>FieldsDict getProperties ( )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>return_value = getProperties ( )</b></div></td>
+</tr>
+<tr>
<td bgcolor= "lightgreen"><div align="center"><b>void Names ( in string aGraphName, in string aNodeName )</b></div></td>
<td bgcolor= "lightgreen"><div align="center"><b>Names ( aGraphName, aNodeName )</b></div></td>
</tr>
<td bgcolor= "lightgreen"><div align="center"><b>Acomponent GetComponent ( in string componentname )</b></div></td>
<td bgcolor= "lightgreen"><div align="center"><b>return_value = GetComponent ( componentname )</b></div></td>
</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>Component GetComponentInfo ( in string componentName )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>return_value = GetComponentInfo ( componentName )</b></div></td>
+</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>void ImportXmlCatalogFile ( in string filename )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>ImportXmlCatalogFile ( filename )</b></div></td>
+</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>void shutdown ( )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>shutdown ( )</b></div></td>
+</tr>
</table><br>
</b></HTML>
<td bgcolor= "lightgreen"><div align="center"><b>GetInterface ( )</b></div></td>
</tr>
<tr>
-<td bgcolor= "lightgreen"><div align="center"><b>Component GetVisuGen ( )</b></div></td>
-<td bgcolor= "lightgreen"><div align="center"><b>return_value = GetVisuGen ( )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>Component GetVisuComponent ( )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>return_value = GetVisuComponent ( )</b></div></td>
</tr>
<tr>
<td bgcolor= "lightgreen"><div align="center"><b>void StopSession ( )</b></div></td>
<td bgcolor= "lightgreen"><div align="center"><b>void ping ( )</b></div></td>
<td bgcolor= "lightgreen"><div align="center"><b>ping ( )</b></div></td>
</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>long GetActiveStudyId ( )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>return_value = GetActiveStudyId ( )</b></div></td>
+</tr>
</table><br>
</b></HTML>
<td bgcolor= "lightgreen"><div align="center"><b>string Coucou ( in long L )</b></div></td>
<td bgcolor= "lightgreen"><div align="center"><b>return_value = Coucou ( L )</b></div></td>
</tr>
+<tr>
+<td bgcolor= "lightgreen"><div align="center"><b>void Setenv ( )</b></div></td>
+<td bgcolor= "lightgreen"><div align="center"><b>Setenv ( )</b></div></td>
+</tr>
</table><br>
</b></HTML>
#---------------------------------------------------------------------------
# General configuration options
#---------------------------------------------------------------------------
-PROJECT_NAME = "SALOME v.2.0.0"
+PROJECT_NAME = "SALOME v.2.1.0"
PROJECT_NUMBER = id#1.1
OUTPUT_DIRECTORY = ../
OUTPUT_LANGUAGE = English
-foldersTree = gFld("<b>SALOME v.2.0.0 </b>", "", "")
+foldersTree = gFld("<b>SALOME v.2.1.0 </b>", "", "")
insDoc(foldersTree, gLnk("Main Page", "", "main.html"))
aux1 = insFld(foldersTree, gFld("TUI Reference Guide", ""))
inc: $(top_builddir)/idl/salome $(IDL_FILES:%=$(top_builddir)/idl/salome/%)
$(top_builddir)/idl/salome:
- mkdir $@
+ mkdir -p $@
$(IDL_FILES:%=$(top_builddir)/idl/salome/%):$(IDL_FILES:%=$(top_srcdir)/idl/%)
# $(CP) $< $@
# install python client (generated from idl file
-install: install-pyidl install-idl
+install: $(top_builddir)/idl/salome install-pyidl install-idl
# create directory $(idldir) and copy idl files into it
install-idl: $(IDL_FILES:%=$(top_builddir)/idl/salome/%)
\return the %tag of a %SObject.
*/
short Tag();
+/*! Gets the depth of a %SObject
+
+ \return the depth of a %SObject.
+*/
+ short Depth();
/*! Looks for subobjects of a given %SObject.
\param atag Tag of the given %SObject
Determines whether the server has already been loaded or not.
*/
void ping();
+/*!
+ Get Active study ID
+*/
+ long GetActiveStudyId();
} ;
} ;
include/salome/SALOMEconfig.h:
+include/salome/config.h:
+
include/salome/sstream:
depend:
AC_SUBST(CAS_LDPATH)
+OWN_CONFIG_H=no
+
CAS_CPPFLAGS=""
CAS_CXXFLAGS=""
CAS_LDFLAGS=""
occ_ok=no
+own_config_h=no
+
dnl libraries directory location
case $host_os in
dnl cascade headers
CPPFLAGS_old="$CPPFLAGS"
- CPPFLAGS="$CPPFLAGS -DLIN -DLINTEL -DCSFDB -DNO_CXX_EXCEPTION -DNo_exception -DHAVE_CONFIG_H -DHAVE_LIMITS_H -I$CASROOT/inc -I$CASROOT -Wno-deprecated -DHAVE_WOK_CONFIG_H"
+ CPPFLAGS="$CPPFLAGS -DLIN -DLINTEL -DCSFDB -DNO_CXX_EXCEPTION -DNo_exception -DHAVE_CONFIG_H -DHAVE_LIMITS_H -I$CASROOT/inc -I$CASROOT -I$KERNEL_ROOT_DIR/include/salome -Wno-deprecated -DHAVE_WOK_CONFIG_H"
CXXFLAGS_old="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -funsigned-char"
+
+ echo
+ echo
+ echo testing config.h
+ echo
+ echo
+
+ AC_CHECK_HEADER(config.h, own_config_h=no, [
+ echo
+ echo
+ echo "config.h file not found! Generating it..."
+ echo
+ echo
+ mv confdefs.h backup_confdefs.h
+ ${ROOT_SRCDIR}/make_config
+ rm -rf ${ROOT_BUILDDIR}/*.log
+ rm -rf ${ROOT_BUILDDIR}/*.status
+ mv backup_confdefs.h confdefs.h
+ rm -f backup_confdefs.h
+ own_config_h=yes
+ echo
+ echo
+ ])
+
+ if test "x$own_config_h" = xyes ; then
+ OWN_CONFIG_H=yes
+ fi
+
+ CPPFLAGS="$CPPFLAGS -I$ROOT_BUILDDIR/salome_adm/unix"
+
AC_CHECK_HEADER(Standard_Type.hxx,occ_ok=yes ,occ_ok=no)
CPPFLAGS="$CPPFLAGS_old"
CXXFLAGS="$CXXFLAGS_old"
fi
+AC_SUBST(OWN_CONFIG_H)
+
if test "x$occ_ok" = xyes ; then
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 -I$CASROOT -DHAVE_WOK_CONFIG_H"
AC_MSG_CHECKING(for OpenCascade libraries)
CPPFLAGS_old="$CPPFLAGS"
- CPPFLAGS="$CPPFLAGS $CAS_CPPFLAGS -Wno-deprecated"
+ CPPFLAGS="$CPPFLAGS $CAS_CPPFLAGS -I$KERNEL_ROOT_DIR/include/salome -I$ROOT_BUILDDIR/salome_adm/unix -Wno-deprecated"
CXXFLAGS_old="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $CAS_CXXFLAGS"
LIBS_old="$LIBS"
if test "x$omniORB_ok" = "xyes"
then
- OMNIORB_IDLCXXFLAGS="-I$OMNIORB_ROOT/idl"
+ OMNIORB_IDLCXXFLAGS="-nf -I$OMNIORB_ROOT/idl"
OMNIORB_IDLPYFLAGS="-bpython -I$OMNIORB_ROOT/idl"
AC_SUBST(OMNIORB_IDLCXXFLAGS)
AC_SUBST(OMNIORB_IDLPYFLAGS)
if test "x$PYQTDIR" = x; then
PYQTDIR="/usr"
fi
-
+
if test "x$PYQT_SIPS" = x; then
PYQT_SIPS="/usr/share/sip/qt"
fi
PYQTBIN=$PYQTDIR
fi
-AC_CHECK_FILE("$PYQTBIN/pyuic",pyqt_ok=yes,pyqt_ok=no)
+if test "x$PYUIC" = x; then
+ PYUIC="$PYQTBIN/pyuic"
+fi
+
+AC_CHECK_FILE("$PYUIC",pyqt_ok=yes,pyqt_ok=no)
if test "x$pyqt_ok" = xyes ; then
AC_CHECK_FILES("$PYQTLIB/qt.py",pyqt_ok=yes,pyqt_ok=no)
esac],
enable_production=AC_ENABLE_PRODUCTION_DEFAULT)dnl
+CXXFLAGS="$CXXFLAGS -Wno-deprecated -Wparentheses -Wreturn-type -Wmissing-declarations -Wunused "
+
+CXXVERSION=`$CXX --version`
+if test "X$CXXVERSION" != "X2.95.3"; then
+ CXXFLAGS="${CXXFLAGS} -fmessage-length=0 "
+fi
+
if test "X$enable_production" = "Xyes"; then
CFLAGS="$CFLAGS -O"
- CXXFLAGS="$CXXFLAGS -O -Wno-deprecated "
+ CXXFLAGS="$CXXFLAGS -O -Wuninitialized "
fi
])
if test "X$enable_debug" = "Xyes"; then
CFLAGS="$CFLAGS -g -D_DEBUG_ "
- CXXFLAGS="$CXXFLAGS -g -D_DEBUG_ -Wno-deprecated "
+ CXXFLAGS="$CXXFLAGS -g -D_DEBUG_ "
fi
])
# C++
CXX = @CXX@
-CXXFLAGS = @CXXFLAGS@
+CXXFLAGS = @CXXFLAGS@
CXX_DEPEND_FLAG = @CXX_DEPEND_FLAG@
# BOOST Library
# PYQT
PYQT_SIPS = @PYQT_SIPS@
PYQT_LIBS = @PYQT_LIBS@
+PYQT_INCLUDES = @PYQT_INCLUDES@
+PYUIC = @PYUIC@
# openGL
OGL_INCLUDES=@OGL_INCLUDES@
# copy python scripts in $(top_builddir)/bin/salome
#
+
+UI_FILES = $(notdir $(wildcard $(srcdir)/*.ui))
+UI_PY_FILES_PY = $(patsubst %.ui, %.py, $(UI_FILES))
+UI_PY_FILES = $(filter-out $(EXPORT_PYSCRIPTS) ,$(UI_PY_FILES_PY))
+
DEST_PYSCRIPTS = $(EXPORT_PYSCRIPTS:%=$(top_builddir)/bin/salome/%)
-pyscripts: $(DEST_PYSCRIPTS)
+DEST_UI_PY_FILES = $(UI_PY_FILES:%=$(top_builddir)/bin/salome/%)
+pyscripts: $(DEST_PYSCRIPTS) $(UI_PY_FILES) $(DEST_UI_PY_FILES)
$(DEST_PYSCRIPTS): $(top_builddir)/bin/salome/%: %
cp -f $< $@
+# generate generic python scripts from *.ui files
+#
+$(UI_PY_FILES): %.py: %.ui
+ $(PYUIC) $< -o $@
+
+# copy ui-generated python scripts in $(top_builddir)/bin
+#
+$(DEST_UI_PY_FILES): $(top_builddir)/bin/salome/%: %
+ cp -f $< $@
+
# copy pyqt files in $(PYTHON_SHARED_SITE)
#
PYTHON_SHARED_SITE=$(top_builddir)/lib/python$(PYTHON_VERSION)/site-packages/salome/shared_modules
done
# Install python script in $(bindir)
-install-python: $(bindir) $(EXPORT_PYSCRIPTS:%=install-%)
+install-python: $(bindir) $(EXPORT_PYSCRIPTS:%=install-%) $(UI_PY_FILES:%=install-%)
+
+$(UI_PY_FILES:%=install-%): install-%: %
+ $(INSTALL_PROGRAM) $< $(bindir)/.
$(EXPORT_PYSCRIPTS:%=install-%): install-%: %
$(INSTALL_PROGRAM) $< $(bindir)/.
fi; \
done
+# Uninstall python script in $(bindir)
+ @for f in X $(UI_PY_FILES); do \
+ if test $$f != X; then \
+ $(LT_UNINSTALL) $(bindir)/$$f ; \
+ fi; \
+ done
+
# Uninstall pyqt script in $(sharedpydir)
@for f in X $(EXPORT_SHAREDPYSCRIPTS); do \
if test $$f != X; then \
// Get the PID of the Container
long Engines_Container_i::getPID() {
- return(_pid);
+ return (long)getpid();
}
// Get the hostName of the Container
# Executables targets
BIN = SALOME_Container
-BIN_SRC =
+BIN_SRC = SALOME_Container_SignalsHandler.cxx
BIN_SERVER_IDL = SALOME_Component.idl
-CPPFLAGS+= $(PYTHON_INCLUDES)
+CPPFLAGS+= $(PYTHON_INCLUDES) $(OCC_INCLUDES)
+CXXFLAGS+=$(OCC_CXXFLAGS)
LDFLAGS+= -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification -lSALOMELocalTrace
-LIBS += -Xlinker -export-dynamic $(PYTHON_LIBS)
+LIBS += -Xlinker -export-dynamic $(PYTHON_LIBS) -lCASCatch
@CONCLUDE@
long CpuUsed_impl() ;
protected:
- string _instanceName ;
- string _interfaceName ;
- string _serviceName ;
- string _graphName ;
- string _nodeName ;
+ std::string _instanceName ;
+ std::string _interfaceName ;
+ std::string _serviceName ;
+ std::string _graphName ;
+ std::string _nodeName ;
CORBA::ORB_ptr _orb;
PortableServer::POA_ptr _poa;
PortableServer::ObjectId * _id;
Engines_Component_i * _thisObj ;
RegistryConnexion *_myConnexionToRegistry;
NOTIFICATION_Supplier* _notifSupplier;
- map<std::string,CORBA::Any>_fieldsDict;
+ std::map<std::string,CORBA::Any>_fieldsDict;
private:
pthread_t _ThreadId ;
// Module : SALOME
// $Header$
+#include <iostream>
+#include <string>
#include <stdio.h>
#include "Utils_ORB_INIT.hxx"
#include "Utils_SINGLETON.hxx"
#include "SALOME_NamingService.hxx"
#include "SALOME_Container_i.hxx"
-#include <iostream>
-#include <string>
#include "utilities.h"
-#include "Utils_CatchSignals.h"
-using namespace std;
#ifdef CHECKTIME
#include <Utils_Timer.hxx>
#include <Python.h>
-static PyMethodDef MethodPyVoidMethod[] =
- {
- { NULL, NULL }
- };
+extern "C" void HandleServerSideSignals(CORBA::ORB_ptr theORB);
+
+using namespace std;
+
+static PyMethodDef MethodPyVoidMethod[] = {{ NULL, NULL }};
int main(int argc, char* argv[])
{
INFOS_COMPILATION;
- BEGIN_OF(argv[0])
-
- Py_Initialize() ;
+ BEGIN_OF(argv[0]);
+
+ Py_Initialize() ;
PySys_SetArgv( argc , argv ) ;
Py_InitModule( "InitPyRunMethod" , MethodPyVoidMethod ) ;
-
- try
- {
-
- // Initialise the ORB.
- ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
- ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
- CORBA::ORB_var &orb = init( argc , argv ) ;
-
- // Obtain a reference to the root POA.
- // obtain the root poa manager
- //
- long TIMESleep = 250000000;
- int NumberOfTries = 40;
- int a;
- timespec ts_req;
- ts_req.tv_nsec=TIMESleep;
- ts_req.tv_sec=0;
- timespec ts_rem;
- ts_rem.tv_nsec=0;
- ts_rem.tv_sec=0;
- CosNaming::NamingContext_var inc;
- PortableServer::POA_var root_poa;
- CORBA::Object_var theObj;
- CORBA::Object_var obj;
- CORBA::Object_var object;
- SALOME_NamingService &naming = *SINGLETON_<SALOME_NamingService>::Instance() ;
- int CONTAINER=0;
- const char * Env = getenv("USE_LOGGER");
- int EnvL =0;
- if ((Env!=NULL) && (strlen(Env)))
- EnvL=1;
-
- CosNaming::Name name;
- name.length(1);
- name[0].id=CORBA::string_dup("Logger");
- PortableServer::POAManager_var pman;
- for (int i = 1; i<=NumberOfTries; i++)
- {
- if (i!=1)
- a=nanosleep(&ts_req,&ts_rem);
- try
- {
- obj = orb->resolve_initial_references("RootPOA");
- if(!CORBA::is_nil(obj))
- root_poa = PortableServer::POA::_narrow(obj);
- if(!CORBA::is_nil(root_poa))
- pman = root_poa->the_POAManager();
- if(!CORBA::is_nil(orb))
- theObj = orb->resolve_initial_references("NameService");
- if (!CORBA::is_nil(theObj))
- inc = CosNaming::NamingContext::_narrow(theObj);
- }
- catch( CORBA::COMM_FAILURE& )
- {
- MESSAGE( "Container: CORBA::COMM_FAILURE: Unable to contact the Naming Service" );
+
+ try{
+ // Initialise the ORB.
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
+ CORBA::ORB_var &orb = init( argc , argv ) ;
+
+ // Obtain a reference to the root POA.
+ // obtain the root poa manager
+ //
+ long TIMESleep = 250000000;
+ int NumberOfTries = 40;
+ int a;
+ timespec ts_req;
+ ts_req.tv_nsec=TIMESleep;
+ ts_req.tv_sec=0;
+ timespec ts_rem;
+ ts_rem.tv_nsec=0;
+ ts_rem.tv_sec=0;
+ CosNaming::NamingContext_var inc;
+ PortableServer::POA_var root_poa;
+ CORBA::Object_var theObj;
+ CORBA::Object_var obj;
+ CORBA::Object_var object;
+ SALOME_NamingService &naming = *SINGLETON_<SALOME_NamingService>::Instance() ;
+ int CONTAINER=0;
+ const char * Env = getenv("USE_LOGGER");
+ int EnvL =0;
+ if(Env != NULL && strlen(Env))
+ EnvL=1;
+
+ CosNaming::Name name;
+ name.length(1);
+ name[0].id=CORBA::string_dup("Logger");
+ PortableServer::POAManager_var pman;
+ for(int i = 1; i <= NumberOfTries; i++){
+ if(i != 1)
+ a=nanosleep(&ts_req,&ts_rem);
+ try{
+ obj = orb->resolve_initial_references("RootPOA");
+ if(!CORBA::is_nil(obj))
+ root_poa = PortableServer::POA::_narrow(obj);
+ if(!CORBA::is_nil(root_poa))
+ pman = root_poa->the_POAManager();
+ if(!CORBA::is_nil(orb))
+ theObj = orb->resolve_initial_references("NameService");
+ if (!CORBA::is_nil(theObj))
+ inc = CosNaming::NamingContext::_narrow(theObj);
+ }catch(CORBA::COMM_FAILURE&){
+ MESSAGE( "Container: CORBA::COMM_FAILURE: Unable to contact the Naming Service" );
+ }
+ if(!CORBA::is_nil(inc)){
+ MESSAGE( "Container: Naming Service was found" );
+ if(EnvL == 1){
+ for(int j = 1; j <= NumberOfTries; j++){
+ if(j != 1)
+ a=nanosleep(&ts_req, &ts_rem);
+ try{
+ object = inc->resolve(name);
+ }catch(CosNaming::NamingContext::NotFound){
+ MESSAGE( "Container: Logger Server wasn't found" );
+ }catch(...){
+ MESSAGE( "Container: Unknown exception" );
}
- if(!CORBA::is_nil(inc))
- {
- MESSAGE( "Container: Naming Service was found" );
- if(EnvL==1)
- {
- for(int j=1; j<=NumberOfTries; j++)
- {
- if (j!=1)
- a=nanosleep(&ts_req, &ts_rem);
- try
- {
- object = inc->resolve(name);
- }
- catch(CosNaming::NamingContext::NotFound)
- {
- MESSAGE( "Container: Logger Server wasn't found" );
- }
- catch(...)
- {
- MESSAGE( "Container: Unknown exception" );
- }
- if (!CORBA::is_nil(object))
- {
- MESSAGE( "Container: Logger Server was found" );
- CONTAINER=1;
- break;
- }
- }
- }
+ if(!CORBA::is_nil(object)){
+ MESSAGE( "Container: Logger Server was found" );
+ CONTAINER = 1;
+ break;
}
- if ((CONTAINER==1)||((EnvL==0)&&(!CORBA::is_nil(inc))))
- break;
- }
-
- // define policy objects
- PortableServer::ImplicitActivationPolicy_var implicitActivation =
- root_poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION) ;
-
- // default = NO_IMPLICIT_ACTIVATION
- PortableServer::ThreadPolicy_var threadPolicy =
- root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL) ;
- // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL
-
- // create policy list
- CORBA::PolicyList policyList;
- policyList.length(2);
- policyList[0] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitActivation) ;
- policyList[1] = PortableServer::ThreadPolicy::_duplicate(threadPolicy) ;
-
- // create the child POA
- PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil() ;
- PortableServer::POA_var factory_poa =
- root_poa->create_POA("factory_poa", pman, policyList) ;
- //with nil_mgr instead of pman, a new POA manager is created with the new POA
-
- // destroy policy objects
- implicitActivation->destroy() ;
- threadPolicy->destroy() ;
-
- char *containerName = "";
- if (argc >1)
- {
- containerName = argv[1] ;
+ }
}
+ }
+ if(CONTAINER == 1 || (EnvL == 0 && !CORBA::is_nil(inc)))
+ break;
+ }
- Engines_Container_i * myContainer
- = new Engines_Container_i(orb, factory_poa, containerName , argc , argv );
-
- // Engines_Container_i * myContainer
- // = new Engines_Container_i(string(argv[1]),string(argv[2]), orb, factory_poa);
-
- // use naming service
- // myContainer->_NS.init_orb(orb);
- // Engines::Container_ptr pCont = Engines::Container::_narrow(myContainer->_this());
- // myContainer->_NS.Register(pCont, argv[2]);
+ // define policy objects
+ PortableServer::ImplicitActivationPolicy_var implicitActivation =
+ root_poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION) ;
+
+ // default = NO_IMPLICIT_ACTIVATION
+ PortableServer::ThreadPolicy_var threadPolicy =
+ root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL);
+ // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL
+
+ // create policy list
+ CORBA::PolicyList policyList;
+ policyList.length(2);
+ policyList[0] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitActivation) ;
+ policyList[1] = PortableServer::ThreadPolicy::_duplicate(threadPolicy) ;
+
+ // create the child POA
+ PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil() ;
+ PortableServer::POA_var factory_poa =
+ root_poa->create_POA("factory_poa", pman, policyList) ;
+ //with nil_mgr instead of pman, a new POA manager is created with the new POA
+
+ // destroy policy objects
+ implicitActivation->destroy() ;
+ threadPolicy->destroy() ;
+
+ char *containerName = "";
+ if(argc > 1){
+ containerName = argv[1] ;
+ }
+
+ Engines_Container_i * myContainer
+ = new Engines_Container_i(orb, factory_poa, containerName , argc , argv );
+
+ // Engines_Container_i * myContainer
+ // = new Engines_Container_i(string(argv[1]),string(argv[2]), orb, factory_poa);
+
+ // use naming service
+ // myContainer->_NS.init_orb(orb);
+ // Engines::Container_ptr pCont = Engines::Container::_narrow(myContainer->_this());
+ // myContainer->_NS.Register(pCont, argv[2]);
+
+ pman->activate();
- pman->activate();
-
#ifdef CHECKTIME
- Utils_Timer timer;
- timer.Start();
- timer.Stop();
- MESSAGE("SALOME_Registry_Server.cxx - orb->run()");
- timer.ShowAbsolute();
+ Utils_Timer timer;
+ timer.Start();
+ timer.Stop();
+ MESSAGE("SALOME_Registry_Server.cxx - orb->run()");
+ timer.ShowAbsolute();
#endif
- Utils_CatchSignals aCatch;
- aCatch.Activate();
-
- orb->run();
-
- aCatch.Deactivate();
- orb->destroy();
- }
- catch(CORBA::SystemException&)
- {
- INFOS("Caught CORBA::SystemException.")
- }
- catch(PortableServer::POA::WrongPolicy&)
- {
- INFOS("Caught CORBA::WrongPolicyException.")
- }
- catch(PortableServer::POA::ServantAlreadyActive&)
- {
- INFOS("Caught CORBA::ServantAlreadyActiveException")
- }
- catch(CORBA::Exception&)
- {
- INFOS("Caught CORBA::Exception.")
- }
- catch(...)
- {
- INFOS("Caught unknown exception.")
- }
+
+ HandleServerSideSignals(orb);
+
+ orb->destroy();
+ }catch(CORBA::SystemException&){
+ INFOS("Caught CORBA::SystemException.");
+ }catch(PortableServer::POA::WrongPolicy&){
+ INFOS("Caught CORBA::WrongPolicyException.");
+ }catch(PortableServer::POA::ServantAlreadyActive&){
+ INFOS("Caught CORBA::ServantAlreadyActiveException");
+ }catch(CORBA::Exception&){
+ INFOS("Caught CORBA::Exception.");
+ }catch(std::exception& exc){
+ INFOS("Caught std::exception - "<<exc.what());
+ }catch(...){
+ INFOS("Caught unknown exception.");
+ }
END_OF(argv[0]);
}
#ifndef _SALOME_CONTAINER_I_HXX_
#define _SALOME_CONTAINER_I_HXX_
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOME_Component)
+
#include <iostream>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SALOME_Component)
#include <omnithread.h>
#include <map>
#include <string>
class SALOME_NamingService;
-class Engines_Container_i: public POA_Engines::Container,
- public PortableServer::RefCountServantBase
+class Engines_Container_i: public virtual POA_Engines::Container,
+ public virtual PortableServer::RefCountServantBase
{
public:
Engines_Container_i();
// Module : SALOME
// $Header$
-using namespace std;
-#define WRITE_CATA_DATA_TYPE
#include "SALOME_DataTypeCatalog_Handler.hxx"
+#include "utilities.h"
+
+using namespace std;
+
+// contains all the data types defined in the catalog
+ListOfParserDataType _datatypelist;
+
//----------------------------------------------------------------------
// Function : SALOME_DataTypeCatalog_Handler
// Purpose : Constructor
#ifndef SALOME_DATA_CATALOG_HANDLER_H
#define SALOME_DATA_CATALOG_HANDLER_H
-#include "utilities.h"
#include "SALOME_DataTypeCatalog_Parser.hxx"
#include <qxml.h>
#include <string>
private:
QString errorProt ;
- string content;
+ std::string content;
const char* test_data_type_name ;
const char* test_data_type_interf_read ;
#include <vector>
// Type Definitions
-typedef vector<string> ListOfParserDataTypeName;
+typedef std::vector<std::string> ListOfParserDataTypeName;
struct ParserDataType{
- string Parserdata_name ;
- string Parserdata_interface_read;
- string Parserdata_interface_write;
+ std::string Parserdata_name ;
+ std::string Parserdata_interface_read;
+ std::string Parserdata_interface_write;
ListOfParserDataTypeName Parserdata_parents ;
};
-typedef vector<ParserDataType> ListOfParserDataType;
+typedef std::vector<ParserDataType> ListOfParserDataType;
-#ifdef WRITE_CATA_DATA_TYPE
// contains all the data types defined in the catalog
-ListOfParserDataType _datatypelist;
-#else
extern ListOfParserDataType _datatypelist;
-#endif
+
#endif // SALOME_DATA_CATALOG_PARSER_H
#include <qsemaphore.h>
#include <qapplication.h>
#include <qthread.h>
+#include <pthread.h>
#ifdef _DEBUG_
static int MYDEBUG = 0;
static int MYDEBUG = 0;
#endif
+
+static pthread_t myThread;
+
+void SALOME_Event::GetSessionThread(){
+ myThread = pthread_self();
+}
+
+bool SALOME_Event::IsSessionThread(){
+ bool aResult = myThread == pthread_self();
+ if(MYDEBUG) INFOS("IsSessionThread() - "<<aResult);
+ return aResult;
+}
+
+
//===========================================================
/*!
* SALOME_Event::SALOME_Event
* Constructor
*/
//===========================================================
-SALOME_Event::SALOME_Event():
- myWait( true ),
- myAutoRelease( false )
-{
- if(MYDEBUG) MESSAGE( "SALOME_Event::SALOME_Event(): this = "<<this<<", myWait = "<<myWait );
- if ( myWait ) {
- // Prepare the semaphore
- mySemaphore = new QSemaphore( 2 );
- mySemaphore->operator+=( 2 );
- }
+SALOME_Event::SALOME_Event(){
+ if(MYDEBUG) MESSAGE( "SALOME_Event::SALOME_Event(): this = "<<this );
+ // Prepare the semaphore
+ mySemaphore = new QSemaphore( 2 );
+ *mySemaphore += 2;
}
//===========================================================
* Destructor
*/
//===========================================================
-SALOME_Event::~SALOME_Event()
-{
- if(MYDEBUG) MESSAGE( "SALOME_Event::~SALOME_Event(): this = "<<this<<", myWait = "<<myWait );
- if ( myWait ) {
- if ( mySemaphore->available() < mySemaphore->total() )
- mySemaphore->operator-=( mySemaphore->total() - mySemaphore->available() );
- delete mySemaphore;
- }
+SALOME_Event::~SALOME_Event(){
+ if(MYDEBUG) MESSAGE( "SALOME_Event::~SALOME_Event(): this = "<<this );
+ if ( mySemaphore->available() < mySemaphore->total() )
+ *mySemaphore -= mySemaphore->total() - mySemaphore->available();
+ delete mySemaphore;
}
//===========================================================
//===========================================================
void SALOME_Event::process()
{
- if(MYDEBUG) MESSAGE( "SALOME_Event::process(): this = "<<this<<", myWait = "<<myWait );
QThread::postEvent( qApp, new QCustomEvent( SALOME_EVENT, (void*)this ) );
- if ( myWait ) {
- if(MYDEBUG) MESSAGE( "SALOME_Event::process(): available = " << mySemaphore->available() );
- if ( !mySemaphore->available() )
- mySemaphore->operator+=( 1 );
-
- if(MYDEBUG) MESSAGE( "SALOME_Event::process() COMPLETED: this = "<<this<<", myWait = "<<myWait );
- }
- if ( myAutoRelease )
- release();
+ if(MYDEBUG) MESSAGE( "SALOME_Event::process(): this = "<<this<<", *mySemaphore += 1 " );
+ *mySemaphore += 1;
+ if(MYDEBUG) MESSAGE( "SALOME_Event::process(): this = "<<this<<" - COMPLETED" );
}
//===========================================================
//===========================================================
void SALOME_Event::processed()
{
- if(MYDEBUG) MESSAGE( "SALOME_Event::processed(): this = "<<this<<", myWait = "<<myWait );
- if ( myWait ) {
- if(MYDEBUG) MESSAGE( "SALOME_Event::processed(): available = " << mySemaphore->available() );
- if ( !mySemaphore->available() ) {
- // process() takes control over mySemaphore after the next line is executed
- mySemaphore->operator-=( 1 );
-
- if(MYDEBUG) MESSAGE( "SALOME_Event::processed(): semaphore DECREMENTED" );
-
- // Current thread will block here until process() completes
- mySemaphore->operator+=( mySemaphore->total() );
- }
- }
- if(MYDEBUG) MESSAGE( "SALOME_Event::processed() COMPLETED: this = "<<this<<", myWait = "<<myWait );
+ if(MYDEBUG) MESSAGE( "SALOME_Event::processed(): this = "<<this );
+ // process() takes control over mySemaphore after the next line is executed
+ *mySemaphore -= 1;
}
-
-//===========================================================
-/*!
- * SALOME_Event::release
- * Wakes up the desktop
- */
-//===========================================================
-void SALOME_Event::release()
-{
- if(MYDEBUG) MESSAGE( "SALOME_Event::release(): this = "<<this<<", myWait = "<<myWait );
- if ( myWait ) {
- if(MYDEBUG) MESSAGE( "SALOME_Event::release(): available = " << mySemaphore->available() );
- mySemaphore->operator-=( mySemaphore->total() - mySemaphore->available() );
- }
- if(MYDEBUG) MESSAGE( "SALOME_Event::release() COMPLETED: this = "<<this<<", myWait = "<<myWait );
-}
-
-
-
-
* no need to protect such fields with a mutex, for only one thread working with
* a SALOME_Event object is active at any moment.
*
- * It is possible to make the thread that creates SALOME_Event
- * wait until the event is processed by the component GUI, SALOME_Event
- * should be constructed with <wait> == TRUE in such a case.
- *
- * SALOME_Event objects should be created on the heap. QAD_Desktop deletes
- * these objects as soon as they have been processed.
- *
* Usage:
- * - create SALOME_Event object on the heap with proper <type> and <wait> parameters.
+ * - create SALOME_Event.
* Components can derive their own event class from SALOME_Event
* in order to pass custom data to the event handler.
- * - call process() method to post the event. Between process() and release()
+ * - call process() method to post the event. After process() execution
* it is possible to examine fields of your custom event object.
- * - call release() method to wake up the desktop (you can also set <autoRelease>
+ * - perform delete operator on the event to wake up the desktop (you can also set <autoRelease>
* parameter to TRUE to automatically wake up desktop after process()
*
* processed() method is used by the desktop to signal that event processing
* has been completed.
*
* Caveats:
- * 1. Never create SALOME_Event with <wait> == TRUE in code that is
- * supposed to be called within main GUI thread, for this will result
- * in GUI process deadlock.
- * 2. Always call release() method after process() if you use <wait> parameters as TRUE,
- * otherwise processed() method will never return and main GUI thread will be blocked!
- * 3. Never use pointers to the event after it has been released (either by calling release()
- * or automatically by process() if <autoRelease> == TRUE) to avoid application crashes!
+ * There is no.
*/
//===========================================================
-class SALOME_Event
-{
+class SALOME_Event{
public:
SALOME_Event();
virtual ~SALOME_Event();
// To do real work
virtual void Execute() = 0;
+ static bool IsSessionThread();
void process();
+
+protected:
void processed();
+ friend class QAD_Desktop;
- void release();
+ static void GetSessionThread();
+ friend int main(int, char **);
private:
- bool myWait;
- bool myAutoRelease;
QSemaphore* mySemaphore;
};
// Template function for processing events with result returing
template<class TEvent> inline typename TEvent::TResult ProcessEvent(TEvent* theEvent){
- theEvent->process();
- typename TEvent::TResult aResult = theEvent->myResult;
- theEvent->release();
+ typename TEvent::TResult aResult;
+ if(SALOME_Event::IsSessionThread()){
+ theEvent->Execute();
+ aResult = theEvent->myResult;
+ }else{
+ theEvent->process();
+ aResult = theEvent->myResult;
+ }
+ delete theEvent;
return aResult;
}
// Template function for processing events without result
inline void ProcessVoidEvent(SALOME_Event* theEvent){
- theEvent->process();
- theEvent->release();
+ if(SALOME_Event::IsSessionThread()){
+ theEvent->Execute();
+ }else{
+ theEvent->process();
+ }
+ delete theEvent;
}
#include "SALOME_GenericObj_i.hh"
#include "utilities.h"
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
using namespace SALOME;
+using namespace std;
GenericObj_i::GenericObj_i(PortableServer::POA_ptr thePOA): myRefCounter(1){
- MESSAGE("GenericObj_i::GenericObj_i() - this = "<<this<<
- "; CORBA::is_nil(thePOA) = "<<CORBA::is_nil(thePOA));
+ if(MYDEBUG)
+ 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();
else
PortableServer::POA_ptr GenericObj_i::_default_POA(){
- //return PortableServer::RefCountServantBase::_default_POA();
return PortableServer::POA::_duplicate(myPOA);
}
void GenericObj_i::Register(){
- MESSAGE("GenericObj_i::Register "<<this<<"; myRefCounter = "<<myRefCounter)
+ if(MYDEBUG)
+ MESSAGE("GenericObj_i::Register "<<this<<"; myRefCounter = "<<myRefCounter)
++myRefCounter;
}
void GenericObj_i::Destroy(){
- MESSAGE("GenericObj_i::Destroy "<<this<<"; myRefCounter = "<<myRefCounter)
+ if(MYDEBUG)
+ MESSAGE("GenericObj_i::Destroy "<<this<<"; myRefCounter = "<<myRefCounter)
if(--myRefCounter <= 0){
PortableServer::ObjectId_var anObjectId = myPOA->servant_to_id(this);
myPOA->deactivate_object(anObjectId.in());
return -1;
};
+
+ return length;
};
#include "HDFfile.hxx"
#include <string>
-using namespace std;
class HDFConvert
{
public:
-static int FromAscii(const string& file, const HDFcontainerObject& hdf_container, const string& nomdataset);
+static int FromAscii(const std::string& file, const HDFcontainerObject& hdf_container, const std::string& nomdataset);
};
/* Exception */
#include <iostream>
-using namespace std;
class HDFexception
{
public :
HDFexception(const char *message) {
- cerr << message << endl;
+ std::cerr << message << std::endl;
}
};
int InquireServersGUI::getExitStatus()
{
- myThread->getExitStatus();
+ return myThread->getExitStatus();
}
InquireServersQThread::InquireServersQThread( InquireServersGUI* r )
#if !defined(AFX_LOGGER_H__96F2A3AB_F6F8_11D6_BFA6_000476A0958C__INCLUDED_)
#define AFX_LOGGER_H__96F2A3AB_F6F8_11D6_BFA6_000476A0958C__INCLUDED_
+#include <strstream.h>
+#include "Logger.hh"
+
//these declarations for files don't using OCC includes (for example HDF)
# ifdef WNT
# endif /* WNT */
-using namespace std;
-
-#include <strstream.h>
-#include "Logger.hh"
-
-class SALOME_Trace : public ostrstream
+class SALOME_Trace : public std::ostrstream
{
public:
virtual ~SALOME_Trace();
TWrapper aMedW(aFileName);
int aNbMeshes = aMed.GetNbMeshes();
- cout<<"GetNbMeshes() = "<<aNbMeshes<<endl;
+ MESSAGE("GetNbMeshes() = "<<aNbMeshes);
string aName;
for(int iMesh = 0; iMesh < aNbMeshes; iMesh++){
aMed.GetMeshInfo(iMesh+1,*aMeshInfo);
int aDim = aMeshInfo->myDim;
aName = aMeshInfo->GetName();
- cout<<"GetMeshInfo - aName = '"<<aName<<"'; aDim = "<<aDim<<endl;
+ MESSAGE("GetMeshInfo - aName = '"<<aName<<"'; aDim = "<<aDim);
*aNewMeshInfo = *aMeshInfo;
aName[0] += 1;
aNewMeshInfo->SetName(aName);
TEntityInfo aEntityInfo = aMed.GetEntityInfo(*aMeshInfo);
med_int aNbFields = aMed.GetNbFields();
- cout<<"GetNbFields() = "<<aNbFields<<endl;
+ MESSAGE("GetNbFields() = "<<aNbFields);
for(int iField = 0; iField < aNbFields; iField++){
med_int aNbComp = aMed.GetNbComp(iField+1);
PFieldInfo aFieldInfo(new TFieldInfo(aMeshInfo,aNbComp));
aMed.GetFieldInfo(iField+1,*aFieldInfo);
- cout<<"\taName = '"<<aFieldInfo->GetName()<<"'; aNbComp = "<<aNbComp<<"; ";
+ MESSAGE("\taName = '"<<aFieldInfo->GetName()<<"'; aNbComp = "<<aNbComp<<"; ");
aMedW.SetFieldInfo(*aFieldInfo);
med_entite_maillage anEntity;
TGeom aTGeom;
med_int aNbTimeStamps = aMed.GetNbTimeStamps(*aFieldInfo,aEntityInfo,
anEntity,aTGeom);
- cout<<"GetNbTimeStamps = "<<aNbTimeStamps<<endl;
+ MESSAGE("GetNbTimeStamps = "<<aNbTimeStamps);
PTimeStampInfo aTimeStampInfo(new TTimeStampInfo(aFieldInfo,anEntity,aTGeom));
for(int iTimeStamp = 0; iTimeStamp < aNbTimeStamps; iTimeStamp++){
aMed.GetTimeStampInfo(iTimeStamp+1, *aTimeStampInfo);
for(; aMeshValueIter != aMeshValue.end(); aMeshValueIter++){
med_geometrie_element aGeom = aMeshValueIter->first;
TValue aValue = aMeshValueIter->second;
- cout<<"\t\taGeom = "<<aGeom<<"; aValue = "<<aValue.size()<<": ";
+ MESSAGE("\t\taGeom = "<<aGeom<<"; aValue = "<<aValue.size()<<": ");
for(int i = 0, iEnd = aValue.size()/aNbComp; i < iEnd; i++){
for(int j = 0, ij = i*aNbComp; j < aNbComp; j++, ij++){
- //cout<<aValue[ij]<<",";
+ //MESSAGE(aValue[ij]<<",");
}
- //cout<<" ";
+ //MESSAGE(" ");
}
- cout<<"\n";
+ MESSAGE("\n");
}
}
}
int aNbFam = aMed.GetNbFamilies(*aMeshInfo);
- cout<<"GetNbFamilies() = "<<aNbFam<<endl;
+ MESSAGE("GetNbFamilies() = "<<aNbFam);
for(int iFam = 0; iFam < aNbFam; iFam++){
int aNbAttr = aMed.GetNbFamAttr(iFam+1,*aMeshInfo);
int aNbGroup = aMed.GetNbFamGroup(iFam+1,*aMeshInfo);
PFamilyInfo aFamilyInfo(new TFamilyInfo(aMeshInfo,aNbGroup,aNbAttr));
aMed.GetFamilyInfo(iFam+1,*aFamilyInfo);
aName = aFamilyInfo->GetName();
- cout<<"\taName = '"<<aName<<"'; aNbAttr = "<<aNbAttr<<"; aNbGroup = "<<aNbGroup<<endl;
+ MESSAGE("\taName = '"<<aName<<"'; aNbAttr = "<<aNbAttr<<"; aNbGroup = "<<aNbGroup);
aName[0] += 1;
aFamilyInfo->SetName(aName);
aFamilyInfo->myMeshInfo = aNewMeshInfo;
aName = aFamilyInfo->GetName();
for(int iGroup = 0; iGroup < aNbGroup; iGroup++){
aName = aFamilyInfo->GetGroupName(iGroup);
- cout<<"\t\taGroupName = '"<<aName<<"'\n";
+ MESSAGE("\t\taGroupName = '"<<aName<<"'");
aName[0] += 1;
aFamilyInfo->SetGroupName(iGroup,aName);
}
aMedW.SetFamilyInfo(*aFamilyInfo);
}
- cout<<"GetEntityInfo - aNbEntities = "<<aEntityInfo.size()<<endl;
+ MESSAGE("GetEntityInfo - aNbEntities = "<<aEntityInfo.size());
TEntityInfo::iterator anEntityInfoIter = aEntityInfo.begin();
for(; anEntityInfoIter != aEntityInfo.end(); anEntityInfoIter++){
const med_entite_maillage& anEntity = anEntityInfoIter->first;
- cout<<"\tanEntity = "<<anEntity<<endl;
+ MESSAGE("\tanEntity = "<<anEntity);
if(anEntity == MED_NOEUD){
int aNbNodes = aMed.GetNbNodes(*aMeshInfo);
PNodeInfo aNodeInfo(new TNodeInfo(aMeshInfo,aNbNodes));
aMed.GetNodeInfo(*aNodeInfo);
- cout<<"\tGetNodeInfo - aNbNodes = "<<aNbNodes<<": ";
+ MESSAGE("\tGetNodeInfo - aNbNodes = "<<aNbNodes<<": ");
TNodeCoord& aCoord = aNodeInfo->myCoord;
for(int iNode = 0; iNode < aNbNodes; iNode++){
for(int iDim = 0, anId = iNode*aDim; iDim < aDim; iDim++, anId++){
- //cout<<aCoord[anId]<<",";
+ //MESSAGE(aCoord[anId]<<",");
aCoord[anId] += 1.0;
}
- //cout<<" ";
+ //MESSAGE(" ");
}
- cout<<endl;
+ MESSAGE(endl);
aNodeInfo->myMeshInfo = aNewMeshInfo;
aMedW.SetNodeInfo(*aNodeInfo);
continue;
for(; anTGeomIter != aTGeom.end(); anTGeomIter++){
const med_geometrie_element& aGeom = anTGeomIter->first;
med_int& aNbElem = anTGeomIter->second;
- cout<<"\t\taGeom = "<<aGeom<<"; aNbElem = "<<aNbElem<<": ";
+ MESSAGE("\t\taGeom = "<<aGeom<<"; aNbElem = "<<aNbElem<<": ");
PCellInfo aCellInfo(new TCellInfo(aMeshInfo,aNbElem,anEntity,aGeom));
aMed.GetCellInfo(*aCellInfo);
for(int iElem = 0; iElem < aCellInfo->myNbElem; iElem++){
int i = iElem*aCellInfo->myConnDim;
for(int iConn = 0; iConn < aCellInfo->myConnDim; iConn++, i++){
- //cout<<aCellInfo->myConn[i]<<",";
+ //MESSAGE(aCellInfo->myConn[i]<<",");
}
- //cout<<" ";
+ //MESSAGE(" ");
}
- cout<<endl;
+ MESSAGE(endl);
aCellInfo->myMeshInfo = aNewMeshInfo;
aMedW.SetCellInfo(*aCellInfo);
}
}
}
- cout<<"OK"<<endl;
+ MESSAGE("OK");
}
ReadMed(argv[1]);
return 0;
}catch(std::exception& exc){
- cout<<"Follow exception was accured :\n"<<exc.what()<<endl;
+ MESSAGE("Follow exception was accured :\n"<<exc.what());
}catch(...){
- cout<<"Unknown exception was accured in VISU_Convertor_impl"<<endl;
+ MESSAGE("Unknown exception was accured in VISU_Convertor_impl");
}
return 1;
}
-// SALOME MSG2QM : duplication of Qt tool
-//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : msg2qm.cxx
-// Module : SALOME
+/////////////////////////////////////////////////////////////////////////////
+// Module : MSG2QM
+// File : msg2qm.cxx
+// Description : This is a duplication of Qt tool for resources compiling
+/////////////////////////////////////////////////////////////////////////////
-using namespace std;
/****************************************************************************
** $Id$
**
** Copyright (C) 1998 by Trolltech AS. All rights reserved.
**
*****************************************************************************/
+
+using namespace std;
#include <qfile.h>
#include <qtextstream.h>
#include <qtextcodec.h>
pos++;
pos++;
while ( pos < int(line.length()) && line[pos] != '\"' ) {
- if ( line[pos] == '\\') {
+ // 0xa5: the yen sign is the Japanese backslash
+ if ( line[pos] == '\\' || line[pos] == QChar(0xa5) ) {
pos++;
switch (char(line[pos]) ) {
case 'n':
@COMMENCE@
-SUBDIRS = MSG2QM SALOMELocalTrace Logger SALOMELogger Utils PatchQt \
+SUBDIRS = MSG2QM SALOMELocalTrace Logger Utils SALOMELogger CASCatch PatchQt \
GenericObj MEDWrapper NamingService Registry \
ModuleCatalog DataTypeCatalog RessourcesCatalog \
Notification NOTIFICATION_SWIG \
- Container TestContainer LifeCycleCORBA HDFPersist \
+ Container TestContainer LifeCycleCORBA HDFPersist Prs \
VTKFilter OBJECT \
TOOLSDS SALOMEDS Event \
SALOMEGUI Plot2d VTKViewer OCCViewer \
// Module : SALOME
// $Header$
-using namespace std;
#include "SALOME_ModuleCatalog_Acomponent_impl.hxx"
#include "Utils_ExceptHandlers.hxx"
UNEXPECT_CATCH(MC_NotFound, SALOME_ModuleCatalog::NotFound);
+#include "utilities.h"
+
+using namespace std;
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
//----------------------------------------------------------------------
// Function : SALOME_ModuleCatalog_AcomponentImpl
// Purpose : Constructor
SALOME_ModuleCatalog_AcomponentImpl::SALOME_ModuleCatalog_AcomponentImpl
(SALOME_ModuleCatalog::Component &C) : _Component(C)
{
- BEGIN_OF("SALOME_ModuleCatalog_AcomponentImpl");
+ if(MYDEBUG) BEGIN_OF("SALOME_ModuleCatalog_AcomponentImpl");
- END_OF("SALOME_ModuleCatalog_AcomponentImpl");
+ if(MYDEBUG) END_OF("SALOME_ModuleCatalog_AcomponentImpl");
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
SALOME_ModuleCatalog_AcomponentImpl::~SALOME_ModuleCatalog_AcomponentImpl()
{
- BEGIN_OF("~SALOME_ModuleCatalog_AcomponentImpl");
+ if(MYDEBUG) BEGIN_OF("~SALOME_ModuleCatalog_AcomponentImpl");
- END_OF("~SALOME_ModuleCatalog_AcomponentImpl");
+ if(MYDEBUG) END_OF("~SALOME_ModuleCatalog_AcomponentImpl");
}
//----------------------------------------------------------------------
SALOME_ModuleCatalog::ListOfInterfaces*
SALOME_ModuleCatalog_AcomponentImpl::GetInterfaceList()
{
- BEGIN_OF("GetInterfaceList");
+ if(MYDEBUG) BEGIN_OF("GetInterfaceList");
SALOME_ModuleCatalog::ListOfInterfaces_var _list
= new SALOME_ModuleCatalog::ListOfInterfaces;
for (unsigned int ind = 0; ind < _length_interfaces; ind++)
{
_list[ind] = CORBA::string_dup(_Component.interfaces[ind].interfacename);
- MESSAGE("The component " << _Component.name
- << " contains " << _list[ind] << " as interface");
+ if(MYDEBUG) MESSAGE("The component " << _Component.name
+ << " contains " << _list[ind] << " as interface");
}
- END_OF("GetInterfaceList");
+ if(MYDEBUG) END_OF("GetInterfaceList");
return _list._retn();
}
SALOME_ModuleCatalog_AcomponentImpl::GetInterface(const char* interfacename)
throw(SALOME_ModuleCatalog::NotFound)
{
- BEGIN_OF("GetInterface");
- SCRUTE(interfacename);
+ if(MYDEBUG) BEGIN_OF("GetInterface");
+ if(MYDEBUG) SCRUTE(interfacename);
SALOME_ModuleCatalog::DefinitionInterface *_interface =
new SALOME_ModuleCatalog::DefinitionInterface;
}
}
- SCRUTE(_find);
+ if(MYDEBUG) SCRUTE(_find);
if (!_find)
{
// The interface was not found, the exception should be thrown
message += " of the component ";
message += _Component.name;
message += " was not found";
- MESSAGE(message)
- throw SALOME_ModuleCatalog::NotFound(message.c_str());
+ if(MYDEBUG) MESSAGE(message);
+ throw SALOME_ModuleCatalog::NotFound(message.c_str());
}
- END_OF("GetInterface");
+ if(MYDEBUG) END_OF("GetInterface");
return _interface;
}
SALOME_ModuleCatalog_AcomponentImpl::GetServiceList(const char* interfacename)
throw(SALOME_ModuleCatalog::NotFound)
{
- BEGIN_OF("GetServiceList");
- SCRUTE(interfacename);
+ if(MYDEBUG) BEGIN_OF("GetServiceList");
+ if(MYDEBUG) SCRUTE(interfacename);
SALOME_ModuleCatalog::ListOfServices_var _list
= new SALOME_ModuleCatalog::ListOfServices;
for (unsigned int ind1 = 0; ind1 < _length_services ; ind1++)
{
_list[ind1] = CORBA::string_dup(I.interfaceservicelist[ind1].ServiceName);
- MESSAGE("The interface " << interfacename << " of the component "
- << _Component.name << " contains " << _list[ind1] << " as a service")
+ if(MYDEBUG) MESSAGE("The interface " << interfacename << " of the component "
+ << _Component.name << " contains " << _list[ind1] << " as a service")
}
}
}
message += " of the component ";
message += _Component.name;
message += " was not found";
- MESSAGE(message)
- throw SALOME_ModuleCatalog::NotFound(message.c_str());
+ if(MYDEBUG) MESSAGE(message);
+ throw SALOME_ModuleCatalog::NotFound(message.c_str());
}
- END_OF("GetServiceList");
+ if(MYDEBUG) END_OF("GetServiceList");
return _list._retn();
}
const char* servicename)
throw(SALOME_ModuleCatalog::NotFound)
{
- BEGIN_OF("GetService");
- SCRUTE(interfacename);
- SCRUTE(servicename);
+ if(MYDEBUG) BEGIN_OF("GetService");
+ if(MYDEBUG) SCRUTE(interfacename);
+ if(MYDEBUG) SCRUTE(servicename);
Unexpect aCatch( MC_NotFound );
SALOME_ModuleCatalog::Service *service = new SALOME_ModuleCatalog::Service;
// looking for the specified interface
for (unsigned int ind = 0; ind < _Component.interfaces.length(); ind++)
{
- SCRUTE(ind);
- SCRUTE(_Component.interfaces[ind].interfacename);
+ if(MYDEBUG) SCRUTE(ind);
+ if(MYDEBUG) SCRUTE(_Component.interfaces[ind].interfacename);
SALOME_ModuleCatalog::DefinitionInterface &I = _Component.interfaces[ind];
if (strcmp(interfacename, I.interfacename) == 0)
for (unsigned int ind1 = 0; ind1 < I.interfaceservicelist.length() ; ind1++)
{
SALOME_ModuleCatalog::Service &S = I.interfaceservicelist[ind1];
- SCRUTE(ind1);
- SCRUTE(S.ServiceName);
+ if(MYDEBUG) SCRUTE(ind1);
+ if(MYDEBUG) SCRUTE(S.ServiceName);
if (strcmp(servicename, S.ServiceName) == 0)
{
}
}
- SCRUTE(_find);
+ if(MYDEBUG) SCRUTE(_find);
if (!_find)
{
// The interface was not found, the exception should be thrown
message += " of the component ";
message += _Component.name;
message += " was not found";
- MESSAGE(message)
- throw SALOME_ModuleCatalog::NotFound(message.c_str());
+ if(MYDEBUG) MESSAGE(message);
+ throw SALOME_ModuleCatalog::NotFound(message.c_str());
}
- END_OF("GetService");
+ if(MYDEBUG) END_OF("GetService");
return service;
}
SALOME_ModuleCatalog_AcomponentImpl::GetDefaultService(const char* interfacename)
throw(SALOME_ModuleCatalog::NotFound)
{
- BEGIN_OF("GetDefaultService");
- SCRUTE(interfacename);
+ if(MYDEBUG) BEGIN_OF("GetDefaultService");
+ if(MYDEBUG) SCRUTE(interfacename);
Unexpect aCatch( MC_NotFound );
SALOME_ModuleCatalog::Service *_service = new SALOME_ModuleCatalog::Service;
message += " of the component ";
message += _Component.name;
message += " was not found";
- MESSAGE(message)
- throw SALOME_ModuleCatalog::NotFound(message.c_str());
+ if(MYDEBUG) MESSAGE(message);
+ throw SALOME_ModuleCatalog::NotFound(message.c_str());
}
- END_OF("GetDefaultService");
+ if(MYDEBUG) END_OF("GetDefaultService");
return _service;
}
SALOME_ModuleCatalog_AcomponentImpl::GetPathPrefix(const char* machinename)
throw(SALOME_ModuleCatalog::NotFound)
{
- BEGIN_OF("GetPathPrefix");
- SCRUTE(machinename);
+ if(MYDEBUG) BEGIN_OF("GetPathPrefix");
+ if(MYDEBUG) SCRUTE(machinename);
Unexpect aCatch( MC_NotFound );
// Variables initialisation
}
}
- SCRUTE(_find);
+ if(MYDEBUG) SCRUTE(_find);
if (!_find)
{
// The computer was not found, the exception should be thrown
message += machinename;
message += " was not found in the catalog associated to the component ";
message += _Component.name;
- MESSAGE(message)
+ if(MYDEBUG) MESSAGE(message);
throw SALOME_ModuleCatalog::NotFound(message.c_str());
}
- END_OF("GetPathPrefix");
+ if(MYDEBUG) END_OF("GetPathPrefix");
return _path;
}
// duplicate out DataStreamParameters
_length = S_in.ServiceoutDataStreamParameter.length();
- SCRUTE(_length);
+ if(MYDEBUG) SCRUTE(_length);
S_out.ServiceoutDataStreamParameter.length(_length);
for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
// duplicate service list
unsigned int _length = I_in.interfaceservicelist.length();
- SCRUTE(_length);
+ if(MYDEBUG) SCRUTE(_length);
I_out.interfaceservicelist.length(_length);
for (unsigned int ind1 = 0; ind1 < _length ; ind1 ++)
#ifndef ACOMPONENT_IMPL_H
#define ACOMPONENT_IMPL_H
-#include "utilities.h"
#include "SALOME_ModuleCatalog_Parser.hxx"
#include <SALOMEconfig.h>
// $Header$
#define WRITE_CATA_COMPONENT
+
#include "SALOME_ModuleCatalog_Handler.hxx"
#include "SALOME_ModuleCatalog_Parser_IO.hxx"
-using namespace std;
+#include "utilities.h"
+
#include <sstream>
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
//----------------------------------------------------------------------
// Function : SALOME_ModuleCatalog_Handler
// Purpose : Constructor
//----------------------------------------------------------------------
SALOME_ModuleCatalog_Handler::SALOME_ModuleCatalog_Handler()
{
- BEGIN_OF("SALOME_ModuleCatalog_Handler");
+ if(MYDEBUG) BEGIN_OF("SALOME_ModuleCatalog_Handler");
// XML Tags initialisation
// Used in the function endElement
test_component="component";
- END_OF("SALOME_ModuleCatalog_Handler");
+ if(MYDEBUG) END_OF("SALOME_ModuleCatalog_Handler");
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
SALOME_ModuleCatalog_Handler::~SALOME_ModuleCatalog_Handler()
{
- BEGIN_OF("~SALOME_ModuleCatalog_Handler()")
- END_OF("~SALOME_ModuleCatalog_Handler()")
+ if(MYDEBUG) BEGIN_OF("~SALOME_ModuleCatalog_Handler()")
+ if(MYDEBUG) END_OF("~SALOME_ModuleCatalog_Handler()")
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
bool SALOME_ModuleCatalog_Handler::startDocument()
{
- MESSAGE("Begin parse document")
+ if(MYDEBUG) MESSAGE("Begin parse document");
// Empty the private elements
_pathList.resize(0);
_pathPrefix.listOfComputer.resize(0);
//tag test_inParameter_name
if ((qName.compare(test_inParameter_name)==0)) {
- SCRUTE(parent);
- SCRUTE(grandparent);
+ if(MYDEBUG) SCRUTE(parent);
+ if(MYDEBUG) SCRUTE(grandparent);
if (grandparent.compare(test_inDataStreamParameter_list) == 0)
_inDataStreamParam.name = content ;
else
{
if (parent.compare(test_inParameter_list)==0) {
- MESSAGE("add inParameter : " << _inParam.name);
+ if(MYDEBUG) MESSAGE("add inParameter : " << _inParam.name);
_inParamList.push_back(_inParam) ;
// Empty temporary structures
}
else if ((qName.compare(test_inDataStreamParameter)==0)) {
- MESSAGE("add inDataStreamParameter : " << _inDataStreamParam.name);
+ if(MYDEBUG) MESSAGE("add inDataStreamParameter : " << _inDataStreamParam.name);
_inDataStreamParamList.push_back(_inDataStreamParam) ;
// Empty temporary structures
//tag test_inParameter_list
if((qName.compare(test_inParameter_list)==0))
{
- SCRUTE(_inParamList.size());
+ if(MYDEBUG) SCRUTE(_inParamList.size());
_aService.inParameters = _inParamList;
_inParamList.resize(0);
return true;
//tag test_inDataStreamParameter_list
if((qName.compare(test_inDataStreamParameter_list)==0))
{
- SCRUTE(_inDataStreamParamList.size());
+ if(MYDEBUG) SCRUTE(_inDataStreamParamList.size());
_aService.inDataStreamParameters = _inDataStreamParamList;
_inDataStreamParamList.resize(0);
}
//tag test_outDataStreamParameter_list
if((qName.compare(test_outDataStreamParameter_list)==0))
{
- SCRUTE(_outDataStreamParamList.size());
+ if(MYDEBUG) SCRUTE(_outDataStreamParamList.size());
_aService.outDataStreamParameters = _outDataStreamParamList;
_outDataStreamParamList.resize(0);
return true;
}
+
// Parameter out
- SCRUTE(qName);
+ if(MYDEBUG) SCRUTE(qName);
// tag test_outParameter_type
if ((qName.compare(test_outParameter_type)==0)) {
//tag test_outDataStreamParameter_name
if ((qName.compare(test_outDataStreamParameter_name)==0)) {
- SCRUTE(grandparent);
- SCRUTE(test_outDataStreamParameter_list);
+ if(MYDEBUG) SCRUTE(grandparent);
+ if(MYDEBUG) SCRUTE(test_outDataStreamParameter_list);
if (grandparent.compare(test_outDataStreamParameter_list) == 0)
_outDataStreamParam.name = content ;
else
{
if (parent.compare(test_outParameter_list)==0) {
- MESSAGE("add outParameter : " << _outParam.name);
+ if(MYDEBUG) MESSAGE("add outParameter : " << _outParam.name);
_outParamList.push_back(_outParam) ;
// Empty temporary structures
}
else if ((qName.compare(test_outDataStreamParameter)==0)) {
- MESSAGE("add outDataStreamParameter : " << _outDataStreamParam.name);
+ if(MYDEBUG) MESSAGE("add outDataStreamParameter : " << _outDataStreamParam.name);
_outDataStreamParamList.push_back(_outDataStreamParam) ;
// Empty temporary structures
//tag test_outParameter_list
if((qName.compare(test_outParameter_list)==0))
{
- SCRUTE(_outParamList.size());
+ if(MYDEBUG) SCRUTE(_outParamList.size());
_aService.outParameters = _outParamList;
_outParamList.resize(0);
return true;
{
// ofstream f("/tmp/logs/xxx.log", std::ofstream::app);
// f << "---------------------------------------------------------" << std::endl;
- BEGIN_OF("endDocument");
+ if(MYDEBUG) BEGIN_OF("endDocument");
//_pathlist
for (unsigned int ind = 0; ind < _pathList.size(); ind++)
{
- MESSAGE("Path :"<<_pathList[ind].path)
+ if(MYDEBUG) MESSAGE("Path :"<<_pathList[ind].path);
for (unsigned int i = 0; i < _pathList[ind].listOfComputer.size(); i++)
- MESSAGE("Computer name :" << _pathList[ind].listOfComputer[i])
+ if(MYDEBUG) MESSAGE("Computer name :" << _pathList[ind].listOfComputer[i]);
}
// _moduleList
-// SCRUTE(_moduleList.size());
+// if(MYDEBUG) SCRUTE(_moduleList.size());
// for (unsigned int ind = 0; ind < _moduleList.size(); ind++)
// {
// f << _moduleList[ind] << std::endl;
// }
- MESSAGE("Document parsed");
- END_OF("endDocument");
+ if(MYDEBUG) MESSAGE("Document parsed");
+ if(MYDEBUG) END_OF("endDocument");
return true;
}
#ifndef SALOME_CATALOG_HANDLER_H
#define SALOME_CATALOG_HANDLER_H
-#include "utilities.h"
#include "SALOME_ModuleCatalog_Parser.hxx"
#include <qxml.h>
#include <string>
private:
QString errorProt ;
- string content;
+ std::string content;
QString test_path_prefix_name ;
QString test_computer_name ;
#include "SALOME_ModuleCatalog_Parser_IO.hxx"
#include <string>
+#include <iostream>
#include "utilities.h"
+using namespace std;
+
std::ostream & operator<< (std::ostream & f, const ParserParameter & P)
{
f << " name : " << P.name << std::endl;
#include <qfileinfo.h>
using namespace std;
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
static const char* SEPARATOR = ":";
//----------------------------------------------------------------------
//----------------------------------------------------------------------
SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA::ORB_ptr orb) : _orb(orb)
{
- MESSAGE("Catalog creation");
+ if(MYDEBUG) MESSAGE("Catalog creation");
// Conversion rules for component types
ComponentTypeConvert[GEOM]
// Parse the arguments given at server run
if (!_parseArguments(argc, argv,&_general_path,&_personal_path))
- MESSAGE( "Error while argument parsing" );
+ if(MYDEBUG) MESSAGE( "Error while argument parsing" );
// Test existency of files
- if (_general_path == NULL)
- MESSAGE( "Error the general catalog should be indicated" )
- else
- {
- // Affect the _general_module_list and _general_path_list members
- // with the common catalog
-
- QStringList dirList
- = QStringList::split( SEPARATOR, _general_path,
- false ); // skip empty entries
-
- for ( int i = 0; i < dirList.count(); i++ ) {
- QFileInfo fileInfo( dirList[ i ] );
- if ( fileInfo.isFile() && fileInfo.exists() ) {
- _parse_xml_file(fileInfo.filePath(),
- _general_module_list,
- _general_path_list);
- }
+ if (_general_path == NULL){
+ if(MYDEBUG) MESSAGE( "Error the general catalog should be indicated" );
+ }else{
+ // Affect the _general_module_list and _general_path_list members
+ // with the common catalog
+
+ QStringList dirList
+ = QStringList::split( SEPARATOR, _general_path,
+ false ); // skip empty entries
+
+ for ( int i = 0; i < dirList.count(); i++ ) {
+ QFileInfo fileInfo( dirList[ i ] );
+ if ( fileInfo.isFile() && fileInfo.exists() ) {
+ _parse_xml_file(fileInfo.filePath(),
+ _general_module_list,
+ _general_path_list);
}
-
- // Verification of _general_path_list content
- if(!_verify_path_prefix(_general_path_list))
- MESSAGE( "Error while parsing the general path list, "
- "differents paths are associated to the same computer,"
- "the first one will be choosen")
- else
- MESSAGE("General path list OK");
+ }
- if(_personal_path != NULL)
- {
- // Initialize the _personal_module_list and
- // _personal_path_list members with the personal catalog files
- _parse_xml_file(_personal_path,
- _personal_module_list,
- _personal_path_list);
-
- // Verification of _general_path_list content
- if(!_verify_path_prefix(_personal_path_list))
- MESSAGE("Error while parsing the personal path list, "
- "differents paths are associated to the same computer, "
- "the first one will be choosen" )
- else
- MESSAGE("Personal path list OK");
- }
- else
- MESSAGE("No personal catalog indicated or error while "
- "opening the personal catalog");
+ // Verification of _general_path_list content
+ if(!_verify_path_prefix(_general_path_list)){
+ if(MYDEBUG) MESSAGE( "Error while parsing the general path list, "
+ "differents paths are associated to the same computer,"
+ "the first one will be choosen");
+ }else{
+ if(MYDEBUG) MESSAGE("General path list OK");
}
+
+ if(_personal_path != NULL){
+ // Initialize the _personal_module_list and
+ // _personal_path_list members with the personal catalog files
+ _parse_xml_file(_personal_path,
+ _personal_module_list,
+ _personal_path_list);
+
+ // Verification of _general_path_list content
+ if(!_verify_path_prefix(_personal_path_list)){
+ if(MYDEBUG) MESSAGE("Error while parsing the personal path list, "
+ "differents paths are associated to the same computer, "
+ "the first one will be choosen" );
+ }else {
+ if(MYDEBUG) MESSAGE("Personal path list OK");
+ }
+ }else
+ if(MYDEBUG) MESSAGE("No personal catalog indicated or error while "
+ "opening the personal catalog");
+ }
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
SALOME_ModuleCatalogImpl::~SALOME_ModuleCatalogImpl()
{
- MESSAGE("Catalog Destruction");
+ if(MYDEBUG) MESSAGE("Catalog Destruction");
}
//----------------------------------------------------------------------
char *
SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) {
- MESSAGE("Begin of GetPathPrefix")
+ if(MYDEBUG) MESSAGE("Begin of GetPathPrefix");
// Variables initialisation
char* _path = NULL;
bool _find = false ;
SALOME_ModuleCatalog::ListOfComponents*
SALOME_ModuleCatalogImpl::GetComponentList()
{
- MESSAGE("Begin of GetComponentList");
+ if(MYDEBUG) MESSAGE("Begin of GetComponentList");
SALOME_ModuleCatalog::ListOfComponents_var _list_components =
new SALOME_ModuleCatalog::ListOfComponents;
_list_components->length(_personal_module_list.size());
// All the components defined in the personal catalog are taken
- for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
- {
- _list_components[ind]=(_personal_module_list[ind].name).c_str();
- SCRUTE(_list_components[ind]) ;
- }
+ for(unsigned int ind=0; ind < _personal_module_list.size();ind++){
+ _list_components[ind]=(_personal_module_list[ind].name).c_str();
+ if(MYDEBUG) SCRUTE(_list_components[ind]) ;
+ }
int indice = _personal_module_list.size() ;
bool _find = false;
// The components in the general catalog are taken only if they're
// not defined in the personal catalog
- for (unsigned int ind=0; ind < _general_module_list.size();ind++)
- {
- _find = false;
- for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
- {
- // searching if the component is already defined in
- // the personal catalog
- if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
- _find = true;
- }
- if (!_find)
- {
- MESSAGE("A new component " << _general_module_list[ind].name
- << " has to be to added in the list");
- _list_components->length(indice+1);
- // The component is not already defined => has to be taken
- _list_components[indice]=(_general_module_list[ind].name).c_str();
- SCRUTE(_list_components[indice]) ;
-
- indice++;
- }
- else
- MESSAGE("The component " <<_general_module_list[ind].name
- << " was already defined in the personal catalog") ;
- }
-
- MESSAGE ( "End of GetComponentList" )
+ for(unsigned int ind=0; ind < _general_module_list.size();ind++){
+ _find = false;
+ for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){
+ // searching if the component is already defined in
+ // the personal catalog
+ if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
+ _find = true;
+ }
+ if(!_find){
+ if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name
+ << " has to be to added in the list");
+ _list_components->length(indice+1);
+ // The component is not already defined => has to be taken
+ _list_components[indice]=(_general_module_list[ind].name).c_str();
+ if(MYDEBUG) SCRUTE(_list_components[indice]) ;
+
+ indice++;
+ }else{
+ if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name
+ << " was already defined in the personal catalog") ;
+ }
+ }
+
+ if(MYDEBUG) MESSAGE ( "End of GetComponentList" );
return _list_components._retn();
}
SALOME_ModuleCatalog::ListOfIAPP_Affich*
SALOME_ModuleCatalogImpl::GetComponentIconeList()
{
- MESSAGE("Begin of GetComponentIconeList");
+ if(MYDEBUG) MESSAGE("Begin of GetComponentIconeList");
SALOME_ModuleCatalog::ListOfIAPP_Affich_var _list_components_icone =
new SALOME_ModuleCatalog::ListOfIAPP_Affich;
_list_components_icone->length(_personal_module_list.size());
// All the components defined in the personal catalog are taken
- for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
- {
- _list_components_icone[ind].modulename=(_personal_module_list[ind].name).c_str();
- _list_components_icone[ind].moduleusername=(_personal_module_list[ind].username).c_str();
- _list_components_icone[ind].moduleicone=(_personal_module_list[ind].icon).c_str();
- //SCRUTE(_list_components_icone[ind].modulename);
- //SCRUTE(_list_components_icone[ind].moduleicone);
- }
-
+ for(unsigned int ind=0; ind < _personal_module_list.size();ind++){
+ _list_components_icone[ind].modulename=(_personal_module_list[ind].name).c_str();
+ _list_components_icone[ind].moduleusername=(_personal_module_list[ind].username).c_str();
+ _list_components_icone[ind].moduleicone=(_personal_module_list[ind].icon).c_str();
+ //if(MYDEBUG) SCRUTE(_list_components_icone[ind].modulename);
+ //if(MYDEBUG) SCRUTE(_list_components_icone[ind].moduleicone);
+ }
+
int indice = _personal_module_list.size() ;
bool _find = false;
// The components in the general catalog are taken only if they're
// not defined in the personal catalog
- for (unsigned int ind=0; ind < _general_module_list.size();ind++)
- {
- _find = false;
- for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
- {
- // searching if the component is aleready defined in
- // the personal catalog
- if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
- _find = true;
- }
- if (!_find)
- {
- // MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
- _list_components_icone->length(indice+1);
- // The component is not already defined => has to be taken
- _list_components_icone[indice].modulename=_general_module_list[ind].name.c_str();
- _list_components_icone[indice].moduleusername=_general_module_list[ind].username.c_str();
- _list_components_icone[indice].moduleicone=_general_module_list[ind].icon.c_str();
- //SCRUTE(_list_components_icone[indice].modulename) ;
- //SCRUTE(_list_components_icone[indice].moduleicone);
-
- indice++;
- }
- // else
- //MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog");
- }
-
+ for(unsigned int ind=0; ind < _general_module_list.size();ind++){
+ _find = false;
+ for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){
+ // searching if the component is aleready defined in
+ // the personal catalog
+ if((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
+ _find = true;
+ }
+ if(!_find){
+ // if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
+ _list_components_icone->length(indice+1);
+ // The component is not already defined => has to be taken
+ _list_components_icone[indice].modulename=_general_module_list[ind].name.c_str();
+ _list_components_icone[indice].moduleusername=_general_module_list[ind].username.c_str();
+ _list_components_icone[indice].moduleicone=_general_module_list[ind].icon.c_str();
+ //if(MYDEBUG) SCRUTE(_list_components_icone[indice].modulename) ;
+ //if(MYDEBUG) SCRUTE(_list_components_icone[indice].moduleicone);
+
+ indice++;
+ }
+ // else
+ //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog");
+ }
+
return _list_components_icone._retn() ;
}
SALOME_ModuleCatalog::ListOfComponents*
SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentType component_type)
{
- MESSAGE("Begin of GetTypedComponentList");
+ if(MYDEBUG) MESSAGE("Begin of GetTypedComponentList");
SALOME_ModuleCatalog::ListOfComponents_var _list_typed_component =
new SALOME_ModuleCatalog::ListOfComponents;
int _j = 0;
{
_list_typed_component->length(_j + 1);
_list_typed_component[_j] = (_moduleList[ind].name).c_str();
- //SCRUTE(_list_typed_component[_j])
+ //if(MYDEBUG) SCRUTE(_list_typed_component[_j]);
_j++;
}
}
}
if (!_find)
{
- //MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
+ //if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
_list_typed_component->length(indice+1);
// The component is not already defined => has to be taken
_list_typed_component[indice]=(_general_module_list[ind].name).c_str();
- //SCRUTE(_list_typed_component[indice]) ;
+ //if(MYDEBUG) SCRUTE(_list_typed_component[indice]) ;
indice++;
}
//else
- //MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog") ;
+ //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog") ;
}
}
else {
// Not found in the personal catalog and in the general catalog
// return NULL object
- MESSAGE("Component with name " << name
- << " not found in catalog");
+ if(MYDEBUG) MESSAGE("Component with name " << name
+ << " not found in catalog");
compo = NULL;
}
for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
if (name.compare(_personal_module_list[ind].name) == 0)
{
- MESSAGE("Component named " << name
- << " found in the personal catalog");
+ if(MYDEBUG) MESSAGE("Component named " << name
+ << " found in the personal catalog");
C_parser = &(_personal_module_list[ind]);
break;
}
{
if (name.compare(_general_module_list[ind].name) == 0)
{
- MESSAGE("Component named " << name
- << " found in the general catalog");
+ if(MYDEBUG) MESSAGE("Component named " << name
+ << " found in the general catalog");
C_parser = &(_general_module_list[ind]);
break;
}
ParserComponents& modulelist,
ParserPathPrefixes& pathList)
{
- BEGIN_OF("_parse_xml_file");
- SCRUTE(file);
+ if(MYDEBUG) BEGIN_OF("_parse_xml_file");
+ if(MYDEBUG) SCRUTE(file);
SALOME_ModuleCatalog_Handler* handler = new SALOME_ModuleCatalog_Handler();
QFile xmlFile(file);
// duplicate service list
unsigned int _length = I_parser.services.size();
- SCRUTE(_length);
+ if(MYDEBUG) SCRUTE(_length);
// I_corba.interfaceservicelist
// = new SALOME_ModuleCatalog::ListOfInterfaceService;
I_corba.interfaceservicelist.length(_length);
// duplicate out DataStreamParameters
_length = S_parser.outDataStreamParameters.size();
- SCRUTE(_length);
+ if(MYDEBUG) SCRUTE(_length);
S_corba.ServiceoutDataStreamParameter.length(_length);
for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
// = (it_type == DataStreamTypeConvert.end())
// ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
- SCRUTE(P_parser.type);
+ if(MYDEBUG) SCRUTE(P_parser.type);
P_corba.Parametertype = SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
for (it_type = DataStreamTypeConvert.begin();
it_type != DataStreamTypeConvert.end();
P_corba.Parametertype = it_type->second;
break;
}
- SCRUTE(P_corba.Parametertype);
+ if(MYDEBUG) SCRUTE(P_corba.Parametertype);
// duplicate parameter type
// = (it_type == DataStreamTypeConvert.end())
// ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
- SCRUTE(P_parser.dependency);
+ if(MYDEBUG) SCRUTE(P_parser.dependency);
P_corba.Parameterdependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
for (it_dep = DataStreamDepConvert.begin();
it_dep != DataStreamDepConvert.end();
break;
}
- SCRUTE(P_corba.Parameterdependency);
+ if(MYDEBUG) SCRUTE(P_corba.Parameterdependency);
}
//----------------------------------------------------------------------
{
if(_machine_list[ind].compare(_machine_list[ind1]) == 0)
{
- MESSAGE( "The computer " << _machine_list[ind] << " is indicated more than once in the path list")
+ if(MYDEBUG) MESSAGE( "The computer " << _machine_list[ind] << " is indicated more than once in the path list");
_return_value = false;
}
}
\param name string argument
\return pointer on a component, NULL if not found
*/
- ParserComponent *findComponent(const string & name);
+ ParserComponent *findComponent(const std::string & name);
//! method to create a CORBA component description from parser
/*!
// Module : SALOME
// $Header$
-using namespace std;
#include "SALOME_NamingService.hxx"
#include "ServiceUnreachable.hxx"
+
+#include "utilities.h"
+
#include <iostream>
#include <cstring>
+using namespace std;
+
//----------------------------------------------------------------------
/*! Function : SALOME_NamingService
* Purpose : Constructor and Initialisation of _root_context
//!method to get all the contexts contained in the current direcotry
// Get only objects, isn't iterative
- vector<string> list_directory()
+ std::vector<std::string> list_directory()
throw(ServiceUnreachable);
//! method to destroy an association Path-Object Reference
event->filterable_data[5].value >>= Anode;
event->filterable_data[6].value >>= Astamp;
event->remainder_of_body >>= Amessage;
- *graph = strdup(Agraph);
- *node = strdup(Anode);
- *type = strdup(Atype);
- *message = strdup(Amessage);
- *sender = strdup(Asender);
+ *graph = CORBA::string_dup(Agraph);
+ *node = CORBA::string_dup(Anode);
+ *type = CORBA::string_dup(Atype);
+ *message = CORBA::string_dup(Amessage);
+ *sender = CORBA::string_dup(Asender);
*counter = (long)Acounter;
- *date = strdup(Adate);
+ *date = CORBA::string_dup(Adate);
*stamp = (long)Astamp;
};
};
Handle_SALOME_AISShape.hxx \
SALOME_AISObject.hxx \
Handle_SALOME_AISObject.hxx \
- VTKViewer_Common.h
-
# Libraries targets
LIB_SRC = SALOME_InteractiveObject.cxx \
SALOME_Actor.cxx \
SALOME_AISShape.cxx\
- SALOME_AISObject.cxx
+ SALOME_AISObject.cxx\
LIB_CLIENT_IDL =
#endif
class SALOME_InteractiveObject;
class TopoDS_Shape;
+class TColStd_IndexedMapOfInteger;
class SALOME_AISShape : public AIS_Shape {
Standard_EXPORT virtual Standard_Boolean hasIO() = 0;
Standard_EXPORT virtual Standard_CString getName() = 0;
Standard_EXPORT virtual void setName(Standard_CString aName) = 0;
+Standard_EXPORT virtual void highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap, const Standard_Boolean aHighlight ) = 0;
Standard_EXPORT ~SALOME_AISShape();
#include "utilities.h"
// VTK Includes
+#include <vtkCell.h>
+#include <vtkRenderer.h>
+#include <vtkPolyData.h>
#include <vtkObjectFactory.h>
#include <vtkDataSetMapper.h>
#include <vtkPolyDataMapper.h>
SALOME_Actor::SALOME_Actor(){
- PreviewProperty = NULL;
- ispreselected = Standard_False;
- myProperty = vtkProperty::New();
+ myIsHighlighted = myIsPreselected = false;
- myRepresentation = 2;
+ myRepresentation = 1;
+ myDisplayMode = myRepresentation - 1;
+
+ myProperty = vtkProperty::New();
+ PreviewProperty = NULL;
myIsInfinite = false;
+ myIsResolveCoincidentTopology = true;
+
+ vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
+ myPolygonOffsetUnits);
myStoreMapping = false;
myGeomFilter = SALOME_GeometryFilter::New();
myTransformFilter->SetTransform(theTransform);
}
+
void SALOME_Actor::SetMapper(vtkMapper* theMapper){
+ InitPipeLine(theMapper);
+}
+
+void SALOME_Actor::InitPipeLine(vtkMapper* theMapper){
if(theMapper){
int anId = 0;
-#if defined __GNUC_2__
- myPassFilter[anId]->SetInput(theMapper->GetInput());
-#else
- myPassFilter.at(anId)->SetInput(theMapper->GetInput());
-#endif
- myGeomFilter->SetStoreMapping(myStoreMapping);
-#if defined __GNUC_2__
- myGeomFilter->SetInput(myPassFilter[anId]->GetOutput());
-#else
- myGeomFilter->SetInput(myPassFilter.at(anId)->GetOutput());
-#endif
-
- anId++;
-
-#if defined __GNUC_2__
- myPassFilter[anId]->SetInput(myGeomFilter->GetOutput());
- myPassFilter[anId+1]->SetInput(myPassFilter[anId]->GetOutput());
-#else
- myPassFilter.at(anId)->SetInput(myGeomFilter->GetOutput());
- myPassFilter.at(anId+1)->SetInput(myPassFilter.at(anId)->GetOutput());
-#endif
+ myPassFilter[ anId ]->SetInput( theMapper->GetInput() );
+ myPassFilter[ anId + 1]->SetInput( myPassFilter[ anId ]->GetOutput() );
+
+ anId++; // 1
+ myGeomFilter->SetStoreMapping( myStoreMapping );
+ myGeomFilter->SetInput( myPassFilter[ anId ]->GetOutput() );
- anId++;
-#if defined __GNUC_2__
- myPassFilter[anId+1]->SetInput(myPassFilter[anId]->GetOutput());
-#else
- myPassFilter.at(anId+1)->SetInput(myPassFilter.at(anId)->GetOutput());
-#endif
+ anId++; // 2
+ myPassFilter[ anId ]->SetInput( myGeomFilter->GetOutput() );
+ myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
- anId++;
-#if defined __GNUC_2__
- myTransformFilter->SetInput(myPassFilter[anId]->GetPolyDataOutput());
-#else
- myTransformFilter->SetInput(myPassFilter.at(anId)->GetPolyDataOutput());
-#endif
+ anId++; // 3
+ myTransformFilter->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() );
- anId++;
-#if defined __GNUC_2__
- myPassFilter[anId]->SetInput(myTransformFilter->GetOutput());
- myPassFilter[anId+1]->SetInput(myPassFilter[anId]->GetOutput());
-#else
- myPassFilter.at(anId)->SetInput(myTransformFilter->GetOutput());
- myPassFilter.at(anId+1)->SetInput(myPassFilter.at(anId)->GetOutput());
-#endif
+ anId++; // 4
+ myPassFilter[ anId ]->SetInput( myTransformFilter->GetOutput() );
+ myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
- anId++;
- if(vtkDataSetMapper* aMapper = dynamic_cast<vtkDataSetMapper*>(theMapper))
-#if defined __GNUC_2__
+ anId++; // 5
+ if(vtkDataSetMapper* aMapper = dynamic_cast<vtkDataSetMapper*>(theMapper)){
aMapper->SetInput(myPassFilter[anId]->GetOutput());
-#else
- aMapper->SetInput(myPassFilter.at(anId)->GetOutput());
-#endif
- else if(vtkPolyDataMapper* aMapper = dynamic_cast<vtkPolyDataMapper*>(theMapper))
-#if defined __GNUC_2__
+ }else if(vtkPolyDataMapper* aMapper = dynamic_cast<vtkPolyDataMapper*>(theMapper)){
aMapper->SetInput(myPassFilter[anId]->GetPolyDataOutput());
-#else
- aMapper->SetInput(myPassFilter.at(anId)->GetPolyDataOutput());
-#endif
+ }
}
vtkLODActor::SetMapper(theMapper);
}
-vtkPolyData* SALOME_Actor::GetPolyDataInput(){
- return myPassFilter.back()->GetPolyDataOutput();
+
+void SALOME_Actor::Render(vtkRenderer *ren, vtkMapper* m){
+ if(myIsResolveCoincidentTopology){
+ int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology();
+ float aFactor, aUnit;
+ vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnit);
+
+ vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
+ vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
+ myPolygonOffsetUnits);
+ vtkLODActor::Render(ren,m);
+
+ vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnit);
+ vtkMapper::SetResolveCoincidentTopology(aResolveCoincidentTopology);
+ }else{
+ vtkLODActor::Render(ren,m);
+ }
+}
+
+
+void SALOME_Actor::SetResolveCoincidentTopology(bool theIsResolve) {
+ myIsResolveCoincidentTopology = theIsResolve;
+}
+
+void SALOME_Actor::SetPolygonOffsetParameters(float factor, float units){
+ myPolygonOffsetFactor = factor;
+ myPolygonOffsetUnits = units;
+}
+
+void SALOME_Actor::GetPolygonOffsetParameters(float& factor, float& units){
+ factor = myPolygonOffsetFactor;
+ units = myPolygonOffsetUnits;
+}
+
+
+vtkDataSet* SALOME_Actor::GetInput(){
+ return myPassFilter.front()->GetOutput();
}
void SALOME_Actor::SetRepresentation(int theMode) {
switch(myRepresentation){
- case 0 :
- case 2 :
+ case VTK_POINTS :
+ case VTK_SURFACE :
myProperty->DeepCopy(GetProperty());
}
switch(theMode){
- case 0 :
- case 2 :
+ case VTK_POINTS :
+ case VTK_SURFACE :
GetProperty()->DeepCopy(myProperty);
break;
default:
- break;
GetProperty()->SetAmbient(1.0);
GetProperty()->SetDiffuse(0.0);
GetProperty()->SetSpecular(0.0);
myGeomFilter->SetInside(true);
GetProperty()->SetRepresentation(1);
break;
- case 0 :
+ case VTK_POINTS :
GetProperty()->SetPointSize(SALOME_POINT_SIZE);
default :
GetProperty()->SetRepresentation(theMode);
return myRepresentation;
}
+
+vtkCell* SALOME_Actor::GetElemCell(int theObjID){
+ return GetInput()->GetCell(theObjID);
+}
+
+
+float* SALOME_Actor::GetNodeCoord(int theObjID){
+ return GetInput()->GetPoint(theObjID);
+}
+
+
//=================================================================================
// function : GetObjDimension
// purpose : Return object dimension.
//=================================================================================
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();
- }
- }
+ if ( vtkCell* aCell = GetElemCell(theObjId) )
+ return aCell->GetCellDimension();
return 0;
}
+bool SALOME_Actor::IsInfinitive(){
+ return myIsInfinite;
+}
+void SALOME_Actor::SetOpacity(float theOpacity){
+ myOpacity = theOpacity;
+ GetProperty()->SetOpacity(theOpacity);
+}
+float SALOME_Actor::GetOpacity(){
+ return myOpacity;
+}
+void SALOME_Actor::SetColor(float r,float g,float b){
+ GetProperty()->SetColor(r,g,b);
+}
+void SALOME_Actor::GetColor(float& r,float& g,float& b){
+ float aColor[3];
+ GetProperty()->GetColor(aColor);
+ r = aColor[0];
+ g = aColor[1];
+ b = aColor[2];
+}
+int SALOME_Actor::getDisplayMode(){
+ return myDisplayMode;
+}
-
-
-
-
-
-
-
+void SALOME_Actor::setDisplayMode(int theMode){
+ SetRepresentation(theMode+1);
+ myDisplayMode = GetRepresentation() - 1;
+}
#ifndef SALOME_ACTOR_H
#define SALOME_ACTOR_H
-// SALOME Includes
-#include "VTKViewer_Common.h"
-#include "SALOME_InteractiveObject.hxx"
-
#include <vector>
+#include <vtkLODActor.h>
+#include <vtkProperty.h>
+
+class vtkCell;
+class vtkDataSet;
+class vtkPolyData;
+class vtkCamera;
+
+#include "SALOME_InteractiveObject.hxx"
+
class SALOME_Transform;
class SALOME_GeometryFilter;
class SALOME_TransformFilter;
extern int SALOME_POINT_SIZE;
class SALOME_Actor : public vtkLODActor{
- protected:
- //constructor should be protected due to first implementation of this class
- //it was abstract class
- SALOME_Actor();
- ~SALOME_Actor();
public:
static SALOME_Actor* New();
vtkTypeMacro(SALOME_Actor,vtkLODActor);
virtual Standard_Boolean hasIO() { return !myIO.IsNull(); }
- virtual Handle_SALOME_InteractiveObject getIO() { return myIO; }
+ virtual const Handle(SALOME_InteractiveObject)& getIO() { return myIO; }
virtual void setIO(const Handle(SALOME_InteractiveObject)& io) { myIO = io; }
- virtual Standard_CString getName() { return myName; }
- virtual void setName(Standard_CString aName){
- myName = aName;
- if(hasIO()) myIO->setName(aName);
+ virtual const char* getName() { return myName.c_str(); }
+ virtual void setName(const char* theName){
+ if(hasIO()) myIO->setName(theName);
+ myName = theName;
}
- virtual int getDisplayMode() { return myDisplayMode; }
- virtual void setDisplayMode(int mode) { myDisplayMode = mode; }
-
- virtual bool hasHighlight() { return false; }
- virtual void highlight(Standard_Boolean highlight) { ishighlighted = highlight; }
- virtual Standard_Boolean isHighlighted() { return ishighlighted; }
+ // To generate highlight automaticaly
+ virtual bool hasHighlight() { return false; }
+ virtual void highlight(bool theHighlight) { myIsHighlighted = theHighlight; }
+ virtual bool isHighlighted() { return myIsHighlighted; }
- virtual void SetOpacity(float opa) { m_opacity = opa; }
- virtual float GetOpacity() { return m_opacity; }
+ virtual void SetOpacity(float theOpacity);
+ virtual float GetOpacity();
- virtual void SetColor(float r,float g,float b) {};
- virtual void GetColor(float& r,float& g,float& b) {};
+ virtual void SetColor(float r,float g,float b);
+ virtual void GetColor(float& r,float& g,float& b);
+ void SetColor(const float theRGB[3]){
+ SetColor(theRGB[0],theRGB[1],theRGB[2]);
+ }
vtkSetObjectMacro(PreviewProperty,vtkProperty);
- virtual void SetPreSelected(Standard_Boolean presel = Standard_False) { ispreselected = presel; }
+ virtual void SetPreSelected(bool thePreselect = false) { myIsPreselected = thePreselect;}
+
// Used to obtain all dependent actors
virtual void GetChildActors(vtkActorCollection*) {};
virtual void AddToRender(vtkRenderer* theRenderer);
virtual void RemoveFromRender(vtkRenderer* theRenderer);
- typedef std::vector<int> TVectorId;
- virtual int GetObjId(int theVtkID) { return -1;}
- virtual TVectorId GetVtkId(int theObjID) { return TVectorId();}
+
+ // For selection mapping purpose
+ virtual int GetNodeObjId(int theVtkID) { return theVtkID;}
+ virtual float* GetNodeCoord(int theObjID);
+
+ virtual int GetElemObjId(int theVtkID) { return theVtkID;}
+ virtual vtkCell* GetElemCell(int theObjID);
virtual int GetObjDimension( const int theObjId );
virtual void SetMapper(vtkMapper* theMapper);
- virtual vtkPolyData* GetPolyDataInput();
+ virtual vtkDataSet* GetInput();
+
virtual void SetTransform(SALOME_Transform* theTransform);
virtual unsigned long int GetMTime();
virtual void SetRepresentation(int theMode);
virtual int GetRepresentation();
- // Infinitive means actor without size (point for example
+ virtual int getDisplayMode();
+ virtual void setDisplayMode(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 myIsInfinite; }
+ void SetInfinitive(bool theIsInfinite) { myIsInfinite = theIsInfinite; }
+ virtual bool IsInfinitive();
+ void SetResolveCoincidentTopology(bool theIsResolve);
+ void SetPolygonOffsetParameters(float factor, float units);
+ void GetPolygonOffsetParameters(float& factor, float& units);
+
+ virtual void Render(vtkRenderer *, vtkMapper *);
+
+ virtual float GetShrinkFactor() { return 1.0;}
+
+ virtual bool IsShrunkable() { return false;}
+ virtual bool IsShrunk() { return false;}
+
+ virtual void SetShrink() {}
+ virtual void UnShrink() {}
+
+ virtual bool IsSetCamera() const { return false; }
+ virtual bool IsResizable() const { return false; }
+ virtual void SetSize( const float ) {}
+ virtual void SetCamera( vtkCamera* ) {}
+
protected:
- vtkProperty *PreviewProperty;
- Standard_Boolean ispreselected;
+ bool myIsResolveCoincidentTopology;
+ float myPolygonOffsetFactor;
+ float myPolygonOffsetUnits;
Handle(SALOME_InteractiveObject) myIO;
- Standard_CString myName;
+ std::string myName;
- float m_opacity;
- Standard_Boolean ishighlighted;
+ vtkProperty *PreviewProperty;
+ bool myIsPreselected;
+
+ float myOpacity;
+ bool myIsHighlighted;
int myDisplayMode;
bool myIsInfinite;
int myRepresentation;
vtkProperty *myProperty;
+
+ void InitPipeLine(vtkMapper* theMapper);
+
+ SALOME_Actor();
+ ~SALOME_Actor();
};
+
#endif // SALOME_ACTOR_H
+
myReference = "";
}
-SALOME_InteractiveObject::SALOME_InteractiveObject(const Standard_CString anEntry,
- const Standard_CString aComponentDataType,
- const Standard_CString aName)
-{
- myEntry = new char [strlen(anEntry)+1];
- strcpy( myEntry, anEntry);
-
- myName = new char [strlen(aName)+1];
- strcpy( myName, aName);
-
- myComponentDataType = new char [strlen(aComponentDataType)+1];
- strcpy( myComponentDataType, aComponentDataType);
-
- myReference = new char [strlen("")+1];
- strcpy( myReference, "");
-}
-
-void SALOME_InteractiveObject::setEntry(const Standard_CString anEntry){
- myEntry = new char [strlen(anEntry)+1];
- strcpy( myEntry, anEntry);
+SALOME_InteractiveObject::SALOME_InteractiveObject(const char* anEntry,
+ const char* aComponentDataType,
+ const char* aName):
+ myEntry(anEntry),
+ myName(aName),
+ myComponentDataType(aComponentDataType),
+ myReference("")
+{}
+
+void SALOME_InteractiveObject::setEntry(const char* anEntry){
+ myEntry = anEntry;
}
-Standard_CString SALOME_InteractiveObject::getEntry(){
- return myEntry;
+const char* SALOME_InteractiveObject::getEntry(){
+ return myEntry.c_str();
}
-void SALOME_InteractiveObject::setComponentDataType(const Standard_CString aComponentDataType){
- myComponentDataType = new char [strlen(aComponentDataType)+1];
- strcpy( myComponentDataType, aComponentDataType);
+void SALOME_InteractiveObject::setComponentDataType(const char* aComponentDataType){
+ myComponentDataType = aComponentDataType;
}
-Standard_CString SALOME_InteractiveObject::getComponentDataType(){
- return myComponentDataType;
+const char* SALOME_InteractiveObject::getComponentDataType(){
+ return myComponentDataType.c_str();
}
-void SALOME_InteractiveObject::setName(const Standard_CString aName){
- myName = new char [strlen(aName)+1];
- strcpy( myName, aName);
+void SALOME_InteractiveObject::setName(const char* aName){
+ myName = aName;
}
-Standard_CString SALOME_InteractiveObject::getName(){
- return myName;
+const char* SALOME_InteractiveObject::getName(){
+ return myName.c_str();
}
Standard_Boolean SALOME_InteractiveObject::hasEntry(){
- return !( strcmp(myEntry, "" ) == 0 );
+ return myEntry != "";
}
Standard_Boolean SALOME_InteractiveObject::isSame(const Handle(SALOME_InteractiveObject)& anIO ){
if ( anIO->hasEntry() && this->hasEntry() ) {
- if ( strcmp(myEntry, anIO->getEntry() ) == 0 )
+ if ( myEntry == anIO->getEntry() )
return Standard_True;
}
return Standard_False;
}
-Standard_Boolean SALOME_InteractiveObject::isComponentType(const Standard_CString ComponentDataType){
- if ( strcmp( myComponentDataType, ComponentDataType) == 0 )
+Standard_Boolean SALOME_InteractiveObject::isComponentType(const char* ComponentDataType){
+ if ( myComponentDataType == ComponentDataType )
return Standard_True;
else
return Standard_False;
Standard_Boolean SALOME_InteractiveObject::hasReference()
{
- return !( strcmp(myReference, "" ) == 0 );
+ return myReference != "";
}
-Standard_CString SALOME_InteractiveObject::getReference()
+const char* SALOME_InteractiveObject::getReference()
{
- return myReference;
+ return myReference.c_str();
}
-void SALOME_InteractiveObject::setReference(const Standard_CString aReference)
+void SALOME_InteractiveObject::setReference(const char* aReference)
{
- myReference = new char [strlen(aReference)+1];
- strcpy( myReference, aReference);
+ myReference = aReference;
}
#include <Standard_Boolean.hxx>
#endif
+#include <string>
class SALOME_InteractiveObject : public MMgt_TShared {
// Methods PUBLIC
//
Standard_EXPORT SALOME_InteractiveObject();
-Standard_EXPORT SALOME_InteractiveObject(const Standard_CString anEntry,
- const Standard_CString aComponentDataType,
- const Standard_CString aName = "");
-Standard_EXPORT void setEntry(const Standard_CString anEntry) ;
-Standard_EXPORT Standard_CString getEntry() ;
-Standard_EXPORT void setName(const Standard_CString aName) ;
-Standard_EXPORT Standard_CString getName() ;
+Standard_EXPORT SALOME_InteractiveObject(const char* anEntry,
+ const char* aComponentDataType,
+ const char* aName = "");
+Standard_EXPORT void setEntry(const char* anEntry) ;
+Standard_EXPORT const char* getEntry() ;
+Standard_EXPORT void setName(const char* aName) ;
+Standard_EXPORT const char* getName() ;
Standard_EXPORT Standard_Boolean hasEntry() ;
Standard_EXPORT virtual Standard_Boolean isSame(const Handle(SALOME_InteractiveObject)& anIO) ;
Standard_EXPORT Standard_Boolean hasReference() ;
-Standard_EXPORT Standard_CString getReference() ;
-Standard_EXPORT void setReference(const Standard_CString aReference) ;
+Standard_EXPORT const char* getReference() ;
+Standard_EXPORT void setReference(const char* aReference) ;
-Standard_EXPORT void setComponentDataType(const Standard_CString ComponentDataType) ;
-Standard_EXPORT Standard_CString getComponentDataType() ;
-Standard_EXPORT Standard_Boolean isComponentType(const Standard_CString ComponentDataType) ;
+Standard_EXPORT void setComponentDataType(const char* ComponentDataType) ;
+Standard_EXPORT const char* getComponentDataType() ;
+Standard_EXPORT Standard_Boolean isComponentType(const char* ComponentDataType) ;
+ //Standard_EXPORT Standard_Boolean isComponentType(std::string ComponentDataType) ;
+Standard_EXPORT virtual ~SALOME_InteractiveObject();
+
+// Must be defined for using by NCollection for ceratin of data map
+friend Standard_Boolean IsEqual(const Handle(SALOME_InteractiveObject)& anIO1,
+ const Handle(SALOME_InteractiveObject)& anIO2)
+{ return anIO1->isSame( anIO2 ); }
-Standard_EXPORT ~SALOME_InteractiveObject();
// Fields PROTECTED
//
-Standard_CString myReference;
-Standard_CString myEntry;
-Standard_CString myName;
-Standard_CString myComponentDataType;
+ std::string myReference;
+ std::string myEntry;
+ std::string myName;
+ std::string myComponentDataType;
private:
EXPORT_HEADERS = \
OCCViewer_AISSelector.h \
- OCCViewer_Selector.h \
OCCViewer_Viewer3d.h \
OCCViewer_ViewFrame.h \
OCCViewer_ViewPort.h \
OCCViewer_ViewPort3d.h \
- OCCViewer_VService.h
+ OCCViewer_VService.h \
+ OCCViewer_Prs.h
# Libraries targets
LIB = libOCCViewer.la
LIB_SRC = OCCViewer.cxx \
- OCCViewer_Selector.cxx \
OCCViewer_Viewer3d.cxx \
OCCViewer_ViewFrame.cxx \
OCCViewer_ViewPort.cxx \
OCCViewer_ViewPort3d.cxx \
OCCViewer_AISSelector.cxx \
- OCCViewer_VService.cxx
+ OCCViewer_VService.cxx \
+ OCCViewer_Prs.cxx
LIB_MOC = \
OCCViewer.h \
OCCViewer_AISSelector.h \
- OCCViewer_Selector.h \
OCCViewer_Viewer3d.h \
OCCViewer_ViewFrame.h \
OCCViewer_ViewPort.h \
- OCCViewer_ViewPort3d.h \
+ OCCViewer_ViewPort3d.h
LIB_CLIENT_IDL = SALOMEDS.idl \
SALOME_ModuleCatalog.idl \
CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(OGL_INCLUDES) $(PYTHON_INCLUDES)
-LDFLAGS+=$(QT_MT_LIBS) $(OGL_LIBS) -lSalomeGUI
+LDFLAGS+=$(QT_MT_LIBS) $(OGL_LIBS) -lSalomePrs -lSalomeGUI
@CONCLUDE@
Constructor
*/
OCCViewer_AISSelector::OCCViewer_AISSelector( const Handle (AIS_InteractiveContext)& aisContext) :
-myAISContext ( aisContext )
+ myAISContext ( aisContext ),
+ myEnableSelection( true ),
+ myEnableMultipleSelection( true )
{
initialize();
}
QAD_ASSERT_DEBUG_ONLY ( !myAISContext.IsNull() );
myHilightColor = Quantity_NOC_CYAN1;
- mySelectColor = Quantity_NOC_GRAY80;
+ mySelectColor = Quantity_NOC_WHITE;
myAISContext->SetHilightColor( myHilightColor );
myAISContext->SelectionColor( mySelectColor );
'selSelectionCancel'.
Returns 'true' if no error, 'false' otherwise.
*/
-bool OCCViewer_AISSelector::checkSelection ( AIS_StatusOfPick status, bool hadSelection, bool addTo )
+void OCCViewer_AISSelector::checkSelection ( int numSelBefore )
{
- myNumSelected = myAISContext->NbCurrents(); /* update after the last selection */
-
- if ( status == AIS_SOP_NothingSelected && !hadSelection ) {
- emit selSelectionCancel( addTo );
- }
- else if ( status == AIS_SOP_NothingSelected && hadSelection ) {
- emit selSelectionCancel( addTo ); /* unselected now */
- }
- else if ( status == AIS_SOP_OneSelected || status == AIS_SOP_SeveralSelected )
- {
- // if ( !hadSelection || status != AIS_SOP_SeveralSelected )
- // addTo = false;
- // MESSAGE (" AIS_StatusOfPick : " << AIS_SOP_OneSelected )
-
- emit selSelectionDone( addTo ); /* selected ( the same object, may be ) */
- }
- return ( status != AIS_SOP_Error && status != AIS_SOP_NothingSelected );
+ int numSelAfter = numSelected();
+ if ( numSelAfter < 1 && numSelBefore > 0 )
+ emit selSelectionCancel( false );
+ else if ( numSelAfter > 0 )
+ emit selSelectionDone( numSelAfter > 1 );
}
Detects the interactive objects at position (x,y).
Returns 'true' if no error, 'false' otherwise.
*/
-bool OCCViewer_AISSelector::moveTo ( int x, int y, const Handle (V3d_View)& view )
+void OCCViewer_AISSelector::moveTo ( int x, int y, const Handle (V3d_View)& view )
{
if ( !myEnableSelection )
- return false;
+ return;
QAD_ASSERT_DEBUG_ONLY ( !myAISContext.IsNull() );
- AIS_StatusOfDetection status = AIS_SOD_Error;
- status = myAISContext->MoveTo (x, y, view);
-
- return ( status != AIS_SOD_Error && status != AIS_SOD_AllBad );
+ myAISContext->MoveTo (x, y, view);
}
/*!
Selects the detected interactive objects.
Calls checkSelection() for checking the status.
*/
-bool OCCViewer_AISSelector::select ()
+void OCCViewer_AISSelector::select ()
{
if ( !myEnableSelection )
- return false;
+ return;
QAD_ASSERT_DEBUG_ONLY ( !myAISContext.IsNull() );
- bool hadSelection = ( myNumSelected > 0 );
+ int numBefore = numSelected();
- /* select and send notifications */
- return checkSelection ( myAISContext->Select(), hadSelection, false );
+ myAISContext->Select();
+
+ /* send notifications */
+ checkSelection ( numBefore );
}
/*!
Multiple selection must be enabled to get use of this function.
Calls checkSelection() for checking the status.
*/
-bool OCCViewer_AISSelector::select ( int left, int top, int right, int bottom,
+void OCCViewer_AISSelector::select ( int left, int top, int right, int bottom,
const Handle (V3d_View)& view )
{
if ( !myEnableSelection || !myEnableMultipleSelection )
- return false; /* selection with rectangle is considered as multiple selection */
+ return; /* selection with rectangle is considered as multiple selection */
QAD_ASSERT_DEBUG_ONLY ( !myAISContext.IsNull() );
- bool hadSelection = ( myNumSelected > 0 );
+ int numBefore = numSelected();
+
+ myAISContext->Select(left, top, right, bottom, view);
- /* select and send notifications */
- return checkSelection ( myAISContext->Select(left, top, right, bottom, view),
- hadSelection, false );
+ /* send notifications */
+ checkSelection ( numBefore );
}
/*!
Multiple selection must be enabled to get use of this function.
Calls checkSelection() for checking the status.
*/
-bool OCCViewer_AISSelector::shiftSelect ()
+void OCCViewer_AISSelector::shiftSelect ()
{
if ( !myEnableSelection )
- return false;
+ return;
QAD_ASSERT_DEBUG_ONLY ( !myAISContext.IsNull() );
- bool hadSelection = ( myNumSelected > 0 ); /* something was selected */
- if ( hadSelection && !myEnableMultipleSelection)
- return false;
+ int numBefore = numSelected();
+
+ if ( numBefore && !myEnableMultipleSelection)
+ myAISContext->Select();
+ else
+ myAISContext->ShiftSelect();
- /* select and send notifications */
- return checkSelection ( myAISContext->ShiftSelect(), hadSelection, true );
+ /* send notifications */
+ checkSelection ( numBefore );
}
/*!
Multiple selection must be enabled to get use of this function.
Calls checkSelection() for checking the status.
*/
-bool OCCViewer_AISSelector::shiftSelect ( int left, int top, int right, int bottom,
+void OCCViewer_AISSelector::shiftSelect ( int left, int top, int right, int bottom,
const Handle (V3d_View)& view )
{
if ( !myEnableSelection || !myEnableMultipleSelection )
- return false; /* selection with rectangle is considered as multiple selection */
+ return; /* selection with rectangle is considered as multiple selection */
QAD_ASSERT_DEBUG_ONLY ( !myAISContext.IsNull() );
- bool hadSelection = ( myNumSelected > 0 ); /* something was selected */
- if ( hadSelection && !myEnableMultipleSelection)
- return false;
+ int numBefore = numSelected();
+
+ myAISContext->ShiftSelect(left,top,right,bottom, view);
+
+ /* send notifications */
+ checkSelection ( numBefore );
+}
+
+/*!
+ Enables/disables selection
+*/
+void OCCViewer_AISSelector::enableSelection( bool bEnable )
+{
+ myEnableSelection = bEnable;
+}
+
+/*!
+ Enables/disables multiple selection i.e
+ selection of several objects at the same time.
+ If enabled, non-multiple selection is enabled as well.
+*/
+void OCCViewer_AISSelector::enableMultipleSelection( bool bEnable )
+{
+ myEnableMultipleSelection = bEnable;
+ if ( bEnable ) myEnableSelection = bEnable;
+}
+
+/*!
+ Returns the number of selected objects.
+*/
+int OCCViewer_AISSelector::numSelected() const
+{
+ if ( myAISContext.IsNull() )
+ return 0;
- /* select and send notifications */
- return checkSelection ( myAISContext->ShiftSelect(left,top,right,bottom, view),
- hadSelection, true );
+ if ( myAISContext->HasOpenedContext() )
+ return myAISContext->NbSelected();
+ return myAISContext->NbCurrents();
}
#define OCCViewer_AISSELECTOR_H
#include "QAD.h"
-#include "OCCViewer_Selector.h"
+
+// QT Include
+#include <qobject.h>
// Open CASCADE Includes
#include <Quantity_NameOfColor.hxx>
#include <AIS_InteractiveContext.hxx>
-class QAD_EXPORT OCCViewer_AISSelector : public OCCViewer_Selector
+class QAD_EXPORT OCCViewer_AISSelector : public QObject
{
Q_OBJECT
~OCCViewer_AISSelector();
public:
- bool moveTo ( int, int, const Handle (V3d_View)& );
- bool select ( int, int, int, int, const Handle (V3d_View)& );
- bool shiftSelect ( int, int, int, int, const Handle (V3d_View)& );
- bool select ();
- bool shiftSelect ();
+ void moveTo ( int, int, const Handle (V3d_View)& );
+ void select ( int, int, int, int, const Handle (V3d_View)& );
+ void shiftSelect ( int, int, int, int, const Handle (V3d_View)& );
+ void select ();
+ void shiftSelect ();
void setContext ( const Handle (AIS_InteractiveContext)& );
void setHilightColor ( Quantity_NameOfColor color );
void setSelectColor ( Quantity_NameOfColor color );
-protected:
- bool checkSelection ( AIS_StatusOfPick status, bool hadSelection, bool addTo );
+ void enableSelection( bool );
+ void enableMultipleSelection( bool );
+
+signals:
+ void selSelectionDone( bool bAdded );
+ void selSelectionCancel( bool bAdded );
protected:
+ void checkSelection ( int numBefore );
+ int numSelected() const;
+
+private:
Handle (AIS_InteractiveContext) myAISContext; // graphic context
Quantity_NameOfColor myHilightColor; // color for hilight object
Quantity_NameOfColor mySelectColor; // color for selected object
+ bool myEnableSelection;
+ bool myEnableMultipleSelection;
+
};
#endif
#include "OCCViewer_Viewer3d.h"
#include "OCCViewer_ViewPort.h"
#include "OCCViewer_ViewPort3d.h"
+#include "OCCViewer_Prs.h"
#include "QAD.h"
#include "QAD_Tools.h"
void OCCViewer_ViewFrame::onViewRight()
{
Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)myViewPort)->getView();
- if ( !view3d.IsNull() ) view3d->SetProj (V3d_Yneg);
+ if ( !view3d.IsNull() )
+ view3d->SetProj( V3d_Ypos );
onViewFitAll();
}
void OCCViewer_ViewFrame::onViewLeft()
{
Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)myViewPort)->getView();
- if ( !view3d.IsNull() ) view3d->SetProj (V3d_Ypos);
+ if ( !view3d.IsNull() )
+ view3d->SetProj( V3d_Yneg );
onViewFitAll();
}
myViewer->setPopupServer( App );
}
-void OCCViewer_ViewFrame::undo(SALOMEDS::Study_var aStudy,
- const char* StudyFrameEntry)
+void OCCViewer_ViewFrame::undo(QAD_Study* theStudy, const char* StudyFrameEntry)
{
+ SALOMEDS::Study_var aStudy = theStudy->getStudyDocument();
AIS_ListOfInteractive List1;
myViewer->getAISContext()->ObjectsInCollector(List1);
AIS_ListIteratorOfListOfInteractive ite1(List1);
- while (ite1.More()) {
- if (ite1.Value()->IsKind(STANDARD_TYPE(SALOME_AISShape))) {
- Handle(SALOME_AISShape) aSh = Handle(SALOME_AISShape)::DownCast(ite1.Value());
- if ( aSh->hasIO() ) {
- Handle(SALOME_InteractiveObject) IO = aSh->getIO();
- if ( IO->hasEntry() ) {
- if (!QAD_ViewFrame::isInViewer(aStudy, IO->getEntry(), StudyFrameEntry))
- myViewer->getAISContext()->Display(aSh);
- }
- }
+ for( ; ite1.More(); ite1.Next() )
+ {
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( ite1.Value()->GetOwner() );
+
+ if ( !anObj.IsNull() &&
+ anObj->hasEntry() &&
+ theStudy->isInViewer( anObj->getEntry(), StudyFrameEntry) )
+ {
+ myViewer->getAISContext()->Display( ite1.Value() );
}
- ite1.Next();
}
AIS_ListOfInteractive List;
myViewer->getAISContext()->DisplayedObjects(List);
AIS_ListIteratorOfListOfInteractive ite(List);
- while (ite.More()) {
- if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISShape))) {
- Handle(SALOME_AISShape) aSh = Handle(SALOME_AISShape)::DownCast(ite.Value());
- if ( aSh->hasIO() ) {
- Handle(SALOME_InteractiveObject) IO = aSh->getIO();
- if ( IO->hasEntry() ) {
- if (!QAD_ViewFrame::isInViewer(aStudy, IO->getEntry(), StudyFrameEntry ))
- myViewer->getAISContext()->Erase(aSh,true,true);
- }
- }
+ for ( ; ite.More(); ite.Next() )
+ {
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
+
+ if ( !anObj.IsNull() &&
+ anObj->hasEntry() &&
+ theStudy->isInViewer( anObj->getEntry(), StudyFrameEntry) )
+ {
+ myViewer->getAISContext()->Erase( ite.Value(), true, true );
}
- ite.Next();
}
}
-void OCCViewer_ViewFrame::redo(SALOMEDS::Study_var aStudy,
- const char* StudyFrameEntry)
+void OCCViewer_ViewFrame::redo(QAD_Study* theStudy, const char* StudyFrameEntry)
{
+ SALOMEDS::Study_var aStudy = theStudy->getStudyDocument();
SALOMEDS::SObject_var RefSO;
SALOMEDS::SObject_var SO = aStudy->FindObjectID( StudyFrameEntry );
SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO);
for (; it->More();it->Next()){
SALOMEDS::SObject_var CSO= it->Value();
- if (CSO->ReferencedObject(RefSO)) {
-
+ if (CSO->ReferencedObject(RefSO))
+ {
AIS_ListOfInteractive List;
myViewer->getAISContext()->ObjectsInCollector(List);
+
AIS_ListIteratorOfListOfInteractive ite(List);
- while (ite.More()) {
- if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISShape))) {
- Handle(SALOME_AISShape) aSh = Handle(SALOME_AISShape)::DownCast(ite.Value());
- if ( aSh->hasIO() ) {
- Handle(SALOME_InteractiveObject) IO = aSh->getIO();
- if ( IO->hasEntry() ) {
- if ( strcmp(IO->getEntry(),RefSO->GetID()) == 0 )
- myViewer->getAISContext()->Display(aSh, false);
- }
- }
- }
- ite.Next();
+ for ( ; ite.More(); ite.Next() )
+ {
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
+
+ if ( !anObj.IsNull() && anObj->hasEntry() && strcmp( anObj->getEntry(), RefSO->GetID() ) == 0 )
+ myViewer->getAISContext()->Display( ite.Value(), false );
}
-
}
}
AIS_ListOfInteractive List1;
myViewer->getAISContext()->DisplayedObjects(List1);
AIS_ListIteratorOfListOfInteractive ite1(List1);
- while (ite1.More()) {
- if (ite1.Value()->IsKind(STANDARD_TYPE(SALOME_AISShape))) {
- Handle(SALOME_AISShape) aSh = Handle(SALOME_AISShape)::DownCast(ite1.Value());
- if ( aSh->hasIO() ) {
- Handle(SALOME_InteractiveObject) IO = aSh->getIO();
- if ( IO->hasEntry() ) {
- if (!QAD_ViewFrame::isInViewer(aStudy, IO->getEntry(), StudyFrameEntry ))
- myViewer->getAISContext()->Erase(aSh,false,true);
- }
- }
- }
- ite1.Next();
+ for ( ; ite1.More(); ite1.Next() )
+ {
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( ite1.Value()->GetOwner() );
+
+ if ( !anObj.IsNull() && anObj->hasEntry() && !theStudy->isInViewer( anObj->getEntry(), StudyFrameEntry ) )
+ myViewer->getAISContext()->Erase( ite1.Value(), false, true );
}
+
Repaint();
}
/* selection */
Handle(SALOME_InteractiveObject) OCCViewer_ViewFrame::FindIObject(const char* Entry)
{
- Handle(SALOME_InteractiveObject) IO;
Handle (AIS_InteractiveContext) ic = myViewer->getAISContext();
AIS_ListOfInteractive List;
List.Append(List1);
AIS_ListIteratorOfListOfInteractive ite(List);
- while (ite.More()) {
- if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISShape))) {
- Handle(SALOME_AISShape) aSh
- = Handle(SALOME_AISShape)::DownCast(ite.Value());
- if ( aSh->hasIO() ) {
- IO = aSh->getIO();
- if ( IO->hasEntry() ) {
- if ( strcmp( IO->getEntry(), Entry ) == 0 ) {
- MESSAGE ( "IO found")
- return IO;
- }
- }
- }
+ for ( ; ite.More(); ite.Next() )
+ {
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
+
+ if ( !anObj.IsNull() && anObj->hasEntry() && strcmp( anObj->getEntry(), Entry ) == 0 )
+ {
+ MESSAGE ( "IO found")
+ return anObj;
}
- ite.Next();
}
MESSAGE ( "IO not found")
- return IO;
+ return Handle(SALOME_InteractiveObject)();
}
/* display */
ic->ObjectsInCollector(List1);
List.Append(List1);
- AIS_ListIteratorOfListOfInteractive ite(List);
- while (ite.More()) {
- if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISShape))) {
- Handle(SALOME_AISShape) aSh
- = Handle(SALOME_AISShape)::DownCast(ite.Value());
- if ( aSh->hasIO() ) {
- Handle(SALOME_InteractiveObject) IO = aSh->getIO();
- if ( IO->isSame( IObject ) ) {
- ic->Display(aSh, false);
- // ic->AddOrRemoveCurrentObject(aSh, false); repeated in Viewer3d after next statement
- Sel->AddIObject(IO, false);
- break;
- }
- }
+ AIS_ListIteratorOfListOfInteractive ite( List );
+ for ( ; ite.More(); ite.Next() )
+ {
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
+
+ if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( IObject ) )
+ {
+ ic->Display( ite.Value(), false );
+ Sel->AddIObject( anObj, false );
+ break;
}
- ite.Next();
}
- if (update)
+
+ if ( update )
Repaint();
}
ic->ObjectsInCollector(List1);
List.Append(List1);
- AIS_ListIteratorOfListOfInteractive ite(List);
- while (ite.More()) {
- if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISShape))) {
- Handle(SALOME_AISShape) aSh
- = Handle(SALOME_AISShape)::DownCast(ite.Value());
- if ( aSh->hasIO() ) {
- Handle(SALOME_InteractiveObject) IO = aSh->getIO();
- if ( !IO->isSame( IObject ) ) {
- ic->Erase(aSh, false);
- Sel->RemoveIObject(IO, false);
- } else {
- ic->Display(aSh, false);
- Sel->AddIObject(IO, false);
- }
+ AIS_ListIteratorOfListOfInteractive ite( List );
+ for ( ; ite.More(); ite.Next() )
+ {
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
+
+ if ( !anObj.IsNull() && anObj->hasEntry() )
+ {
+ if ( !anObj->isSame( IObject ) )
+ {
+ ic->Erase( ite.Value(), false );
+ Sel->RemoveIObject( anObj, false );
+ }
+ else
+ {
+ ic->Display( ite.Value(), false );
+ Sel->AddIObject( anObj, false );
}
}
- ite.Next();
}
+
Repaint();
}
void OCCViewer_ViewFrame::Erase(const Handle(SALOME_InteractiveObject)& IObject, bool update)
AIS_ListOfInteractive List;
ic->DisplayedObjects(List);
- AIS_ListIteratorOfListOfInteractive ite(List);
- while (ite.More())
+
+ AIS_ListIteratorOfListOfInteractive ite( List );
+ for ( ; ite.More(); ite.Next() )
+ {
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
+
+ if ( !anObj.IsNull() && anObj->hasEntry() )
{
- if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISShape)))
- {
- Handle(SALOME_AISShape) aSh
- = Handle(SALOME_AISShape)::DownCast(ite.Value());
- if ( aSh->hasIO() )
- {
- Handle(SALOME_InteractiveObject) IO = aSh->getIO();
- if ( IO->isSame( IObject ) )
- {
- ic->Erase(aSh, false);
- Sel->RemoveIObject(IO, false);
- break;
- }
- }
- }
- ite.Next();
+ if ( anObj->isSame( IObject ) )
+ {
+ ic->Erase( ite.Value(), false );
+ Sel->RemoveIObject( anObj, false );
+ break;
+ }
}
- if (update)
+ }
+
+ if ( update )
Repaint();
}
myViewer->getViewer3d()->Update();
}
-void OCCViewer_ViewFrame::onAdjustTrihedron()
+//==========================================================
+/*!
+ * OCCViewer_ViewFrame::getTrihedronSize
+ * Get new an current trihedron size
+ */
+//==========================================================
+bool OCCViewer_ViewFrame::getTrihedronSize( double& theNewSize, double& theSize )
+{
+ theNewSize = 100;
+ theSize = 100;
+
+ Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)myViewPort)->getView();
+
+ if ( view3d.IsNull() )
+ return false;
+
+ double Xmin = 0, Ymin = 0, Zmin = 0, Xmax = 0, Ymax = 0, Zmax = 0;
+ double aMaxSide;
+ double aPercents;
+
+ view3d->View()->MinMaxValues( Xmin, Ymin, Zmin, Xmax, Ymax, Zmax );
+
+ if ( Xmin == RealFirst() || Ymin == RealFirst() || Zmin == RealFirst() ||
+ Xmax == RealLast() || Ymax == RealLast() || Zmax == RealLast() )
+ return false;
+
+ aMaxSide = Xmax - Xmin;
+ if ( aMaxSide < Ymax -Ymin ) aMaxSide = Ymax -Ymin;
+ if ( aMaxSide < Zmax -Zmin ) aMaxSide = Zmax -Zmin;
+
+ static float aSizeInPercents = 105;
+ QString aSetting = QAD_CONFIG->getSetting("Viewer:TrihedronSize");
+ if (!aSetting.isEmpty())
+ aSizeInPercents = aSetting.toFloat();
+
+ static float EPS = 5.0E-3;
+ theSize = myViewer->getTrihedron()->Size();
+ theNewSize = aMaxSide*aSizeInPercents / 100.0;
+
+ return fabs( theNewSize - theSize ) > theSize * EPS ||
+ fabs( theNewSize - theSize) > theNewSize * EPS;
+}
+
+void OCCViewer_ViewFrame::AdjustTrihedrons( const bool forced )
{
Handle (AIS_InteractiveContext) ic = myViewer->getAISContext();
-
- if (!ic->IsDisplayed(myViewer->getTrihedron()))
+
+ if ( !myViewer->isTrihedronDisplayed() )
return;
- else
+ else
+ {
+ AIS_ListOfInteractive List;
+ ic->DisplayedObjects(List);
+ if ( List.First() == List.Last() && List.First() == myViewer->getTrihedron() )
{
- AIS_ListOfInteractive List;
- ic->Erase( myViewer->getTrihedron() );
- ic->DisplayedObjects(List);
- ic->Display( myViewer->getTrihedron() );
- if (List.IsEmpty())
- {
- myViewer->setTrihedronSize(100);
- return;
+ myViewer->setTrihedronSize( 100 );
+ return;
+ }
+ }
+
+ double aNewSize = 100, aSize = 100;
+ if ( getTrihedronSize( aNewSize, aSize ) || forced )
+ myViewer->setTrihedronSize( aNewSize );
+}
+
+void OCCViewer_ViewFrame::onAdjustTrihedron()
+{
+ AdjustTrihedrons( false );
+}
+
+//==========================================================
+/*!
+ * OCCViewer_ViewFrame::Display
+ * Display presentation
+ */
+//==========================================================
+void OCCViewer_ViewFrame::Display( const SALOME_OCCPrs* prs )
+{
+ // try do downcast object
+ const OCCViewer_Prs* anOCCPrs = dynamic_cast<const OCCViewer_Prs*>( prs );
+ if ( !anOCCPrs || anOCCPrs->IsNull() )
+ return;
+
+ // get context
+ Handle (AIS_InteractiveContext) ic = myViewer->getAISContext();
+ // get all displayed objects
+ AIS_ListOfInteractive List;
+ ic->DisplayedObjects( List );
+ // get objects in he collector
+ AIS_ListOfInteractive ListCollector;
+ ic->ObjectsInCollector( ListCollector );
+
+ // get objects to be displayed
+ AIS_ListOfInteractive anAISObjects;
+ anOCCPrs->GetObjects( anAISObjects );
+
+ AIS_ListIteratorOfListOfInteractive aIter( anAISObjects );
+ for ( ; aIter.More(); aIter.Next() ) {
+ Handle(AIS_InteractiveObject) anAIS = aIter.Value();
+ if ( !anAIS.IsNull() ) {
+ // try to find presentation in the viewer
+ bool bDisplayed = false;
+ AIS_ListIteratorOfListOfInteractive ite( List );
+ while ( ite.More() ) {
+ // compare presentations by handles
+ // if the object is already displayed - nothing to do more
+ if ( ite.Value() == anAIS ) {
+
+ // Deactivate object if necessary
+ if ( !anOCCPrs->ToActivate() )
+ ic->Deactivate( anAIS );
+ bDisplayed = true;
+ break;
}
+ ite.Next();
+ }
+ if ( bDisplayed )
+ continue;
+ // then try to find presentation in the collector
+ bDisplayed = false;
+ ite.Initialize( ListCollector );
+ while ( ite.More() ) {
+ // compare presentations by handles
+ // if the object is in collector - display it
+ if ( ite.Value() == anAIS ) {
+ ic->DisplayFromCollector( anAIS, false );
+
+ // Deactivate object if necessary
+ if ( !anOCCPrs->ToActivate() )
+ ic->Deactivate( anAIS );
+ bDisplayed = true;
+ break;
+ }
+ ite.Next();
+ }
+ if ( bDisplayed )
+ continue;
+ // if object is not displayed and not found in the collector - display it
+ if ( anAIS->IsKind( STANDARD_TYPE(AIS_Trihedron) ) )
+ {
+ Handle(AIS_Trihedron) aTrh = Handle(AIS_Trihedron)::DownCast( anAIS );
+ double aNewSize = 100, aSize = 100;
+ getTrihedronSize( aNewSize, aSize );
+ aTrh->SetSize( aTrh == myViewer->getTrihedron() ? aNewSize : 0.5 * aNewSize );
+ }
+
+ ic->Display( anAIS, false );
+
+ // Deactivate object if necessary
+ if ( !anOCCPrs->ToActivate() )
+ ic->Deactivate( anAIS );
+ }
+ }
+}
+
+//==========================================================
+/*!
+ * OCCViewer_ViewFrame::Erase
+ * Erase presentation
+ */
+//==========================================================
+void OCCViewer_ViewFrame::Erase( const SALOME_OCCPrs* prs, const bool forced )
+{
+ // try do downcast object
+ const OCCViewer_Prs* anOCCPrs = dynamic_cast<const OCCViewer_Prs*>( prs );
+ if ( !anOCCPrs || anOCCPrs->IsNull() )
+ return;
+
+ // get context
+ Handle(AIS_InteractiveContext) ic = myViewer->getAISContext();
+
+ // get objects to be erased
+ AIS_ListOfInteractive anAISObjects;
+ anOCCPrs->GetObjects( anAISObjects );
+
+ AIS_ListIteratorOfListOfInteractive aIter( anAISObjects );
+ for ( ; aIter.More(); aIter.Next() ) {
+ Handle(AIS_InteractiveObject) anAIS = aIter.Value();
+ if ( !anAIS.IsNull() ) {
+ // erase the object from context : move it to collector
+ ic->Erase( anAIS, false, forced ? false : true );
+ }
+ }
+}
+
+//==========================================================
+/*!
+ * OCCViewer_ViewFrame::CreatePrs
+ * Create presentation by entry
+ */
+//==========================================================
+SALOME_Prs* OCCViewer_ViewFrame::CreatePrs( const char* entry )
+{
+ OCCViewer_Prs* prs = new OCCViewer_Prs();
+ if ( entry )
+ {
+ // get context
+ Handle(AIS_InteractiveContext) ic = myViewer->getAISContext();
+
+ // get displayed objects
+ AIS_ListOfInteractive List;
+ ic->DisplayedObjects( List );
+ // get objects in the collector
+ AIS_ListOfInteractive ListCollector;
+ ic->ObjectsInCollector( ListCollector );
+ List.Append( ListCollector );
+
+ AIS_ListIteratorOfListOfInteractive ite( List );
+ for ( ; ite.More(); ite.Next() )
+ {
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
+
+ if ( !anObj.IsNull() && anObj->hasEntry() && strcmp( anObj->getEntry(), entry ) == 0 )
+ prs->AddObject( ite.Value() );
}
+ }
+ return prs;
+}
+
+//==========================================================
+/*!
+ * OCCViewer_ViewFrame::LocalSelection
+ * Activates selection of sub shapes
+ */
+//==========================================================
+void OCCViewer_ViewFrame::LocalSelection( const SALOME_OCCPrs* thePrs, const int theMode )
+{
+ Handle(AIS_InteractiveContext) anIC = myViewer->getAISContext();
- Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)myViewPort)->getView();
+ const OCCViewer_Prs* anOCCPrs = dynamic_cast<const OCCViewer_Prs*>( thePrs );
+ if ( anIC.IsNull() )
+ return;
- if (!view3d.IsNull())
+ // Open local context if there is no one
+ bool allObjects = thePrs == 0 || thePrs->IsNull();
+ if ( !anIC->HasOpenedContext() ) {
+ anIC->ClearCurrents( false );
+ anIC->OpenLocalContext( allObjects, true, true );
+ }
+
+ AIS_ListOfInteractive anObjs;
+ // Get objects to be activated
+ if ( allObjects )
+ anIC->DisplayedObjects( anObjs );
+ else
+ anOCCPrs->GetObjects( anObjs );
+
+ // Activate selection of objects from prs
+ AIS_ListIteratorOfListOfInteractive aIter( anObjs );
+ for ( ; aIter.More(); aIter.Next() ) {
+ Handle(AIS_InteractiveObject) anAIS = aIter.Value();
+ if ( !anAIS.IsNull() )
{
- double Xmin=0, Ymin=0, Zmin=0, Xmax=0, Ymax=0, Zmax=0;
- double aMaxSide;
- double aPercents;
-
- view3d->View()->MinMaxValues(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
-
- if (Xmin==RealFirst() || Ymin==RealFirst() || Zmin==RealFirst() ||
- Xmax==RealLast() || Ymax==RealLast() || Zmax==RealLast())
- return;
-
- aMaxSide = Xmax - Xmin;
- if (aMaxSide < Ymax -Ymin) aMaxSide = Ymax -Ymin;
- if (aMaxSide < Zmax -Zmin) aMaxSide = Zmax -Zmin;
-
- static float aSizeInPercents = 105;
- QString aSetting = QAD_CONFIG->getSetting("Viewer:TrihedronSize");
- if (!aSetting.isEmpty()) aSizeInPercents = aSetting.toFloat();
-
- static float EPS = 5.0E-3;
- float aSize = myViewer->getTrihedron()->Size();
- float aNewSize = aMaxSide*aSizeInPercents/100.0;
- // if the new trihedron size have sufficient difference, then apply the value
- if(fabs(aNewSize-aSize) > aSize*EPS || fabs(aNewSize-aSize) > aNewSize*EPS)
- myViewer->setTrihedronSize(aNewSize);
+ if ( anAIS->IsKind( STANDARD_TYPE( AIS_Shape ) ) )
+ {
+ anIC->Load( anAIS, -1, false );
+ anIC->Activate( anAIS, AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)theMode ) );
+ }
+ else if ( anAIS->DynamicType() != STANDARD_TYPE(AIS_Trihedron) )
+ {
+ anIC->Load( anAIS, -1, false );
+ anIC->Activate( anAIS, theMode );
+ }
}
+ }
+}
+
+//==========================================================
+/*!
+ * OCCViewer_ViewFrame::GlobalSelection
+ * Deactivates selection of sub shapes
+ */
+//==========================================================
+void OCCViewer_ViewFrame::GlobalSelection( const bool update ) const
+{
+ Handle(AIS_InteractiveContext) anIC = myViewer->getAISContext();
+ if ( !anIC.IsNull() )
+ anIC->CloseAllContexts( false );
+ if ( update )
+ anIC->CurrentViewer()->Redraw();
+}
+
+//==========================================================
+/*!
+ * OCCViewer_ViewFrame::BeforeDisplay
+ * Axiluary method called before displaying of objects
+ */
+//==========================================================
+void OCCViewer_ViewFrame::BeforeDisplay( SALOME_Displayer* d )
+{
+ d->BeforeDisplay( this, SALOME_OCCViewType() );
+}
+
+//==========================================================
+/*!
+ * OCCViewer_ViewFrame::AfterDisplay
+ * Axiluary method called after displaying of objects
+ */
+//==========================================================
+void OCCViewer_ViewFrame::AfterDisplay( SALOME_Displayer* d )
+{
+ d->AfterDisplay( this, SALOME_OCCViewType() );
}
+
// File : OCCViewer_ViewFrame.h
// Author : Nicolas REJNERI
// Module : SALOME
-// $Header$
+// $Header$
#ifndef OCCViewer_ViewFrame_H
#define OCCViewer_ViewFrame_H
bool isVisible( const Handle(SALOME_InteractiveObject)& IObject );
/* undo/redo management */
- void undo(SALOMEDS::Study_var aStudy,
- const char* StudyFrameEntry);
- void redo(SALOMEDS::Study_var aStudy,
- const char* StudyFrameEntry);
+ void undo(QAD_Study* aStudy, const char* StudyFrameEntry);
+ void redo(QAD_Study* aStudy, const char* StudyFrameEntry);
/* selection */
Handle(SALOME_InteractiveObject) FindIObject(const char* Entry);
void EraseAll();
void Repaint();
+ /* Reimplemented from SALOME_View */
+ void Display( const SALOME_OCCPrs* );
+ void Erase( const SALOME_OCCPrs*, const bool = false );
+ SALOME_Prs* CreatePrs( const char* entry = 0 );
+ virtual void BeforeDisplay( SALOME_Displayer* d );
+ virtual void AfterDisplay ( SALOME_Displayer* d );
+ virtual void LocalSelection( const SALOME_OCCPrs*, const int );
+ virtual void GlobalSelection( const bool = false ) const;
+
+
+ void AdjustTrihedrons( const bool forced = false );
+
+ // Method for activation of sub-shapes selection
+
+
protected:
void closeEvent(QCloseEvent* e);
void resizeEvent(QResizeEvent* e);
void onViewTop();
void onViewTrihedron();
void onAdjustTrihedron();
+
+private:
+ bool getTrihedronSize( double& theNewSize, double& theSize );
protected:
OCCViewer_Viewer3d* myViewer; // my owner
// Module : SALOME
// $Header$
-using namespace std;
#include <stdlib.h>
#if !defined WNT
#include <qpixmap.h>
#include <qintdict.h>
+#include "utilities.h"
+
+using namespace std;
+
/* XPM */
const char* imageZoomCursor[] = {
"32 32 3 1",
#include <Geom_Axis2Placement.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopExp.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <NCollection_DefineBaseCollection.hxx>
+#include <NCollection_DefineDataMap.hxx>
+
+DEFINE_BASECOLLECTION( OCCViewer_CollectionOfIndexedMapOfShapes, TopTools_IndexedMapOfShape )
+DEFINE_DATAMAP( OCCViewer_MapOfIOIndexedMapOfShape, OCCViewer_CollectionOfIndexedMapOfShapes, Handle_SALOME_InteractiveObject, TopTools_IndexedMapOfShape)
+
+DEFINE_BASECOLLECTION( OCCViewer_CollectionOfMapOfInteger, TColStd_MapOfInteger )
+DEFINE_DATAMAP( OCCViewer_MapOfIOMapOfInteger, OCCViewer_CollectionOfMapOfInteger, Handle_SALOME_InteractiveObject, TColStd_MapOfInteger )
/*!
Constructor
return myTrihedron;
}
-void OCCViewer_Viewer3d::setTrihedronSize(float size)
+void OCCViewer_Viewer3d::setTrihedronSize( float size )
{
- myTrihedron->SetSize(size);
+ AIS_ListOfInteractive aList;
+ myAISContext->DisplayedObjects( aList );
+ myAISContext->ObjectsInCollector( aList );
+
+ AIS_ListIteratorOfListOfInteractive anIter( aList );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ Handle(AIS_Trihedron) aTrh = Handle(AIS_Trihedron)::DownCast( anIter.Value() );
+ if ( !aTrh.IsNull() )
+ aTrh->SetSize( aTrh == myTrihedron ? size : 0.5 *size );
+ }
+
myAISContext->UpdateCurrentViewer();
}
myAISContext->DisplayedObjects(List);
AIS_ListIteratorOfListOfInteractive ite(List);
- while (ite.More()) {
- if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISShape))) {
- Handle(SALOME_AISShape) aSh =
- Handle(SALOME_AISShape)::DownCast(ite.Value());
+ while (ite.More())
+ {
+ if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISShape)))
+ {
+ Handle(SALOME_AISShape) aSh = Handle(SALOME_AISShape)::DownCast(ite.Value());
- if ( aSh->hasIO() ) {
- Handle(SALOME_InteractiveObject) IO = aSh->getIO();
- if ( IO->isSame( IObject ) ) {
- aSh->setName( strdup(newName.latin1()) );
- break;
- }
+ if ( aSh->hasIO() )
+ {
+ Handle(SALOME_InteractiveObject) IO = aSh->getIO();
+ if ( IO->isSame( IObject ) )
+ {
+ char* aCopyName = CORBA::string_dup(newName.latin1());
+ aSh->setName( aCopyName );
+ delete( aCopyName );
+ break;
+ }
}
- } else if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISObject))) {
- Handle(SALOME_AISObject) aSh =
- Handle(SALOME_AISObject)::DownCast(ite.Value());
+ }
+ else if ( ite.Value()->IsKind( STANDARD_TYPE( SALOME_AISObject ) ) )
+ {
+ Handle(SALOME_AISObject) aSh = Handle(SALOME_AISObject)::DownCast( ite.Value() );
// Add code here, if someone create a MODULE_AISObject.
}
myAISContext->DisplayedObjects(List);
AIS_ListIteratorOfListOfInteractive ite(List);
- while (ite.More()) {
- if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISShape))) {
- Handle(SALOME_AISShape) aSh =
- Handle(SALOME_AISShape)::DownCast(ite.Value());
-
- if ( aSh->hasIO() ) {
- Handle(SALOME_InteractiveObject) IO = aSh->getIO();
- if ( IO->isSame( IObject ) ) {
- Quantity_Color CSFColor = Quantity_Color ( thecolor.red()/255., thecolor.green()/255., thecolor.blue()/255., Quantity_TOC_RGB );
- aSh->SetColor ( CSFColor );
- // aSh->SetShadingColor ( CSFColor );
- break;
- }
- }
- } else if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISObject))) {
- Handle(SALOME_AISObject) aSh =
- Handle(SALOME_AISObject)::DownCast(ite.Value());
-
- // Add code here, if someone create a MODULE_AISObject.
+ for ( ; ite.More(); ite.Next() )
+ {
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
+
+ if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( IObject ) )
+ {
+ Quantity_Color CSFColor = Quantity_Color ( thecolor.red() / 255.,
+ thecolor.green() / 255.,
+ thecolor.blue() / 255.,
+ Quantity_TOC_RGB );
+ ite.Value()->SetColor( CSFColor );
+ break;
}
- ite.Next();
}
+
myV3dViewer->Update();
}
-void OCCViewer_Viewer3d::SwitchRepresentation(const Handle(SALOME_InteractiveObject)& IObject,
- int mode)
+void OCCViewer_Viewer3d::SwitchRepresentation( const Handle(SALOME_InteractiveObject)& IObject,
+ int mode )
{
AIS_ListOfInteractive List;
myAISContext->DisplayedObjects(List);
AIS_ListIteratorOfListOfInteractive ite(List);
- while (ite.More()) {
- if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISShape))) {
- Handle(SALOME_AISShape) aSh =
- Handle(SALOME_AISShape)::DownCast(ite.Value());
-
- if ( aSh->hasIO() ) {
- Handle(SALOME_InteractiveObject) IO = aSh->getIO();
- if ( IO->isSame( IObject ) ) {
- myAISContext->SetDisplayMode(aSh,Standard_Integer(mode),true);
- }
- }
- } else if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISObject))) {
- Handle(SALOME_AISObject) aSh =
- Handle(SALOME_AISObject)::DownCast(ite.Value());
-
- // Add code here, if someone create a MODULE_AISObject.
- }
- ite.Next();
+ for ( ; ite.More(); ite.Next() )
+ {
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
+
+ if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( IObject ) )
+ myAISContext->SetDisplayMode( ite.Value(), (Standard_Integer)mode ,true );
}
+
myV3dViewer->Update();
}
-void OCCViewer_Viewer3d::SetTransparency(const Handle(SALOME_InteractiveObject)& IObject,
- float transp)
+void OCCViewer_Viewer3d::SetTransparency( const Handle(SALOME_InteractiveObject)& IObject,
+ float transp )
{
AIS_ListOfInteractive List;
- myAISContext->DisplayedObjects(List);
+ myAISContext->DisplayedObjects( List );
- AIS_ListIteratorOfListOfInteractive ite(List);
- while (ite.More()) {
- if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISShape))) {
- Handle(SALOME_AISShape) aSh =
- Handle(SALOME_AISShape)::DownCast(ite.Value());
-
- if ( aSh->hasIO() ) {
- Handle(SALOME_InteractiveObject) IO = aSh->getIO();
- if ( IO->isSame( IObject ) ) {
- myAISContext->SetTransparency( aSh, transp, false );
- myAISContext->Redisplay( aSh, Standard_False, Standard_True );
- }
- }
- } else if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISObject))) {
- Handle(SALOME_AISObject) aSh =
- Handle(SALOME_AISObject)::DownCast(ite.Value());
-
- // Add code here, if someone create a MODULE_AISObject.
+ AIS_ListIteratorOfListOfInteractive ite( List );
+ for ( ; ite.More(); ite.Next() )
+ {
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
+
+ if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( IObject ) )
+ {
+ myAISContext->SetTransparency( ite.Value(), transp, false );
+ myAISContext->Redisplay( ite.Value(), Standard_False, Standard_True );
}
- ite.Next();
}
+
myV3dViewer->Update();
}
*/
bool OCCViewer_Viewer3d::highlight( const Handle(SALOME_InteractiveObject)& IObject, bool highlight, bool update )
{
+ bool isInLocal = myAISContext->HasOpenedContext();
+ QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
+ SALOME_Selection* Sel = SALOME_Selection::Selection( ActiveStudy->getSelection() );
+
AIS_ListOfInteractive List;
myAISContext->DisplayedObjects(List);
AIS_ListIteratorOfListOfInteractive ite(List);
- while (ite.More()) {
- if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISShape))) {
- Handle(SALOME_AISShape) aSh =
- Handle(SALOME_AISShape)::DownCast(ite.Value());
-
- if ( aSh->hasIO() ) {
- Handle(SALOME_InteractiveObject) IO = aSh->getIO();
- if ( IO->isSame( IObject ) ) {
- if ( highlight ) {
- if ( !myAISContext->IsSelected(aSh) )
- myAISContext->AddOrRemoveCurrentObject(aSh, false);
- } else {
- if ( myAISContext->IsSelected(aSh) )
- myAISContext->AddOrRemoveCurrentObject(aSh, false);
- }
- break;
- }
+ for ( ; ite.More(); ite.Next() )
+ {
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
+
+ if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( IObject ) )
+ {
+ if ( !isInLocal )
+ {
+ if ( highlight && !myAISContext->IsSelected( ite.Value() ) )
+ myAISContext->AddOrRemoveCurrentObject( ite.Value(), false );
+ else if ( !highlight && myAISContext->IsSelected( ite.Value() ) )
+ myAISContext->AddOrRemoveCurrentObject( ite.Value(), false );
}
- } else if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISObject))) {
- Handle(SALOME_AISObject) aSh =
- Handle(SALOME_AISObject)::DownCast(ite.Value());
-
- // Add code here, if someone create a MODULE_AISObject.
+ // highlight subshapes only when local selection is active
+ else
+ {
+ if ( ite.Value()->IsKind( STANDARD_TYPE( SALOME_AISShape ) ) )
+ {
+ Handle(SALOME_AISShape) aSh = Handle(SALOME_AISShape)::DownCast( ite.Value() );
+ TColStd_IndexedMapOfInteger MapIndex;
+ Sel->GetIndex( IObject, MapIndex );
+ aSh->highlightSubShapes( MapIndex, highlight );
+ }
+ }
+ break;
}
- ite.Next();
}
- if (update)
- myV3dViewer->Update();
+
+ if ( update )
+ myV3dViewer->Redraw();
+
return false;
}
*/
bool OCCViewer_Viewer3d::unHighlightAll()
{
- myAISContext->ClearCurrents();
+ if ( myAISContext->HasOpenedContext() )
+ myAISContext->ClearSelected();
+ else
+ myAISContext->ClearCurrents();
return false;
}
}
AIS_ListIteratorOfListOfInteractive ite(List);
- while (ite.More()) {
- if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISShape))) {
- Handle(SALOME_AISShape) aSh =
- Handle(SALOME_AISShape)::DownCast(ite.Value());
-
- if ( aSh->hasIO() ) {
- Handle(SALOME_InteractiveObject) IO = aSh->getIO();
- if ( IObject->isSame( IO ) ) {
- return true;
- }
- }
- } else if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISObject))) {
- Handle(SALOME_AISObject) aSh =
- Handle(SALOME_AISObject)::DownCast(ite.Value());
+ for ( ; ite.More(); ite.Next() )
+ {
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
- // Add code here, if someone create a MODULE_AISObject.
- }
- ite.Next();
+ if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( IObject ) )
+ return true;
}
return false;
}
bool OCCViewer_Viewer3d::isVisible( const Handle(SALOME_InteractiveObject)& IObject )
{
AIS_ListOfInteractive List;
- myAISContext->DisplayedObjects(List);
+ myAISContext->DisplayedObjects( List );
- AIS_ListIteratorOfListOfInteractive ite(List);
- while (ite.More()) {
- if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISShape))) {
- Handle(SALOME_AISShape) aSh =
- Handle(SALOME_AISShape)::DownCast(ite.Value());
-
- if ( aSh->hasIO() ) {
- Handle(SALOME_InteractiveObject) IO = aSh->getIO();
- if ( IObject->isSame( IO ) ) {
- return myAISContext->IsDisplayed(aSh);
- }
- }
- } else if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISObject))) {
- Handle(SALOME_AISObject) aSh =
- Handle(SALOME_AISObject)::DownCast(ite.Value());
+ AIS_ListIteratorOfListOfInteractive ite( List );
+ for ( ; ite.More(); ite.Next() )
+ {
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
- // Add code here, if someone create a MODULE_AISObject.
- }
- ite.Next();
+ if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( IObject ) )
+ return myAISContext->IsDisplayed( ite.Value() );
}
+
return false;
}
void OCCViewer_Viewer3d::onMouseMove( QMouseEvent* pe )
{
/* activate hilighting only if no MB pressed */
- if ( pe->state() == Qt::NoButton )
- {
- QAD_Application::getDesktop()->onMouseMove( pe );
-
- OCCViewer_ViewPort* vp = myViewFrame->getViewPort();
- myAISSelector->moveTo ( pe->x(), pe->y(), ((OCCViewer_ViewPort3d*)vp)->getView() );
- }
+ if ( ! ( pe->state() & ( Qt::LeftButton | Qt::MidButton | Qt::RightButton ) ) ) {
+ QAD_Application::getDesktop()->onMouseMove( pe );
+ OCCViewer_ViewPort* vp = myViewFrame->getViewPort();
+ myAISSelector->moveTo ( pe->x(), pe->y(), ((OCCViewer_ViewPort3d*)vp)->getView() );
+ }
}
/*!
{
emit vw3dSelectionDone( bAdded );
- QAD_Study* myActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
- QAD_StudyFrame* myActiveSFrame = myActiveStudy->getActiveStudyFrame();
- SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
- MESSAGE ( "OCCViewer_Viewer3d - NB SELECTED INTERACTIVE OBJECT : " << Sel->IObjectCount() )
+// QAD_Study* myActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
+// QAD_StudyFrame* myActiveSFrame = myActiveStudy->getActiveStudyFrame();
+ // SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
+// MESSAGE ( "OCCViewer_Viewer3d - NB SELECTED INTERACTIVE OBJECT : " << Sel->IObjectCount() )
- QString ActiveComp = QAD_Application::getDesktop()->getActiveComponent();
+ QString ActiveComp = QAD_Application::getDesktop()->getActiveComponent();
- if ( ActiveComp.isEmpty() ) {
+ if ( ActiveComp.isEmpty() )
+ {
unHighlightAll();
return;
}
+ if ( myAISContext->IndexOfCurrentLocal() <= 0 )
+ globalSelectionDone( bAdded );
+ else
+ localSelectionDone( bAdded );
+
+ myV3dViewer->Update();
+}
+
+/*!
+ Called when an object is selected and there is no opened local context
+*/
+void OCCViewer_Viewer3d::globalSelectionDone( const bool bAdded )
+{
+ SALOME_Selection* Sel = SALOME_Selection::Selection(
+ QAD_Application::getDesktop()->getActiveStudy()->getSelection() );
+
+ MESSAGE ( "OCCViewer_Viewer3d - NB SELECTED INTERACTIVE OBJECT : " << Sel->IObjectCount() )
+
SALOME_ListIO DeltaPos;
DeltaPos.Clear();
SALOME_ListIO DeltaNeg;
DeltaNeg.Clear();
- if ( !bAdded ) { /* select */
- myAISContext->InitCurrent();
- while (myAISContext->MoreCurrent()) {
- if (myAISContext->Current()->IsKind(STANDARD_TYPE(SALOME_AISShape))) {
- Handle(SALOME_AISShape) aSh =
- Handle(SALOME_AISShape)::DownCast(myAISContext->Current());
-
- if ( aSh->hasIO() ) {
- Handle( SALOME_InteractiveObject) IO = aSh->getIO();
-
- bool itemAllreadySelected = false;
- int nbSel = Sel->IObjectCount();
- if ( nbSel == 0 ) {
- DeltaPos.Append( IO );
- } else {
- SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
- for(;It.More();It.Next()) {
- Handle( SALOME_InteractiveObject) IO1 = It.Value();
- if ( IO->isSame( IO1 ) ) {
- itemAllreadySelected = true;
- break;
- }
- }
- if (!itemAllreadySelected)
- DeltaPos.Append( IO );
- }
+ if ( !bAdded )
+ {
+ for ( myAISContext->InitCurrent(); myAISContext->MoreCurrent(); myAISContext->NextCurrent() )
+ {
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( myAISContext->Current()->GetOwner() );
+
+ if ( !anObj.IsNull() )
+ {
+ bool itemAllreadySelected = false;
+ int nbSel = Sel->IObjectCount();
+ if ( nbSel == 0 )
+ DeltaPos.Append( anObj );
+ else
+ {
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ for( ; It.More(); It.Next() )
+ {
+ Handle( SALOME_InteractiveObject) IO1 = It.Value();
+ if ( anObj->isSame( IO1 ) )
+ {
+ itemAllreadySelected = true;
+ break;
+ }
+ }
+ if ( !itemAllreadySelected )
+ DeltaPos.Append( anObj );
}
- } else if (myAISContext->Current()->IsKind(STANDARD_TYPE(SALOME_AISObject))) {
- Handle(SALOME_AISObject) aSh =
- Handle(SALOME_AISObject)::DownCast(myAISContext->Current());
-
- // Add code here, if someone create a MODULE_AISObject.
}
- myAISContext->NextCurrent();
+ else if ( myAISContext->Current()->IsKind( STANDARD_TYPE( SALOME_AISObject ) ) )
+ {
+ //Handle(SALOME_AISObject) aSh =
+ // Handle(SALOME_AISObject)::DownCast( myAISContext->Current() );
+ // Add code here, if someone create a MODULE_AISObject.
+ }
}
if ( DeltaPos.Extent() > 0 )
Sel->ClearIObjects();
-
- } else { /* shift select */
+
+ }
+ else
+ { /* shift select */
SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
- for(;It.More();It.Next()) {
+ for ( ;It.More(); It.Next() )
+ {
Handle( SALOME_InteractiveObject) IO1 = It.Value();
bool itemAllreadySelected = false;
- myAISContext->InitCurrent();
- while (myAISContext->MoreCurrent()) {
- if (myAISContext->Current()->IsKind(STANDARD_TYPE(SALOME_AISShape))) {
- Handle(SALOME_AISShape) aSh =
- Handle(SALOME_AISShape)::DownCast(myAISContext->Current());
- if ( aSh->hasIO() ) {
- Handle( SALOME_InteractiveObject) IO = aSh->getIO();
-
- if ( IO->isSame( IO1 ) ) {
- itemAllreadySelected = true;
- break;
- }
- }
- } else if (myAISContext->Current()->IsKind(STANDARD_TYPE(SALOME_AISObject))) {
- Handle(SALOME_AISObject) aSh =
- Handle(SALOME_AISObject)::DownCast(myAISContext->Current());
-
- // Add code here, if someone create a MODULE_AISObject.
- }
- myAISContext->NextCurrent();
+ for ( myAISContext->InitCurrent(); myAISContext->MoreCurrent(); myAISContext->NextCurrent() )
+ {
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( myAISContext->Current()->GetOwner() );
+
+ if ( !anObj.IsNull() && anObj->isSame( IO1 ) )
+ {
+ itemAllreadySelected = true;
+ break;
+ }
+ else if ( myAISContext->Current()->IsKind( STANDARD_TYPE( SALOME_AISObject ) ) )
+ {
+ //Handle(SALOME_AISObject) aSh =
+ // Handle(SALOME_AISObject)::DownCast(myAISContext->Current());
+ // Add code here, if someone create a MODULE_AISObject.
+ }
}
- if (!itemAllreadySelected)
- DeltaNeg.Append( IO1 );
+ if ( !itemAllreadySelected )
+ DeltaNeg.Append( IO1 );
}
myAISContext->InitCurrent();
- while (myAISContext->MoreCurrent()) {
- if (myAISContext->Current()->IsKind(STANDARD_TYPE(SALOME_AISShape))) {
- Handle(SALOME_AISShape) aSh =
- Handle(SALOME_AISShape)::DownCast(myAISContext->Current());
- if ( aSh->hasIO() ) {
- Handle( SALOME_InteractiveObject) IO = aSh->getIO();
-
- bool itemAllreadySelected = false;
- SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
- for(;It.More();It.Next()) {
- Handle( SALOME_InteractiveObject) IO1 = It.Value();
-
- if ( IO->isSame( IO1 ) ) {
- itemAllreadySelected = true;
- break;
- }
- }
-
- if (!itemAllreadySelected )
- DeltaPos.Append( IO );
- }
- } else if ( myAISContext->Current()->IsKind(STANDARD_TYPE(SALOME_AISObject))) {
- Handle(SALOME_AISObject) aSh =
- Handle(SALOME_AISObject)::DownCast(myAISContext->Current());
-
- // Add code here, if someone create a MODULE_AISObject.
+ for ( myAISContext->InitCurrent(); myAISContext->MoreCurrent(); myAISContext->NextCurrent() )
+ {
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( myAISContext->Current()->GetOwner() );
+
+ if ( !anObj.IsNull() )
+ {
+ bool itemAllreadySelected = false;
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ for ( ;It.More(); It.Next() )
+ {
+ Handle( SALOME_InteractiveObject) IO1 = It.Value();
+
+ if ( anObj->isSame( IO1 ) )
+ {
+ itemAllreadySelected = true;
+ break;
+ }
+ }
+
+ if ( !itemAllreadySelected )
+ DeltaPos.Append( anObj );
+ }
+ else if ( myAISContext->Current()->IsKind(STANDARD_TYPE(SALOME_AISObject)))
+ {
+ //Handle(SALOME_AISObject) aSh =
+ // Handle(SALOME_AISObject)::DownCast(myAISContext->Current());
+ // Add code here, if someone create a MODULE_AISObject.
}
- myAISContext->NextCurrent();
}
}
-
+
// MESSAGE ( "VIEWER onSelectionDone DeltaNeg.count() == " << DeltaNeg.count() )
SALOME_ListIteratorOfListIO ItNeg( DeltaNeg );
- for(;ItNeg.More();ItNeg.Next()) {
+ for( ;ItNeg.More();ItNeg.Next() )
+ {
Sel->RemoveIObject( ItNeg.Value(), false );
}
-
+
// MESSAGE ( "VIEWER onSelectionDone DeltaPos.count() == " << DeltaPos.Extent() )
SALOME_ListIteratorOfListIO ItPos( DeltaPos );
- for(;ItPos.More();ItPos.Next()) {
+ for ( ;ItPos.More();ItPos.Next() )
+ {
Sel->AddIObject( ItPos.Value(), false );
- }
- myV3dViewer->Update();
+ }
+}
+
+/*!
+ Called when an object is selected and there is opened local context
+*/
+void OCCViewer_Viewer3d::localSelectionDone( const bool /*bAdded*/ )
+{
+ SALOME_Selection* aSelection = SALOME_Selection::Selection(
+ QAD_Application::getDesktop()->getActiveStudy()->getSelection() );
+
+ aSelection->BlockSignals( true );
+
+ OCCViewer_MapOfIOIndexedMapOfShape aMapsOfShapes; // SALOME_InteractiveObject <--> TopTools_IndexedMapOfShape
+ OCCViewer_MapOfIOMapOfInteger aMapsOfIndexes; // SALOME_InteractiveObject <--> TColStd_MapOfInteger
+
+
+ // Iterate through selected objects and add them to selection
+ for( myAISContext->InitSelected(); myAISContext->MoreSelected(); myAISContext->NextSelected() )
+ {
+ // Retrive selected shape and subshape
+ Handle(SelectMgr_EntityOwner) anOwner = myAISContext->SelectedOwner();
+ if ( anOwner.IsNull() )
+ continue;
+
+ Handle(AIS_InteractiveObject) anIO =
+ Handle(AIS_InteractiveObject)::DownCast( myAISContext->SelectedInteractive() );
+ if ( anIO.IsNull() )
+ continue;
+
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( anIO->GetOwner() );
+ if ( anObj.IsNull() )
+ continue;
+
+ if ( anIO->IsKind( STANDARD_TYPE( AIS_Shape ) ) )
+ {
+ Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast( anIO );
+ TopoDS_Shape aShape = anAISShape->Shape();
+ TopoDS_Shape aSubShape = anOwner->Shape();
+ if ( aShape.IsNull() || aSubShape.IsNull() )
+ continue;
+
+ // Get index of selected shape
+ if ( aMapsOfShapes.IsBound( anObj ) )
+ {
+ const TopTools_IndexedMapOfShape& aShapes = aMapsOfShapes( anObj );
+ int anIndex = aShapes.FindIndex( aSubShape );
+
+ aMapsOfIndexes( anObj ).Add( anIndex );
+ }
+ else
+ {
+ TopTools_IndexedMapOfShape aShapes;
+ TopExp::MapShapes( aShape, aShapes );
+ int anIndex = aShapes.FindIndex( aSubShape );
+
+ TColStd_MapOfInteger anIndexes;
+ anIndexes.Add( anIndex );
+
+ aMapsOfShapes.Bind( anObj, aShapes );
+ aMapsOfIndexes.Bind( anObj, anIndexes );
+ }
+ }
+ else
+ {
+ aMapsOfShapes.Bind( anObj, TopTools_IndexedMapOfShape() );
+ aMapsOfIndexes.Bind( anObj, TColStd_MapOfInteger() );
+ }
+ }
+
+ // Clear selection
+ aSelection->ClearIObjects();
+
+ // Add object in selection
+ OCCViewer_MapOfIOMapOfInteger::Iterator anIter( aMapsOfIndexes );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ if ( anIter.Value().IsEmpty() )
+ aSelection->AddIObject( anIter.Key(), false );
+ else
+ {
+ aSelection->AddIObject( anIter.Key(), false );
+ aSelection->AddOrRemoveIndex( anIter.Key(), anIter.Value(), false, false );
+ }
+ }
+
+ aSelection->BlockSignals( false );
+ aSelection->SelectionChanged();
}
/*!
{
emit vw3dSelectionCancel();
- QAD_Study* myActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
- QAD_StudyFrame* myActiveSFrame = myActiveStudy->getActiveStudyFrame();
- SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
-
- // MESSAGE ( "OCCViewer_Viewer3d - NB SELECTED INTERACTIVE OBJECT : " << Sel->IObjectCount() )
+ QAD_Study* myActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
+ SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
SALOME_ListIO DeltaPos;
DeltaPos.Clear();
SALOME_ListIO DeltaNeg;
DeltaNeg.Clear();
- if (!bAdded) { /* select */
+
+ if ( !bAdded )
+ { /* select */
Sel->ClearIObjects();
- } else { /* shiftselect */
+ }
+ else
+ { /* shiftselect */
SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
- for(;It.More();It.Next()) {
+ for ( ; It.More(); It.Next() )
+ {
Handle( SALOME_InteractiveObject) IO1 = It.Value();
bool itemAllreadySelected = false;
myAISContext->InitCurrent();
- while (myAISContext->MoreCurrent()) {
- if (myAISContext->Current()->IsKind(STANDARD_TYPE(SALOME_AISShape))) {
- Handle(SALOME_AISShape) aSh =
- Handle(SALOME_AISShape)::DownCast(myAISContext->Current());
- if ( aSh->hasIO() ) {
- Handle( SALOME_InteractiveObject) IO = aSh->getIO();
- if ( IO->isSame(IO1) ) {
- itemAllreadySelected = true;
- break;
- }
- }
- } else if (myAISContext->Current()->IsKind(STANDARD_TYPE(SALOME_AISObject))) {
- Handle(SALOME_AISObject) aSh =
- Handle(SALOME_AISObject)::DownCast(myAISContext->Current());
-
- // Add code here, if someone create a MODULE_AISObject.
- }
- myAISContext->NextCurrent();
+ for ( myAISContext->InitCurrent(); myAISContext->MoreCurrent(); myAISContext->NextCurrent() )
+ {
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( myAISContext->Current()->GetOwner() );
+
+ if ( !anObj.IsNull() && anObj->isSame( IO1 ) )
+ {
+ itemAllreadySelected = true;
+ break;
+ }
+ else if ( myAISContext->Current()->IsKind( STANDARD_TYPE( SALOME_AISObject ) ) )
+ {
+ Handle(SALOME_AISObject) aSh =
+ Handle(SALOME_AISObject)::DownCast(myAISContext->Current());
+ // Add code here, if someone create a MODULE_AISObject.
+ }
}
// only if isknown
- if (!itemAllreadySelected)
- DeltaNeg.Append( IO1 );
+ if ( !itemAllreadySelected )
+ DeltaNeg.Append( IO1 );
}
}
// MESSAGE ( "VIEWER onSelectionCancel DeltaNeg.count() == " << DeltaNeg.Extent() )
SALOME_ListIteratorOfListIO ItNeg( DeltaNeg );
- for(;ItNeg.More();ItNeg.Next()) {
+ for ( ; ItNeg.More(); ItNeg.Next() )
Sel->RemoveIObject( ItNeg.Value(), false);
- }
+
myV3dViewer->Update();
}
protected:
OCCViewer_ViewFrame* myViewFrame;
+private:
+
+ void globalSelectionDone( const bool );
+ void localSelectionDone ( const bool );
+
Handle (AIS_InteractiveContext) myAISContext;
OCCViewer_AISSelector* myAISSelector;
bool myEnableSelection;
EXPORT_HEADERS = \
qsplitterP.h \
qworkspaceP.h \
- qactionP.h
+ qactionP.h \
+ qfiledialogP.h
# Libraries targets
LIB = libqsplitterP.la
-LIB_SRC = qsplitterP.cxx qsplitterP_moc.cxx qworkspaceP.cxx qworkspaceP_moc.cxx qactionP.cxx qactionP_moc.cxx
+LIB_SRC = qsplitterP.cxx qsplitterP_moc.cxx qworkspaceP.cxx qworkspaceP_moc.cxx qactionP.cxx qactionP_moc.cxx qfiledialogP.cxx qfiledialogP_moc.cxx
qsplitterP_moc.cxx: $(inc_builddir)/qsplitterP.h
$(MOC) $(inc_builddir)/qsplitterP.h -o qsplitterP_moc.cxx
qactionP_moc.cxx: $(inc_builddir)/qactionP.h
$(MOC) $(inc_builddir)/qactionP.h -o qactionP_moc.cxx
+qfiledialogP_moc.cxx: $(inc_builddir)/qfiledialogP.h
+ $(MOC) $(inc_builddir)/qfiledialogP.h -o qfiledialogP_moc.cxx
+
CPPFLAGS+=$(QT_INCLUDES) -I${QTDIR}/src/kernel -I$(QTDIR)/mkspecs/linux-g++
CXXFLAGS+=
LDFLAGS+=$(QT_MT_LIBS)
-// SALOME PatchQt : patch for Qt
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
-// File : qactionP.cxx
-// Author : Vadim SANDLER
-// Module : SALOME
-// $Header$
+/////////////////////////////////////////////////////////////////////////////
+// Module : PatchQt
+// File : qactionP.cxx
+// Description : the patch for Qt's QAction class (qaction.cpp)
+/////////////////////////////////////////////////////////////////////////////
+
+/****************************************************************************
+** $Id$
+**
+** Implementation of QAction class
+**
+** Created : 000000
+**
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of the widgets module of the Qt GUI Toolkit.
+**
+** This file may be distributed under the terms of the Q Public License
+** as defined by Trolltech AS of Norway and appearing in the file
+** LICENSE.QPL included in the packaging of this file.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
+** licenses may use this file in accordance with the Qt Commercial License
+** Agreement provided with the Software.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
+** information about Qt Commercial License Agreements.
+** See http://www.trolltech.com/qpl/ for QPL licensing information.
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
#include "qactionP.h"
-// SALOME PatchQt : patch for Qt
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
-// File : qactionP.h
-// Author : Vadim SANDLER
-// Module : SALOME
-// $Header$
+/////////////////////////////////////////////////////////////////////////////
+// Module : PatchQt
+// File : qactionP.h
+// Description : the patch for Qt's QAction class (qaction.h)
+/////////////////////////////////////////////////////////////////////////////
+
+/****************************************************************************
+** $Id$
+**
+** Definition of QAction class
+**
+** Created : 000000
+**
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of the widgets module of the Qt GUI Toolkit.
+**
+** This file may be distributed under the terms of the Q Public License
+** as defined by Trolltech AS of Norway and appearing in the file
+** LICENSE.QPL included in the packaging of this file.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
+** licenses may use this file in accordance with the Qt Commercial License
+** Agreement provided with the Software.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
+** information about Qt Commercial License Agreements.
+** See http://www.trolltech.com/qpl/ for QPL licensing information.
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
#ifndef QACTIONP_H
#define QACTIONP_H
-// SALOME PatchQt : patch for Qt
-//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : qsplitterP.cxx
-// Module : SALOME
+/////////////////////////////////////////////////////////////////////////////
+// Module : PatchQt
+// File : qsplitterP.cxx
+// Description : the patch for Qt's QSplitter class (qsplitter.cpp)
+/////////////////////////////////////////////////////////////////////////////
-using namespace std;
/****************************************************************************
** $Id$
**
** not clear to you.
**
**********************************************************************/
+
+using namespace std;
#include "qsplitterP.h"
#ifndef QT_NO_COMPLEXWIDGETS
-// SALOME PatchQt : patch for Qt
-//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : qsplitterP.h
-// Module : SALOME
+/////////////////////////////////////////////////////////////////////////////
+// Module : PatchQt
+// File : qsplitterP.h
+// Description : the patch for Qt's QSplitter class (qsplitter.h)
+/////////////////////////////////////////////////////////////////////////////
/****************************************************************************
** $Id$
QSplitterPHandle* getHandleBefore(QWidget* w);
// VSR 21/11/02 <- ================================
+// ASL 07/09/04
+ bool isCompressed( const QWidget* ) const;
+// ASL 07/09/04
+
protected:
void childEvent( QChildEvent * );
int idAfter( QWidget* ) const;
QWidget* widgetBefore( int id ) const;
QWidget* widgetAfter( int id ) const;
- bool isCompressed(const QWidget*) const;
+
QSize minSize( const QWidget *w ) const;
QSize maxSize( const QWidget *w ) const;
-// SALOME PatchQt : patch for Qt
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
-// File : qworkspaceP.cxx
-// Author : Vadim SANDLER
-// Module : SALOME
-// $Header$
+/////////////////////////////////////////////////////////////////////////////
+// Module : PatchQt
+// File : qworkspaceP.cxx
+// Description : the patch for Qt's QWorkspace class (qworkspace.cpp)
+/////////////////////////////////////////////////////////////////////////////
+
+/****************************************************************************
+** $Id$
+**
+** Implementation of the QWorkspace class
+**
+** Created : 931107
+**
+** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+**
+** This file is part of the workspace module of the Qt GUI Toolkit.
+**
+** This file may be distributed under the terms of the Q Public License
+** as defined by Trolltech AS of Norway and appearing in the file
+** LICENSE.QPL included in the packaging of this file.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** Licensees holding valid Qt Enterprise Edition licenses may use this
+** file in accordance with the Qt Commercial License Agreement provided
+** with the Software.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
+** information about Qt Commercial License Agreements.
+** See http://www.trolltech.com/qpl/ for QPL licensing information.
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
using namespace std;
#include "qworkspaceP.h"
-// SALOME PatchQt : patch for Qt
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
-// File : qworkspaceP.h
-// Author : Vadim SANDLER
-// Module : SALOME
-// $Header$
+/////////////////////////////////////////////////////////////////////////////
+// Module : PatchQt
+// File : qworkspaceP.h
+// Description : the patch for Qt's QWorkspace class (qworkspace.h)
+/////////////////////////////////////////////////////////////////////////////
+
+/****************************************************************************
+** $Id$
+**
+** Definition of the QWorkspace class
+**
+** Created : 990210
+**
+** Copyright (C) 1999-2000 Trolltech AS. All rights reserved.
+**
+** This file is part of the workspace module of the Qt GUI Toolkit.
+**
+** This file may be distributed under the terms of the Q Public License
+** as defined by Trolltech AS of Norway and appearing in the file
+** LICENSE.QPL included in the packaging of this file.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** Licensees holding valid Qt Enterprise Edition licenses may use this
+** file in accordance with the Qt Commercial License Agreement provided
+** with the Software.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
+** information about Qt Commercial License Agreements.
+** See http://www.trolltech.com/qpl/ for QPL licensing information.
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
#ifndef QWORKSPACEP_H
#define QWORKSPACEP_H
Plot2d_ViewFrame.h \
Plot2d_SetupViewDlg.h \
Plot2d_SetupPlot2dDlg.h \
- Plot2d_FitDataDlg.h
+ Plot2d_FitDataDlg.h \
+ Plot2d_Prs.h
# .po files to transform in .qm
#PO_FILES = \
Plot2d_ViewFrame.cxx \
Plot2d_SetupViewDlg.cxx \
Plot2d_SetupPlot2dDlg.cxx \
- Plot2d_FitDataDlg.cxx
+ Plot2d_FitDataDlg.cxx \
+ Plot2d_Prs.cxx
LIB_MOC = \
Plot2d.h \
SALOME_Exception.idl
CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(OGL_INCLUDES) $(PYTHON_INCLUDES) $(QWT_INCLUDES)
-LDFLAGS+=$(QT_MT_LIBS) $(OGL_LIBS) $(QWT_LIBS) -lSalomeGUI
+LDFLAGS+=$(QT_MT_LIBS) $(OGL_LIBS) $(QWT_LIBS) -lSalomePrs -lSalomeGUI
@CONCLUDE@
/*!
Returns true if contains no curves
*/
-bool Plot2d_CurveContainer::isEmpty()
+bool Plot2d_CurveContainer::isEmpty() const
{
return myCurves.isEmpty();
}
void removeCurve( const int index, bool alsoDelete = false ) ;
void clear( bool alsoDelete = false );
int count();
- bool isEmpty();
+ bool isEmpty() const;
Plot2d_Curve* curve( const int index );
private:
#include <qcolordialog.h>
#include <qspinbox.h>
+#include "utilities.h"
+
+using namespace std;
+
#define DLG_SIZE_WIDTH 500
#define DLG_SIZE_HEIGHT 400
#define MAX_LINE_WIDTH 100
frameLayout->addWidget( item->myVBtn, row, 1 );
frameLayout->addWidget( item->myTitleLab, row, 3 );
if ( rowTitles->length() > 0 )
- item->myTitleLab->setText( QString( strdup( rowTitles[ i ] ) ) );
+ item->myTitleLab->setText( QString( rowTitles[ i ] ) );
frameLayout->addWidget( item->myUnitLab, row, 5 );
if ( rowUnits->length() > 0 )
- item->myUnitLab->setText( QString( strdup( rowUnits[ i ] ) ) );
+ item->myUnitLab->setText( QString( rowUnits[ i ] ) );
frameLayout->addWidget( item->myAutoCheck, row, 7 );
frameLayout->addWidget( item->myLineCombo, row, 8 );
frameLayout->addWidget( item->myLineSpin, row, 9 );
frameLayout->addWidget( item->myVBtn, row, 1 );
frameLayout->addWidget( item->myTitleLab, row, 3 );
if ( rowTitles->length() > 0 )
- item->myTitleLab->setText( QString( strdup( rowTitles[ i ] ) ) );
+ item->myTitleLab->setText( QString( rowTitles[ i ] ) );
frameLayout->addWidget( item->myUnitLab, row, 5 );
if ( rowUnits->length() > 0 )
- item->myUnitLab->setText( QString( strdup( rowUnits[ i ] ) ) );
+ item->myUnitLab->setText( QString( rowUnits[ i ] ) );
frameLayout->addWidget( item->myAutoCheck, row, 7 );
frameLayout->addWidget( item->myLineCombo, row, 8 );
frameLayout->addWidget( item->myLineSpin, row, 9 );
Plot2d_Curve* curve = new Plot2d_Curve();
// curve titles
if ( rowTitles->length() > 0 ) {
- curve->setHorTitle( strdup( rowTitles[ horIndex ] ) );
- curve->setVerTitle( strdup( rowTitles[ verIndex[i] ] ) );
+ curve->setHorTitle( QString( rowTitles[ horIndex ] ) );
+ curve->setVerTitle( QString( rowTitles[ verIndex[i] ] ) );
}
// curve units
if ( rowUnits->length() > 0 ) {
- curve->setHorUnits( strdup( rowUnits[ horIndex ] ) );
- curve->setVerUnits( strdup( rowUnits[ verIndex[i] ] ) );
+ curve->setHorUnits( QString( rowUnits[ horIndex ] ) );
+ curve->setVerUnits( QString( rowUnits[ verIndex[i] ] ) );
}
// curve data
int nbPoints = 0;
Plot2d_Curve* curve = new Plot2d_Curve();
// curve titles
if ( rowTitles->length() > 0 ) {
- curve->setHorTitle( strdup( rowTitles[ horIndex ] ) );
- curve->setVerTitle( strdup( rowTitles[ verIndex[i] ] ) );
+ curve->setHorTitle( QString( rowTitles[ horIndex ] ) );
+ curve->setVerTitle( QString( rowTitles[ verIndex[i] ] ) );
}
// curve units
if ( rowUnits->length() > 0 ) {
- curve->setHorUnits( strdup( rowUnits[ horIndex ] ) );
- curve->setVerUnits( strdup( rowUnits[ verIndex[i] ] ) );
+ curve->setHorUnits( QString( rowUnits[ horIndex ] ) );
+ curve->setVerUnits( QString( rowUnits[ verIndex[i] ] ) );
}
// curve data
int nbPoints = 0;
#include "Plot2d_ViewFrame.h"
#include "Plot2d_SetupViewDlg.h"
+#include "Plot2d_Prs.h"
+
#include "QAD_Desktop.h"
#include "QAD_ResourceMgr.h"
#include "QAD_FileDlg.h"
QSize( myMarkerSize, myMarkerSize ) ) );
}
myPlot->setCurveTitle( curveKey, curve->getVerTitle() );
+ myPlot->setCurveData( curveKey, curve->horData(), curve->verData(), curve->nbPoints() );
myPlot->curve( curveKey )->setEnabled( true );
updateTitles();
if ( update )
}
return false;
}
+
+//==========================================================
+/*!
+ * Plot2d_ViewFrame::Display
+ * Display presentation
+ */
+//==========================================================
+void Plot2d_ViewFrame::Display( const SALOME_Prs2d* prs )
+{
+ // try do downcast object
+ const Plot2d_Prs* aPlot2dPrs = dynamic_cast<const Plot2d_Prs*>( prs );
+ if ( !aPlot2dPrs || aPlot2dPrs->IsNull() )
+ return;
+
+ // display all curves from presentation
+ Plot2d_CurveContainer aCurves = aPlot2dPrs->GetObjects();
+ displayCurves( aCurves );
+}
+
+//==========================================================
+/*!
+ * Plot2d_ViewFrame::Erase
+ * Erase presentation
+ */
+//==========================================================
+void Plot2d_ViewFrame::Erase( const SALOME_Prs2d* prs, const bool )
+{
+ // try do downcast object
+ const Plot2d_Prs* aPlot2dPrs = dynamic_cast<const Plot2d_Prs*>( prs );
+ if ( !aPlot2dPrs || aPlot2dPrs->IsNull() )
+ return;
+
+ // erase all curves from presentation
+ Plot2d_CurveContainer aCurves = aPlot2dPrs->GetObjects();
+ eraseCurves( aCurves );
+}
+
+//==========================================================
+/*!
+ * Plot2d_ViewFrame::CreatePrs
+ * Create presentation by entry
+ */
+//==========================================================
+SALOME_Prs* Plot2d_ViewFrame::CreatePrs( const char* entry )
+{
+ Plot2d_Prs* prs = new Plot2d_Prs();
+ if ( entry ) {
+ QIntDictIterator<Plot2d_Curve> it( myCurves );
+ for ( ; it.current(); ++it ) {
+ if ( it.current()->hasIO() && !strcmp( it.current()->getIO()->getEntry(), entry ) ) {
+ prs->AddObject( it.current() );
+ }
+ }
+ }
+ return prs;
+}
+
+//==========================================================
+/*!
+ * Plot2d_ViewFrame::BeforeDisplay
+ * Axiluary method called before displaying of objects
+ */
+//==========================================================
+void Plot2d_ViewFrame::BeforeDisplay( SALOME_Displayer* d )
+{
+ d->BeforeDisplay( this, SALOME_Plot2dViewType() );
+}
+
+//==========================================================
+/*!
+ * Plot2d_ViewFrame::AfterDisplay
+ * Axiluary method called after displaying of objects
+ */
+//==========================================================
+void Plot2d_ViewFrame::AfterDisplay( SALOME_Displayer* d )
+{
+ d->AfterDisplay( this, SALOME_Plot2dViewType() );
+}
void EraseAll();
void Repaint();
+ /* Reimplemented from SALOME_View */
+ void Display( const SALOME_Prs2d* );
+ void Erase( const SALOME_Prs2d*, const bool = false );
+ SALOME_Prs* CreatePrs( const char* entry = 0 );
+ virtual void BeforeDisplay( SALOME_Displayer* d );
+ virtual void AfterDisplay ( SALOME_Displayer* d );
+
/* event filter */
bool eventFilter( QObject* o, QEvent* e );
connect( _refresh, SIGNAL( clicked() ), this, SLOT( slotListeSelect() ) );
QToolTip::add( _refresh, "", toolTipGroup(), tr("Immediately updates list of components") );
+ /* PAL5540 - this button is needless
QPushButton* help = new QPushButton( tr( "Help" ), topbar );
connect( help, SIGNAL( clicked() ), this, SLOT( slotHelp() ) );
QToolTip::add( help, "", toolTipGroup(), tr("Opens Help window") );
+ */
_interval = new QPushButton( tr( "Interval" ), topbar );
connect( _interval, SIGNAL( clicked() ), this, SLOT( slotSelectRefresh() ) );
// Module : SALOME
//$Header$
-using namespace std;
-#define WRITE_RESSOURCES_TYPE
#include "SALOME_RessourcesCatalog_Handler.hxx"
+#include "utilities.h"
+
+using namespace std;
+
+ListOfParserressources _ressources_list;
+
//----------------------------------------------------------------------
//Function : SALOME_RessourcesCatalog_Handler
//Purpose: Constructor
#ifndef SALOME_RESSOURCES_CATALOG_HANDLER
#define SALOME_RESSOURCES_CATALOG_HANDLER
-#include "utilities.h"
#include "SALOME_RessourcesCatalog_Parser.hxx"
+
#include <qxml.h>
#include <string>
#include <vector>
private :
QString errorProt;
- string content;
+ std::string content;
const char* test_computer;
const char* test_computer_name;
struct ParserProc{
long Parsernumber;
- string Parsermodel_name;
+ std::string Parsermodel_name;
float Parsercpu_mhz;
float Parsercache_size;
};
-typedef vector<ParserProc> ListOfParserProc;
+typedef std::vector<ParserProc> ListOfParserProc;
enum Parsercontainertype {Cpp, python, NP};
-typedef vector<Parsercontainertype> ListOfParserContainerType;
+typedef std::vector<Parsercontainertype> ListOfParserContainerType;
struct Parserressources{
- string Parsername;
- string ParserOS;
- string ParserOS_version;
+ std::string Parsername;
+ std::string ParserOS;
+ std::string ParserOS_version;
ListOfParserProc Parserprocs;
ListOfParserContainerType Parsercontainertype;
};
-typedef vector<Parserressources> ListOfParserressources;
+typedef std::vector<Parserressources> ListOfParserressources;
-#ifdef WRITE_RESSOURCES_TYPE
-ListOfParserressources _ressources_list;
-#else
extern ListOfParserressources _ressources_list;
-#endif
+
#endif //SALOME_RESSOURCES_CATALOG_PARSER
CPPFLAGS+=$(OCC_INCLUDES) $(HDF5_INCLUDES)
CXXFLAGS+=$(OCC_CXXFLAGS)
-LDFLAGS+= $(HDF5_LIBS) -lTOOLSDS -lSalomeNS -lSalomeHDFPersist -lOpUtil -lSALOMELocalTrace $(CAS_LDPATH) -lTKCAF -lTKStdSchema -lSalomeGenericObj -lSalomeLifeCycleCORBA
+LDFLAGS+= $(HDF5_LIBS) -lTOOLSDS -lSalomeNS -lSalomeHDFPersist -lOpUtil -lSALOMELocalTrace $(CAS_LDPATH) -lTKCAF -lTKBO -lTKStdSchema -lSalomeGenericObj -lSalomeLifeCycleCORBA
# _CS_gbo_090604 Ajout Spécifique Calibre 3, pour l'utilisation de la version 5.12 de la bibliothèque OCC.
# La bibliothèque OCC5.12 a été compilée sur Calibre 3 avec l'extention Xmu (impossible de compiler sans).
}
char* SALOMEDS_AttributeDrawable_i::Store() {
- return strdup(IsDrawable()?"1":"0");
+ return CORBA::string_dup(IsDrawable()?"1":"0");
}
void SALOMEDS_AttributeDrawable_i::Restore(const char* value) {
}
char* SALOMEDS_AttributeExpandable_i::Store() {
- return strdup(IsExpandable()?"1":"0");
+ return CORBA::string_dup(IsExpandable()?"1":"0");
}
void SALOMEDS_AttributeExpandable_i::Restore(const char* value) {
void SALOMEDS_AttributeName_i::SetValue(const char* value) {
CheckLocked();
- CORBA::String_var Str = CORBA::string_dup(value);
- Handle(TDataStd_Name)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str));
+ //CORBA::String_var Str = CORBA::string_dup(value);
+ //Handle(TDataStd_Name)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str));
+ Handle(TDataStd_Name)::DownCast(_myAttr)->Set(TCollection_ExtendedString((char*)value));
}
char* SALOMEDS_AttributeName_i::Store() {
}
char* SALOMEDS_AttributeOpened_i::Store() {
- return strdup(IsOpened()?"1":"0");
+ return CORBA::string_dup(IsOpened()?"1":"0");
}
void SALOMEDS_AttributeOpened_i::Restore(const char* value) {
}
void SALOMEDS_AttributePythonObject_i::Restore(const char* value) {
- char* aString = strdup(value);
+ char* aString = CORBA::string_dup(value);
SetObject(aString + 1, aString[0]=='s');
+ delete(aString);
}
// Module : SALOME
// $Header$
-using namespace std;
#include "SALOMEDS_AttributeReal_i.hxx"
#include "SALOMEDS_SObject_i.hxx"
+#include <sstream>
+
+using namespace std;
+
+static const char* write_double(double value)
+{
+ std::ostringstream os;
+ unsigned char* array = (unsigned char*)&value;
+ for(int i = 0; i < sizeof(double); i++) {
+ unsigned tmp = (unsigned short)array[i];
+ os << " " << tmp;
+ }
+ return os.str().c_str();
+}
+
+static double read_double(const char* str)
+{
+ std::istringstream is(str);
+ double value;
+ unsigned char* array = (unsigned char*)(&value);
+ for(int i = 0; i < sizeof(double); i++) {
+ unsigned tmp;
+ is >> tmp;
+ array[i] = (unsigned char)tmp;
+ }
+ return value;
+}
CORBA::Double SALOMEDS_AttributeReal_i::Value() {
return Handle(TDataStd_Real)::DownCast(_myAttr)->Get();
}
char* SALOMEDS_AttributeReal_i::Store() {
- char* RealVal = new char[25];
- sprintf(RealVal, "%f", Value());
- return RealVal;
+ // char* RealVal = new char[35];
+ // sprintf(RealVal, "%.20f", Value());
+ //return RealVal;
+ return (char*)write_double( (double)Value() );
}
void SALOMEDS_AttributeReal_i::Restore(const char* value) {
- char *err = NULL;
- CORBA::Double r = strtod(value, &err);
- if (err != value) SetValue(r);
+ //char *err = NULL;
+ //CORBA::Double r = strtod(value, &err);
+ //if (err != value) SetValue(r);
+ SetValue( read_double(value) );
}
+
}
char* SALOMEDS_AttributeSelectable_i::Store() {
- return strdup(IsSelectable()?"1":"0");
+ return CORBA::string_dup(IsSelectable()?"1":"0");
}
void SALOMEDS_AttributeSelectable_i::Restore(const char* value) {
void SALOMEDS_AttributeSequenceOfInteger_i::Restore(const char* value) {
Handle(TColStd_HSequenceOfInteger) CasCadeSeq = new TColStd_HSequenceOfInteger;
- char* aCopy = strdup(value);
+ char* aCopy = CORBA::string_dup(value);
char* adr = strtok(aCopy, " ");
while (adr) {
CORBA::Long l = atol(adr);
void SALOMEDS_AttributeSequenceOfReal_i::Restore(const char* value) {
Handle(TColStd_HSequenceOfReal) CasCadeSeq = new TColStd_HSequenceOfReal;
- char* aCopy = strdup(value);
+ char* aCopy = CORBA::string_dup(value);
char* adr = strtok(aCopy, " ");
char *err = NULL;
while (adr) {
void SALOMEDS_AttributeStudyProperties_i::SetUserName(const char* theName) {
CheckLocked();
Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
- aProp->SetFirstName(TCollection_ExtendedString(strdup(theName)));
+ aProp->SetFirstName((char*)theName);
}
char* SALOMEDS_AttributeStudyProperties_i::GetUserName() {
CORBA::Long theYear) {
CheckLocked();
Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
- aProp->SetUserName(strdup(theName));
+ aProp->SetUserName((char*)theName);
aProp->SetModificationDate((int)theMinute, (int)theHour, (int)theDay, (int)theMonth, (int)theYear);
}
void SALOMEDS_AttributeStudyProperties_i::GetModificationsList(SALOMEDS::StringSeq_out theNames,
}
void SALOMEDS_AttributeStudyProperties_i::Restore(const char* value) {
- char* aCopy = strdup(value);
+ char* aCopy = CORBA::string_dup(value);
if (aCopy[0] == 'f') SetCreationMode("from scratch");
else if (aCopy[0] == 'c') SetCreationMode("copy from");
else SetCreationMode("none");
Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr);
Handle(TDF_Data) DF = TDocStd_Document::Get(_myAttr->Label())->GetData();
- char* aCopy = strdup(value);
+ char* aCopy = CORBA::string_dup(value);
char* adr = strtok(aCopy, " ");
TDF_Label aLabel;
if (!aLabel.FindAttribute(aNode->ID(), aDepNode)) aDepNode = TDataStd_TreeNode::Set(aLabel, aNode->ID());
aNode->SetFirst(aDepNode);
}
+ delete(aCopy);
}
// defines for creation attributes objects
-//cout<<"*** Create new CORBA attribute for "<<#CORBA_Name<<endl;
+//MESSAGE("*** Create new CORBA attribute for "<<#CORBA_Name);
#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;
+//MESSAGE("Create New Attribute "<<#CORBA_Name);
#define __FindOrCreateAttribute(OCAF_Name, CORBA_Name) if (strcmp(aTypeOfAttribute, #CORBA_Name) == 0) { \
Handle(OCAF_Name) anAttr; \
if (!Lab.FindAttribute(OCAF_Name::GetID(), anAttr)) { \
return Attr->CORBA_Name::_this(); \
}
-//cout<<"Create New Attribute "<<#CORBA_Name<<endl;
+//MESSAGE("Create New Attribute "<<#CORBA_Name);
#define __FindOrCreateAttributeLocked(OCAF_Name, CORBA_Name) if (strcmp(aTypeOfAttribute, #CORBA_Name) == 0) { \
Handle(OCAF_Name) anAttr; \
if (!Lab.FindAttribute(OCAF_Name::GetID(), anAttr)) { \
if (!_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(),ior) )
return false;
TCollection_AsciiString ch(ior->Get());
- IOR = strdup(ch.ToCString());
+ IOR = CORBA::string_dup(ch.ToCString());
return true;
}
return _lab.Tag();
}
+//============================================================================
+/*! Function :
+ * Purpose :
+ */
+//============================================================================
+CORBA::Short SALOMEDS_SObject_i::Depth()
+{
+ return _lab.Depth();
+}
+
//============================================================================
/*! Function :
* Purpose :
virtual char* GetIOR();
virtual CORBA::Short Tag();
+ virtual CORBA::Short Depth();
static char* AttributeIDToType(Standard_GUID);
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] = 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_SALOME_CORBA_EXCEPTION("Unable to load component data",SALOME::BAD_PARAM);
+ throw HDFexception("Unable to load component");
}
delete(aDir);
if (isASCII) {
SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
aFilesToRemove->length(1);
- aFilesToRemove[0] = CORBA::string_dup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))]));
- SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true);
+ aFilesToRemove[0] = CORBA::string_dup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl).c_str())]));
+ SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aHDFUrl).c_str(), aFilesToRemove, true);
}
delete aHDFUrl;
}
if (isASCII) {
SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
aFilesToRemove->length(1);
- aFilesToRemove[0] = CORBA::string_dup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))]));
- SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true);
+ aFilesToRemove[0] = CORBA::string_dup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl).c_str())]));
+ SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aHDFUrl).c_str(), aFilesToRemove, true);
}
delete aHDFUrl;
if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true);
- return;
+ THROW_SALOME_CORBA_EXCEPTION("No persistent file Name found",SALOME::BAD_PARAM);
}
try {
Lab.ForgetAttribute(TDF_Reference::GetID());
- TDF_Label RefLab;
+ //SRN: 30 Aug, 2004 : fix from Ecole l'ete version
+
+ TDF_Label RefLab;
ASSERT(!CORBA::is_nil(theReferencedObject));
CORBA::String_var roid = theReferencedObject->GetID();
TDF_Tool::Label(_doc->GetData(),roid,RefLab);
-
- RemoveAttribute(theReferencedObject, "AttributeTarget");
- //if(!CORBA::is_nil(_callbackOnRemove) && Lab.IsDescendant(_doc->Main())) _callbackOnRemove->OnRemoveSObject(me);
+
+ Handle(SALOMEDS_TargetAttribute) aTarget;
+ if(RefLab.FindAttribute(SALOMEDS_TargetAttribute::GetID(), aTarget)) aTarget->Remove(Lab);
}
//============================================================================
CORBA::Boolean SALOMEDS_StudyBuilder_i::HasOpenCommand()
{
- _doc->HasOpenCommand();
+ return _doc->HasOpenCommand();
}
//============================================================================
// Assign the value of the IOR in the study->root
const char* IORStudy = _orb->object_to_string(Study);
- SALOMEDS_IORAttribute::Set(Doc->Main().Root(),TCollection_ExtendedString(strdup(IORStudy)),_orb);
+ SALOMEDS_IORAttribute::Set(Doc->Main().Root(),TCollection_ExtendedString((char*)IORStudy),_orb);
// set Study properties
SALOMEDS::AttributeStudyProperties_ptr aProp = Study->GetProperties();
sprintf(aHDFUrl, "%shdf_from_ascii.hdf", aResultPath);
delete(aResultPath);
} else {
- aHDFUrl = strdup(aUrl);
+ aHDFUrl = CORBA::string_dup(aUrl);
}
hdf_file = new HDFfile(aHDFUrl);
SALOMEDS_IORAttribute::Set(Doc->Main().Root(),
TCollection_ExtendedString(CORBA::string_dup(IORStudy)),_orb);
- SALOMEDS_PersRefAttribute::Set(Doc->Main(),strdup(aUrl));
+ SALOMEDS_PersRefAttribute::Set(Doc->Main(),(char*)aUrl);
if (!hdf_file->ExistInternalObject("STUDY_STRUCTURE")) {
delete aHDFUrl;
if (isASCII) {
SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
aFilesToRemove->length(1);
- aFilesToRemove[0] = strdup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl))]));
- SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true);
+ aFilesToRemove[0] = CORBA::string_dup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl).c_str())]));
+ SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aHDFUrl).c_str(), aFilesToRemove, true);
}
delete aHDFUrl;
delete hdf_file; // all related hdf objects will be deleted
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());
+ CORBA::String_var aSaveStr = CORBA::string_dup(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;
+ //MESSAGE("********** Write Attribute "<<anAttrList[a]->Type()<<" : "<<aSaveStr<<" done");
hdf_dataset=0; //will be deleted by hdf_sco_group destructor
}
// 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());
+ CORBA::String_var attribute_reference = CORBA::string_dup(RefSO->GetID());
size[0] = strlen(attribute_reference) + 1 ;
HDFdataset *hdf_dataset = new HDFdataset("Reference",hdf_group_sobject,HDF_STRING,size,1);
hdf_dataset->CreateOnDisk();
MESSAGE("attribute StudyProperties " << aProperty << " wrote on file");
hdf_dataset->CloseOnDisk();
hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- delete(aProperty);
+ //delete(aProperty);
+ delete [] aProperty;
aProp->SetModified(0);
}
for (; itcomponent1->More(); itcomponent1->Next())
{
SALOMEDS::SComponent_var sco = itcomponent1->Value();
+
// if there is an associated Engine call its method for saving
CORBA::String_var IOREngine;
try {
-
if (!sco->ComponentIOR(IOREngine)) {
SALOMEDS::GenericAttribute_var aGeneric;
- SALOMEDS::AttributeName_var aName;
- if(sco->FindAttribute(aGeneric, "AttributeName"))
- aName = SALOMEDS::AttributeName::_narrow(aGeneric);
-
+ SALOMEDS::AttributeComment_var aName;
+ if(sco->FindAttribute(aGeneric, "AttributeComment"))
+ aName = SALOMEDS::AttributeComment::_narrow(aGeneric);
+
if (!aName->_is_nil()) {
CORBA::String_var aCompType = aName->Value();
-
CORBA::String_var aFactoryType;
if (strcmp(aCompType, "SUPERV") == 0) aFactoryType = "SuperVisionContainer";
else aFactoryType = "FactoryServer";
Engines::Component_var aComp =
SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component(aFactoryType, aCompType);
-
if (aComp->_is_nil()) {
Engines::Component_var aComp =
SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component("FactoryServerPy", aCompType);
SALOMEDS::TMPFile_var aStream;
- if (theASCII) aStream = Engine->SaveASCII(sco,SALOMEDS_Tool::GetDirFromPath(aUrl),theMultiFile);
- else aStream = Engine->Save(sco,SALOMEDS_Tool::GetDirFromPath(aUrl),theMultiFile);
+ if (theASCII) aStream = Engine->SaveASCII(sco,SALOMEDS_Tool::GetDirFromPath(aUrl).c_str(),theMultiFile);
+ else aStream = Engine->Save(sco,SALOMEDS_Tool::GetDirFromPath(aUrl).c_str(),theMultiFile);
HDFdataset *hdf_dataset;
hdf_size aHDFSize[1];
}
}
- CORBA::String_var scoid = strdup(SO->GetID());
+ CORBA::String_var scoid = CORBA::string_dup(SO->GetID());
hdf_group_sobject = new HDFgroup(scoid,hdf_group_datatype);
hdf_group_sobject->CreateOnDisk();
SaveAttributes(SO, hdf_group_sobject);
Standard_ExtCharacter val2 = ToExtCharacter(':');
theUrl.ChangeAll(val1,val2);
TCollection_AsciiString ch(theUrl);
- return strdup(ch.ToCString());
+ return CORBA::string_dup(ch.ToCString());
}
//============================================================================
if (!Handle(SALOMEDS_IORAttribute)::DownCast(anAttr).IsNull()) { // IOR => ID and TMPFile of Engine
TCollection_AsciiString anEntry;
TDF_Tool::Entry(theSource, anEntry);
- SALOMEDS::SObject_var aSO = theSourceStudy->FindObjectID(strdup(anEntry.ToCString()));
+ SALOMEDS::SObject_var aSO = theSourceStudy->FindObjectID(anEntry.ToCString());
// if (theEngine->CanCopy(aSO)) {
CORBA::Long anObjID;
// TCollection_ExtendedString aResStr(strdup((char*)(theEngine->CopyFrom(aSO, anObjID))));
// set component data type to the name attribute of root label
if (!aStructureOnly) {
TDataStd_Comment::Set(aTargetDocument->Main().Root(),
- TCollection_ExtendedString(strdup(Engine->ComponentDataType())));
+ TCollection_ExtendedString(Engine->ComponentDataType()));
}
// set to the Root label integer attribute: study id
TDataStd_Integer::Set(aTargetDocument->Main().Root(), aStudy->StudyId());
// iterate all theObject's label children
TDF_Label aStartLabel;
- char* aStartID = strdup(theObject->GetID());
+ char* aStartID = CORBA::string_dup(theObject->GetID());
TDF_Tool::Label(aDocument->GetData(), aStartID, aStartLabel);
+ delete(aStartID);
Standard_Integer aSourceStartDepth = aStartLabel.Depth();
// copy main source label
CORBA::Object_var obj = _orb->string_to_object(IOREngine);
SALOMEDS::Driver_var Engine = SALOMEDS::Driver::_narrow(obj) ;
if (CORBA::is_nil(Engine)) return false;
- return Engine->CanPaste(strdup(TCollection_AsciiString(aCompName->Get()).ToCString()), anObjID->Get());
+ return Engine->CanPaste(TCollection_AsciiString(aCompName->Get()).ToCString(), anObjID->Get());
}
//============================================================================
/*! Function : PasteLabel
aAuxSourceLabel.FindAttribute(TDataStd_Integer::GetID(), anObjID);
Handle(TDataStd_Comment) aComponentName;
theSource.Root().FindAttribute(TDataStd_Comment::GetID(), aComponentName);
- CORBA::String_var aCompName = strdup(TCollection_AsciiString(aComponentName->Get()).ToCString());
+ CORBA::String_var aCompName = CORBA::string_dup(TCollection_AsciiString(aComponentName->Get()).ToCString());
if (theEngine->CanPaste(aCompName, anObjID->Get())) {
SALOMEDS::TMPFile_var aTMPFil = new SALOMEDS::TMPFile();
TCollection_AsciiString anEntry;
TDF_Tool::Entry(aTargetLabel, anEntry);
- SALOMEDS::SObject_var aPastedSO = theDestinationStudy->FindObjectID(strdup(anEntry.ToCString()));
+ SALOMEDS::SObject_var aPastedSO = theDestinationStudy->FindObjectID(anEntry.ToCString());
if (isFirstElement) {
SALOMEDS::SObject_var aDestSO =
theEngine->PasteInto(aTMPFil.in(),
if (aNameStart) TDataStd_Name::Set(aTargetLabel, aNameStart);
else TDataStd_Name::Set(aTargetLabel, TCollection_ExtendedString("Reference to:")+anEntry);
}
- delete(anEntry);
+ delete [] anEntry;
}
return aTargetLabel;
const Standard_GUID& SALOMEDS_TableOfStringAttribute::GetID()
{
- static Standard_GUID SALOMEDS_TableOfStringAttributeID ("128371A2-8F52-11d6-A8A3-0001021E8C7F");
+ static Standard_GUID SALOMEDS_TableOfStringAttributeID ("128371A4-8F52-11d6-A8A3-0001021E8C7F");
return SALOMEDS_TableOfStringAttributeID;
}
if (anIterator.Value().Length()) { // check empty string in the value table
theStream << anIterator.Key() << "\n";
unsigned long aValueSize = anIterator.Value().Length();
- theStream.write((char*)&aValueSize, sizeof(unsigned long));
+ theStream<<aValueSize << "\n";
theStream.write((TCollection_AsciiString(anIterator.Value()).ToCString()),aValueSize);
+ theStream<<"\n";
} else { // write index only of kind: "0key"; "05", for an example
theStream << "0" << anIterator.Key() << "\n";
}
aValue = "";
else {
unsigned long aValueSize;
- theStream.read((char*)&aValueSize, sizeof(unsigned long));
+ theStream >> aValueSize;
+ theStream.read(aValueString, 1); // an '\n' omitting
theStream.read(aValueString, aValueSize);
+ theStream.read(aValueString, 1); // an '\n' omitting
aValue = aValueString;
}
myTable.Bind(aKey, aValue);
Backup();
Handle(TDF_Reference) aReference;
if (theReferencedObject.FindAttribute(TDF_Reference::GetID(),aReference)) {
+ TDF_ListIteratorOfAttributeList anIter(GetVariables());
+ for(;anIter.More();anIter.Next()) if(anIter.Value()->Label() == theReferencedObject) return; //BugID: PAL6192
GetVariables().Append(aReference);
} else {
MESSAGE("SALOMEDS_TargetAttribute::Append: can't append referenced object");
if(_root.IsNull()) return 0;
Handle(TDataStd_Name) aNameAttrib;
- TCollection_ExtendedString aName(strdup(theName));
+ TCollection_ExtendedString aName((char*)theName);
if (!_root->FindAttribute(TDataStd_Name::GetID(), aNameAttrib))
aNameAttrib = TDataStd_Name::Set(_root->Label(), aName);
Handle(TDataStd_Name) aName;
if (!_root->FindAttribute(TDataStd_Name::GetID(), aName)) return aString._retn();
- aString = strdup(TCollection_AsciiString(aName->Get()).ToCString());
+ aString = CORBA::string_dup(TCollection_AsciiString(aName->Get()).ToCString());
return aString._retn();
}
TDF_Label aChild = aLabel.FindChild(anInteger->Get());
aNode = TDataStd_TreeNode::Set(aChild, aBasicGUID);
aFatherNode->Append(aNode);
- TDataStd_Name::Set(aChild, TCollection_ExtendedString(strdup(theName)));
+ TDataStd_Name::Set(aChild, TCollection_ExtendedString((char*)theName));
SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aChild, _orb);
SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this());
#---------------
msgid "INF_VERSION"
-msgstr "Version 2.0.0"
+msgstr "Version 2.1.0"
msgid "INF_COPYRIGHT"
-msgstr " "
+msgstr "Copyright : CEA"
msgid "INF_LICENSE"
msgstr " "
#: SALOMEGUI_AboutDlg.cxx:42
msgid "ABOUT_TLT"
-msgstr "About SALOME"
+msgstr "About PAL/SALOME"
#: QAD_Config.cxx:84
msgid "MEN_APPNAME"
#: QAD_Application.cxx:133
msgid "QAD_Application::APP_DEFAULTTITLE"
-msgstr "SALOME 2.0.0"
+msgstr "PAL/SALOME 2.1.0"
#: QAD_Desktop.cxx:424
msgid "QAD_Desktop::DESK_DEFAULTTITLE"
-msgstr "SALOME 2.0.0"
+msgstr "PAL/SALOME 2.1.0"
SALOME_NumberFilter.hxx \
Handle_SALOME_NumberFilter.hxx \
SALOME_DataMapOfIOMapOfInteger.hxx \
+ SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx \
Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx \
SALOMEGUI.h \
SALOMEGUI_LoadStudiesDlg.h \
SALOME_Exception.idl
CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES)
-LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lqsplitterP -lSalomeLifeCycleCORBA -lOpUtil -lSalomeObject -lEvent
+LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lqsplitterP -lSalomeLifeCycleCORBA -lOpUtil -lSalomeObject -lEvent -lSalomePrs
LIBS+= $(PYTHON_LIBS)
*/
PyInterp_PyQt::PyInterp_PyQt(): PyInterp_base()
{
- initialize();
}
PyInterp_PyQt::~PyInterp_PyQt()
// Module : SALOME
// $Header$
+
#include <string>
#include <vector>
#include "SALOMEGUI_CloseDlg.h"
#include "SALOMEGUI_ActivateComponentDlg.h"
+#include "SALOMEGUI_QtCatchCorbaException.hxx"
#include "SALOME_Event.hxx"
myCntUntitled(0),
//NRImyHelpWindow(0),
myDefaultTitle( tr("DESK_DEFAULTTITLE") ),
-myQueryClose( true )
+myQueryClose( true ),
+myAboutToClose( false )
{
/* Force reading of user config file */
QAD_CONFIG->readConfigFile();
QString resDir;
/* find component icon */
- QString iconfile = strdup(list_composants[ind].moduleicone) ;
- QString modulename = strdup(list_composants[ind].modulename) ;
- QString moduleusername = strdup(list_composants[ind].moduleusername) ;
+ QString iconfile = CORBA::string_dup(list_composants[ind].moduleicone) ;
+ QString modulename = CORBA::string_dup(list_composants[ind].modulename) ;
+ QString moduleusername = CORBA::string_dup(list_composants[ind].moduleusername) ;
// MESSAGE ( " MODULE = " << modulename )
// MESSAGE ( " MODULE icon = " << iconfile )
*/
bool QAD_Desktop::eventFilter( QObject* o, QEvent* e )
{
- if (e->type() == 2000 ) {
+ if (e->type() == QEvent::Close && o == this )
+ myAboutToClose = true;
+ else if (e->type() == 2000 ) {
QMessageBox::information (this, tr ( "Help Information" ), tr ( "Can't run choosen browser.\nRunning default browser (Mozilla). "));
return TRUE;
}
QMessageBox::critical(this, tr ( "Help Error" ), tr ( "Can't run the default browser.") );
return TRUE;
}
- else if ( e->type() == QEvent::ContextMenu ) {
- QContextMenuEvent* ce = (QContextMenuEvent*)e;
- if ( o->inherits("QRenameEdit") ) {
+ else if ( e->type() == QEvent::ContextMenu ) {
+ QContextMenuEvent* ce = (QContextMenuEvent*)e;
+ if ( o->inherits("QRenameEdit") ) {
return TRUE;
}
else if ( o->inherits("QLineEdit") ) {
}
else if ( e->type() == SALOME_EVENT ) {
SALOME_Event* aSE = (SALOME_Event*)((QCustomEvent*)e)->data();
- processEvent( aSE );
- // Signal the calling thread that the event has been processed
- aSE->processed();
+ processEvent(aSE);
((QCustomEvent*)e)->setData( 0 );
- delete aSE;
return TRUE;
}
return QMainWindow::eventFilter( o, e );
*/
void QAD_Desktop::processEvent( SALOME_Event* theEvent )
{
- if ( !theEvent )
- return;
- theEvent->Execute();
+ if(theEvent){
+ theEvent->Execute();
+ // Signal the calling thread that the event has been processed
+ theEvent->processed();
+ }
}
/*!
myCatalogue->GetComponentIconeList();
for (unsigned int ind = 0; ind < list_composants->length(); ind++) {
- QString aModuleName = strdup(list_composants[ind].modulename) ;
+ QString aModuleName = CORBA::string_dup(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) ;
+ QString aModuleUserName = CORBA::string_dup(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() )));
QAD_NO, QAD_NO ) == QAD_YES;
}
- if ( doClose ) {
- for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) {
- QList<QAD_Study>& studies = app->getStudies();
- for(QAD_Study* study = studies.first(); study != 0; study = studies.next()) {
- if(myQueryClose && study->getStudyDocument()->IsModified()) {
- SALOMEGUI_CloseDlg aDlg( this );
- switch ( aDlg.exec() ) {
- case 1:
- if ( !onSaveStudy( study ) ) {
- putInfo( tr("INF_CANCELLED") );
- e->ignore();
- return;
- }
- break;
- case 2:
- case 3:
- break;
- case 0:
- default:
- e->ignore();
+ for ( QAD_Application* app = myApps.first(); doClose && app; app = myApps.next() ) {
+ QList<QAD_Study>& studies = app->getStudies();
+ for(QAD_Study* study = studies.first(); doClose && study != 0; study = studies.next()) {
+ if(myQueryClose && study->getStudyDocument()->IsModified()) {
+ SALOMEGUI_CloseDlg aDlg( this );
+ switch ( aDlg.exec() ) {
+ case 1:
+ if ( !onSaveStudy( study ) ) {
putInfo( tr("INF_CANCELLED") );
- return;
+ doClose = false;
}
+ break;
+ case 2:
+ case 3:
+ break;
+ case 0:
+ default:
+ doClose = false;
+ putInfo( tr("INF_CANCELLED") );
}
- study->close();
}
+ if ( doClose )
+ study->close();
}
}
+
myQueryClose = true;
- doClose ? e->accept() : e->ignore();
+
+ if ( !doClose ) {
+ myAboutToClose = false;
+ // onActiveStudyChanged() is normally caused by QWorkspace::eventFilter(),
+ // but this call was blocked by myAboutToClose == true, so now we should do it manually
+ onActiveStudyChanged();
+
+ e->ignore();
+ }
+ else
+ e->accept();
}
/*!
tr("ERR_ERROR"),
tr("ERR_DOC_CANTOPEN") + "\n" + name,
tr("BUT_OK") );
- } else if (myActiveComp != "") {
- QApplication::setOverrideCursor( Qt::waitCursor );
- loadComponentData(mapComponentName[myActiveComp]);
- openStudy->updateObjBrowser(true);
- QApplication::restoreOverrideCursor();
- }
+ }
break;
}
}
bool QAD_Desktop::loadComponentData( const QString& compName )
{
+ QAD_WaitCursor wc;
+
+ if ( compName.isEmpty() ) {
+ MESSAGE("loadComponentData(): empty component name passed!")
+ return false;
+ }
+
// Open component's data in active study if any
MESSAGE("loadComponentData(): Opening " << compName << " component data ")
if (!myActiveStudy) {
comp = getEngine( "FactoryServerPy", compName);
}
+ if ( CORBA::is_nil( comp ) ) {
+ MESSAGE("loadComponentData(): Engine is null");
+ return false;
+ }
+
SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
SALOMEDS::SComponent_var SCO = SALOMEDS::SComponent::_narrow(aStudy->FindObject( getComponentUserName(compName) ));
if (!SCO->_is_nil()) {
- if (!CORBA::is_nil(comp)) {
- SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
- if (!CORBA::is_nil(driver)) {
- SALOMEDS::StudyBuilder_var B = aStudy->NewBuilder();
- if (!CORBA::is_nil(B)) {
-// QAD_Operation* op = new QAD_Operation( myActiveStudy );
-// op->start();
+ SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
+ if (!CORBA::is_nil(driver)) {
+ SALOMEDS::StudyBuilder_var B = aStudy->NewBuilder();
+ if (!CORBA::is_nil(B)) {
+ try {
B->LoadWith(SCO,driver);
-// op->finish();
- } else {
+ }
+ catch( const SALOME::SALOME_Exception& ) {
+ // Oops, something went wrong while loading -> return an error
return false;
}
- } else {
- MESSAGE("loadComponentData(): Driver is null");
- return false;
- }
+ }
} else {
- MESSAGE("loadComponentData(): Engine is null");
+ MESSAGE("loadComponentData(): Driver is null");
+ // Incorrect! All components should inherit SALOMEDS::Driver
return false;
}
} else {
MESSAGE("loadComponentData(): SComponent is null");
- return false;
+ // Don't return false here, for there might be no data
+ // for a given component in the study yet
}
return true;
if (SCO->FindAttribute(anAttr, "AttributeName")) {
aName = SALOMEDS::AttributeName::_narrow(anAttr);
name = aName->Value();
- SALOME_ModuleCatalog::Acomponent_var Comp = myCatalogue->GetComponent( mapComponentName[name] );
+ if ( getComponentName( name ).isEmpty() )
+ return;
+ SALOME_ModuleCatalog::Acomponent_var Comp = myCatalogue->GetComponent( getComponentName(name) );
if ( !Comp->_is_nil() ) {
SALOME_ModuleCatalog::ListOfComponents_var list_type_composants =
} else if ( list_type_composants->length() > 1 ) {
SALOMEGUI_OpenWith* aDlg = new SALOMEGUI_OpenWith( this );
for (unsigned int ind = 0; ind < list_type_composants->length();ind++) {
- QString compusername = getComponentUserName( strdup(list_type_composants[ind]) );
+ QString compusername = getComponentUserName( (char*)list_type_composants[ind] );
if ( !compusername.isEmpty() )
aDlg->addComponent( compusername );
}
*/
bool QAD_Desktop::loadComponent(QString Component)
{
+ if ( Component.isEmpty() ) {
+ MESSAGE("loadComponent(): empty component name passed!")
+ return false;
+ }
+
QAD_WaitCursor wc;
QString resDir("/"); //NRI : Pb under Windows
if (myActiveMenus)
nbToolbars = myActiveMenus->getToolBarList().count();
- // san - avoid loading component GUI library multiple times
- QString aUserName( getComponentUserName( Component ) );
-
- SALOMEGUI* anActiveGUI = getComponentGUI(aUserName);
- if ( !anActiveGUI )
- return false;
-
- /* SETTINGS */
- anActiveGUI->SetSettings( this, (char*)Component.latin1() );
-
/* COMPONENT INTERFACE */
SALOME_ModuleCatalog::Acomponent_ptr aComponent =
myCatalogue->GetComponent(Component.latin1());
//NRI if (component.compare(QString("Salome"))!= 0) {
if (component.compare( getComponentUserName( "KERNEL" ) )!= 0) {
// QApplication::setOverrideCursor( Qt::waitCursor );
+ bool isOk = ( !isLoadData || loadComponentData( getComponentName(component) ) );
+ if ( !isOk ) {
+ QAD_MessageBox::error1( this,
+ tr("ERR_ERROR"),
+ tr("ERR_COMP_DATA_NOT_LOADED").arg( component ),
+ tr("BUT_OK") );
+ }
+
+ if ( !isOk || !loadComponent( getComponentName(component) ) ) {
+ myCombo->setCurrentItem (0);
+ for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
+ aButton->setOn(false);
+ }
+ myActiveComp = "";
+ return;
+ }
+
myActiveComp = component;
SALOME_Selection* oldSel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
}
myActiveStudy->Selection( component );
- if ( !loadComponent(mapComponentName[component]) ) {
- myCombo->setCurrentItem (0);
- for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
- aButton->setOn(false);
- }
- myActiveComp = "";
- }
SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
SALOME_ListIteratorOfListIO It( oldSel->StoredIObjects() );
}
- // Open new component's data in active study if any
- if(isLoadData) loadComponentData(mapComponentName[component]);
-
oldSel->Clear();
+
+ /* SETTINGS */
+ // IMPORTANT: SetSettings() should be called AFTER SALOME_Selection
+ // has been created for a newly activated component
+ getComponentGUI(component)->SetSettings( this, (char*)getComponentName(component).latin1() );
+
myActiveStudy->updateObjBrowser(true);
// QApplication::restoreOverrideCursor();
*/
void QAD_Desktop::clearMenus()
{
- onActiveStudyChanged();
+ // san - commented as presumably obsolete
+ // onActiveStudyChanged();
/* menus */
myMenusList.clear();
SALOMEGUI* QAD_Desktop::getComponentGUI( const QString& component )
{
SALOMEGUI* aCompGUI = 0;
+ if ( component.isEmpty() || getComponentName( component ).isEmpty() )
+ return aCompGUI;
// Load component GUI if requested for the first time
if ( myComponents.find( component ) == myComponents.end() ) {
}
+/*!
+ Returns name of active component
+*/
+QString QAD_Desktop::getComponentDataType() const
+{
+ using namespace SALOMEDS;
+ Study_var aStudy = getActiveStudy()->getStudyDocument();
+ SObject_var aSObject = aStudy->FindObject(myActiveComp.latin1());
+ SComponent_var aComponent = SComponent::_narrow(aSObject);
+ if(!aComponent->_is_nil()){
+ CORBA::String_var aString = aComponent->ComponentDataType();
+ return aString.in();
+ }
+ return "";
+}
+
void QAD_Desktop::definePopup(QString & theContext,
QString & theParent,
QString & theObject )
void QAD_Desktop::onActiveStudyChanged()
{
+ // Avoid recursive calls caused by QAD_MessageBox
+ static bool isRecursion = false;
+ if ( isRecursion || myAboutToClose )
+ return;
+
+ if (myActiveComp != "") {
+ // Try to load active component's data in the activated study
+ if ( !loadComponentData(mapComponentName[myActiveComp]) ) {
+ isRecursion = true;
+ QAD_MessageBox::error1( this,
+ tr("ERR_ERROR"),
+ tr("ERR_COMP_DATA_NOT_LOADED").arg( myActiveComp ),
+ tr("BUT_OK") );
+ // Error while loading component's data -> deactivate it
+ deactivateComponent();
+ if (!myXmlHandler->myIdList.IsEmpty()) clearMenus();
+ myCombo->setCurrentItem (0);
+ for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
+ aButton->setOn(false);
+ }
+ myActiveComp = "";
+ isRecursion = false;
+ return;
+ }
+ else
+ myActiveStudy->updateObjBrowser(true);
+ }
+
SALOMEGUI* anActiveGUI = getActiveGUI();
if ( anActiveGUI )
anActiveGUI->ActiveStudyChanged(this);
virtual void helpContext(const QString& path, const QString& dir = QString::null);
*/
bool loadComponent(QString);
+ bool loadComponentData( const QString& );
QString changeXmlInputSourceData(QString theData, QString theComponent);
void activateComponent(const QString& theName, bool isLoadData = true);
void deactivateComponent();
const QString& getActiveComponent() const;
SALOMEGUI* getActiveGUI();
SALOMEGUI* getComponentGUI( const QString& ); // accepts component`s user name
+ QString getComponentDataType() const;
SALOME_NamingService* getNameService() {return myNameService;}
Engines::Component_var getEngine(const char *containerName,
virtual void updateCaption( UpdateCommand );
virtual void updateMenu( UpdateCommand );
- bool loadComponentData( const QString& );
-
protected slots:
virtual void onNewStudy();
virtual void onNewStudy(QAD_Application* app);
SALOME_LifeCycleCORBA * myEnginesLifeCycle;
QComboBox * myCombo;
bool myQueryClose;
+ bool myAboutToClose;
bool _islibso;
ComponentMap myComponents;
Constructor
*/
QAD_FileDlg::QAD_FileDlg( QWidget* parent, bool open, bool showQuickDir, bool modal ) :
-QFileDialog( parent, 0, modal ),
+QFileDialogP( parent, 0, modal ),
myValidator( 0 ),
myQuickCombo( 0 ),
myOpen( open )
{
if ( parent->icon() )
- setIcon( *parent->icon() );
+ setIcon( *parent->icon() );
setSizeGripEnabled( true );
-
+
if (showQuickDir) {
// inserting quick dir combo box
QLabel* lab = new QLabel(tr("Quick path:"), this);
{
// mySelectedFile = QFileDialog::selectedFile().simplifyWhiteSpace(); //VSR- 06/12/02
if ( mode() != ExistingFiles ) {
- mySelectedFile = QFileDialog::selectedFile(); //VSR+ 06/12/02
+ mySelectedFile = QFileDialogP::selectedFile(); //VSR+ 06/12/02
addExtension();
}
// mySelectedFile = mySelectedFile.simplifyWhiteSpace(); //VSR- 06/12/02
*/
if ( acceptData() ) {
myLastVisitedPath = dirPath();
- QFileDialog::accept();
+ QFileDialogP::accept();
}
}
void QAD_FileDlg::reject()
{
mySelectedFile = QString::null;
- QFileDialog::reject();
+ QFileDialogP::reject();
}
/*!
if ( !initial.isEmpty() ) {
fd->processPath( initial ); // VSR 24/03/03 check for existing of directory has been added to avoid QFileDialog's bug
}
- fd->setFilters( filters );
+
+ fd->setFilters( filters );
+
if ( validator )
fd->setValidator( validator );
fd->exec();
}
fd->setMode( DirectoryOnly );
fd->setFilters(tr("DIRECTORIES_FILTER"));
+
fd->exec();
QString dirname = fd->selectedFile();
delete fd;
qApp->processEvents();
return dirname;
-
}
#ifndef QAD_FILEDIALOG_H
#define QAD_FILEDIALOG_H
-#include <qfiledialog.h>
#include <qcombobox.h>
+
+#include <qfiledialogP.h>
#include "QAD.h"
#include "QAD_FileValidator.h"
-class QAD_EXPORT QAD_FileDlg : public QFileDialog
+class QAD_EXPORT QAD_FileDlg : public QFileDialogP
{
Q_OBJECT
public:
QAD_FileDlg( QWidget* parent, bool open, bool showQuickDir = true, bool modal = true );
- ~QAD_FileDlg();
+ virtual ~QAD_FileDlg();
public:
bool isOpenDlg() const;
const QString& initial,
const QString& caption,
bool showQuickDir = true);
+
+protected:
+ virtual bool acceptData();
+
private:
- bool acceptData();
void addExtension();
bool processPath( const QString& path );
QAD_FileValidator* myValidator; /* file validator */
static QString myLastVisitedPath; /* last visited path */
QComboBox* myQuickCombo; /* quick dir combo box */
-
};
#endif
// Module : SALOME
// $Header$
-using namespace std;
#include "QAD_FileValidator.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_MessageBox.h"
+#include "utilities.h"
+
#include <qfile.h>
#include <qfileinfo.h>
+using namespace std;
+
/* constructor */
QAD_FileValidator::QAD_FileValidator(QWidget* parent) :
myParent(parent)
// Module : SALOME
// $Header$
-using namespace std;
#include "QAD_ListView.h"
#include <qheader.h>
#include "QAD_Desktop.h"
-//#include <QAD_Application.h>
-//#include <QAD_Document.h>
-
-
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_ListIteratorOfListOfReal.hxx>
+#include "utilities.h"
+
+using namespace std;
+
//////////////////////////////////////////////////////////////////////
// QAD_ListView class implementation
//////////////////////////////////////////////////////////////////////
#include <qtooltip.h>
#include <qdragobject.h>
#include <qstringlist.h>
+#include <qmap.h>
+
using namespace std;
//VRV: porting on Qt 3.0.5
}
+/*!
+ Returns true if item is collapsed has collapsed children
+*/
+static bool hasCollapsed( QListViewItem* item )
+{
+ if ( !item )
+ return false;
+
+ bool res = ( item->childCount() && !item->isOpen() );
+ for ( QListViewItem* child = item->firstChild(); !res && child; child = child->nextSibling() )
+ res = hasCollapsed( child );
+
+ return res;
+}
+
+/*!
+ Expands item and all its children
+*/
+static void expand(QListViewItem* item)
+{
+ if ( !item )
+ return;
+
+ item->setOpen( true );
+
+ for ( QListViewItem* child = item->firstChild(); child; child = child->nextSibling() )
+ expand( child );
+}
+
/*!
Builds popup menu
*/
this,
SLOT( onEditAttribute() ) );
}
+
+ bool canExpand = false;
+ for ( QListViewItemIterator it( getListView() ); it.current() && !canExpand; ++it )
+ canExpand = canExpand || ( it.current()->isSelected() && hasCollapsed( it.current() ) );
+
+ if ( canExpand ) {
+ if ( myPopup->count() > 0 )
+ myPopup->insertSeparator();
+ myPopup->insertItem( tr( "EXPAND_ALL_CMD" ),
+ this,
+ SLOT( onExpandAll() ) );
+ }
}
} else {
// NRI 02/12/2002
}
}
+/*!
+ Called on "Expand all" popup menu command
+*/
+void QAD_ObjectBrowser::onExpandAll()
+{
+ for ( QListViewItemIterator it( getListView() ); it.current(); ++it )
+ if ( it.current()->isSelected() )
+ expand( it.current() );
+}
+
/*!
Returns Object Browser list view
*/
SALOMEDS::SObject_var CSO = it->Value();
SALOMEDS::SObject_var RefSO;
QString ior = "";
- QString CSOEntry = strdup( CSO->GetID() );
+ QString CSOEntry = CORBA::string_dup( CSO->GetID() );
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributeComment_var aCmnt;
if ( CSO->ReferencedObject(RefSO) && !RefSO->_is_nil() ) {
- QString RefSOEntry = strdup( RefSO->GetID() );
+ QString RefSOEntry = CORBA::string_dup( RefSO->GetID() );
if (CSO->FindAttribute(anAttr, "AttributeName") || RefSO->FindAttribute(anAttr, "AttributeName")) {
aName = SALOMEDS::AttributeName::_narrow(anAttr);
if (RefSO->FindAttribute(anAttr, "AttributeIOR")) {
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- ior = strdup( anIOR->Value() );
+ ior = CORBA::string_dup( anIOR->Value() );
}
valueString = getValueFromObject( RefSO );
-// AddItem (Item, QString(" * ") + strdup( aName->Value() ), RefSOEntry, ior, 2, CSOEntry);
+// AddItem (Item, QString(" * ") + CORBA::string_dup( aName->Value() ), RefSOEntry, ior, 2, CSOEntry);
Item = AddItem(theParentItem,
- QString(" * ") + strdup( aName->Value() ),
+ QString(" * ") + CORBA::string_dup( aName->Value() ),
RefSOEntry,
ior,
2,
// getting IOR
if (CSO->FindAttribute(anAttr, "AttributeIOR")) {
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- ior = strdup( anIOR->Value() );
+ ior = CORBA::string_dup( anIOR->Value() );
}
// getting Name and adding new Item
if (CSO->FindAttribute(anAttr, "AttributeName") ) {
aName = SALOMEDS::AttributeName::_narrow(anAttr);
- Item = AddItem(theParentItem, strdup( aName->Value() ), CSOEntry, ior, 0, "", valueString);
+ Item = AddItem(theParentItem, CORBA::string_dup( aName->Value() ), CSOEntry, ior, 0, "", valueString);
myListViewMap[ CSOEntry ].append( Item );
}
else {
for (; itcomp->More(); itcomp->Next()) {
QAD_ObjectBrowserItem* Item = 0;
SALOMEDS::SComponent_var SC = itcomp->Value();
- QString dataType = strdup( SC->ComponentDataType() );
+ QString dataType = CORBA::string_dup( SC->ComponentDataType() );
QString ior = "";
- QString SCEntry = strdup( SC->GetID() );
+ QString SCEntry = CORBA::string_dup( SC->GetID() );
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
if (SC->FindAttribute(anAttr, "AttributeIOR")) {
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- ior = strdup( anIOR->Value() );
+ ior = CORBA::string_dup( anIOR->Value() );
}
bool caseIAPP = false;
if ( ShowIAPP.compare("true") == 0 ) {
if (SC->FindAttribute(anAttr, "AttributeName")) {
aName = SALOMEDS::AttributeName::_narrow(anAttr);
- Item = AddItem (myListView, strdup( aName->Value() ), strdup( SCEntry ), ior, 1, "");
+ Item = AddItem (myListView, CORBA::string_dup( aName->Value() ), SCEntry, ior, 1, "");
myListViewMap[ SCEntry ].append( Item );
}
else {
caseIAPP = false;
if (SC->FindAttribute(anAttr, "AttributeName")) {
aName = SALOMEDS::AttributeName::_narrow(anAttr);
- Item = AddItem (myListView, strdup( aName->Value() ), SCEntry, ior, 1, "");
+ Item = AddItem (myListView, CORBA::string_dup( aName->Value() ), SCEntry, ior, 1, "");
myListViewMap[ SCEntry ].append( Item );
}
else {
QAD_ObjectBrowserItem* root = ( QAD_ObjectBrowserItem* )myUseCaseView->firstChild();
SALOMEDS::UseCaseBuilder_var UCBuilder = myStudy->GetUseCaseBuilder();
SALOMEDS::SObject_var SOCurrent = UCBuilder->GetCurrentObject();
- QString UCName = QString( strdup( UCBuilder->GetName() ) );
+ QString UCName = CORBA::string_dup( UCBuilder->GetName() );
if ( UCName.isEmpty() )
UCName = QString( tr( "Root" ) );
// creating root item if is not yet created
if ( !UCIter->_is_nil() ) {
for ( ; UCIter->More(); UCIter->Next() ) {
SALOMEDS::SObject_var UCObject = UCIter->Value();
- QString UCEntry = strdup( UCObject->GetID() );
+ QString UCEntry = CORBA::string_dup( UCObject->GetID() );
ucList[ UCEntry ] = UCObject;
}
}
SALOMEDS::AttributeTextHighlightColor_var aTextHighlightColor;
QString valueString;
QString ior = "";
- QString UCEntry = strdup( UCObject->GetID() );
+ QString UCEntry = CORBA::string_dup( UCObject->GetID() );
SALOMEDS::UseCaseBuilder_var UCBuilder = myStudy->GetUseCaseBuilder();
SALOMEDS::SObject_var SOCurrent = UCBuilder->GetCurrentObject();
// if ( !bFound ) {
if ( UCObject->ReferencedObject( RefSO ) && !RefSO->_is_nil() ) {
- QString RefSOEntry = strdup( RefSO->GetID() );
+ QString RefSOEntry = CORBA::string_dup( RefSO->GetID() );
if ( UCObject->FindAttribute( anAttr, "AttributeName" ) || RefSO->FindAttribute( anAttr, "AttributeName" ) ) {
aName = SALOMEDS::AttributeName::_narrow( anAttr );
if ( RefSO->FindAttribute( anAttr, "AttributeIOR" ) ) {
anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr );
- ior = strdup( anIOR->Value() );
+ ior = CORBA::string_dup( anIOR->Value() );
}
valueString = getValueFromObject( RefSO );
if ( !UCSubItem ) {
UCSubItem = AddItem( UCItem,
- QString( " * " ) + strdup( aName->Value() ),
+ QString( " * " ) + CORBA::string_dup( aName->Value() ),
RefSOEntry,
ior,
2,
myUseCaseMap[ RefSOEntry ].append( UCSubItem );
}
else {
- UCSubItem->setName( QString( " * " ) + strdup( aName->Value() ) );
+ UCSubItem->setName( QString( " * " ) + CORBA::string_dup( aName->Value() ) );
UCSubItem->setEntry( RefSOEntry );
UCSubItem->setIOR( ior );
UCSubItem->setReference( UCEntry );
// getting IOR
if ( UCObject->FindAttribute( anAttr, "AttributeIOR" ) ) {
anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr );
- ior = strdup( anIOR->Value() );
+ ior = CORBA::string_dup( anIOR->Value() );
}
// getting Name and adding new Item
if ( UCObject->FindAttribute( anAttr, "AttributeName" ) ) {
aName = SALOMEDS::AttributeName::_narrow( anAttr );
if ( !UCSubItem ) {
- UCSubItem = AddItem( UCItem, strdup( aName->Value() ), UCEntry, ior, 0, "", valueString );
+ UCSubItem = AddItem( UCItem, CORBA::string_dup( aName->Value() ), UCEntry, ior, 0, "", valueString );
myUseCaseMap[ UCEntry ].append( UCSubItem );
}
else {
- UCSubItem->setName( strdup( aName->Value() ) );
+ UCSubItem->setName( CORBA::string_dup( aName->Value() ) );
UCSubItem->setEntry( UCEntry );
UCSubItem->setIOR( ior );
UCSubItem->setReference( "" );
if ( !UCIter->_is_nil() ) {
for ( ; UCIter->More(); UCIter->Next() ) {
SALOMEDS::SObject_var UCSubObject = UCIter->Value();
- QString UCSubEntry = strdup( UCSubObject->GetID() );
+ QString UCSubEntry = CORBA::string_dup( UCSubObject->GetID() );
ucList[ UCSubEntry ] = UCSubObject;
}
}
QString ActiveComp = QAD_Application::getDesktop()->getActiveComponent();
if (theItem != NULL && ( Sel->IObjectCount()>0 || ActiveComp.isEmpty() ) ) {
+
+ // PAL5618: if IO is presented by several items, assure that the selected IO
+ // is presented exactly by theItem: difference is in reference
+ QAD_ObjectBrowserItem *item = (QAD_ObjectBrowserItem *) theItem;
+ QString theEntry = item->getEntry();
+ const SALOME_ListIO& SelIO = Sel->StoredIObjects();
+ for ( SALOME_ListIteratorOfListIO SelIt( SelIO ); SelIt.More(); SelIt.Next() ) {
+ const Handle(SALOME_InteractiveObject)& IO = SelIt.Value();
+ if ( strcmp ( IO->getEntry(), theEntry ) == 0 )
+ IO->setReference( item->getReference() );
+ }
+
createPopup();
if ( myPopup ) {
SALOME_ListIO DeltaNeg;
DeltaNeg.Clear();
+ typedef QMap<QString, SALOME_InteractiveObject*> SelMap;
+
+ SelMap currMap, allMap;
+ for( SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); It.More(); It.Next() )
+ currMap.insert( It.Value()->getEntry(), It.Value().operator->() );
+
QListViewItemIterator it( whoIs );
for ( ; it.current(); ++it ) {
QAD_ObjectBrowserItem* item = (QAD_ObjectBrowserItem*)it.current();
if ( !theEntry.isEmpty() ) {
if ( item->isSelected() ) {
- bool itemAlreadySelected = false;
-
- SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
- for(;It.More();It.Next()) {
- Handle(SALOME_InteractiveObject) IO = It.Value();
- if ( strcmp ( IO->getEntry(), theEntry ) == 0 ) {
- itemAlreadySelected = true;
- break;
- }
- }
-
- if (!itemAlreadySelected) {
+ allMap.insert( theEntry, 0 );
+
+ if ( !currMap.contains( theEntry ) ) {
Handle(SALOME_InteractiveObject) newIO;
SALOMEDS::SObject_var obj = aStudy->FindObjectID( theEntry.latin1() );
if ( !obj->_is_nil() ) {
SALOMEDS::SComponent_var comp = obj->GetFatherComponent();
if ( !comp->_is_nil() ) {
- Standard_CString datatype = comp->ComponentDataType();
- newIO = new SALOME_InteractiveObject( strdup(theEntry),
- datatype,
- strdup(theName) );
- newIO->setReference( strdup(theRef) );
+ //Standard_CString datatype = comp->ComponentDataType();
+ const char* datatype = comp->ComponentDataType();
+ // newIO = new SALOME_InteractiveObject( CORBA::string_dup(theEntry),
+ // datatype,
+ // CORBA::string_dup(theName) );
+ newIO = new SALOME_InteractiveObject( theEntry, datatype, theName );
+ newIO->setReference( CORBA::string_dup(theRef) );
}
} else {
- newIO = new SALOME_InteractiveObject( strdup(theEntry),
- "",
- strdup(theName) );
- newIO->setReference( strdup(theRef) );
+ //newIO = new SALOME_InteractiveObject( CORBA::string_dup(theEntry),
+ // "",
+ // CORBA::string_dup(theName) );
+ newIO = new SALOME_InteractiveObject( theEntry, "", theName );
+ newIO->setReference( CORBA::string_dup(theRef) );
}
if (!newIO.IsNull()) {
DeltaPos.Append( newIO );
}
}
- } else {
- SALOME_ListIteratorOfListIO It1( Sel->StoredIObjects() );
- for(;It1.More();It1.Next()) {
- Handle(SALOME_InteractiveObject) IO = It1.Value();
- if ( strcmp( IO->getEntry(), item->getEntry() ) == 0 ) {
- DeltaNeg.Append( IO );
- break;
- }
- }
- }
+ } else if ( currMap.contains( theEntry ) )
+ DeltaNeg.Append( currMap[theEntry] );
}
}
for(;ItPos.More();ItPos.Next()) {
Sel->AddIObject( ItPos.Value() );
}
+
+ for ( SelMap::iterator it = currMap.begin(); it != currMap.end(); ++it )
+ if ( !allMap.contains( it.key() ) )
+ Sel->RemoveIObject( it.data() );
+
if ( myApp )
myApp->updateActions();
}
// Table of integer
if ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ) {
aTableInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
- QString tlt = QString( strdup( aTableInt->GetTitle() ) );
+ QString tlt = QString( aTableInt->GetTitle() );
if ( !tlt.isEmpty() )
tlt += " ";
int nbRows = aTableInt->GetNbRows() ;
// Table of real
if ( SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) {
aTableReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
- QString tlt = QString( strdup( aTableReal->GetTitle() ) );
+ QString tlt = QString( aTableReal->GetTitle() );
if ( !tlt.isEmpty() )
tlt += " ";
int nbRows = aTableReal->GetNbRows() ;
// Comment
if ( SO->FindAttribute(anAttr, "AttributeComment") ) {
aComment = SALOMEDS::AttributeComment::_narrow( anAttr );
- QString val = QString( strdup( aComment->Value() ) );
+ QString val = QString( aComment->Value() );
return val;
}
return QString::null;
{
if ( myStudy->_is_nil() )
return;
+
+ // Check if the study is locked
QAD_Desktop* Desktop = (QAD_Desktop*) QAD_Application::getDesktop();
QAD_Study* myActiveStudy = Desktop->getActiveStudy();
+ SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
+ if ( aStudy->GetProperties()->IsLocked() )
+ {
+ QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
+ QObject::tr("WRN_WARNING"),
+ QObject::tr("WRN_STUDY_LOCKED"),
+ QObject::tr("BUT_OK") );
+ return;
+ }
+
SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
SALOMEDS::UseCaseBuilder_var UCBuilder = myStudy->GetUseCaseBuilder();
SALOMEDS::SObject_var Current = UCBuilder->GetCurrentObject();
if ( ucSelected.count() == 1 ) {
QAD_ObjectBrowserItem* useCaseItem = ( QAD_ObjectBrowserItem* )( ucSelected.at( 0 ) );
if ( isRootItem( useCaseItem ) ) {
- QString name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), strdup( UCBuilder->GetName() ) );
+ QString name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), UCBuilder->GetName() );
if ( !name.isEmpty() ) {
- bool ok = UCBuilder->SetName( strdup( name.latin1() ) );
+ bool ok = UCBuilder->SetName( name.latin1() );
myActiveStudy->updateUseCaseBrowser( );
}
}
else/* if ( UCBuilder->IsUseCase( myStudy->FindObjectID( (( QAD_ObjectBrowserItem* )( ucSelected.at(0) ))->getEntry() ) ) )*/ {
- QString name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), strdup( useCaseItem->getName() ) );
+ QString name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), CORBA::string_dup( useCaseItem->getName() ) );
if ( !name.isEmpty() ) {
myActiveStudy->renameIObject( Sel->firstIObject(), name );
}
*/
void QAD_ObjectBrowser::onUseCaseBtn()
{
+ // Check if the study is locked
+ QAD_Desktop* Desktop = (QAD_Desktop*) QAD_Application::getDesktop();
+ QAD_Study* myActiveStudy = Desktop->getActiveStudy();
+ SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
+ if ( aStudy->GetProperties()->IsLocked() )
+ {
+ QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
+ QObject::tr("WRN_WARNING"),
+ QObject::tr("WRN_STUDY_LOCKED"),
+ QObject::tr("BUT_OK") );
+ return;
+ }
+
if ( sender() == myNewBtn ) {
- QAD_Desktop* Desktop = (QAD_Desktop*) QAD_Application::getDesktop();
- QAD_Study* myActiveStudy = Desktop->getActiveStudy();
SALOMEDS::UseCaseBuilder_var UCBuilder = myStudy->GetUseCaseBuilder();
UCBuilder->AddUseCase( tr( "NEW_OBJECT" ) );
myActiveStudy->updateUseCaseBrowser();
void showPopupMenu(QListViewItem*);
void showUseCasePopupMenu(QListViewItem*);
+ void onExpandAll();
void onExpanded (QListViewItem*);
void onCollapsed(QListViewItem*);
void onUseCasePopupMenu( int );
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
//NRI
+#include "utilities.h"
using namespace std;
_isInHistory = true;
_currentCommand = text(endLine).remove(0,SIZEPR);
_currentCommand.truncate( _currentCommand.length() - 1 );
- SCRUTE(_currentCommand);
}
QString previousCommand = myInterp->getPrevious();
if (previousCommand.compare(BEGIN_HISTORY_PY) != 0)
// $Header$
+
+
#include "QAD_PyInterp_mono.h"
#include "utilities.h"
return;
}
- SharedLib.SetName( strdup(ComponentLib) );
+ const Standard_CString aCopyCL = CORBA::string_dup(ComponentLib);
+ SharedLib.SetName( aCopyCL);
+ delete(aCopyCL);
+
bool ok = SharedLib.DlOpen(OSD_RTLD_LAZY);
if (!ok) {
h->unCompressAfter();
}
+void QAD_RightFrame::compressLeft()
+{
+ QSplitterPHandle* h = mySplitter->getHandleAfter( getPyEditor() );
+ if( h )
+ h->compressBefore();
+}
+
+void QAD_RightFrame::compressRight()
+{
+ QSplitterPHandle* h = mySplitter->getHandleAfter( getPyEditor() );
+ if( h )
+ h->compressAfter();
+}
+
+void QAD_RightFrame::unCompressLeft()
+{
+ QSplitterPHandle* h = mySplitter->getHandleAfter( getPyEditor() );
+ if( h )
+ h->unCompressBefore();
+}
+
+void QAD_RightFrame::unCompressRight()
+{
+ QSplitterPHandle* h = mySplitter->getHandleAfter( getPyEditor() );
+ if( h )
+ h->unCompressAfter();
+}
+
+bool QAD_RightFrame::isCompressedViewFrame() const
+{
+ return isCompressed( myViewFrame );
+}
+
+bool QAD_RightFrame::isCompressedPython() const
+{
+ return mySplitter->isCompressed( getPyEditor() );
+}
+
+bool QAD_RightFrame::isCompressedMessage() const
+{
+ return mySplitter->isCompressed( getMessage() );
+}
+
void compressUp();
void unCompressBottom();
void unCompressUp();
-
+
+ void compressLeft();
+ void compressRight();
+ void unCompressLeft();
+ void unCompressRight();
+
+ bool isCompressedViewFrame() const;
+ bool isCompressedPython() const;
+ bool isCompressedMessage() const;
+
protected:
ViewType myViewType;
myIsReadOnly = state;
}
+bool QAD_Study::isLocked()
+{
+ bool state = false;
+ if ( !CORBA::is_nil( myStudy ) )
+ state = myStudy->GetProperties()->IsLocked();
+ return state;
+}
+
//=======================================================================//
// Study operations //
//=======================================================================//
title, VIEW_OCC,
myInterp, myMutex );
- Standard_CString name = strdup(sf->title().latin1());
+ Standard_CString name = CORBA::string_dup(sf->title().latin1());
anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
aName->SetValue(name);
for ( QAD_StudyFrame* sf = myStudyFrames.first(); sf; sf = myStudyFrames.next() ) {
/* Update Viewer */
- sf->getRightFrame()->getViewFrame()->undo( myStudy, sf->entry() );
+ sf->getRightFrame()->getViewFrame()->undo( this, sf->entry() );
}
updateCaptions();
/* Update Viewer */
for ( QAD_StudyFrame* sf = myStudyFrames.first(); sf; sf = myStudyFrames.next() ) {
- sf->getRightFrame()->getViewFrame()->redo( myStudy, sf->entry() );
+ sf->getRightFrame()->getViewFrame()->redo( this, sf->entry() );
}
updateCaptions();
SALOMEDS::AttributeName_var aName;
anAttr = aStudyBuilder->FindOrCreateAttribute(obj, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
- aName->SetValue(strdup(newName.latin1()));
+ aName->SetValue(newName.latin1());
}
// VSR 13/03/03 - rename Interactive object
bool isModified() const;
bool isReadOnly() const;
void setReadOnly(bool state);
+ bool isLocked();
const QString& getTitle() const;
int getStudyId();
const QString& getPath() const;
\brief Frame window which contains QAD_LeftFrame and QAD_RightFrame.
*/
+#include "QAD_StudyFrame.h"
#include "QAD_StudyFrame.h"
#include "QAD_RightFrame.h"
#include "QAD_LeftFrame.h"
*/
void QAD_StudyFrame::compressLeft()
{
- mySplitter->compress(myLeftFrm);
+ QSplitterPHandle* h = mySplitter->getHandleAfter(myLeftFrm);
+ if( h )
+ h->compressBefore();
}
void QAD_StudyFrame::compressRight()
{
- mySplitter->compress(myRightFrm);
+ QSplitterPHandle* h = mySplitter->getHandleAfter(myLeftFrm);
+ if( h )
+ h->compressAfter();
}
void QAD_StudyFrame::unCompressLeft()
{
- mySplitter->unCompress(myLeftFrm);
+ QSplitterPHandle* h = mySplitter->getHandleAfter(myLeftFrm);
+ if( h )
+ h->unCompressBefore();
}
void QAD_StudyFrame::unCompressRight()
{
- mySplitter->unCompress(myRightFrm);
+ QSplitterPHandle* h = mySplitter->getHandleAfter(myLeftFrm);
+ if( h )
+ h->unCompressAfter();
+}
+
+bool QAD_StudyFrame::isCompressedLeft() const
+{
+ return mySplitter->isCompressed(myLeftFrm);
+}
+
+bool QAD_StudyFrame::isCompressedRight() const
+{
+ return mySplitter->isCompressed(myRightFrm);
}
/*!
void unCompressLeft();
void unCompressRight();
+ bool isCompressedLeft() const;
+ bool isCompressedRight() const;
+
signals:
void sfStudyFrameActivated( QAD_StudyFrame* );
void sfStudyFrameClosing( QAD_StudyFrame*);
// Module : SALOME
// $Header$
-using namespace std;
#include "QAD.h"
#include "QAD_ViewFrame.h"
#include "QAD_Application.h"
#include <qimage.h>
#include "utilities.h"
+using namespace std;
+
/*!
Constructor
*/
{
}
-bool QAD_ViewFrame::isInViewer(SALOMEDS::Study_var aStudy,
- const char* anEntry, const char* StudyFrameEntry)
-{
- SALOMEDS::SObject_var RefSO;
- SALOMEDS::SObject_var SO = aStudy->FindObjectID(StudyFrameEntry);
- SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO);
- for (; it->More();it->Next()){
- SALOMEDS::SObject_var CSO= it->Value();
- if (CSO->ReferencedObject(RefSO))
- if ( strcmp( anEntry, RefSO->GetID() ) == 0 )
- return 1;
- }
- return 0;
-}
-
-//san:T3.13 - it's up to VTKViewer_ViewFrame to implement (or not implement) getRenderer() method. Be careful!
-/*
-vtkRenderer* QAD_ViewFrame::getRenderer()
-{
- MESSAGE ( "Only redefined VTKViewer")
- return NULL;
-}
-*/
-
/*
Dumps 3d-Viewer contents into image file
File format is defined by file's extension; supported formats : PNG, BMP, GIF, JPG
#include "QAD_StudyFrame.h"
#include "SALOME_InteractiveObject.hxx"
#include "SALOME_Selection.h"
+#include "SALOME_Prs.h"
+
+class QAD_Study;
// QT Include
#include <qmainwindow.h>
-//class vtkRenderer;
-class QAD_EXPORT QAD_ViewFrame : public QMainWindow
+class QAD_EXPORT QAD_ViewFrame : public QMainWindow, public SALOME_View
{
Q_OBJECT
virtual ViewType getTypeView() const = 0;
virtual QWidget* getViewWidget() = 0;
-// virtual vtkRenderer* getRenderer();
virtual void setBackgroundColor( const QColor& ) = 0;
virtual QColor backgroundColor() const = 0;
virtual bool isVisible( const Handle(SALOME_InteractiveObject)& IObject ) = 0;
/* undo/redo management */
- virtual void undo(SALOMEDS::Study_var aStudy,
- const char* StudyFrameEntry) = 0;
- virtual void redo(SALOMEDS::Study_var aStudy,
- const char* StudyFrameEntry) = 0;
-
- static bool isInViewer(SALOMEDS::Study_var aStudy,
- const char* anEntry,
- const char* StudyFrameEntry);
+ virtual void undo(QAD_Study* aStudy, const char* StudyFrameEntry) {}
+ virtual void redo(QAD_Study* aStudy, const char* StudyFrameEntry) {}
/* selection */
virtual Handle(SALOME_InteractiveObject) FindIObject(const char* Entry) = 0;
msgid "ERR_GET_GUI_NOT_FOUND"
msgstr "GetComponentGUI() function not found in %1 library!"
+msgid "ERR_EMPTY_COMP_NAME"
+msgstr "Component name not found for %1"
+
+msgid "ERR_COMP_DATA_NOT_LOADED"
+msgstr "Persistent data for %1 component has not been loaded!\nProbably, persistent data file is missing or corrupted.\nThe component will be deactivated."
+
#---------------
# QUESTION
#---------------
msgid "EDIT_VALUE_CMD"
msgstr "Edit value"
+msgid "EXPAND_ALL_CMD"
+msgstr "Expand all"
+
msgid "PLOT_TABLE_CMD"
msgstr "Plot table"
#include "QAD_Resource.h"
#include "QAD_Tools.h"
#include "QAD_WaitCursor.h"
+#include "QAD_MessageBox.h"
// QT Includes
#include <qapplication.h>
}
QAD_StudyFrame* sf = myActiveStudy->getActiveStudyFrame();
- Standard_CString name = strdup(sf->title().latin1());
+ Standard_CString name = CORBA::string_dup(sf->title().latin1());
SALOMEDS::SComponent_var father = aStudy->FindComponent("Interface Applicative");
SALOMEDS::SObject_var newObj = B->NewObject(father);
QAD_ViewFrame* viewFrame = myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
+ // Ensure that parent component's data are loaded
+ QString compName = desktop->getComponentName( parentComp );
+ if ( compName.isEmpty() ) {
+ waitCursor.stop();
+ QAD_MessageBox::error1( desktop,
+ tr("ERR_ERROR"),
+ tr("ERR_EMPTY_COMP_NAME").arg( parentComp ),
+ tr("BUT_OK"));
+ return;
+ }
+
+ desktop->loadComponentData( compName );
+
// Build the graphic presentation (it is stored in the corresponding viewer)
+ bool isComponent = false;
+ SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
+ bool needRepaint = false;
+
// Copy the selection
SALOME_ListIteratorOfListIO itInit( Sel->StoredIObjects() );
SALOME_ListIO selList;
for (; itInit.More(); itInit.Next()) {
- selList.Append(itInit.Value());
+ Handle(SALOME_InteractiveObject) IObject = itInit.Value();
+ if ( IObject->hasEntry() ) {
+ // check whether the component is selected
+ SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry() );
+ if ( !obj->_is_nil() && strcmp( obj->GetFatherComponent()->GetID(), obj->GetID() ) == 0 ) {
+ selList.Clear();
+ isComponent = true;
+ selList.Append( IObject );
+ break;
+ }
+ }
+ selList.Append( IObject );
}
-
- SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
- bool needRepaint = false;
-
if (id == QAD_DisplayOnly_Popup_ID)
viewFrame->EraseAll();
- SALOME_ListIteratorOfListIO It( selList );
- for(;It.More();It.Next()) {
- Handle(SALOME_InteractiveObject) IObject = It.Value();
-
- // First check whether the object is a component or a child object
- bool isComponent = false;
-
- if (!IObject->hasEntry()) continue;
-
- SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry());
- if (!obj->_is_nil()) {
- SALOMEDS::SComponent_var comp = obj->GetFatherComponent();
- isComponent = (strcmp(comp->GetID(), obj->GetID()) == 0);
- }
-
- // For component -> display all children
- if (isComponent) {
- SALOMEDS::ChildIterator_ptr it = aStudy->NewChildIterator(obj);
- it->InitEx(true);
- for ( ; it->More(); it->Next()) {
- SALOMEDS::SObject_ptr child = it->Value();
+ // For component -> display all children
+ if ( isComponent ) {
+ SALOMEDS::SObject_var obj = aStudy->FindObjectID( selList.First()->getEntry() );
+ SALOMEDS::ChildIterator_ptr It = aStudy->NewChildIterator( obj );
+ It->InitEx( true );
+ for ( ; It->More(); It->Next() ) {
+ SALOMEDS::SObject_ptr child = It->Value();
+ SALOMEDS::SObject_ptr ref;
+ if ( !child->ReferencedObject( ref ) ) {
Handle(SALOME_InteractiveObject) childIObject = new SALOME_InteractiveObject();
- childIObject->setEntry(child->GetID());
-
+ childIObject->setEntry( child->GetID() );
// Ensure that proper 3D presentation exists for IObject
aGUI->BuildPresentation(childIObject);
viewFrame->Display(childIObject, false);
needRepaint = true;
}
- } else { // for child object -> simply display it (no children are displayed)
+ }
+ }
+ else { // for child object -> simply display it (no children are displayed)
+ SALOME_ListIteratorOfListIO It( selList );
+ for( ;It.More();It.Next() ) {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
// Ensure that proper 3D presentation exists for IObject
aGUI->BuildPresentation(IObject);
viewFrame->Display(IObject, false);
needRepaint = true;
}
-
}
- if (needRepaint)
+ if ( needRepaint )
viewFrame->Repaint();
myActiveStudy->updateObjBrowser(true);
// Module : SALOME
// $Header$
-using namespace std;
+#include "SALOMEGUI_Swig.hxx"
+
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_Study.h"
#include "QAD_RightFrame.h"
#include "QAD_StudyFrame.h"
-#include "SALOMEGUI_Swig.hxx"
-#include "utilities.h"
+
+#include "SALOME_Event.hxx"
#include "SALOME_Selection.h"
#include "SALOME_InteractiveObject.hxx"
#include "SALOME_ListIteratorOfListIO.hxx"
+#include "utilities.h"
+
+using namespace std;
+
+namespace SALOME{
+ QAD_ViewFrame* GetViewFrame(QAD_Study* theStudy){
+ return theStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
+ }
+
+ Handle(SALOME_InteractiveObject) FindIObject(QAD_Study* theStudy, const char *theEntry)
+ {
+ return GetViewFrame(theStudy)->FindIObject(theEntry);
+ }
+}
+
/*!
Constructor
*/
SALOMEGUI_Swig::SALOMEGUI_Swig()
-// VSR 06-05-03 : _studyId(0)
{
// MESSAGE("Constructeur");
}
*/
QAD_Study* SALOMEGUI_Swig::getActiveStudy()
{
- QAD_Application* app = QAD_Application::getDesktop()->getActiveApp();
- if ( app ) return app->getActiveStudy();
+ if(QAD_Application* app = QAD_Application::getDesktop()->getActiveApp())
+ return app->getActiveStudy();
return 0;
}
*/
void SALOMEGUI_Swig::updateObjBrowser( bool updateSelection )
{
- // VSR 06-05-03 ============================================================
- //QAD_Study* myActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
- QAD_Study* myActiveStudy = getActiveStudy();
- if ( !myActiveStudy) return;
- // end of VSR 06-05-03 =====================================================
- myActiveStudy->updateObjBrowser( updateSelection );
+ if(QAD_Study* myActiveStudy = getActiveStudy())
+ ProcessVoidEvent(new TVoidMemFun1ArgEvent<QAD_Study,bool>
+ (myActiveStudy,&QAD_Study::updateObjBrowser,updateSelection));
}
/*!
*/
int SALOMEGUI_Swig::getActiveStudyId()
{
- // NRI 24-02-03 :
- // if (_studyId ==0)
- // {
- // QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
- // _name = myStudy->getTitle();
-
- // VSR 06-05-03 ============================================================
- // _studyId = QAD_Application::getDesktop()->getActiveStudy()->getStudyId();
- int _studyId = 0;
- QAD_Study* myActiveStudy = getActiveStudy();
- if ( myActiveStudy) _studyId = myActiveStudy->getStudyId();
- // SCRUTE(_studyId);
- // end of VSR 06-05-03 =====================================================
- // }
- return _studyId;
+ if(QAD_Study* myActiveStudy = getActiveStudy())
+ return myActiveStudy->getStudyId();
+ return 0;
}
/*!
*/
const char *SALOMEGUI_Swig::getActiveStudyName()
{
- // VSR 06-05-03 ============================================================
- // QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
- // _name = myStudy->getTitle();
- QString _name = QString::null;
- QAD_Study* myActiveStudy = getActiveStudy();
- if ( myActiveStudy) _name = myActiveStudy->getTitle();
- // end of VSR 06-05-03 =====================================================
-
- // NRI 24-02-03 :
- //if (_studyId ==0)
- // getActiveStudyId();
- return _name.latin1();
+ if(QAD_Study* myActiveStudy = getActiveStudy())
+ return myActiveStudy->getTitle().latin1();
+ return QString::null;
}
/*!
*/
int SALOMEGUI_Swig::SelectedCount()
{
- // VSR 06-05-03 ============================================================
- //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
- QAD_Study* myStudy = getActiveStudy();
- if ( !myStudy) return 0;
- // end of VSR 06-05-03 =====================================================
- SALOME_Selection* Sel
- = SALOME_Selection::Selection( myStudy->getSelection() );
- return Sel->IObjectCount();
+ if(QAD_Study* myStudy = getActiveStudy()){
+ SALOME_Selection* Sel = SALOME_Selection::Selection(myStudy->getSelection());
+ return Sel->IObjectCount();
+ }
+ return 0;
}
/*!
*/
const char* SALOMEGUI_Swig::getSelected(int i)
{
- // VSR 06-05-03 ============================================================
- //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
- QAD_Study* myStudy = getActiveStudy();
- if ( !myStudy) return "";
- // end of VSR 06-05-03 =====================================================
- SALOME_Selection* Sel
- = SALOME_Selection::Selection( myStudy->getSelection() );
- SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
- int index = 0;
- for(;It.More();It.Next())
- {
- Handle(SALOME_InteractiveObject) IObject = It.Value();
- if ( i == index++ )
- {
+ if(QAD_Study* myStudy = getActiveStudy()){
+ SALOME_Selection* Sel = SALOME_Selection::Selection( myStudy->getSelection() );
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ int index = 0;
+ for(;It.More();It.Next()){
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+ if( i == index++ ){
if ( IObject->hasEntry() )
return IObject->getEntry();
}
}
+ }
return "";
}
/*!
Add object with Entry into selection.
*/
-void SALOMEGUI_Swig::AddIObject(const char *Entry)
+void SALOMEGUI_Swig::AddIObject(const char *theEntry)
{
- // VSR 06-05-03 ============================================================
- //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
- QAD_Study* myStudy = getActiveStudy();
- if ( !myStudy) return;
- // end of VSR 06-05-03 =====================================================
- SALOME_Selection* Sel
- = SALOME_Selection::Selection( myStudy->getSelection() );
-
- if ( !IsInCurrentView( Entry ) )
- return;
-
- Handle(SALOME_InteractiveObject) IO =
- myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry );
- Sel->AddIObject( IO );
+ if(QAD_Study* myStudy = getActiveStudy()){
+ SALOME_Selection* aSel = SALOME_Selection::Selection( myStudy->getSelection() );
+ if(IsInCurrentView(theEntry)){
+ Handle(SALOME_InteractiveObject) anIO = SALOME::FindIObject(myStudy,theEntry);
+ if(anIO.IsNull()) return;
+ ProcessEvent(new TMemFun2ArgEvent<SALOME_Selection,int,
+ const Handle(SALOME_InteractiveObject)&,bool,
+ Handle(SALOME_InteractiveObject)>
+ (aSel,&SALOME_Selection::AddIObject,anIO,true));
+ }
+ }
}
/*!
Removes object with Entry into selection.
*/
-void SALOMEGUI_Swig::RemoveIObject(const char *Entry)
+void SALOMEGUI_Swig::RemoveIObject(const char *theEntry)
{
- // VSR 06-05-03 ============================================================
- //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
- QAD_Study* myStudy = getActiveStudy();
- if ( !myStudy) return;
- // end of VSR 06-05-03 =====================================================
- SALOME_Selection* Sel
- = SALOME_Selection::Selection( myStudy->getSelection() );
-
- if ( !IsInCurrentView( Entry ) )
- return;
-
- Handle(SALOME_InteractiveObject) IO =
- myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry );
- Sel->RemoveIObject( IO );
+ if(QAD_Study* myStudy = getActiveStudy()){
+ SALOME_Selection* aSel = SALOME_Selection::Selection( myStudy->getSelection() );
+ if(IsInCurrentView(theEntry)){
+ Handle(SALOME_InteractiveObject) anIO = SALOME::FindIObject(myStudy,theEntry);
+ if(anIO.IsNull()) return;
+ ProcessEvent(new TMemFun2ArgEvent<SALOME_Selection,int,
+ const Handle(SALOME_InteractiveObject)&,bool,
+ Handle(SALOME_InteractiveObject)>
+ (aSel,&SALOME_Selection::RemoveIObject,anIO,true));
+ }
+ }
}
*/
void SALOMEGUI_Swig::ClearIObjects()
{
- // VSR 06-05-03 ============================================================
- //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
- QAD_Study* myStudy = getActiveStudy();
- if ( !myStudy) return;
- // end of VSR 06-05-03 =====================================================
- SALOME_Selection* Sel
- = SALOME_Selection::Selection( myStudy->getSelection() );
- Sel->ClearIObjects();
+ if(QAD_Study* myStudy = getActiveStudy()){
+ SALOME_Selection* aSel = SALOME_Selection::Selection( myStudy->getSelection() );
+ ProcessVoidEvent(new TVoidMemFunEvent<SALOME_Selection>
+ (aSel,&SALOME_Selection::ClearIObjects));
+ }
}
/*!
Display
*/
-void SALOMEGUI_Swig::Display(const char *Entry)
+void SALOMEGUI_Swig::Display(const char *theEntry)
{
- // VSR 06-05-03 ============================================================
- //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
- QAD_Study* myStudy = getActiveStudy();
- if ( !myStudy) return;
- // end of VSR 06-05-03 =====================================================
-
- if ( !IsInCurrentView( Entry ) )
- return;
-
- Handle(SALOME_InteractiveObject) IO =
- myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry );
-
- myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->Display(IO);
+ if(QAD_Study* myStudy = getActiveStudy()){
+ if(IsInCurrentView(theEntry)){
+ Handle(SALOME_InteractiveObject) anIO = SALOME::FindIObject(myStudy,theEntry);
+ if(anIO.IsNull()) return;
+ QAD_ViewFrame* aViewFrame = SALOME::GetViewFrame(myStudy);
+ ProcessVoidEvent(new TVoidMemFun2ArgEvent<QAD_ViewFrame,
+ const Handle(SALOME_InteractiveObject)&,bool,
+ Handle(SALOME_InteractiveObject)>
+ (aViewFrame,&QAD_ViewFrame::Display,anIO,true));
+ }
+ }
}
/*!
Display only
*/
-void SALOMEGUI_Swig::DisplayOnly(const char *Entry)
+void SALOMEGUI_Swig::DisplayOnly(const char *theEntry)
{
- // VSR 06-05-03 ============================================================
- //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
- QAD_Study* myStudy = getActiveStudy();
- if ( !myStudy) return;
- // end of VSR 06-05-03 =====================================================
-
- if ( !IsInCurrentView( Entry ) )
- return;
-
- Handle(SALOME_InteractiveObject) IO =
- myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry );
-
- if ( !IO.IsNull() ) {
- myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->DisplayOnly(IO);
+ if(QAD_Study* myStudy = getActiveStudy()){
+ if(IsInCurrentView(theEntry)){
+ Handle(SALOME_InteractiveObject) anIO = SALOME::FindIObject(myStudy,theEntry);
+ if(anIO.IsNull()) return;
+ QAD_ViewFrame* aViewFrame = SALOME::GetViewFrame(myStudy);
+ ProcessVoidEvent(new TVoidMemFun1ArgEvent<QAD_ViewFrame,
+ const Handle(SALOME_InteractiveObject)&,
+ Handle(SALOME_InteractiveObject)>
+ (aViewFrame,&QAD_ViewFrame::DisplayOnly,anIO));
+ }
}
}
/*!
Erase
*/
-void SALOMEGUI_Swig::Erase(const char *Entry)
+void SALOMEGUI_Swig::Erase(const char *theEntry)
{
- // VSR 06-05-03 ============================================================
- //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
- QAD_Study* myStudy = getActiveStudy();
- if ( !myStudy) return;
- // end of VSR 06-05-03 =====================================================
-
- if ( !IsInCurrentView( Entry ) )
- return;
-
- Handle(SALOME_InteractiveObject) IO =
- myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry );
-
- myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->Erase(IO);
+ if(QAD_Study* myStudy = getActiveStudy()){
+ if(IsInCurrentView(theEntry)){
+ Handle(SALOME_InteractiveObject) anIO = SALOME::FindIObject(myStudy,theEntry);
+ if(anIO.IsNull()) return;
+ QAD_ViewFrame* aViewFrame = SALOME::GetViewFrame(myStudy);
+ ProcessVoidEvent(new TVoidMemFun2ArgEvent<QAD_ViewFrame,
+ const Handle(SALOME_InteractiveObject)&,bool,
+ Handle(SALOME_InteractiveObject)>
+ (aViewFrame,&QAD_ViewFrame::Erase,anIO,true));
+ }
+ }
}
/*!
*/
void SALOMEGUI_Swig::DisplayAll()
{
- // VSR 06-05-03 ============================================================
- //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
- QAD_Study* myStudy = getActiveStudy();
- if ( !myStudy) return;
- // end of VSR 06-05-03 =====================================================
- myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->DisplayAll();
+ if(QAD_Study* myStudy = getActiveStudy()){
+ QAD_ViewFrame* aViewFrame = SALOME::GetViewFrame(myStudy);
+ ProcessVoidEvent(new TVoidMemFunEvent<QAD_ViewFrame>
+ (aViewFrame,&QAD_ViewFrame::DisplayAll));
+ }
}
/*!
*/
void SALOMEGUI_Swig::EraseAll()
{
- // VSR 06-05-03 ============================================================
- //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
- QAD_Study* myStudy = getActiveStudy();
- if ( !myStudy) return;
- // end of VSR 06-05-03 =====================================================
- SALOME_Selection* Sel
- = SALOME_Selection::Selection( myStudy->getSelection() );
-
- Sel->ClearIObjects();
- myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->EraseAll();
+ ClearIObjects();
+ if(QAD_Study* myStudy = getActiveStudy()){
+ QAD_ViewFrame* aViewFrame = SALOME::GetViewFrame(myStudy);
+ ProcessVoidEvent(new TVoidMemFunEvent<QAD_ViewFrame>
+ (aViewFrame,&QAD_ViewFrame::EraseAll));
+ }
}
/*!
Checks if object is displayed in current viewer
*/
-bool SALOMEGUI_Swig::IsInCurrentView(const char *Entry)
+bool SALOMEGUI_Swig::IsInCurrentView(const char *theEntry)
{
- // VSR 06-05-03 ============================================================
- //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
- QAD_Study* myStudy = getActiveStudy();
- if ( !myStudy) return false;
- // end of VSR 06-05-03 =====================================================
- return myStudy->isInViewer( Entry, myStudy->getActiveStudyFrame()->entry() );
+ if(QAD_Study* myStudy = getActiveStudy())
+ return myStudy->isInViewer( theEntry, myStudy->getActiveStudyFrame()->entry() );
+ return false;
}
-
-/*!
- Gets VTK renderer if available
-*/
-//san:T3.13 - move getRenderer() implementation from here to SalomePy.cxx
-/*vtkRenderer *SALOMEGUI_Swig::getRenderer(int viewId)
-{
- // VSR 06-05-03 ============================================================
- //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
- QAD_Application* app = QAD_Application::getDesktop()->getActiveApp();
- if ( !app ) return NULL;
- QAD_Study* myStudy = app->getActiveStudy();
- if ( !myStudy) return NULL;
- // end of VSR 06-05-03 =====================================================
- int nbStudyFrames = myStudy->getStudyFramesCount();
- vtkRenderer *myRenderer = NULL;
- if (viewId == -1) // find the first frame with VTK viewer & get renderer
- {
- int i=0;
- for(i=0; i<nbStudyFrames; i++)
- {
- if ( myStudy->getStudyFrame(i)->getTypeView() == VIEW_VTK )
- {
- myRenderer = myStudy->getStudyFrame(i)->getRightFrame()->getViewFrame()->getRenderer();
- break;
- }
- }
- }
- else // get the VTK renderer of a given frame
- {
- SCRUTE(viewId);
- if ((viewId >=0) && (viewId <nbStudyFrames))
- myRenderer = myStudy->getStudyFrame(viewId)->getRightFrame()->getViewFrame()->getRenderer();
- }
- if (myRenderer == NULL) MESSAGE("No VTK Renderer available !");
- return myRenderer;
-}
-*/
-
#include <Standard.hxx>
-class vtkRenderer;
+#include "SALOME_InteractiveObject.hxx"
+
class QAD_Study;
+class QAD_ViewFrame;
+
+namespace SALOME{
+ QAD_ViewFrame* GetViewFrame(QAD_Study* theStudy);
+ Handle(SALOME_InteractiveObject) FindIObject(QAD_Study* theStudy, const char *theEntry);
+}
+
class SALOMEGUI_Swig
{
SALOMEGUI_Swig();
~SALOMEGUI_Swig();
- //san:T3.13 - move getRenderer() implementation from here to SalomePy.cxx
- //static vtkRenderer* getRenderer(int viewId = -1);
-
void updateObjBrowser( bool updateSelection );
QAD_Study* getActiveStudy();
int getActiveStudyId();
}
if ( !bEmptyRow ) { // Skip rows with no data !!!
// set row title
- tblIntAttr->SetRowTitle( nRow+1, rowTitles[ i ].isNull() ? strdup( "" ) : strdup( rowTitles[ i ] ) );
+ tblIntAttr->SetRowTitle( nRow+1, rowTitles[ i ].isNull() ? QString( "" ) : QString( rowTitles[ i ] ) );
// set row unit
- tblIntAttr->SetRowUnit( nRow+1, units[ i ].isNull() ? strdup( "" ) : strdup( units[ i ] ) );
+ tblIntAttr->SetRowUnit( nRow+1, units[ i ].isNull() ? QString( "" ) : QString( units[ i ] ) );
nRow++;
}
}
if ( nRow > 0 ) { // Set columns only if table is not empty, otherwise exception is raised !!!
// column titles
for ( i = 0; i < colTitles.count(); i++ )
- tblIntAttr->SetColumnTitle( i+1, colTitles[ i ].isNull() ? strdup( "" ) : strdup( colTitles[ i ] ) );
+ tblIntAttr->SetColumnTitle( i+1, colTitles[ i ].isNull() ? QString( "" ) : QString( colTitles[ i ] ) );
}
}
// title
}
if ( !bEmptyRow ) { // Skip rows with no data !!!
// set row title
- tblRealAttr->SetRowTitle( nRow+1, rowTitles[ i ].isNull() ? strdup( "" ) : strdup( rowTitles[ i ] ) );
+ tblRealAttr->SetRowTitle( nRow+1, rowTitles[ i ].isNull() ? QString( "" ) : QString( rowTitles[ i ] ) );
// set row unit
- tblRealAttr->SetRowUnit( nRow+1, units[ i ].isNull() ? strdup( "" ) : strdup( units[ i ] ) );
+ tblRealAttr->SetRowUnit( nRow+1, units[ i ].isNull() ? QString( "" ) : QString( units[ i ] ) );
nRow++;
}
}
if ( nRow > 0 ) { // Set columns only if table is not empty, otherwise exception is raised !!!
// column titles
for ( i = 0; i < colTitles.count(); i++ )
- tblRealAttr->SetColumnTitle( i+1, colTitles[ i ].isNull() ? strdup( "" ) : strdup( colTitles[ i ] ) );
+ tblRealAttr->SetColumnTitle( i+1, colTitles[ i ].isNull() ? QString( "" ) : QString( colTitles[ i ] ) );
}
}
// title
try {
SALOMEGUI_Table* tbl = myIntTable->getTable();
// title
- myIntTable->setTableTitle( strdup( tblIntAttr->GetTitle() ) );
+ myIntTable->setTableTitle( CORBA::string_dup( tblIntAttr->GetTitle() ) );
// nb of rows & cols
int nbRows = tblIntAttr->GetNbRows() ;
int nbCols = tblIntAttr->GetNbColumns();
SALOMEDS::StringSeq_var rowTitles = tblIntAttr->GetRowTitles();
for ( i = 0; i < nbRows; i++ ) {
if ( rowTitles->length() > 0 )
- strlist.append( strdup( rowTitles[i] ) );
+ strlist.append( CORBA::string_dup( rowTitles[i] ) );
else
strlist.append( "" );
}
SALOMEDS::StringSeq_var colTitles = tblIntAttr->GetColumnTitles();
for ( i = 0; i < nbCols; i++ ) {
if ( colTitles->length() > 0 )
- strlist.append( strdup( colTitles[i] ) );
+ strlist.append( CORBA::string_dup( colTitles[i] ) );
else
strlist.append( "" );
}
SALOMEDS::StringSeq_var rowUnits = tblIntAttr->GetRowUnits();
if ( rowUnits->length() > 0 ) {
for ( i = 0; i < nbRows; i++ )
- strlist.append( strdup( rowUnits[i] ) );
+ strlist.append( CORBA::string_dup( rowUnits[i] ) );
myIntTable->setUnits( strlist );
}
// data
try {
SALOMEGUI_Table* tbl = myRealTable->getTable();
// title
- myRealTable->setTableTitle( strdup( tblRealAttr->GetTitle() ) );
+ myRealTable->setTableTitle( CORBA::string_dup( tblRealAttr->GetTitle() ) );
// nb of rows & cols
int nbRows = tblRealAttr->GetNbRows() ;
int nbCols = tblRealAttr->GetNbColumns();
SALOMEDS::StringSeq_var rowTitles = tblRealAttr->GetRowTitles();
for ( i = 0; i < nbRows; i++ ) {
if ( rowTitles->length() > 0 )
- strlist.append( strdup( rowTitles[i] ) );
+ strlist.append( CORBA::string_dup( rowTitles[i] ) );
else
strlist.append( "" );
}
SALOMEDS::StringSeq_var colTitles = tblRealAttr->GetColumnTitles();
for ( i = 0; i < nbCols; i++ ) {
if ( colTitles->length() > 0 )
- strlist.append( strdup( colTitles[i] ) );
+ strlist.append( CORBA::string_dup( colTitles[i] ) );
else
strlist.append( "" );
}
SALOMEDS::StringSeq_var rowUnits = tblRealAttr->GetRowUnits();
if ( rowUnits->length() > 0 ) {
for ( i = 0; i < nbRows; i++ )
- strlist.append( strdup( rowUnits[i] ) );
+ strlist.append( CORBA::string_dup( rowUnits[i] ) );
myRealTable->setUnits( strlist );
}
// data
#endif
class Standard_NoSuchObject;
class SALOME_InteractiveObject;
-class TColStd_MapOfInteger;
+class TColStd_IndexedMapOfInteger;
class TColStd_MapTransientHasher;
class SALOME_DataMapOfIOMapOfInteger;
class SALOME_DataMapNodeOfDataMapOfIOMapOfInteger;
Standard_EXPORT SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger(const SALOME_DataMapOfIOMapOfInteger& aMap);
Standard_EXPORT void Initialize(const SALOME_DataMapOfIOMapOfInteger& aMap) ;
Standard_EXPORT const Handle_SALOME_InteractiveObject& Key() const;
-Standard_EXPORT const TColStd_MapOfInteger& Value() const;
+Standard_EXPORT const TColStd_IndexedMapOfInteger& Value() const;
#ifndef _SALOME_InteractiveObject_HeaderFile
#include "SALOME_InteractiveObject.hxx"
#endif
-#ifndef _TColStd_MapOfInteger_HeaderFile
-#include <TColStd_MapOfInteger.hxx>
+#ifndef _TColStd_IndexedMapOfInteger_HeaderFile
+#include <TColStd_IndexedMapOfInteger.hxx>
#endif
#ifndef _TColStd_MapTransientHasher_HeaderFile
#include <TColStd_MapTransientHasher.hxx>
#define TheKey Handle_SALOME_InteractiveObject
#define TheKey_hxx "SALOME_InteractiveObject.hxx"
-#define TheItem TColStd_MapOfInteger
-#define TheItem_hxx <TColStd_MapOfInteger.hxx>
+#define TheItem TColStd_IndexedMapOfInteger
+#define TheItem_hxx <TColStd_IndexedMapOfInteger.hxx>
#define Hasher TColStd_MapTransientHasher
#define Hasher_hxx <TColStd_MapTransientHasher.hxx>
#define TCollection_DataMapNode SALOME_DataMapNodeOfDataMapOfIOMapOfInteger
#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
#include <Handle_SALOME_InteractiveObject.hxx>
#endif
-#ifndef _TColStd_MapOfInteger_HeaderFile
-#include <TColStd_MapOfInteger.hxx>
+#ifndef _TColStd_IndexedMapOfInteger_HeaderFile
+#include <TColStd_IndexedMapOfInteger.hxx>
#endif
#ifndef _TCollection_MapNode_HeaderFile
#include <TCollection_MapNode.hxx>
#include <TCollection_MapNodePtr.hxx>
#endif
class SALOME_InteractiveObject;
-class TColStd_MapOfInteger;
+class TColStd_IndexedMapOfInteger;
class TColStd_MapTransientHasher;
class SALOME_DataMapOfIOMapOfInteger;
class SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger;
// }
// Methods PUBLIC
//
-Standard_EXPORT inline SALOME_DataMapNodeOfDataMapOfIOMapOfInteger(const Handle(SALOME_InteractiveObject)& K,const TColStd_MapOfInteger& I,const TCollection_MapNodePtr& n);
+Standard_EXPORT inline SALOME_DataMapNodeOfDataMapOfIOMapOfInteger(const Handle(SALOME_InteractiveObject)& K,const TColStd_IndexedMapOfInteger& I,const TCollection_MapNodePtr& n);
Standard_EXPORT inline Handle_SALOME_InteractiveObject& Key() const;
-Standard_EXPORT inline TColStd_MapOfInteger& Value() const;
+Standard_EXPORT inline TColStd_IndexedMapOfInteger& Value() const;
Standard_EXPORT ~SALOME_DataMapNodeOfDataMapOfIOMapOfInteger();
// Fields PRIVATE
//
Handle_SALOME_InteractiveObject myKey;
-TColStd_MapOfInteger myValue;
+TColStd_IndexedMapOfInteger myValue;
};
#define TheKey Handle_SALOME_InteractiveObject
#define TheKey_hxx "SALOME_InteractiveObject.hxx"
-#define TheItem TColStd_MapOfInteger
-#define TheItem_hxx <TColStd_MapOfInteger.hxx>
+#define TheItem TColStd_IndexedMapOfInteger
+#define TheItem_hxx <TColStd_IndexedMapOfInteger.hxx>
#define Hasher TColStd_MapTransientHasher
#define Hasher_hxx <TColStd_MapTransientHasher.hxx>
#define TCollection_DataMapNode SALOME_DataMapNodeOfDataMapOfIOMapOfInteger
#ifndef _SALOME_InteractiveObject_HeaderFile
#include "SALOME_InteractiveObject.hxx"
#endif
-#ifndef _TColStd_MapOfInteger_HeaderFile
-#include <TColStd_MapOfInteger.hxx>
+#ifndef _TColStd_IndexedMapOfInteger_HeaderFile
+#include <TColStd_IndexedMapOfInteger.hxx>
#endif
#ifndef _TColStd_MapTransientHasher_HeaderFile
#include <TColStd_MapTransientHasher.hxx>
Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger::~Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger() {}
#define TheKey Handle_SALOME_InteractiveObject
#define TheKey_hxx "SALOME_InteractiveObject.hxx"
-#define TheItem TColStd_MapOfInteger
-#define TheItem_hxx <TColStd_MapOfInteger.hxx>
+#define TheItem TColStd_IndexedMapOfInteger
+#define TheItem_hxx <TColStd_IndexedMapOfInteger.hxx>
#define Hasher TColStd_MapTransientHasher
#define Hasher_hxx <TColStd_MapTransientHasher.hxx>
#define TCollection_DataMapNode SALOME_DataMapNodeOfDataMapOfIOMapOfInteger
class Standard_DomainError;
class Standard_NoSuchObject;
class SALOME_InteractiveObject;
-class TColStd_MapOfInteger;
+class TColStd_IndexedMapOfInteger;
class TColStd_MapTransientHasher;
class SALOME_DataMapNodeOfDataMapOfIOMapOfInteger;
class SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger;
Clear();
}
-Standard_EXPORT Standard_Boolean Bind(const Handle(SALOME_InteractiveObject)& K,const TColStd_MapOfInteger& I) ;
+Standard_EXPORT Standard_Boolean Bind(const Handle(SALOME_InteractiveObject)& K,const TColStd_IndexedMapOfInteger& I) ;
Standard_EXPORT Standard_Boolean IsBound(const Handle(SALOME_InteractiveObject)& K) const;
Standard_EXPORT Standard_Boolean UnBind(const Handle(SALOME_InteractiveObject)& K) ;
-Standard_EXPORT const TColStd_MapOfInteger& Find(const Handle(SALOME_InteractiveObject)& K) const;
- const TColStd_MapOfInteger& operator()(const Handle(SALOME_InteractiveObject)& K) const
+Standard_EXPORT const TColStd_IndexedMapOfInteger& Find(const Handle(SALOME_InteractiveObject)& K) const;
+ const TColStd_IndexedMapOfInteger& operator()(const Handle(SALOME_InteractiveObject)& K) const
{
return Find(K);
}
-Standard_EXPORT TColStd_MapOfInteger& ChangeFind(const Handle(SALOME_InteractiveObject)& K) ;
- TColStd_MapOfInteger& operator()(const Handle(SALOME_InteractiveObject)& K)
+Standard_EXPORT TColStd_IndexedMapOfInteger& ChangeFind(const Handle(SALOME_InteractiveObject)& K) ;
+ TColStd_IndexedMapOfInteger& operator()(const Handle(SALOME_InteractiveObject)& K)
{
return ChangeFind(K);
}
#ifndef _SALOME_InteractiveObject_HeaderFile
#include "SALOME_InteractiveObject.hxx"
#endif
-#ifndef _TColStd_MapOfInteger_HeaderFile
-#include <TColStd_MapOfInteger.hxx>
+#ifndef _TColStd_IndexedMapOfInteger_HeaderFile
+#include <TColStd_IndexedMapOfInteger.hxx>
#endif
#ifndef _TColStd_MapTransientHasher_HeaderFile
#include <TColStd_MapTransientHasher.hxx>
#define TheKey Handle_SALOME_InteractiveObject
#define TheKey_hxx "SALOME_InteractiveObject.hxx"
-#define TheItem TColStd_MapOfInteger
-#define TheItem_hxx <TColStd_MapOfInteger.hxx>
+#define TheItem TColStd_IndexedMapOfInteger
+#define TheItem_hxx <TColStd_IndexedMapOfInteger.hxx>
#define Hasher TColStd_MapTransientHasher
#define Hasher_hxx <TColStd_MapTransientHasher.hxx>
#define TCollection_DataMapNode SALOME_DataMapNodeOfDataMapOfIOMapOfInteger
// Module : SALOME
// $Header$
-using namespace std;
/*!
\class SALOME_Selection SALOME_Selection.h
\brief Selection Mechanism of Interactive Object.
#include "utilities.h"
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+using namespace std;
static QList<SALOME_Selection>& SALOME_Sel_GetSelections()
{
QAD_Study* myActiveStudy = myDesktop->getActiveStudy();
if ( !IsOk(anObject) ) {
- MESSAGE ( "The Object not authorized by Filters" )
+ if(MYDEBUG) INFOS ( "The Object not authorized by Filters" )
myActiveStudy->highlight(anObject,false, update);
return -1;
}
//! Returns the first InteractiveObject in the selection.
Handle(SALOME_InteractiveObject) SALOME_Selection::firstIObject()
{
- return myIObjects.First();
+ return myIObjects.Extent() > 0 ? myIObjects.First() : Handle(SALOME_InteractiveObject)();
}
//! Returns the last InteractiveObject in the selection.
Handle(SALOME_InteractiveObject) SALOME_Selection::lastIObject()
{
- return myIObjects.Last();
+ return myIObjects.Extent() > 0 ? myIObjects.Last() : Handle(SALOME_InteractiveObject)();
}
/*!
return myMapIOSubIndex.IsBound(IObject);
}
-void SALOME_Selection::GetIndex( const Handle(SALOME_InteractiveObject)& IObject, TColStd_MapOfInteger& theIndex )
+void SALOME_Selection::GetIndex( const Handle(SALOME_InteractiveObject)& IObject, TColStd_IndexedMapOfInteger& theIndex )
{
if ( myMapIOSubIndex.IsBound(IObject) ) {
theIndex = myMapIOSubIndex.Find(IObject);
if ( !myMapIOSubIndex.IsBound( IObject ) ) {
return false;
}
- TColStd_MapOfInteger& MapIndex = myMapIOSubIndex.ChangeFind( IObject );
+ TColStd_IndexedMapOfInteger& MapIndex = myMapIOSubIndex.ChangeFind( IObject );
return MapIndex.Contains( index );
}
-
+static bool removeIndex( TColStd_IndexedMapOfInteger& MapIndex,
+ const int Index)
+{
+ int i = MapIndex.FindIndex( Index ); // i==0 if Index is not in the MapIndex
+ if ( i ) {
+ // only the last key can be removed
+ int indexLast = MapIndex.FindKey( MapIndex.Extent() );
+ if ( indexLast == Index )
+ MapIndex.RemoveLast();
+ else {
+ TColStd_IndexedMapOfInteger aNewMap;
+ aNewMap.ReSize( MapIndex.Extent() - 1 );
+ for ( int j = 1; j <= MapIndex.Extent(); j++ ) {
+ int ind = MapIndex( j );
+ if ( ind != Index )
+ aNewMap.Add( ind );
+ }
+ MapIndex = aNewMap;
+ }
+ }
+ return i;
+}
bool SALOME_Selection::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject,
bool modeShift,
bool update)
{
- MESSAGE ( " SALOME_Selection::AddOrRemoveIndex " << index << " - " << modeShift );
+ if(MYDEBUG) INFOS( " SALOME_Selection::AddOrRemoveIndex " << index << " - " << modeShift );
QAD_Desktop* myDesktop = (QAD_Desktop*) QAD_Application::getDesktop();
QAD_Study* myActiveStudy = myDesktop->getActiveStudy();
if ( !myMapIOSubIndex.IsBound( IObject ) ) {
- TColStd_MapOfInteger Empty;
+ TColStd_IndexedMapOfInteger Empty;
myMapIOSubIndex.Bind( IObject, Empty );
}
- TColStd_MapOfInteger& MapIndex = myMapIOSubIndex.ChangeFind( IObject );
+ TColStd_IndexedMapOfInteger& MapIndex = myMapIOSubIndex.ChangeFind( IObject );
- if ( MapIndex.Contains( index )) {
- if ( modeShift ) {
- MapIndex.Remove( index );
- myActiveStudy->highlight( IObject, true, update );
- }
- } else {
- if ( !modeShift )
- MapIndex.Clear();
+ bool anIsConatains = MapIndex.Contains( index );
+ if (anIsConatains)
+ removeIndex( MapIndex, index );
+
+ if (!modeShift)
+ MapIndex.Clear();
+
+ if(!anIsConatains)
MapIndex.Add( index );
- myActiveStudy->highlight( IObject, true, update );
- emit currentSelectionChanged();
- return true;
- }
if ( MapIndex.IsEmpty() ) {
myMapIOSubIndex.UnBind( IObject );
RemoveIObject( IObject, update );
}
+ myActiveStudy->highlight( IObject, true, update );
+
emit currentSelectionChanged();
return false;
}
QAD_Study* myActiveStudy = myDesktop->getActiveStudy();
if ( !myMapIOSubIndex.IsBound( IObject ) ) {
- TColStd_MapOfInteger Empty;
+ TColStd_IndexedMapOfInteger Empty;
myMapIOSubIndex.Bind( IObject, Empty );
}
- TColStd_MapOfInteger& MapIndex = myMapIOSubIndex.ChangeFind( IObject );
+ TColStd_IndexedMapOfInteger& 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)
+ 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());
-
+ for(;It.More();It.Next())
+ MapIndex.Add(It.Key());
+ if ( MapIndex.IsEmpty() ) {
+ myMapIOSubIndex.UnBind( IObject );
+ RemoveIObject( IObject, update );
+ }
+
myActiveStudy->highlight( IObject, true, update );
- if ( MapIndex.IsEmpty() ) myMapIOSubIndex.UnBind( IObject );
+
emit currentSelectionChanged();
- return add;
+ return !MapIndex.IsEmpty();
}
bool SALOME_Selection::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject,
- const std::vector<int>& theIndices,
+ const TContainerOfId& theIndices,
bool modeShift,
bool update)
{
QAD_Study* myActiveStudy = myDesktop->getActiveStudy();
if ( !myMapIOSubIndex.IsBound( IObject ) ) {
- TColStd_MapOfInteger Empty;
+ TColStd_IndexedMapOfInteger Empty;
myMapIOSubIndex.Bind( IObject, Empty );
}
- TColStd_MapOfInteger& MapIndex = myMapIOSubIndex.ChangeFind( IObject );
+ TColStd_IndexedMapOfInteger& MapIndex = myMapIOSubIndex.ChangeFind( IObject );
- bool add = true;
-
- if (MapIndex.Contains(theIndices[0]))
- {
- if (!modeShift) return add;
- add = false;
- }
- else if (!modeShift)
+ 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() )
+ TContainerOfId::const_iterator anIter = theIndices.begin();
+ TContainerOfId::const_iterator anIterEnd = theIndices.end();
+ for(; anIter != anIterEnd; anIter++)
+ MapIndex.Add(*anIter);
+
+ if ( MapIndex.IsEmpty() ) {
myMapIOSubIndex.UnBind( IObject );
+ RemoveIObject( IObject, update );
+ }
+
+ myActiveStudy->highlight( IObject, true, update );
+
emit currentSelectionChanged();
- return add;
+ return !MapIndex.IsEmpty();
}
void SALOME_Selection::RemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, int index )
{
if ( myMapIOSubIndex.IsBound( IObject ) ) {
- TColStd_MapOfInteger& MapIndex = myMapIOSubIndex.ChangeFind( IObject );
- if ( MapIndex.Contains( index ) )
- MapIndex.Remove( index );
+ TColStd_IndexedMapOfInteger& MapIndex = myMapIOSubIndex.ChangeFind( IObject );
+ removeIndex( MapIndex, index );
}
}
+void SALOME_Selection::ClearIndex()
+{
+ myMapIOSubIndex.Clear();
+}
+
+
+//================================================================
+// Function : GEOMBase_Helper
+// Purpose : Block signal currentSelectionChanged. Use this method to
+// deactivate signal before big modification of selection.
+// After this modification this signal must be activated and
+// method SelectionChanged must be called to notify other oblects
+// ( dialogs for example )
+//================================================================
+void SALOME_Selection::BlockSignals( const bool theState )
+{
+ blockSignals( theState );
+}
+
+//================================================================
+// Function : SelectionChanged
+// Purpose : Enit signal currentSelectionChanged()
+//================================================================
+void SALOME_Selection::SelectionChanged()
+{
+ emit currentSelectionChanged();
+}
// Open CASCADE Include
#include <TColStd_MapOfInteger.hxx>
-#include <vector>
+#include <set>
enum Selection_Mode {
NodeSelection,
bool HasIndex( const Handle(SALOME_InteractiveObject)& IObject );
void GetIndex( const Handle(SALOME_InteractiveObject)& IObject,
- TColStd_MapOfInteger& theIndex );
+ TColStd_IndexedMapOfInteger& theIndex );
+ typedef std::set<int> TContainerOfId;
+
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 );
+ bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, const TContainerOfId& theIndices, bool modeShift, bool update=true );
void RemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, int index );
bool IsIndexSelected(const Handle(SALOME_InteractiveObject)& IObject, int index);
+ void ClearIndex();
+
+ void BlockSignals( const bool );
+ void SelectionChanged();
signals:
void currentSelectionChanged();
#include <iostream>
#include "SALOME_Log.hxx"
-using namespace std;
-
-SALOME_Log* SALOME_Log::_singleton = 0;
-// log line size: if too short, log line is truncated, without crash...
-char SALOME_LogStr[1024];
+using namespace std;
-SALOME_Log::SALOME_Log(): ostrstream(SALOME_LogStr,sizeof(SALOME_LogStr))
+SALOME_Log::SALOME_Log()
{
}
{
}
-SALOME_Log* SALOME_Log::Instance()
+SALOME_Log& SALOME_Log::Instance()
{
- if (_singleton == 0) _singleton = new SALOME_Log();
- return _singleton;
+ static SALOME_Log instance;
+ return instance;
}
void SALOME_Log::putMessage(std::ostream& msg)
seekp(0);
}
-
#ifndef _SALOME_LOG_HXX_
#define _SALOME_LOG_HXX_
+#include <iostream>
+#include <strstream>
+
//these declarations for files don't using OCC includes (for example HDF)
# ifdef WNT
# endif /* WNT */
-
-#include <iostream>
-#include <strstream>
-
-using namespace std;
-
-class SALOME_Log : public ostrstream
+class SALOME_Log : public std::ostrstream
{
-private:
- static SALOME_Log* _singleton;
-protected:
- //disable creation of instances: force use static SALOME_Log& Instance()
- SALOME_Log();
public:
virtual ~SALOME_Log();
- static Standard_EXPORT SALOME_Log* Instance();
+ static Standard_EXPORT SALOME_Log& Instance();
Standard_EXPORT void putMessage(std::ostream& msg);
+
+protected:
+ //disable creation of instances: force use static SALOME_Log& Instance()
+ SALOME_Log();
};
+
#define SLog SALOME_Log::Instance()
#endif
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(Logger)
-SALOME_Logger::Logger_ptr m_pInterfaceLogger; // object reference on Logger server
+#include "utilities.h"
-SALOME_Log* SALOME_Log::_singleton = 0;
+// class SALOME_LoggerClient : public SALOME_Log
+// {
+// protected:
+// SALOME_Logger::Logger_var m_pInterfaceLogger; // object reference on Logger server
+// };
-// log line size: if too short, log line is truncated, without crash...
-char SALOME_LogStr[1024];
+SALOME_Logger::Logger_ptr m_pInterfaceLogger; // object reference on Logger server
-SALOME_Log::SALOME_Log(): ostrstream(SALOME_LogStr,sizeof(SALOME_LogStr))
+SALOME_Log::SALOME_Log()
{
- cout << "SALOME_LoggerClient: constructor" << endl;
+ MESSAGE("SALOME_LoggerClient: constructor");
//get reference on object reference from NS
//and initialize m_pInterfaceLogger
}
catch( CORBA::COMM_FAILURE& )
{
- cout<<"SALOME_LoggerClient: CORBA::COMM_FAILURE: Unable to contact the Naming Service"<<endl;
+ MESSAGE("SALOME_LoggerClient: CORBA::COMM_FAILURE: Unable to contact the Naming Service");
}
catch(...)
{
- cout<<"SALOME_LoggerClient: Unknown exception dealing with Naming Service"<<endl;
+ MESSAGE("SALOME_LoggerClient: Unknown exception dealing with Naming Service");
}
if(!CORBA::is_nil(inc))
obj = inc->resolve(name);
m_pInterfaceLogger = SALOME_Logger::Logger::_narrow(obj);
if (!CORBA::is_nil(m_pInterfaceLogger))
- cout<<"SALOME_LoggerClient: Logger Server was found"<<endl;
+ MESSAGE("SALOME_LoggerClient: Logger Server was found");
break;
}
}
}
catch (const CosNaming::NamingContext::NotFound&)
{
- // cout << "Caught exception: Naming Service can't found Logger";
+ // MESSAGE("Caught exception: Naming Service can't found Logger");
}
catch (CORBA::COMM_FAILURE&)
{
- // cout << "Caught CORBA::SystemException CommFailure.";
+ // MESSAGE("Caught CORBA::SystemException CommFailure.");
}
catch (CORBA::SystemException&)
{
- // cout << "Caught CORBA::SystemException.";
+ // MESSAGE("Caught CORBA::SystemException.");
}
catch (CORBA::Exception&)
{
- // cout << "Caught CORBA::Exception.";
+ // MESSAGE("Caught CORBA::Exception.");
}
catch (...)
{
- // cout << "Caught unknown exception.";
+ // MESSAGE("Caught unknown exception.");
}
//cerr << "-----SALOME_Trace::SALOME_Trace----"<<endl;
}
{
}
-SALOME_Log* SALOME_Log::Instance()
+SALOME_Log& SALOME_Log::Instance()
{
- if (_singleton == 0) _singleton = new SALOME_Log();
- return _singleton;
+ static SALOME_Log instance;
+ return instance;
}
void SALOME_Log::putMessage(std::ostream& msg)
* The creation of Python interpretor must be protected par a C++ Lock because of C threads
*/
ThreadLock aPyLock = GetPyThreadLock("SALOME_PYQT_GUI::initInterp");
- interp=new PyInterp_PyQt();
+ interp = new PyInterp_PyQt();
+ interp->initialize();
mapInterp[StudyID] = interp;
}
// imports Python GUI module and puts it in _module attribute
QAD_Desktop* parent)
{
MESSAGE("SALOME_PYQT_GUI::OnGUIEvent");
+ ThreadLock aPyLock = GetPyThreadLock("SALOME_PYQT_GUI::OnGUIEvent");
PyLockWrapper aLock = interp->GetLockWrapper();
PyObjWrapper res(PyObject_CallMethod(_module,"OnGUIEvent","i",theCommandID));
if theComponentPaste:
aSObj = theSO.GetFatherComponent()
theInfo = theInfo + "(paste for component)"
- if not myStudyManager.Paste(aSObj):
- raise RuntimeError, "<Paste> for "+theInfo+" returns false"
+ if myStudyManager.Paste(aSObj) == None:
+ raise RuntimeError, "<Paste> for "+theInfo+" returns None object"
aNewTree = GetTree(aRoot)
aLen = len(aTree)
for a in range(0,aLen):
#--------------------------------------------------------------------------
# initialise the ORB
-orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+orb = None
+
+while orb == None:
+ orb = CORBA.ORB_init([''], CORBA.ORB_ID)
# create an LifeCycleCORBA instance
lcc = LifeCycleCORBA(orb)
+while lcc._catalog == None:
+ lcc = LifeCycleCORBA(orb)
+
#create a naming service instance
naming_service = SALOME_NamingServicePy_i(orb)
# get Study Manager reference
-obj = naming_service.Resolve('myStudyManager')
+obj=None
+while obj == None:
+ obj = naming_service.Resolve('myStudyManager')
myStudyManager = obj._narrow(SALOMEDS.StudyManager)
# create new study
myStudyId = myStudy._get_StudyId()
print myStudyId
+
subShapeList=geompy.SubShapeAll(box,ShapeTypeFace)
face=subShapeList[0]
-name = geompy.SubShapeName( face._get_Name(), box._get_Name() )
+name = geompy.SubShapeName(face, box)
print name
idface=geompy.addToStudyInFather(box,face,name)
subShellList=geompy.SubShapeAll(box,ShapeTypeShell)
shell = subShellList[0]
-name = geompy.SubShapeName( shell._get_Name(), box._get_Name() )
+name = geompy.SubShapeName(shell, box)
print name
idshell=geompy.addToStudyInFather(box,shell,name)
edgeList = geompy.SubShapeAll(face,ShapeTypeEdge)
edge=edgeList[0];
-name = geompy.SubShapeName( edge._get_Name(), face._get_Name() )
+name = geompy.SubShapeName(edge, face)
print name
idedge=geompy.addToStudyInFather(face,edge,name)
/* selection */
- Handle(SALOME_InteractiveObject) FindIObject(const char* Entry) { };
+ Handle(SALOME_InteractiveObject) FindIObject(const char* Entry) { Handle(SALOME_InteractiveObject) o; return o; };
/* display */
void Display(const Handle(SALOME_InteractiveObject)& IObject, bool immediatly = true){};
LIB_SRC=\
SALOME_Session_i.cxx \
Session_ServerThread.cxx \
- Session_ServerLauncher.cxx
+ Session_ServerLauncher.cxx \
+ SALOME_Session_SignalsHandler.cxx
# Executables targets
BIN = SALOME_Session_Server
CPPFLAGS+=$(QT_MT_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) $(HDF5_INCLUDES)
CXXFLAGS+=$(OCC_CXXFLAGS)
-LDFLAGS+=$(QT_MT_LIBS) $(HDF5_LIBS) -lSalomeHDFPersist -lSalomeNS -lSalomeGUI -lSalomeObject -lSalomeLifeCycleCORBA -lqsplitterP -lOpUtil -lPlot2d -lSalomeVTKFilter -lSALOMELocalTrace -lSalomeContainer -lRegistry -lSalomeNotification -lSalomeDS -lTOOLSDS -lSalomeGenericObj -lSalomeCatalog -lEvent
+LDFLAGS+=$(QT_MT_LIBS) $(HDF5_LIBS) -lSalomeHDFPersist -lSalomeNS -lSalomeGUI -lSalomeObject -lSalomeLifeCycleCORBA -lqsplitterP -lOpUtil -lPlot2d -lSalomeVTKFilter -lSALOMELocalTrace -lSalomeContainer -lRegistry -lSalomeNotification -lSalomeDS -lTOOLSDS -lSalomeGenericObj -lSalomeCatalog -lEvent -lSalomePrs $(CAS_LDPATH) -lTKBO -lCASCatch
@CONCLUDE@
#include "SALOME_NamingService.hxx"
#include <iostream>
#include <unistd.h>
-using namespace std;
#include <qthread.h>
#include <qapplication.h>
#include "QAD_Config.h"
#include "QAD_Tools.h"
#include "QAD_ResourceMgr.h"
-#include "Utils_CatchSignals.h"
#include "Utils_SALOME_Exception.hxx"
#include "Utils_CorbaException.hxx"
#include "SALOMEGUI_QtCatchCorbaException.hxx"
-
+#include "SALOME_Event.hxx"
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOME_Session)
#include "Session_ServerLauncher.hxx"
+extern "C" int HandleSignals(QApplication *theQApplication);
+
/*! - read arguments, define list of server to launch with their arguments.
* - wait for naming service
* - create and run a thread for launch of all servers
*
*/
-// ----------------------------------------------------------------------------
-
-
-
-// ----------------------------------------------------------------------------
-
//! CORBA server for SALOME Session
/*!
* SALOME_Session Server launches a SALOME session servant.
* - get session state
*/
+using namespace std;
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
int main(int argc, char **argv)
{
try
{
+ SALOME_Event::GetSessionThread();
+
ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
int orbArgc = 1;
SALOME_NamingService *_NS = new SALOME_NamingService(orb);
- Utils_CatchSignals aCatch;
- aCatch.Activate();
-
// CORBA Servant Launcher
-
QMutex _GUIMutex ;
QWaitCondition _ServerLaunch;
_GUIMutex.lock(); // to block Launch server thread until wait(mutex)
= new Session_ServerLauncher(argc, argv, orb, poa, &_GUIMutex, &_ServerLaunch);
myServerLauncher->start();
- MESSAGE("waiting wakeAll()");
- _ServerLaunch.wait(&_GUIMutex); // to be reseased by Launch server thread when ready:
- // atomic operation lock - unlock on mutex
- // unlock mutex: serverThread runs, calls _ServerLaunch->wakeAll()
- // this thread wakes up, and lock mutex
+ QApplication *_qappl = 0;
+
+ // Allow multiple activation/deactivation of GUI
+ while ( 1 ) {
+ MESSAGE("waiting wakeAll()");
+ _ServerLaunch.wait(&_GUIMutex); // to be reseased by Launch server thread when ready:
+ // atomic operation lock - unlock on mutex
+ // unlock mutex: serverThread runs, calls _ServerLaunch->wakeAll()
+ // this thread wakes up, and lock mutex
+
+ INFOS("Session activated, Launch IAPP...");
- INFOS("Session activated, Launch IAPP...");
+ int qappArgc = 1;
+ if ( !_qappl )
+ _qappl = new QApplication(qappArgc, argv );
- int qappArgc = 1;
- QApplication *_qappl = new QApplication(qappArgc, argv );
- INFOS("creation QApplication");
- _GUIMutex.unlock();
+ INFOS("creation QApplication");
+ _GUIMutex.unlock();
- QAD_ASSERT ( QObject::connect(_qappl, SIGNAL(lastWindowClosed()), _qappl, SLOT(quit()) ) );
- SALOMEGUI_Application* _mw = new SALOMEGUI_Application ( "MDTV-Standard", "HDF", "hdf" );
- INFOS("creation SALOMEGUI_Application");
-
- SCRUTE(_NS);
- if ( !SALOMEGUI_Application::addToDesktop ( _mw, _NS ) )
- {
+ QAD_ASSERT ( QObject::connect(_qappl, SIGNAL(lastWindowClosed()), _qappl, SLOT(quit()) ) );
+ SALOMEGUI_Application* _mw = new SALOMEGUI_Application ( "MDTV-Standard", "HDF", "hdf" );
+ INFOS("creation SALOMEGUI_Application");
+
+ SCRUTE(_NS);
+ if ( !SALOMEGUI_Application::addToDesktop ( _mw, _NS ) ) {
QAD_MessageBox::error1 ( 0,
QObject::tr("ERR_ERROR"),
QObject::tr("ERR_APP_INITFAILED"),
QObject::tr("BUT_OK") );
}
- else
- {
-
+ else {
QFileInfo prgInfo(argv[0]);
QDir prgDir(prgInfo.dirPath(true));
QAD_CONFIG->setPrgDir(prgDir); // CWD is program directory
_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");
- int _ret = _qappl->exec();
- break;
- }
- catch (SALOME::SALOME_Exception& e)
- {
- QtCatchCorbaException(e);
- }
- catch(SALOMEDS::StudyBuilder::LockProtection&)
- {
- 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("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");
+ while (1) {
+ try
+ {
+ MESSAGE("run(): starting the main event loop");
+ int _ret = HandleSignals(_qappl);
+ break;
+ }
+ catch (SALOME::SALOME_Exception& e)
+ {
+ QtCatchCorbaException(e);
+ }
+ catch(SALOMEDS::StudyBuilder::LockProtection&)
+ {
+ 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("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(...)
- {
- 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("BUT_OK") );
- }
- }
- //aCatch.Deactivate();
+ 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")+ "\n" +QObject::tr(e.what()),
+ QObject::tr("BUT_OK") );
+ }
+ catch(...)
+ {
+ 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("BUT_OK") );
+ }
+ }
QString confMsg = "Settings create "
+ QAD_CONFIG->getConfigDir().absPath() + "/" + QObject::tr("MEN_APPNAME") + ".conf";
MESSAGE (confMsg);
QAD_CONFIG->createConfigFile(true);
}
+
+ // Prepare _GUIMutex for a new GUI activation
+ _GUIMutex.lock();
+ }
+
//orb->shutdown(0);
myServerLauncher->KillAll();
- aCatch.Deactivate();
}
catch (SALOME_Exception& e)
{
{
INFOS("Caught unknown exception.");
}
- MESSAGE("End of SALOME_Session_Server");
return 0 ;
}
#include "SALOME_Session_i.hxx"
#include "SALOME_NamingService.hxx"
-#include "SALOME_Session_QThread.hxx"
+#include "SALOME_Event.hxx"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
*/
//=============================================================================
-SALOME_Session_i::SALOME_Session_i(int argc, char ** argv, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, QMutex* GUIMutex)
+SALOME_Session_i::SALOME_Session_i(int argc,
+ char ** argv,
+ CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ QMutex* GUIMutex,
+ QWaitCondition* GUILauncher)
{
_argc = argc ;
_argv = argv ;
_orb = CORBA::ORB::_duplicate(orb) ;
_poa = PortableServer::POA::_duplicate(poa) ;
_GUIMutex = GUIMutex;
- MESSAGE("constructor end");
+ _GUILauncher = GUILauncher;
+ //MESSAGE("constructor end");
}
//=============================================================================
Engines::Component_ptr SALOME_Session_i::GetVisuComponent()
{
- MESSAGE("SALOME_Session_i::GetVisuGen");
+ //MESSAGE("SALOME_Session_i::GetVisuGen");
typedef Engines::Component_ptr TGetImpl(CORBA::ORB_ptr,
PortableServer::POA_ptr,
SALOME_NamingService*,QMutex*);
SALOME_Session_i::~SALOME_Session_i()
{
- MESSAGE("destructor end");
+ //MESSAGE("destructor end");
}
//=============================================================================
{
INFOS("Caught unknown exception from Naming Service");
}
- MESSAGE("Session registered in Naming Service");
+ //MESSAGE("Session registered in Naming Service");
}
//=============================================================================
void SALOME_Session_i::GetInterface()
{
- _GUIMutex->lock() ; // get access to boolean _isGUI
- //_isGUI = _IAPPThread->running();
- if(!_isGUI)
- {
- _isGUI = TRUE ;
- //_IAPPThread->start() ;
- }
- _GUIMutex->unlock() ; // release access to boolean _isGUI
+ if( !QAD_Application::getDesktop() ) {
+ _GUILauncher->wakeAll();
+ MESSAGE("SALOME_Session_i::GetInterface() called, starting GUI...")
+ }
}
//=============================================================================
* Kills the session if there are no active studies nore GUI
*/
//=============================================================================
+class CloseEvent : public SALOME_Event
+{
+public:
+ virtual void Execute() {
+ if ( QAD_Application::getDesktop() )
+ QAD_Application::getDesktop()->closeDesktop( true );
+ }
+};
void SALOME_Session_i::StopSession()
{
- qApp->lock();
- QAD_Application::getDesktop()->closeDesktop( true );
- qApp->unlock();
+ ProcessVoidEvent( new CloseEvent() );
}
//=============================================================================
*/
//=============================================================================
+class QtLock
+{
+public:
+ QtLock() { if ( qApp ) qApp->lock(); }
+ ~QtLock() { if ( qApp ) qApp->unlock(); }
+};
+
+
SALOME::StatSession SALOME_Session_i::GetStatSession()
{
// update Session state
- //qApp->lock(); // rollback bug
_GUIMutex->lock();
- //_isGUI = _IAPPThread->running();
- _isGUI = 1;
+
_runningStudies = 0;
- if (_isGUI)
- {
- qApp->lock();
- if ( QAD_Application::getDesktop() && QAD_Application::getDesktop()->getActiveApp() )
- _runningStudies = QAD_Application::getDesktop()->getActiveApp()->getStudies().count();
- qApp->unlock();
- }
+ {
+ QtLock lock;
+ _isGUI = QAD_Application::getDesktop();
+ if ( _isGUI && QAD_Application::getDesktop()->getActiveApp() )
+ _runningStudies = QAD_Application::getDesktop()->getActiveApp()->getStudies().count();
+ }
+
_GUIMutex->unlock();
- //qApp->unlock();
+
// getting stat info
SALOME::StatSession_var myStats = new SALOME::StatSession ;
if (_runningStudies)
return myStats._retn() ;
}
+CORBA::Long SALOME_Session_i::GetActiveStudyId()
+{
+ long aStudyId=-1;
+ if( QAD_Application::getDesktop() && QAD_Application::getDesktop()->getActiveStudy()) {
+ aStudyId = QAD_Application::getDesktop()->getActiveStudy()->getStudyId();
+ }
+ return aStudyId;
+}
public virtual PortableServer::RefCountServantBase
{
public:
- SALOME_Session_i(int argc, char ** argv, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, QMutex* GUIMutex);
+ SALOME_Session_i(int argc,
+ char ** argv,
+ CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ QMutex* GUIMutex,
+ QWaitCondition* GUILauncher);
~SALOME_Session_i();
//! Launch Graphical User Interface
//! Register the servant to Naming Service
void NSregister();
+
+ CORBA::Long GetActiveStudyId();
void ping(){};
char **_argv;
CORBA::Boolean _isGUI ;
QMutex* _GUIMutex ;
+ QWaitCondition* _GUILauncher;
int _runningStudies ;
CORBA::ORB_var _orb;
PortableServer::POA_var _poa;
void Session_ServerLauncher::run()
{
- MESSAGE("Session_ServerLauncher::run");
+ //MESSAGE("Session_ServerLauncher::run");
_GUIMutex->lock(); // lock released by calling thread when ready: wait(mutex)
- MESSAGE("Server Launcher thread free to go...");
+ //MESSAGE("Server Launcher thread free to go...");
_GUIMutex->unlock();
CheckArgs();
ActivateAll();
- _ServerLaunch->wakeAll();
_orb->run(); // this thread wait, during omniORB process events
}
int argc=1;
char** argv = new char*[argc];
argv[0] = "Session";
- Session_ServerThread* aServerThread
- = new Session_ServerThread(argc, argv, _orb,_root_poa,_GUIMutex);
+ Session_SessionThread* aServerThread
+ = new Session_SessionThread(argc, argv, _orb,_root_poa,_GUIMutex,_ServerLaunch);
_serverThreads.push_front(aServerThread);
aServerThread->Init();
PortableServer::POA_ptr poa,
QMutex *GUIMutex)
{
- MESSAGE("Session_ServerThread Constructor " << argv[0]);
+ //MESSAGE("Session_ServerThread Constructor " << argv[0]);
_argc = argc;
_argv = argv;
_orb = CORBA::ORB::_duplicate(orb);
Session_ServerThread::~Session_ServerThread()
{
- MESSAGE("~Session_ServerThread "<< _argv[0]);
+ //MESSAGE("~Session_ServerThread "<< _argv[0]);
}
//=============================================================================
void Session_ServerThread::ActivateSession(int argc,
char ** argv)
+{
+ MESSAGE("Session_ServerThread::ActivateSession() not implemented!");
+}
+
+Session_SessionThread::Session_SessionThread(int argc,
+ char** argv,
+ CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ QMutex* GUIMutex,
+ QWaitCondition* GUILauncher)
+: Session_ServerThread(argc, argv, orb, poa, GUIMutex),
+ _GUILauncher( GUILauncher )
+{
+}
+
+Session_SessionThread::~Session_SessionThread()
+{
+}
+
+void Session_SessionThread::ActivateSession(int argc,
+ char ** argv)
{
try
{
INFOS("Session thread started");
SALOME_Session_i * mySALOME_Session
- = new SALOME_Session_i(argc, argv, _orb, _root_poa, _GUIMutex) ;
+ = new SALOME_Session_i(argc, argv, _orb, _root_poa, _GUIMutex, _GUILauncher) ;
PortableServer::ObjectId_var mySALOME_Sessionid
= _root_poa->activate_object(mySALOME_Session);
INFOS("poa->activate_object(mySALOME_Session)");
char ** argv);
void ActivateContainer(int argc,
char ** argv);
- void ActivateSession(int argc,
+ virtual void ActivateSession(int argc,
char ** argv);
-private:
+protected:
int _argc;
char ** _argv;
int _servType;
SALOME_NamingService *_NS;
};
+class Session_SessionThread : public Session_ServerThread
+{
+public:
+ Session_SessionThread() {}
+ Session_SessionThread(int argc,
+ char** argv,
+ CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ QMutex* GUIMutex,
+ QWaitCondition* GUILauncher);
+ virtual ~Session_SessionThread();
+
+protected:
+ virtual void ActivateSession(int argc,
+ char ** argv);
+private:
+ QWaitCondition* _GUILauncher;
+};
+
#endif
// function : GetTempDir
// purpose : Return a temp directory to store created files like "/tmp/sub_dir/"
//============================================================================
-char* SALOMEDS_Tool::GetTmpDir()
+std::string SALOMEDS_Tool::GetTmpDir()
{
//Find a temporary directory to store a file
OSD_Protection aProtection(OSD_RW, OSD_RWX, OSD_RX, OSD_RX);
aDir.Build(aProtection);
- return CORBA::string_dup(aTmpDir.ToCString());
+ return aTmpDir.ToCString();
}
//============================================================================
OSD_File anOSDFile(anOSDPath);
if(!anOSDFile.Exists()) continue;
+ OSD_Protection aProtection = anOSDFile.Protection();
+ aProtection.SetUser(OSD_RW);
+ anOSDFile.SetProtection(aProtection);
+
anOSDFile.Remove();
}
const int theNamesOnly)
{
int i, aLength = theFiles.length();
- if(aLength == 0) return NULL;
+ if(aLength == 0)
+// return NULL;
+ return (new SALOMEDS::TMPFile);
TCollection_AsciiString aTmpDir(const_cast<char*>(theFromDirectory)); //Get a temporary directory for saved a file
//Check if the file exists
if (!theNamesOnly) { // mpv 15.01.2003: if only file names must be stroed, then size of files is zero
- TCollection_AsciiString aFullPath = aTmpDir + strdup(theFiles[i]);
+ TCollection_AsciiString aFullPath = aTmpDir + CORBA::string_dup(theFiles[i]);
OSD_Path anOSDPath(aFullPath);
OSD_File anOSDFile(anOSDPath);
if(!anOSDFile.Exists()) continue;
aBufferSize += 4; //4 bytes for a number of the files that will be written to the stream;
unsigned char* aBuffer = new unsigned char[aBufferSize];
- if(aBuffer == NULL) return NULL;
+ if(aBuffer == NULL)
+// return NULL;
+ return (new SALOMEDS::TMPFile);
//Initialize 4 bytes of the buffer by 0
memset(aBuffer, 0, 4);
for(i=0; i<aLength; i++) {
ifstream *aFile;
if (!theNamesOnly) { // mpv 15.01.2003: we don't open any file if theNamesOnly = true
- TCollection_AsciiString aFullPath = aTmpDir + strdup(theFiles[i]);
+ TCollection_AsciiString aFullPath = aTmpDir + CORBA::string_dup(theFiles[i]);
OSD_Path anOSDPath(aFullPath);
OSD_File anOSDFile(anOSDPath);
if(!anOSDFile.Exists()) continue;
// function : PutStreamToFile
// purpose : converts the stream "theStream" to the files
//============================================================================
-SALOMEDS::ListOfFileNames*
+SALOMEDS::ListOfFileNames_var
SALOMEDS_Tool::PutStreamToFiles(const SALOMEDS::TMPFile& theStream,
const char* theToDirectory,
const int theNamesOnly)
delete[] aFileName;
}
- return aFiles._retn();
+ return aFiles;
}
//============================================================================
// function : GetNameFromPath
// purpose : Returns the name by the path
//============================================================================
-char* SALOMEDS_Tool::GetNameFromPath(const char* thePath) {
- if (thePath == NULL) return strdup("");
- OSD_Path aPath = OSD_Path(TCollection_AsciiString(strdup(thePath)));
+std::string SALOMEDS_Tool::GetNameFromPath(const char* thePath) {
+ if (thePath == NULL) return string("");
+ OSD_Path aPath = OSD_Path(TCollection_AsciiString((char*)thePath));
TCollection_AsciiString aNameString(aPath.Name());
- return CORBA::string_dup(aNameString.ToCString());
+ return aNameString.ToCString();
}
//============================================================================
// function : GetDirFromPath
// purpose : Returns the dir by the path
//============================================================================
-char* SALOMEDS_Tool::GetDirFromPath(const char* thePath) {
- if (thePath == NULL) return strdup("");
- OSD_Path aPath = OSD_Path(TCollection_AsciiString(strdup(thePath)));
+std::string SALOMEDS_Tool::GetDirFromPath(const char* thePath) {
+ if (thePath == NULL) return string("");
+ OSD_Path aPath = OSD_Path(TCollection_AsciiString((char*)thePath));
TCollection_AsciiString aDirString(aPath.Trek());
aDirString.ChangeAll('|','/');
- return CORBA::string_dup(aDirString.ToCString());
+ return aDirString.ToCString();
}
#ifndef __SALOMEDS_Tool_H__
#define __SALOMEDS_Tool_H__
-
+#include <string>
// IDL headers
-#include <SALOMEDS.hh>
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SALOMEDS)
class SALOMEDS_Tool
{
+
public:
// Returns the unique temporary directory, that is defined in SALOME_TMP_DIR if this variable is set
// otherwise return /tmp/something/ for Unix or c:\something\ for WNT
- static char* GetTmpDir();
+ static std::string GetTmpDir();
// Removes files which are in <theDirectory>, the files for deletion are listed in <theFiles>
const int theNamesOnly = 0);
// Converts a byte sequence <theStream> to files and places them in <theToDirectory>
- static SALOMEDS::ListOfFileNames* PutStreamToFiles(const SALOMEDS::TMPFile& theStream,
+ static SALOMEDS::ListOfFileNames_var PutStreamToFiles(const SALOMEDS::TMPFile& theStream,
const char* theToDirectory,
const int theNamesOnly = 0);
// Returns the name by the path
// for an example: if thePath = "/tmp/aaa/doc1.hdf" the function returns "doc1"
- static char* GetNameFromPath(const char* thePath);
+ static std::string GetNameFromPath(const char* thePath);
// Returns the directory by the path
// for an example: if thePath = "/tmp/aaa/doc1.hdf" the function returns "/tmp/aaa"
- static char* GetDirFromPath(const char* thePath);
+ static std::string GetDirFromPath(const char* thePath);
};
#endif
// Module : SALOME
// $Header$
-using namespace std;
#include "ToolsGUI_CatalogGeneratorDlg.h"
#include "QAD_Application.h"
#include <TCollection_AsciiString.hxx>
#include <Standard_CString.hxx>
+#include "utilities.h"
+
+using namespace std;
+
#define SPACING_SIZE 6
#define MARGIN_SIZE 11
#define MIN_EDIT_SIZE 250
QString IDLpath = "";
for (unsigned int ind = 0; ind < list_composants->length();ind++) {
- QString modulename = strdup(list_composants[ind].modulename) ;
+ QString modulename = CORBA::string_dup(list_composants[ind].modulename) ;
QCString dir;
if (dir = getenv( modulename + "_ROOT_DIR")) {
#include "Utils_CommException.hxx"
using namespace std;
+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<<"Test blocking exception was catch of the kind : ";
+ if ( *p != '\0' ) {
+ os<<p;
+ }
+ else {
+ os << tc->id();
+ }
+
+ return os;
+}
+
+
int main (int argc, char * argv[])
{
catch(CORBA::COMM_FAILURE& ex) {
INFOS("Caught system exception COMM_FAILURE -- unable to contact the object.")
}
- catch(CORBA::SystemException&) {
- INFOS("Caught a CORBA::SystemException.")
+ catch(CORBA::SystemException& e) {
+ INFOS("Caught a CORBA::SystemException."<<e)
}
- catch(CORBA::Exception&) {
- INFOS("Caught CORBA::Exception.")
+ catch(CORBA::Exception& e) {
+ INFOS("Caught CORBA::Exception."<<e)
}
catch(...) {
INFOS("Caught unknown exception.")
Utils_SINGLETON.hxx \
Utils_DESTRUCTEUR_GENERIQUE.hxx \
Utils_ExceptHandlers.hxx \
- Utils_CatchSignals.h
+ Utils_SignalsHandler.h
EXPORT_PYSCRIPTS = Utils_Identity.py SALOME_utilities.py
# Libraries targets
Utils_Identity.cxx Utils_ORB_INIT.cxx \
Utils_DESTRUCTEUR_GENERIQUE.cxx \
Utils_ExceptHandlers.cxx \
- Utils_CatchSignals.cxx
+ Utils_SignalsHandler.cxx
LIB_SERVER_IDL = SALOME_Exception.idl
// Module : SALOME
// $Header$
-using namespace std;
-void Nettoyage( void ) ;
# include <iostream>
-# include "utilities.h"
-# include "Utils_DESTRUCTEUR_GENERIQUE.hxx"
# include <list>
extern "C"
{
# include <stdlib.h>
}
-static list<DESTRUCTEUR_GENERIQUE_*> *Destructeurs=0 ;
+# include "Utils_DESTRUCTEUR_GENERIQUE.hxx"
+# include "utilities.h"
+void Nettoyage();
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+using namespace std;
+static list<DESTRUCTEUR_GENERIQUE_*> *Destructeurs=0 ;
/*! \class ATEXIT_
*
ATEXIT_( void )
{
ASSERT (Destructeurs==0);
- MESSAGE("Construction ATEXIT"); // message necessaire pour utiliser logger dans Nettoyage (cf.BUG KERNEL4561)
+ if(MYDEBUG) MESSAGE("Construction ATEXIT"); // message necessaire pour utiliser logger dans Nettoyage (cf.BUG KERNEL4561)
Destructeurs = new list<DESTRUCTEUR_GENERIQUE_*> ; // Destructeurs alloué dynamiquement (cf. ci-dessous) ,
// il est utilisé puis détruit par la fonction Nettoyage
int cr = atexit( Nettoyage ); // exécute Nettoyage lors de exit, après la destruction des données statiques !
~ATEXIT_( )
{
- MESSAGE("Destruction ATEXIT") ;
+ if(MYDEBUG) MESSAGE("Destruction ATEXIT") ;
}
};
void Nettoyage( void )
{
- BEGIN_OF("Nettoyage( void )") ;
+ if(MYDEBUG) BEGIN_OF("Nettoyage( void )") ;
ASSERT(Destructeurs) ;
- SCRUTE( Destructeurs->size() ) ;
+ if(MYDEBUG) SCRUTE( Destructeurs->size() ) ;
if( Destructeurs->size() )
{
list<DESTRUCTEUR_GENERIQUE_*>::iterator it = Destructeurs->end() ;
do
{
- MESSAGE( "DESTRUCTION d'un SINGLETON") ;
+ if(MYDEBUG) MESSAGE( "DESTRUCTION d'un SINGLETON");
it-- ;
DESTRUCTEUR_GENERIQUE_* ptr = *it ;
//Destructeurs->remove( *it ) ;
}while( it!= Destructeurs->begin() ) ;
Destructeurs->clear() ;
- SCRUTE( Destructeurs->size() ) ;
+ if(MYDEBUG) SCRUTE( Destructeurs->size() ) ;
ASSERT( Destructeurs->size()==0 ) ;
ASSERT( Destructeurs->empty() ) ;
}
delete Destructeurs;
Destructeurs=0;
- END_OF("Nettoyage( void )") ;
+ if(MYDEBUG) END_OF("Nettoyage( void )") ;
return ;
}
// <ota@localhost.localdomain>
-#include <Utils_ExceptHandlers.hxx>
+#include "Utils_ExceptHandlers.hxx"
#include "Utils_CorbaException.hxx"
#include "Utils_SALOME_Exception.hxx"
+
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOME_Exception)
#define Utils_ExceptHandlers_HeaderFile
#include <stdexcept>
-#include <utilities.h>
typedef void (*PVF)();
PVF old;
public :
Unexpect( PVF f )
- { old = set_unexpected(f); }
- ~Unexpect() { set_unexpected(old); }
+ { old = std::set_unexpected(f); }
+ ~Unexpect() { std::set_unexpected(old); }
};
class Terminate {//save / retrieve terminate function
PVF old;
public :
Terminate( PVF f )
- { old = set_terminate(f); }
- ~Terminate() { set_terminate(old); }
+ { old = std::set_terminate(f); }
+ ~Terminate() { std::set_terminate(old); }
};
#define UNEXPECT_CATCH(FuncName, ExceptionConstructor) \
-void FuncName () {\
+inline void FuncName () {\
throw ExceptionConstructor (); \
}
//Example of the usage
//Definitions :
extern void SalomeException();
extern void SALOME_SalomeException();
+
#endif
delete [] (char*)_name ;
(char*&)_name = NULL ;
- delete [] (char*)_dir ;
- (char*&)_dir = NULL ;
-
+ //delete [] (char*)_dir ;
+ //(char*&)_dir = NULL ;
+ free((char*)_dir);
+
delete [] (char*)_adip ;
(char*&)_adip = NULL ;
}
# include <exception>
# include <iostream>
-using namespace std;
-
# define LOCALIZED(message) #message , __FILE__ , __LINE__
-class SALOME_Exception : public exception
+
+class SALOME_Exception : public std::exception
{
private :
SALOME_Exception( const char *text, const char *fileName=0, const unsigned int lineNumber=0 );
SALOME_Exception( const SALOME_Exception &ex );
~SALOME_Exception() throw ();
- friend ostream & operator<<( ostream &os , const SALOME_Exception &ex );
+ friend std::ostream & operator<<( std::ostream &os , const SALOME_Exception &ex );
virtual const char *what( void ) const throw () ;
} ;
MESSAGE("Destruction du SINGLETON_") ;
- list<DESTRUCTEUR_GENERIQUE_ *>::iterator k ;
+ std::list<DESTRUCTEUR_GENERIQUE_ *>::iterator k ;
for( k=DESTRUCTEUR_GENERIQUE_::Destructeurs.begin() ; k!=DESTRUCTEUR_GENERIQUE_::Destructeurs.end();k++)
{
if ( *k == PtrSingleton->_Instance )
# include <stream.h>
using namespace std;
+#include "utilities.h"
+
static struct timezone *tz=(struct timezone*) malloc(sizeof(struct timezone));
#ifndef CLK_TCK
void Utils_Timer::Show() {
bool StopSav = Stopped;
if (!StopSav) Stop();
- cout << "CPU user time: " << Cumul_user << " seconds " << endl;
- cout << "CPU system time: " << Cumul_sys << " seconds " << endl;
+ MESSAGE("CPU user time: " << Cumul_user << " seconds ");
+ MESSAGE("CPU system time: " << Cumul_sys << " seconds ");
if (!StopSav) Start();
}
void Utils_Timer::ShowAbsolute(){
unsigned long Absolute_user = (unsigned long) ((timeval*)RefToCurrentTimeB)->tv_sec ;
- cout << "Absolute time: " << Absolute_user << " seconds " << endl;
+ MESSAGE("Absolute time: " << Absolute_user << " seconds ");
}
}
#include "utilities.h"
+using namespace std;
+
const char* duplicate( const char *const str )
{
ASSERT(str!=NULL) ;
#include <string>
#include <iostream>
-#include <cstdlib>
#include "SALOME_Log.hxx"
/* --- 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<<std::endl<<std::ends);}
+#define PYSCRIPT(msg) {SLog.putMessage(SLog<<"---PYSCRIPT--- "<<msg<<std::endl<<std::ends);}
/* --- To print date and time of compilation of current source --- */
#define COMPILER "KCC"
#elif defined ( __PGI )
#define COMPILER "pgCC"
-#elif defined ( __alpha )
-#define COMPILER "cxx"
#else
#define COMPILER "undefined"
#endif
#endif
#define INFOS_COMPILATION { \
- SLog->putMessage(\
- *SLog<<__FILE__<<" ["<< __LINE__<<"] : "\
+ SLog.putMessage(\
+ SLog<<__FILE__<<" ["<< __LINE__<<"] : "\
<< "COMPILED with " << COMPILER \
<< ", " << __DATE__ \
- << " at " << __TIME__ <<endl); }
+ << " at " << __TIME__ <<std::endl<<std::ends); }
#ifdef _DEBUG_
/* --- the following MACROS are useful at debug time --- */
-#define MYTRACE *SLog << "- Trace " << __FILE__ << " [" << __LINE__ << "] : "
+#define MYTRACE SLog<<"- Trace "<<__FILE__<<" ["<<__LINE__<<"] : "
-#define MESSAGE(msg) {SLog->putMessage( MYTRACE <<msg<<endl<<ends); }
-#define SCRUTE(var) {SLog->putMessage( MYTRACE << #var << "=" << var <<endl<<ends); }
+#define MESSAGE(msg) {SLog.putMessage(MYTRACE<<msg<<std::endl<<std::ends);}
+#define SCRUTE(var) {SLog.putMessage(MYTRACE<<#var<<"="<<var<<std::endl<<std::ends);}
-#define REPERE *SLog << " --------------" << endl
-#define BEGIN_OF(msg) {REPERE;MYTRACE<<"Begin of: " <<msg<<endl;REPERE;}
-#define END_OF(msg) {REPERE;MYTRACE<<"Normal end of: "<<msg<<endl;REPERE;}
+#define BEGIN_OF(msg) {SLog.putMessage(MYTRACE<<"Begin of: "<<msg<<"\n\n"<<std::ends);}
+#define END_OF(msg) {SLog.putMessage(SLog<<"\n"<<std::ends); \
+ SLog.putMessage(MYTRACE<<"Normal end of: "<<msg<<"\n"<<std::ends);}
-#define HERE {cout<<flush ;cerr<<"- Trace "<<__FILE__<<" ["<<__LINE__<<"] : "<<flush ;}
+#define HERE {std::cout<<std::flush ;std::cerr<<"- Trace "<<__FILE__<<" ["<<__LINE__<<"] : "<<std::flush;}
-#define INTERRUPTION(code) {HERE;cerr<<"INTERRUPTION return code= "<<code<< endl;std::exit(code);}
+#define INTERRUPTION(code) {HERE; \
+ cerr<<"INTERRUPTION return code= "<<code<<std::endl; \
+ std::exit(code);}
#ifndef ASSERT
#define ASSERT(condition) \
- if (!(condition)){HERE;cerr<<"CONDITION "<<#condition<<" NOT VERIFIED"<<endl;INTERRUPTION(1);}
+ if(!(condition)){ \
+ HERE; \
+ std::cerr<<"CONDITION "<<#condition<<" NOT VERIFIED"<<std::endl; \
+ INTERRUPTION(1); \
+ }
+
#endif /* ASSERT */
#define HERE
#define SCRUTE(var) {}
#define MESSAGE(msg) {}
-#define REPERE
#define BEGIN_OF(msg) {}
#define END_OF(msg) {}
EXPORT_HEADERS = SALOME_Transform.h \
SALOME_TransformFilter.h \
SALOME_PassThroughFilter.h \
+ SALOME_ShrinkFilter.h \
SALOME_GeometryFilter.h \
SALOME_ExtractUnstructuredGrid.h
LIB_SRC = SALOME_Transform.cxx \
SALOME_TransformFilter.cxx \
SALOME_PassThroughFilter.cxx \
+ SALOME_ShrinkFilter.cxx \
SALOME_GeometryFilter.cxx \
SALOME_ExtractUnstructuredGrid.cxx
using namespace std;
#ifdef _DEBUG_
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
#else
static int MYDEBUG = 0;
#endif
this->Modified();
}
-vtkIdType SALOME_ExtractUnstructuredGrid::GetOutId(int theOutId) const{
+vtkIdType SALOME_ExtractUnstructuredGrid::GetInputId(int theOutId) const{
if(myCellIds.empty() && myCellTypes.empty()) return theOutId;
if(myOut2InId.empty() || theOutId > myOut2InId.size()) return -1;
#if defined __GNUC_2__
#endif
}
-vtkIdType SALOME_ExtractUnstructuredGrid::GetInId(int theInId) const{
+vtkIdType SALOME_ExtractUnstructuredGrid::GetOutputId(int theInId) const{
if(myCellIds.empty() && myCellTypes.empty()) return theInId;
TMapId::const_iterator anIter = myIn2OutId.find(theInId);
if(anIter == myIn2OutId.end()) return -1;
}
}
}
- if(aNbElems = aConnectivity->GetNumberOfCells()){
+ if((aNbElems = aConnectivity->GetNumberOfCells())){
vtkIntArray* aCellLocationsArray = vtkIntArray::New();
aCellLocationsArray->SetNumberOfComponents(1);
aCellLocationsArray->SetNumberOfTuples(aNbElems);
}
}
}
- if(aNbElems = aConnectivity->GetNumberOfCells()){
+ if((aNbElems = aConnectivity->GetNumberOfCells())){
vtkIntArray* aCellLocationsArray = vtkIntArray::New();
aCellLocationsArray->SetNumberOfComponents(1);
aCellLocationsArray->SetNumberOfTuples(aNbElems);
// Remove the cell from the output
void RegisterCell(vtkIdType theCellId);
int IsCellsRegistered() { return !myCellIds.empty();}
- int ClearRegisteredCells() {
+ void ClearRegisteredCells() {
myCellIds.clear();
Modified();
}
// Remove every cells with the type from the output
void RegisterCellsWithType(vtkIdType theCellType);
int IsCellsWithTypeRegistered() { return !myCellTypes.empty();}
- int ClearRegisteredCellsWithType() {
+ void ClearRegisteredCellsWithType() {
myCellTypes.clear();
Modified();
}
void SetStoreMapping(int theStoreMapping);
int GetStoreMapping(){ return myStoreMapping;}
- vtkIdType GetOutId(int theOutId) const;
- vtkIdType GetInId(int theInId) const;
+ vtkIdType GetInputId(int theOutId) const;
+ vtkIdType GetOutputId(int theInId) const;
typedef std::vector<vtkIdType> TVectorId;
typedef std::map<vtkIdType,vtkIdType> TMapId;
}
-vtkIdType SALOME_GeometryFilter::GetObjId(int theVtkID){
+vtkIdType SALOME_GeometryFilter::GetElemObjId(int theVtkID){
if(myVTK2ObjIds.empty() || theVtkID > myVTK2ObjIds.size()) return -1;
#if defined __GNUC_2__
return myVTK2ObjIds[theVtkID];
}
-SALOME_GeometryFilter::TVectorId SALOME_GeometryFilter::GetVtkId(int theObjID){
- TVectorId aVect;
- if(myObj2VTKIds.empty() || theObjID > myObj2VTKIds.size()) return aVect;
-#if defined __GNUC_2__
- return myObj2VTKIds[theObjID];
-#else
- return myObj2VTKIds.at(theObjID);
-#endif
-}
-
-
void SALOME_GeometryFilter::UnstructuredGridExecute()
{
vtkUnstructuredGrid *input= (vtkUnstructuredGrid *)this->GetInput();
// (Have to compute visibility first for 3D cell boundarys)
int progressInterval = numCells/20 + 1;
if(myStoreMapping){
- myVTK2ObjIds.clear(); myObj2VTKIds.clear(); //apo
+ myVTK2ObjIds.clear();
myVTK2ObjIds.reserve(numCells);
- myObj2VTKIds.resize(numCells);
}
for (cellId=0, Connectivity->InitTraversal();
Connectivity->GetNextCell(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;
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;
newCellId = output->InsertNextCell(aCellType,npts,pts);
if(myStoreMapping){
myVTK2ObjIds.push_back(cellId); //apo
- myObj2VTKIds[cellId].push_back(newCellId);
}
outputCD->CopyData(cd,cellId,newCellId);
break;
newCellId = output->InsertNextCell(aCellType,npts,pts);
if(myStoreMapping){
myVTK2ObjIds.push_back(cellId); //apo
- myObj2VTKIds[cellId].push_back(newCellId);
}
outputCD->CopyData(cd,cellId,newCellId);
break;
newCellId = output->InsertNextCell(aCellType,npts,pts);
if(myStoreMapping){
myVTK2ObjIds.push_back(cellId); //apo
- myObj2VTKIds[cellId].push_back(newCellId);
}
outputCD->CopyData(cd,cellId,newCellId);
break;
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
if(myStoreMapping){
myVTK2ObjIds.push_back(cellId); //apo
- myObj2VTKIds[cellId].push_back(newCellId);
}
outputCD->CopyData(cd,cellId,newCellId);
}
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
if(myStoreMapping){
myVTK2ObjIds.push_back(cellId); //apo
- myObj2VTKIds[cellId].push_back(newCellId);
}
outputCD->CopyData(cd,cellId,newCellId);
}
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
if(myStoreMapping){
myVTK2ObjIds.push_back(cellId); //apo
- myObj2VTKIds[cellId].push_back(newCellId);
}
outputCD->CopyData(cd,cellId,newCellId);
}
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
if(myStoreMapping){
myVTK2ObjIds.push_back(cellId); //apo
- myObj2VTKIds[cellId].push_back(newCellId);
}
outputCD->CopyData(cd,cellId,newCellId);
}
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
if(myStoreMapping){
myVTK2ObjIds.push_back(cellId); //apo
- myObj2VTKIds[cellId].push_back(newCellId);
}
outputCD->CopyData(cd,cellId,newCellId);
}
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
void SetStoreMapping(int theStoreMapping);
int GetStoreMapping(){ return myStoreMapping;}
- typedef std::vector<vtkIdType> TVectorId;
- virtual vtkIdType GetObjId(int theVtkID);
- virtual TVectorId GetVtkId(int theObjID);
+ virtual vtkIdType GetNodeObjId(int theVtkID) { return theVtkID;}
+ virtual vtkIdType GetElemObjId(int theVtkID);
protected:
SALOME_GeometryFilter();
int myShowInside;
int myStoreMapping;
+ typedef std::vector<vtkIdType> TVectorId;
TVectorId myVTK2ObjIds;
- typedef std::vector<TVectorId> TVecVectorId;
- TVecVectorId myObj2VTKIds;
};
#endif
VTKViewer_ViewFrame.h \
VTKViewer_RenderWindowInteractor.h \
VTKViewer_InteractorStyleSALOME.h \
- VTKViewer_Filter.h
+ VTKViewer_Filter.h \
+ VTKViewer_Prs.h \
+ VTKViewer_Trihedron.h \
+ VTKViewer_VectorText.h
# Libraries targets
LIB = libVTKViewer.la
VTKViewer_RectPicker.cxx \
VTKViewer_CellRectPicker.cxx \
VTKViewer_Utilities.cxx \
- VTKViewer_Filter.cxx
+ VTKViewer_Filter.cxx \
+ VTKViewer_Actor.cxx \
+ VTKViewer_Prs.cxx
LIB_MOC = \
VTKViewer.h \
SALOME_Component.idl \
SALOME_Exception.idl
-CPPFLAGS+=$(QT_INCLUDES) $(OGL_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES)
-CXXFLAGS+=
-LDFLAGS+=$(VTK_LIBS) $(OGL_LIBS) $(QT_MT_LIBS) -lSalomeGUI
+CPPFLAGS+=$(QT_INCLUDES) $(OGL_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES)
+
+LDFLAGS+=$(VTK_LIBS) $(OGL_LIBS) $(QT_MT_LIBS) -lSalomePrs -lSalomeGUI
@CONCLUDE@
dir[i] = p2[i] - p1[i];
}
- input->GetCell(curData.cellId, cell2);
+ actor->GetMapper()->GetInput()->GetCell(curData.cellId, cell2);
result = IntersectCells(cell1, cellData.depth,
cell2, curData.depth, dir);
if (result > 0) {
VTKViewer_Filter();\r
virtual ~VTKViewer_Filter();\r
\r
- bool IsValid( SALOME_Actor*, const int theCellId );\r
- virtual bool IsValid( const int theCellId ) const = 0;\r
+ bool IsValid( SALOME_Actor*, const int theId );\r
+ virtual bool IsValid( const int theId ) const = 0;\r
+ virtual int GetId() const = 0;\r
+ virtual bool IsNodeFilter() const = 0;\r
\r
virtual void SetActor( SALOME_Actor* );\r
-\r
+ \r
protected:\r
\r
SALOME_Actor* myActor;\r
// $Header$
#include "VTKViewer_InteractorStyleSALOME.h"
+
#include "VTKViewer_RenderWindowInteractor.h"
#include "VTKViewer_RenderWindow.h"
+#include "VTKViewer_ViewFrame.h"
+
#include "VTKViewer_Utilities.h"
#include "VTKViewer_Trihedron.h"
#include "VTKViewer_RectPicker.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
-#include "SALOME_Selection.h"
#include "SALOME_Actor.h"
+#include "VTKViewer_Actor.h"
+#include "SALOME_Selection.h"
#include "SALOME_ListIteratorOfListIO.hxx"
#include <vtkObjectFactory.h>
#include <vtkMath.h>
#include <vtkCommand.h>
-#include <vtkAssemblyNode.h>
+#include <vtkCamera.h>
+#include <vtkRenderer.h>
#include <vtkPicker.h>
#include <vtkPointPicker.h>
#include <vtkCellPicker.h>
#include <vtkLine.h>
-#include <vtkUnstructuredGrid.h>
-#include <vtkExtractEdges.h>
-#include <vtkPolyDataMapper.h>
-#include <vtkDataSetCollection.h>
-#include <vtkImageData.h>
+#include <vtkMapper.h>
+#include <vtkDataSet.h>
+#include <vtkSmartPointer.h>
#include <qapplication.h>
//VRV: porting on Qt 3.0.5
using namespace std;
-extern int SetVisibility(vtkActorCollection* theCollection, int theParam);
-extern int GetVisibility(vtkActorCollection* theCollection);
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+
+static bool IsStored(Handle(SALOME_InteractiveObject)& theIO,
+ const SALOME_ListIO& theListIO)
+{
+ if (!theListIO.IsEmpty()){
+ SALOME_ListIteratorOfListIO anIter(theListIO);
+ for(; anIter.More(); anIter.Next()) {
+ Handle(SALOME_InteractiveObject) anIO = anIter.Value();
+ if(theIO->isSame(anIO)) {
+ theIO = anIO; //Added by SRN, fix SAL1307
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+
+static bool IsSelected(Handle(SALOME_InteractiveObject)& theIO,
+ SALOME_Selection* theSel)
+{
+ return IsStored(theIO,theSel->StoredIObjects());
+}
+
+
+static int GetEdgeId(vtkPicker *thePicker, SALOME_Actor *theActor, int theObjId){
+ int anEdgeId = -1;
+ if (vtkCell* aPickedCell = theActor->GetElemCell(theObjId)) {
+ float aPickPosition[3];
+ thePicker->GetPickPosition(aPickPosition);
+ float aMinDist = 1000000.0, aDist = 0;
+ for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){
+ if(vtkLine* aLine = vtkLine::SafeDownCast(aPickedCell->GetEdge(i))){
+ int subId; float pcoords[3], closestPoint[3], weights[3];
+ aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights);
+ if (aDist < aMinDist) {
+ aMinDist = aDist;
+ anEdgeId = i;
+ }
+ }
+ }
+ }
+ return anEdgeId;
+}
+
+
+static bool CheckDimensionId(Selection_Mode theMode, SALOME_Actor *theActor, vtkIdType theObjId){
+ switch(theMode){
+ case CellSelection:
+ return true;
+ case EdgeSelection:
+ return ( theActor->GetObjDimension( theObjId ) == 1 );
+ case FaceSelection:
+ return ( theActor->GetObjDimension( theObjId ) == 2 );
+ case VolumeSelection:
+ return ( theActor->GetObjDimension( theObjId ) == 3 );
+ };
+ return false;
+}
+
//----------------------------------------------------------------------------
vtkStandardNewMacro(VTKViewer_InteractorStyleSALOME);
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);
+ myPreSelectionActor = VTKViewer_Actor::New();
+ myPreSelectionActor->GetProperty()->SetColor(0,1,1);
+ myPreSelectionActor->GetProperty()->SetLineWidth(5);
+ myPreSelectionActor->GetProperty()->SetPointSize(5);
+
+ OnSelectionModeChanged();
}
//----------------------------------------------------------------------------
VTKViewer_InteractorStyleSALOME::~VTKViewer_InteractorStyleSALOME()
{
+ if(MYDEBUG) INFOS("VTKViewer_InteractorStyleSALOME::~VTKViewer_InteractorStyleSALOME()");
+ m_ViewFrame->RemoveActor(myPreSelectionActor);
}
//----------------------------------------------------------------------------
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);
+ myPreSelectionActor->GetProperty()->SetColor(theRed, theGreen, theBlue);
+ myPreSelectionActor->GetProperty()->SetLineWidth(theWidth);
+ myPreSelectionActor->GetProperty()->SetPointSize(theWidth);
+}
+
+//----------------------------------------------------------------------------
+void VTKViewer_InteractorStyleSALOME::SetInteractor(vtkRenderWindowInteractor *theInteractor){
+ m_Interactor = dynamic_cast<VTKViewer_RenderWindowInteractor*>(theInteractor);
+ Superclass::SetInteractor(theInteractor);
+}
+
+//----------------------------------------------------------------------------
+void VTKViewer_InteractorStyleSALOME::setViewFrame(VTKViewer_ViewFrame* theViewFrame){
+ m_ViewFrame = theViewFrame;
+ m_ViewFrame->AddActor(myPreSelectionActor);
+ myPreSelectionActor->Delete();
+}
+
+//----------------------------------------------------------------------------
+void VTKViewer_InteractorStyleSALOME::setGUIWindow(QWidget* theWindow){
+ myGUIWindow = theWindow;
}
//----------------------------------------------------------------------------
cam->Elevation(ryf);
cam->OrthogonalizeViewUp();
::ResetCameraClippingRange(this->CurrentRenderer);
- this->Interactor->Render();
+ //this->Interactor->Render();
+ myGUIWindow->update();
}
//----------------------------------------------------------------------------
void VTKViewer_InteractorStyleSALOME::PanXY(int x, int y, int oldX, int oldY)
{
TranslateView(x, y, oldX, oldY);
- //vtkRenderWindowInteractor *rwi = this->Interactor;
- /* VSV Light follows camera: if (this->CurrentLight)
- {
- vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
- this->CurrentLight->SetPosition(cam->GetPosition());
- this->CurrentLight->SetFocalPoint(cam->GetFocalPoint());
- }*/
-
- this->Interactor->Render();
+ //this->Interactor->Render();
+ myGUIWindow->update();
}
-//----------------------------------------------------------------------------
-void VTKViewer_InteractorStyleSALOME::ControlLblSize(double aOldScale, double aNewScale) {
- return;
-}
//----------------------------------------------------------------------------
void VTKViewer_InteractorStyleSALOME::DollyXY(int dx, int dy)
aCam->Dolly(zoomFactor);
::ResetCameraClippingRange(this->CurrentRenderer);
}
-
- /* VSV Light follows camera: if (this->CurrentLight)
- {
- this->CurrentLight->SetPosition(cam->GetPosition());
- this->CurrentLight->SetFocalPoint(cam->GetFocalPoint());
- }*/
-
- this->Interactor->Render();
+
+ //this->Interactor->Render();
+ myGUIWindow->update();
}
//----------------------------------------------------------------------------
void VTKViewer_InteractorStyleSALOME::SpinXY(int x, int y, int oldX, int oldY)
{
- vtkRenderWindowInteractor *rwi = this->Interactor;
vtkCamera *cam;
if (this->CurrentRenderer == NULL)
cam->Roll(newAngle - oldAngle);
cam->OrthogonalizeViewUp();
- rwi->Render();
+ //this->Interactor->Render();
+ myGUIWindow->update();
}
}
return;
}
+
+
//----------------------------------------------------------------------------
void VTKViewer_InteractorStyleSALOME::OnLeftButtonUp(int vtkNotUsed(ctrl),
int shift,
}
}
+
//----------------------------------------------------------------------------
void VTKViewer_InteractorStyleSALOME::OnMiddleButtonDown(int ctrl,
int shift,
startOperation(VTK_INTERACTOR_STYLE_CAMERA_PAN);
}
}
+
+
//----------------------------------------------------------------------------
void VTKViewer_InteractorStyleSALOME::OnMiddleButtonUp(int vtkNotUsed(ctrl),
int shift,
}
}
+
//----------------------------------------------------------------------------
void VTKViewer_InteractorStyleSALOME::OnRightButtonDown(int ctrl,
int shift,
}
//----------------------------------------------------------------------------
-void VTKViewer_InteractorStyleSALOME::PrintSelf(ostream& os, vtkIndent indent)
-{
- vtkInteractorStyle::PrintSelf(os,indent);
-
-}
-
/* XPM */
const char* imageZoomCursor[] = {
"32 32 3 1",
"................................",
"................................"};
+
+//----------------------------------------------------------------------------
// loads cursors for viewer operations - zoom, pan, etc...
void VTKViewer_InteractorStyleSALOME::loadCursors()
{
myCursorState = false;
}
+
+//----------------------------------------------------------------------------
// event filter - controls mouse and keyboard events during viewer operations
bool VTKViewer_InteractorStyleSALOME::eventFilter(QObject* object, QEvent* event)
{
return QObject::eventFilter(object, event);
}
+
+//----------------------------------------------------------------------------
// starts Zoom operation (e.g. through menu command)
void VTKViewer_InteractorStyleSALOME::startZoom()
{
qApp->installEventFilter(this);
}
+
+//----------------------------------------------------------------------------
// starts Pan operation (e.g. through menu command)
void VTKViewer_InteractorStyleSALOME::startPan()
{
qApp->installEventFilter(this);
}
+//----------------------------------------------------------------------------
// starts Rotate operation (e.g. through menu command)
void VTKViewer_InteractorStyleSALOME::startRotate()
{
qApp->installEventFilter(this);
}
+
+//----------------------------------------------------------------------------
// starts Spin operation (e.g. through menu command)
void VTKViewer_InteractorStyleSALOME::startSpin()
{
}
+
+//----------------------------------------------------------------------------
// starts Fit Area operation (e.g. through menu command)
void VTKViewer_InteractorStyleSALOME::startFitArea()
{
}
+//----------------------------------------------------------------------------
void VTKViewer_InteractorStyleSALOME::ViewFitAll() {
int aTriedronWasVisible = false;
if(m_Trihedron){
}
+//----------------------------------------------------------------------------
// starts Global Panning operation (e.g. through menu command)
void VTKViewer_InteractorStyleSALOME::startGlobalPan()
{
myScale = cam->GetParallelScale();
ViewFitAll();
- // make fit all
-// int TriedronWasVisible = false;
-// if(m_Trihedron){
-// TriedronWasVisible =
-// m_Trihedron->GetVisibility() == VTKViewer_Trihedron::eOn;
-// if(TriedronWasVisible) m_Trihedron->VisibilityOff();
-// }
-
-// ::ResetCamera(this->CurrentRenderer);
-
-// if(m_Trihedron)
-// if(TriedronWasVisible)
-// m_Trihedron->VisibilityOn();
- //VTKViewer_RenderWindow* aRW = dynamic_cast<VTKViewer_RenderWindow*>(this->Interactor->GetRenderWindow());
if (myGUIWindow) myGUIWindow->update();
qApp->installEventFilter(this);
}
+
+//----------------------------------------------------------------------------
// returns TRUE if needs redrawing
bool VTKViewer_InteractorStyleSALOME::needsRedrawing()
{
State == VTK_INTERACTOR_STYLE_CAMERA_NONE;
}
+
+//----------------------------------------------------------------------------
// fits viewer contents to rect
void VTKViewer_InteractorStyleSALOME::fitRect(const int left,
const int top,
::ResetCameraClippingRange(this->CurrentRenderer);
}
- //vtkRenderWindowInteractor *rwi = this->Interactor;
- /* VSV Light follows camera: if (this->CurrentLight) {
- this->CurrentLight->SetPosition(cam->GetPosition());
- this->CurrentLight->SetFocalPoint(cam->GetFocalPoint());
- }*/
- // rwi->Render();
- //VTKViewer_RenderWindow* aRW = dynamic_cast<VTKViewer_RenderWindow*>(rwi->GetRenderWindow());
myGUIWindow->update();
}
-
+//----------------------------------------------------------------------------
// starts viewer operation (!internal usage!)
void VTKViewer_InteractorStyleSALOME::startOperation(int operation)
{
}
}
+
+//----------------------------------------------------------------------------
// sets proper cursor for window when viewer operation is activated
void VTKViewer_InteractorStyleSALOME::setCursor(const int operation)
{
}
}
+
+//----------------------------------------------------------------------------
// called when viewer operation started (!put necessary initialization here!)
void VTKViewer_InteractorStyleSALOME::onStartOperation()
{
}
}
+
+//----------------------------------------------------------------------------
// called when viewer operation finished (!put necessary post-processing here!)
void VTKViewer_InteractorStyleSALOME::onFinishOperation()
{
QAD_Study* aActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
SALOME_Selection* aSel = SALOME_Selection::Selection( aActiveStudy->getSelection() );
- vtkRenderWindowInteractor *rwi = this->Interactor;
// VSV: LOD actor activisation
// rwi->GetRenderWindow()->SetDesiredUpdateRate(rwi->GetStillUpdateRate());
if (State == VTK_INTERACTOR_STYLE_CAMERA_FIT) {
// making fit rect opeation
int w, h, x, y;
- rwi->GetSize(w, h);
+ m_Interactor->GetSize(w, h);
int x1, y1, x2, y2;
x1 = rect.left();
y1 = h - rect.top() - 1;
}
else {
if (myPoint == myOtherPoint) {
- // process point selection
+ // process point selection
int w, h, x, y;
- rwi->GetSize(w, h);
+ m_Interactor->GetSize(w, h);
x = myPoint.x();
y = h - myPoint.y() - 1;
- vtkActorCollection* listactors = NULL;
+
this->FindPokedRenderer(x, y);
- rwi->StartPickCallback();
+ m_Interactor->StartPickCallback();
-// vtkPicker* aPicker = vtkPicker::SafeDownCast(rwi->GetPicker());
-// if (aPicker)
-// aPicker->SetTolerance(0.01);
-
- rwi->GetPicker()->Pick(x, y, 0.0, this->CurrentRenderer);
+ vtkPicker* aPicker = vtkPicker::SafeDownCast(m_Interactor->GetPicker());
+ aPicker->Pick(x, y, 0.0, this->CurrentRenderer);
- if ( rwi->GetPicker()->IsA("vtkCellPicker") ) {
- vtkCellPicker* picker;
- if ( (picker = vtkCellPicker::SafeDownCast(rwi->GetPicker())) ) {
- 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 );
- INFOS ( " NAME Actor : " << SActor->getName() << ", CellId : " << aVtkId );
-
- //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());
- Standard_Boolean IsSelected = false;
- for(;It.More();It.Next()) {
- Handle(SALOME_InteractiveObject) IOS = It.Value();
- if(IO->isSame(IOS)) {
- IsSelected = true;
- IO = IOS; //Added by SRN, fix SAL1307
- break;
- }
- }
-
- 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();
- }
- 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, 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);
- }
- 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 );
- }
- }
+ SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
+
+ if (vtkCellPicker* picker = vtkCellPicker::SafeDownCast(aPicker)) {
+ int aVtkId = picker->GetCellId();
+ if ( aVtkId >= 0 && SActor && SActor->hasIO() && IsValid( SActor, aVtkId ) ) {
+ int anObjId = SActor->GetElemObjId(aVtkId);
+ if(anObjId >= 0){
+ Handle(SALOME_InteractiveObject) IO = SActor->getIO();
+ if(aSelectionMode != EdgeOfCellSelection) {
+ if(CheckDimensionId(aSelectionMode,SActor,anObjId)){
+ if(MYDEBUG) INFOS(" CellId : "<<anObjId);
+ if (IsSelected(IO,aSel)) {
+ // This IO is already in the selection
+ aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
+ } else {
+ if (!myShiftState) {
+ this->HighlightProp( NULL );
+ aSel->ClearIObjects();
}
+ aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
+ aSel->AddIObject( IO, false );
}
}
- }
- } else {
- this->HighlightProp( NULL );
- aSel->ClearIObjects();
- }
- }
- } else if ( rwi->GetPicker()->IsA("vtkPointPicker") ) {
- vtkPointPicker* picker;
- if ( (picker = vtkPointPicker::SafeDownCast(rwi->GetPicker())) ) {
- INFOS ( " 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 ( SActor->hasIO() ) {
- Handle(SALOME_InteractiveObject) IO = SActor->getIO();
- /*
- if (IO.IsNull())
- break;
- if (aSelActiveCompOnly &&
- strcmp(aActiveComponent->ComponentDataType(),
- IO->getComponentDataType()) != 0) {
- break;
+ }else{
+ if (!myShiftState) {
+ this->HighlightProp( NULL );
+ aSel->ClearIObjects();
+ }
+ int anEdgeId = GetEdgeId(picker,SActor,anObjId);
+ if (anEdgeId >= 0) {
+ if(MYDEBUG) INFOS(" CellId : "<<anObjId<<"; EdgeId : "<<anEdgeId);
+ aSel->AddOrRemoveIndex( IO, anObjId, true, false);
+ aSel->AddOrRemoveIndex( IO, -anEdgeId-1, true, true );
+ aSel->AddIObject( IO, false );
+ }
+ }
+ }
+ } else {
+ this->HighlightProp( NULL );
+ aSel->ClearIObjects();
+ }
+ } else if ( vtkPointPicker* picker = vtkPointPicker::SafeDownCast(aPicker) ) {
+ int aVtkId = picker->GetPointId();
+ if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ) {
+ if ( SActor && SActor->hasIO() ) {
+ int anObjId = SActor->GetNodeObjId(aVtkId);
+ if(anObjId >= 0){
+ Handle(SALOME_InteractiveObject) IO = SActor->getIO();
+ if(IsSelected(IO,aSel)) {
+ // This IO is already in the selection
+ aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
+ } else {
+ if(!myShiftState) {
+ this->HighlightProp( NULL );
+ aSel->ClearIObjects();
}
- */
- // 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(IsSelected) {
- // This IO is already in the selection
- bool add = aSel->AddOrRemoveIndex( IO, picker->GetPointId(), myShiftState, false );
- } else {
- if(!myShiftState) {
- this->HighlightProp( NULL );
- aSel->ClearIObjects();
- }
- bool add = aSel->AddOrRemoveIndex( IO, picker->GetPointId(), myShiftState, false );
- aSel->AddIObject( IO, false );
- }
- }
- }
- } else {
- this->HighlightProp( NULL );
- aSel->ClearIObjects();
- }
- }
- } else {
- vtkPicker* picker;
- if ( (picker = vtkPicker::SafeDownCast(rwi->GetPicker())) ) {
- listactors = picker->GetActors();
- }
- if ( listactors->GetNumberOfItems() == 0 ) {
- // No selection clear all
- this->PropPicked = 0;
- this->HighlightProp( NULL );
- aSel->ClearIObjects();
- } else {
- vtkActor* ac;
- listactors->InitTraversal();
- ac = listactors->GetNextActor();
- if ( ac->IsA("SALOME_Actor") ) {
- SALOME_Actor* SActor = SALOME_Actor::SafeDownCast( ac );
- if ( SActor->hasIO() ) {
- this->PropPicked++;
- Handle(SALOME_InteractiveObject) IO = SActor->getIO();
- // 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(IsSelected) {
- // This IO is already in the selection
- if(myShiftState) {
- aSel->RemoveIObject(IO);
- }
- }
- else {
- if(!myShiftState) {
- this->HighlightProp( NULL );
- aSel->ClearIObjects();
- }
- aSel->AddIObject( IO, false );
- }
- }
- }
- }
- }
- rwi->EndPickCallback();
+ if(MYDEBUG) INFOS(" PointId : "<<anObjId);
+ aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
+ aSel->AddIObject( IO, false );
+ }
+ }
+ }
+ } else {
+ this->HighlightProp( NULL );
+ aSel->ClearIObjects();
+ }
+ } else {
+ if ( SActor && SActor->hasIO() ) {
+ this->PropPicked++;
+ Handle(SALOME_InteractiveObject) IO = SActor->getIO();
+ if(IsSelected(IO,aSel)) {
+ // This IO is already in the selection
+ if(myShiftState) {
+ aSel->RemoveIObject(IO);
+ }
+ }
+ else {
+ if(!myShiftState) {
+ this->HighlightProp( NULL );
+ aSel->ClearIObjects();
+ }
+ aSel->AddIObject( IO, false );
+ }
+ }else{
+ // No selection clear all
+ this->PropPicked = 0;
+ this->HighlightProp( NULL );
+ aSel->ClearIObjects();
+ }
+ }
+ m_Interactor->EndPickCallback();
} else {
//processing rectangle selection
- SALOMEDS::SComponent_var aActiveComponent =
- SALOMEDS::SComponent::_narrow(aActiveStudy->getStudyDocument()->
- FindObject(QAD_Application::getDesktop()->getActiveComponent()));
- if(aSelActiveCompOnly && aActiveComponent->_is_nil()) return;
- rwi->StartPickCallback();
+ QString aComponentDataType = QAD_Application::getDesktop()->getComponentDataType();
+ if(aSelActiveCompOnly && aComponentDataType.isEmpty()) return;
+ m_Interactor->StartPickCallback();
if (!myShiftState) {
this->PropPicked = 0;
QRect rect(myPoint, myOtherPoint);
rect = rect.normalize();
int w, h, x, y;
- rwi->GetSize(w, h);
+ m_Interactor->GetSize(w, h);
int x1, y1, x2, y2;
x1 = rect.left();
y1 = h - rect.top() - 1;
y2 = h - rect.bottom() - 1;
switch (aSelectionMode) {
- case NodeSelection: // Nodes selection
- {
- if (! rwi->GetPicker()->IsA("vtkPointPicker") ) break;
- vtkPointPicker* aPointPicker = vtkPointPicker::SafeDownCast(rwi->GetPicker());
+ case NodeSelection: {
+ if ( vtkPointPicker* aPointPicker = vtkPointPicker::SafeDownCast(m_Interactor->GetPicker()) ) {
vtkActorCollection* aListActors = this->CurrentRenderer->GetActors();
aListActors->InitTraversal();
- vtkActor* aActor;
- for (int k = 0; k < aListActors->GetNumberOfItems(); k++) {
- aActor = aListActors->GetNextActor();
- if (aActor != NULL) {
- if (aActor->GetVisibility() == 0)
- continue;
- vtkAbstractMapper3D* aMapper3D = aActor->GetMapper();
- if ((aMapper3D != NULL) && (aActor->IsA("SALOME_Actor"))) {
- SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aActor);
-
- if ((SActor != NULL) && (SActor->hasIO())) {
- Handle(SALOME_InteractiveObject) IO = SActor->getIO();
- if (IO.IsNull())
- continue;
- if (aSelActiveCompOnly &&
- strcmp(aActiveComponent->ComponentDataType(),
- IO->getComponentDataType()) != 0) {
- continue;
- }
-
- vtkMapper* aMapper;
- vtkVolumeMapper* aVolumeMapper;
- vtkDataSet* aDataSet;
-
- if ( (aMapper = vtkMapper::SafeDownCast(aMapper3D)) != NULL ) {
- aDataSet = aMapper->GetInput();
- } else if ((aVolumeMapper = vtkVolumeMapper::SafeDownCast(aMapper3D)) != NULL ){
- aDataSet = aVolumeMapper->GetInput();
- } else {
- continue;
- }
- if (aDataSet) {
-
- std::vector<int> anIndices;
- for (int i=0; i < aDataSet->GetNumberOfPoints(); i++) {
- float* aPoint;
- aPoint = aDataSet->GetPoint(i);
- if (IsInRect(aPoint, x1, y1, x2, y2)) {
- float aDisp[3];
- ComputeWorldToDisplay(aPoint[0],
- aPoint[1],
- aPoint[2], aDisp);
- aPointPicker->Pick(aDisp[0], aDisp[1], 0.0, CurrentRenderer);
-
- 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);
- }
+ while (vtkActor* aActor = aListActors->GetNextActor()) {
+ if (!aActor->GetVisibility())
+ continue;
+ if(SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aActor)) {
+ if (SActor->hasIO()) {
+ Handle(SALOME_InteractiveObject) IO = SActor->getIO();
+ if (IO.IsNull())
+ continue;
+ if (aSelActiveCompOnly && aComponentDataType != IO->getComponentDataType())
+ continue;
+ if (vtkDataSet* aDataSet = SActor->GetInput()) {
+ SALOME_Selection::TContainerOfId anIndices;
+ for(int i = 0; i < aDataSet->GetNumberOfPoints(); i++) {
+ float aPoint[3];
+ aDataSet->GetPoint(i,aPoint);
+ if (IsInRect(aPoint,x1,y1,x2,y2)){
+ float aDisp[3];
+ ComputeWorldToDisplay(aPoint[0],aPoint[1],aPoint[2],aDisp);
+ if(aPointPicker->Pick(aDisp[0],aDisp[1],0.0,CurrentRenderer)){
+ if(vtkActorCollection *anActorCollection = aPointPicker->GetActors()){
+ if(anActorCollection->IsItemPresent(SActor)){
+ float aPickedPoint[3];
+ aPointPicker->GetMapperPosition(aPickedPoint);
+ vtkIdType aVtkId = aDataSet->FindPoint(aPickedPoint);
+ if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ){
+ int anObjId = SActor->GetNodeObjId(aVtkId);
+ anIndices.insert(anObjId);
+ }
+ }
+ }
}
}
- if (!anIndices.empty()) {
- aSel->AddOrRemoveIndex(IO, anIndices, true, false);
- aSel->AddIObject(IO, false);
- anIndices.clear();
- }
+ }
+ if (!anIndices.empty()) {
+ aSel->AddOrRemoveIndex(IO, anIndices, true, false);
+ aSel->AddIObject(IO, false);
+ anIndices.clear();
+ }else{
+ aSel->RemoveIObject(IO, false);
}
}
}
}
}
break;
+ }
case CellSelection:
case EdgeOfCellSelection:
case EdgeSelection:
case FaceSelection:
case VolumeSelection:
{
- VTKViewer_CellRectPicker* picker = VTKViewer_CellRectPicker::New();
+ vtkSmartPointer<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;
aListActors->InitTraversal();
- while(aActor = aListActors->GetNextActor()) {
- if (aActor->IsA("SALOME_Actor")) {
- SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor);
+ while(vtkActor* aActor = aListActors->GetNextActor()) {
+ if (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) {
+ if (aSelActiveCompOnly && aComponentDataType != aIO->getComponentDataType())
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);
- }
- }
- 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);
- }
+ if(MYDEBUG) INFOS ( " NAME Actor : " << aSActor->getName() );
+ SALOME_Selection::TContainerOfId anIndexes;
+ VTKViewer_CellDataSet::iterator it;
+ for ( it = cellList.begin(); it != cellList.end(); ++it ) {
+ int aCellId = (*it).cellId;
+
+ if ( !IsValid( aSActor, aCellId ) )
+ continue;
+
+ int anObjId = aSActor->GetElemObjId(aCellId);
+ if (anObjId != -1){
+ if ( CheckDimensionId(aSelectionMode,aSActor,anObjId) ) {
+ anIndexes.insert(anObjId);
}
}
}
break;
case ActorSelection: // objects selection
{
- VTKViewer_RectPicker* picker = VTKViewer_RectPicker::New();
+ vtkSmartPointer<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;
aListActors->InitTraversal();
- while(aActor = aListActors->GetNextActor()) {
- if (aActor->IsA("SALOME_Actor")) {
- SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor);
+ while(vtkActor* aActor = aListActors->GetNextActor()) {
+ if (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)
+ if (!IsStored(aIO,aListIO))
aListIO.Append(aIO);
}
}
}
} // end case 4
} //end switch
- rwi->EndPickCallback();
+ m_Interactor->EndPickCallback();
}
aActiveStudy->update3dViewers();
}
case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
{
int w, h, x, y;
- rwi->GetSize(w, h);
+ m_Interactor->GetSize(w, h);
x = myPoint.x();
y = h - myPoint.y() - 1;
Place(x, y);
// called when selection mode changed (!put necessary initialization here!)
void VTKViewer_InteractorStyleSALOME::OnSelectionModeChanged()
{
- myPActor->VisibilityOff();
+
+ myPreSelectionActor->SetVisibility(false);
+ myElemId = myEdgeId = myNodeId = -1;
+ mySelectedActor = NULL;
}
// called when user moves mouse inside viewer window and there is no active viewer operation
// processing highlighting
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;
- rwi->GetSize(w, h);
+ m_Interactor->GetSize(w, h);
x = mousePos.x(); y = h - mousePos.y() - 1;
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() );
+ m_Interactor->StartPickCallback();
+ myPreSelectionActor->SetVisibility(false);
- if (rwi->IsA("VTKViewer_RenderWindowInteractor")) {
- VTKViewer_RenderWindowInteractor* aRWI =
- VTKViewer_RenderWindowInteractor::SafeDownCast(rwi);
+ vtkPicker* aPicker = vtkPicker::SafeDownCast(m_Interactor->GetPicker());
+ aPicker->Pick(x, y, 0.0, this->CurrentRenderer);
- //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();
+ SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
+
+ if (vtkCellPicker* picker = vtkCellPicker::SafeDownCast(aPicker)) {
+ int aVtkId = picker->GetCellId();
+ if ( aVtkId >= 0 ) {
+ int anObjId = SActor->GetElemObjId(aVtkId);
+ if ( SActor && SActor->hasIO() && IsValid( SActor, aVtkId ) ) {
+ bool anIsSameObjId = (mySelectedActor == SActor && myElemId == anObjId);
+ bool aResult = anIsSameObjId;
+ if(!anIsSameObjId) {
+ if(aSelectionMode != EdgeOfCellSelection) {
+ aResult = CheckDimensionId(aSelectionMode,SActor,anObjId);
+ if(aResult){
+ mySelectedActor = SActor;
+ myElemId = anObjId;
+ if(MYDEBUG) INFOS(" CellId : "<<anObjId);
+ m_Interactor->setCellData(anObjId,SActor,myPreSelectionActor);
}
}
-
- //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();
- }
- }
- }
- }
+ }
+ if(aSelectionMode == EdgeOfCellSelection){
+ int anEdgeId = GetEdgeId(picker,SActor,anObjId);
+ bool anIsSameEdgeId = (myEdgeId != anEdgeId) && anIsSameObjId;
+ aResult = anIsSameEdgeId;
+ if(!anIsSameEdgeId) {
+ aResult = (anEdgeId >= 0);
+ if (aResult) {
+ mySelectedActor = SActor;
+ myEdgeId = anEdgeId;
+ myElemId = anObjId;
+ if(MYDEBUG) INFOS(" CellId : "<<anObjId<<"; EdgeId : "<<anEdgeId);
+ m_Interactor->setEdgeData(anObjId,SActor,-anEdgeId-1,myPreSelectionActor);
+ }
}
}
+ if(aResult) {
+ myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
+ myPreSelectionActor->SetVisibility(true);
+ }
}
}
}
- 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->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 (vtkPointPicker* picker = vtkPointPicker::SafeDownCast(aPicker)) {
+ int aVtkId = picker->GetPointId();
+ if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ) {
+ if ( SActor && SActor->hasIO() ) {
+ int anObjId = SActor->GetNodeObjId(aVtkId);
+ bool anIsSameObjId = (mySelectedActor == SActor && myNodeId == anObjId);
+ if(!anIsSameObjId) {
+ mySelectedActor = SActor;
+ myNodeId = anObjId;
+ if(MYDEBUG) INFOS(" PointId : "<<anObjId);
+ m_Interactor->setPointData(anObjId,SActor,myPreSelectionActor);
}
+ myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
+ myPreSelectionActor->SetVisibility(true);
}
}
}
- else if ( rwi->GetPicker()->IsA("vtkPicker") ) {
- vtkPicker* picker = vtkPicker::SafeDownCast(rwi->GetPicker());
- vtkActor* ac = picker->GetActor();
-
- if ( ac != NULL ) {
- if ( ac->IsA("SALOME_Actor") ) {
- SALOME_Actor* SActor = SALOME_Actor::SafeDownCast( ac );
- if ( preview != SActor ) {
- if ( preview != NULL ) {
- preview->SetPreSelected( false );
- }
- preview = SActor;
+ else if ( vtkPicker* picker = vtkPicker::SafeDownCast(aPicker) ) {
+ if ( SActor ) {
+ if ( myPreViewActor != SActor ) {
+ if ( myPreViewActor != NULL ) {
+ myPreViewActor->SetPreSelected( false );
+ }
+ myPreViewActor = SActor;
- if ( SActor->hasIO() ) {
- Handle( SALOME_InteractiveObject) IO = SActor->getIO();
-
- SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
- Standard_Boolean IsSelected = false;
- for(;It.More();It.Next()) {
- Handle(SALOME_InteractiveObject) IOS = It.Value();
- if(IO->isSame(IOS)) {
- IsSelected = true;
- break;
- }
- }
-
- if ( !IsSelected ) {
+ if ( SActor->hasIO() ) {
+ Handle( SALOME_InteractiveObject) IO = SActor->getIO();
+ if ( !IsSelected(IO,Sel) ) {
// Find All actors with same IO
- vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
- theActors->InitTraversal();
- vtkActor *ac = theActors->GetNextActor();
- while( ac ) {
- if ( ac->IsA("SALOME_Actor") ) {
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
- if ( anActor->hasIO() ) {
- Handle(SALOME_InteractiveObject) IOS = anActor->getIO();
- if(IO->isSame(IOS)) {
- anActor->SetPreSelected( true );
- }
- }
- }
- ac = theActors->GetNextActor();
- }
- // INFOS ( " NAME PREVIEW " << SActor->getName() );
- }
- }
- }
+ vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
+ theActors->InitTraversal();
+ while( vtkActor *ac = theActors->GetNextActor() ) {
+ if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) {
+ if ( anActor->hasIO() ) {
+ Handle(SALOME_InteractiveObject) IOS = anActor->getIO();
+ if(IO->isSame(IOS)) {
+ anActor->SetPreSelected( true );
+ }
+ }
+ }
+ }
+ //if(MYDEBUG) INFOS ( " NAME PREVIEW " << SActor->getName() );
+ }
+ }
}
} else {
- preview = NULL;
+ myPreViewActor = NULL;
vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
theActors->InitTraversal();
- vtkActor *ac = theActors->GetNextActor();
- while( ac ) {
- if ( ac->IsA("SALOME_Actor") ) {
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
+ while( vtkActor *ac = theActors->GetNextActor() ) {
+ if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) {
anActor->SetPreSelected( false );
}
- ac = theActors->GetNextActor();
}
}
}
- rwi->EndPickCallback();
- rwi->Render();
-
+ m_Interactor->EndPickCallback();
+ //m_Interactor->Render();
+ myGUIWindow->update();
+
this->LastPos[0] = x;
this->LastPos[1] = y;
}
cam->SetParallelScale(myScale);
::ResetCameraClippingRange(this->CurrentRenderer);
- /* VSV Light follows camera: if (this->CurrentLight) {
- this->CurrentLight->SetPosition(cam->GetPosition());
- this->CurrentLight->SetFocalPoint(cam->GetFocalPoint());
- }*/
- //VTKViewer_RenderWindow* aRW = dynamic_cast<VTKViewer_RenderWindow*>(this->Interactor->GetRenderWindow());
if (myGUIWindow) myGUIWindow->update();
}
return ((aPnt[0]>left) && (aPnt[0]<right) && (aPnt[1]>bottom) && (aPnt[1]<top));
}
-void VTKViewer_InteractorStyleSALOME::SetFaceFilter( const Handle(VTKViewer_Filter)& f )
+void VTKViewer_InteractorStyleSALOME::SetFilter( const Handle(VTKViewer_Filter)& theFilter )
{
- myFaceFilter = f;
+ myFilters[ theFilter->GetId() ] = theFilter;
}
-void VTKViewer_InteractorStyleSALOME::RemoveFaceFilter()
+bool VTKViewer_InteractorStyleSALOME::IsFilterPresent( const int theId )
{
- myFaceFilter.Nullify();
+ return myFilters.find( theId ) != myFilters.end();
}
-void VTKViewer_InteractorStyleSALOME::SetEdgeFilter( const Handle(VTKViewer_Filter)& f )
+void VTKViewer_InteractorStyleSALOME::RemoveFilter( const int theId )
{
- myEdgeFilter = f;
+ if ( IsFilterPresent( theId ) )
+ myFilters.erase( theId );
}
-void VTKViewer_InteractorStyleSALOME::RemoveEdgeFilter()
-{
- myEdgeFilter.Nullify();
-}
-bool VTKViewer_InteractorStyleSALOME::isValid( SALOME_Actor* theActor,
- const int theId,
- const Selection_Mode theSelMode )
+bool VTKViewer_InteractorStyleSALOME::IsValid( SALOME_Actor* theActor,
+ const int theId,
+ const bool theIsNode )
{
- if ( theSelMode != CellSelection &&
- theSelMode != FaceSelection &&
- theSelMode != EdgeSelection )
- return true;
-
- if ( theSelMode == CellSelection )
+ std::map<int, Handle(VTKViewer_Filter)>::const_iterator anIter;
+ for ( anIter = myFilters.begin(); anIter != myFilters.end(); ++anIter )
{
- 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;
+ const Handle(VTKViewer_Filter)& aFilter = anIter->second;
+ if ( theIsNode == aFilter->IsNodeFilter() &&
+ !aFilter->IsValid( theActor, theId ) )
+ 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;
}
+
+Handle(VTKViewer_Filter) VTKViewer_InteractorStyleSALOME::GetFilter( const int theId )
+{
+ return IsFilterPresent( theId ) ? myFilters[ theId ] : Handle(VTKViewer_Filter)();
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#define __VTKViewer_InteractorStyleSALOME_h
#include <vtkInteractorStyle.h>
+
+class vtkCell;
+class vtkRenderWindowInteractor;
+
#include <qobject.h>
#include <qcursor.h>
-#include "SALOME_Actor.h"
+
#include "VTKViewer_Filter.h"
-#include "SALOME_Selection.h"
+class SALOME_Actor;
+class VTKViewer_Actor;
class VTKViewer_Trihedron;
+class VTKViewer_ViewFrame;
+class VTKViewer_RenderWindowInteractor;
#define VTK_INTERACTOR_STYLE_CAMERA_NONE 0
#define VTK_INTERACTOR_STYLE_CAMERA_ROTATE 1
// parent. This class should not normally be instantiated by application
// programmers.
static VTKViewer_InteractorStyleSALOME *New();
+ vtkTypeMacro(VTKViewer_InteractorStyleSALOME, vtkInteractorStyle);
+
+ virtual void SetInteractor(vtkRenderWindowInteractor *theInteractor);
+ void setViewFrame(VTKViewer_ViewFrame* theViewFrame);
+ void setGUIWindow(QWidget* theWindow);
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);
-
// Generic event bindings must be overridden in subclasses
void OnMouseMove (int ctrl, int shift, int x, int y);
void OnLeftButtonDown(int ctrl, int shift, int x, int y);
void ViewFitAll();
- void SetEdgeFilter( const Handle(VTKViewer_Filter)& );
- void SetFaceFilter( const Handle(VTKViewer_Filter)& );
- void RemoveFaceFilter();
- void RemoveEdgeFilter();
+ void SetFilter( const Handle(VTKViewer_Filter)& );
+ Handle(VTKViewer_Filter) GetFilter( const int );
+ bool IsFilterPresent( const int );
+ void RemoveFilter( const int );
+ bool IsValid( SALOME_Actor* theActor,
+ const int theId,
+ const bool theIsNode = false );
+
protected:
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;
+ SALOME_Actor* myPreViewActor;
-public:
+ VTKViewer_Actor* myPreSelectionActor;
+ SALOME_Actor* mySelectedActor;
+ int myElemId;
+ int myEdgeId;
+ int myNodeId;
+
+ public:
bool eventFilter(QObject* object, QEvent* event);
- void ControlLblSize(double aOldScale, double aNewScale);
void startZoom();
void startPan();
void startGlobalPan();
void startFitArea();
void startSpin();
bool needsRedrawing();
- QWidget* getGUIWindow() {return myGUIWindow;}
- void setGUIWindow(QWidget* theWin) { myGUIWindow = theWin;}
-protected:
+ protected:
void loadCursors();
void startOperation(int operation);
void onStartOperation();
void onCursorMove(QPoint mousePos);
void setCursor(const int operation);
-protected:
+
+ protected:
QCursor myDefCursor;
QCursor myPanCursor;
QCursor myZoomCursor;
bool myShiftState;
int ForcedState;
+ VTKViewer_RenderWindowInteractor* m_Interactor;
+ VTKViewer_ViewFrame* m_ViewFrame;
VTKViewer_Trihedron* m_Trihedron;
-
QWidget* myGUIWindow;
- Handle(VTKViewer_Filter) myEdgeFilter;
- Handle(VTKViewer_Filter) myFaceFilter;
+ std::map<int, Handle(VTKViewer_Filter)> myFilters;
// members from old version
double DeltaElevation;
// $Header$
#include "VTKViewer_RenderWindowInteractor.h"
-#include "VTKViewer_RenderWindow.h"
+
#include "VTKViewer_InteractorStyleSALOME.h"
+#include "VTKViewer_RenderWindow.h"
+#include "VTKViewer_ViewFrame.h"
+
+#include "VTKViewer_Algorithm.h"
+#include "VTKViewer_Functor.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
-//#include "SALOME_Selection.h"
-#include "SALOME_Actor.h"
+#include "VTKViewer_Actor.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
// VTK Includes
-#include <vtkAssemblyNode.h>
-#include <vtkActor.h>
-#include <vtkInteractorStyle.h>
#include <vtkObjectFactory.h>
#include <vtkPicker.h>
#include <vtkCellPicker.h>
#include <vtkPointPicker.h>
-#include <vtkUnstructuredGrid.h>
-#include <vtkPolyDataMapper.h>
-#include <vtkSphereSource.h>
-#include <vtkDataSet.h>
-#include <vtkMaskPoints.h>
-#include <vtkVertex.h>
#include <vtkRendererCollection.h>
-#include <vtkPolyDataWriter.h>
// QT Includes
#include <qkeycode.h>
+#include <TColStd_IndexedMapOfInteger.hxx>
+
+#include "utilities.h"
+
using namespace std;
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+
VTKViewer_RenderWindowInteractor* VTKViewer_RenderWindowInteractor::New() {
vtkObject *ret = vtkObjectFactory::CreateInstance("VTKViewer_RenderWindowInteractor") ;
if( ret ) {
VTKViewer_RenderWindowInteractor::VTKViewer_RenderWindowInteractor() {
this->Enabled = 0 ;
this->mTimer = new QTimer( this ) ;
- this->displaymode = 0;
+ myDisplayMode = 0;
myGUIWindow = 0;
- vtkPicker* thepicker = vtkPicker::New();
- thepicker->SetTolerance(0);
- this->SetPicker(thepicker);
+
+ myBasicPicker = vtkPicker::New();
+ myCellPicker = vtkCellPicker::New();
+ myPointPicker = vtkPointPicker::New();
+
+ myCellActor = VTKViewer_Actor::New();
+ myCellActor->PickableOff();
+ myCellActor->GetProperty()->SetColor(1,1,0);
+ myCellActor->GetProperty()->SetLineWidth(5);
+ myCellActor->GetProperty()->SetRepresentationToSurface();
+
+ myEdgeActor = VTKViewer_Actor::New();
+ myEdgeActor->PickableOff();
+ myEdgeActor->GetProperty()->SetColor(1,0,0);
+ myEdgeActor->GetProperty()->SetLineWidth(5);
+ myEdgeActor->GetProperty()->SetRepresentationToWireframe();
+
+ myPointActor = VTKViewer_Actor::New();
+ myPointActor->PickableOff();
+ myPointActor->GetProperty()->SetColor(1,1,0);
+ myPointActor->GetProperty()->SetPointSize(5);
+ myPointActor->GetProperty()->SetRepresentationToPoints();
connect(mTimer, SIGNAL(timeout()), this, SLOT(TimerFunc())) ;
}
VTKViewer_RenderWindowInteractor::~VTKViewer_RenderWindowInteractor() {
+ if(MYDEBUG) INFOS("VTKViewer_RenderWindowInteractor::~VTKViewer_RenderWindowInteractor()");
+
delete mTimer ;
+
+ myViewFrame->RemoveActor(myCellActor);
+ myViewFrame->RemoveActor(myEdgeActor);
+ myViewFrame->RemoveActor(myPointActor);
+
+ myCellActor->Delete();
+ myEdgeActor->Delete();
+ myPointActor->Delete();
+
+ myBasicPicker->Delete();
+ myCellPicker->Delete();
+ myPointPicker->Delete();
}
void VTKViewer_RenderWindowInteractor::PrintSelf(ostream& os, vtkIndent indent) {
this->Size[0] = ((aSize[0] > 0) ? aSize[0] : 300);
this->Size[1] = ((aSize[1] > 0) ? aSize[1] : 300);
+ this->SetPicker(myBasicPicker);
+
+ SetSelectionTolerance();
+
//
// Enable the interactor.
//
//
this->Initialized = 1 ;
- myTolNodes = 0.025;
- myTolItems = 0.001;
+ return ;
+}
- Cell_Actor = vtkActor::New();
- Cell_Actor->PickableOff();
- Cell_Actor->GetProperty()->SetColor(1,1,0);
- Cell_Actor->GetProperty()->SetLineWidth(5);
- Cell_Actor->GetProperty()->SetRepresentationToSurface();
- Edge_Actor = vtkActor::New();
- Edge_Actor->PickableOff();
- Edge_Actor->GetProperty()->SetColor(1,0,0);
- Edge_Actor->GetProperty()->SetLineWidth(5);
- Edge_Actor->GetProperty()->SetRepresentationToWireframe();
+//----------------------------------------------------------------------------
+void VTKViewer_RenderWindowInteractor::setGUIWindow(QWidget* theWindow){
+ myGUIWindow = theWindow;
+}
- Point_Actor = vtkActor::New();
- Point_Actor->PickableOff();
- Point_Actor->GetProperty()->SetColor(1,1,0);
- Point_Actor->GetProperty()->SetPointSize(5);
- Point_Actor->GetProperty()->SetRepresentationToPoints();
+//----------------------------------------------------------------------------
+void VTKViewer_RenderWindowInteractor::setViewFrame(VTKViewer_ViewFrame* theViewFrame){
+ myViewFrame = theViewFrame;
- return ;
+ myViewFrame->InsertActor(myCellActor);
+ myViewFrame->InsertActor(myEdgeActor);
+ myViewFrame->InsertActor(myPointActor);
}
+//----------------------------------------------------------------------------
+void VTKViewer_RenderWindowInteractor::MoveInternalActors()
+{
+ myViewFrame->MoveActor(myCellActor);
+ myViewFrame->MoveActor(myEdgeActor);
+ myViewFrame->MoveActor(myPointActor);
+}
+//----------------------------------------------------------------------------
void VTKViewer_RenderWindowInteractor::SetInteractorStyle(vtkInteractorObserver *theInteractor){
myInteractorStyle = dynamic_cast<VTKViewer_InteractorStyleSALOME*>(theInteractor);
vtkRenderWindowInteractor::SetInteractorStyle(theInteractor);
}
-void VTKViewer_RenderWindowInteractor::SetSelectionMode(Selection_Mode mode)
+void VTKViewer_RenderWindowInteractor::SetSelectionMode(Selection_Mode theMode)
{
- Cell_Actor->VisibilityOff();
- Edge_Actor->VisibilityOff();
- Point_Actor->VisibilityOff();
-
- selectionmode = mode;
- if ( mode == NodeSelection ) {
- vtkPointPicker* thepicker = vtkPointPicker::New();
- thepicker->SetTolerance(myTolNodes);
- this->SetPicker(thepicker);
- } else if ( mode == EdgeOfCellSelection ) {
- vtkCellPicker* thepicker = vtkCellPicker::New();
- thepicker->SetTolerance(myTolItems);
- this->SetPicker(thepicker);
- } else if ( mode == CellSelection || mode == EdgeSelection ||
- mode == FaceSelection || mode == VolumeSelection ) {
- vtkCellPicker* thepicker = vtkCellPicker::New();
- thepicker->SetTolerance(myTolItems);
- this->SetPicker(thepicker);
- } else if ( mode == ActorSelection ) {
- vtkPicker* thepicker = vtkPicker::New();
- thepicker->SetTolerance(myTolItems);
- this->SetPicker(thepicker);
+ myCellActor->SetVisibility(false);
+ myEdgeActor->SetVisibility(false);
+ myPointActor->SetVisibility(false);
+
+ switch(theMode){
+ case ActorSelection:
+ this->SetPicker(myBasicPicker);
+ break;
+ case NodeSelection:
+ this->SetPicker(myPointPicker);
+ break;
+ case CellSelection:
+ case EdgeSelection:
+ case FaceSelection:
+ case VolumeSelection:
+ case EdgeOfCellSelection:
+ this->SetPicker(myCellPicker);
+ break;
}
- VTKViewer_InteractorStyleSALOME* Style = 0;
- if (this->InteractorStyle->IsA("VTKViewer_InteractorStyleSALOME"))
- Style = VTKViewer_InteractorStyleSALOME::SafeDownCast(this->InteractorStyle);
- else
- return;
- Style->OnSelectionModeChanged();
+ myInteractorStyle->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);
+ myCellActor->GetProperty()->SetColor(theRed, theGreen, theBlue);
+ myCellActor->GetProperty()->SetLineWidth(theWidth);
- Point_Actor->GetProperty()->SetColor(theRed, theGreen, theBlue);
- Point_Actor->GetProperty()->SetPointSize(theWidth);
+ myPointActor->GetProperty()->SetColor(theRed, theGreen, theBlue);
+ myPointActor->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);
- }
+
+ myBasicPicker->SetTolerance(myTolItems);
+ myCellPicker->SetTolerance(myTolItems);
+ myPointPicker->SetTolerance(myTolNodes);
+
}
void VTKViewer_RenderWindowInteractor::Enable() {
if( ! this->Enabled ) {
return ;
}
- VTKViewer_InteractorStyleSALOME* Style = 0;
- if (this->InteractorStyle->IsA("VTKViewer_InteractorStyleSALOME"))
- Style = VTKViewer_InteractorStyleSALOME::SafeDownCast(this->InteractorStyle);
- else {
- emit RenderWindowModified() ;
- return;
- }
- Style->OnMouseMove(0, 0, event->x(), event->y()/*this->Size[1] - event->y() - 1*/) ;
- if (Style->needsRedrawing() )
+ myInteractorStyle->OnMouseMove(0, 0, event->x(), event->y()/*this->Size[1] - event->y() - 1*/) ;
+ if (myInteractorStyle->needsRedrawing() )
emit RenderWindowModified() ;
}
if( ! this->Enabled ) {
return ;
}
- VTKViewer_InteractorStyleSALOME* Style = 0;
- if (this->InteractorStyle->IsA("VTKViewer_InteractorStyleSALOME"))
- Style = VTKViewer_InteractorStyleSALOME::SafeDownCast(this->InteractorStyle);
- else
- return;
- Style->OnLeftButtonDown((event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y());
+ myInteractorStyle->OnLeftButtonDown((event->state() & ControlButton),
+ (event->state() & ShiftButton),
+ event->x(), event->y());
}
void VTKViewer_RenderWindowInteractor::LeftButtonReleased(const QMouseEvent *event) {
if( ! this->Enabled ) {
return ;
}
- VTKViewer_InteractorStyleSALOME* Style = 0;
- if (this->InteractorStyle->IsA("VTKViewer_InteractorStyleSALOME"))
- Style = VTKViewer_InteractorStyleSALOME::SafeDownCast(this->InteractorStyle);
- else
- return;
- Style->OnLeftButtonUp( (event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y() ) ;
+ myInteractorStyle->OnLeftButtonUp( (event->state() & ControlButton),
+ (event->state() & ShiftButton),
+ event->x(), event->y() ) ;
}
void VTKViewer_RenderWindowInteractor::MiddleButtonPressed(const QMouseEvent *event) {
if( ! this->Enabled ) {
return ;
}
- VTKViewer_InteractorStyleSALOME* Style = 0;
- if (this->InteractorStyle->IsA("VTKViewer_InteractorStyleSALOME"))
- Style = VTKViewer_InteractorStyleSALOME::SafeDownCast(this->InteractorStyle);
- else
- return;
- Style->OnMiddleButtonDown((event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y() ) ;
+ myInteractorStyle->OnMiddleButtonDown((event->state() & ControlButton),
+ (event->state() & ShiftButton),
+ event->x(), event->y() ) ;
}
void VTKViewer_RenderWindowInteractor::MiddleButtonReleased(const QMouseEvent *event) {
if( ! this->Enabled ) {
return ;
}
- VTKViewer_InteractorStyleSALOME* Style = 0;
- if (this->InteractorStyle->IsA("VTKViewer_InteractorStyleSALOME"))
- Style = VTKViewer_InteractorStyleSALOME::SafeDownCast(this->InteractorStyle);
- else
- return;
- Style->OnMiddleButtonUp( (event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y() ) ;
+ myInteractorStyle->OnMiddleButtonUp( (event->state() & ControlButton),
+ (event->state() & ShiftButton),
+ event->x(), event->y() ) ;
}
void VTKViewer_RenderWindowInteractor::RightButtonPressed(const QMouseEvent *event) {
if( ! this->Enabled ) {
return ;
}
- VTKViewer_InteractorStyleSALOME* Style = 0;
- if (this->InteractorStyle->IsA("VTKViewer_InteractorStyleSALOME"))
- Style = VTKViewer_InteractorStyleSALOME::SafeDownCast(this->InteractorStyle);
- else
- return;
- Style->OnRightButtonDown( (event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y() ) ;
+ myInteractorStyle->OnRightButtonDown( (event->state() & ControlButton),
+ (event->state() & ShiftButton),
+ event->x(), event->y() ) ;
}
void VTKViewer_RenderWindowInteractor::RightButtonReleased(const QMouseEvent *event) {
if( ! this->Enabled ) {
return ;
}
- VTKViewer_InteractorStyleSALOME* Style = 0;
- if (this->InteractorStyle->IsA("VTKViewer_InteractorStyleSALOME"))
- Style = VTKViewer_InteractorStyleSALOME::SafeDownCast(this->InteractorStyle);
- else
- return;
- Style->OnRightButtonUp( (event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y() ) ;
+ myInteractorStyle->OnRightButtonUp( (event->state() & ControlButton),
+ (event->state() & ShiftButton),
+ event->x(), event->y() ) ;
}
void VTKViewer_RenderWindowInteractor::ButtonPressed(const QMouseEvent *event) {
return ;
}
-void VTKViewer_RenderWindowInteractor::ChangeRepresentationToWireframe(vtkActorCollection* ac)
-{
- vtkActor* anActor;
-
- for (ac->InitTraversal(); (anActor = ac->GetNextActor()); ) {
- if ( anActor->IsA("GEOM_Actor") ) {
- SALOME_Actor* SALOMEactor = SALOME_Actor::SafeDownCast(anActor);
- // Specific for GEOM actor
- if ( SALOMEactor->getDisplayMode() == 1 )
- SALOMEactor->setDisplayMode(0);
- } else {
- anActor->GetProperty()->SetRepresentationToWireframe();
- }
- }
- this->RenderWindow->Render();
- emit RenderWindowModified() ;
-}
int VTKViewer_RenderWindowInteractor::GetDisplayMode() {
- return displaymode;
-}
-
-void VTKViewer_RenderWindowInteractor::SetDisplayMode(int mode) {
- if(mode==0) ChangeRepresentationToWireframe();
- else ChangeRepresentationToSurface();
- displaymode = mode;
-}
-
-void VTKViewer_RenderWindowInteractor::SwitchRepresentation(const Handle(SALOME_InteractiveObject)& IObject,
- bool update) {
- vtkRenderer* aren;
- for (this->RenderWindow->GetRenderers()->InitTraversal();
- (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) {
- vtkActorCollection* theActors = aren->GetActors();
- theActors->InitTraversal();
- vtkActor *ac = theActors->GetNextActor();
- while(!(ac==NULL)) {
- if ( ac->IsA("SALOME_Actor") ) {
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
- if ( anActor->hasIO() ) {
- if ( IObject->isSame( anActor->getIO() ) ) {
- if ( anActor->IsA("GEOM_Actor") ) {
- // GEOM actor
- if ( anActor->getDisplayMode() == 0 ) anActor->setDisplayMode(1);
- else anActor->setDisplayMode(0);
- }
- else {
- if(anActor->GetProperty()->GetRepresentation() <= 1)
- anActor->GetProperty()->SetRepresentationToSurface();
- else
- anActor->GetProperty()->SetRepresentationToWireframe();
- }
- }
- }
- }
- ac = theActors->GetNextActor();
- }
- }
- if (update) {
- this->RenderWindow->Render();
- emit RenderWindowModified() ;
- }
+ return myDisplayMode;
+}
+
+void VTKViewer_RenderWindowInteractor::SetDisplayMode(int theMode) {
+ if(theMode == 0)
+ ChangeRepresentationToWireframe();
+ else
+ ChangeRepresentationToSurface();
+ myDisplayMode = theMode;
}
+void VTKViewer_RenderWindowInteractor::SetDisplayMode(const Handle(SALOME_InteractiveObject)& theIObject, int theMode){
+ using namespace SALOME::VTK;
+ ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject),
+ TSetFunction<SALOME_Actor,int>
+ (&SALOME_Actor::setDisplayMode,theMode));
+}
+
void VTKViewer_RenderWindowInteractor::ChangeRepresentationToWireframe()
- // change all actors to wireframe
{
- vtkActorCollection *ac;
- vtkActor *anActor, *aPart;
-
- ac = GetRenderer()->GetActors();
- ChangeRepresentationToWireframe(ac);
+ ChangeRepresentationToWireframe(GetRenderer()->GetActors());
}
+void VTKViewer_RenderWindowInteractor::ChangeRepresentationToSurface()
+{
+ ChangeRepresentationToSurface(GetRenderer()->GetActors());
+}
-void VTKViewer_RenderWindowInteractor::ChangeRepresentationToSurface(vtkActorCollection* ac)
+void VTKViewer_RenderWindowInteractor::ChangeRepresentationToWireframe(vtkActorCollection* theCollection)
{
- vtkActor *anActor, *aPart;
-
- for (ac->InitTraversal(); (anActor = ac->GetNextActor()); ) {
- if ( anActor->IsA("GEOM_Actor") ) {
- SALOME_Actor* SALOMEactor = SALOME_Actor::SafeDownCast(anActor);
- // Specific for GEOM actor
- if ( SALOMEactor->getDisplayMode() == 0 )
- SALOMEactor->setDisplayMode(1);
- } else {
- anActor->GetProperty()->SetRepresentationToSurface();
- }
- }
- this->RenderWindow->Render();
- emit RenderWindowModified() ;
+ using namespace SALOME::VTK;
+ ForEach<SALOME_Actor>(theCollection,
+ TSetFunction<SALOME_Actor,int>
+ (&SALOME_Actor::setDisplayMode,0));
+ emit RenderWindowModified();
}
-void VTKViewer_RenderWindowInteractor::ChangeRepresentationToSurface()
- // change all actors to "surface" or solid
+void VTKViewer_RenderWindowInteractor::ChangeRepresentationToSurface(vtkActorCollection* theCollection)
{
- vtkActorCollection *ac;
- vtkActor *anActor, *aPart;
-
- ac = GetRenderer()->GetActors();
- ChangeRepresentationToSurface(ac);
+ using namespace SALOME::VTK;
+ ForEach<SALOME_Actor>(theCollection,
+ TSetFunction<SALOME_Actor,int>
+ (&SALOME_Actor::setDisplayMode,1));
+ emit RenderWindowModified();
}
+
vtkRenderer* VTKViewer_RenderWindowInteractor::GetRenderer()
{
vtkRendererCollection * theRenderers = this->RenderWindow->GetRenderers();
return theRenderers->GetNextItem();
}
+
+struct TErase{
+ SALOME::VTK::TSetFunction<vtkActor,int> mySetFunction;
+ TErase():
+ mySetFunction(&vtkActor::SetVisibility,false)
+ {}
+ void operator()(SALOME_Actor* theActor){
+ theActor->SetVisibility(false);
+ // Erase dependent actors
+ vtkActorCollection* aCollection = vtkActorCollection::New();
+ theActor->GetChildActors(aCollection);
+ SALOME::VTK::ForEach<vtkActor>(aCollection,mySetFunction);
+ aCollection->Delete();
+ }
+};
+
void VTKViewer_RenderWindowInteractor::EraseAll()
{
- vtkActorCollection *ac;
- vtkActor *anActor, *aPart;
-
- ac = GetRenderer()->GetActors();
- for (ac->InitTraversal(); (anActor = ac->GetNextActor()); ) {
- if ( anActor->IsA("SALOME_Actor") ) {
- SALOME_Actor* SActor = SALOME_Actor::SafeDownCast( anActor );
- SActor->SetVisibility(false);
- }
- }
+ using namespace SALOME::VTK;
+ ForEach<SALOME_Actor>(GetRenderer()->GetActors(),
+ TErase());
+
emit RenderWindowModified() ;
}
+
void VTKViewer_RenderWindowInteractor::DisplayAll()
-{
- vtkActorCollection *ac;
- vtkActor *anActor, *aPart;
-
- ac = GetRenderer()->GetActors();
- for (ac->InitTraversal(); (anActor = ac->GetNextActor()); ) {
- if ( anActor->IsA("SALOME_Actor") ) {
- SALOME_Actor* SActor = SALOME_Actor::SafeDownCast( anActor );
- SActor->SetVisibility( true );
- }
- }
+{
+ vtkActorCollection* aCollection = GetRenderer()->GetActors();
+ using namespace SALOME::VTK;
+ ForEach<SALOME_Actor>(aCollection,TSetVisibility<SALOME_Actor>(true));
+
emit RenderWindowModified() ;
}
-void VTKViewer_RenderWindowInteractor::Erase( SALOME_Actor* SActor, bool update)
+
+void VTKViewer_RenderWindowInteractor::Erase(SALOME_Actor* theActor, bool update)
{
- SActor->SetVisibility( false );
+ TErase()(theActor);
- // Erase dependent actors
- vtkActorCollection* theChildActors = vtkActorCollection::New();
- SActor->GetChildActors(theChildActors);
+ if(update)
+ emit RenderWindowModified();
+}
- theChildActors->InitTraversal();
- vtkActor *ac = theChildActors->GetNextActor();
- while(!(ac==NULL)) {
- ac->SetVisibility( false );
- ac = theChildActors->GetNextActor();
- }
- if (update)
+void VTKViewer_RenderWindowInteractor::Erase(const Handle(SALOME_InteractiveObject)& theIObject, bool update)
+{
+ using namespace SALOME::VTK;
+ ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject),
+ TErase());
+
+ if(update)
emit RenderWindowModified();
}
-void VTKViewer_RenderWindowInteractor::Erase(const Handle(SALOME_InteractiveObject)& IObject, bool update)
+
+struct TRemoveAction{
+ vtkRenderer* myRen;
+ TRemoveAction(vtkRenderer* theRen): myRen(theRen){}
+ void operator()(SALOME_Actor* theActor){
+ myRen->RemoveActor(theActor);
+ }
+};
+
+void VTKViewer_RenderWindowInteractor::Remove(const Handle(SALOME_InteractiveObject)& theIObject, bool update)
{
- vtkRenderer* aren;
- for (this->RenderWindow->GetRenderers()->InitTraversal();
- (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) {
- vtkActorCollection* theActors = aren->GetActors();
- theActors->InitTraversal();
- vtkActor *ac = theActors->GetNextActor();
- while(!(ac==NULL)) {
- if ( ac->IsA("SALOME_Actor") ) {
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
- if ( anActor->hasIO() ) {
- if ( IObject->isSame( anActor->getIO() ) ) {
- Erase(anActor, false);
- }
- }
- }
- ac = theActors->GetNextActor();
- }
- }
- if (update)
- emit RenderWindowModified() ;
+ vtkRenderer* aRen = GetRenderer();
+
+ using namespace SALOME::VTK;
+ ForEachIf<SALOME_Actor>(aRen->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject),
+ TRemoveAction(aRen));
+
+ if(update)
+ emit RenderWindowModified();
}
-void VTKViewer_RenderWindowInteractor::Remove(const Handle(SALOME_InteractiveObject)& IObject, bool update)
+
+float VTKViewer_RenderWindowInteractor::GetTransparency(const Handle(SALOME_InteractiveObject)& theIObject)
{
- vtkRenderer* aren;
- for (this->RenderWindow->GetRenderers()->InitTraversal();
- (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) {
- vtkActorCollection* theActors = aren->GetActors();
- theActors->InitTraversal();
- vtkActor *ac = theActors->GetNextActor();
- while(!(ac==NULL)) {
- if ( ac->IsA("SALOME_Actor") ) {
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
- if ( anActor->hasIO() ) {
- if ( IObject->isSame( anActor->getIO() ) ) {
- aren->RemoveActor(anActor);
- }
- }
- }
- ac = theActors->GetNextActor();
- }
- }
- if (update)
- emit RenderWindowModified() ;
+ using namespace SALOME::VTK;
+ SALOME_Actor* anActor =
+ Find<SALOME_Actor>(GetRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject));
+ if(anActor)
+ return 1.0 - anActor->GetOpacity();
+ return -1.0;
}
-float VTKViewer_RenderWindowInteractor::GetTransparency(const Handle(SALOME_InteractiveObject)& IObject) {
- vtkRenderer* aren;
- for (this->RenderWindow->GetRenderers()->InitTraversal();
- (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) {
- vtkActorCollection* theActors = aren->GetActors();
- theActors->InitTraversal();
- vtkActor *ac = theActors->GetNextActor();
- while(!(ac==NULL)) {
- if ( ac->IsA("SALOME_Actor") ) {
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
- if ( anActor->hasIO() ) {
- if ( IObject->isSame( anActor->getIO() ) ) {
- if ( anActor->IsA("GEOM_Actor") ) {
- // GEOM actor
- return (1-(anActor->GetOpacity()));
- }
- else return (1-anActor->GetProperty()->GetOpacity());
- }
- }
- }
- ac = theActors->GetNextActor();
- }
- }
- return -1;
-}
-
-void VTKViewer_RenderWindowInteractor::SetTransparency(const Handle(SALOME_InteractiveObject)& IObject, float trans) {
- vtkRenderer* aren;
- for (this->RenderWindow->GetRenderers()->InitTraversal();
- (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) {
- vtkActorCollection* theActors = aren->GetActors();
- theActors->InitTraversal();
- vtkActor *ac = theActors->GetNextActor();
- while(!(ac==NULL)) {
- if ( ac->IsA("SALOME_Actor") ) {
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
- if ( anActor->hasIO() ) {
- if ( IObject->isSame( anActor->getIO() ) ) {
- if ( anActor->IsA("GEOM_Actor") ) {
- // GEOM actor
- anActor->SetOpacity(1-trans);
- }
- else anActor->GetProperty()->SetOpacity(1-trans);
- }
- }
- }
- ac = theActors->GetNextActor();
- }
- }
+
+void VTKViewer_RenderWindowInteractor::SetTransparency(const Handle(SALOME_InteractiveObject)& theIObject, float theTrans)
+{
+ float anOpacity = 1.0 - theTrans;
+ using namespace SALOME::VTK;
+ ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject),
+ TSetFunction<SALOME_Actor,float>
+ (&SALOME_Actor::SetOpacity,anOpacity));
}
-void VTKViewer_RenderWindowInteractor::Display( SALOME_Actor* SActor, bool update)
+
+void VTKViewer_RenderWindowInteractor::Display(SALOME_Actor* theActor, bool update)
{
- vtkRenderer* aren;
- for (this->RenderWindow->GetRenderers()->InitTraversal();
- (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) {
- aren->AddActor( SActor );
- SActor->SetVisibility( true );
- }
+ GetRenderer()->AddActor(theActor);
+ theActor->SetVisibility(true);
- if (update) {
- Render();
+ if(update)
emit RenderWindowModified();
- }
}
-void VTKViewer_RenderWindowInteractor::Display(const Handle(SALOME_InteractiveObject)& IObject, bool update)
+
+void VTKViewer_RenderWindowInteractor::Display(const Handle(SALOME_InteractiveObject)& theIObject, bool update)
{
- Standard_Boolean isalreadydisplayed = false;
-
- vtkRenderer* aren;
- for (this->RenderWindow->GetRenderers()->InitTraversal();
- (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) {
- vtkActorCollection* theActors = aren->GetActors();
- theActors->InitTraversal();
- vtkActor *ac = theActors->GetNextActor();
- while(!(ac==NULL)) {
- if ( ac->IsA("SALOME_Actor") ) {
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
- if ( anActor->hasIO() ) {
- if ( IObject->isSame( anActor->getIO() ) ) {
- anActor->SetVisibility( true );
- }
- }
- }
- ac = theActors->GetNextActor();
- }
- }
- if (update)
+ using namespace SALOME::VTK;
+ ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject),
+ TSetVisibility<SALOME_Actor>(true));
+
+ if(update)
emit RenderWindowModified() ;
}
-void VTKViewer_RenderWindowInteractor::KeyPressed(QKeyEvent *event) {
-// MESSAGE ( " vtkQGLRenderWindowInteractor::KeyPressed " )
-// if (!QAD_Application::getDesktop()->getActiveComponent().isEmpty()) {
-// QAD_Application::getDesktop()->onKeyPress( event );
-// }
-}
+void VTKViewer_RenderWindowInteractor::KeyPressed(QKeyEvent *event){}
+
+
+struct THighlightAction{
+ bool myIsHighlight;
+ VTKViewer_InteractorStyleSALOME* myInteractorStyle;
+ THighlightAction(VTKViewer_InteractorStyleSALOME* theInteractorStyle,
+ bool theIsHighlight):
+ myInteractorStyle(theInteractorStyle),
+ myIsHighlight(theIsHighlight)
+ {}
+ void operator()(SALOME_Actor* theActor){
+ if(theActor->GetMapper()){
+ if(theActor->hasHighlight())
+ theActor->highlight(myIsHighlight);
+ else{
+ if(theActor->GetVisibility() && myIsHighlight)
+ myInteractorStyle->HighlightProp(theActor);
+ else if(!myIsHighlight)
+ myInteractorStyle->HighlightProp(NULL);
+ }
+ }
+ }
+};
-bool VTKViewer_RenderWindowInteractor::highlight( const Handle(SALOME_InteractiveObject)& IObject,
+bool VTKViewer_RenderWindowInteractor::highlight( const Handle(SALOME_InteractiveObject)& theIObject,
bool hilight,
bool update)
{
- VTKViewer_InteractorStyleSALOME* aStyle =
- VTKViewer_InteractorStyleSALOME::SafeDownCast(this->InteractorStyle);
- if(!aStyle) return false;
- vtkRendererCollection* aRenColl = this->RenderWindow->GetRenderers();
- aRenColl->InitTraversal();
- while(vtkRenderer* aRen = this->RenderWindow->GetRenderers()->GetNextItem()){
- vtkActorCollection* theActors = aRen->GetActors();
- theActors->InitTraversal();
- while(vtkActor *anAct = theActors->GetNextActor()) {
- if(SALOME_Actor* anActor = SALOME_Actor::SafeDownCast(anAct)){
- if(anActor->hasIO()){
- if(IObject->isSame(anActor->getIO())){
- if(anActor->GetMapper() == NULL)
- return false;
- //highlight or unhilight actors
- if(anActor->hasHighlight())
- anActor->highlight(hilight);
- else{
- if(anActor->GetVisibility() == 1 && hilight)
- aStyle->HighlightProp(anActor);
- else if(!hilight)
- aStyle->HighlightProp(NULL);
- }
- }
- }
- }
- }
- }
- if(update){
- Render();
+ using namespace SALOME::VTK;
+ ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject),
+ THighlightAction(myInteractorStyle,hilight));
+
+ if(update)
emit RenderWindowModified();
- }
+
return false;
}
-void VTKViewer_RenderWindowInteractor::Update() {
- vtkRenderer* aren;
- for (this->RenderWindow->GetRenderers()->InitTraversal();
- (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) {
- vtkActorCollection* theActors = aren->GetActors();
- theActors->InitTraversal();
- vtkActor *ac = theActors->GetNextActor();
-
- while(!(ac==NULL)) {
- ac->ApplyProperties();
- //VSV: No in VTK: ac->Update();
- ac = theActors->GetNextActor();
- }
- aren->ResetCamera();
- emit RenderWindowModified() ;
+
+struct TUpdateAction{
+ void operator()(vtkActor* theActor){
+ theActor->ApplyProperties();
}
+};
+
+void VTKViewer_RenderWindowInteractor::Update() {
+ vtkRenderer* aRen = GetRenderer();
+
+ using namespace SALOME::VTK;
+ ForEach<vtkActor>(aRen->GetActors(),TUpdateAction());
+
+ aRen->ResetCamera();
+
+ emit RenderWindowModified();
}
-bool VTKViewer_RenderWindowInteractor::unHighlightAll(){
- VTKViewer_InteractorStyleSALOME* aStyle =
- VTKViewer_InteractorStyleSALOME::SafeDownCast(this->InteractorStyle);
- if(aStyle) aStyle->HighlightProp(NULL);
- vtkRendererCollection* aRenColl = this->RenderWindow->GetRenderers();
- aRenColl->InitTraversal();
- while(vtkRenderer* aRen = this->RenderWindow->GetRenderers()->GetNextItem()){
- vtkActorCollection* theActors = aRen->GetActors();
- 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);
-
- theActors->InitTraversal();
- while(vtkActor *anAct = theActors->GetNextActor()) {
- if(SALOME_Actor* anActor = SALOME_Actor::SafeDownCast(anAct)){
- if(anActor->hasIO()){
- //highlight or unhilight actors
- if(anActor->hasHighlight())
- anActor->highlight(false);
- }
- }
+void VTKViewer_RenderWindowInteractor::unHighlightSubSelection(){
+ myPointActor->SetVisibility(false);
+ myEdgeActor->SetVisibility(false);
+ myCellActor->SetVisibility(false);
+}
+
+
+struct TUnHighlightAllAction{
+ void operator()(SALOME_Actor* theActor){
+ if(theActor->hasIO()){
+ if(theActor->hasHighlight())
+ theActor->highlight(false);
}
}
+};
+
+bool VTKViewer_RenderWindowInteractor::unHighlightAll(){
+ unHighlightSubSelection();
+
+ using namespace SALOME::VTK;
+ ForEach<SALOME_Actor>(GetRenderer()->GetActors(),
+ TUnHighlightAllAction());
+
emit RenderWindowModified() ;
return false;
}
// Color methods
//-----------------
-void VTKViewer_RenderWindowInteractor::SetColor(const Handle(SALOME_InteractiveObject)& IObject,QColor thecolor) {
- vtkRenderer* aren;
- for (this->RenderWindow->GetRenderers()->InitTraversal();
- (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) {
- vtkActorCollection* theActors = aren->GetActors();
- theActors->InitTraversal();
- vtkActor *ac = theActors->GetNextActor();
- while(!(ac==NULL)) {
- if ( ac->IsA("SALOME_Actor") ) {
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
- if ( anActor->hasIO() ) {
- if ( IObject->isSame( anActor->getIO() ) ) {
- if ( anActor->IsA("GEOM_Actor") ) {
- // GEOM actor
- anActor->SetColor(float(thecolor.red())/255,float(thecolor.green())/255,float(thecolor.blue())/255);
- }
- else {
- anActor->GetProperty()->SetColor(float(thecolor.red())/255,float(thecolor.green())/255,float(thecolor.blue())/255);
- }
- }
- }
- }
- ac = theActors->GetNextActor();
- }
- }
-}
-
-QColor VTKViewer_RenderWindowInteractor::GetColor(const Handle(SALOME_InteractiveObject)& IObject) {
- vtkRenderer* aren;
- QColor emptycolor(0,0,0);
- for (this->RenderWindow->GetRenderers()->InitTraversal();
- (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) {
- vtkActorCollection* theActors = aren->GetActors();
- theActors->InitTraversal();
- vtkActor *ac = theActors->GetNextActor();
- while(!(ac==NULL)) {
- if ( ac->IsA("SALOME_Actor") ) {
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
- if ( anActor->hasIO() ) {
- if ( IObject->isSame( anActor->getIO() ) ) {
- if ( anActor->IsA("GEOM_Actor") ) {
- // GEOM actor
- float r,g,b;
- anActor->GetColor(r,g,b);
- return QColor(int(r*255),int(g*255),int(b*255));
- }
- else {
- float color[3];
- anActor->GetProperty()->GetColor(color);
- return QColor(int(color[0]*255),int(color[1]*255),int(color[2]*255));
- }
- }
- }
- }
- ac = theActors->GetNextActor();
- }
- }
- return emptycolor;
+void VTKViewer_RenderWindowInteractor::SetColor(const Handle(SALOME_InteractiveObject)& theIObject,QColor theColor)
+{
+ float aColor[3] = {theColor.red()/255., theColor.green()/255., theColor.blue()/255.};
+ using namespace SALOME::VTK;
+ ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject),
+ TSetFunction<SALOME_Actor,const float*>
+ (&SALOME_Actor::SetColor,aColor));
}
-
-
-bool VTKViewer_RenderWindowInteractor::isInViewer(const Handle(SALOME_InteractiveObject)& IObject)
+QColor VTKViewer_RenderWindowInteractor::GetColor(const Handle(SALOME_InteractiveObject)& theIObject)
{
- vtkRenderer* aren;
- for (this->RenderWindow->GetRenderers()->InitTraversal();
- (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) {
- vtkActorCollection* theActors = aren->GetActors();
- theActors->InitTraversal();
- vtkActor *ac = theActors->GetNextActor();
- while(!(ac==NULL)) {
- if ( ac->IsA("SALOME_Actor") ) {
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
- if ( anActor->hasIO() ) {
- if ( IObject->isSame( anActor->getIO() ) ) {
- //MESSAGE ( " VTKViewer_RenderWindowInteractor::isInViewer = TRUE" )
- return true;
- }
- }
- }
- ac = theActors->GetNextActor();
- }
+ using namespace SALOME::VTK;
+ SALOME_Actor* anActor =
+ Find<SALOME_Actor>(GetRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject));
+ if(anActor){
+ float r,g,b;
+ anActor->GetColor(r,g,b);
+ return QColor(int(r*255),int(g*255),int(b*255));
}
- //MESSAGE ( " VTKViewer_RenderWindowInteractor::isInViewer = FALSE" )
- return false;
+ return QColor(0,0,0);
}
-bool VTKViewer_RenderWindowInteractor::isVisible(const Handle(SALOME_InteractiveObject)& IObject)
+
+bool VTKViewer_RenderWindowInteractor::isInViewer(const Handle(SALOME_InteractiveObject)& theIObject)
{
- vtkRenderer* aren;
- for (this->RenderWindow->GetRenderers()->InitTraversal();
- (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) {
- vtkActorCollection* theActors = aren->GetActors();
- theActors->InitTraversal();
- vtkActor *ac = theActors->GetNextActor();
- while(!(ac==NULL)) {
- if ( ac->IsA("SALOME_Actor") ) {
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
- if ( anActor->hasIO() ) {
- if ( IObject->isSame( anActor->getIO() ) ) {
- return anActor->GetVisibility();
- }
- }
- }
- ac = theActors->GetNextActor();
- }
- }
- return false;
+ using namespace SALOME::VTK;
+ SALOME_Actor* anActor =
+ Find<SALOME_Actor>(GetRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject));
+ return anActor != NULL;
}
-void VTKViewer_RenderWindowInteractor::rename(const Handle(SALOME_InteractiveObject)& IObject, QString newName)
+
+bool VTKViewer_RenderWindowInteractor::isVisible(const Handle(SALOME_InteractiveObject)& theIObject)
{
- vtkRenderer* aren;
- for (this->RenderWindow->GetRenderers()->InitTraversal();
- (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) {
- vtkActorCollection* theActors = aren->GetActors();
- theActors->InitTraversal();
- vtkActor *ac = theActors->GetNextActor();
- while(!(ac==NULL)) {
- if ( ac->IsA("SALOME_Actor") ) {
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
- if ( anActor->hasIO() ) {
- if ( IObject->isSame( anActor->getIO() ) ) {
- anActor->setName(strdup(newName));
- }
- }
- }
- ac = theActors->GetNextActor();
- }
- }
+ using namespace SALOME::VTK;
+ SALOME_Actor* anActor =
+ Find<SALOME_Actor>(GetRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject));
+ return anActor != NULL && anActor->GetVisibility();
+}
- emit RenderWindowModified() ;
+
+void VTKViewer_RenderWindowInteractor::rename(const Handle(SALOME_InteractiveObject)& theIObject, QString theName)
+{
+ using namespace SALOME::VTK;
+ ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject),
+ TSetFunction<SALOME_Actor,const char*,QString>
+ (&SALOME_Actor::setName,theName.latin1()));
}
-bool VTKViewer_RenderWindowInteractor::highlight(const Handle(SALOME_InteractiveObject)& IObject,
- const TColStd_MapOfInteger& MapIndex,
- VTKViewer_RenderWindowInteractor::TCreateMapperFun theFun,
- vtkActor *theActor, bool hilight, bool update )
+
+//----------------------------------------------------------------------------
+bool VTKViewer_RenderWindowInteractor::highlight(const TColStd_IndexedMapOfInteger& theMapIndex,
+ SALOME_Actor* theMapActor, VTKViewer_Actor* theActor,
+ TUpdateActor theFun, bool hilight, bool update)
{
- if(MapIndex.Extent() == 0) return false;
- vtkRenderer* aRen = GetRenderer();
- vtkActorCollection* anActorColl = aRen->GetActors();
- if ( anActorColl->IsItemPresent(theActor) != 0 )
- aRen->RemoveActor(theActor);
+ if(theMapIndex.Extent() == 0) return false;
if (hilight) {
- setActorData(IObject, MapIndex, theFun, theActor);
- aRen->AddActor(theActor);
- theActor->VisibilityOn();
+ setActorData(theMapIndex,theMapActor,theActor,theFun);
+ theActor->SetVisibility(true);
}
else {
- theActor->VisibilityOff();
+ theActor->SetVisibility(false);
}
if(update){
return false;
}
-void VTKViewer_RenderWindowInteractor::setActorData(const Handle(SALOME_InteractiveObject)& IObject,
- const TColStd_MapOfInteger& MapIndex,
- VTKViewer_RenderWindowInteractor::TCreateMapperFun theFun,
- vtkActor* theActor)
+void VTKViewer_RenderWindowInteractor::setActorData(const TColStd_IndexedMapOfInteger& theMapIndex,
+ SALOME_Actor* theMapActor,
+ VTKViewer_Actor *theActor,
+ TUpdateActor theFun)
{
- 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;
- }
- }
- }
- }
- }
+ (*theFun)(theMapIndex,theMapActor,theActor);
}
-static void CellCreateMapper(vtkPolyData *theSourcePolyData, vtkPolyDataMapper* theMapper,
- const TColStd_MapOfInteger& theMapIndex)
+//----------------------------------------------------------------------------
+static void CellsUpdateActor(const TColStd_IndexedMapOfInteger& theMapIndex,
+ SALOME_Actor* theMapActor,
+ VTKViewer_Actor* theActor)
{
- vtkPolyData* aPolyData = vtkPolyData::New();
- aPolyData->Allocate();
-
- vtkIdList *ptIds = vtkIdList::New();
- ptIds->Allocate(theSourcePolyData->GetMaxCellSize());
- // vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New();
- aPolyData->SetPoints(theSourcePolyData->GetPoints());
- TColStd_MapIteratorOfMapOfInteger ite(theMapIndex);
- int aNbOfParts = theSourcePolyData->GetNumberOfCells();
- for(; ite.More(); ite.Next()){
- int aPartId = ite.Key();
- if(0 > aPartId || aPartId >= aNbOfParts) break;
- theSourcePolyData->GetCellPoints(aPartId,ptIds);
- vtkCell* aCell = theSourcePolyData->GetCell(aPartId);
- aPolyData->InsertNextCell(aCell->GetCellType(),ptIds);
- for (int i = 0, iEnd = aCell->GetNumberOfEdges(); i < iEnd; i++){
- vtkCell* anEdgeCell = aCell->GetEdge(i);
- aPolyData->InsertNextCell(VTK_LINE,anEdgeCell->GetPointIds());
- }
- }
- ptIds->Delete();
- theMapper->SetInput(aPolyData);
- aPolyData->Delete();
+ theActor->MapCells(theMapActor,theMapIndex);
}
-bool VTKViewer_RenderWindowInteractor::highlightCell(const Handle(SALOME_InteractiveObject)& IObject,
+bool VTKViewer_RenderWindowInteractor::highlightCell(const TColStd_IndexedMapOfInteger& theMapIndex,
+ SALOME_Actor* theMapActor,
bool hilight,
- const TColStd_MapOfInteger& MapIndex,
- bool update )
-{
- return highlight(IObject,MapIndex,&CellCreateMapper,Cell_Actor,hilight,update);
-}
-
-void VTKViewer_RenderWindowInteractor::setCellData(const Handle(SALOME_InteractiveObject)& IObject,
- const int& theIndex, vtkActor* theActor )
+ bool update)
{
- TColStd_MapOfInteger MapIndex; MapIndex.Add(theIndex);
- return setActorData(IObject,MapIndex,&CellCreateMapper,theActor);
+ return highlight(theMapIndex,theMapActor,myCellActor,&CellsUpdateActor,hilight,update);
}
-void VTKViewer_RenderWindowInteractor::setCellData(const Handle(SALOME_InteractiveObject)& IObject,
- const std::vector<int>& theIndexes, vtkActor* theActor )
+void VTKViewer_RenderWindowInteractor::setCellData(const int& theIndex,
+ SALOME_Actor* theMapActor,
+ VTKViewer_Actor* 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);
+ TColStd_IndexedMapOfInteger MapIndex;
+ MapIndex.Add(theIndex);
+ theActor->MapCells(theMapActor,MapIndex);
}
-static void PointCreateMapper(vtkPolyData *theSourcePolyData, vtkPolyDataMapper* theMapper,
- const TColStd_MapOfInteger& theMapIndex)
+//----------------------------------------------------------------------------
+static void PointsUpdateActor(const TColStd_IndexedMapOfInteger& theMapIndex,
+ SALOME_Actor* theMapActor,
+ VTKViewer_Actor* theActor)
{
- vtkPolyData* aPolyData = vtkPolyData::New();
- aPolyData->Allocate();
-
- vtkPoints *aPoints = vtkPoints::New();
- vtkMaskPoints* aMaskPoints = vtkMaskPoints::New();
- TColStd_MapIteratorOfMapOfInteger ite(theMapIndex);
- aPoints->SetNumberOfPoints(theMapIndex.Extent());
- int aNbOfParts = theSourcePolyData->GetNumberOfPoints();
- for(int i = 0; ite.More(); ite.Next(),i++){
- int aPartId = ite.Key();
- if(0 > aPartId || aPartId >= aNbOfParts) break;
- aPoints->SetPoint(i,theSourcePolyData->GetPoint(aPartId));
- }
- aPolyData->SetPoints(aPoints);
- aPoints->Delete();
- aMaskPoints->SetInput(aPolyData);
- aMaskPoints->SetGenerateVertices(1);
- aMaskPoints->SetOnRatio(1);
- theMapper->SetInput(aMaskPoints->GetOutput());
- aMaskPoints->Delete();
+ theActor->MapPoints(theMapActor,theMapIndex);
}
-bool VTKViewer_RenderWindowInteractor::highlightPoint(const Handle(SALOME_InteractiveObject)& IObject,
- bool hilight, const TColStd_MapOfInteger& MapIndex,
+bool VTKViewer_RenderWindowInteractor::highlightPoint(const TColStd_IndexedMapOfInteger& theMapIndex,
+ SALOME_Actor* theMapActor,
+ bool hilight,
bool update)
{
- return highlight(IObject,MapIndex,&PointCreateMapper,Point_Actor,hilight,update);
+ return highlight(theMapIndex,theMapActor,myPointActor,&PointsUpdateActor,hilight,update);
}
-
-void VTKViewer_RenderWindowInteractor::setPointData(const Handle(SALOME_InteractiveObject)& IObject,
- const int& theIndex, vtkActor* theActor )
+void VTKViewer_RenderWindowInteractor::setPointData(const int& theIndex,
+ SALOME_Actor* theMapActor,
+ VTKViewer_Actor* theActor)
{
- TColStd_MapOfInteger MapIndex; MapIndex.Add(theIndex);
- return setActorData(IObject,MapIndex,&PointCreateMapper,theActor);
+ TColStd_IndexedMapOfInteger MapIndex;
+ MapIndex.Add(theIndex);
+ theActor->MapPoints(theMapActor,MapIndex);
}
-static void EdgeCreateMapper(vtkPolyData *theSourcePolyData, vtkPolyDataMapper* theMapper,
- const TColStd_MapOfInteger& theMapIndex)
+//----------------------------------------------------------------------------
+static void EdgesUpdateActor(const TColStd_IndexedMapOfInteger& theMapIndex,
+ SALOME_Actor* theMapActor,
+ VTKViewer_Actor* theActor)
{
- vtkPolyData* aPolyData = vtkPolyData::New();
- aPolyData->Allocate();
-
- vtkIdList *ptIds = vtkIdList::New();
- ptIds->Allocate(theSourcePolyData->GetMaxCellSize());
- vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New();
- aPolyData->SetPoints(theSourcePolyData->GetPoints());
- int aCellId = -1, aCellCounter = 0;
- for(TColStd_MapIteratorOfMapOfInteger ite(theMapIndex); ite.More(); ite.Next()){
- if(ite.Key() > 0){
- aCellId = ite.Key();
- aCellCounter++;
- }
- }
- if(aCellCounter == 1){
- vtkCell* aCell = theSourcePolyData->GetCell(aCellId);
- if(aCell->GetCellType() <= VTK_LINE){
- aPolyData->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
- }else{
- TColStd_MapIteratorOfMapOfInteger ite(theMapIndex);
- int aNbOfParts = aCell->GetNumberOfEdges();
- for(; ite.More(); ite.Next()){
- if(ite.Key() < 0){
- int aPartId = -ite.Key()-1;
- if(0 > aPartId || aPartId >= aNbOfParts) break;
- vtkCell* anEdgeCell = aCell->GetEdge(aPartId);
- aPolyData->InsertNextCell(VTK_LINE,anEdgeCell->GetPointIds());
- }
- }
- }
- }else{
- int aNbOfParts = theSourcePolyData->GetNumberOfCells();
- for(TColStd_MapIteratorOfMapOfInteger ite(theMapIndex); ite.More(); ite.Next()){
- if(ite.Key() > 0){
- int aPartId = ite.Key();
- if(0 > aPartId || aPartId >= aNbOfParts) break;
- vtkCell* aCell = theSourcePolyData->GetCell(aPartId);
- aPolyData->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
- }
- }
- }
- ptIds->Delete();
- theMapper->SetInput(aPolyData);
- aPolyData->Delete();
+ theActor->MapEdge(theMapActor,theMapIndex);
}
-
-bool VTKViewer_RenderWindowInteractor::highlightEdge( const Handle(SALOME_InteractiveObject)& IObject,
- bool hilight,
- const TColStd_MapOfInteger& MapIndex,
- bool update )
+bool VTKViewer_RenderWindowInteractor::highlightEdge(const TColStd_IndexedMapOfInteger& theMapIndex,
+ SALOME_Actor* theMapActor,
+ bool hilight,
+ bool update)
{
- return highlight(IObject,MapIndex,&EdgeCreateMapper,Edge_Actor,hilight,update);
+ return highlight(theMapIndex,theMapActor,myEdgeActor,&EdgesUpdateActor,hilight,update);
}
-void VTKViewer_RenderWindowInteractor::setEdgeData(const Handle(SALOME_InteractiveObject)& IObject,
- const int& theCellIndex, const int& theEdgeIndex,
- vtkActor* theActor )
+void VTKViewer_RenderWindowInteractor::setEdgeData(const int& theCellIndex,
+ SALOME_Actor* theMapActor,
+ const int& theEdgeIndex,
+ VTKViewer_Actor* theActor )
{
- TColStd_MapOfInteger MapIndex; MapIndex.Add(theCellIndex); MapIndex.Add(theEdgeIndex);
- return setActorData(IObject,MapIndex,&EdgeCreateMapper,theActor);
+ TColStd_IndexedMapOfInteger MapIndex;
+ MapIndex.Add(theCellIndex);
+ MapIndex.Add(theEdgeIndex);
+ theActor->MapEdge(theMapActor,MapIndex);
}
// now we define the C++ class
#include "SALOME_InteractiveObject.hxx"
-#include "SALOME_Actor.h"
#include "SALOME_Selection.h"
// QT Includes
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
-class vtkPolyData;
-class vtkPolyDataMapper;
+class vtkPicker;
+class vtkCellPicker;
+class vtkPointPicker;
+class vtkActorCollection;
+class SALOME_Actor;
+class VTKViewer_Actor;
+class VTKViewer_ViewFrame;
class VTKViewer_RenderWindow;
class VTKViewer_InteractorStyleSALOME;
class VTK_EXPORT VTKViewer_RenderWindowInteractor :
public QObject, public vtkRenderWindowInteractor
{
- Q_OBJECT
+ Q_OBJECT ;
+ friend class VTKViewer_ViewFrame;
public:
static VTKViewer_RenderWindowInteractor *New() ;
//virtual void EndPickCallback();
/* Selection Management */
- bool highlightCell(const Handle(SALOME_InteractiveObject)& IObject, bool hilight,
- const TColStd_MapOfInteger& MapIndex, bool immediatly = true );
- bool highlightEdge(const Handle(SALOME_InteractiveObject)& IObject, bool hilight,
- const TColStd_MapOfInteger& MapIndex, bool immediatly = true ); //NB
- bool highlightPoint(const Handle(SALOME_InteractiveObject)& IObject, bool hilight,
- const TColStd_MapOfInteger& MapIndex, bool immediatly = true );
+ bool highlightCell(const TColStd_IndexedMapOfInteger& MapIndex,
+ SALOME_Actor* theMapActor,
+ bool hilight,
+ bool update = true );
+ bool highlightEdge(const TColStd_IndexedMapOfInteger& MapIndex,
+ SALOME_Actor* theMapActor,
+ bool hilight,
+ bool update = true );
+ bool highlightPoint(const TColStd_IndexedMapOfInteger& MapIndex,
+ SALOME_Actor* theMapActor,
+ bool hilight,
+ bool update = true );
bool highlight(const Handle(SALOME_InteractiveObject)& IObject, bool hiligth, bool immediatly = true );
+ void unHighlightSubSelection();
bool unHighlightAll();
+
bool isInViewer( const Handle(SALOME_InteractiveObject)& IObject);
bool isVisible( const Handle(SALOME_InteractiveObject)& IObject);
void rename(const Handle(SALOME_InteractiveObject)& IObject, QString newName);
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 SetDisplayMode(int);
// Switch representation wireframe/shading
- void SwitchRepresentation(const Handle(SALOME_InteractiveObject)& IObject, bool update = true);
+ void SetDisplayMode(const Handle(SALOME_InteractiveObject)& IObject, int theMode);
// Change all actors to wireframe or surface
void ChangeRepresentationToWireframe();
vtkRenderer* GetRenderer();
- QWidget* getGUIWindow() {return myGUIWindow;}
- void setGUIWindow(QWidget* theWin) {myGUIWindow = theWin;}
+ void setGUIWindow(QWidget* theWindow);
+
+ void setViewFrame(VTKViewer_ViewFrame* ViewFrame);
- typedef void (*TCreateMapperFun)(vtkPolyData *theSourcePolyData,
- vtkPolyDataMapper* theMapper,
- const TColStd_MapOfInteger& theMapIndex);
+ void setCellData(const int& theIndex,
+ SALOME_Actor* theMapActor,
+ VTKViewer_Actor* theActor);
+ void setEdgeData(const int& theCellIndex,
+ SALOME_Actor* theMapActor,
+ const int& theEdgeIndex,
+ VTKViewer_Actor* theActor ); //NB
+ void setPointData(const int& theIndex,
+ SALOME_Actor* theMapActor,
+ VTKViewer_Actor* theActor);
+
+ typedef void (*TUpdateActor)(const TColStd_IndexedMapOfInteger& theMapIndex,
+ SALOME_Actor* theMapActor,
+ VTKViewer_Actor* theActor);
protected:
VTKViewer_RenderWindowInteractor();
VTKViewer_InteractorStyleSALOME* myInteractorStyle;
- 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 );
-
+ bool highlight(const TColStd_IndexedMapOfInteger& theMapIndex,
+ SALOME_Actor* theMapActor, VTKViewer_Actor* theActor,
+ TUpdateActor theFun, bool hilight, bool update);
+ void setActorData(const TColStd_IndexedMapOfInteger& theMapIndex,
+ SALOME_Actor* theMapActor,
+ VTKViewer_Actor *theActor,
+ TUpdateActor theFun);
+
// Timer used during various mouse events to figure
// out mouse movements.
QTimer *mTimer ;
- //CAI: Display mode
- int displaymode;
+ int myDisplayMode;
//NRI: Selection mode
- Selection_Mode selectionmode;
- vtkActor* Point_Actor;
- vtkActor* Edge_Actor; //NB
- vtkActor* Cell_Actor;
+ VTKViewer_Actor* myPointActor;
+ VTKViewer_Actor* myEdgeActor;
+ VTKViewer_Actor* myCellActor;
+ void MoveInternalActors();
+
+ vtkPicker* myBasicPicker;
+ vtkCellPicker* myCellPicker;
+ vtkPointPicker* myPointPicker;
// User for switching to stereo mode.
int PositionBeforeStereo[2];
void RenderWindowModified() ;
private:
- QWidget* myGUIWindow;
- double myTolNodes;
- double myTolItems;
+ VTKViewer_ViewFrame* myViewFrame;
+ QWidget* myGUIWindow;
+ double myTolNodes;
+ double myTolItems;
};
#endif
//==============================================================================
-class VTKViewer_UnScaledActor: public vtkFollower{
- VTKViewer_UnScaledActor(const VTKViewer_UnScaledActor&);
-
-public:
- vtkTypeMacro(VTKViewer_UnScaledActor,vtkFollower);
- static VTKViewer_UnScaledActor *New();
-
- virtual void SetSize(int theSize);
- virtual void Render(vtkRenderer *theRenderer);
-
-protected:
- VTKViewer_UnScaledActor();
- ~VTKViewer_UnScaledActor(){}
- int mySize;
-};
-
vtkStandardNewMacro(VTKViewer_UnScaledActor);
VTKViewer_UnScaledActor::VTKViewer_UnScaledActor(){}
//==============================================================================
-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);
}
//==============================================================================
-
// The base class for concreate Axis
// Its only duty is to give correct initialization and destruction
// of its pipe-lines
-class VTKViewer_Axis : public vtkObject{
-protected:
- VTKViewer_Axis();
- VTKViewer_Axis(const VTKViewer_Axis&);
- virtual ~VTKViewer_Axis();
- public:
- vtkTypeMacro(VTKViewer_Axis,vtkObject);
-
- virtual void AddToRender(vtkRenderer* theRenderer){
- //Order of the calls are important
- theRenderer->AddActor(myLineActor);
- theRenderer->AddActor(myLabelActor);
- theRenderer->AddActor(myArrowActor);
- }
-
- virtual void SetVisibility(VTKViewer_Trihedron::TVisibility theVis);
- virtual VTKViewer_Trihedron::TVisibility GetVisibility() {
- return myVisibility;
- }
-
- virtual void SetCamera(vtkCamera* theCamera){
- myLabelActor->SetCamera(theCamera);
- }
-
- virtual void SetProperty(vtkProperty* theProperty){
- myLabelActor->SetProperty(theProperty);
- myArrowActor->SetProperty(theProperty);
- myLineActor->SetProperty(theProperty);
- }
-
- virtual void SetSize(float theSize);
-
- virtual VTKViewer_UnScaledActor* GetLabel(){
- return myLabelActor;
- }
-
- virtual VTKViewer_UnScaledActor* GetArrow(){
- return myArrowActor;
- }
-
-protected:
- VTKViewer_Trihedron::TVisibility myVisibility;
- float myDir[3], myRot[3];
-
- VTKViewer_LineActor *myLineActor;
- //vtkActor *myLineActor;
- VTKViewer_UnScaledActor *myArrowActor;
- VTKViewer_UnScaledActor *myLabelActor;
-
- vtkPolyDataMapper *myMapper[3];
- vtkLineSource *myLineSource;
- vtkConeSource *myConeSource;
- VTKViewer_VectorText* myVectorText;
-};
VTKViewer_Axis::VTKViewer_Axis(){
+
// Initialize the Line pipe-line representation
myLineSource = vtkLineSource::New();
- myLineSource->SetPoint1(0.0,0.0,0.0);
+ myLineSource->SetPoint1( 0, 0, 0 );
myMapper[0] = vtkPolyDataMapper::New();
myMapper[0]->SetInput(myLineSource->GetOutput());
// Destroy of the Arrow pipe-line representation
myLineActor->Delete();
- myMapper[2]->RemoveAllInputs();
- myMapper[2]->Delete();
+ myMapper[0]->RemoveAllInputs();
+ myMapper[0]->Delete();
myLineSource->Delete();
}
myLabelActor->AddPosition(aPosition);
}
+void VTKViewer_Axis::AddToRender( vtkRenderer* theRenderer )
+{
+ //Order of the calls are important
+ theRenderer->AddActor( myLineActor );
+ theRenderer->AddActor( myLabelActor );
+ theRenderer->AddActor( myArrowActor );
+}
+
+void VTKViewer_Axis::SetCamera( vtkCamera* theCamera )
+{
+ myLabelActor->SetCamera(theCamera);
+}
+
+void VTKViewer_Axis::SetProperty( vtkProperty* theProperty )
+{
+ myLabelActor->SetProperty(theProperty);
+ myArrowActor->SetProperty(theProperty);
+ myLineActor->SetProperty(theProperty);
+ }
+
//==============================================================================
class VTKViewer_XAxis : public VTKViewer_Axis{
protected:
#define VTKViewer_Trihedron_H
#include <vtkObject.h>
+#include <vtkFollower.h>
class vtkActorCollection;
class VTKViewer_Axis;
class vtkRenderer;
+class vtkPolyDataMapper;
+class vtkLineSource;
+class vtkConeSource;
+class VTKViewer_VectorText;
+class vtkCamera;
+class vtkProperty;
+
+//==============================================================================
+
+class VTKViewer_UnScaledActor: public vtkFollower{
+ VTKViewer_UnScaledActor(const VTKViewer_UnScaledActor&);
+
+public:
+ vtkTypeMacro(VTKViewer_UnScaledActor,vtkFollower);
+ static VTKViewer_UnScaledActor *New();
+
+ virtual void SetSize(int theSize);
+ virtual void Render(vtkRenderer *theRenderer);
+
+protected:
+ VTKViewer_UnScaledActor();
+ ~VTKViewer_UnScaledActor(){}
+ int mySize;
+};
+
+//==============================================================================
+
+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;
+};
+
+//================================================
class VTKViewer_Trihedron : public vtkObject{
protected:
float mySize;
};
+//==============================================================================
+// The base class for concreate Axis
+// Its only duty is to give correct initialization and destruction
+// of its pipe-lines
+class VTKViewer_Axis : public vtkObject{
+protected:
+ VTKViewer_Axis();
+ VTKViewer_Axis(const VTKViewer_Axis&);
+ virtual ~VTKViewer_Axis();
+ public:
+ vtkTypeMacro(VTKViewer_Axis,vtkObject);
+
+ virtual void AddToRender(vtkRenderer* theRenderer);
+
+ virtual void SetVisibility(VTKViewer_Trihedron::TVisibility theVis);
+ virtual VTKViewer_Trihedron::TVisibility GetVisibility() { return myVisibility; }
+
+ virtual void SetCamera(vtkCamera* theCamera);
+ virtual void SetProperty(vtkProperty* theProperty);
+ virtual void SetSize(float theSize);
+
+ virtual VTKViewer_UnScaledActor* GetLabel(){ return myLabelActor; }
+ virtual VTKViewer_UnScaledActor* GetArrow(){ return myArrowActor; }
+
+protected:
+ VTKViewer_Trihedron::TVisibility myVisibility;
+ float myDir[3], myRot[3];
+
+ VTKViewer_LineActor *myLineActor;
+ //vtkActor *myLineActor;
+ VTKViewer_UnScaledActor *myArrowActor;
+ VTKViewer_UnScaledActor *myLabelActor;
+
+ vtkPolyDataMapper *myMapper[3];
+ vtkLineSource *myLineSource;
+ vtkConeSource *myConeSource;
+ VTKViewer_VectorText* myVectorText;
+};
+
#endif
#include "VTKViewer_Utilities.h"
#include "VTKViewer_Trihedron.h"
#include "VTKViewer_RenderWindow.h"
+#include "VTKViewer_RenderWindowInteractor.h"
#include "VTKViewer_InteractorStyleSALOME.h"
+#include "VTKViewer_Algorithm.h"
+#include "VTKViewer_Functor.h"
+#include "VTKViewer_Prs.h"
+#include "SALOME_Actor.h"
#include "SALOME_Transform.h"
#include "SALOME_TransformFilter.h"
#include "SALOME_GeometryFilter.h"
// VTK Includes
#include <vtkActor.h>
+#include <vtkCamera.h>
#include <vtkRenderer.h>
#include <vtkTransform.h>
+#include <vtkActorCollection.h>
+
+#include <TColStd_IndexedMapOfInteger.hxx>
using namespace std;
// Create an interactor.
m_RWInteractor = VTKViewer_RenderWindowInteractor::New();
- m_RWInteractor->setGUIWindow(m_RW);
m_RWInteractor->SetRenderWindow(m_RW->getRenderWindow());
VTKViewer_InteractorStyleSALOME* RWS = VTKViewer_InteractorStyleSALOME::New();
- RWS->setGUIWindow(m_RW);
m_RWInteractor->SetInteractorStyle(RWS);
+ RWS->Delete();
+
+ m_RWInteractor->setGUIWindow(m_RW);
+ RWS->setGUIWindow(m_RW);
m_RWInteractor->Initialize();
+ m_RWInteractor->setViewFrame(this);
RWS->setTriedron(m_Triedron);
+ RWS->setViewFrame(this);
//SRN: additional initialization, to init CurrentRenderer of vtkInteractorStyle
RWS->FindPokedRenderer(0, 0);
}
VTKViewer_ViewFrame::~VTKViewer_ViewFrame() {
- m_Transform->Delete() ;
// In order to ensure that the interactor unregisters
// this RenderWindow, we assign a NULL RenderWindow to
// it before deleting it.
m_RWInteractor->SetRenderWindow(NULL) ;
m_RWInteractor->Delete() ;
+ m_Transform->Delete() ;
//m_RW->Delete() ;
m_Renderer->RemoveAllProps();
// NRI : BugID 1137: m_Renderer->Delete() ;
m_Triedron->Delete();
- MESSAGE("VTKViewer_ViewFrame::~VTKViewer_ViewFrame()");
+ INFOS("VTKViewer_ViewFrame::~VTKViewer_ViewFrame()");
}
/*!
return m_Triedron->GetVisibility() == VTKViewer_Trihedron::eOn;
}
-void VTKViewer_ViewFrame::onAdjustTrihedron(){
- if(!isTrihedronDisplayed())
+bool VTKViewer_ViewFrame::ComputeTrihedronSize( double& theNewSize, double& theSize )
+{
+ // calculating diagonal of visible props of the renderer
+ float bnd[ 6 ];
+ m_Triedron->VisibilityOff();
+ if ( ::ComputeVisiblePropBounds( m_Renderer, bnd ) == 0 )
+ {
+ bnd[ 1 ] = bnd[ 3 ] = bnd[ 5 ] = 100;
+ bnd[ 0 ] = bnd[ 2 ] = bnd[ 100 ] = 0;
+ }
+ m_Triedron->VisibilityOn();
+ float aLength = 0;
+ static bool CalcByDiag = false;
+ if ( CalcByDiag )
+ {
+ aLength = sqrt( ( bnd[1]-bnd[0])*(bnd[1]-bnd[0] )+
+ ( bnd[3]-bnd[2])*(bnd[3]-bnd[2] )+
+ ( bnd[5]-bnd[4])*(bnd[5]-bnd[4] ) );
+ }
+ else
+ {
+ aLength = bnd[ 1 ]-bnd[ 0 ];
+ aLength = max( ( bnd[ 3 ] - bnd[ 2 ] ),aLength );
+ aLength = max( ( bnd[ 5 ] - bnd[ 4 ] ),aLength );
+ }
+
+ static float aSizeInPercents = 105;
+ QString aSetting = QAD_CONFIG->getSetting( "Viewer:TrihedronSize" );
+ if ( !aSetting.isEmpty() )
+ aSizeInPercents = aSetting.toFloat();
+
+ static float EPS_SIZE = 5.0E-3;
+ theSize = m_Triedron->GetSize();
+ theNewSize = aLength * aSizeInPercents / 100.0;
+
+ // if the new trihedron size have sufficient difference, then apply the value
+ return fabs( theNewSize - theSize) > theSize * EPS_SIZE ||
+ fabs( theNewSize-theSize ) > theNewSize * EPS_SIZE;
+}
+
+double VTKViewer_ViewFrame::GetTrihedronSize() const
+{
+ return m_Triedron->GetSize();
+}
+
+void VTKViewer_ViewFrame::AdjustTrihedrons( const bool forcedUpdate )
+{
+ if ( !isTrihedronDisplayed() && !forcedUpdate )
return;
- int aVisibleNum = m_Triedron->GetVisibleActorCount(m_Renderer);
- if(aVisibleNum){
- // calculating diagonal of visible props of the renderer
- float bnd[6];
- m_Triedron->VisibilityOff();
- ::ComputeVisiblePropBounds(m_Renderer,bnd);
- m_Triedron->VisibilityOn();
- float aLength = 0;
- static bool CalcByDiag = false;
- if(CalcByDiag){
- aLength = sqrt((bnd[1]-bnd[0])*(bnd[1]-bnd[0])+
- (bnd[3]-bnd[2])*(bnd[3]-bnd[2])+
- (bnd[5]-bnd[4])*(bnd[5]-bnd[4]));
- }else{
- aLength = bnd[1]-bnd[0];
- aLength = max((bnd[3]-bnd[2]),aLength);
- aLength = max((bnd[5]-bnd[4]),aLength);
- }
-
- static float aSizeInPercents = 105;
- QString aSetting = QAD_CONFIG->getSetting("Viewer:TrihedronSize");
- if(!aSetting.isEmpty()) aSizeInPercents = aSetting.toFloat();
-
- static float EPS_SIZE = 5.0E-3;
- float aSize = m_Triedron->GetSize();
- float aNewSize = aLength*aSizeInPercents/100.0;
+
+ int aVisibleNum = m_Triedron->GetVisibleActorCount( m_Renderer );
+ if ( aVisibleNum || forcedUpdate )
+ {
// if the new trihedron size have sufficient difference, then apply the value
- if(fabs(aNewSize-aSize) > aSize*EPS_SIZE || fabs(aNewSize-aSize) > aNewSize*EPS_SIZE){
- m_Triedron->SetSize(aNewSize);
+ double aNewSize = 100, anOldSize;
+ if ( ComputeTrihedronSize( aNewSize, anOldSize ) || forcedUpdate )
+ {
+ m_Triedron->SetSize( aNewSize );
+ // itearte throuh displayed objects and set size if necessary
+
+ vtkActorCollection* anActors = getRenderer()->GetActors();
+ anActors->InitTraversal();
+ while( vtkActor* anActor = anActors->GetNextActor() )
+ {
+ if( SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast( anActor ) )
+ {
+ if ( aSActor->IsResizable() )
+ aSActor->SetSize( 0.5 * aNewSize );
+ }
+ }
}
}
+
::ResetCameraClippingRange(m_Renderer);
}
+void VTKViewer_ViewFrame::onAdjustTrihedron()
+{
+ AdjustTrihedrons( false );
+}
+
/*!
Display/hide Trihedron
*/
*/
void VTKViewer_ViewFrame::onViewLeft(){
vtkCamera* camera = m_Renderer->GetActiveCamera();
- camera->SetPosition(0,1,0);
+ camera->SetPosition(0,-1,0);
camera->SetViewUp(0,0,1);
camera->SetFocalPoint(0,0,0);
onViewFitAll();
*/
void VTKViewer_ViewFrame::onViewRight(){
vtkCamera* camera = m_Renderer->GetActiveCamera();
- camera->SetPosition(0,-1,0);
+ camera->SetPosition(0,1,0);
camera->SetViewUp(0,0,1);
camera->SetFocalPoint(0,0,0);
onViewFitAll();
*/
void VTKViewer_ViewFrame::onViewFitAll(){
m_RWInteractor->GetInteractorStyleSALOME()->ViewFitAll();
-// int aTriedronWasVisible = isTrihedronDisplayed();
-// if(m_Triedron->GetVisibleActorCount(m_Renderer)){
-// m_Triedron->VisibilityOff();
-// ::ResetCamera(m_Renderer);
-// }else{
-// m_Triedron->SetVisibility(VTKViewer_Trihedron::eOnlyLineOn);
-// ::ResetCamera(m_Renderer,true);
-// }
-// if(aTriedronWasVisible) m_Triedron->VisibilityOn();
-// else m_Triedron->VisibilityOff();
-
Repaint();
}
SALOME_Selection* Sel = SALOME_Selection::Selection( ActiveStudy->getSelection() );
m_RWInteractor->highlight(IObject, highlight, update);
- switch (Sel->SelectionMode()) {
- case NodeSelection:
- if ( Sel->HasIndex( IObject ) ) {
- TColStd_MapOfInteger MapIndex;
- Sel->GetIndex( IObject, MapIndex );
- m_RWInteractor->highlightPoint(IObject, highlight, MapIndex, update);
- }
- break;
- case EdgeOfCellSelection:
- if ( Sel->HasIndex( IObject ) ) {
- TColStd_MapOfInteger MapIndex;
- Sel->GetIndex( IObject, MapIndex );
- m_RWInteractor->highlightEdge(IObject, highlight, MapIndex, update);
- }
- break;
- case CellSelection:
- case EdgeSelection:
- case FaceSelection:
- case VolumeSelection:
- if ( Sel->HasIndex( IObject ) ) {
- TColStd_MapOfInteger MapIndex;
- Sel->GetIndex( IObject, MapIndex );
- m_RWInteractor->highlightCell(IObject, highlight, MapIndex, update);
+ if(Sel->HasIndex(IObject) && IObject->hasEntry()){
+ TColStd_IndexedMapOfInteger MapIndex;
+ Sel->GetIndex(IObject,MapIndex);
+ using namespace SALOME::VTK;
+ const char* anEntry = IObject->getEntry();
+ vtkActorCollection* aCollection = getRenderer()->GetActors();
+ if(SALOME_Actor* anActor = Find<SALOME_Actor>(aCollection,TIsSameEntry<SALOME_Actor>(anEntry))){
+ switch (Sel->SelectionMode()) {
+ case NodeSelection:
+ m_RWInteractor->highlightPoint(MapIndex,anActor,highlight,update);
+ break;
+ case EdgeOfCellSelection:
+ m_RWInteractor->highlightEdge(MapIndex,anActor,highlight,update);
+ break;
+ case CellSelection:
+ case EdgeSelection:
+ case FaceSelection:
+ case VolumeSelection:
+ m_RWInteractor->highlightCell(MapIndex,anActor,highlight,update);
+ break;
+ }
}
- break;
+ }else{
+ m_RWInteractor->unHighlightSubSelection();
}
}
m_RW->setPopupServer( App );
}
-void VTKViewer_ViewFrame::undo(SALOMEDS::Study_var aStudy,
- const char* StudyFrameEntry)
+/* selection */
+Handle(SALOME_InteractiveObject) VTKViewer_ViewFrame::FindIObject(const char* theEntry)
{
- vtkActorCollection* theActors = m_Renderer->GetActors();
- theActors->InitTraversal();
- vtkActor *ac = theActors->GetNextActor();
- while(!(ac==NULL)) {
- if ( ac->IsA("SALOME_Actor") ) {
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
- if ( anActor->hasIO() ) {
- Handle(SALOME_InteractiveObject) IO = anActor->getIO();
- if ( IO->hasEntry() ) {
- /*if (!QAD_ViewFrame::isInViewer(aStudy, IO->getEntry(), StudyFrameEntry)) {
- m_RWInteractor->Erase(IO);
- }*/
- }
- }
- }
- ac = theActors->GetNextActor();
- }
+ using namespace SALOME::VTK;
+ SALOME_Actor* anActor =
+ Find<SALOME_Actor>(getRenderer()->GetActors(),
+ TIsSameEntry<SALOME_Actor>(theEntry));
+ if(anActor)
+ return anActor->getIO();
+
+ return Handle(SALOME_InteractiveObject)();
}
-void VTKViewer_ViewFrame::redo(SALOMEDS::Study_var aStudy,
- const char* StudyFrameEntry)
+/* display */
+void VTKViewer_ViewFrame::Display(const Handle(SALOME_InteractiveObject)& theIObject, bool update)
{
- SALOMEDS::SObject_var RefSO;
- SALOMEDS::SObject_var SO = aStudy->FindObjectID( StudyFrameEntry );
- SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO);
- for (; it->More();it->Next()){
- SALOMEDS::SObject_var CSO= it->Value();
- if (CSO->ReferencedObject(RefSO)) {
- vtkActorCollection* theActors = m_Renderer->GetActors();
- theActors->InitTraversal();
- vtkActor *ac = theActors->GetNextActor();
- while(!(ac==NULL)) {
- if ( ac->IsA("SALOME_Actor") ) {
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
- if ( anActor->hasIO() ) {
- Handle(SALOME_InteractiveObject) IO = anActor->getIO();
- if ( IO->hasEntry() ) {
- /*if ( strcmp(IO->getEntry(),RefSO->GetID()) == 0 )
- m_RWInteractor->Display(IO);*/
- }
- }
- }
- ac = theActors->GetNextActor();
- }
- }
- }
+ QAD_Study* aStudy = QAD_Application::getDesktop()->getActiveStudy();
+ SALOME_Selection* aSel = SALOME_Selection::Selection(aStudy->getSelection());
+
+ m_RWInteractor->Display(theIObject,false);
+ aSel->AddIObject(theIObject,false);
+
+ if(update)
+ Repaint();
}
-/* selection */
-Handle(SALOME_InteractiveObject) VTKViewer_ViewFrame::FindIObject(const char* Entry)
-{
- Handle(SALOME_InteractiveObject) IO;
- vtkActorCollection* theActors = m_Renderer->GetActors();
- theActors->InitTraversal();
- vtkActor *ac = theActors->GetNextActor();
- while(!(ac==NULL)) {
- if ( ac->IsA("SALOME_Actor") ) {
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
- if ( anActor->hasIO() ) {
- IO = anActor->getIO();
- if ( IO->hasEntry() ) {
- if ( strcmp( IO->getEntry(), Entry ) == 0 ) {
- return IO;
- }
- }
- }
- }
- ac = theActors->GetNextActor();
+struct TDisplayAction{
+ SALOME_Selection* mySel;
+ Handle(SALOME_InteractiveObject) myIO;
+ TDisplayAction(SALOME_Selection* theSel,
+ Handle(SALOME_InteractiveObject) theIO):
+ mySel(theSel), myIO(theIO)
+ {}
+ void operator()(SALOME_Actor* theActor){
+ theActor->SetVisibility(true);
+ mySel->AddIObject(myIO,false);
}
- return IO;
-}
+};
-/* display */
-void VTKViewer_ViewFrame::Display(const Handle(SALOME_InteractiveObject)& IObject, bool update)
+void VTKViewer_ViewFrame::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject)
{
- QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
- SALOME_Selection* Sel
- = SALOME_Selection::Selection( myStudy->getSelection() );
-
- vtkActorCollection* theActors = m_Renderer->GetActors();
- theActors->InitTraversal();
- vtkActor *ac = theActors->GetNextActor();
- while(!(ac==NULL))
- {
- if ( ac->IsA("SALOME_Actor") )
- {
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
- if ( anActor->hasIO() )
- {
- Handle(SALOME_InteractiveObject) IO = anActor->getIO();
- if ( IO->isSame(IObject) )
- {
- m_RWInteractor->Display(IO, false);
- Sel->AddIObject(IO, false);
- break;
- }
- }
- }
- ac = theActors->GetNextActor();
- }
- if (update)
- Repaint();
-}
+ QAD_Study* aStudy = QAD_Application::getDesktop()->getActiveStudy();
+ SALOME_Selection* aSel = SALOME_Selection::Selection(aStudy->getSelection());
+ aSel->ClearIObjects();
+ m_RWInteractor->EraseAll();
+
+ using namespace SALOME::VTK;
+ ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject),
+ TDisplayAction(aSel,theIObject));
-void VTKViewer_ViewFrame::DisplayOnly(const Handle(SALOME_InteractiveObject)& IObject)
-{
- QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
- SALOME_Selection* Sel
- = SALOME_Selection::Selection( myStudy->getSelection() );
-
- vtkActorCollection* theActors = m_Renderer->GetActors();
- theActors->InitTraversal();
- vtkActor *ac = theActors->GetNextActor();
- while(!(ac==NULL)) {
- if ( ac->IsA("SALOME_Actor") ) {
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
- if ( anActor->hasIO() ) {
- Handle(SALOME_InteractiveObject) IO = anActor->getIO();
- if ( !IO->isSame(IObject) ) {
- m_RWInteractor->Erase(IO, false);
- Sel->RemoveIObject(IO, false);
- } else {
- anActor->SetVisibility(true);
- Sel->AddIObject(IO, false);
- }
- }
- }
- ac = theActors->GetNextActor();
- }
Repaint();
}
-void VTKViewer_ViewFrame::Erase(const Handle(SALOME_InteractiveObject)& IObject, bool update)
+
+struct TEraseAction: TDisplayAction{
+ VTKViewer_RenderWindowInteractor* myRWInteractor;
+ TEraseAction(SALOME_Selection* theSel,
+ Handle(SALOME_InteractiveObject) theIO,
+ VTKViewer_RenderWindowInteractor* theRWInteractor):
+ TDisplayAction(theSel,theIO),
+ myRWInteractor(theRWInteractor)
+ {}
+ void operator()(SALOME_Actor* theActor){
+ myRWInteractor->Erase(myIO,false);
+ mySel->RemoveIObject(myIO,false);
+ }
+};
+
+void VTKViewer_ViewFrame::Erase(const Handle(SALOME_InteractiveObject)& theIObject, bool update)
{
- QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
- SALOME_Selection* Sel
- = SALOME_Selection::Selection( myStudy->getSelection() );
-
- vtkActorCollection* theActors = m_Renderer->GetActors();
- theActors->InitTraversal();
- vtkActor *ac = theActors->GetNextActor();
- while(!(ac==NULL))
- {
- if ( ac->IsA("SALOME_Actor") )
- {
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
- if ( anActor->hasIO() )
- {
- Handle(SALOME_InteractiveObject) IO = anActor->getIO();
- if ( IO->isSame( IObject ) ) {
- m_RWInteractor->Erase(IO, false);
- Sel->RemoveIObject(IO, false);
- break;
- }
- }
- }
- ac = theActors->GetNextActor();
- }
- if (update)
+ QAD_Study* aStudy = QAD_Application::getDesktop()->getActiveStudy();
+ SALOME_Selection* aSel = SALOME_Selection::Selection(aStudy->getSelection());
+
+ using namespace SALOME::VTK;
+ ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject),
+ TEraseAction(aSel,theIObject,m_RWInteractor));
+
+ if(update)
Repaint();
}
Repaint();
}
-void VTKViewer_ViewFrame::AddActor( SALOME_Actor* theActor, bool update /*=false*/ ){
- theActor->SetVisibility(true);
+void VTKViewer_ViewFrame::InsertActor( SALOME_Actor* theActor, bool theMoveInternalActors ){
theActor->AddToRender(m_Renderer);
theActor->SetTransform(m_Transform);
- if(update) Repaint();
+ if(theMoveInternalActors)
+ m_RWInteractor->MoveInternalActors();
+}
+
+void VTKViewer_ViewFrame::AddActor( SALOME_Actor* theActor, bool theUpdate /*=false*/ ){
+ InsertActor(theActor);
+ if(theUpdate)
+ Repaint();
}
-void VTKViewer_ViewFrame::RemoveActor( SALOME_Actor* theActor, bool update /*=false*/ ){
+void VTKViewer_ViewFrame::RemoveActor( SALOME_Actor* theActor, bool theUpdate /*=false*/ ){
theActor->RemoveFromRender(m_Renderer);
- if(update) Repaint();
+ if(theUpdate)
+ Repaint();
+}
+
+void VTKViewer_ViewFrame::MoveActor(SALOME_Actor* theActor)
+{
+ RemoveActor(theActor);
+ InsertActor(theActor,true);
+}
+
+//==========================================================
+/*!
+ * VTKViewer_ViewFrame::Display
+ * Display presentation
+ */
+//==========================================================
+void VTKViewer_ViewFrame::Display( const SALOME_VTKPrs* prs )
+{
+ // try do downcast object
+ const VTKViewer_Prs* aVTKPrs = dynamic_cast<const VTKViewer_Prs*>( prs );
+ if ( !aVTKPrs || aVTKPrs->IsNull() )
+ return;
+
+ vtkActorCollection* actors = aVTKPrs->GetObjects();
+ if ( !actors )
+ return;
+
+ actors->InitTraversal();
+ vtkActor* actor;
+ while( ( actor = actors->GetNextActor() ) )
+ {
+ SALOME_Actor* salomeActor = SALOME_Actor::SafeDownCast( actor );
+ if ( salomeActor )
+ {
+ // just display the object
+ m_RWInteractor->Display( salomeActor, false );
+ if ( salomeActor->IsSetCamera() )
+ salomeActor->SetCamera( getRenderer()->GetActiveCamera() );
+ }
+ }
+}
+
+//==========================================================
+/*!
+ * VTKViewer_ViewFrame::Erase
+ * Erase presentation
+ */
+//==========================================================
+void VTKViewer_ViewFrame::Erase( const SALOME_VTKPrs* prs, const bool forced )
+{
+ // try do downcast object
+ const VTKViewer_Prs* aVTKPrs = dynamic_cast<const VTKViewer_Prs*>( prs );
+ if ( !aVTKPrs || aVTKPrs->IsNull() )
+ return;
+
+ vtkActorCollection* actors = aVTKPrs->GetObjects();
+ if ( !actors )
+ return;
+
+ actors->InitTraversal();
+ vtkActor* actor;
+ while( ( actor = actors->GetNextActor() ) ) {
+ SALOME_Actor* salomeActor = SALOME_Actor::SafeDownCast( actor );
+ if ( salomeActor ) {
+ // just erase the object
+ m_RWInteractor->Erase( salomeActor, forced );
+ }
+ }
+}
+
+//==========================================================
+/*!
+ * VTKViewer_ViewFrame::CreatePrs
+ * Create presentation by entry
+ */
+//==========================================================
+SALOME_Prs* VTKViewer_ViewFrame::CreatePrs( const char* entry )
+{
+ VTKViewer_Prs* prs = new VTKViewer_Prs();
+ if ( entry ) {
+ vtkActorCollection* theActors = m_Renderer->GetActors();
+ theActors->InitTraversal();
+ vtkActor* ac;
+ while( ( ac = theActors->GetNextActor() ) ) {
+ SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
+ if ( anActor && anActor->hasIO() && !strcmp( anActor->getIO()->getEntry(), entry ) ) {
+ prs->AddObject( ac );
+ }
+ }
+ }
+ return prs;
+}
+
+//==========================================================
+/*!
+ * VTKViewer_ViewFrame::BeforeDisplay
+ * Axiluary method called before displaying of objects
+ */
+//==========================================================
+void VTKViewer_ViewFrame::BeforeDisplay( SALOME_Displayer* d )
+{
+ d->BeforeDisplay( this, SALOME_VTKViewType() );
+}
+
+//==========================================================
+/*!
+ * VTKViewer_ViewFrame::AfterDisplay
+ * Axiluary method called after displaying of objects
+ */
+//==========================================================
+void VTKViewer_ViewFrame::AfterDisplay( SALOME_Displayer* d )
+{
+ d->AfterDisplay( this, SALOME_VTKViewType() );
}
#include "QAD.h"
#include "QAD_ViewFrame.h"
-#include "VTKViewer_RenderWindowInteractor.h"
-#include "VTKViewer_RenderWindow.h"
-
-// VTK Includes
class vtkRenderer;
-class vtkTransform;
+
+class SALOME_Actor;
+class SALOME_Transform;
+
class VTKViewer_Trihedron;
+class VTKViewer_RenderWindow;
+class VTKViewer_RenderWindowInteractor;
+
class QAD_EXPORT VTKViewer_ViewFrame : public QAD_ViewFrame{
Q_OBJECT;
bool isInViewer( const Handle(SALOME_InteractiveObject)& IObject );
bool isVisible( const Handle(SALOME_InteractiveObject)& IObject );
- /* undo/redo management */
- void undo(SALOMEDS::Study_var aStudy,
- const char* StudyFrameEntry);
- void redo(SALOMEDS::Study_var aStudy,
- const char* StudyFrameEntry);
-
-
/* selection */
Handle(SALOME_InteractiveObject) FindIObject(const char* Entry);
void Repaint(bool theUpdateTrihedron);
void Repaint() { Repaint(true); }
+ /* Reimplemented from SALOME_View */
+ void Display( const SALOME_VTKPrs* );
+ void Erase( const SALOME_VTKPrs*, const bool = false );
+ SALOME_Prs* CreatePrs( const char* entry = 0 );
+ virtual void BeforeDisplay( SALOME_Displayer* d );
+ virtual void AfterDisplay ( SALOME_Displayer* d );
+
//apply existing transformation on adding SALOME_Actor
void SetScale(double theScale[3]);
void GetScale(double theScale[3]);
void AddActor(SALOME_Actor*, bool update = false);
void RemoveActor(SALOME_Actor*, bool update = false);
+ void AdjustTrihedrons( const bool forced );
+ bool ComputeTrihedronSize( double& theNewSize, double& theOldSize );
+ double GetTrihedronSize() const;
public slots:
void onViewPan();
void onViewZoom();
void onAdjustTrihedron();
private:
- double m_ViewUp[3];
- double m_ViewNormal[3];
-
- void InitialSetup();
+ void InitialSetup();
- vtkRenderer* m_Renderer;
- VTKViewer_RenderWindow* m_RW;
+ double m_ViewUp[3];
+ double m_ViewNormal[3];
+
+ vtkRenderer* m_Renderer;
+ VTKViewer_RenderWindow* m_RW;
VTKViewer_RenderWindowInteractor* m_RWInteractor;
- VTKViewer_Trihedron *m_Triedron;
- SALOME_Transform *m_Transform;
+ friend class VTKViewer_RenderWindowInteractor;
+ void InsertActor(SALOME_Actor* theActor, bool theMoveInternalActors = false);
+ void MoveActor(SALOME_Actor* theActor);
+
+ VTKViewer_Trihedron* m_Triedron;
+ SALOME_Transform* m_Transform;
};
#endif