From: prascle Date: Fri, 5 Nov 2004 12:02:26 +0000 (+0000) Subject: PR: merge from trunk tag mergeto_BR_GEAY_04Nov04 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6c43b0659b08ab73136c56b22a86c8e50b70f1d5;p=modules%2Fkernel.git PR: merge from trunk tag mergeto_BR_GEAY_04Nov04 --- diff --git a/INSTALL b/INSTALL index 197b45757..a8d9d6266 100644 --- a/INSTALL +++ b/INSTALL @@ -1,6 +1,7 @@ -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 diff --git a/Makefile.in b/Makefile.in index 5ec410ee3..426130bbd 100644 --- a/Makefile.in +++ b/Makefile.in @@ -100,10 +100,20 @@ salome.launch \ 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) @@ -121,6 +131,10 @@ salome_adm/unix/SALOMEconfig.ref: salome_adm/unix/SALOMEconfig.h 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) ../../$< $@ @@ -168,7 +182,7 @@ distclean: distclean-other 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@ diff --git a/bin/VERSION b/bin/VERSION index 699b2270c..f15697e35 100755 --- a/bin/VERSION +++ b/bin/VERSION @@ -1 +1 @@ -THIS IS SALOME - KERNEL VERSION: 2.0.0 +THIS IS SALOME - KERNEL VERSION: 2.1.0 diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py index 47f120d8e..b673049e9 100755 --- a/bin/launchConfigureParser.py +++ b/bin/launchConfigureParser.py @@ -44,7 +44,7 @@ class xml_parser: 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")) diff --git a/bin/runSalome b/bin/runSalome index 9577ea58e..7505e8b89 100755 --- a/bin/runSalome +++ b/bin/runSalome @@ -1,19 +1,33 @@ #!/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} < $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 $* @@ -26,15 +40,15 @@ fi # --------- # $: ${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): diff --git a/bin/runSalome.csh b/bin/runSalome.csh index 5761b299f..73798c25c 100755 --- a/bin/runSalome.csh +++ b/bin/runSalome.csh @@ -1,3 +1,3 @@ #!/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 diff --git a/bin/runSalome.py b/bin/runSalome.py index af5d4c114..400866a1b 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -255,7 +255,10 @@ if "SMESH" in modules_list: 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 # @@ -330,6 +333,8 @@ def startSalome(): 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() diff --git a/bin/salome.launch b/bin/salome.launch index 43b8fc9f6..1b5bbdd1b 100644 --- a/bin/salome.launch +++ b/bin/salome.launch @@ -10,8 +10,8 @@ + - diff --git a/build_configure b/build_configure index 0cf5fc380..8ce1d16ed 100755 --- a/build_configure +++ b/build_configure @@ -119,7 +119,7 @@ echo " ./salome_adm/Makefile \\" >> configure.in_tmp1 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 @@ -191,6 +191,23 @@ else 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 diff --git a/configure.in.base b/configure.in.base index acf3a45fd..0eef838db 100644 --- a/configure.in.base +++ b/configure.in.base @@ -149,6 +149,22 @@ dnl CHECK_SOCKETS +dnl +dnl --------------------------------------------- +dnl testing OpenPBS +dnl --------------------------------------------- +dnl + +echo +echo --------------------------------------------- +echo testing OpenPBS +echo --------------------------------------------- +echo + +openpbs_ok=no +CHECK_OPENPBS +dnl openpbs_ok is set to yes by CHECK_OPENPBS + echo echo --------------------------------------------- echo testing LEX \& YACC @@ -300,7 +316,7 @@ echo --------------------------------------------- echo echo Configure -variables="cc_ok boost_ok lex_yacc_ok mpi_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok med2_ok omniORB_ok occ_ok sip_ok pyqt_ok qwt_ok doxygen_ok graphviz_ok" +variables="cc_ok boost_ok lex_yacc_ok mpi_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok med2_ok omniORB_ok occ_ok sip_ok pyqt_ok qwt_ok doxygen_ok graphviz_ok openpbs_ok" for var in $variables do @@ -374,7 +390,7 @@ do case "$local_bin" in *.in | *~) ;; ./bin/CVS | ./bin/salome) ;; - *) /usr/bin/install -C $i .; echo $local_bin ;; + *) /usr/bin/install -c $i .; echo $local_bin ;; esac done cd $ROOT_BUILDDIR diff --git a/doc/salome/gui/KERNEL/files/running_salome_pro.htm b/doc/salome/gui/KERNEL/files/running_salome_pro.htm index c37559391..358eb21ac 100755 --- a/doc/salome/gui/KERNEL/files/running_salome_pro.htm +++ b/doc/salome/gui/KERNEL/files/running_salome_pro.htm @@ -1,38 +1,41 @@ - - - - - - - - - - -Running SALOME - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - + + + + + + + + + -

Running SALOME

- -

To launch SALOME:

- -

 

- -

1. Install the SALOME package into a definite - directory (ex. SALOME) on your - hard disk. It is preferable if you use the special - installation procedure allowing to install the  SALOME - platform and all corresponding applications.

- -

 

- -

2. - The installation shell script will create a special file: env.csh - (CShell file) in your SALOME 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:

- -

 

- -

source - env.csh

- -

 

- -

During - the installation procedure you have a possibility to - set your profile automatically.  

- -

 

- -

 

- -

3. Launch SALOME platform, using the following - Python script located in the SALOME/KERNEL/bin/salome - directory:

- -

 

- -
    - -
  • runSalome.py - [command line options]

  • -
- -

 

- - - - +

Running SALOME

+ +

To launch SALOME:

+ +

 

+ +

1. Install the SALOME package into a definite directory +(ex. SALOME) on your hard +disk. It is preferable if you use the special installation +procedure allowing to install the  SALOME platform and all corresponding +applications.

+ +

 

+ +

2. +The installation shell script will create a special file: env.csh + (CShell file) in your SALOME 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:

+ +

 

+ +

source + env.csh

+ +

 

+ +

3. Launch SALOME platform, using the following Python +script located in the SALOME/KERNEL/bin/salome + directory:

+ +

 

+ +
    +
  • +

    runSalome.py + [command line options]

    +
  • + +
+ +

 

+ +
+ + --- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -
-

Options

-

Description

-

--help or - -h   

-

print this help

-

 

-

--gui or - -g   

-

launch with GUI

-

 --terminal or - -t      

-

launch without GUI in batch mode

-

--logger or - -l   

-

redirection of log messages into a definite file

-

--xterm or - -x

-

the servers open an xterm window and log messages are displayed in this - window

-

--modules=module1,module2,... - or -m=module1,module2,...

-

list of SALOME modules which will be loaded into the module catalogue

-

--containers=cpp,python,superv

-

or -c=cpp,python,superv

-

launch of cpp, python and supervision containers

-

--portkill or - -p

-

kill SALOME launched with the current port

-

--killall or - -k    

-

kill SALOME

+

Options

+
+

Description

+
+

--help or -h   

+
+

print this help

+ +

 

+
+

--gui or -g   

+
+

launch with GUI

+
+

 --terminal + or -t      

+
+

launch without GUI in batch mode

+
+

--logger or -l   

+
+

redirection of log messages into a definite file

+
+

--xterm or -x

+
+

the servers open an xterm window and log messages are displayed +in this window

+
+

--modules=module1,module2,... + or -m=module1,module2,...

+
+

list of SALOME modules which will be loaded into the module catalogue

+
+

--containers=cpp,python,superv

+ +

or -c=cpp,python,superv

+
+

launch of cpp, python and supervision containers

+
+

--portkill or -p

+
+

kill SALOME launched with the current port

+
+

--killall or -k    

+
+

kill SALOME

+
- -

 

- -

- If the runSalome.py - script - is launched without prompting any options, they will be taken by default - from the xml file salome.launch, - which has been automatically created in your home directory: HOME/.salome/. -    

- -

 

- -

 

- -

-Related Topics

- -

 

- -

 

- -

 

- - + + + +

 

+ +

+ + If the runSalome.py + script + is launched without prompting any options, they will be taken by default + from the xml file salome.launch, which +has been automatically created in your home directory: HOME/.salome/.    

+ +

 

+ +

 

+ +

Related Topics +

+ +

 

+ +

 

+ +

 

+ + + - - - +
+ + diff --git a/doc/salome/tui/KERNEL/HTML/SALOMEDS.html b/doc/salome/tui/KERNEL/HTML/SALOMEDS.html index 52291faa3..f9d2b559d 100644 --- a/doc/salome/tui/KERNEL/HTML/SALOMEDS.html +++ b/doc/salome/tui/KERNEL/HTML/SALOMEDS.html @@ -35,6 +35,10 @@
return_value = FindObjectID ( aObjectID )
+
SObject CreateObjectID ( in ID aObjectID )
+
return_value = CreateObjectID ( aObjectID )
+ +
SObject FindObjectIOR ( in ID aObjectIOR )
return_value = FindObjectIOR ( aObjectIOR )
@@ -130,6 +134,22 @@
void EnableUseCaseAutoFilling ( in boolean isEnabled )
EnableUseCaseAutoFilling ( isEnabled )
+ +
void AddPostponed ( in string theIOR )
+
AddPostponed ( theIOR )
+ + +
void AddCreatedPostponed ( in string theIOR )
+
AddCreatedPostponed ( theIOR )
+ + +
void RemovePostponed ( in long theUndoLimit )
+
RemovePostponed ( theUndoLimit )
+ + +
void UndoPostponed ( in long theWay )
+
UndoPostponed ( theWay )
+
@@ -191,6 +211,10 @@ + + + + @@ -242,6 +266,18 @@ + + + + + + + + + + + +
Addreference ( anObject, theReferencedObject )
void RemoveReference ( in SObject anObject )
RemoveReference ( anObject )
void AddDirectory ( in string theName )
AddDirectory ( theName )
Callback SetOnRemoveSObject ( in Callback theCallback )
return_value = SetOnRemoveSObject ( theCallback )
void SetName ( in SObject theSO, in string theValue )
SetName ( theSO, theValue )
void SetComment ( in SObject theSO, in string theValue )
SetComment ( theSO, theValue )
void SetIOR ( in SObject theSO, in string theValue )
SetIOR ( theSO, theValue )

@@ -335,6 +371,10 @@ + + + + @@ -354,6 +394,22 @@ + + + + + + + + + + + + + + + +
return_value = Tag ( )
short Depth ( )
return_value = Depth ( )
boolean FindSubObject ( in long atag, out SObject obj )
[ return_value, obj ] = FindSubObject ( atag )
Study GetStudy ( )
return_value = GetStudy ( )
Object GetObject ( )
return_value = GetObject ( )
string GetName ( )
return_value = GetName ( )
string GetComment ( )
return_value = GetComment ( )
string GetIOR ( )
return_value = GetIOR ( )

@@ -366,6 +422,22 @@ + + + + + + + + + + + + + + + +
void CheckLocked ( )
CheckLocked ( )
string Store ( )
return_value = Store ( )
void Restore ( in string theData )
Restore ( theData )
string Type ( )
return_value = Type ( )
SObject GetSObject ( )
return_value = GetSObject ( )

diff --git a/doc/salome/tui/KERNEL/HTML/SALOMEDS_Attributes.html b/doc/salome/tui/KERNEL/HTML/SALOMEDS_Attributes.html index 7dbf29d3f..49f848f73 100644 --- a/doc/salome/tui/KERNEL/HTML/SALOMEDS_Attributes.html +++ b/doc/salome/tui/KERNEL/HTML/SALOMEDS_Attributes.html @@ -169,6 +169,38 @@

+ + + + + + + + + + + + + +
interface AttributeExternalFileDef
IDL file
Python
string Value ( )
return_value = Value ( )
void SetValue ( in string value )
SetValue ( value )

+ + + + + + + + + + + + + + + +
interface AttributeFileType
IDL file
Python
string Value ( )
return_value = Value ( )
void SetValue ( in string value )
SetValue ( value )

+ + diff --git a/doc/salome/tui/KERNEL/HTML/SALOME_Component.html b/doc/salome/tui/KERNEL/HTML/SALOME_Component.html index 045775117..2d802860c 100644 --- a/doc/salome/tui/KERNEL/HTML/SALOME_Component.html +++ b/doc/salome/tui/KERNEL/HTML/SALOME_Component.html @@ -30,6 +30,14 @@ + + + + + + + +
interface AttributeDrawable
IDL file
boolean Kill_impl ( )
return_value = Kill_impl ( )
string getHostName ( )
return_value = getHostName ( )
long getPID ( )
return_value = getPID ( )

@@ -51,6 +59,14 @@ + + + + + + + + diff --git a/doc/salome/tui/KERNEL/HTML/SALOME_ModuleCatalog.html b/doc/salome/tui/KERNEL/HTML/SALOME_ModuleCatalog.html index 009c6308d..5f618eb1a 100644 --- a/doc/salome/tui/KERNEL/HTML/SALOME_ModuleCatalog.html +++ b/doc/salome/tui/KERNEL/HTML/SALOME_ModuleCatalog.html @@ -66,5 +66,17 @@ + + + + + + + + + + + +
return_value = GetContainerRef ( )
void setProperties ( in FieldsDict dico )
setProperties ( dico )
FieldsDict getProperties ( )
return_value = getProperties ( )
void Names ( in string aGraphName, in string aNodeName )
Names ( aGraphName, aNodeName )
Acomponent GetComponent ( in string componentname )
return_value = GetComponent ( componentname )
Component GetComponentInfo ( in string componentName )
return_value = GetComponentInfo ( componentName )
void ImportXmlCatalogFile ( in string filename )
ImportXmlCatalogFile ( filename )
void shutdown ( )
shutdown ( )

diff --git a/doc/salome/tui/KERNEL/HTML/SALOME_Session.html b/doc/salome/tui/KERNEL/HTML/SALOME_Session.html index 804a067a9..37b46747d 100644 --- a/doc/salome/tui/KERNEL/HTML/SALOME_Session.html +++ b/doc/salome/tui/KERNEL/HTML/SALOME_Session.html @@ -11,8 +11,8 @@
GetInterface ( )
-
Component GetVisuGen ( )
-
return_value = GetVisuGen ( )
+
Component GetVisuComponent ( )
+
return_value = GetVisuComponent ( )
void StopSession ( )
@@ -26,5 +26,9 @@
void ping ( )
ping ( )
+ +
long GetActiveStudyId ( )
+
return_value = GetActiveStudyId ( )
+
diff --git a/doc/salome/tui/KERNEL/HTML/SALOME_TestComponent.html b/doc/salome/tui/KERNEL/HTML/SALOME_TestComponent.html index 44a507fdd..56348f8a1 100644 --- a/doc/salome/tui/KERNEL/HTML/SALOME_TestComponent.html +++ b/doc/salome/tui/KERNEL/HTML/SALOME_TestComponent.html @@ -10,5 +10,9 @@
string Coucou ( in long L )
return_value = Coucou ( L )
+ +
void Setenv ( )
+
Setenv ( )
+
diff --git a/doc/salome/tui/KERNEL/doxyfile b/doc/salome/tui/KERNEL/doxyfile index 6cda60af0..29f6496ce 100755 --- a/doc/salome/tui/KERNEL/doxyfile +++ b/doc/salome/tui/KERNEL/doxyfile @@ -3,7 +3,7 @@ #--------------------------------------------------------------------------- # 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 diff --git a/doc/salome/tui/KERNEL/sources/static/tree.js b/doc/salome/tui/KERNEL/sources/static/tree.js index c76590490..18cf7f25f 100755 --- a/doc/salome/tui/KERNEL/sources/static/tree.js +++ b/doc/salome/tui/KERNEL/sources/static/tree.js @@ -1,4 +1,4 @@ -foldersTree = gFld("SALOME v.2.0.0 ", "", "") +foldersTree = gFld("SALOME v.2.1.0 ", "", "") insDoc(foldersTree, gLnk("Main Page", "", "main.html")) aux1 = insFld(foldersTree, gFld("TUI Reference Guide", "")) diff --git a/idl/Makefile.in b/idl/Makefile.in index c90643669..7de067f74 100644 --- a/idl/Makefile.in +++ b/idl/Makefile.in @@ -35,7 +35,7 @@ PY_CLIENT_IDL = $(IDL_FILES) 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) $< $@ @@ -56,7 +56,7 @@ $(PYTHON_BUILD_SITE)/%_idl.py: $(top_builddir)/idl/salome/%.idl # 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/%) diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index f019faf31..15e651164 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -820,6 +820,11 @@ Gets the list of open studies \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 diff --git a/idl/SALOME_Session.idl b/idl/SALOME_Session.idl index f42ccde7e..ae28b4472 100644 --- a/idl/SALOME_Session.idl +++ b/idl/SALOME_Session.idl @@ -101,6 +101,10 @@ module SALOME Determines whether the server has already been loaded or not. */ void ping(); +/*! + Get Active study ID +*/ + long GetActiveStudyId(); } ; } ; diff --git a/salome_adm/Makefile.in b/salome_adm/Makefile.in index d170972f1..2982ad06c 100644 --- a/salome_adm/Makefile.in +++ b/salome_adm/Makefile.in @@ -21,6 +21,8 @@ lib: include/salome/SALOMEconfig.h: +include/salome/config.h: + include/salome/sstream: depend: diff --git a/salome_adm/unix/config_files/check_boost.m4 b/salome_adm/unix/config_files/check_boost.m4 index 66efc5a13..1cc692c5f 100644 --- a/salome_adm/unix/config_files/check_boost.m4 +++ b/salome_adm/unix/config_files/check_boost.m4 @@ -43,7 +43,6 @@ else AC_CHECK_HEADER(boost/shared_ptr.hpp,boost_ok=yes,boost_ok=no) CPPFLAGS="${CPPFLAGS_old}" - boost_ok=yes fi AC_LANG_RESTORE diff --git a/salome_adm/unix/config_files/check_cas.m4 b/salome_adm/unix/config_files/check_cas.m4 index 2b2048043..85d8f0c73 100644 --- a/salome_adm/unix/config_files/check_cas.m4 +++ b/salome_adm/unix/config_files/check_cas.m4 @@ -39,10 +39,14 @@ AC_SUBST(CAS_LDFLAGS) 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 @@ -89,16 +93,48 @@ if test "x$occ_ok" = "xyes"; then 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" @@ -107,7 +143,7 @@ if test "x$occ_ok" = xyes ; then 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" diff --git a/salome_adm/unix/config_files/check_omniorb.m4 b/salome_adm/unix/config_files/check_omniorb.m4 index 1cd4d763d..f3d5abcdb 100644 --- a/salome_adm/unix/config_files/check_omniorb.m4 +++ b/salome_adm/unix/config_files/check_omniorb.m4 @@ -176,7 +176,7 @@ fi 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) diff --git a/salome_adm/unix/config_files/check_pyqt.m4 b/salome_adm/unix/config_files/check_pyqt.m4 index 6764c325a..cb99775f8 100644 --- a/salome_adm/unix/config_files/check_pyqt.m4 +++ b/salome_adm/unix/config_files/check_pyqt.m4 @@ -29,7 +29,7 @@ pyqt_ok=no if test "x$PYQTDIR" = x; then PYQTDIR="/usr" fi - + if test "x$PYQT_SIPS" = x; then PYQT_SIPS="/usr/share/sip/qt" fi @@ -50,7 +50,11 @@ else 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) diff --git a/salome_adm/unix/config_files/production.m4 b/salome_adm/unix/config_files/production.m4 index aa161181a..b115b8aab 100644 --- a/salome_adm/unix/config_files/production.m4 +++ b/salome_adm/unix/config_files/production.m4 @@ -53,9 +53,16 @@ no) enable_production=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 ]) @@ -89,7 +96,7 @@ enable_debug=AC_ENABLE_DEBUG_DEFAULT)dnl 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 ]) diff --git a/salome_adm/unix/make_commence.in b/salome_adm/unix/make_commence.in index 0c4f7c26a..e42171246 100644 --- a/salome_adm/unix/make_commence.in +++ b/salome_adm/unix/make_commence.in @@ -31,13 +31,19 @@ C_DEPEND_FLAG = @C_DEPEND_FLAG@ # C++ CXX = @CXX@ -CXXFLAGS = @CXXFLAGS@ +CXXFLAGS = @CXXFLAGS@ CXX_DEPEND_FLAG = @CXX_DEPEND_FLAG@ # BOOST Library BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ +# OpenPBS + +OPENPBS_INCLUDES = @OPENPBS_INCLUDES@ +OPENPBS_LIBDIR = @OPENPBS_LIBDIR@ +OPENPBS_LIBS = @OPENPBS_LIBS@ + # JAVA JAVA_INCLUDES = @JAVA_INCLUDES@ @@ -78,6 +84,8 @@ SIP_LIBS = @SIP_LIBS@ # PYQT PYQT_SIPS = @PYQT_SIPS@ PYQT_LIBS = @PYQT_LIBS@ +PYQT_INCLUDES = @PYQT_INCLUDES@ +PYUIC = @PYUIC@ # openGL OGL_INCLUDES=@OGL_INCLUDES@ diff --git a/salome_adm/unix/make_conclude.in b/salome_adm/unix/make_conclude.in index b791f484d..4ad410361 100644 --- a/salome_adm/unix/make_conclude.in +++ b/salome_adm/unix/make_conclude.in @@ -99,11 +99,27 @@ $(BIN) $(TEST_PROGS): %: %.lo $(BIN_OBJ) # 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 @@ -166,7 +182,10 @@ install: $(LIB) $(BIN) $(TEST_PROGS) $(libdir) $(includedir) $(bindir) $(datadir 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)/. @@ -224,6 +243,13 @@ uninstall: 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 \ diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index 9c68bb2a1..b753a6707 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -449,7 +449,7 @@ void SigIntHandler(int what , siginfo_t * siginfo , // Get the PID of the Container long Engines_Container_i::getPID() { - return(_pid); + return (long)getpid(); } // Get the hostName of the Container diff --git a/src/Container/Makefile.in b/src/Container/Makefile.in index 2a7d7ad87..6d68f0fd7 100644 --- a/src/Container/Makefile.in +++ b/src/Container/Makefile.in @@ -48,13 +48,14 @@ LIB_SERVER_IDL = SALOME_Registry.idl SALOME_Component.idl # Executables targets BIN = SALOME_Container -BIN_SRC = +BIN_SRC = SALOME_Container_SignalsHandler.cxx BIN_SERVER_IDL = SALOME_Component.idl -CPPFLAGS+= $(PYTHON_INCLUDES) $(MPI_INCLUDE) +CPPFLAGS+= $(PYTHON_INCLUDES) $(MPI_INCLUDE) $(OCC_INCLUDES) +CXXFLAGS+=$(OCC_CXXFLAGS) LDFLAGS+= -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification -lSALOMELocalTrace -LIBS += -Xlinker -export-dynamic $(PYTHON_LIBS) $(MPI_LIBS) +LIBS += -Xlinker -export-dynamic $(PYTHON_LIBS) $(MPI_LIBS) -lCASCatch @CONCLUDE@ diff --git a/src/Container/SALOME_Component_i.hxx b/src/Container/SALOME_Component_i.hxx index 4b93ef5b5..16a135dc2 100644 --- a/src/Container/SALOME_Component_i.hxx +++ b/src/Container/SALOME_Component_i.hxx @@ -93,11 +93,11 @@ public: 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; @@ -105,7 +105,7 @@ protected: Engines_Component_i * _thisObj ; RegistryConnexion *_myConnexionToRegistry; NOTIFICATION_Supplier* _notifSupplier; - map_fieldsDict; + std::map_fieldsDict; private: pthread_t _ThreadId ; diff --git a/src/Container/SALOME_Container.cxx b/src/Container/SALOME_Container.cxx index 1217b2bd7..a324089b7 100644 --- a/src/Container/SALOME_Container.cxx +++ b/src/Container/SALOME_Container.cxx @@ -26,17 +26,15 @@ // Module : SALOME // $Header$ +#include +#include #include #include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" #include "SALOME_NamingService.hxx" #include "SALOME_Container_i.hxx" -#include -#include #include "utilities.h" -#include "Utils_CatchSignals.h" -using namespace std; #ifdef CHECKTIME #include @@ -48,191 +46,166 @@ using namespace std; #include -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 - { + + try{ #ifdef HAVE_MPI2 MPI_Init(&argc,&argv); #endif - // Initialise the ORB. - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::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_::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" ); + // Initialise the ORB. + ORB_INIT &init = *SINGLETON_::Instance() ; + ASSERT(SINGLETON_::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_::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 - "< +#include CORBA_SERVER_HEADER(SALOME_Component) + #include #include #include #include #include -#include -#include CORBA_SERVER_HEADER(SALOME_Component) #include #include #include 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(); diff --git a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Handler.cxx b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Handler.cxx index 55217510a..47f8fb92d 100644 --- a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Handler.cxx +++ b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Handler.cxx @@ -26,10 +26,15 @@ // 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 diff --git a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Handler.hxx b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Handler.hxx index 7e76f636c..78d08de30 100644 --- a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Handler.hxx +++ b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Handler.hxx @@ -29,7 +29,6 @@ #ifndef SALOME_DATA_CATALOG_HANDLER_H #define SALOME_DATA_CATALOG_HANDLER_H -#include "utilities.h" #include "SALOME_DataTypeCatalog_Parser.hxx" #include #include @@ -104,7 +103,7 @@ public: private: QString errorProt ; - string content; + std::string content; const char* test_data_type_name ; const char* test_data_type_interf_read ; diff --git a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Parser.hxx b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Parser.hxx index ed65a0c59..fc867bed3 100644 --- a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Parser.hxx +++ b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Parser.hxx @@ -33,22 +33,19 @@ #include // Type Definitions -typedef vector ListOfParserDataTypeName; +typedef std::vector 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 ListOfParserDataType; +typedef std::vector 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 diff --git a/src/Event/SALOME_Event.cxx b/src/Event/SALOME_Event.cxx index dfebd7b02..e12fc070f 100644 --- a/src/Event/SALOME_Event.cxx +++ b/src/Event/SALOME_Event.cxx @@ -33,6 +33,7 @@ #include #include #include +#include #ifdef _DEBUG_ static int MYDEBUG = 0; @@ -40,22 +41,31 @@ 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() - "<operator+=( mySemaphore->total() ); - } - } - if(MYDEBUG) MESSAGE( "SALOME_Event::processed() COMPLETED: this = "< -using namespace std; class HDFConvert { @@ -54,7 +53,7 @@ private: 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); }; diff --git a/src/HDFPersist/HDFexception.hxx b/src/HDFPersist/HDFexception.hxx index 5395341a8..c62f6a18f 100644 --- a/src/HDFPersist/HDFexception.hxx +++ b/src/HDFPersist/HDFexception.hxx @@ -27,12 +27,11 @@ /* Exception */ #include -using namespace std; class HDFexception { public : HDFexception(const char *message) { - cerr << message << endl; + std::cerr << message << std::endl; } }; diff --git a/src/Loader/InquireServersQThread.cxx b/src/Loader/InquireServersQThread.cxx index ed5d276cd..c5cf70377 100644 --- a/src/Loader/InquireServersQThread.cxx +++ b/src/Loader/InquireServersQThread.cxx @@ -192,7 +192,7 @@ void InquireServersGUI::customEvent( QCustomEvent* pe ) int InquireServersGUI::getExitStatus() { - myThread->getExitStatus(); + return myThread->getExitStatus(); } InquireServersQThread::InquireServersQThread( InquireServersGUI* r ) diff --git a/src/Logger/SALOME_Trace.hxx b/src/Logger/SALOME_Trace.hxx index 90fbfd06f..e0019a1f5 100644 --- a/src/Logger/SALOME_Trace.hxx +++ b/src/Logger/SALOME_Trace.hxx @@ -11,6 +11,9 @@ #if !defined(AFX_LOGGER_H__96F2A3AB_F6F8_11D6_BFA6_000476A0958C__INCLUDED_) #define AFX_LOGGER_H__96F2A3AB_F6F8_11D6_BFA6_000476A0958C__INCLUDED_ +#include +#include "Logger.hh" + //these declarations for files don't using OCC includes (for example HDF) # ifdef WNT @@ -42,12 +45,7 @@ # endif /* WNT */ -using namespace std; - -#include -#include "Logger.hh" - -class SALOME_Trace : public ostrstream +class SALOME_Trace : public std::ostrstream { public: virtual ~SALOME_Trace(); diff --git a/src/MEDWrapper/MED_Test.cxx b/src/MEDWrapper/MED_Test.cxx index b227bc110..adc7477d1 100644 --- a/src/MEDWrapper/MED_Test.cxx +++ b/src/MEDWrapper/MED_Test.cxx @@ -45,7 +45,7 @@ void ReadMed(const char* theFileName){ TWrapper aMedW(aFileName); int aNbMeshes = aMed.GetNbMeshes(); - cout<<"GetNbMeshes() = "<SetGroupName(iGroup,aName); } @@ -123,25 +123,25 @@ void ReadMed(const char* theFileName){ aMedW.SetFamilyInfo(*aFamilyInfo); } - cout<<"GetEntityInfo - aNbEntities = "<myCoord; for(int iNode = 0; iNode < aNbNodes; iNode++){ for(int iDim = 0, anId = iNode*aDim; iDim < aDim; iDim++, anId++){ - //cout<myMeshInfo = aNewMeshInfo; aMedW.SetNodeInfo(*aNodeInfo); continue; @@ -151,24 +151,24 @@ void ReadMed(const char* theFileName){ for(; anTGeomIter != aTGeom.end(); anTGeomIter++){ const med_geometrie_element& aGeom = anTGeomIter->first; med_int& aNbElem = anTGeomIter->second; - cout<<"\t\taGeom = "<myNbElem; iElem++){ int i = iElem*aCellInfo->myConnDim; for(int iConn = 0; iConn < aCellInfo->myConnDim; iConn++, i++){ - //cout<myConn[i]<<","; + //MESSAGE(aCellInfo->myConn[i]<<","); } - //cout<<" "; + //MESSAGE(" "); } - cout<myMeshInfo = aNewMeshInfo; aMedW.SetCellInfo(*aCellInfo); } } } - cout<<"OK"< #include #include @@ -61,7 +42,8 @@ QString extractContents( const QString& line ) 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': diff --git a/src/Makefile.in b/src/Makefile.in index 19ce24aba..1eaa66af2 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -32,11 +32,11 @@ VPATH=.:@srcdir@ @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 \ @@ -48,4 +48,8 @@ ifeq (@mpi_ok@,yes) SUBDIRS+= MPIContainer endif +ifeq (@WITHOPENPBS@,yes) + SUBDIRS += Batch Batch_SWIG +endif + @MODULE@ diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx index 4cf8e579a..ad1c34169 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx @@ -26,12 +26,21 @@ // 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 @@ -43,9 +52,9 @@ UNEXPECT_CATCH(MC_NotFound, SALOME_ModuleCatalog::NotFound); 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"); } //---------------------------------------------------------------------- @@ -54,10 +63,10 @@ SALOME_ModuleCatalog_AcomponentImpl::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"); } //---------------------------------------------------------------------- @@ -67,7 +76,7 @@ SALOME_ModuleCatalog_AcomponentImpl::~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; @@ -82,11 +91,11 @@ SALOME_ModuleCatalog_AcomponentImpl::GetInterfaceList() 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(); } @@ -98,8 +107,8 @@ SALOME_ModuleCatalog::DefinitionInterface* 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; @@ -120,7 +129,7 @@ SALOME_ModuleCatalog_AcomponentImpl::GetInterface(const char* interfacename) } } - SCRUTE(_find); + if(MYDEBUG) SCRUTE(_find); if (!_find) { // The interface was not found, the exception should be thrown @@ -129,11 +138,11 @@ SALOME_ModuleCatalog_AcomponentImpl::GetInterface(const char* interfacename) 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; } @@ -149,8 +158,8 @@ SALOME_ModuleCatalog::ListOfServices* 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; @@ -173,8 +182,8 @@ SALOME_ModuleCatalog_AcomponentImpl::GetServiceList(const char* interfacename) 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") } } } @@ -187,11 +196,11 @@ SALOME_ModuleCatalog_AcomponentImpl::GetServiceList(const char* interfacename) 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(); } @@ -205,9 +214,9 @@ SALOME_ModuleCatalog_AcomponentImpl::GetService(const char* interfacename, 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; @@ -219,8 +228,8 @@ SALOME_ModuleCatalog_AcomponentImpl::GetService(const char* interfacename, // 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) @@ -230,8 +239,8 @@ SALOME_ModuleCatalog_AcomponentImpl::GetService(const char* interfacename, 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) { @@ -245,7 +254,7 @@ SALOME_ModuleCatalog_AcomponentImpl::GetService(const char* interfacename, } } - SCRUTE(_find); + if(MYDEBUG) SCRUTE(_find); if (!_find) { // The interface was not found, the exception should be thrown @@ -256,11 +265,11 @@ SALOME_ModuleCatalog_AcomponentImpl::GetService(const char* interfacename, 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; } @@ -272,8 +281,8 @@ SALOME_ModuleCatalog::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; @@ -310,11 +319,11 @@ SALOME_ModuleCatalog_AcomponentImpl::GetDefaultService(const char* interfacename 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; } @@ -326,8 +335,8 @@ char* 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 @@ -349,7 +358,7 @@ SALOME_ModuleCatalog_AcomponentImpl::GetPathPrefix(const char* machinename) } } - SCRUTE(_find); + if(MYDEBUG) SCRUTE(_find); if (!_find) { // The computer was not found, the exception should be thrown @@ -357,11 +366,11 @@ SALOME_ModuleCatalog_AcomponentImpl::GetPathPrefix(const char* machinename) 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; } @@ -499,7 +508,7 @@ void SALOME_ModuleCatalog_AcomponentImpl::duplicate // 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 ++) @@ -517,7 +526,7 @@ void SALOME_ModuleCatalog_AcomponentImpl::duplicate // 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 ++) diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx index b7718b169..4580350ae 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx @@ -29,7 +29,6 @@ #ifndef ACOMPONENT_IMPL_H #define ACOMPONENT_IMPL_H -#include "utilities.h" #include "SALOME_ModuleCatalog_Parser.hxx" #include diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx index da1ce33ce..19275eec5 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx @@ -27,18 +27,26 @@ // $Header$ #define WRITE_CATA_COMPONENT + #include "SALOME_ModuleCatalog_Handler.hxx" #include "SALOME_ModuleCatalog_Parser_IO.hxx" -using namespace std; +#include "utilities.h" + #include +#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 @@ -90,7 +98,7 @@ SALOME_ModuleCatalog_Handler::SALOME_ModuleCatalog_Handler() test_component="component"; - END_OF("SALOME_ModuleCatalog_Handler"); + if(MYDEBUG) END_OF("SALOME_ModuleCatalog_Handler"); } //---------------------------------------------------------------------- @@ -99,8 +107,8 @@ SALOME_ModuleCatalog_Handler::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()") } //---------------------------------------------------------------------- @@ -109,7 +117,7 @@ SALOME_ModuleCatalog_Handler::~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); @@ -304,8 +312,8 @@ bool SALOME_ModuleCatalog_Handler::endElement(const QString&, //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 @@ -324,7 +332,7 @@ bool SALOME_ModuleCatalog_Handler::endElement(const QString&, { 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 @@ -333,7 +341,7 @@ bool SALOME_ModuleCatalog_Handler::endElement(const QString&, } 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 @@ -347,7 +355,7 @@ bool SALOME_ModuleCatalog_Handler::endElement(const QString&, //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; @@ -356,22 +364,23 @@ bool SALOME_ModuleCatalog_Handler::endElement(const QString&, //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)) { @@ -402,8 +411,8 @@ bool SALOME_ModuleCatalog_Handler::endElement(const QString&, //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 @@ -422,7 +431,7 @@ bool SALOME_ModuleCatalog_Handler::endElement(const QString&, { 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 @@ -431,7 +440,7 @@ bool SALOME_ModuleCatalog_Handler::endElement(const QString&, } 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 @@ -445,7 +454,7 @@ bool SALOME_ModuleCatalog_Handler::endElement(const QString&, //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; @@ -525,24 +534,24 @@ bool SALOME_ModuleCatalog_Handler::endDocument() { // 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; } diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx index 3509d1423..775966ae7 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx @@ -29,7 +29,6 @@ #ifndef SALOME_CATALOG_HANDLER_H #define SALOME_CATALOG_HANDLER_H -#include "utilities.h" #include "SALOME_ModuleCatalog_Parser.hxx" #include #include @@ -105,7 +104,7 @@ public: private: QString errorProt ; - string content; + std::string content; QString test_path_prefix_name ; QString test_computer_name ; diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Parser_IO.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Parser_IO.cxx index 4864f32a4..98ac7336f 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Parser_IO.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Parser_IO.cxx @@ -29,8 +29,11 @@ #include "SALOME_ModuleCatalog_Parser_IO.hxx" #include +#include #include "utilities.h" +using namespace std; + std::ostream & operator<< (std::ostream & f, const ParserParameter & P) { f << " name : " << P.name << std::endl; diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx index 7ba1b29f9..7018c1cac 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx @@ -35,6 +35,12 @@ #include using namespace std; +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + static const char* SEPARATOR = ":"; //---------------------------------------------------------------------- @@ -43,7 +49,7 @@ 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] @@ -93,57 +99,56 @@ SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA: // 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"); + } } //---------------------------------------------------------------------- @@ -152,7 +157,7 @@ SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA: //---------------------------------------------------------------------- SALOME_ModuleCatalogImpl::~SALOME_ModuleCatalogImpl() { - MESSAGE("Catalog Destruction"); + if(MYDEBUG) MESSAGE("Catalog Destruction"); } @@ -174,7 +179,7 @@ SALOME_ModuleCatalogImpl::GetComputerList() //---------------------------------------------------------------------- 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 ; @@ -229,51 +234,47 @@ SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) { 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(); } @@ -288,7 +289,7 @@ SALOME_ModuleCatalogImpl::GetComponentList() 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; @@ -296,47 +297,43 @@ SALOME_ModuleCatalogImpl::GetComponentIconeList() _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() ; } @@ -350,7 +347,7 @@ SALOME_ModuleCatalogImpl::GetComponentIconeList() 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; @@ -392,7 +389,7 @@ SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentT { _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++; } } @@ -417,16 +414,16 @@ SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentT } 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") ; } } @@ -474,8 +471,8 @@ SALOME_ModuleCatalogImpl::GetComponent(const char* name) 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; } @@ -509,8 +506,8 @@ SALOME_ModuleCatalogImpl::findComponent(const string & name) 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; } @@ -520,8 +517,8 @@ SALOME_ModuleCatalogImpl::findComponent(const string & name) { 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; } @@ -539,8 +536,8 @@ SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file, 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); @@ -622,7 +619,7 @@ void SALOME_ModuleCatalogImpl::duplicate // 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); @@ -676,7 +673,7 @@ void SALOME_ModuleCatalogImpl::duplicate // 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 ++) @@ -723,7 +720,7 @@ void SALOME_ModuleCatalogImpl::duplicate // = (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(); @@ -732,7 +729,7 @@ void SALOME_ModuleCatalogImpl::duplicate P_corba.Parametertype = it_type->second; break; } - SCRUTE(P_corba.Parametertype); + if(MYDEBUG) SCRUTE(P_corba.Parametertype); // duplicate parameter type @@ -742,7 +739,7 @@ void SALOME_ModuleCatalogImpl::duplicate // = (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(); @@ -752,7 +749,7 @@ void SALOME_ModuleCatalogImpl::duplicate break; } - SCRUTE(P_corba.Parameterdependency); + if(MYDEBUG) SCRUTE(P_corba.Parameterdependency); } //---------------------------------------------------------------------- @@ -795,7 +792,7 @@ SALOME_ModuleCatalogImpl::_verify_path_prefix(ParserPathPrefixes & pathList) { 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; } } diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx index a878c2f49..712091151 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx @@ -123,7 +123,7 @@ private: \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 /*! diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx index 6fe58e93c..07b0e9342 100644 --- a/src/NamingService/SALOME_NamingService.cxx +++ b/src/NamingService/SALOME_NamingService.cxx @@ -26,12 +26,16 @@ // Module : SALOME // $Header$ -using namespace std; #include "SALOME_NamingService.hxx" #include "ServiceUnreachable.hxx" + +#include "utilities.h" + #include #include +using namespace std; + //---------------------------------------------------------------------- /*! Function : SALOME_NamingService * Purpose : Constructor and Initialisation of _root_context diff --git a/src/NamingService/SALOME_NamingService.hxx b/src/NamingService/SALOME_NamingService.hxx index cd4683155..4504e6ec7 100644 --- a/src/NamingService/SALOME_NamingService.hxx +++ b/src/NamingService/SALOME_NamingService.hxx @@ -82,7 +82,7 @@ public: //!method to get all the contexts contained in the current direcotry // Get only objects, isn't iterative - vector list_directory() + std::vector list_directory() throw(ServiceUnreachable); //! method to destroy an association Path-Object Reference diff --git a/src/Notification/NOTIFICATION_Consumer.cxx b/src/Notification/NOTIFICATION_Consumer.cxx index 809d328ec..f7bc0d67d 100644 --- a/src/Notification/NOTIFICATION_Consumer.cxx +++ b/src/Notification/NOTIFICATION_Consumer.cxx @@ -109,13 +109,13 @@ bool NOTIFICATION_Consumer::Receive(char** graph, char** node, char** type, char 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; }; }; diff --git a/src/OBJECT/Makefile.in b/src/OBJECT/Makefile.in index d15092cab..6d1a55859 100644 --- a/src/OBJECT/Makefile.in +++ b/src/OBJECT/Makefile.in @@ -14,8 +14,6 @@ EXPORT_HEADERS = SALOME_InteractiveObject.hxx \ Handle_SALOME_AISShape.hxx \ SALOME_AISObject.hxx \ Handle_SALOME_AISObject.hxx \ - VTKViewer_Common.h - # Libraries targets @@ -23,7 +21,7 @@ LIB = libSalomeObject.la LIB_SRC = SALOME_InteractiveObject.cxx \ SALOME_Actor.cxx \ SALOME_AISShape.cxx\ - SALOME_AISObject.cxx + SALOME_AISObject.cxx\ LIB_CLIENT_IDL = diff --git a/src/OBJECT/SALOME_AISShape.hxx b/src/OBJECT/SALOME_AISShape.hxx index 137e0d9b9..6cc5077df 100644 --- a/src/OBJECT/SALOME_AISShape.hxx +++ b/src/OBJECT/SALOME_AISShape.hxx @@ -48,6 +48,7 @@ #endif class SALOME_InteractiveObject; class TopoDS_Shape; +class TColStd_IndexedMapOfInteger; class SALOME_AISShape : public AIS_Shape { @@ -77,6 +78,7 @@ Standard_EXPORT virtual Handle_SALOME_InteractiveObject getIO() = 0; 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(); diff --git a/src/OBJECT/SALOME_Actor.cxx b/src/OBJECT/SALOME_Actor.cxx index 43a88b901..b2040b2a3 100644 --- a/src/OBJECT/SALOME_Actor.cxx +++ b/src/OBJECT/SALOME_Actor.cxx @@ -41,6 +41,9 @@ #include "utilities.h" // VTK Includes +#include +#include +#include #include #include #include @@ -60,14 +63,20 @@ vtkStandardNewMacro(SALOME_Actor); 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(); @@ -111,73 +120,79 @@ void SALOME_Actor::SetTransform(SALOME_Transform* theTransform){ 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(theMapper)) -#if defined __GNUC_2__ + anId++; // 5 + if(vtkDataSetMapper* aMapper = dynamic_cast(theMapper)){ aMapper->SetInput(myPassFilter[anId]->GetOutput()); -#else - aMapper->SetInput(myPassFilter.at(anId)->GetOutput()); -#endif - else if(vtkPolyDataMapper* aMapper = dynamic_cast(theMapper)) -#if defined __GNUC_2__ + }else if(vtkPolyDataMapper* aMapper = dynamic_cast(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(); } @@ -195,17 +210,16 @@ unsigned long int SALOME_Actor::GetMTime(){ 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); @@ -215,7 +229,7 @@ void SALOME_Actor::SetRepresentation(int theMode) { myGeomFilter->SetInside(true); GetProperty()->SetRepresentation(1); break; - case 0 : + case VTK_POINTS : GetProperty()->SetPointSize(SALOME_POINT_SIZE); default : GetProperty()->SetRepresentation(theMode); @@ -228,6 +242,17 @@ int SALOME_Actor::GetRepresentation(){ 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. @@ -235,41 +260,45 @@ int SALOME_Actor::GetRepresentation(){ //================================================================================= int SALOME_Actor::GetObjDimension( const int theObjId ) { - if ( theObjId < 0 ) - return 0; - - std::vector aVtkList = GetVtkId( theObjId ); - int nbVtk = aVtkList.size(); - - if ( nbVtk == 0 ) - return 0; - else if ( nbVtk > 1 ) - return 3; - else // nbVtk = 1 - { - if ( vtkDataSet* aGrid = GetMapper()->GetInput() ) - { - if ( vtkCell* aCell = aGrid->GetCell( aVtkList.front() ) ) - return aCell->GetCellDimension(); - } - } + 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; +} diff --git a/src/OBJECT/SALOME_Actor.h b/src/OBJECT/SALOME_Actor.h index 08a15bd4e..6b57f9ca8 100644 --- a/src/OBJECT/SALOME_Actor.h +++ b/src/OBJECT/SALOME_Actor.h @@ -29,12 +29,18 @@ #ifndef SALOME_ACTOR_H #define SALOME_ACTOR_H -// SALOME Includes -#include "VTKViewer_Common.h" -#include "SALOME_InteractiveObject.hxx" - #include +#include +#include + +class vtkCell; +class vtkDataSet; +class vtkPolyData; +class vtkCamera; + +#include "SALOME_InteractiveObject.hxx" + class SALOME_Transform; class SALOME_GeometryFilter; class SALOME_TransformFilter; @@ -43,42 +49,39 @@ class SALOME_PassThroughFilter; 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*) {}; @@ -86,14 +89,19 @@ class SALOME_Actor : public vtkLODActor{ virtual void AddToRender(vtkRenderer* theRenderer); virtual void RemoveFromRender(vtkRenderer* theRenderer); - typedef std::vector 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(); @@ -101,19 +109,46 @@ class SALOME_Actor : public vtkLODActor{ 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; @@ -124,6 +159,13 @@ class SALOME_Actor : public vtkLODActor{ int myRepresentation; vtkProperty *myProperty; + + void InitPipeLine(vtkMapper* theMapper); + + SALOME_Actor(); + ~SALOME_Actor(); }; + #endif // SALOME_ACTOR_H + diff --git a/src/OBJECT/SALOME_InteractiveObject.cxx b/src/OBJECT/SALOME_InteractiveObject.cxx index 36a977af6..4f07e3b88 100644 --- a/src/OBJECT/SALOME_InteractiveObject.cxx +++ b/src/OBJECT/SALOME_InteractiveObject.cxx @@ -42,65 +42,54 @@ SALOME_InteractiveObject::SALOME_InteractiveObject() 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; @@ -108,16 +97,15 @@ Standard_Boolean SALOME_InteractiveObject::isComponentType(const Standard_CStrin 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; } diff --git a/src/OBJECT/SALOME_InteractiveObject.hxx b/src/OBJECT/SALOME_InteractiveObject.hxx index 4c22120c3..91d1e5af2 100644 --- a/src/OBJECT/SALOME_InteractiveObject.hxx +++ b/src/OBJECT/SALOME_InteractiveObject.hxx @@ -44,6 +44,7 @@ #include #endif +#include class SALOME_InteractiveObject : public MMgt_TShared { @@ -64,25 +65,31 @@ public: // 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(); @@ -101,10 +108,10 @@ protected: // 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: diff --git a/src/OCCViewer/Makefile.in b/src/OCCViewer/Makefile.in index 5f466d4af..d42b49280 100644 --- a/src/OCCViewer/Makefile.in +++ b/src/OCCViewer/Makefile.in @@ -9,33 +9,32 @@ VPATH=.:@srcdir@:@top_srcdir@/idl 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 \ @@ -44,7 +43,7 @@ LIB_CLIENT_IDL = SALOMEDS.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@ diff --git a/src/OCCViewer/OCCViewer_AISSelector.cxx b/src/OCCViewer/OCCViewer_AISSelector.cxx index 6310f51c6..826b8d285 100644 --- a/src/OCCViewer/OCCViewer_AISSelector.cxx +++ b/src/OCCViewer/OCCViewer_AISSelector.cxx @@ -40,7 +40,9 @@ using namespace std; Constructor */ OCCViewer_AISSelector::OCCViewer_AISSelector( const Handle (AIS_InteractiveContext)& aisContext) : -myAISContext ( aisContext ) + myAISContext ( aisContext ), + myEnableSelection( true ), + myEnableMultipleSelection( true ) { initialize(); } @@ -61,7 +63,7 @@ void OCCViewer_AISSelector::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 ); @@ -105,25 +107,13 @@ void OCCViewer_AISSelector::setContext ( const Handle (AIS_InteractiveContext)& '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 ); } @@ -131,32 +121,31 @@ bool OCCViewer_AISSelector::checkSelection ( AIS_StatusOfPick status, bool hadSe 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 ); } /*! @@ -164,18 +153,19 @@ bool OCCViewer_AISSelector::select () 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 ); } /*! @@ -183,18 +173,21 @@ bool OCCViewer_AISSelector::select ( int left, int top, int right, int bottom, 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 ); } /*! @@ -203,19 +196,50 @@ bool OCCViewer_AISSelector::shiftSelect () 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(); } diff --git a/src/OCCViewer/OCCViewer_AISSelector.h b/src/OCCViewer/OCCViewer_AISSelector.h index e51a7bca5..8a7bd6524 100644 --- a/src/OCCViewer/OCCViewer_AISSelector.h +++ b/src/OCCViewer/OCCViewer_AISSelector.h @@ -30,13 +30,15 @@ #define OCCViewer_AISSELECTOR_H #include "QAD.h" -#include "OCCViewer_Selector.h" + +// QT Include +#include // Open CASCADE Includes #include #include -class QAD_EXPORT OCCViewer_AISSelector : public OCCViewer_Selector +class QAD_EXPORT OCCViewer_AISSelector : public QObject { Q_OBJECT @@ -48,24 +50,35 @@ public: ~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 diff --git a/src/OCCViewer/OCCViewer_ViewFrame.cxx b/src/OCCViewer/OCCViewer_ViewFrame.cxx index 2ddc4325f..b43955be1 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.cxx +++ b/src/OCCViewer/OCCViewer_ViewFrame.cxx @@ -31,6 +31,7 @@ using namespace std; #include "OCCViewer_Viewer3d.h" #include "OCCViewer_ViewPort.h" #include "OCCViewer_ViewPort3d.h" +#include "OCCViewer_Prs.h" #include "QAD.h" #include "QAD_Tools.h" @@ -339,7 +340,8 @@ void OCCViewer_ViewFrame::onViewBack() 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(); } @@ -349,7 +351,8 @@ void OCCViewer_ViewFrame::onViewRight() 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(); } @@ -415,97 +418,85 @@ void OCCViewer_ViewFrame::setPopupServer( QAD_Application* App ) 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; @@ -515,24 +506,19 @@ Handle(SALOME_InteractiveObject) OCCViewer_ViewFrame::FindIObject(const char* En 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 */ @@ -550,24 +536,21 @@ void OCCViewer_ViewFrame::Display(const Handle(SALOME_InteractiveObject)& IObjec 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(); } @@ -585,24 +568,27 @@ void OCCViewer_ViewFrame::DisplayOnly(const Handle(SALOME_InteractiveObject)& IO 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) @@ -615,27 +601,25 @@ void OCCViewer_ViewFrame::Erase(const Handle(SALOME_InteractiveObject)& IObject, 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(); } @@ -662,52 +646,308 @@ void OCCViewer_ViewFrame::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( 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( 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( 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() ); } + diff --git a/src/OCCViewer/OCCViewer_ViewFrame.h b/src/OCCViewer/OCCViewer_ViewFrame.h index 46bdb4af7..4d29bcc44 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.h +++ b/src/OCCViewer/OCCViewer_ViewFrame.h @@ -24,7 +24,7 @@ // File : OCCViewer_ViewFrame.h // Author : Nicolas REJNERI // Module : SALOME -// $Header$ +// $Header$ #ifndef OCCViewer_ViewFrame_H #define OCCViewer_ViewFrame_H @@ -81,10 +81,8 @@ class QAD_EXPORT OCCViewer_ViewFrame : public QAD_ViewFrame 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); @@ -97,6 +95,21 @@ class QAD_EXPORT OCCViewer_ViewFrame : public QAD_ViewFrame 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); @@ -134,6 +147,9 @@ class QAD_EXPORT OCCViewer_ViewFrame : public QAD_ViewFrame void onViewTop(); void onViewTrihedron(); void onAdjustTrihedron(); + +private: + bool getTrihedronSize( double& theNewSize, double& theSize ); protected: OCCViewer_Viewer3d* myViewer; // my owner diff --git a/src/OCCViewer/OCCViewer_ViewPort.cxx b/src/OCCViewer/OCCViewer_ViewPort.cxx index 1d6d410ba..695d42692 100644 --- a/src/OCCViewer/OCCViewer_ViewPort.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort.cxx @@ -26,7 +26,6 @@ // Module : SALOME // $Header$ -using namespace std; #include #if !defined WNT @@ -53,6 +52,10 @@ using namespace std; #include #include +#include "utilities.h" + +using namespace std; + /* XPM */ const char* imageZoomCursor[] = { "32 32 3 1", diff --git a/src/OCCViewer/OCCViewer_Viewer3d.cxx b/src/OCCViewer/OCCViewer_Viewer3d.cxx index 8d4a1331a..cd97a6e90 100644 --- a/src/OCCViewer/OCCViewer_Viewer3d.cxx +++ b/src/OCCViewer/OCCViewer_Viewer3d.cxx @@ -56,6 +56,18 @@ using namespace std; #include #include #include +#include +#include +#include +#include +#include +#include + +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 @@ -169,9 +181,20 @@ Handle(AIS_Trihedron) OCCViewer_Viewer3d::getTrihedron() const 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(); } @@ -187,21 +210,27 @@ void OCCViewer_Viewer3d::rename( const Handle(SALOME_InteractiveObject)& IObject 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. } @@ -216,87 +245,63 @@ void OCCViewer_Viewer3d::SetColor(const Handle(SALOME_InteractiveObject)& IObjec 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(); } @@ -305,38 +310,46 @@ void OCCViewer_Viewer3d::SetTransparency(const Handle(SALOME_InteractiveObject)& */ 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; } @@ -345,7 +358,10 @@ bool OCCViewer_Viewer3d::highlight( const Handle(SALOME_InteractiveObject)& IObj */ bool OCCViewer_Viewer3d::unHighlightAll() { - myAISContext->ClearCurrents(); + if ( myAISContext->HasOpenedContext() ) + myAISContext->ClearSelected(); + else + myAISContext->ClearCurrents(); return false; } @@ -364,24 +380,13 @@ bool OCCViewer_Viewer3d::isInViewer( const Handle(SALOME_InteractiveObject)& IOb } 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; } @@ -389,28 +394,18 @@ bool OCCViewer_Viewer3d::isInViewer( const Handle(SALOME_InteractiveObject)& IOb 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; } @@ -498,13 +493,11 @@ void OCCViewer_Viewer3d::onMousePress( QMouseEvent* pe ) 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() ); + } } /*! @@ -582,138 +575,247 @@ void OCCViewer_Viewer3d::onSelectionDone( bool bAdded ) { 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(); } /*! @@ -723,56 +825,56 @@ void OCCViewer_Viewer3d::onSelectionCancel( bool bAdded ) { 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(); } diff --git a/src/OCCViewer/OCCViewer_Viewer3d.h b/src/OCCViewer/OCCViewer_Viewer3d.h index 9cfed35a2..dab77ab2a 100644 --- a/src/OCCViewer/OCCViewer_Viewer3d.h +++ b/src/OCCViewer/OCCViewer_Viewer3d.h @@ -124,6 +124,11 @@ protected: protected: OCCViewer_ViewFrame* myViewFrame; +private: + + void globalSelectionDone( const bool ); + void localSelectionDone ( const bool ); + Handle (AIS_InteractiveContext) myAISContext; OCCViewer_AISSelector* myAISSelector; bool myEnableSelection; diff --git a/src/PatchQt/Makefile.in b/src/PatchQt/Makefile.in index 81078aa9f..d916a9a7a 100644 --- a/src/PatchQt/Makefile.in +++ b/src/PatchQt/Makefile.in @@ -34,12 +34,13 @@ VPATH=.:@srcdir@:@top_srcdir@/idl 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 @@ -49,6 +50,9 @@ qworkspaceP_moc.cxx: $(inc_builddir)/qworkspaceP.h 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) diff --git a/src/PatchQt/qactionP.cxx b/src/PatchQt/qactionP.cxx index 4779d3762..0d1269dac 100644 --- a/src/PatchQt/qactionP.cxx +++ b/src/PatchQt/qactionP.cxx @@ -1,13 +1,45 @@ -// 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" diff --git a/src/PatchQt/qactionP.h b/src/PatchQt/qactionP.h index ecca035c7..1fcf05053 100644 --- a/src/PatchQt/qactionP.h +++ b/src/PatchQt/qactionP.h @@ -1,13 +1,45 @@ -// 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 diff --git a/src/PatchQt/qsplitterP.cxx b/src/PatchQt/qsplitterP.cxx index 4b8268af9..fd2a7fc5c 100644 --- a/src/PatchQt/qsplitterP.cxx +++ b/src/PatchQt/qsplitterP.cxx @@ -1,30 +1,9 @@ -// 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$ ** @@ -61,6 +40,8 @@ using namespace std; ** not clear to you. ** **********************************************************************/ + +using namespace std; #include "qsplitterP.h" #ifndef QT_NO_COMPLEXWIDGETS diff --git a/src/PatchQt/qsplitterP.h b/src/PatchQt/qsplitterP.h index 70d9a72ec..263a90429 100644 --- a/src/PatchQt/qsplitterP.h +++ b/src/PatchQt/qsplitterP.h @@ -1,28 +1,8 @@ -// 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$ @@ -116,6 +96,10 @@ public: 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 * ); @@ -125,7 +109,7 @@ protected: 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; diff --git a/src/PatchQt/qworkspaceP.cxx b/src/PatchQt/qworkspaceP.cxx index 0d4d618f7..f73e73927 100644 --- a/src/PatchQt/qworkspaceP.cxx +++ b/src/PatchQt/qworkspaceP.cxx @@ -1,13 +1,45 @@ -// 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" diff --git a/src/PatchQt/qworkspaceP.h b/src/PatchQt/qworkspaceP.h index fd7040117..fb1523735 100644 --- a/src/PatchQt/qworkspaceP.h +++ b/src/PatchQt/qworkspaceP.h @@ -1,13 +1,45 @@ -// 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 diff --git a/src/Plot2d/Makefile.in b/src/Plot2d/Makefile.in index 580beb445..375a786b0 100644 --- a/src/Plot2d/Makefile.in +++ b/src/Plot2d/Makefile.in @@ -14,7 +14,8 @@ EXPORT_HEADERS = \ 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 = \ @@ -29,7 +30,8 @@ LIB_SRC = \ Plot2d_ViewFrame.cxx \ Plot2d_SetupViewDlg.cxx \ Plot2d_SetupPlot2dDlg.cxx \ - Plot2d_FitDataDlg.cxx + Plot2d_FitDataDlg.cxx \ + Plot2d_Prs.cxx LIB_MOC = \ Plot2d.h \ @@ -44,7 +46,7 @@ LIB_CLIENT_IDL = SALOMEDS.idl \ 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@ diff --git a/src/Plot2d/Plot2d_CurveContainer.cxx b/src/Plot2d/Plot2d_CurveContainer.cxx index f55104645..b5267b086 100644 --- a/src/Plot2d/Plot2d_CurveContainer.cxx +++ b/src/Plot2d/Plot2d_CurveContainer.cxx @@ -62,7 +62,7 @@ int Plot2d_CurveContainer::count() /*! Returns true if contains no curves */ -bool Plot2d_CurveContainer::isEmpty() +bool Plot2d_CurveContainer::isEmpty() const { return myCurves.isEmpty(); } diff --git a/src/Plot2d/Plot2d_CurveContainer.h b/src/Plot2d/Plot2d_CurveContainer.h index 7cbf58f85..ff5fdfcd8 100644 --- a/src/Plot2d/Plot2d_CurveContainer.h +++ b/src/Plot2d/Plot2d_CurveContainer.h @@ -23,7 +23,7 @@ public: 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: diff --git a/src/Plot2d/Plot2d_SetupPlot2dDlg.cxx b/src/Plot2d/Plot2d_SetupPlot2dDlg.cxx index 89d8a738a..1a14428e4 100644 --- a/src/Plot2d/Plot2d_SetupPlot2dDlg.cxx +++ b/src/Plot2d/Plot2d_SetupPlot2dDlg.cxx @@ -25,6 +25,10 @@ #include #include +#include "utilities.h" + +using namespace std; + #define DLG_SIZE_WIDTH 500 #define DLG_SIZE_HEIGHT 400 #define MAX_LINE_WIDTH 100 @@ -107,10 +111,10 @@ Plot2d_SetupPlot2dDlg::Plot2d_SetupPlot2dDlg( SALOMEDS::SObject_var object, QWid 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 ); @@ -142,10 +146,10 @@ Plot2d_SetupPlot2dDlg::Plot2d_SetupPlot2dDlg( SALOMEDS::SObject_var object, QWid 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 ); @@ -272,13 +276,13 @@ void Plot2d_SetupPlot2dDlg::getCurves( Plot2d_CurveContainer& container ) 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; @@ -324,13 +328,13 @@ void Plot2d_SetupPlot2dDlg::getCurves( Plot2d_CurveContainer& container ) 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; diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index a2a03544d..53a7b3d92 100644 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -9,6 +9,8 @@ #include "Plot2d_ViewFrame.h" #include "Plot2d_SetupViewDlg.h" +#include "Plot2d_Prs.h" + #include "QAD_Desktop.h" #include "QAD_ResourceMgr.h" #include "QAD_FileDlg.h" @@ -806,6 +808,7 @@ void Plot2d_ViewFrame::updateCurve( Plot2d_Curve* curve, bool update ) 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 ) @@ -1713,3 +1716,81 @@ bool Plot2d_Plot2d::existMarker( const QwtSymbol::Style typeMarker, const QColor } 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( 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( 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 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() ); +} diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index 40e41b357..04c87155c 100644 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -78,6 +78,13 @@ public: 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 ); diff --git a/src/RegistryDisplay/RegWidget.cxx b/src/RegistryDisplay/RegWidget.cxx index c7a16048f..d78d5150f 100644 --- a/src/RegistryDisplay/RegWidget.cxx +++ b/src/RegistryDisplay/RegWidget.cxx @@ -134,9 +134,11 @@ RegWidget::RegWidget(CORBA::ORB_var &orb, QWidget *parent, const char *name ) 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() ) ); diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Handler.cxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Handler.cxx index e82e54a23..565170301 100755 --- a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Handler.cxx +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Handler.cxx @@ -26,10 +26,14 @@ // 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 diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Handler.hxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Handler.hxx index eaae9def9..9e1b8e2f8 100755 --- a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Handler.hxx +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Handler.hxx @@ -29,8 +29,8 @@ #ifndef SALOME_RESSOURCES_CATALOG_HANDLER #define SALOME_RESSOURCES_CATALOG_HANDLER -#include "utilities.h" #include "SALOME_RessourcesCatalog_Parser.hxx" + #include #include #include @@ -101,7 +101,7 @@ public : private : QString errorProt; - string content; + std::string content; const char* test_computer; const char* test_computer_name; diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Parser.hxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Parser.hxx index b32e4c312..107f5ee41 100755 --- a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Parser.hxx +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Parser.hxx @@ -34,30 +34,27 @@ struct ParserProc{ long Parsernumber; - string Parsermodel_name; + std::string Parsermodel_name; float Parsercpu_mhz; float Parsercache_size; }; -typedef vector ListOfParserProc; +typedef std::vector ListOfParserProc; enum Parsercontainertype {Cpp, python, NP}; -typedef vector ListOfParserContainerType; +typedef std::vector 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 ListOfParserressources; +typedef std::vector ListOfParserressources; -#ifdef WRITE_RESSOURCES_TYPE -ListOfParserressources _ressources_list; -#else extern ListOfParserressources _ressources_list; -#endif + #endif //SALOME_RESSOURCES_CATALOG_PARSER diff --git a/src/SALOMEDS/Makefile.in b/src/SALOMEDS/Makefile.in index 11336f9ae..a5f6b39e8 100644 --- a/src/SALOMEDS/Makefile.in +++ b/src/SALOMEDS/Makefile.in @@ -115,7 +115,7 @@ BIN_CLIENT_IDL = 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). diff --git a/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx index f21ae9b3b..516443558 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx @@ -42,7 +42,7 @@ void SALOMEDS_AttributeDrawable_i::SetDrawable(CORBA::Boolean value) { } 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) { diff --git a/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx index 98a0720cf..01679d0ca 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx @@ -41,7 +41,7 @@ void SALOMEDS_AttributeExpandable_i::SetExpandable(CORBA::Boolean 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) { diff --git a/src/SALOMEDS/SALOMEDS_AttributeName_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeName_i.cxx index e9ce976d4..3dafade54 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeName_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeName_i.cxx @@ -39,8 +39,9 @@ char* SALOMEDS_AttributeName_i::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() { diff --git a/src/SALOMEDS/SALOMEDS_AttributeOpened_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeOpened_i.cxx index cd4e87f17..1c5808a59 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeOpened_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeOpened_i.cxx @@ -41,7 +41,7 @@ void SALOMEDS_AttributeOpened_i::SetOpened(CORBA::Boolean value) { } 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) { diff --git a/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.cxx b/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.cxx index a02fa874e..dde8e6093 100644 --- a/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.cxx @@ -40,6 +40,7 @@ char* SALOMEDS_AttributePythonObject_i::Store() { } 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); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeReal_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeReal_i.cxx index c87b60486..62b529680 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeReal_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeReal_i.cxx @@ -26,9 +26,35 @@ // Module : SALOME // $Header$ -using namespace std; #include "SALOMEDS_AttributeReal_i.hxx" #include "SALOMEDS_SObject_i.hxx" +#include + +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(); @@ -40,13 +66,16 @@ void SALOMEDS_AttributeReal_i::SetValue(CORBA::Double value) { } 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) ); } + diff --git a/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.cxx index fd9fa7ad2..c18334aea 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.cxx @@ -41,7 +41,7 @@ void SALOMEDS_AttributeSelectable_i::SetSelectable(CORBA::Boolean 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) { diff --git a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.cxx index 703810bc5..28748f753 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.cxx @@ -97,7 +97,7 @@ char* SALOMEDS_AttributeSequenceOfInteger_i::Store() { 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); diff --git a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.cxx index d7f480a16..a88637f6a 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.cxx @@ -96,7 +96,7 @@ char* SALOMEDS_AttributeSequenceOfReal_i::Store() { 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) { diff --git a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx index 9b2b8912c..8444beca9 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx @@ -22,7 +22,7 @@ using namespace std; 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() { @@ -111,7 +111,7 @@ void SALOMEDS_AttributeStudyProperties_i::SetModification(const char* theName, CORBA::Long theYear) { CheckLocked(); Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr); - aProp->SetUserName(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, @@ -185,7 +185,7 @@ char* SALOMEDS_AttributeStudyProperties_i::Store() { } 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"); diff --git a/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx index 6e575f131..e37bd2a9b 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx @@ -204,7 +204,7 @@ void SALOMEDS_AttributeTreeNode_i::Restore(const char* value) { Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); Handle(TDF_Data) DF = TDocStd_Document::Get(_myAttr->Label())->GetData(); - char* aCopy = strdup(value); + char* aCopy = CORBA::string_dup(value); char* adr = strtok(aCopy, " "); TDF_Label aLabel; @@ -236,4 +236,5 @@ void SALOMEDS_AttributeTreeNode_i::Restore(const char* value) { if (!aLabel.FindAttribute(aNode->ID(), aDepNode)) aDepNode = TDataStd_TreeNode::Set(aLabel, aNode->ID()); aNode->SetFirst(aDepNode); } + delete(aCopy); } diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx index 2ea8c97fe..2e4af4382 100644 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx @@ -62,13 +62,13 @@ public: // defines for creation attributes objects -//cout<<"*** Create new CORBA attribute for "<<#CORBA_Name<ID() == OCAF_Name::GetID()) { \ SALOMEDS_##CORBA_Name##_i* Attr = new SALOMEDS_##CORBA_Name##_i(Handle(OCAF_Name)::DownCast(theAttr), theOrb); \ return Attr->CORBA_Name::_this(); \ } -//cout<<"Create New Attribute "<<#CORBA_Name<CORBA_Name::_this(); \ } -//cout<<"Create New Attribute "<<#CORBA_Name<Get()); - IOR = strdup(ch.ToCString()); + IOR = CORBA::string_dup(ch.ToCString()); return true; } diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.cxx b/src/SALOMEDS/SALOMEDS_SObject_i.cxx index 25cb25ac7..429716886 100644 --- a/src/SALOMEDS/SALOMEDS_SObject_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.cxx @@ -233,6 +233,16 @@ CORBA::Short SALOMEDS_SObject_i::Tag() return _lab.Tag(); } +//============================================================================ +/*! Function : + * Purpose : + */ +//============================================================================ +CORBA::Short SALOMEDS_SObject_i::Depth() +{ + return _lab.Depth(); +} + //============================================================================ /*! Function : * Purpose : diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.hxx b/src/SALOMEDS/SALOMEDS_SObject_i.hxx index fa0fa58dc..67ab9d9ba 100644 --- a/src/SALOMEDS/SALOMEDS_SObject_i.hxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.hxx @@ -87,6 +87,7 @@ public: virtual char* GetIOR(); virtual CORBA::Short Tag(); + virtual CORBA::Short Depth(); static char* AttributeIDToType(Standard_GUID); diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx index 64eba6c88..47bfde5ae 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx @@ -457,16 +457,10 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, 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); @@ -485,8 +479,8 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, 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; } @@ -496,12 +490,12 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, 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 { @@ -689,13 +683,15 @@ void SALOMEDS_StudyBuilder_i::RemoveReference(SALOMEDS::SObject_ptr me) 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); } @@ -849,7 +845,7 @@ void SALOMEDS_StudyBuilder_i::CommitCommand() throw (SALOMEDS::StudyBuilder::Loc //============================================================================ CORBA::Boolean SALOMEDS_StudyBuilder_i::HasOpenCommand() { - _doc->HasOpenCommand(); + return _doc->HasOpenCommand(); } //============================================================================ diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index 222a6fe27..0f4a38c99 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -278,7 +278,7 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* study_name) // 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(); @@ -315,7 +315,7 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* aUrl) sprintf(aHDFUrl, "%shdf_from_ascii.hdf", aResultPath); delete(aResultPath); } else { - aHDFUrl = strdup(aUrl); + aHDFUrl = CORBA::string_dup(aUrl); } hdf_file = new HDFfile(aHDFUrl); @@ -354,7 +354,7 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* aUrl) 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; @@ -391,8 +391,8 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* aUrl) 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 @@ -583,20 +583,20 @@ static void SaveAttributes(SALOMEDS::SObject_ptr SO, HDFgroup *hdf_group_sobject 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 "<Type()<<" : "<Type()<<" : "<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(); @@ -668,7 +668,8 @@ void SALOMEDS_StudyManager_i::_SaveProperties(SALOMEDS::Study_ptr aStudy, HDFgro 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); } @@ -717,28 +718,26 @@ void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl, 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); @@ -842,8 +841,8 @@ void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl, 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]; @@ -1006,7 +1005,7 @@ void SALOMEDS_StudyManager_i::_SaveObject(SALOMEDS::Study_ptr aStudy, } } - 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); @@ -1031,7 +1030,7 @@ const char *SALOMEDS_StudyManager_i::_SubstituteSlash(const char *aUrl) Standard_ExtCharacter val2 = ToExtCharacter(':'); theUrl.ChangeAll(val1,val2); TCollection_AsciiString ch(theUrl); - return strdup(ch.ToCString()); + return CORBA::string_dup(ch.ToCString()); } //============================================================================ @@ -1122,7 +1121,7 @@ void SALOMEDS_StudyManager_i::CopyLabel(const SALOMEDS::Study_ptr theSourceStudy 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)))); @@ -1176,14 +1175,15 @@ CORBA::Boolean SALOMEDS_StudyManager_i::Copy(SALOMEDS::SObject_ptr theObject) { // 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 @@ -1230,7 +1230,7 @@ CORBA::Boolean SALOMEDS_StudyManager_i::CanPaste(SALOMEDS::SObject_ptr theObject 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 @@ -1265,7 +1265,7 @@ TDF_Label SALOMEDS_StudyManager_i::PasteLabel(const SALOMEDS::Study_ptr theDesti 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(); @@ -1281,7 +1281,7 @@ TDF_Label SALOMEDS_StudyManager_i::PasteLabel(const SALOMEDS::Study_ptr theDesti 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(), @@ -1325,7 +1325,7 @@ TDF_Label SALOMEDS_StudyManager_i::PasteLabel(const SALOMEDS::Study_ptr theDesti if (aNameStart) TDataStd_Name::Set(aTargetLabel, aNameStart); else TDataStd_Name::Set(aTargetLabel, TCollection_ExtendedString("Reference to:")+anEntry); } - delete(anEntry); + delete [] anEntry; } return aTargetLabel; diff --git a/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.cxx b/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.cxx index 737f1f752..d3a3ab2e5 100644 --- a/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.cxx @@ -18,7 +18,7 @@ using namespace std; 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; } @@ -332,8 +332,9 @@ void SALOMEDS_TableOfStringAttribute::ConvertToString(ostrstream& theStream) 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; + theStream.read(aValueString, 1); // an '\n' omitting theStream.read(aValueString, aValueSize); + theStream.read(aValueString, 1); // an '\n' omitting aValue = aValueString; } myTable.Bind(aKey, aValue); diff --git a/src/SALOMEDS/SALOMEDS_TargetAttribute.cxx b/src/SALOMEDS/SALOMEDS_TargetAttribute.cxx index 004fd6973..9e623b8b1 100644 --- a/src/SALOMEDS/SALOMEDS_TargetAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_TargetAttribute.cxx @@ -77,6 +77,8 @@ void SALOMEDS_TargetAttribute::Append(TDF_Label& theReferencedObject) { 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"); diff --git a/src/SALOMEDS/SALOMEDS_Tool.cxx b/src/SALOMEDS/SALOMEDS_Tool.cxx deleted file mode 100644 index 341ba99a5..000000000 --- a/src/SALOMEDS/SALOMEDS_Tool.cxx +++ /dev/null @@ -1,306 +0,0 @@ -// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server -// -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : SALOMEDS_Tool.cxx -// Author : Sergey RUIN -// Module : SALOME - -using namespace std; -#include "SALOMEDS_Tool.hxx" - -#include "utilities.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -//============================================================================ -// function : GetTempDir -// purpose : Return a temp directory to store created files like "/tmp/sub_dir/" -//============================================================================ -char* SALOMEDS_Tool::GetTmpDir() -{ - //Find a temporary directory to store a file - - TCollection_AsciiString aTmpDir; - - char *Tmp_dir = getenv("SALOME_TMP_DIR"); - if(Tmp_dir != NULL) { - aTmpDir = TCollection_AsciiString(Tmp_dir); -#ifdef WIN32 - if(aTmpDir.Value(aTmpDir.Length()) != '\\') aTmpDir+='\\'; -#else - if(aTmpDir.Value(aTmpDir.Length()) != '/') aTmpDir+='/'; -#endif - } - else { -#ifdef WIN32 - aTmpDir = TCollection_AsciiString("C:\\"); -#else - aTmpDir = TCollection_AsciiString("/tmp/"); -#endif - } - - srand((unsigned int)time(NULL)); - int aRND = 999 + (int)(100000.0*rand()/(RAND_MAX+1.0)); //Get a random number to present a name of a sub directory - TCollection_AsciiString aSubDir(aRND); - if(aSubDir.Length() <= 1) aSubDir = TCollection_AsciiString("123409876"); - - MESSAGE("#### RND " << aRND); - - aTmpDir += aSubDir; //Get RND sub directory - -#ifdef WIN32 - if(aTmpDir.Value(aTmpDir.Length()) != '\\') aTmpDir+='\\'; -#else - if(aTmpDir.Value(aTmpDir.Length()) != '/') aTmpDir+='/'; -#endif - - OSD_Path aPath(aTmpDir); - OSD_Directory aDir(aPath); - - for(aRND = 0; aDir.Exists(); aRND++) { - aTmpDir.Insert((aTmpDir.Length() - 1), TCollection_AsciiString(aRND)); //Build a unique directory name - aPath = OSD_Path(aTmpDir); - aDir = OSD_Directory(aPath); - } - - MESSAGE("#### TMP" << aTmpDir.ToCString()); - - OSD_Protection aProtection(OSD_RW, OSD_RWX, OSD_RX, OSD_RX); - aDir.Build(aProtection); - - return CORBA::string_dup(aTmpDir.ToCString()); -} - -//============================================================================ -// function : RemoveTemporaryFiles -// purpose : Removes files listed in theFileList -//============================================================================ -void SALOMEDS_Tool::RemoveTemporaryFiles(const char* theDirectory, - const SALOMEDS::ListOfFileNames& theFiles, - const bool IsDirDeleted) -{ - TCollection_AsciiString aDirName(const_cast(theDirectory)); - - int i, aLength = theFiles.length(); - for(i=0; i(theFromDirectory)); //Get a temporary directory for saved a file - - long aBufferSize = 0; - long aCurrentPos; - - int aNbFiles = 0; - int* aFileNameSize= new int[aLength]; - long* aFileSize= new long[aLength]; - - //Determine the required size of the buffer - - for(i=0; i 4) ? 4 : sizeof(int))); - - - aCurrentPos = 4; - - for(i=0; i 4) ? 4 : sizeof(int))); - aCurrentPos += 4; - - //Copy the file name to the buffer - memcpy((aBuffer + aCurrentPos), theFiles[i], aFileNameSize[i]); - aCurrentPos += aFileNameSize[i]; - - if (!theNamesOnly) { // mpv 15.01.2003: we don't copy file content to the buffer if !theNamesOnly - //Initialize 8 bytes of the buffer by 0 - memset((aBuffer + aCurrentPos), 0, 8); - //Copy the length of the file to the buffer - memcpy((aBuffer + aCurrentPos), (aFileSize + i), ((sizeof(long) > 8) ? 8 : sizeof(long))); - aCurrentPos += 8; - - aFile->seekg(0, ios::beg); - aFile->read((char *)(aBuffer + aCurrentPos), aFileSize[i]); - aFile->close(); - delete(aFile); - aCurrentPos += aFileSize[i]; - } - } - - delete[] aFileNameSize; - delete[] aFileSize; - - - CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer; - - return (new SALOMEDS::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1)); -} - -//============================================================================ -// function : PutStreamToFile -// purpose : converts the stream "theStream" to the files -//============================================================================ -SALOMEDS::ListOfFileNames* -SALOMEDS_Tool::PutStreamToFiles(const SALOMEDS::TMPFile& theStream, - const char* theToDirectory, - const int theNamesOnly) -{ - if(theStream.length() == 0) return NULL; - TCollection_AsciiString aTmpDir(const_cast(theToDirectory)); //Get a temporary directory for saving a file - - unsigned char *aBuffer = (unsigned char*)theStream.NP_data(); - - if(aBuffer == NULL) return NULL; - - long aBufferSize = theStream.length(); - long aFileSize, aCurrentPos = 4; - int i, aFileNameSize, aNbFiles = 0; - - //Copy the number of files in the stream - memcpy(&aNbFiles, aBuffer, sizeof(int)); - - SALOMEDS::ListOfFileNames_var aFiles = new SALOMEDS::ListOfFileNames; - aFiles->length(aNbFiles); - - for(i=0; i 4) ? 4 : sizeof(int))); - aCurrentPos += 4; - - char *aFileName = new char[aFileNameSize]; - //Put a file name to aFileName - memcpy(aFileName, (aBuffer + aCurrentPos), aFileNameSize); - aCurrentPos += aFileNameSize; - - //Put a length of the file to aFileSize - if (!theNamesOnly) { - memcpy(&aFileSize, (aBuffer + aCurrentPos), ((sizeof(long) > 8) ? 8 : sizeof(long))); - aCurrentPos += 8; - - TCollection_AsciiString aFullPath = aTmpDir + aFileName; - ofstream aFile(aFullPath.ToCString()); - aFile.write((char *)(aBuffer+aCurrentPos), aFileSize); - aFile.close(); - aCurrentPos += aFileSize; - } - aFiles[i] = CORBA::string_dup(aFileName); - delete[] aFileName; - } - - return aFiles._retn(); -} - -//============================================================================ -// 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))); - TCollection_AsciiString aNameString(aPath.Name()); - return CORBA::string_dup(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))); - TCollection_AsciiString aDirString(aPath.Trek()); - aDirString.ChangeAll('|','/'); - return CORBA::string_dup(aDirString.ToCString()); -} diff --git a/src/SALOMEDS/SALOMEDS_Tool.hxx b/src/SALOMEDS/SALOMEDS_Tool.hxx deleted file mode 100644 index 85557372d..000000000 --- a/src/SALOMEDS/SALOMEDS_Tool.hxx +++ /dev/null @@ -1,53 +0,0 @@ -// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server -// -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : SALOMEDS_Tool.hxx -// Author : Sergey RUIN -// Module : SALOME - -#ifndef __SALOMEDS_Tool_H__ -#define __SALOMEDS_Tool_H__ - - - -// IDL headers -#include - -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(); - - - // Removes files which are in , the files for deletion are listed in - // if is true is also deleted if it is empty - static void RemoveTemporaryFiles(const char* theDirectory, - const SALOMEDS::ListOfFileNames& theFiles, - const bool IsDirDeleted); - - // Converts files listed in which are in into a byte sequence TMPFile - static SALOMEDS::TMPFile* PutFilesToStream(const char* theFromDirectory, - const SALOMEDS::ListOfFileNames& theFiles, - const int theNamesOnly = 0); - - // Converts a byte sequence to files and places them in - static SALOMEDS::ListOfFileNames* 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); - - // 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); - -}; -#endif diff --git a/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx b/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx index 698fbb1c6..ba6d6397e 100644 --- a/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx +++ b/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx @@ -272,7 +272,7 @@ CORBA::Boolean SALOMEDS_UseCaseBuilder_i::SetName(const char* theName) { 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); @@ -315,7 +315,7 @@ char* SALOMEDS_UseCaseBuilder_i::GetName() { 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(); } @@ -368,7 +368,7 @@ SALOMEDS::SObject_ptr SALOMEDS_UseCaseBuilder_i::AddUseCase(const char* theName) 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()); diff --git a/src/SALOMEGUI/CLIENT_msg_en.po b/src/SALOMEGUI/CLIENT_msg_en.po index f0e5f90f9..73e232ffc 100644 --- a/src/SALOMEGUI/CLIENT_msg_en.po +++ b/src/SALOMEGUI/CLIENT_msg_en.po @@ -20,17 +20,17 @@ msgstr "" #--------------- msgid "INF_VERSION" -msgstr "Version 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" @@ -38,8 +38,8 @@ msgstr "salome" #: 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" diff --git a/src/SALOMEGUI/Makefile.in b/src/SALOMEGUI/Makefile.in index 3f7bc1c78..f3d426d18 100644 --- a/src/SALOMEGUI/Makefile.in +++ b/src/SALOMEGUI/Makefile.in @@ -91,6 +91,7 @@ EXPORT_HEADERS = \ SALOME_NumberFilter.hxx \ Handle_SALOME_NumberFilter.hxx \ SALOME_DataMapOfIOMapOfInteger.hxx \ + SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx \ Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx \ SALOMEGUI.h \ SALOMEGUI_LoadStudiesDlg.h \ @@ -220,7 +221,7 @@ LIB_CLIENT_IDL = SALOMEDS.idl \ SALOME_Exception.idl CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) -LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lqsplitterP -lSalomeLifeCycleCORBA -lOpUtil -lSalomeObject -lEvent +LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lqsplitterP -lSalomeLifeCycleCORBA -lOpUtil -lSalomeObject -lEvent -lSalomePrs LIBS+= $(PYTHON_LIBS) diff --git a/src/SALOMEGUI/PyInterp_PyQt.cxx b/src/SALOMEGUI/PyInterp_PyQt.cxx index dd136e506..440c302f3 100644 --- a/src/SALOMEGUI/PyInterp_PyQt.cxx +++ b/src/SALOMEGUI/PyInterp_PyQt.cxx @@ -22,7 +22,6 @@ using namespace std; */ PyInterp_PyQt::PyInterp_PyQt(): PyInterp_base() { - initialize(); } PyInterp_PyQt::~PyInterp_PyQt() diff --git a/src/SALOMEGUI/PyInterp_base.cxx b/src/SALOMEGUI/PyInterp_base.cxx index e16f1e041..08990e6e5 100644 --- a/src/SALOMEGUI/PyInterp_base.cxx +++ b/src/SALOMEGUI/PyInterp_base.cxx @@ -9,6 +9,7 @@ // Module : SALOME // $Header$ + #include #include diff --git a/src/SALOMEGUI/QAD_Desktop.cxx b/src/SALOMEGUI/QAD_Desktop.cxx index 3f2222027..ac1763f4d 100644 --- a/src/SALOMEGUI/QAD_Desktop.cxx +++ b/src/SALOMEGUI/QAD_Desktop.cxx @@ -72,6 +72,7 @@ #include "SALOMEGUI_CloseDlg.h" #include "SALOMEGUI_ActivateComponentDlg.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" #include "SALOME_Event.hxx" @@ -201,7 +202,8 @@ myActiveStudy(0), myCntUntitled(0), //NRImyHelpWindow(0), myDefaultTitle( tr("DESK_DEFAULTTITLE") ), -myQueryClose( true ) +myQueryClose( true ), +myAboutToClose( false ) { /* Force reading of user config file */ QAD_CONFIG->readConfigFile(); @@ -287,9 +289,9 @@ myQueryClose( true ) 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 ) @@ -388,7 +390,9 @@ const int IdSelectAll = 1004; */ 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; } @@ -396,9 +400,9 @@ bool QAD_Desktop::eventFilter( QObject* o, QEvent* e ) 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") ) { @@ -453,11 +457,8 @@ bool QAD_Desktop::eventFilter( QObject* o, QEvent* e ) } else if ( e->type() == SALOME_EVENT ) { SALOME_Event* aSE = (SALOME_Event*)((QCustomEvent*)e)->data(); - processEvent( aSE ); - // Signal the calling thread that the event has been processed - aSE->processed(); + processEvent(aSE); ((QCustomEvent*)e)->setData( 0 ); - delete aSE; return TRUE; } return QMainWindow::eventFilter( o, e ); @@ -468,9 +469,11 @@ bool QAD_Desktop::eventFilter( QObject* o, QEvent* 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(); + } } /*! @@ -990,13 +993,13 @@ void QAD_Desktop::createActions() 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() ))); @@ -1412,36 +1415,44 @@ void QAD_Desktop::closeEvent ( QCloseEvent* e ) QAD_NO, QAD_NO ) == QAD_YES; } - if ( doClose ) { - for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) { - QList& 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& 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(); } /*! @@ -1716,12 +1727,7 @@ void QAD_Desktop::onOpenStudy() 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; } } @@ -1738,6 +1744,13 @@ void QAD_Desktop::onOpenStudy() 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) { @@ -1758,33 +1771,36 @@ bool QAD_Desktop::loadComponentData( const QString& compName ) 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; @@ -2551,7 +2567,9 @@ void QAD_Desktop::onOpenWith() 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 = @@ -2562,7 +2580,7 @@ void QAD_Desktop::onOpenWith() } else if ( list_type_composants->length() > 1 ) { SALOMEGUI_OpenWith* aDlg = new SALOMEGUI_OpenWith( this ); for (unsigned int ind = 0; ind < list_type_composants->length();ind++) { - QString compusername = getComponentUserName( strdup(list_type_composants[ind]) ); + QString compusername = getComponentUserName( (char*)list_type_composants[ind] ); if ( !compusername.isEmpty() ) aDlg->addComponent( compusername ); } @@ -2622,6 +2640,11 @@ void QAD_Desktop::setSettings() */ 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 @@ -2694,16 +2717,6 @@ bool QAD_Desktop::loadComponent(QString Component) 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()); @@ -3012,6 +3025,23 @@ void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoad //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() ); @@ -3024,13 +3054,6 @@ void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoad } 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() ); @@ -3044,10 +3067,13 @@ void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoad } - // 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(); @@ -3132,7 +3158,8 @@ void QAD_Desktop::onButtonActiveComponent( ) */ void QAD_Desktop::clearMenus() { - onActiveStudyChanged(); + // san - commented as presumably obsolete + // onActiveStudyChanged(); /* menus */ myMenusList.clear(); @@ -3223,6 +3250,8 @@ typedef SALOMEGUI* (*ComponentGUI)(); 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() ) { @@ -3328,6 +3357,22 @@ SALOMEGUI* QAD_Desktop::getComponentGUI( const QString& component ) } +/*! + 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 ) @@ -3417,6 +3462,34 @@ void QAD_Desktop::createPopup(QPopupMenu* popup, const QString & theContext, 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); diff --git a/src/SALOMEGUI/QAD_Desktop.h b/src/SALOMEGUI/QAD_Desktop.h index 96d3b9089..83bc083c9 100644 --- a/src/SALOMEGUI/QAD_Desktop.h +++ b/src/SALOMEGUI/QAD_Desktop.h @@ -151,6 +151,7 @@ public: 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(); @@ -165,6 +166,7 @@ public: 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, @@ -194,8 +196,6 @@ protected: virtual void updateCaption( UpdateCommand ); virtual void updateMenu( UpdateCommand ); - bool loadComponentData( const QString& ); - protected slots: virtual void onNewStudy(); virtual void onNewStudy(QAD_Application* app); @@ -342,6 +342,7 @@ private: SALOME_LifeCycleCORBA * myEnginesLifeCycle; QComboBox * myCombo; bool myQueryClose; + bool myAboutToClose; bool _islibso; ComponentMap myComponents; diff --git a/src/SALOMEGUI/QAD_FileDlg.cxx b/src/SALOMEGUI/QAD_FileDlg.cxx index 76860b89d..d3e1bb230 100644 --- a/src/SALOMEGUI/QAD_FileDlg.cxx +++ b/src/SALOMEGUI/QAD_FileDlg.cxx @@ -31,15 +31,15 @@ QString QAD_FileDlg::myLastVisitedPath; 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); @@ -176,7 +176,7 @@ void QAD_FileDlg::accept() { // 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 @@ -187,7 +187,7 @@ void QAD_FileDlg::accept() */ if ( acceptData() ) { myLastVisitedPath = dirPath(); - QFileDialog::accept(); + QFileDialogP::accept(); } } @@ -197,7 +197,7 @@ Closes this dialog and sets the return code to 'Rejected' void QAD_FileDlg::reject() { mySelectedFile = QString::null; - QFileDialog::reject(); + QFileDialogP::reject(); } /*! @@ -342,7 +342,9 @@ QString QAD_FileDlg::getFileName( QWidget* parent, 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(); @@ -396,11 +398,11 @@ QString QAD_FileDlg::getExistingDirectory ( QWidget* parent, } fd->setMode( DirectoryOnly ); fd->setFilters(tr("DIRECTORIES_FILTER")); + fd->exec(); QString dirname = fd->selectedFile(); delete fd; qApp->processEvents(); return dirname; - } diff --git a/src/SALOMEGUI/QAD_FileDlg.h b/src/SALOMEGUI/QAD_FileDlg.h index e6964280f..a604596a5 100644 --- a/src/SALOMEGUI/QAD_FileDlg.h +++ b/src/SALOMEGUI/QAD_FileDlg.h @@ -12,18 +12,19 @@ #ifndef QAD_FILEDIALOG_H #define QAD_FILEDIALOG_H -#include #include + +#include #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; @@ -48,8 +49,11 @@ public: const QString& initial, const QString& caption, bool showQuickDir = true); + +protected: + virtual bool acceptData(); + private: - bool acceptData(); void addExtension(); bool processPath( const QString& path ); @@ -64,7 +68,6 @@ protected: QAD_FileValidator* myValidator; /* file validator */ static QString myLastVisitedPath; /* last visited path */ QComboBox* myQuickCombo; /* quick dir combo box */ - }; #endif diff --git a/src/SALOMEGUI/QAD_FileValidator.cxx b/src/SALOMEGUI/QAD_FileValidator.cxx index f12915a41..0a4c77426 100644 --- a/src/SALOMEGUI/QAD_FileValidator.cxx +++ b/src/SALOMEGUI/QAD_FileValidator.cxx @@ -9,15 +9,18 @@ // 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 #include +using namespace std; + /* constructor */ QAD_FileValidator::QAD_FileValidator(QWidget* parent) : myParent(parent) diff --git a/src/SALOMEGUI/QAD_ListView.cxx b/src/SALOMEGUI/QAD_ListView.cxx index d555fd378..b48d62418 100644 --- a/src/SALOMEGUI/QAD_ListView.cxx +++ b/src/SALOMEGUI/QAD_ListView.cxx @@ -9,7 +9,6 @@ // Module : SALOME // $Header$ -using namespace std; #include "QAD_ListView.h" #include @@ -19,13 +18,13 @@ using namespace std; #include "QAD_Desktop.h" -//#include -//#include - - #include #include +#include "utilities.h" + +using namespace std; + ////////////////////////////////////////////////////////////////////// // QAD_ListView class implementation ////////////////////////////////////////////////////////////////////// diff --git a/src/SALOMEGUI/QAD_ObjectBrowser.cxx b/src/SALOMEGUI/QAD_ObjectBrowser.cxx index 4516e9934..91cc38a59 100644 --- a/src/SALOMEGUI/QAD_ObjectBrowser.cxx +++ b/src/SALOMEGUI/QAD_ObjectBrowser.cxx @@ -55,6 +55,8 @@ #include #include #include +#include + using namespace std; //VRV: porting on Qt 3.0.5 @@ -456,6 +458,35 @@ bool QAD_ObjectBrowser::eventFilter( QObject* o, QEvent* e ) } +/*! + 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 */ @@ -486,6 +517,18 @@ void QAD_ObjectBrowser::onCreatePopup() 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 @@ -534,6 +577,16 @@ void QAD_ObjectBrowser::onCreatePopup() } } +/*! + 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 */ @@ -627,7 +680,7 @@ void QAD_ObjectBrowser::Update( SALOMEDS::SObject_ptr SO, 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; @@ -647,17 +700,17 @@ void QAD_ObjectBrowser::Update( SALOMEDS::SObject_ptr SO, 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, @@ -674,12 +727,12 @@ void QAD_ObjectBrowser::Update( SALOMEDS::SObject_ptr SO, // 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 { @@ -773,9 +826,9 @@ void QAD_ObjectBrowser::Update() 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; @@ -792,7 +845,7 @@ void QAD_ObjectBrowser::Update() if (SC->FindAttribute(anAttr, "AttributeIOR")) { anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - ior = strdup( anIOR->Value() ); + ior = CORBA::string_dup( anIOR->Value() ); } bool caseIAPP = false; @@ -803,7 +856,7 @@ void QAD_ObjectBrowser::Update() 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 { @@ -817,7 +870,7 @@ void QAD_ObjectBrowser::Update() 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 { @@ -932,7 +985,7 @@ void QAD_ObjectBrowser::UpdateUseCaseBrowser() { 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 @@ -950,7 +1003,7 @@ void QAD_ObjectBrowser::UpdateUseCaseBrowser() { 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; } } @@ -998,7 +1051,7 @@ void QAD_ObjectBrowser::UpdateUCItem( SALOMEDS::SObject_var UCObject, QAD_Object 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(); @@ -1010,17 +1063,17 @@ void QAD_ObjectBrowser::UpdateUCItem( SALOMEDS::SObject_var UCObject, QAD_Object // 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, @@ -1029,7 +1082,7 @@ void QAD_ObjectBrowser::UpdateUCItem( SALOMEDS::SObject_var UCObject, QAD_Object 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 ); @@ -1044,17 +1097,17 @@ void QAD_ObjectBrowser::UpdateUCItem( SALOMEDS::SObject_var UCObject, QAD_Object // 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( "" ); @@ -1119,7 +1172,7 @@ void QAD_ObjectBrowser::UpdateUCItem( SALOMEDS::SObject_var UCObject, QAD_Object 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; } } @@ -1298,6 +1351,18 @@ void QAD_ObjectBrowser::showPopupMenu(QListViewItem* theItem) 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 ) { @@ -1348,6 +1413,12 @@ void QAD_ObjectBrowser::onSelectedItem() SALOME_ListIO DeltaNeg; DeltaNeg.Clear(); + typedef QMap 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(); @@ -1357,49 +1428,35 @@ void QAD_ObjectBrowser::onSelectedItem() 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] ); } } @@ -1412,6 +1469,11 @@ void QAD_ObjectBrowser::onSelectedItem() 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(); } @@ -1496,7 +1558,7 @@ QString QAD_ObjectBrowser::getValueFromObject( SALOMEDS::SObject_ptr SO ) // 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() ; @@ -1507,7 +1569,7 @@ QString QAD_ObjectBrowser::getValueFromObject( SALOMEDS::SObject_ptr SO ) // 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() ; @@ -1518,7 +1580,7 @@ QString QAD_ObjectBrowser::getValueFromObject( SALOMEDS::SObject_ptr SO ) // 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; @@ -1744,8 +1806,20 @@ void QAD_ObjectBrowser::onUseCasePopupMenu( int action ) { 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(); @@ -1779,14 +1853,14 @@ void QAD_ObjectBrowser::onUseCasePopupMenu( int action ) 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 ); } @@ -1845,9 +1919,20 @@ void QAD_ObjectBrowser::onUseCasePopupMenu( int action ) */ 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(); diff --git a/src/SALOMEGUI/QAD_ObjectBrowser.h b/src/SALOMEGUI/QAD_ObjectBrowser.h index ef5f94099..fec96c965 100644 --- a/src/SALOMEGUI/QAD_ObjectBrowser.h +++ b/src/SALOMEGUI/QAD_ObjectBrowser.h @@ -124,6 +124,7 @@ protected slots: void showPopupMenu(QListViewItem*); void showUseCasePopupMenu(QListViewItem*); + void onExpandAll(); void onExpanded (QListViewItem*); void onCollapsed(QListViewItem*); void onUseCasePopupMenu( int ); diff --git a/src/SALOMEGUI/QAD_PyEditor.cxx b/src/SALOMEGUI/QAD_PyEditor.cxx index 72e22033e..f5258e1a0 100644 --- a/src/SALOMEGUI/QAD_PyEditor.cxx +++ b/src/SALOMEGUI/QAD_PyEditor.cxx @@ -46,6 +46,7 @@ #include CORBA_SERVER_HEADER(SALOMEDS_Attributes) //NRI +#include "utilities.h" using namespace std; @@ -409,7 +410,6 @@ void QAD_PyEditor::keyPressEvent( QKeyEvent *e ) _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) diff --git a/src/SALOMEGUI/QAD_PyInterp_mono.cxx b/src/SALOMEGUI/QAD_PyInterp_mono.cxx index fad3df375..611b0e49b 100644 --- a/src/SALOMEGUI/QAD_PyInterp_mono.cxx +++ b/src/SALOMEGUI/QAD_PyInterp_mono.cxx @@ -10,6 +10,8 @@ // $Header$ + + #include "QAD_PyInterp_mono.h" #include "utilities.h" diff --git a/src/SALOMEGUI/QAD_RightFrame.cxx b/src/SALOMEGUI/QAD_RightFrame.cxx index 7656e6de4..8559ce5fb 100644 --- a/src/SALOMEGUI/QAD_RightFrame.cxx +++ b/src/SALOMEGUI/QAD_RightFrame.cxx @@ -164,7 +164,10 @@ QAD_RightFrame::QAD_RightFrame(QWidget *theParent, 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) { @@ -284,3 +287,46 @@ void QAD_RightFrame::unCompressBottom() 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() ); +} + diff --git a/src/SALOMEGUI/QAD_RightFrame.h b/src/SALOMEGUI/QAD_RightFrame.h index b92b6eb66..8b4a10b9e 100644 --- a/src/SALOMEGUI/QAD_RightFrame.h +++ b/src/SALOMEGUI/QAD_RightFrame.h @@ -55,7 +55,16 @@ class QAD_EXPORT QAD_RightFrame : public QAD_Splitter 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; diff --git a/src/SALOMEGUI/QAD_Study.cxx b/src/SALOMEGUI/QAD_Study.cxx index f43c8714f..1ad0b2112 100644 --- a/src/SALOMEGUI/QAD_Study.cxx +++ b/src/SALOMEGUI/QAD_Study.cxx @@ -389,6 +389,14 @@ void QAD_Study::setReadOnly(bool state) myIsReadOnly = state; } +bool QAD_Study::isLocked() +{ + bool state = false; + if ( !CORBA::is_nil( myStudy ) ) + state = myStudy->GetProperties()->IsLocked(); + return state; +} + //=======================================================================// // Study operations // //=======================================================================// @@ -648,7 +656,7 @@ QAD_StudyFrame* QAD_Study::createStudyFrame( const QString& title, ViewType theV 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); @@ -820,7 +828,7 @@ bool QAD_Study::undo() 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(); @@ -855,7 +863,7 @@ bool QAD_Study::redo() /* 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(); @@ -1192,7 +1200,7 @@ void QAD_Study::renameIObject( const Handle(SALOME_InteractiveObject)& IObject, 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 diff --git a/src/SALOMEGUI/QAD_Study.h b/src/SALOMEGUI/QAD_Study.h index 8139e8a5d..4a41ee5d7 100644 --- a/src/SALOMEGUI/QAD_Study.h +++ b/src/SALOMEGUI/QAD_Study.h @@ -83,6 +83,7 @@ public: bool isModified() const; bool isReadOnly() const; void setReadOnly(bool state); + bool isLocked(); const QString& getTitle() const; int getStudyId(); const QString& getPath() const; diff --git a/src/SALOMEGUI/QAD_StudyFrame.cxx b/src/SALOMEGUI/QAD_StudyFrame.cxx index b54b6dfc0..92f5823d6 100644 --- a/src/SALOMEGUI/QAD_StudyFrame.cxx +++ b/src/SALOMEGUI/QAD_StudyFrame.cxx @@ -31,6 +31,7 @@ \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" @@ -133,22 +134,40 @@ void QAD_StudyFrame::closeEvent(QCloseEvent* e) */ 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); } /*! diff --git a/src/SALOMEGUI/QAD_StudyFrame.h b/src/SALOMEGUI/QAD_StudyFrame.h index cdb83befa..ea8e45e82 100644 --- a/src/SALOMEGUI/QAD_StudyFrame.h +++ b/src/SALOMEGUI/QAD_StudyFrame.h @@ -82,6 +82,9 @@ class QAD_EXPORT QAD_StudyFrame: public QMainWindow void unCompressLeft(); void unCompressRight(); + bool isCompressedLeft() const; + bool isCompressedRight() const; + signals: void sfStudyFrameActivated( QAD_StudyFrame* ); void sfStudyFrameClosing( QAD_StudyFrame*); diff --git a/src/SALOMEGUI/QAD_ViewFrame.cxx b/src/SALOMEGUI/QAD_ViewFrame.cxx index 6fa905371..c22c7a4a8 100644 --- a/src/SALOMEGUI/QAD_ViewFrame.cxx +++ b/src/SALOMEGUI/QAD_ViewFrame.cxx @@ -26,7 +26,6 @@ // Module : SALOME // $Header$ -using namespace std; #include "QAD.h" #include "QAD_ViewFrame.h" #include "QAD_Application.h" @@ -38,6 +37,8 @@ using namespace std; #include #include "utilities.h" +using namespace std; + /*! Constructor */ @@ -69,30 +70,6 @@ void QAD_ViewFrame::cleanup() { } -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 diff --git a/src/SALOMEGUI/QAD_ViewFrame.h b/src/SALOMEGUI/QAD_ViewFrame.h index 48aa8693a..119490b63 100644 --- a/src/SALOMEGUI/QAD_ViewFrame.h +++ b/src/SALOMEGUI/QAD_ViewFrame.h @@ -34,13 +34,15 @@ #include "QAD_StudyFrame.h" #include "SALOME_InteractiveObject.hxx" #include "SALOME_Selection.h" +#include "SALOME_Prs.h" + +class QAD_Study; // QT Include #include -//class vtkRenderer; -class QAD_EXPORT QAD_ViewFrame : public QMainWindow +class QAD_EXPORT QAD_ViewFrame : public QMainWindow, public SALOME_View { Q_OBJECT @@ -53,7 +55,6 @@ public: virtual ViewType getTypeView() const = 0; virtual QWidget* getViewWidget() = 0; -// virtual vtkRenderer* getRenderer(); virtual void setBackgroundColor( const QColor& ) = 0; virtual QColor backgroundColor() const = 0; @@ -75,14 +76,8 @@ public: 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; diff --git a/src/SALOMEGUI/QAD_msg_en.po b/src/SALOMEGUI/QAD_msg_en.po index a843fd12f..07e568038 100644 --- a/src/SALOMEGUI/QAD_msg_en.po +++ b/src/SALOMEGUI/QAD_msg_en.po @@ -588,6 +588,12 @@ msgstr "%1GUI instance creation failed!" 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 #--------------- @@ -856,6 +862,9 @@ msgstr "Pastes object from the clipboard" msgid "EDIT_VALUE_CMD" msgstr "Edit value" +msgid "EXPAND_ALL_CMD" +msgstr "Expand all" + msgid "PLOT_TABLE_CMD" msgstr "Plot table" diff --git a/src/SALOMEGUI/SALOMEGUI_Application.cxx b/src/SALOMEGUI/SALOMEGUI_Application.cxx index 8d95761e9..4b2a35045 100644 --- a/src/SALOMEGUI/SALOMEGUI_Application.cxx +++ b/src/SALOMEGUI/SALOMEGUI_Application.cxx @@ -42,6 +42,7 @@ #include "QAD_Resource.h" #include "QAD_Tools.h" #include "QAD_WaitCursor.h" +#include "QAD_MessageBox.h" // QT Includes #include @@ -218,7 +219,7 @@ void SALOMEGUI_Application::onStudyShown( QAD_Study* study ) } 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); @@ -479,61 +480,76 @@ void SALOMEGUI_Application::onDisplay(int id) 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); diff --git a/src/SALOMEGUI/SALOMEGUI_Swig.cxx b/src/SALOMEGUI/SALOMEGUI_Swig.cxx index 00f6efb08..9edbd3bb1 100644 --- a/src/SALOMEGUI/SALOMEGUI_Swig.cxx +++ b/src/SALOMEGUI/SALOMEGUI_Swig.cxx @@ -26,25 +26,40 @@ // 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"); } @@ -62,8 +77,8 @@ SALOMEGUI_Swig::~SALOMEGUI_Swig() */ 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; } @@ -72,12 +87,9 @@ QAD_Study* SALOMEGUI_Swig::getActiveStudy() */ 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 + (myActiveStudy,&QAD_Study::updateObjBrowser,updateSelection)); } /*! @@ -85,21 +97,9 @@ void SALOMEGUI_Swig::updateObjBrowser( bool 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; } /*! @@ -107,18 +107,9 @@ int SALOMEGUI_Swig::getActiveStudyId() */ 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; } /*! @@ -141,14 +132,11 @@ const char* SALOMEGUI_Swig::getComponentUserName( const char* ComponentName ) */ 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; } /*! @@ -156,68 +144,56 @@ int SALOMEGUI_Swig::SelectedCount() */ 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 + (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 + (aSel,&SALOME_Selection::RemoveIObject,anIO,true)); + } + } } @@ -226,76 +202,65 @@ void SALOMEGUI_Swig::RemoveIObject(const char *Entry) */ 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 + (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 + (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 + (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 + (aViewFrame,&QAD_ViewFrame::Erase,anIO,true)); + } + } } /*! @@ -303,12 +268,11 @@ void SALOMEGUI_Swig::Erase(const char *Entry) */ 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 + (aViewFrame,&QAD_ViewFrame::DisplayAll)); + } } /*! @@ -316,66 +280,20 @@ void SALOMEGUI_Swig::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 + (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; igetStudyFrame(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 getStudyFrame(viewId)->getRightFrame()->getViewFrame()->getRenderer(); - } - if (myRenderer == NULL) MESSAGE("No VTK Renderer available !"); - return myRenderer; -} -*/ - diff --git a/src/SALOMEGUI/SALOMEGUI_Swig.hxx b/src/SALOMEGUI/SALOMEGUI_Swig.hxx index 0af5330a1..f61d26fd0 100644 --- a/src/SALOMEGUI/SALOMEGUI_Swig.hxx +++ b/src/SALOMEGUI/SALOMEGUI_Swig.hxx @@ -34,8 +34,16 @@ #include -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 { @@ -43,9 +51,6 @@ public: 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(); diff --git a/src/SALOMEGUI/SALOMEGUI_TableDlg.cxx b/src/SALOMEGUI/SALOMEGUI_TableDlg.cxx index 07c1b7bdb..5f0455fcd 100644 --- a/src/SALOMEGUI/SALOMEGUI_TableDlg.cxx +++ b/src/SALOMEGUI/SALOMEGUI_TableDlg.cxx @@ -202,16 +202,16 @@ void SALOMEGUI_TableDlg::onOK() } 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 @@ -247,16 +247,16 @@ void SALOMEGUI_TableDlg::onOK() } 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 @@ -300,7 +300,7 @@ void SALOMEGUI_TableDlg::initDlg() 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(); @@ -311,7 +311,7 @@ void SALOMEGUI_TableDlg::initDlg() 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( "" ); } @@ -321,7 +321,7 @@ void SALOMEGUI_TableDlg::initDlg() 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( "" ); } @@ -331,7 +331,7 @@ void SALOMEGUI_TableDlg::initDlg() 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 @@ -356,7 +356,7 @@ void SALOMEGUI_TableDlg::initDlg() 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(); @@ -367,7 +367,7 @@ void SALOMEGUI_TableDlg::initDlg() 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( "" ); } @@ -377,7 +377,7 @@ void SALOMEGUI_TableDlg::initDlg() 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( "" ); } @@ -387,7 +387,7 @@ void SALOMEGUI_TableDlg::initDlg() 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 diff --git a/src/SALOMEGUI/SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx b/src/SALOMEGUI/SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx index e118f219d..760c94eb3 100644 --- a/src/SALOMEGUI/SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx +++ b/src/SALOMEGUI/SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx @@ -38,7 +38,7 @@ #endif class Standard_NoSuchObject; class SALOME_InteractiveObject; -class TColStd_MapOfInteger; +class TColStd_IndexedMapOfInteger; class TColStd_MapTransientHasher; class SALOME_DataMapOfIOMapOfInteger; class SALOME_DataMapNodeOfDataMapOfIOMapOfInteger; @@ -77,7 +77,7 @@ Standard_EXPORT SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger(); 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; diff --git a/src/SALOMEGUI/SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_0.cxx b/src/SALOMEGUI/SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_0.cxx index 1fca36e3e..b45bb6c6d 100644 --- a/src/SALOMEGUI/SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_0.cxx +++ b/src/SALOMEGUI/SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_0.cxx @@ -33,8 +33,8 @@ using namespace std; #ifndef _SALOME_InteractiveObject_HeaderFile #include "SALOME_InteractiveObject.hxx" #endif -#ifndef _TColStd_MapOfInteger_HeaderFile -#include +#ifndef _TColStd_IndexedMapOfInteger_HeaderFile +#include #endif #ifndef _TColStd_MapTransientHasher_HeaderFile #include @@ -49,8 +49,8 @@ using namespace std; #define TheKey Handle_SALOME_InteractiveObject #define TheKey_hxx "SALOME_InteractiveObject.hxx" -#define TheItem TColStd_MapOfInteger -#define TheItem_hxx +#define TheItem TColStd_IndexedMapOfInteger +#define TheItem_hxx #define Hasher TColStd_MapTransientHasher #define Hasher_hxx #define TCollection_DataMapNode SALOME_DataMapNodeOfDataMapOfIOMapOfInteger diff --git a/src/SALOMEGUI/SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx b/src/SALOMEGUI/SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx index dc0cbd32d..cbfa39192 100644 --- a/src/SALOMEGUI/SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx +++ b/src/SALOMEGUI/SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx @@ -37,8 +37,8 @@ #ifndef _Handle_SALOME_InteractiveObject_HeaderFile #include #endif -#ifndef _TColStd_MapOfInteger_HeaderFile -#include +#ifndef _TColStd_IndexedMapOfInteger_HeaderFile +#include #endif #ifndef _TCollection_MapNode_HeaderFile #include @@ -47,7 +47,7 @@ #include #endif class SALOME_InteractiveObject; -class TColStd_MapOfInteger; +class TColStd_IndexedMapOfInteger; class TColStd_MapTransientHasher; class SALOME_DataMapOfIOMapOfInteger; class SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger; @@ -75,9 +75,9 @@ public: // } // 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(); @@ -108,15 +108,15 @@ private: // 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 +#define TheItem TColStd_IndexedMapOfInteger +#define TheItem_hxx #define Hasher TColStd_MapTransientHasher #define Hasher_hxx #define TCollection_DataMapNode SALOME_DataMapNodeOfDataMapOfIOMapOfInteger diff --git a/src/SALOMEGUI/SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_0.cxx b/src/SALOMEGUI/SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_0.cxx index 7fefc9c06..d4d843fe0 100644 --- a/src/SALOMEGUI/SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_0.cxx +++ b/src/SALOMEGUI/SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_0.cxx @@ -34,8 +34,8 @@ using namespace std; #ifndef _SALOME_InteractiveObject_HeaderFile #include "SALOME_InteractiveObject.hxx" #endif -#ifndef _TColStd_MapOfInteger_HeaderFile -#include +#ifndef _TColStd_IndexedMapOfInteger_HeaderFile +#include #endif #ifndef _TColStd_MapTransientHasher_HeaderFile #include @@ -98,8 +98,8 @@ Standard_Boolean SALOME_DataMapNodeOfDataMapOfIOMapOfInteger::IsKind(const Handl Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger::~Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger() {} #define TheKey Handle_SALOME_InteractiveObject #define TheKey_hxx "SALOME_InteractiveObject.hxx" -#define TheItem TColStd_MapOfInteger -#define TheItem_hxx +#define TheItem TColStd_IndexedMapOfInteger +#define TheItem_hxx #define Hasher TColStd_MapTransientHasher #define Hasher_hxx #define TCollection_DataMapNode SALOME_DataMapNodeOfDataMapOfIOMapOfInteger diff --git a/src/SALOMEGUI/SALOME_DataMapOfIOMapOfInteger.hxx b/src/SALOMEGUI/SALOME_DataMapOfIOMapOfInteger.hxx index 6617df7e0..0478b82a1 100644 --- a/src/SALOMEGUI/SALOME_DataMapOfIOMapOfInteger.hxx +++ b/src/SALOMEGUI/SALOME_DataMapOfIOMapOfInteger.hxx @@ -45,7 +45,7 @@ class Standard_DomainError; class Standard_NoSuchObject; class SALOME_InteractiveObject; -class TColStd_MapOfInteger; +class TColStd_IndexedMapOfInteger; class TColStd_MapTransientHasher; class SALOME_DataMapNodeOfDataMapOfIOMapOfInteger; class SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger; @@ -94,17 +94,17 @@ Standard_EXPORT void Clear() ; 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); } diff --git a/src/SALOMEGUI/SALOME_DataMapOfIOMapOfInteger_0.cxx b/src/SALOMEGUI/SALOME_DataMapOfIOMapOfInteger_0.cxx index 990e1bad6..e55a3e490 100644 --- a/src/SALOMEGUI/SALOME_DataMapOfIOMapOfInteger_0.cxx +++ b/src/SALOMEGUI/SALOME_DataMapOfIOMapOfInteger_0.cxx @@ -36,8 +36,8 @@ using namespace std; #ifndef _SALOME_InteractiveObject_HeaderFile #include "SALOME_InteractiveObject.hxx" #endif -#ifndef _TColStd_MapOfInteger_HeaderFile -#include +#ifndef _TColStd_IndexedMapOfInteger_HeaderFile +#include #endif #ifndef _TColStd_MapTransientHasher_HeaderFile #include @@ -52,8 +52,8 @@ using namespace std; #define TheKey Handle_SALOME_InteractiveObject #define TheKey_hxx "SALOME_InteractiveObject.hxx" -#define TheItem TColStd_MapOfInteger -#define TheItem_hxx +#define TheItem TColStd_IndexedMapOfInteger +#define TheItem_hxx #define Hasher TColStd_MapTransientHasher #define Hasher_hxx #define TCollection_DataMapNode SALOME_DataMapNodeOfDataMapOfIOMapOfInteger diff --git a/src/SALOMEGUI/SALOME_Selection.cxx b/src/SALOMEGUI/SALOME_Selection.cxx index 21fa00996..74a60fb5e 100644 --- a/src/SALOMEGUI/SALOME_Selection.cxx +++ b/src/SALOMEGUI/SALOME_Selection.cxx @@ -26,7 +26,6 @@ // Module : SALOME // $Header$ -using namespace std; /*! \class SALOME_Selection SALOME_Selection.h \brief Selection Mechanism of Interactive Object. @@ -42,6 +41,15 @@ using namespace std; #include "utilities.h" #include +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +using namespace std; static QList& SALOME_Sel_GetSelections() { @@ -245,7 +253,7 @@ int SALOME_Selection::AddIObject(const Handle(SALOME_InteractiveObject)& anObjec 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; } @@ -307,13 +315,13 @@ int SALOME_Selection::IObjectCount() //! 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)(); } /*! @@ -351,7 +359,7 @@ bool SALOME_Selection::HasIndex( const Handle(SALOME_InteractiveObject)& IObject 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); @@ -368,11 +376,32 @@ bool SALOME_Selection::IsIndexSelected(const Handle(SALOME_InteractiveObject)& I 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, @@ -380,36 +409,34 @@ bool SALOME_Selection::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& 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; } @@ -423,40 +450,33 @@ bool SALOME_Selection::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& 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& theIndices, + const TContainerOfId& theIndices, bool modeShift, bool update) { @@ -464,42 +484,63 @@ bool SALOME_Selection::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& 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; ihighlight( 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(); +} diff --git a/src/SALOMEGUI/SALOME_Selection.h b/src/SALOMEGUI/SALOME_Selection.h index 0058a1984..a2e413262 100644 --- a/src/SALOMEGUI/SALOME_Selection.h +++ b/src/SALOMEGUI/SALOME_Selection.h @@ -43,7 +43,7 @@ // Open CASCADE Include #include -#include +#include enum Selection_Mode { NodeSelection, @@ -96,13 +96,19 @@ public: bool HasIndex( const Handle(SALOME_InteractiveObject)& IObject ); void GetIndex( const Handle(SALOME_InteractiveObject)& IObject, - TColStd_MapOfInteger& theIndex ); + TColStd_IndexedMapOfInteger& theIndex ); + typedef std::set 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& 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(); diff --git a/src/SALOMELocalTrace/SALOME_Log.cxx b/src/SALOMELocalTrace/SALOME_Log.cxx index c7059d855..be0041573 100644 --- a/src/SALOMELocalTrace/SALOME_Log.cxx +++ b/src/SALOMELocalTrace/SALOME_Log.cxx @@ -30,14 +30,10 @@ #include #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() { } @@ -45,10 +41,10 @@ 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) @@ -59,4 +55,3 @@ void SALOME_Log::putMessage(std::ostream& msg) seekp(0); } - diff --git a/src/SALOMELocalTrace/SALOME_Log.hxx b/src/SALOMELocalTrace/SALOME_Log.hxx index 30694062b..c92699457 100644 --- a/src/SALOMELocalTrace/SALOME_Log.hxx +++ b/src/SALOMELocalTrace/SALOME_Log.hxx @@ -29,6 +29,9 @@ #ifndef _SALOME_LOG_HXX_ #define _SALOME_LOG_HXX_ +#include +#include + //these declarations for files don't using OCC includes (for example HDF) # ifdef WNT @@ -61,25 +64,19 @@ # endif /* WNT */ - -#include -#include - -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 diff --git a/src/SALOMELogger/SALOME_LoggerClient.cxx b/src/SALOMELogger/SALOME_LoggerClient.cxx index a468e9ffe..d876a7350 100644 --- a/src/SALOMELogger/SALOME_LoggerClient.cxx +++ b/src/SALOMELogger/SALOME_LoggerClient.cxx @@ -36,16 +36,19 @@ using namespace std; #include #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 @@ -86,11 +89,11 @@ SALOME_Log::SALOME_Log(): ostrstream(SALOME_LogStr,sizeof(SALOME_LogStr)) } catch( CORBA::COMM_FAILURE& ) { - cout<<"SALOME_LoggerClient: CORBA::COMM_FAILURE: Unable to contact the Naming Service"<resolve(name); m_pInterfaceLogger = SALOME_Logger::Logger::_narrow(obj); if (!CORBA::is_nil(m_pInterfaceLogger)) - cout<<"SALOME_LoggerClient: Logger Server was found"<initialize(); mapInterp[StudyID] = interp; } // imports Python GUI module and puts it in _module attribute @@ -134,6 +135,7 @@ bool SALOME_PYQT_GUI::OnGUIEvent (int theCommandID, 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)); diff --git a/src/SALOME_SWIG/batchmode_salome.py b/src/SALOME_SWIG/batchmode_salome.py index f06796eb7..c997d9fa6 100644 --- a/src/SALOME_SWIG/batchmode_salome.py +++ b/src/SALOME_SWIG/batchmode_salome.py @@ -180,8 +180,8 @@ def CheckCopyPaste(theSO, theInfo ,theComponentPaste): if theComponentPaste: aSObj = theSO.GetFatherComponent() theInfo = theInfo + "(paste for component)" - if not myStudyManager.Paste(aSObj): - raise RuntimeError, " for "+theInfo+" returns false" + if myStudyManager.Paste(aSObj) == None: + raise RuntimeError, " for "+theInfo+" returns None object" aNewTree = GetTree(aRoot) aLen = len(aTree) for a in range(0,aLen): @@ -213,16 +213,24 @@ def FindFileInDataDir(filename): #-------------------------------------------------------------------------- # 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 @@ -239,3 +247,4 @@ myStudyName = myStudy._get_Name() myStudyId = myStudy._get_StudyId() print myStudyId + diff --git a/src/SALOME_SWIG/salome_test.py b/src/SALOME_SWIG/salome_test.py index 2a8196dc0..a1e63a6cc 100644 --- a/src/SALOME_SWIG/salome_test.py +++ b/src/SALOME_SWIG/salome_test.py @@ -95,7 +95,7 @@ idbox = geompy.addToStudy(box,"box") 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) @@ -103,7 +103,7 @@ 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) @@ -111,7 +111,7 @@ 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) diff --git a/src/SUPERVGraph/SUPERVGraph_ViewFrame.h b/src/SUPERVGraph/SUPERVGraph_ViewFrame.h index 42aeafdf3..05edf9581 100644 --- a/src/SUPERVGraph/SUPERVGraph_ViewFrame.h +++ b/src/SUPERVGraph/SUPERVGraph_ViewFrame.h @@ -87,7 +87,7 @@ class QAD_EXPORT SUPERVGraph_ViewFrame : public QAD_ViewFrame { /* 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){}; diff --git a/src/Session/Makefile.in b/src/Session/Makefile.in index 2072c8e84..01c587221 100644 --- a/src/Session/Makefile.in +++ b/src/Session/Makefile.in @@ -42,7 +42,8 @@ LIB = libSalomeSession.la 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 @@ -52,7 +53,7 @@ BIN_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Component.idl SALOM 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@ diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index b4e40e63f..cd9060a3c 100644 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -31,7 +31,6 @@ #include "SALOME_NamingService.hxx" #include #include -using namespace std; #include #include @@ -46,11 +45,10 @@ using namespace std; #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 #include CORBA_SERVER_HEADER(SALOME_Session) @@ -62,18 +60,14 @@ using namespace std; #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. @@ -86,10 +80,20 @@ using namespace std; * - 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_::Instance() ; ASSERT(SINGLETON_::IsAlreadyExisting()) ; int orbArgc = 1; @@ -104,11 +108,7 @@ int main(int argc, char **argv) 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) @@ -117,34 +117,37 @@ int main(int argc, char **argv) = 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 @@ -154,77 +157,76 @@ int main(int argc, char **argv) _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 : "<name(); + INFOS ("run(): CORBA exception of the kind : "<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) { @@ -251,6 +253,5 @@ int main(int argc, char **argv) { INFOS("Caught unknown exception."); } - MESSAGE("End of SALOME_Session_Server"); return 0 ; } diff --git a/src/Session/SALOME_Session_i.cxx b/src/Session/SALOME_Session_i.cxx index 890028127..7e6c34c86 100644 --- a/src/Session/SALOME_Session_i.cxx +++ b/src/Session/SALOME_Session_i.cxx @@ -30,7 +30,7 @@ #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" @@ -48,7 +48,12 @@ using namespace std; */ //============================================================================= -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 ; @@ -57,7 +62,8 @@ SALOME_Session_i::SALOME_Session_i(int argc, char ** argv, CORBA::ORB_ptr orb, P _orb = CORBA::ORB::_duplicate(orb) ; _poa = PortableServer::POA::_duplicate(poa) ; _GUIMutex = GUIMutex; - MESSAGE("constructor end"); + _GUILauncher = GUILauncher; + //MESSAGE("constructor end"); } //============================================================================= @@ -68,7 +74,7 @@ SALOME_Session_i::SALOME_Session_i(int argc, char ** argv, CORBA::ORB_ptr orb, P 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*); @@ -87,7 +93,7 @@ Engines::Component_ptr SALOME_Session_i::GetVisuComponent() SALOME_Session_i::~SALOME_Session_i() { - MESSAGE("destructor end"); + //MESSAGE("destructor end"); } //============================================================================= @@ -114,7 +120,7 @@ void SALOME_Session_i::NSregister() { INFOS("Caught unknown exception from Naming Service"); } - MESSAGE("Session registered in Naming Service"); + //MESSAGE("Session registered in Naming Service"); } //============================================================================= @@ -126,14 +132,10 @@ void SALOME_Session_i::NSregister() 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...") + } } //============================================================================= @@ -141,12 +143,18 @@ void SALOME_Session_i::GetInterface() * 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() ); } //============================================================================= @@ -156,23 +164,29 @@ void SALOME_Session_i::StopSession() */ //============================================================================= +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) @@ -184,3 +198,11 @@ SALOME::StatSession SALOME_Session_i::GetStatSession() 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; +} diff --git a/src/Session/SALOME_Session_i.hxx b/src/Session/SALOME_Session_i.hxx index 438b93f62..b6820e5af 100644 --- a/src/Session/SALOME_Session_i.hxx +++ b/src/Session/SALOME_Session_i.hxx @@ -41,7 +41,12 @@ class SALOME_Session_i: public virtual POA_SALOME::Session, 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 @@ -58,6 +63,8 @@ public: //! Register the servant to Naming Service void NSregister(); + + CORBA::Long GetActiveStudyId(); void ping(){}; @@ -70,6 +77,7 @@ protected: char **_argv; CORBA::Boolean _isGUI ; QMutex* _GUIMutex ; + QWaitCondition* _GUILauncher; int _runningStudies ; CORBA::ORB_var _orb; PortableServer::POA_var _poa; diff --git a/src/Session/Session_ServerLauncher.cxx b/src/Session/Session_ServerLauncher.cxx index 4f278190b..8cbfce4de 100644 --- a/src/Session/Session_ServerLauncher.cxx +++ b/src/Session/Session_ServerLauncher.cxx @@ -81,15 +81,14 @@ Session_ServerLauncher::~Session_ServerLauncher() 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 } @@ -207,8 +206,8 @@ void Session_ServerLauncher::ActivateAll() 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(); diff --git a/src/Session/Session_ServerThread.cxx b/src/Session/Session_ServerThread.cxx index e5e4f055c..be3f1a4f2 100644 --- a/src/Session/Session_ServerThread.cxx +++ b/src/Session/Session_ServerThread.cxx @@ -137,7 +137,7 @@ Session_ServerThread::Session_ServerThread(int argc, 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); @@ -156,7 +156,7 @@ Session_ServerThread::Session_ServerThread(int argc, Session_ServerThread::~Session_ServerThread() { - MESSAGE("~Session_ServerThread "<< _argv[0]); + //MESSAGE("~Session_ServerThread "<< _argv[0]); } //============================================================================= @@ -473,12 +473,33 @@ void Session_ServerThread::ActivateContainer(int argc, 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)"); diff --git a/src/Session/Session_ServerThread.hxx b/src/Session/Session_ServerThread.hxx index 3c12b138e..73737cb45 100644 --- a/src/Session/Session_ServerThread.hxx +++ b/src/Session/Session_ServerThread.hxx @@ -63,10 +63,10 @@ protected: 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; @@ -76,5 +76,24 @@ private: 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 diff --git a/src/TOOLSDS/SALOMEDS_Tool.cxx b/src/TOOLSDS/SALOMEDS_Tool.cxx index 210c42739..f14dcade0 100644 --- a/src/TOOLSDS/SALOMEDS_Tool.cxx +++ b/src/TOOLSDS/SALOMEDS_Tool.cxx @@ -31,7 +31,7 @@ using namespace std; // 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 @@ -83,7 +83,7 @@ char* SALOMEDS_Tool::GetTmpDir() OSD_Protection aProtection(OSD_RW, OSD_RWX, OSD_RX, OSD_RX); aDir.Build(aProtection); - return CORBA::string_dup(aTmpDir.ToCString()); + return aTmpDir.ToCString(); } //============================================================================ @@ -105,6 +105,10 @@ void SALOMEDS_Tool::RemoveTemporaryFiles(const char* theDirectory, OSD_File anOSDFile(anOSDPath); if(!anOSDFile.Exists()) continue; + OSD_Protection aProtection = anOSDFile.Protection(); + aProtection.SetUser(OSD_RW); + anOSDFile.SetProtection(aProtection); + anOSDFile.Remove(); } @@ -128,7 +132,9 @@ SALOMEDS_Tool::PutFilesToStream(const char* theFromDirectory, 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(theFromDirectory)); //Get a temporary directory for saved a file @@ -146,7 +152,7 @@ SALOMEDS_Tool::PutFilesToStream(const char* theFromDirectory, //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; @@ -168,7 +174,9 @@ SALOMEDS_Tool::PutFilesToStream(const char* theFromDirectory, 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); @@ -181,7 +189,7 @@ SALOMEDS_Tool::PutFilesToStream(const char* theFromDirectory, for(i=0; i // IDL headers -#include +#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 , the files for deletion are listed in @@ -36,17 +38,17 @@ public: const int theNamesOnly = 0); // Converts a byte sequence to files and places them in - 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 diff --git a/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx b/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx index abe1d147d..43b673a8e 100644 --- a/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx +++ b/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx @@ -27,7 +27,6 @@ // Module : SALOME // $Header$ -using namespace std; #include "ToolsGUI_CatalogGeneratorDlg.h" #include "QAD_Application.h" @@ -50,6 +49,10 @@ using namespace std; #include #include +#include "utilities.h" + +using namespace std; + #define SPACING_SIZE 6 #define MARGIN_SIZE 11 #define MIN_EDIT_SIZE 250 @@ -300,7 +303,7 @@ QString ToolsGUI_CatalogGeneratorDlg::getIdlPath() 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")) { diff --git a/src/TestContainer/TestContainer.cxx b/src/TestContainer/TestContainer.cxx index 8fc899ec0..25eeed28b 100644 --- a/src/TestContainer/TestContainer.cxx +++ b/src/TestContainer/TestContainer.cxx @@ -41,6 +41,24 @@ #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<id(); + } + + return os; +} + + int main (int argc, char * argv[]) { @@ -193,11 +211,11 @@ 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."< -# include "utilities.h" -# include "Utils_DESTRUCTEUR_GENERIQUE.hxx" # include extern "C" { # include } -static list *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 *Destructeurs=0 ; /*! \class ATEXIT_ * @@ -66,7 +71,7 @@ public : 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 ; // 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 ! @@ -75,7 +80,7 @@ public : ~ATEXIT_( ) { - MESSAGE("Destruction ATEXIT") ; + if(MYDEBUG) MESSAGE("Destruction ATEXIT") ; } }; @@ -95,16 +100,16 @@ static ATEXIT_ nettoyage ; /* singleton statique */ 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::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 ) ; @@ -113,14 +118,14 @@ void Nettoyage( void ) }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 ; } diff --git a/src/Utils/Utils_ExceptHandlers.cxx b/src/Utils/Utils_ExceptHandlers.cxx index 4037ebd8c..2e9b09567 100644 --- a/src/Utils/Utils_ExceptHandlers.cxx +++ b/src/Utils/Utils_ExceptHandlers.cxx @@ -4,9 +4,10 @@ // -#include +#include "Utils_ExceptHandlers.hxx" #include "Utils_CorbaException.hxx" #include "Utils_SALOME_Exception.hxx" + #include #include CORBA_SERVER_HEADER(SALOME_Exception) diff --git a/src/Utils/Utils_ExceptHandlers.hxx b/src/Utils/Utils_ExceptHandlers.hxx index 55558245e..7996ae922 100644 --- a/src/Utils/Utils_ExceptHandlers.hxx +++ b/src/Utils/Utils_ExceptHandlers.hxx @@ -30,7 +30,6 @@ #define Utils_ExceptHandlers_HeaderFile #include -#include typedef void (*PVF)(); @@ -38,8 +37,8 @@ class Unexpect { //save / retrieve unexpected exceptions treatment 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 @@ -47,12 +46,12 @@ 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 @@ -72,4 +71,5 @@ void FuncName () {\ //Definitions : extern void SalomeException(); extern void SALOME_SalomeException(); + #endif diff --git a/src/Utils/Utils_Identity.cxx b/src/Utils/Utils_Identity.cxx index f30cdb03d..55bed3bf7 100644 --- a/src/Utils/Utils_Identity.cxx +++ b/src/Utils/Utils_Identity.cxx @@ -86,9 +86,10 @@ Identity::~Identity(void) 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 ; } diff --git a/src/Utils/Utils_SALOME_Exception.hxx b/src/Utils/Utils_SALOME_Exception.hxx index 9202df72e..9ab9c9c3c 100644 --- a/src/Utils/Utils_SALOME_Exception.hxx +++ b/src/Utils/Utils_SALOME_Exception.hxx @@ -32,11 +32,10 @@ # include # include -using namespace std; - # define LOCALIZED(message) #message , __FILE__ , __LINE__ -class SALOME_Exception : public exception + +class SALOME_Exception : public std::exception { private : @@ -49,7 +48,7 @@ public : 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 () ; } ; diff --git a/src/Utils/Utils_SINGLETON.hxx b/src/Utils/Utils_SINGLETON.hxx index 4e06560a0..79d484389 100644 --- a/src/Utils/Utils_SINGLETON.hxx +++ b/src/Utils/Utils_SINGLETON.hxx @@ -146,7 +146,7 @@ template int SINGLETON_::Destruction( void ) MESSAGE("Destruction du SINGLETON_") ; - list::iterator k ; + std::list::iterator k ; for( k=DESTRUCTEUR_GENERIQUE_::Destructeurs.begin() ; k!=DESTRUCTEUR_GENERIQUE_::Destructeurs.end();k++) { if ( *k == PtrSingleton->_Instance ) diff --git a/src/Utils/Utils_Timer.cxx b/src/Utils/Utils_Timer.cxx index c2748f6ec..f594aba9b 100644 --- a/src/Utils/Utils_Timer.cxx +++ b/src/Utils/Utils_Timer.cxx @@ -28,6 +28,8 @@ # include using namespace std; +#include "utilities.h" + static struct timezone *tz=(struct timezone*) malloc(sizeof(struct timezone)); #ifndef CLK_TCK @@ -78,8 +80,8 @@ void Utils_Timer::Stop() { 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(); } @@ -90,5 +92,5 @@ void Utils_Timer::Reset() { 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 "); } diff --git a/src/Utils/duplicate.cxx b/src/Utils/duplicate.cxx index fd4b95633..b1e449ce4 100644 --- a/src/Utils/duplicate.cxx +++ b/src/Utils/duplicate.cxx @@ -38,6 +38,8 @@ extern "C" } #include "utilities.h" +using namespace std; + const char* duplicate( const char *const str ) { ASSERT(str!=NULL) ; diff --git a/src/Utils/utilities.h b/src/Utils/utilities.h index 1cf18d27a..066e25d24 100644 --- a/src/Utils/utilities.h +++ b/src/Utils/utilities.h @@ -33,13 +33,12 @@ #include #include -#include #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__<<"] : "<putMessage(*SLog<<"---PYSCRIPT--- "<putMessage(\ - *SLog<<__FILE__<<" ["<< __LINE__<<"] : "\ + SLog.putMessage(\ + SLog<<__FILE__<<" ["<< __LINE__<<"] : "\ << "COMPILED with " << COMPILER \ << ", " << __DATE__ \ - << " at " << __TIME__ <putMessage( MYTRACE <putMessage( MYTRACE << #var << "=" << var <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__ @@ -90,7 +90,7 @@ vtkIdType SALOME_ExtractUnstructuredGrid::GetOutId(int theOutId) const{ #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; @@ -233,7 +233,7 @@ void SALOME_ExtractUnstructuredGrid::Execute(){ } } } - if(aNbElems = aConnectivity->GetNumberOfCells()){ + if((aNbElems = aConnectivity->GetNumberOfCells())){ vtkIntArray* aCellLocationsArray = vtkIntArray::New(); aCellLocationsArray->SetNumberOfComponents(1); aCellLocationsArray->SetNumberOfTuples(aNbElems); @@ -322,7 +322,7 @@ void SALOME_ExtractUnstructuredGrid::Execute(){ } } } - if(aNbElems = aConnectivity->GetNumberOfCells()){ + if((aNbElems = aConnectivity->GetNumberOfCells())){ vtkIntArray* aCellLocationsArray = vtkIntArray::New(); aCellLocationsArray->SetNumberOfComponents(1); aCellLocationsArray->SetNumberOfTuples(aNbElems); diff --git a/src/VTKFilter/SALOME_ExtractUnstructuredGrid.h b/src/VTKFilter/SALOME_ExtractUnstructuredGrid.h index 2e913795e..dc3bcc41a 100644 --- a/src/VTKFilter/SALOME_ExtractUnstructuredGrid.h +++ b/src/VTKFilter/SALOME_ExtractUnstructuredGrid.h @@ -57,7 +57,7 @@ public: // Remove the cell from the output void RegisterCell(vtkIdType theCellId); int IsCellsRegistered() { return !myCellIds.empty();} - int ClearRegisteredCells() { + void ClearRegisteredCells() { myCellIds.clear(); Modified(); } @@ -65,7 +65,7 @@ public: // 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(); } @@ -77,8 +77,8 @@ public: 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 TVectorId; typedef std::map TMapId; diff --git a/src/VTKFilter/SALOME_GeometryFilter.cxx b/src/VTKFilter/SALOME_GeometryFilter.cxx index c61818750..d61f825e0 100644 --- a/src/VTKFilter/SALOME_GeometryFilter.cxx +++ b/src/VTKFilter/SALOME_GeometryFilter.cxx @@ -96,7 +96,7 @@ void SALOME_GeometryFilter::SetStoreMapping(int theStoreMapping){ } -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]; @@ -106,17 +106,6 @@ vtkIdType SALOME_GeometryFilter::GetObjId(int 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(); @@ -243,9 +232,8 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() // (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); @@ -279,7 +267,6 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() newCellId = output->InsertNextCell(aCellType,npts,pts); if(myStoreMapping){ myVTK2ObjIds.push_back(cellId); //apo - myObj2VTKIds[cellId].push_back(newCellId); } outputCD->CopyData(cd,cellId,newCellId); break; @@ -289,7 +276,6 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() 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; @@ -300,7 +286,6 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() newCellId = output->InsertNextCell(aCellType,npts,pts); if(myStoreMapping){ myVTK2ObjIds.push_back(cellId); //apo - myObj2VTKIds[cellId].push_back(newCellId); } outputCD->CopyData(cd,cellId,newCellId); break; @@ -309,7 +294,6 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() newCellId = output->InsertNextCell(aCellType,npts,pts); if(myStoreMapping){ myVTK2ObjIds.push_back(cellId); //apo - myObj2VTKIds[cellId].push_back(newCellId); } outputCD->CopyData(cd,cellId,newCellId); break; @@ -318,7 +302,6 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() newCellId = output->InsertNextCell(aCellType,npts,pts); if(myStoreMapping){ myVTK2ObjIds.push_back(cellId); //apo - myObj2VTKIds[cellId].push_back(newCellId); } outputCD->CopyData(cd,cellId,newCellId); break; @@ -344,7 +327,6 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); if(myStoreMapping){ myVTK2ObjIds.push_back(cellId); //apo - myObj2VTKIds[cellId].push_back(newCellId); } outputCD->CopyData(cd,cellId,newCellId); } @@ -373,7 +355,6 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); if(myStoreMapping){ myVTK2ObjIds.push_back(cellId); //apo - myObj2VTKIds[cellId].push_back(newCellId); } outputCD->CopyData(cd,cellId,newCellId); } @@ -402,7 +383,6 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); if(myStoreMapping){ myVTK2ObjIds.push_back(cellId); //apo - myObj2VTKIds[cellId].push_back(newCellId); } outputCD->CopyData(cd,cellId,newCellId); } @@ -436,7 +416,6 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); if(myStoreMapping){ myVTK2ObjIds.push_back(cellId); //apo - myObj2VTKIds[cellId].push_back(newCellId); } outputCD->CopyData(cd,cellId,newCellId); } @@ -470,7 +449,6 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); if(myStoreMapping){ myVTK2ObjIds.push_back(cellId); //apo - myObj2VTKIds[cellId].push_back(newCellId); } outputCD->CopyData(cd,cellId,newCellId); } @@ -495,15 +473,6 @@ void SALOME_GeometryFilter::UnstructuredGridExecute() cout< 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(); @@ -59,9 +58,8 @@ private: int myShowInside; int myStoreMapping; + typedef std::vector TVectorId; TVectorId myVTK2ObjIds; - typedef std::vector TVecVectorId; - TVecVectorId myObj2VTKIds; }; #endif diff --git a/src/VTKViewer/Makefile.in b/src/VTKViewer/Makefile.in index 40ca16b52..43786ab25 100644 --- a/src/VTKViewer/Makefile.in +++ b/src/VTKViewer/Makefile.in @@ -39,7 +39,10 @@ EXPORT_HEADERS= VTKViewer_RenderWindow.h \ 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 @@ -53,7 +56,9 @@ LIB_SRC= VTKViewer.cxx \ 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 \ @@ -66,9 +71,9 @@ LIB_CLIENT_IDL = SALOMEDS.idl \ 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@ diff --git a/src/VTKViewer/VTKViewer_CellRectPicker.cxx b/src/VTKViewer/VTKViewer_CellRectPicker.cxx index 6e05537cd..b2506538b 100644 --- a/src/VTKViewer/VTKViewer_CellRectPicker.cxx +++ b/src/VTKViewer/VTKViewer_CellRectPicker.cxx @@ -299,7 +299,7 @@ void VTKViewer_CellRectPicker::IncludeActor(vtkProp3D* prop, 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) { diff --git a/src/VTKViewer/VTKViewer_Filter.h b/src/VTKViewer/VTKViewer_Filter.h index d9d9831a8..f667356b8 100755 --- a/src/VTKViewer/VTKViewer_Filter.h +++ b/src/VTKViewer/VTKViewer_Filter.h @@ -48,11 +48,13 @@ public: VTKViewer_Filter(); virtual ~VTKViewer_Filter(); - bool IsValid( SALOME_Actor*, const int theCellId ); - virtual bool IsValid( const int theCellId ) const = 0; + bool IsValid( SALOME_Actor*, const int theId ); + virtual bool IsValid( const int theId ) const = 0; + virtual int GetId() const = 0; + virtual bool IsNodeFilter() const = 0; virtual void SetActor( SALOME_Actor* ); - + protected: SALOME_Actor* myActor; diff --git a/src/VTKViewer/VTKViewer_InteractorStyleSALOME.cxx b/src/VTKViewer/VTKViewer_InteractorStyleSALOME.cxx index d7cbfb5c2..c2ac9c3cc 100644 --- a/src/VTKViewer/VTKViewer_InteractorStyleSALOME.cxx +++ b/src/VTKViewer/VTKViewer_InteractorStyleSALOME.cxx @@ -27,8 +27,11 @@ // $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" @@ -38,23 +41,23 @@ #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 #include #include -#include +#include +#include #include #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include #include //VRV: porting on Qt 3.0.5 @@ -68,8 +71,73 @@ 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); @@ -84,25 +152,46 @@ VTKViewer_InteractorStyleSALOME::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(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; } //---------------------------------------------------------------------------- @@ -134,28 +223,18 @@ void VTKViewer_InteractorStyleSALOME::RotateXY(int dx, int dy) 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) @@ -174,20 +253,14 @@ 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) @@ -207,7 +280,8 @@ void VTKViewer_InteractorStyleSALOME::SpinXY(int x, int y, int oldX, int oldY) cam->Roll(newAngle - oldAngle); cam->OrthogonalizeViewUp(); - rwi->Render(); + //this->Interactor->Render(); + myGUIWindow->update(); } @@ -253,6 +327,8 @@ void VTKViewer_InteractorStyleSALOME::OnLeftButtonDown(int ctrl, int shift, } return; } + + //---------------------------------------------------------------------------- void VTKViewer_InteractorStyleSALOME::OnLeftButtonUp(int vtkNotUsed(ctrl), int shift, @@ -267,6 +343,7 @@ void VTKViewer_InteractorStyleSALOME::OnLeftButtonUp(int vtkNotUsed(ctrl), } } + //---------------------------------------------------------------------------- void VTKViewer_InteractorStyleSALOME::OnMiddleButtonDown(int ctrl, int shift, @@ -297,6 +374,8 @@ void VTKViewer_InteractorStyleSALOME::OnMiddleButtonDown(int ctrl, startOperation(VTK_INTERACTOR_STYLE_CAMERA_PAN); } } + + //---------------------------------------------------------------------------- void VTKViewer_InteractorStyleSALOME::OnMiddleButtonUp(int vtkNotUsed(ctrl), int shift, @@ -311,6 +390,7 @@ void VTKViewer_InteractorStyleSALOME::OnMiddleButtonUp(int vtkNotUsed(ctrl), } } + //---------------------------------------------------------------------------- void VTKViewer_InteractorStyleSALOME::OnRightButtonDown(int ctrl, int shift, @@ -357,12 +437,6 @@ void VTKViewer_InteractorStyleSALOME::OnRightButtonUp(int vtkNotUsed(ctrl), } //---------------------------------------------------------------------------- -void VTKViewer_InteractorStyleSALOME::PrintSelf(ostream& os, vtkIndent indent) -{ - vtkInteractorStyle::PrintSelf(os,indent); - -} - /* XPM */ const char* imageZoomCursor[] = { "32 32 3 1", @@ -440,6 +514,8 @@ const char* imageRotateCursor[] = { "................................", "................................"}; + +//---------------------------------------------------------------------------- // loads cursors for viewer operations - zoom, pan, etc... void VTKViewer_InteractorStyleSALOME::loadCursors() { @@ -453,6 +529,8 @@ void VTKViewer_InteractorStyleSALOME::loadCursors() myCursorState = false; } + +//---------------------------------------------------------------------------- // event filter - controls mouse and keyboard events during viewer operations bool VTKViewer_InteractorStyleSALOME::eventFilter(QObject* object, QEvent* event) { @@ -465,6 +543,8 @@ 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() { @@ -478,6 +558,8 @@ void VTKViewer_InteractorStyleSALOME::startZoom() qApp->installEventFilter(this); } + +//---------------------------------------------------------------------------- // starts Pan operation (e.g. through menu command) void VTKViewer_InteractorStyleSALOME::startPan() { @@ -491,6 +573,7 @@ void VTKViewer_InteractorStyleSALOME::startPan() qApp->installEventFilter(this); } +//---------------------------------------------------------------------------- // starts Rotate operation (e.g. through menu command) void VTKViewer_InteractorStyleSALOME::startRotate() { @@ -504,6 +587,8 @@ void VTKViewer_InteractorStyleSALOME::startRotate() qApp->installEventFilter(this); } + +//---------------------------------------------------------------------------- // starts Spin operation (e.g. through menu command) void VTKViewer_InteractorStyleSALOME::startSpin() { @@ -518,6 +603,8 @@ void VTKViewer_InteractorStyleSALOME::startSpin() } + +//---------------------------------------------------------------------------- // starts Fit Area operation (e.g. through menu command) void VTKViewer_InteractorStyleSALOME::startFitArea() { @@ -532,6 +619,7 @@ void VTKViewer_InteractorStyleSALOME::startFitArea() } +//---------------------------------------------------------------------------- void VTKViewer_InteractorStyleSALOME::ViewFitAll() { int aTriedronWasVisible = false; if(m_Trihedron){ @@ -552,6 +640,7 @@ void VTKViewer_InteractorStyleSALOME::ViewFitAll() { } +//---------------------------------------------------------------------------- // starts Global Panning operation (e.g. through menu command) void VTKViewer_InteractorStyleSALOME::startGlobalPan() { @@ -568,26 +657,14 @@ 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(this->Interactor->GetRenderWindow()); if (myGUIWindow) myGUIWindow->update(); qApp->installEventFilter(this); } + +//---------------------------------------------------------------------------- // returns TRUE if needs redrawing bool VTKViewer_InteractorStyleSALOME::needsRedrawing() { @@ -598,6 +675,8 @@ 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, @@ -627,18 +706,11 @@ void VTKViewer_InteractorStyleSALOME::fitRect(const int left, ::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(rwi->GetRenderWindow()); myGUIWindow->update(); } - +//---------------------------------------------------------------------------- // starts viewer operation (!internal usage!) void VTKViewer_InteractorStyleSALOME::startOperation(int operation) { @@ -666,6 +738,8 @@ void VTKViewer_InteractorStyleSALOME::startOperation(int operation) } } + +//---------------------------------------------------------------------------- // sets proper cursor for window when viewer operation is activated void VTKViewer_InteractorStyleSALOME::setCursor(const int operation) { @@ -705,6 +779,8 @@ void VTKViewer_InteractorStyleSALOME::setCursor(const int operation) } } + +//---------------------------------------------------------------------------- // called when viewer operation started (!put necessary initialization here!) void VTKViewer_InteractorStyleSALOME::onStartOperation() { @@ -730,6 +806,8 @@ void VTKViewer_InteractorStyleSALOME::onStartOperation() } } + +//---------------------------------------------------------------------------- // called when viewer operation finished (!put necessary post-processing here!) void VTKViewer_InteractorStyleSALOME::onFinishOperation() { @@ -738,7 +816,6 @@ 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()); @@ -759,7 +836,7 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() 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; @@ -769,260 +846,114 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() } 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 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 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 = "<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 : "<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 : "<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 : "<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; @@ -1035,7 +966,7 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() 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; @@ -1043,70 +974,49 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() 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 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::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); } } } @@ -1114,100 +1024,40 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() } } break; + } case CellSelection: case EdgeOfCellSelection: case EdgeSelection: case FaceSelection: case VolumeSelection: { - VTKViewer_CellRectPicker* picker = VTKViewer_CellRectPicker::New(); + vtkSmartPointer 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 anIndexes; - if (aSelectionMode == CellSelection) { - VTKViewer_CellDataSet::iterator it; - for (it = cellList.begin(); it != cellList.end(); ++it) { - int aCellId = (*it).cellId; - if ( !isValid( aSActor, aCellId, aSelectionMode ) ) - continue; - - int aObjId = aSActor->GetObjId(aCellId); - std::vector aVtkList; - if ( aObjId != -1 ) - aVtkList = aSActor->GetVtkId(aObjId); - - if (aVtkList.size() > 0) { - std::vector::iterator it; - for (it = aVtkList.begin(); it != aVtkList.end(); ++it) { - std::vector::iterator found = - find(anIndexes.begin(), anIndexes.end(), *it); - if (found == anIndexes.end()) - anIndexes.push_back(*it); - } - } - else - anIndexes.push_back(aCellId); - } - } - else { - if ( vtkDataSet* aDataSet = aSActor->GetMapper()->GetInput() ) { - VTKViewer_CellDataSet::iterator it; - for ( it = cellList.begin(); it != cellList.end(); ++it ) { - int aCellId = (*it).cellId; - - if ( !isValid( aSActor, aCellId, aSelectionMode ) ) - continue; - - int aObjId = aSActor->GetObjId(aCellId); - std::vector aVtkList; - if (aObjId != -1) - aVtkList = aSActor->GetVtkId(aObjId); - bool result = false; - if (vtkCell* aCell = aDataSet->GetCell(aCellId)) { - if ( aSelectionMode == EdgeSelection ) { - if ( aSActor->GetObjDimension( aObjId ) == 1 ) - result = true; - } - else if ( aSelectionMode == FaceSelection ) { - if ( aSActor->GetObjDimension( aObjId ) == 2 ) - result = true; - } - else if ( aSelectionMode == VolumeSelection ) { - if ( aSActor->GetObjDimension( aObjId ) == 3 ) - result = true; - } - } - if ( result ) { - if (aVtkList.size() > 0) { - std::vector::iterator it; - for (it = aVtkList.begin(); it != aVtkList.end(); ++it) { - std::vector::iterator found = - find(anIndexes.begin(), anIndexes.end(), *it); - if (found == anIndexes.end()) - anIndexes.push_back(*it); - } - } - else - anIndexes.push_back(aCellId); - } + 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); } } } @@ -1221,32 +1071,18 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() break; case ActorSelection: // objects selection { - VTKViewer_RectPicker* picker = VTKViewer_RectPicker::New(); + vtkSmartPointer 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); } } @@ -1261,7 +1097,7 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() } } // end case 4 } //end switch - rwi->EndPickCallback(); + m_Interactor->EndPickCallback(); } aActiveStudy->update3dViewers(); } @@ -1275,7 +1111,7 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() 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); @@ -1352,7 +1188,10 @@ void VTKViewer_InteractorStyleSALOME::onOperation(QPoint mousePos) // 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 @@ -1361,216 +1200,121 @@ void VTKViewer_InteractorStyleSALOME::onCursorMove(QPoint mousePos) { // 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 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 : "<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 aVtkList; - if (anObjId > -1) - aVtkList = SActor->GetVtkId(anObjId); - - if ( aSelectionMode == EdgeSelection ) { - if ( SActor->GetObjDimension( anObjId ) == 1 ) - result = true; - } - else if ( aSelectionMode == FaceSelection ) { - if ( SActor->GetObjDimension( anObjId ) == 2 ) - result = true; - } - else if ( aSelectionMode == VolumeSelection ) { - if ( SActor->GetObjDimension( anObjId ) == 3 ) - result = true; - } - else { - float pickPosition[3]; - picker->GetPickPosition(pickPosition); - float distMin = 1000000.0, dist = 0; - for (int i = 0, iEnd = pickedCell->GetNumberOfEdges(); i < iEnd; i++){ - vtkCell* edge = pickedCell->GetEdge(i); - if(vtkLine* line = vtkLine::SafeDownCast(edge)){ - float pcoords[3],closestPoint[3],weights[3]; - int subId; - line->EvaluatePosition(pickPosition,closestPoint,subId,pcoords,dist,weights); - if (dist < distMin) { - distMin = dist; - edgeId = i; - } - } - } - if (edgeId != -1 || pickedCell->GetCellDimension() == 1) - result = true; - // INFOS("edgeID transformed = "<CurrentRenderer->RemoveActor(myPActor); - if (edgeId == -1) { - if (aVtkList.size() > 0) - aRWI->setCellData(SActor->getIO(), aVtkList, myPActor); - else - aRWI->setCellData(SActor->getIO(), aVtkId, myPActor); - } - else - aRWI->setEdgeData(SActor->getIO(), aVtkId, -edgeId-1, myPActor); - - this->CurrentRenderer->AddActor(myPActor); - myPActor->GetProperty()->SetRepresentationToSurface(); - myPActor->VisibilityOn(); - } - } - } - } + } + 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 : "<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 : "<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; } @@ -1594,11 +1338,6 @@ void VTKViewer_InteractorStyleSALOME::Place(const int theX, const int theY) 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(this->Interactor->GetRenderWindow()); if (myGUIWindow) myGUIWindow->update(); } @@ -1696,58 +1435,64 @@ bool VTKViewer_InteractorStyleSALOME::IsInRect(float* thePoint, return ((aPnt[0]>left) && (aPnt[0]bottom) && (aPnt[1]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::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)(); +} + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/VTKViewer/VTKViewer_InteractorStyleSALOME.h b/src/VTKViewer/VTKViewer_InteractorStyleSALOME.h index ce55fdfc8..851aeafdf 100644 --- a/src/VTKViewer/VTKViewer_InteractorStyleSALOME.h +++ b/src/VTKViewer/VTKViewer_InteractorStyleSALOME.h @@ -30,13 +30,20 @@ #define __VTKViewer_InteractorStyleSALOME_h #include + +class vtkCell; +class vtkRenderWindowInteractor; + #include #include -#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 @@ -55,14 +62,16 @@ class VTKViewer_InteractorStyleSALOME : public QObject, public vtkInteractorStyl // 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); @@ -76,10 +85,14 @@ class VTKViewer_InteractorStyleSALOME : public QObject, public vtkInteractorStyl 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(); @@ -104,19 +117,21 @@ class VTKViewer_InteractorStyleSALOME : public QObject, public vtkInteractorStyl const int left, const int top, const int right, const int bottom); - bool isValid( SALOME_Actor* theActor, const int theCellId, const Selection_Mode theSelMode ); - int State; float MotionFactor; float RadianToDegree; // constant: for conv from deg to rad double myScale; - SALOME_Actor* preview; - vtkActor* myPActor; + 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(); @@ -124,10 +139,8 @@ public: 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(); @@ -136,7 +149,8 @@ protected: void onCursorMove(QPoint mousePos); void setCursor(const int operation); -protected: + + protected: QCursor myDefCursor; QCursor myPanCursor; QCursor myZoomCursor; @@ -150,12 +164,12 @@ protected: 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 myFilters; // members from old version double DeltaElevation; diff --git a/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx b/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx index 9658ef5e5..c7d3828a9 100644 --- a/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx +++ b/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx @@ -27,14 +27,18 @@ // $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 #include @@ -42,27 +46,28 @@ #include // VTK Includes -#include -#include -#include #include #include #include #include -#include -#include -#include -#include -#include -#include #include -#include // QT Includes #include +#include + +#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 ) { @@ -74,18 +79,51 @@ VTKViewer_RenderWindowInteractor* VTKViewer_RenderWindowInteractor::New() { 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) { @@ -132,6 +170,10 @@ void VTKViewer_RenderWindowInteractor::Initialize() { 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. // @@ -147,93 +189,83 @@ void VTKViewer_RenderWindowInteractor::Initialize() { // 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(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() { @@ -391,15 +423,8 @@ void VTKViewer_RenderWindowInteractor::MouseMove(const QMouseEvent *event) { 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() ; } @@ -407,84 +432,54 @@ void VTKViewer_RenderWindowInteractor::LeftButtonPressed(const QMouseEvent *even 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) { @@ -495,112 +490,59 @@ void VTKViewer_RenderWindowInteractor::ButtonReleased(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(GetRenderer()->GetActors(), + TIsSameIObject(theIObject), + TSetFunction + (&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(theCollection, + TSetFunction + (&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(theCollection, + TSetFunction + (&SALOME_Actor::setDisplayMode,1)); + emit RenderWindowModified(); } + vtkRenderer* VTKViewer_RenderWindowInteractor::GetRenderer() { vtkRendererCollection * theRenderers = this->RenderWindow->GetRenderers(); @@ -608,287 +550,212 @@ vtkRenderer* VTKViewer_RenderWindowInteractor::GetRenderer() return theRenderers->GetNextItem(); } + +struct TErase{ + SALOME::VTK::TSetFunction 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(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(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(aCollection,TSetVisibility(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(GetRenderer()->GetActors(), + TIsSameIObject(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(aRen->GetActors(), + TIsSameIObject(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(GetRenderer()->GetActors(), + TIsSameIObject(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(GetRenderer()->GetActors(), + TIsSameIObject(theIObject), + TSetFunction + (&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(GetRenderer()->GetActors(), + TIsSameIObject(theIObject), + TSetVisibility(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(GetRenderer()->GetActors(), + TIsSameIObject(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(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(GetRenderer()->GetActors(), + TUnHighlightAllAction()); + emit RenderWindowModified() ; return false; } @@ -897,159 +764,75 @@ bool VTKViewer_RenderWindowInteractor::unHighlightAll(){ // 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(GetRenderer()->GetActors(), + TIsSameIObject(theIObject), + TSetFunction + (&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(GetRenderer()->GetActors(), + TIsSameIObject(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(GetRenderer()->GetActors(), + TIsSameIObject(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(GetRenderer()->GetActors(), + TIsSameIObject(theIObject)); + return anActor != NULL && anActor->GetVisibility(); +} - emit RenderWindowModified() ; + +void VTKViewer_RenderWindowInteractor::rename(const Handle(SALOME_InteractiveObject)& theIObject, QString theName) +{ + using namespace SALOME::VTK; + ForEachIf(GetRenderer()->GetActors(), + TIsSameIObject(theIObject), + TSetFunction + (&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){ @@ -1060,190 +843,90 @@ bool VTKViewer_RenderWindowInteractor::highlight(const Handle(SALOME_Interactive 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& theIndexes, vtkActor* theActor ) +void VTKViewer_RenderWindowInteractor::setCellData(const int& theIndex, + SALOME_Actor* theMapActor, + VTKViewer_Actor* theActor) { - TColStd_MapOfInteger MapIndex; - std::vector::const_iterator it; - for (it = theIndexes.begin(); it != theIndexes.end(); ++it) - MapIndex.Add(*it); - return setActorData(IObject,MapIndex,&CellCreateMapper,theActor); + 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); } diff --git a/src/VTKViewer/VTKViewer_RenderWindowInteractor.h b/src/VTKViewer/VTKViewer_RenderWindowInteractor.h index 3a22e676a..eb4fdb004 100644 --- a/src/VTKViewer/VTKViewer_RenderWindowInteractor.h +++ b/src/VTKViewer/VTKViewer_RenderWindowInteractor.h @@ -33,7 +33,6 @@ // now we define the C++ class #include "SALOME_InteractiveObject.hxx" -#include "SALOME_Actor.h" #include "SALOME_Selection.h" // QT Includes @@ -48,9 +47,14 @@ #include #include -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; @@ -64,7 +68,8 @@ 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() ; @@ -129,15 +134,23 @@ public: //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); @@ -147,22 +160,12 @@ public: const double& theBlue = 0, const int& theWidth = 5); void SetSelectionTolerance(const double& theTolNodes = 0.025, const double& theTolCell = 0.001); - void setCellData(const Handle(SALOME_InteractiveObject)& IObject, - const int& theIndex, vtkActor* theActor ); - void setCellData(const Handle(SALOME_InteractiveObject)& IObject, - const std::vector& theIndexes, vtkActor* theActor ); - void setEdgeData(const Handle(SALOME_InteractiveObject)& IObject, - const int& theCellIndex, const int& theEdgeIndex, - vtkActor* theActor ); //NB - void setPointData(const Handle(SALOME_InteractiveObject)& IObject, - const int& theIndex, vtkActor* theActor ); - // Displaymode management int GetDisplayMode(); 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(); @@ -194,12 +197,24 @@ public: 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(); @@ -207,25 +222,29 @@ public: 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]; @@ -259,9 +278,10 @@ public: void RenderWindowModified() ; private: - QWidget* myGUIWindow; - double myTolNodes; - double myTolItems; + VTKViewer_ViewFrame* myViewFrame; + QWidget* myGUIWindow; + double myTolNodes; + double myTolItems; }; #endif diff --git a/src/VTKViewer/VTKViewer_Trihedron.cxx b/src/VTKViewer/VTKViewer_Trihedron.cxx index 9a278d4a6..17b56a422 100644 --- a/src/VTKViewer/VTKViewer_Trihedron.cxx +++ b/src/VTKViewer/VTKViewer_Trihedron.cxx @@ -51,22 +51,6 @@ using namespace std; //============================================================================== -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(){} @@ -99,31 +83,6 @@ void VTKViewer_UnScaledActor::SetSize(int theSize){ //============================================================================== -class VTKViewer_LineActor: public vtkFollower{ - VTKViewer_LineActor(const VTKViewer_LineActor&); - -public: - vtkTypeMacro(VTKViewer_LineActor,vtkFollower); - static VTKViewer_LineActor *New(); - - void SetLabelActor(VTKViewer_UnScaledActor* theLabelActor); - void SetArrowActor(VTKViewer_UnScaledActor* theLabelActor); - virtual void Render(vtkRenderer *theRenderer); - -protected: - VTKViewer_LineActor(){ - LabelActor = NULL; - ArrowActor = NULL; - } - ~VTKViewer_LineActor(){ - SetLabelActor(NULL); - SetArrowActor(NULL); - } - - VTKViewer_UnScaledActor* LabelActor; - VTKViewer_UnScaledActor* ArrowActor; -}; - vtkStandardNewMacro(VTKViewer_LineActor); vtkCxxSetObjectMacro(VTKViewer_LineActor,LabelActor,VTKViewer_UnScaledActor); @@ -142,69 +101,15 @@ void VTKViewer_LineActor::Render(vtkRenderer *theRenderer){ } //============================================================================== - // 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()); @@ -268,8 +173,8 @@ VTKViewer_Axis::~VTKViewer_Axis(){ // Destroy of the Arrow pipe-line representation myLineActor->Delete(); - myMapper[2]->RemoveAllInputs(); - myMapper[2]->Delete(); + myMapper[0]->RemoveAllInputs(); + myMapper[0]->Delete(); myLineSource->Delete(); } @@ -305,6 +210,26 @@ void VTKViewer_Axis::SetSize(float theSize){ 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: diff --git a/src/VTKViewer/VTKViewer_Trihedron.h b/src/VTKViewer/VTKViewer_Trihedron.h index d53a602c3..169e47345 100644 --- a/src/VTKViewer/VTKViewer_Trihedron.h +++ b/src/VTKViewer/VTKViewer_Trihedron.h @@ -30,10 +30,64 @@ #define VTKViewer_Trihedron_H #include +#include 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: @@ -64,4 +118,43 @@ 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 diff --git a/src/VTKViewer/VTKViewer_ViewFrame.cxx b/src/VTKViewer/VTKViewer_ViewFrame.cxx index b68158db7..f16a93f4c 100644 --- a/src/VTKViewer/VTKViewer_ViewFrame.cxx +++ b/src/VTKViewer/VTKViewer_ViewFrame.cxx @@ -30,8 +30,13 @@ #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" @@ -53,8 +58,12 @@ // VTK Includes #include +#include #include #include +#include + +#include using namespace std; @@ -95,15 +104,19 @@ void VTKViewer_ViewFrame::InitialSetup() { // 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); @@ -112,18 +125,18 @@ void VTKViewer_ViewFrame::InitialSetup() { } 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()"); } /*! @@ -137,43 +150,87 @@ bool VTKViewer_ViewFrame::isTrihedronDisplayed(){ 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 */ @@ -214,7 +271,7 @@ void VTKViewer_ViewFrame::onViewBottom(){ */ 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(); @@ -225,7 +282,7 @@ void VTKViewer_ViewFrame::onViewLeft(){ */ 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(); @@ -258,17 +315,6 @@ void VTKViewer_ViewFrame::onViewFront(){ */ 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(); } @@ -372,31 +418,30 @@ void VTKViewer_ViewFrame::highlight( const Handle(SALOME_InteractiveObject)& IOb 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(aCollection,TIsSameEntry(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(); } } @@ -415,170 +460,88 @@ void VTKViewer_ViewFrame::setPopupServer( QAD_Application* App ) 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(getRenderer()->GetActors(), + TIsSameEntry(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(getRenderer()->GetActors(), + TIsSameIObject(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(getRenderer()->GetActors(), + TIsSameIObject(theIObject), + TEraseAction(aSel,theIObject,m_RWInteractor)); + + if(update) Repaint(); } @@ -611,14 +574,132 @@ void VTKViewer_ViewFrame::SetScale(double theScale[3]){ 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( 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( 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() ); } diff --git a/src/VTKViewer/VTKViewer_ViewFrame.h b/src/VTKViewer/VTKViewer_ViewFrame.h index 5547699fa..7f67e444d 100644 --- a/src/VTKViewer/VTKViewer_ViewFrame.h +++ b/src/VTKViewer/VTKViewer_ViewFrame.h @@ -32,13 +32,15 @@ #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; @@ -72,13 +74,6 @@ class QAD_EXPORT VTKViewer_ViewFrame : public QAD_ViewFrame{ 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); @@ -91,12 +86,22 @@ class QAD_EXPORT VTKViewer_ViewFrame : public QAD_ViewFrame{ 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(); @@ -115,16 +120,20 @@ class QAD_EXPORT VTKViewer_ViewFrame : public QAD_ViewFrame{ 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