From: prascle Date: Fri, 22 Oct 2004 12:21:09 +0000 (+0000) Subject: PR: mergefrom_PAL_OCC_21Oct04 X-Git-Tag: V2_1_0a1~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=788659d329f8451bd9c2197748003d2dd69b2e85;p=modules%2Fkernel.git PR: mergefrom_PAL_OCC_21Oct04 --- 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/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/examples/fedges.unv b/examples/fedges.unv new file mode 100644 index 000000000..d2c47a388 --- /dev/null +++ b/examples/fedges.unv @@ -0,0 +1,2926 @@ + -1 + 2411 + 1 0 0 0 + 0.0000000000000000E+00 0.0000000000000000E+00 0.0000000000000000E+00 + 2 0 0 0 + 0.0000000000000000E+00 -2.3999999999999999E+00 0.0000000000000000E+00 + 3 0 0 0 + 0.0000000000000000E+00 -4.0000000000000000E+00 0.0000000000000000E+00 + 4 0 0 0 + 0.0000000000000000E+00 -5.5999999999999996E+00 0.0000000000000000E+00 + 5 0 0 0 + 0.0000000000000000E+00 -8.0000000000000000E+00 0.0000000000000000E+00 + 6 0 0 0 + 0.0000000000000000E+00 -1.0400000000000000E+01 0.0000000000000000E+00 + 7 0 0 0 + 0.0000000000000000E+00 -1.2000000000000000E+01 0.0000000000000000E+00 + 8 0 0 0 + 0.0000000000000000E+00 -1.4350000000000000E+01 0.0000000000000000E+00 + 9 0 0 0 + 0.0000000000000000E+00 -1.5500000000000000E+01 5.0000000000000000E-01 + 10 0 0 0 + 0.0000000000000000E+00 -1.6129999999999999E+01 1.7000000000000000E+00 + 11 0 0 0 + 0.0000000000000000E+00 -1.6129999999999999E+01 3.3500000000000001E+00 + 12 0 0 0 + 0.0000000000000000E+00 -1.6129999999999999E+01 4.9500000000000002E+00 + 13 0 0 0 + 0.0000000000000000E+00 -1.6129999999999999E+01 7.1550000000000002E+00 + 14 0 0 0 + 0.0000000000000000E+00 -1.6129999999999999E+01 9.3599999999999994E+00 + 15 0 0 0 + 0.0000000000000000E+00 -1.6129999999999999E+01 1.2359999999999999E+01 + 16 0 0 0 + 0.0000000000000000E+00 -1.6129999999999999E+01 1.5359999999999999E+01 + 17 0 0 0 + 0.0000000000000000E+00 -1.6129999999999999E+01 1.7609999999999999E+01 + 18 0 0 0 + 0.0000000000000000E+00 -1.6129999999999999E+01 1.8969999999999999E+01 + 19 0 0 0 + 0.0000000000000000E+00 -1.6129999999999999E+01 2.0800000000000001E+01 + 20 0 0 0 + 0.0000000000000000E+00 -2.3999999999999999E+00 2.1449999999999999E+01 + 21 0 0 0 + 0.0000000000000000E+00 -4.0000000000000000E+00 2.1449999999999999E+01 + 22 0 0 0 + 0.0000000000000000E+00 -5.5999999999999996E+00 2.1366000000000000E+01 + 23 0 0 0 + 0.0000000000000000E+00 -8.0000000000000000E+00 2.1239000000000001E+01 + 24 0 0 0 + 0.0000000000000000E+00 -1.0400000000000000E+01 2.1111999999999998E+01 + 25 0 0 0 + 0.0000000000000000E+00 -1.2000000000000000E+01 2.1027999999999999E+01 + 26 0 0 0 + 0.0000000000000000E+00 -1.4130000000000001E+01 2.0916000000000000E+01 + 27 0 0 0 + 0.0000000000000000E+00 0.0000000000000000E+00 2.0000000000000000E+00 + 28 0 0 0 + 0.0000000000000000E+00 0.0000000000000000E+00 1.8969999999999999E+01 + 29 0 0 0 + 0.0000000000000000E+00 -2.3999999999999999E+00 2.0000000000000000E+00 + 30 0 0 0 + 0.0000000000000000E+00 -4.0000000000000000E+00 2.0000000000000000E+00 + 31 0 0 0 + 0.0000000000000000E+00 -5.5999999999999996E+00 2.0000000000000000E+00 + 32 0 0 0 + 0.0000000000000000E+00 -8.0000000000000000E+00 2.0000000000000000E+00 + 33 0 0 0 + 0.0000000000000000E+00 -1.0400000000000000E+01 2.0000000000000000E+00 + 34 0 0 0 + 0.0000000000000000E+00 -1.2000000000000000E+01 2.0000000000000000E+00 + 35 0 0 0 + 0.0000000000000000E+00 -1.2877000000000001E+01 3.2160000000000002E+00 + 36 0 0 0 + 0.0000000000000000E+00 -1.4130000000000001E+01 4.9500000000000002E+00 + 37 0 0 0 + 0.0000000000000000E+00 -1.4130000000000001E+01 7.1550000000000002E+00 + 38 0 0 0 + 0.0000000000000000E+00 -1.4130000000000001E+01 9.3599999999999994E+00 + 39 0 0 0 + 0.0000000000000000E+00 -1.4130000000000001E+01 1.2359999999999999E+01 + 40 0 0 0 + 0.0000000000000000E+00 -1.4130000000000001E+01 1.5359999999999999E+01 + 41 0 0 0 + 0.0000000000000000E+00 -1.4130000000000001E+01 1.7609999999999999E+01 + 42 0 0 0 + 0.0000000000000000E+00 -1.4130000000000001E+01 1.8969999999999999E+01 + 43 0 0 0 + 0.0000000000000000E+00 -1.3600000000000000E+01 2.0000000000000000E+00 + 44 0 0 0 + 0.0000000000000000E+00 -1.5199999999999999E+01 3.8500000000000001E+00 + 45 0 0 0 + 0.0000000000000000E+00 -1.4500000000000000E+01 3.8500000000000001E+00 + 46 0 0 0 + 0.0000000000000000E+00 -1.4150000000000000E+01 3.1040000000000001E+00 + 47 0 0 0 + 0.0000000000000000E+00 -1.5199999999999999E+01 2.0000000000000000E+00 + 48 0 0 0 + 0.0000000000000000E+00 0.0000000000000000E+00 3.6600000000000001E+00 + 49 0 0 0 + 0.0000000000000000E+00 0.0000000000000000E+00 4.9500000000000002E+00 + 50 0 0 0 + 0.0000000000000000E+00 -2.3999999999999999E+00 3.0000000000000000E+00 + 51 0 0 0 + 0.0000000000000000E+00 -4.0000000000000000E+00 2.7999999999999998E+00 + 52 0 0 0 + 0.0000000000000000E+00 0.0000000000000000E+00 1.7609999999999999E+01 + 53 0 0 0 + 0.0000000000000000E+00 2.3999999999999999E+00 0.0000000000000000E+00 + 54 0 0 0 + 0.0000000000000000E+00 4.0000000000000000E+00 0.0000000000000000E+00 + 55 0 0 0 + 0.0000000000000000E+00 5.5999999999999996E+00 0.0000000000000000E+00 + 56 0 0 0 + 0.0000000000000000E+00 8.0000000000000000E+00 0.0000000000000000E+00 + 57 0 0 0 + 0.0000000000000000E+00 1.0400000000000000E+01 0.0000000000000000E+00 + 58 0 0 0 + 0.0000000000000000E+00 1.2000000000000000E+01 0.0000000000000000E+00 + 59 0 0 0 + 0.0000000000000000E+00 1.4350000000000000E+01 0.0000000000000000E+00 + 60 0 0 0 + 0.0000000000000000E+00 1.5500000000000000E+01 5.0000000000000000E-01 + 61 0 0 0 + 0.0000000000000000E+00 1.6129999999999999E+01 1.7000000000000000E+00 + 62 0 0 0 + 0.0000000000000000E+00 1.6129999999999999E+01 3.3500000000000001E+00 + 63 0 0 0 + 0.0000000000000000E+00 1.6129999999999999E+01 4.9500000000000002E+00 + 64 0 0 0 + 0.0000000000000000E+00 1.6129999999999999E+01 7.1550000000000002E+00 + 65 0 0 0 + 0.0000000000000000E+00 1.6129999999999999E+01 9.3599999999999994E+00 + 66 0 0 0 + 0.0000000000000000E+00 1.6129999999999999E+01 1.2359999999999999E+01 + 67 0 0 0 + 0.0000000000000000E+00 1.6129999999999999E+01 1.5359999999999999E+01 + 68 0 0 0 + 0.0000000000000000E+00 1.6129999999999999E+01 1.7609999999999999E+01 + 69 0 0 0 + 0.0000000000000000E+00 1.6129999999999999E+01 1.8969999999999999E+01 + 70 0 0 0 + 0.0000000000000000E+00 1.6129999999999999E+01 2.0800000000000001E+01 + 71 0 0 0 + 0.0000000000000000E+00 0.0000000000000000E+00 2.1449999999999999E+01 + 72 0 0 0 + 0.0000000000000000E+00 2.3999999999999999E+00 2.1449999999999999E+01 + 73 0 0 0 + 0.0000000000000000E+00 4.0000000000000000E+00 2.1449999999999999E+01 + 74 0 0 0 + 0.0000000000000000E+00 5.5999999999999996E+00 2.1366000000000000E+01 + 75 0 0 0 + 0.0000000000000000E+00 8.0000000000000000E+00 2.1239000000000001E+01 + 76 0 0 0 + 0.0000000000000000E+00 1.0400000000000000E+01 2.1111999999999998E+01 + 77 0 0 0 + 0.0000000000000000E+00 1.2000000000000000E+01 2.1027999999999999E+01 + 78 0 0 0 + 0.0000000000000000E+00 1.4130000000000001E+01 2.0916000000000000E+01 + 79 0 0 0 + 0.0000000000000000E+00 2.3999999999999999E+00 2.0000000000000000E+00 + 80 0 0 0 + 0.0000000000000000E+00 4.0000000000000000E+00 2.0000000000000000E+00 + 81 0 0 0 + 0.0000000000000000E+00 5.5999999999999996E+00 2.0000000000000000E+00 + 82 0 0 0 + 0.0000000000000000E+00 8.0000000000000000E+00 2.0000000000000000E+00 + 83 0 0 0 + 0.0000000000000000E+00 1.0400000000000000E+01 2.0000000000000000E+00 + 84 0 0 0 + 0.0000000000000000E+00 1.2000000000000000E+01 2.0000000000000000E+00 + 85 0 0 0 + 0.0000000000000000E+00 1.2877000000000001E+01 3.2160000000000002E+00 + 86 0 0 0 + 0.0000000000000000E+00 1.4130000000000001E+01 4.9500000000000002E+00 + 87 0 0 0 + 0.0000000000000000E+00 1.4130000000000001E+01 7.1550000000000002E+00 + 88 0 0 0 + 0.0000000000000000E+00 1.4130000000000001E+01 9.3599999999999994E+00 + 89 0 0 0 + 0.0000000000000000E+00 1.4130000000000001E+01 1.2359999999999999E+01 + 90 0 0 0 + 0.0000000000000000E+00 1.4130000000000001E+01 1.5359999999999999E+01 + 91 0 0 0 + 0.0000000000000000E+00 1.4130000000000001E+01 1.7609999999999999E+01 + 92 0 0 0 + 0.0000000000000000E+00 1.4130000000000001E+01 1.8969999999999999E+01 + 93 0 0 0 + 0.0000000000000000E+00 1.3600000000000000E+01 2.0000000000000000E+00 + 94 0 0 0 + 0.0000000000000000E+00 1.5199999999999999E+01 3.8500000000000001E+00 + 95 0 0 0 + 0.0000000000000000E+00 1.4500000000000000E+01 3.8500000000000001E+00 + 96 0 0 0 + 0.0000000000000000E+00 1.4150000000000000E+01 3.1040000000000001E+00 + 97 0 0 0 + 0.0000000000000000E+00 1.5199999999999999E+01 2.0000000000000000E+00 + 98 0 0 0 + 0.0000000000000000E+00 2.3999999999999999E+00 3.6600000000000001E+00 + 99 0 0 0 + 0.0000000000000000E+00 2.3999999999999999E+00 4.9500000000000002E+00 + 100 0 0 0 + 0.0000000000000000E+00 4.0000000000000000E+00 3.0000000000000000E+00 + 101 0 0 0 + 0.0000000000000000E+00 0.0000000000000000E+00 7.1550000000000002E+00 + 102 0 0 0 + 0.0000000000000000E+00 0.0000000000000000E+00 9.3599999999999994E+00 + 103 0 0 0 + 0.0000000000000000E+00 0.0000000000000000E+00 1.2359999999999999E+01 + 104 0 0 0 + 0.0000000000000000E+00 0.0000000000000000E+00 1.5359999999999999E+01 + 105 0 0 0 + 0.0000000000000000E+00 2.3999999999999999E+00 7.1550000000000002E+00 + 106 0 0 0 + 0.0000000000000000E+00 2.3999999999999999E+00 9.3599999999999994E+00 + 107 0 0 0 + 0.0000000000000000E+00 2.3999999999999999E+00 1.2359999999999999E+01 + 108 0 0 0 + 0.0000000000000000E+00 2.3999999999999999E+00 1.5359999999999999E+01 + 109 0 0 0 + 0.0000000000000000E+00 2.3999999999999999E+00 1.7609999999999999E+01 + 110 0 0 0 + 0.0000000000000000E+00 -1.2000000000000000E+01 3.2149999999999999E+00 + 111 0 0 0 + 0.0000000000000000E+00 -5.5999999999999996E+00 3.2149999999999999E+00 + 112 0 0 0 + 0.0000000000000000E+00 -8.0000000000000000E+00 3.2149999999999999E+00 + 113 0 0 0 + 0.0000000000000000E+00 -1.0400000000000000E+01 3.2149999999999999E+00 + 114 0 0 0 + 0.0000000000000000E+00 1.2000000000000000E+01 3.2149999999999999E+00 + 115 0 0 0 + 0.0000000000000000E+00 5.5999999999999996E+00 3.2149999999999999E+00 + 116 0 0 0 + 0.0000000000000000E+00 8.0000000000000000E+00 3.2149999999999999E+00 + 117 0 0 0 + 0.0000000000000000E+00 1.0400000000000000E+01 3.2149999999999999E+00 + 118 0 0 0 + 0.0000000000000000E+00 2.3999999999999999E+00 1.8969999999999999E+01 + 119 0 0 0 + 0.0000000000000000E+00 -1.2877000000000001E+01 4.9500000000000002E+00 + 120 0 0 0 + 0.0000000000000000E+00 -2.3999999999999999E+00 4.9500000000000002E+00 + 121 0 0 0 + 0.0000000000000000E+00 1.2877000000000001E+01 4.9500000000000002E+00 + 122 0 0 0 + 0.0000000000000000E+00 4.0000000000000000E+00 4.9500000000000002E+00 + 123 0 0 0 + 0.0000000000000000E+00 -1.2000000000000000E+01 4.9500000000000002E+00 + 124 0 0 0 + 0.0000000000000000E+00 -2.3999999999999999E+00 7.1550000000000002E+00 + 125 0 0 0 + 0.0000000000000000E+00 -1.2000000000000000E+01 1.7609999999999999E+01 + 126 0 0 0 + 0.0000000000000000E+00 -2.3999999999999999E+00 1.7609999999999999E+01 + 127 0 0 0 + 0.0000000000000000E+00 4.0000000000000000E+00 7.1550000000000002E+00 + 128 0 0 0 + 0.0000000000000000E+00 1.2000000000000000E+01 1.7609999999999999E+01 + 129 0 0 0 + 0.0000000000000000E+00 1.2000000000000000E+01 4.9500000000000002E+00 + 130 0 0 0 + 0.0000000000000000E+00 4.0000000000000000E+00 1.7609999999999999E+01 + 131 0 0 0 + 0.0000000000000000E+00 -1.2000000000000000E+01 7.1550000000000002E+00 + 132 0 0 0 + 0.0000000000000000E+00 1.2000000000000000E+01 7.1550000000000002E+00 + 133 0 0 0 + 0.0000000000000000E+00 -4.0000000000000000E+00 4.9500000000000002E+00 + 134 0 0 0 + 0.0000000000000000E+00 5.5999999999999996E+00 4.9500000000000002E+00 + 135 0 0 0 + 0.0000000000000000E+00 -1.0400000000000000E+01 4.9500000000000002E+00 + 136 0 0 0 + 0.0000000000000000E+00 -2.3999999999999999E+00 9.3599999999999994E+00 + 137 0 0 0 + 0.0000000000000000E+00 -2.3999999999999999E+00 1.2359999999999999E+01 + 138 0 0 0 + 0.0000000000000000E+00 -2.3999999999999999E+00 1.5359999999999999E+01 + 139 0 0 0 + 0.0000000000000000E+00 1.0400000000000000E+01 4.9500000000000002E+00 + 140 0 0 0 + 0.0000000000000000E+00 8.0000000000000000E+00 4.9500000000000002E+00 + 141 0 0 0 + 0.0000000000000000E+00 -1.2000000000000000E+01 1.5359999999999999E+01 + 142 0 0 0 + 0.0000000000000000E+00 -1.2000000000000000E+01 1.2359999999999999E+01 + 143 0 0 0 + 0.0000000000000000E+00 -1.2000000000000000E+01 9.3599999999999994E+00 + 144 0 0 0 + 0.0000000000000000E+00 4.0000000000000000E+00 9.3599999999999994E+00 + 145 0 0 0 + 0.0000000000000000E+00 4.0000000000000000E+00 1.2359999999999999E+01 + 146 0 0 0 + 0.0000000000000000E+00 4.0000000000000000E+00 1.5359999999999999E+01 + 147 0 0 0 + 0.0000000000000000E+00 1.2000000000000000E+01 1.5359999999999999E+01 + 148 0 0 0 + 0.0000000000000000E+00 1.2000000000000000E+01 1.2359999999999999E+01 + 149 0 0 0 + 0.0000000000000000E+00 1.2000000000000000E+01 9.3599999999999994E+00 + 150 0 0 0 + 0.0000000000000000E+00 -8.0000000000000000E+00 4.9500000000000002E+00 + 151 0 0 0 + 0.0000000000000000E+00 -5.5999999999999996E+00 4.9500000000000002E+00 + 152 0 0 0 + 0.0000000000000000E+00 4.0000000000000000E+00 1.8969999999999999E+01 + 153 0 0 0 + 0.0000000000000000E+00 5.5999999999999996E+00 1.8969999999999999E+01 + 154 0 0 0 + 0.0000000000000000E+00 8.0000000000000000E+00 1.8969999999999999E+01 + 155 0 0 0 + 0.0000000000000000E+00 1.0400000000000000E+01 1.8969999999999999E+01 + 156 0 0 0 + 0.0000000000000000E+00 1.2000000000000000E+01 1.8969999999999999E+01 + 157 0 0 0 + 0.0000000000000000E+00 -2.3999999999999999E+00 1.8969999999999999E+01 + 158 0 0 0 + 0.0000000000000000E+00 -4.0000000000000000E+00 1.8969999999999999E+01 + 159 0 0 0 + 0.0000000000000000E+00 -5.5999999999999996E+00 1.8969999999999999E+01 + 160 0 0 0 + 0.0000000000000000E+00 -8.0000000000000000E+00 1.8969999999999999E+01 + 161 0 0 0 + 0.0000000000000000E+00 -1.0400000000000000E+01 1.8969999999999999E+01 + 162 0 0 0 + 0.0000000000000000E+00 -1.2000000000000000E+01 1.8969999999999999E+01 + 163 0 0 0 + 3.3999999999999999E+00 -4.0000000000000000E+00 0.0000000000000000E+00 + 164 0 0 0 + 3.3999999999999999E+00 -2.3999999999999999E+00 0.0000000000000000E+00 + 165 0 0 0 + 3.3999999999999999E+00 4.0000000000000000E+00 0.0000000000000000E+00 + 166 0 0 0 + 3.3999999999999999E+00 2.3999999999999999E+00 0.0000000000000000E+00 + 167 0 0 0 + 3.3999999999999999E+00 0.0000000000000000E+00 0.0000000000000000E+00 + 168 0 0 0 + 3.3999999999999999E+00 0.0000000000000000E+00 3.6600000000000001E+00 + 169 0 0 0 + 3.3999999999999999E+00 -5.5999999999999996E+00 0.0000000000000000E+00 + 170 0 0 0 + 3.3999999999999999E+00 -8.0000000000000000E+00 0.0000000000000000E+00 + 171 0 0 0 + 3.3999999999999999E+00 -1.0400000000000000E+01 0.0000000000000000E+00 + 172 0 0 0 + 3.3999999999999999E+00 -4.0000000000000000E+00 2.0000000000000000E+00 + 173 0 0 0 + 3.3999999999999999E+00 -2.3999999999999999E+00 2.0000000000000000E+00 + 174 0 0 0 + 3.3999999999999999E+00 0.0000000000000000E+00 2.0000000000000000E+00 + 175 0 0 0 + 3.3999999999999999E+00 2.3999999999999999E+00 2.0000000000000000E+00 + 176 0 0 0 + 3.3999999999999999E+00 4.0000000000000000E+00 2.0000000000000000E+00 + 177 0 0 0 + 3.3999999999999999E+00 5.5999999999999996E+00 0.0000000000000000E+00 + 178 0 0 0 + 3.3999999999999999E+00 8.0000000000000000E+00 0.0000000000000000E+00 + 179 0 0 0 + 3.3999999999999999E+00 1.0400000000000000E+01 0.0000000000000000E+00 + 180 0 0 0 + 3.3999999999999999E+00 -2.3999999999999999E+00 3.0000000000000000E+00 + 181 0 0 0 + 0.0000000000000000E+00 -4.0000000000000000E+00 7.1550000000000002E+00 + 182 0 0 0 + 3.3999999999999999E+00 0.0000000000000000E+00 7.1550000000000002E+00 + 183 0 0 0 + 3.3999999999999999E+00 -8.0000000000000000E+00 2.0000000000000000E+00 + 184 0 0 0 + 3.3999999999999999E+00 -1.0400000000000000E+01 2.0000000000000000E+00 + 185 0 0 0 + 3.3999999999999999E+00 2.3999999999999999E+00 3.6600000000000001E+00 + 186 0 0 0 + 3.3999999999999999E+00 -1.2000000000000000E+01 0.0000000000000000E+00 + 187 0 0 0 + 3.3999999999999999E+00 -1.2000000000000000E+01 2.0000000000000000E+00 + 188 0 0 0 + 3.3999999999999999E+00 -1.4350000000000000E+01 0.0000000000000000E+00 + 189 0 0 0 + 0.0000000000000000E+00 -1.0400000000000000E+01 1.7609999999999999E+01 + 190 0 0 0 + 3.3999999999999999E+00 -1.2877000000000001E+01 3.2160000000000002E+00 + 191 0 0 0 + 3.3999999999999999E+00 -1.5500000000000000E+01 5.0000000000000000E-01 + 192 0 0 0 + 0.0000000000000000E+00 -4.0000000000000000E+00 1.7609999999999999E+01 + 193 0 0 0 + 3.3999999999999999E+00 2.3999999999999999E+00 1.9800000000000001E+01 + 194 0 0 0 + 3.3999999999999999E+00 -1.6129999999999999E+01 1.7000000000000000E+00 + 195 0 0 0 + 3.3999999999999999E+00 -1.6129999999999999E+01 3.3500000000000001E+00 + 196 0 0 0 + 3.3999999999999999E+00 8.0000000000000000E+00 2.0000000000000000E+00 + 197 0 0 0 + 0.0000000000000000E+00 5.5999999999999996E+00 7.1550000000000002E+00 + 198 0 0 0 + 0.0000000000000000E+00 8.0000000000000000E+00 7.1550000000000002E+00 + 199 0 0 0 + 0.0000000000000000E+00 1.0400000000000000E+01 7.1550000000000002E+00 + 200 0 0 0 + 3.3999999999999999E+00 1.2000000000000000E+01 0.0000000000000000E+00 + 201 0 0 0 + 3.3999999999999999E+00 1.0400000000000000E+01 2.0000000000000000E+00 + 202 0 0 0 + 0.0000000000000000E+00 1.0400000000000000E+01 1.7609999999999999E+01 + 203 0 0 0 + 0.0000000000000000E+00 8.0000000000000000E+00 1.7609999999999999E+01 + 204 0 0 0 + 0.0000000000000000E+00 5.5999999999999996E+00 1.7609999999999999E+01 + 205 0 0 0 + 3.3999999999999999E+00 1.4350000000000000E+01 0.0000000000000000E+00 + 206 0 0 0 + 3.3999999999999999E+00 -1.6129999999999999E+01 4.9500000000000002E+00 + 207 0 0 0 + 3.3999999999999999E+00 1.2000000000000000E+01 2.0000000000000000E+00 + 208 0 0 0 + 3.3999999999999999E+00 1.5500000000000000E+01 5.0000000000000000E-01 + 209 0 0 0 + 3.3999999999999999E+00 -1.6129999999999999E+01 7.1550000000000002E+00 + 210 0 0 0 + 3.3999999999999999E+00 0.0000000000000000E+00 1.2359999999999999E+01 + 211 0 0 0 + 0.0000000000000000E+00 -1.0400000000000000E+01 7.1550000000000002E+00 + 212 0 0 0 + 3.3999999999999999E+00 1.2877000000000001E+01 3.2160000000000002E+00 + 213 0 0 0 + 3.3999999999999999E+00 1.6129999999999999E+01 1.7000000000000000E+00 + 214 0 0 0 + 3.3999999999999999E+00 1.6129999999999999E+01 3.3500000000000001E+00 + 215 0 0 0 + 3.3999999999999999E+00 -1.4130000000000001E+01 7.1550000000000002E+00 + 216 0 0 0 + 3.3999999999999999E+00 -1.4130000000000001E+01 4.9500000000000002E+00 + 217 0 0 0 + 3.3999999999999999E+00 -1.6129999999999999E+01 9.3599999999999994E+00 + 218 0 0 0 + 3.3999999999999999E+00 -1.6129999999999999E+01 1.2359999999999999E+01 + 219 0 0 0 + 3.3999999999999999E+00 1.6129999999999999E+01 4.9500000000000002E+00 + 220 0 0 0 + 3.3999999999999999E+00 1.6129999999999999E+01 7.1550000000000002E+00 + 221 0 0 0 + 3.3999999999999999E+00 1.4130000000000001E+01 7.1550000000000002E+00 + 222 0 0 0 + 3.3999999999999999E+00 1.4130000000000001E+01 4.9500000000000002E+00 + 223 0 0 0 + 3.3999999999999999E+00 -1.4130000000000001E+01 1.2359999999999999E+01 + 224 0 0 0 + 3.3999999999999999E+00 -1.4130000000000001E+01 9.3599999999999994E+00 + 225 0 0 0 + 3.3999999999999999E+00 -1.6129999999999999E+01 1.5359999999999999E+01 + 226 0 0 0 + 3.3999999999999999E+00 -1.6129999999999999E+01 1.7609999999999999E+01 + 227 0 0 0 + 3.3999999999999999E+00 -1.6129999999999999E+01 1.8969999999999999E+01 + 228 0 0 0 + 3.3999999999999999E+00 -1.6129999999999999E+01 2.0800000000000001E+01 + 229 0 0 0 + 3.3999999999999999E+00 1.6129999999999999E+01 9.3599999999999994E+00 + 230 0 0 0 + 3.3999999999999999E+00 1.6129999999999999E+01 1.2359999999999999E+01 + 231 0 0 0 + 3.3999999999999999E+00 1.4130000000000001E+01 1.2359999999999999E+01 + 232 0 0 0 + 3.3999999999999999E+00 1.4130000000000001E+01 9.3599999999999994E+00 + 233 0 0 0 + 3.3999999999999999E+00 -1.4130000000000001E+01 1.5359999999999999E+01 + 234 0 0 0 + 3.3999999999999999E+00 1.6129999999999999E+01 1.5359999999999999E+01 + 235 0 0 0 + 3.3999999999999999E+00 1.6129999999999999E+01 1.7609999999999999E+01 + 236 0 0 0 + 3.3999999999999999E+00 1.6129999999999999E+01 1.8969999999999999E+01 + 237 0 0 0 + 3.3999999999999999E+00 1.6129999999999999E+01 2.0800000000000001E+01 + 238 0 0 0 + 3.3999999999999999E+00 -1.4130000000000001E+01 2.0916000000000000E+01 + 239 0 0 0 + 3.3999999999999999E+00 -1.4130000000000001E+01 1.8969999999999999E+01 + 240 0 0 0 + 3.3999999999999999E+00 -1.2000000000000000E+01 2.1027999999999999E+01 + 241 0 0 0 + 3.3999999999999999E+00 -1.0400000000000000E+01 2.1111999999999998E+01 + 242 0 0 0 + 3.3999999999999999E+00 -8.0000000000000000E+00 2.1239000000000001E+01 + 243 0 0 0 + 3.3999999999999999E+00 -5.5999999999999996E+00 2.1366000000000000E+01 + 244 0 0 0 + 3.3999999999999999E+00 -4.0000000000000000E+00 2.1449999999999999E+01 + 245 0 0 0 + 3.3999999999999999E+00 -2.3999999999999999E+00 2.1449999999999999E+01 + 246 0 0 0 + 3.3999999999999999E+00 0.0000000000000000E+00 2.1449999999999999E+01 + 247 0 0 0 + 3.3999999999999999E+00 2.3999999999999999E+00 2.1449999999999999E+01 + 248 0 0 0 + 0.0000000000000000E+00 -8.0000000000000000E+00 1.7609999999999999E+01 + 249 0 0 0 + 0.0000000000000000E+00 -5.5999999999999996E+00 1.7609999999999999E+01 + 250 0 0 0 + 3.3999999999999999E+00 4.0000000000000000E+00 2.1449999999999999E+01 + 251 0 0 0 + 3.3999999999999999E+00 5.5999999999999996E+00 2.1366000000000000E+01 + 252 0 0 0 + 3.3999999999999999E+00 8.0000000000000000E+00 2.1239000000000001E+01 + 253 0 0 0 + 3.3999999999999999E+00 1.0400000000000000E+01 2.1111999999999998E+01 + 254 0 0 0 + 3.3999999999999999E+00 1.2000000000000000E+01 2.1027999999999999E+01 + 255 0 0 0 + 3.3999999999999999E+00 1.4130000000000001E+01 2.0916000000000000E+01 + 256 0 0 0 + 3.3999999999999999E+00 1.4130000000000001E+01 1.8969999999999999E+01 + 257 0 0 0 + 0.0000000000000000E+00 -5.5999999999999996E+00 7.1550000000000002E+00 + 258 0 0 0 + 0.0000000000000000E+00 -8.0000000000000000E+00 7.1550000000000002E+00 + 259 0 0 0 + 3.3999999999999999E+00 1.4130000000000001E+01 1.5359999999999999E+01 + 260 0 0 0 + 2.2000000000000002E+00 2.3999999999999999E+00 4.9500000000000002E+00 + 261 0 0 0 + 3.3999999999999999E+00 0.0000000000000000E+00 9.3599999999999994E+00 + 262 0 0 0 + 2.2000000000000002E+00 2.3999999999999999E+00 9.3599999999999994E+00 + 263 0 0 0 + 3.3999999999999999E+00 0.0000000000000000E+00 1.5359999999999999E+01 + 264 0 0 0 + 2.2000000000000002E+00 2.3999999999999999E+00 1.5359999999999999E+01 + 265 0 0 0 + 3.3999999999999999E+00 0.0000000000000000E+00 1.7609999999999999E+01 + 266 0 0 0 + 3.3999999999999999E+00 -1.4130000000000001E+01 1.7609999999999999E+01 + 267 0 0 0 + 3.3999999999999999E+00 1.4130000000000001E+01 1.7609999999999999E+01 + 268 0 0 0 + 2.2000000000000002E+00 -1.2877000000000001E+01 4.9500000000000002E+00 + 269 0 0 0 + 2.2000000000000002E+00 -2.3999999999999999E+00 4.9500000000000002E+00 + 270 0 0 0 + 2.2000000000000002E+00 1.2877000000000001E+01 4.9500000000000002E+00 + 271 0 0 0 + 2.2000000000000002E+00 4.0000000000000000E+00 4.9500000000000002E+00 + 272 0 0 0 + 0.0000000000000000E+00 -4.0000000000000000E+00 9.3599999999999994E+00 + 273 0 0 0 + 0.0000000000000000E+00 -4.0000000000000000E+00 1.2359999999999999E+01 + 274 0 0 0 + 0.0000000000000000E+00 -4.0000000000000000E+00 1.5359999999999999E+01 + 275 0 0 0 + 0.0000000000000000E+00 -1.0400000000000000E+01 1.5359999999999999E+01 + 276 0 0 0 + 0.0000000000000000E+00 -1.0400000000000000E+01 1.2359999999999999E+01 + 277 0 0 0 + 3.3999999999999999E+00 -5.5999999999999996E+00 2.0000000000000000E+00 + 278 0 0 0 + 3.3999999999999999E+00 0.0000000000000000E+00 4.9500000000000002E+00 + 279 0 0 0 + 0.0000000000000000E+00 -1.0400000000000000E+01 9.3599999999999994E+00 + 280 0 0 0 + 0.0000000000000000E+00 5.5999999999999996E+00 9.3599999999999994E+00 + 281 0 0 0 + 0.0000000000000000E+00 5.5999999999999996E+00 1.2359999999999999E+01 + 282 0 0 0 + 0.0000000000000000E+00 5.5999999999999996E+00 1.5359999999999999E+01 + 283 0 0 0 + 0.0000000000000000E+00 1.0400000000000000E+01 1.2359999999999999E+01 + 284 0 0 0 + 0.0000000000000000E+00 8.0000000000000000E+00 1.2359999999999999E+01 + 285 0 0 0 + 0.0000000000000000E+00 1.0400000000000000E+01 1.5359999999999999E+01 + 286 0 0 0 + 0.0000000000000000E+00 8.0000000000000000E+00 1.5359999999999999E+01 + 287 0 0 0 + 0.0000000000000000E+00 1.0400000000000000E+01 9.3599999999999994E+00 + 288 0 0 0 + 0.0000000000000000E+00 8.0000000000000000E+00 9.3599999999999994E+00 + 289 0 0 0 + 3.3999999999999999E+00 5.5999999999999996E+00 2.0000000000000000E+00 + 290 0 0 0 + 2.2000000000000002E+00 -2.3999999999999999E+00 9.3599999999999994E+00 + 291 0 0 0 + 2.2000000000000002E+00 -2.3999999999999999E+00 1.5359999999999999E+01 + 292 0 0 0 + 2.2000000000000002E+00 -1.2000000000000000E+01 4.9500000000000002E+00 + 293 0 0 0 + 2.2000000000000002E+00 -1.2000000000000000E+01 1.5359999999999999E+01 + 294 0 0 0 + 3.3999999999999999E+00 -2.3999999999999999E+00 1.9800000000000001E+01 + 295 0 0 0 + 2.2000000000000002E+00 -1.2000000000000000E+01 9.3599999999999994E+00 + 296 0 0 0 + 2.2000000000000002E+00 4.0000000000000000E+00 9.3599999999999994E+00 + 297 0 0 0 + 3.3999999999999999E+00 -1.2000000000000000E+01 1.9527999999999999E+01 + 298 0 0 0 + 2.2000000000000002E+00 4.0000000000000000E+00 1.5359999999999999E+01 + 299 0 0 0 + 2.2000000000000002E+00 1.2000000000000000E+01 1.5359999999999999E+01 + 300 0 0 0 + 2.2000000000000002E+00 1.2000000000000000E+01 4.9500000000000002E+00 + 301 0 0 0 + 2.2000000000000002E+00 1.2000000000000000E+01 9.3599999999999994E+00 + 302 0 0 0 + 3.3999999999999999E+00 -1.3600000000000000E+01 2.0000000000000000E+00 + 303 0 0 0 + 3.3999999999999999E+00 1.2000000000000000E+01 1.9527999999999999E+01 + 304 0 0 0 + 3.3999999999999999E+00 -4.0000000000000000E+00 2.7999999999999998E+00 + 305 0 0 0 + 3.3999999999999999E+00 -2.3999999999999999E+00 3.6600000000000001E+00 + 306 0 0 0 + 2.2000000000000002E+00 -4.0000000000000000E+00 4.9500000000000002E+00 + 307 0 0 0 + 3.3999999999999999E+00 1.3600000000000000E+01 2.0000000000000000E+00 + 308 0 0 0 + 2.2000000000000002E+00 5.5999999999999996E+00 4.9500000000000002E+00 + 309 0 0 0 + 2.2000000000000002E+00 1.0400000000000000E+01 4.9500000000000002E+00 + 310 0 0 0 + 2.2000000000000002E+00 8.0000000000000000E+00 4.9500000000000002E+00 + 311 0 0 0 + 2.2000000000000002E+00 -1.0400000000000000E+01 4.9500000000000002E+00 + 312 0 0 0 + 3.3999999999999999E+00 4.0000000000000000E+00 3.0000000000000000E+00 + 313 0 0 0 + 2.2000000000000002E+00 -8.0000000000000000E+00 4.9500000000000002E+00 + 314 0 0 0 + 2.2000000000000002E+00 -5.5999999999999996E+00 4.9500000000000002E+00 + 315 0 0 0 + 3.3999999999999999E+00 -1.5199999999999999E+01 2.0000000000000000E+00 + 316 0 0 0 + 3.3999999999999999E+00 -1.4150000000000000E+01 3.1040000000000001E+00 + 317 0 0 0 + 3.3999999999999999E+00 -4.0000000000000000E+00 1.9949999999999999E+01 + 318 0 0 0 + 3.3999999999999999E+00 -1.0400000000000000E+01 1.9611999999999998E+01 + 319 0 0 0 + 3.3999999999999999E+00 2.3999999999999999E+00 4.9500000000000002E+00 + 320 0 0 0 + 3.3999999999999999E+00 2.3999999999999999E+00 1.7609999999999999E+01 + 321 0 0 0 + 3.3999999999999999E+00 4.0000000000000000E+00 1.9949999999999999E+01 + 322 0 0 0 + 3.3999999999999999E+00 1.5199999999999999E+01 2.0000000000000000E+00 + 323 0 0 0 + 3.3999999999999999E+00 1.4150000000000000E+01 3.1040000000000001E+00 + 324 0 0 0 + 3.3999999999999999E+00 1.0400000000000000E+01 1.9611999999999998E+01 + 325 0 0 0 + 3.3999999999999999E+00 -1.5199999999999999E+01 3.8500000000000001E+00 + 326 0 0 0 + 3.3999999999999999E+00 -1.4500000000000000E+01 3.8500000000000001E+00 + 327 0 0 0 + 3.3999999999999999E+00 -8.0000000000000000E+00 1.9739000000000001E+01 + 328 0 0 0 + 3.3999999999999999E+00 -5.5999999999999996E+00 1.9866000000000000E+01 + 329 0 0 0 + 3.3999999999999999E+00 8.0000000000000000E+00 1.9739000000000001E+01 + 330 0 0 0 + 3.3999999999999999E+00 5.5999999999999996E+00 1.9866000000000000E+01 + 331 0 0 0 + 3.3999999999999999E+00 1.5199999999999999E+01 3.8500000000000001E+00 + 332 0 0 0 + 3.3999999999999999E+00 1.4500000000000000E+01 3.8500000000000001E+00 + 333 0 0 0 + 0.0000000000000000E+00 -8.0000000000000000E+00 1.5359999999999999E+01 + 334 0 0 0 + 0.0000000000000000E+00 -5.5999999999999996E+00 1.5359999999999999E+01 + 335 0 0 0 + 0.0000000000000000E+00 -8.0000000000000000E+00 1.2359999999999999E+01 + 336 0 0 0 + 0.0000000000000000E+00 -5.5999999999999996E+00 1.2359999999999999E+01 + 337 0 0 0 + 0.0000000000000000E+00 -8.0000000000000000E+00 9.3599999999999994E+00 + 338 0 0 0 + 0.0000000000000000E+00 -5.5999999999999996E+00 9.3599999999999994E+00 + 339 0 0 0 + 3.3999999999999999E+00 0.0000000000000000E+00 1.8969999999999999E+01 + 340 0 0 0 + 3.3999999999999999E+00 2.3999999999999999E+00 7.1550000000000002E+00 + 341 0 0 0 + 3.3999999999999999E+00 2.3999999999999999E+00 1.5359999999999999E+01 + 342 0 0 0 + 3.3999999999999999E+00 2.3999999999999999E+00 9.3599999999999994E+00 + 343 0 0 0 + 3.3999999999999999E+00 2.3999999999999999E+00 1.2359999999999999E+01 + 344 0 0 0 + 6.7999999999999998E+00 -2.3999999999999999E+00 0.0000000000000000E+00 + 345 0 0 0 + 6.7999999999999998E+00 -4.0000000000000000E+00 0.0000000000000000E+00 + 346 0 0 0 + 6.7999999999999998E+00 0.0000000000000000E+00 0.0000000000000000E+00 + 347 0 0 0 + 6.7999999999999998E+00 2.3999999999999999E+00 0.0000000000000000E+00 + 348 0 0 0 + 6.7999999999999998E+00 4.0000000000000000E+00 0.0000000000000000E+00 + 349 0 0 0 + 6.7999999999999998E+00 0.0000000000000000E+00 2.0000000000000000E+00 + 350 0 0 0 + 6.7999999999999998E+00 -2.3999999999999999E+00 2.0000000000000000E+00 + 351 0 0 0 + 6.7999999999999998E+00 0.0000000000000000E+00 3.6600000000000001E+00 + 352 0 0 0 + 6.7999999999999998E+00 2.3999999999999999E+00 2.0000000000000000E+00 + 353 0 0 0 + 6.7999999999999998E+00 -5.5999999999999996E+00 0.0000000000000000E+00 + 354 0 0 0 + 6.7999999999999998E+00 -4.0000000000000000E+00 2.0000000000000000E+00 + 355 0 0 0 + 6.7999999999999998E+00 -8.0000000000000000E+00 0.0000000000000000E+00 + 356 0 0 0 + 6.7999999999999998E+00 -1.0400000000000000E+01 0.0000000000000000E+00 + 357 0 0 0 + 6.7999999999999998E+00 5.5999999999999996E+00 0.0000000000000000E+00 + 358 0 0 0 + 6.7999999999999998E+00 4.0000000000000000E+00 2.0000000000000000E+00 + 359 0 0 0 + 6.7999999999999998E+00 8.0000000000000000E+00 0.0000000000000000E+00 + 360 0 0 0 + 6.7999999999999998E+00 1.0400000000000000E+01 0.0000000000000000E+00 + 361 0 0 0 + 6.7999999999999998E+00 -1.2000000000000000E+01 0.0000000000000000E+00 + 362 0 0 0 + 6.7999999999999998E+00 -8.0000000000000000E+00 2.0000000000000000E+00 + 363 0 0 0 + 6.7999999999999998E+00 -1.0400000000000000E+01 2.0000000000000000E+00 + 364 0 0 0 + 6.7999999999999998E+00 0.0000000000000000E+00 7.1550000000000002E+00 + 365 0 0 0 + 6.7999999999999998E+00 -1.2000000000000000E+01 2.0000000000000000E+00 + 366 0 0 0 + 6.7999999999999998E+00 -1.4350000000000000E+01 0.0000000000000000E+00 + 367 0 0 0 + 6.7999999999999998E+00 -1.2877000000000001E+01 3.2160000000000002E+00 + 368 0 0 0 + 6.7999999999999998E+00 -1.5500000000000000E+01 5.0000000000000000E-01 + 369 0 0 0 + 6.7999999999999998E+00 1.2000000000000000E+01 0.0000000000000000E+00 + 370 0 0 0 + 6.7999999999999998E+00 -1.6129999999999999E+01 1.7000000000000000E+00 + 371 0 0 0 + 6.7999999999999998E+00 8.0000000000000000E+00 2.0000000000000000E+00 + 372 0 0 0 + 2.2000000000000002E+00 -4.0000000000000000E+00 9.3599999999999994E+00 + 373 0 0 0 + 6.7999999999999998E+00 1.0400000000000000E+01 2.0000000000000000E+00 + 374 0 0 0 + 6.7999999999999998E+00 0.0000000000000000E+00 9.3599999999999994E+00 + 375 0 0 0 + 2.2000000000000002E+00 -4.0000000000000000E+00 1.5359999999999999E+01 + 376 0 0 0 + 6.7999999999999998E+00 -1.4130000000000001E+01 4.9500000000000002E+00 + 377 0 0 0 + 6.7999999999999998E+00 1.4350000000000000E+01 0.0000000000000000E+00 + 378 0 0 0 + 6.7999999999999998E+00 -1.6129999999999999E+01 3.3500000000000001E+00 + 379 0 0 0 + 6.7999999999999998E+00 1.2000000000000000E+01 2.0000000000000000E+00 + 380 0 0 0 + 6.7999999999999998E+00 -1.6129999999999999E+01 4.9500000000000002E+00 + 381 0 0 0 + 2.2000000000000002E+00 -1.0400000000000000E+01 1.5359999999999999E+01 + 382 0 0 0 + 6.7999999999999998E+00 1.5500000000000000E+01 5.0000000000000000E-01 + 383 0 0 0 + 2.2000000000000002E+00 -1.0400000000000000E+01 9.3599999999999994E+00 + 384 0 0 0 + 6.7999999999999998E+00 -1.6129999999999999E+01 7.1550000000000002E+00 + 385 0 0 0 + 2.2000000000000002E+00 5.5999999999999996E+00 9.3599999999999994E+00 + 386 0 0 0 + 2.2000000000000002E+00 1.0400000000000000E+01 9.3599999999999994E+00 + 387 0 0 0 + 2.2000000000000002E+00 8.0000000000000000E+00 9.3599999999999994E+00 + 388 0 0 0 + 6.7999999999999998E+00 1.2877000000000001E+01 3.2160000000000002E+00 + 389 0 0 0 + 2.2000000000000002E+00 5.5999999999999996E+00 1.5359999999999999E+01 + 390 0 0 0 + 2.2000000000000002E+00 1.0400000000000000E+01 1.5359999999999999E+01 + 391 0 0 0 + 2.2000000000000002E+00 8.0000000000000000E+00 1.5359999999999999E+01 + 392 0 0 0 + 6.7999999999999998E+00 1.6129999999999999E+01 1.7000000000000000E+00 + 393 0 0 0 + 6.7999999999999998E+00 -1.4130000000000001E+01 7.1550000000000002E+00 + 394 0 0 0 + 6.7999999999999998E+00 0.0000000000000000E+00 1.2359999999999999E+01 + 395 0 0 0 + 6.7999999999999998E+00 -1.6129999999999999E+01 9.3599999999999994E+00 + 396 0 0 0 + 6.7999999999999998E+00 1.6129999999999999E+01 3.3500000000000001E+00 + 397 0 0 0 + 6.7999999999999998E+00 1.4130000000000001E+01 4.9500000000000002E+00 + 398 0 0 0 + 6.7999999999999998E+00 -1.6129999999999999E+01 1.2359999999999999E+01 + 399 0 0 0 + 6.7999999999999998E+00 -1.4130000000000001E+01 9.3599999999999994E+00 + 400 0 0 0 + 6.7999999999999998E+00 1.6129999999999999E+01 4.9500000000000002E+00 + 401 0 0 0 + 6.7999999999999998E+00 0.0000000000000000E+00 1.5359999999999999E+01 + 402 0 0 0 + 6.7999999999999998E+00 1.6129999999999999E+01 7.1550000000000002E+00 + 403 0 0 0 + 6.7999999999999998E+00 1.4130000000000001E+01 7.1550000000000002E+00 + 404 0 0 0 + 6.7999999999999998E+00 -1.4130000000000001E+01 1.2359999999999999E+01 + 405 0 0 0 + 6.7999999999999998E+00 -1.6129999999999999E+01 1.5359999999999999E+01 + 406 0 0 0 + 6.7999999999999998E+00 1.6129999999999999E+01 9.3599999999999994E+00 + 407 0 0 0 + 6.7999999999999998E+00 1.4130000000000001E+01 9.3599999999999994E+00 + 408 0 0 0 + 6.7999999999999998E+00 -1.6129999999999999E+01 1.7609999999999999E+01 + 409 0 0 0 + 6.7999999999999998E+00 -1.4130000000000001E+01 1.5359999999999999E+01 + 410 0 0 0 + 6.7999999999999998E+00 -1.6129999999999999E+01 1.8969999999999999E+01 + 411 0 0 0 + 6.7999999999999998E+00 -1.6129999999999999E+01 2.0800000000000001E+01 + 412 0 0 0 + 6.7999999999999998E+00 1.6129999999999999E+01 1.2359999999999999E+01 + 413 0 0 0 + 6.7999999999999998E+00 1.4130000000000001E+01 1.2359999999999999E+01 + 414 0 0 0 + 6.7999999999999998E+00 1.6129999999999999E+01 1.5359999999999999E+01 + 415 0 0 0 + 6.7999999999999998E+00 1.6129999999999999E+01 1.7609999999999999E+01 + 416 0 0 0 + 6.7999999999999998E+00 1.6129999999999999E+01 1.8969999999999999E+01 + 417 0 0 0 + 6.7999999999999998E+00 -1.4130000000000001E+01 2.0916000000000000E+01 + 418 0 0 0 + 6.7999999999999998E+00 -1.4130000000000001E+01 1.8969999999999999E+01 + 419 0 0 0 + 6.7999999999999998E+00 1.6129999999999999E+01 2.0800000000000001E+01 + 420 0 0 0 + 6.7999999999999998E+00 1.4130000000000001E+01 1.5359999999999999E+01 + 421 0 0 0 + 6.7999999999999998E+00 -1.2000000000000000E+01 2.1027999999999999E+01 + 422 0 0 0 + 6.7999999999999998E+00 -1.0400000000000000E+01 2.1111999999999998E+01 + 423 0 0 0 + 6.7999999999999998E+00 -8.0000000000000000E+00 2.1239000000000001E+01 + 424 0 0 0 + 6.7999999999999998E+00 -5.5999999999999996E+00 2.1366000000000000E+01 + 425 0 0 0 + 6.7999999999999998E+00 -4.0000000000000000E+00 2.1449999999999999E+01 + 426 0 0 0 + 6.7999999999999998E+00 -2.3999999999999999E+00 2.1449999999999999E+01 + 427 0 0 0 + 6.7999999999999998E+00 0.0000000000000000E+00 2.1449999999999999E+01 + 428 0 0 0 + 6.7999999999999998E+00 2.3999999999999999E+00 2.1449999999999999E+01 + 429 0 0 0 + 6.7999999999999998E+00 1.4130000000000001E+01 2.0916000000000000E+01 + 430 0 0 0 + 6.7999999999999998E+00 1.4130000000000001E+01 1.8969999999999999E+01 + 431 0 0 0 + 6.7999999999999998E+00 4.0000000000000000E+00 2.1449999999999999E+01 + 432 0 0 0 + 6.7999999999999998E+00 1.2000000000000000E+01 2.1027999999999999E+01 + 433 0 0 0 + 6.7999999999999998E+00 1.0400000000000000E+01 2.1111999999999998E+01 + 434 0 0 0 + 6.7999999999999998E+00 5.5999999999999996E+00 2.1366000000000000E+01 + 435 0 0 0 + 6.7999999999999998E+00 8.0000000000000000E+00 2.1239000000000001E+01 + 436 0 0 0 + 6.7999999999999998E+00 0.0000000000000000E+00 4.9500000000000002E+00 + 437 0 0 0 + 6.7999999999999998E+00 -5.5999999999999996E+00 2.0000000000000000E+00 + 438 0 0 0 + 6.7999999999999998E+00 -2.3999999999999999E+00 3.0000000000000000E+00 + 439 0 0 0 + 6.7999999999999998E+00 5.5999999999999996E+00 2.0000000000000000E+00 + 440 0 0 0 + 6.7999999999999998E+00 2.3999999999999999E+00 3.6600000000000001E+00 + 441 0 0 0 + 2.2000000000000002E+00 -8.0000000000000000E+00 1.5359999999999999E+01 + 442 0 0 0 + 2.2000000000000002E+00 -5.5999999999999996E+00 1.5359999999999999E+01 + 443 0 0 0 + 2.2000000000000002E+00 -8.0000000000000000E+00 9.3599999999999994E+00 + 444 0 0 0 + 2.2000000000000002E+00 -5.5999999999999996E+00 9.3599999999999994E+00 + 445 0 0 0 + 6.7999999999999998E+00 0.0000000000000000E+00 1.7609999999999999E+01 + 446 0 0 0 + 6.7999999999999998E+00 -1.4130000000000001E+01 1.7609999999999999E+01 + 447 0 0 0 + 6.7999999999999998E+00 1.4130000000000001E+01 1.7609999999999999E+01 + 448 0 0 0 + 6.7999999999999998E+00 0.0000000000000000E+00 1.8969999999999999E+01 + 449 0 0 0 + 6.7999999999999998E+00 -4.0000000000000000E+00 2.7999999999999998E+00 + 450 0 0 0 + 6.7999999999999998E+00 -2.3999999999999999E+00 3.6600000000000001E+00 + 451 0 0 0 + 6.7999999999999998E+00 4.0000000000000000E+00 3.0000000000000000E+00 + 452 0 0 0 + 6.7999999999999998E+00 -1.3600000000000000E+01 2.0000000000000000E+00 + 453 0 0 0 + 1.0199999999999999E+01 -2.3999999999999999E+00 0.0000000000000000E+00 + 454 0 0 0 + 1.0199999999999999E+01 -4.0000000000000000E+00 0.0000000000000000E+00 + 455 0 0 0 + 1.0199999999999999E+01 0.0000000000000000E+00 0.0000000000000000E+00 + 456 0 0 0 + 1.0199999999999999E+01 2.3999999999999999E+00 0.0000000000000000E+00 + 457 0 0 0 + 1.0199999999999999E+01 4.0000000000000000E+00 0.0000000000000000E+00 + 458 0 0 0 + 6.7999999999999998E+00 2.3999999999999999E+00 4.9500000000000002E+00 + 459 0 0 0 + 1.0199999999999999E+01 -2.3999999999999999E+00 2.0000000000000000E+00 + 460 0 0 0 + 1.0199999999999999E+01 0.0000000000000000E+00 2.0000000000000000E+00 + 461 0 0 0 + 1.0199999999999999E+01 2.3999999999999999E+00 2.0000000000000000E+00 + 462 0 0 0 + 1.0199999999999999E+01 0.0000000000000000E+00 3.6600000000000001E+00 + 463 0 0 0 + 1.0199999999999999E+01 -5.5999999999999996E+00 0.0000000000000000E+00 + 464 0 0 0 + 6.7999999999999998E+00 2.3999999999999999E+00 1.9800000000000001E+01 + 465 0 0 0 + 1.0199999999999999E+01 -4.0000000000000000E+00 2.0000000000000000E+00 + 466 0 0 0 + 1.0199999999999999E+01 -8.0000000000000000E+00 0.0000000000000000E+00 + 467 0 0 0 + 1.0199999999999999E+01 5.5999999999999996E+00 0.0000000000000000E+00 + 468 0 0 0 + 6.7999999999999998E+00 1.3600000000000000E+01 2.0000000000000000E+00 + 469 0 0 0 + 1.0199999999999999E+01 -1.0400000000000000E+01 0.0000000000000000E+00 + 470 0 0 0 + 1.0199999999999999E+01 4.0000000000000000E+00 2.0000000000000000E+00 + 471 0 0 0 + 1.0199999999999999E+01 8.0000000000000000E+00 0.0000000000000000E+00 + 472 0 0 0 + 1.0199999999999999E+01 1.0400000000000000E+01 0.0000000000000000E+00 + 473 0 0 0 + 1.0199999999999999E+01 -1.2000000000000000E+01 0.0000000000000000E+00 + 474 0 0 0 + 6.7999999999999998E+00 2.3999999999999999E+00 7.1550000000000002E+00 + 475 0 0 0 + 1.0199999999999999E+01 -8.0000000000000000E+00 2.0000000000000000E+00 + 476 0 0 0 + 1.0199999999999999E+01 -1.0400000000000000E+01 2.0000000000000000E+00 + 477 0 0 0 + 6.7999999999999998E+00 -1.4150000000000000E+01 3.1040000000000001E+00 + 478 0 0 0 + 1.0199999999999999E+01 -1.2000000000000000E+01 2.0000000000000000E+00 + 479 0 0 0 + 1.0199999999999999E+01 -1.4350000000000000E+01 0.0000000000000000E+00 + 480 0 0 0 + 1.0199999999999999E+01 0.0000000000000000E+00 7.1550000000000002E+00 + 481 0 0 0 + 6.7999999999999998E+00 -1.5199999999999999E+01 2.0000000000000000E+00 + 482 0 0 0 + 6.7999999999999998E+00 -1.5199999999999999E+01 3.8500000000000001E+00 + 483 0 0 0 + 6.7999999999999998E+00 -1.4500000000000000E+01 3.8500000000000001E+00 + 484 0 0 0 + 1.0199999999999999E+01 1.2000000000000000E+01 0.0000000000000000E+00 + 485 0 0 0 + 1.0199999999999999E+01 -1.2877000000000001E+01 3.2160000000000002E+00 + 486 0 0 0 + 1.0199999999999999E+01 8.0000000000000000E+00 2.0000000000000000E+00 + 487 0 0 0 + 1.0199999999999999E+01 -1.5500000000000000E+01 5.0000000000000000E-01 + 488 0 0 0 + 1.0199999999999999E+01 1.0400000000000000E+01 2.0000000000000000E+00 + 489 0 0 0 + 6.7999999999999998E+00 2.3999999999999999E+00 9.3599999999999994E+00 + 490 0 0 0 + 1.0199999999999999E+01 -1.6129999999999999E+01 1.7000000000000000E+00 + 491 0 0 0 + 1.0199999999999999E+01 1.4350000000000000E+01 0.0000000000000000E+00 + 492 0 0 0 + 1.0199999999999999E+01 0.0000000000000000E+00 9.3599999999999994E+00 + 493 0 0 0 + 1.0199999999999999E+01 1.2000000000000000E+01 2.0000000000000000E+00 + 494 0 0 0 + 6.7999999999999998E+00 1.5199999999999999E+01 2.0000000000000000E+00 + 495 0 0 0 + 1.0199999999999999E+01 -1.4130000000000001E+01 4.9500000000000002E+00 + 496 0 0 0 + 6.7999999999999998E+00 1.4150000000000000E+01 3.1040000000000001E+00 + 497 0 0 0 + 1.0199999999999999E+01 -1.6129999999999999E+01 3.3500000000000001E+00 + 498 0 0 0 + 1.0199999999999999E+01 1.5500000000000000E+01 5.0000000000000000E-01 + 499 0 0 0 + 1.0199999999999999E+01 -1.6129999999999999E+01 4.9500000000000002E+00 + 500 0 0 0 + 6.7999999999999998E+00 1.5199999999999999E+01 3.8500000000000001E+00 + 501 0 0 0 + 6.7999999999999998E+00 1.4500000000000000E+01 3.8500000000000001E+00 + 502 0 0 0 + 6.7999999999999998E+00 -1.2000000000000000E+01 1.9527999999999999E+01 + 503 0 0 0 + 1.0199999999999999E+01 1.2877000000000001E+01 3.2160000000000002E+00 + 504 0 0 0 + 1.0199999999999999E+01 -1.4130000000000001E+01 7.1550000000000002E+00 + 505 0 0 0 + 1.0199999999999999E+01 -1.6129999999999999E+01 7.1550000000000002E+00 + 506 0 0 0 + 6.7999999999999998E+00 -2.3999999999999999E+00 1.9800000000000001E+01 + 507 0 0 0 + 1.0199999999999999E+01 1.6129999999999999E+01 1.7000000000000000E+00 + 508 0 0 0 + 1.0199999999999999E+01 0.0000000000000000E+00 1.2359999999999999E+01 + 509 0 0 0 + 6.7999999999999998E+00 2.3999999999999999E+00 1.2359999999999999E+01 + 510 0 0 0 + 1.0199999999999999E+01 -1.6129999999999999E+01 9.3599999999999994E+00 + 511 0 0 0 + 6.7999999999999998E+00 1.2000000000000000E+01 1.9527999999999999E+01 + 512 0 0 0 + 1.0199999999999999E+01 -1.4130000000000001E+01 9.3599999999999994E+00 + 513 0 0 0 + 6.7999999999999998E+00 2.3999999999999999E+00 1.5359999999999999E+01 + 514 0 0 0 + 1.0199999999999999E+01 1.4130000000000001E+01 4.9500000000000002E+00 + 515 0 0 0 + 1.0199999999999999E+01 -1.6129999999999999E+01 1.2359999999999999E+01 + 516 0 0 0 + 1.0199999999999999E+01 1.6129999999999999E+01 3.3500000000000001E+00 + 517 0 0 0 + 1.0199999999999999E+01 1.6129999999999999E+01 4.9500000000000002E+00 + 518 0 0 0 + 1.0199999999999999E+01 0.0000000000000000E+00 1.5359999999999999E+01 + 519 0 0 0 + 1.0199999999999999E+01 1.4130000000000001E+01 7.1550000000000002E+00 + 520 0 0 0 + 1.0199999999999999E+01 -1.4130000000000001E+01 1.2359999999999999E+01 + 521 0 0 0 + 1.0199999999999999E+01 1.6129999999999999E+01 7.1550000000000002E+00 + 522 0 0 0 + 1.0199999999999999E+01 -1.6129999999999999E+01 1.5359999999999999E+01 + 523 0 0 0 + 6.7999999999999998E+00 2.3999999999999999E+00 1.7609999999999999E+01 + 524 0 0 0 + 1.0199999999999999E+01 1.6129999999999999E+01 9.3599999999999994E+00 + 525 0 0 0 + 1.0199999999999999E+01 1.4130000000000001E+01 9.3599999999999994E+00 + 526 0 0 0 + 1.0199999999999999E+01 -1.4130000000000001E+01 1.5359999999999999E+01 + 527 0 0 0 + 1.0199999999999999E+01 -1.6129999999999999E+01 1.7609999999999999E+01 + 528 0 0 0 + 1.0199999999999999E+01 -5.5999999999999996E+00 2.0000000000000000E+00 + 529 0 0 0 + 1.0199999999999999E+01 1.6129999999999999E+01 1.2359999999999999E+01 + 530 0 0 0 + 1.0199999999999999E+01 0.0000000000000000E+00 4.9500000000000002E+00 + 531 0 0 0 + 1.0199999999999999E+01 -1.6129999999999999E+01 1.8969999999999999E+01 + 532 0 0 0 + 1.0199999999999999E+01 1.4130000000000001E+01 1.2359999999999999E+01 + 533 0 0 0 + 1.0199999999999999E+01 -1.6129999999999999E+01 2.0800000000000001E+01 + 534 0 0 0 + 1.0199999999999999E+01 5.5999999999999996E+00 2.0000000000000000E+00 + 536 0 0 0 + 6.7999999999999998E+00 -1.0400000000000000E+01 1.9611999999999998E+01 + 538 0 0 0 + 1.0199999999999999E+01 1.6129999999999999E+01 1.5359999999999999E+01 + 539 0 0 0 + 1.0199999999999999E+01 1.4130000000000001E+01 1.5359999999999999E+01 + 540 0 0 0 + 1.0199999999999999E+01 -1.4130000000000001E+01 1.8969999999999999E+01 + 541 0 0 0 + 1.0199999999999999E+01 -1.4130000000000001E+01 2.0916000000000000E+01 + 542 0 0 0 + 1.0199999999999999E+01 1.6129999999999999E+01 1.7609999999999999E+01 + 543 0 0 0 + 6.7999999999999998E+00 -4.0000000000000000E+00 1.9949999999999999E+01 + 544 0 0 0 + 1.0199999999999999E+01 1.6129999999999999E+01 1.8969999999999999E+01 + 545 0 0 0 + 6.7999999999999998E+00 -8.0000000000000000E+00 1.9739000000000001E+01 + 546 0 0 0 + 6.7999999999999998E+00 -5.5999999999999996E+00 1.9866000000000000E+01 + 547 0 0 0 + 1.0199999999999999E+01 -1.2000000000000000E+01 2.1027999999999999E+01 + 548 0 0 0 + 1.0199999999999999E+01 1.6129999999999999E+01 2.0800000000000001E+01 + 549 0 0 0 + 6.7999999999999998E+00 4.0000000000000000E+00 1.9949999999999999E+01 + 550 0 0 0 + 1.0199999999999999E+01 -1.0400000000000000E+01 2.1111999999999998E+01 + 551 0 0 0 + 6.7999999999999998E+00 1.0400000000000000E+01 1.9611999999999998E+01 + 552 0 0 0 + 6.7999999999999998E+00 8.0000000000000000E+00 1.9739000000000001E+01 + 553 0 0 0 + 6.7999999999999998E+00 5.5999999999999996E+00 1.9866000000000000E+01 + 554 0 0 0 + 1.0199999999999999E+01 1.4130000000000001E+01 1.8969999999999999E+01 + 555 0 0 0 + 1.0199999999999999E+01 1.4130000000000001E+01 2.0916000000000000E+01 + 556 0 0 0 + 1.0199999999999999E+01 0.0000000000000000E+00 2.1449999999999999E+01 + 557 0 0 0 + 1.0199999999999999E+01 -8.0000000000000000E+00 2.1239000000000001E+01 + 558 0 0 0 + 1.0199999999999999E+01 -2.3999999999999999E+00 2.1449999999999999E+01 + 559 0 0 0 + 1.0199999999999999E+01 -4.0000000000000000E+00 2.1449999999999999E+01 + 560 0 0 0 + 1.0199999999999999E+01 -5.5999999999999996E+00 2.1366000000000000E+01 + 561 0 0 0 + 1.0199999999999999E+01 2.3999999999999999E+00 2.1449999999999999E+01 + 562 0 0 0 + 1.0199999999999999E+01 1.2000000000000000E+01 2.1027999999999999E+01 + 563 0 0 0 + 1.0199999999999999E+01 4.0000000000000000E+00 2.1449999999999999E+01 + 564 0 0 0 + 1.0199999999999999E+01 1.0400000000000000E+01 2.1111999999999998E+01 + 565 0 0 0 + 1.0199999999999999E+01 5.5999999999999996E+00 2.1366000000000000E+01 + 566 0 0 0 + 1.0199999999999999E+01 8.0000000000000000E+00 2.1239000000000001E+01 + 569 0 0 0 + 1.0199999999999999E+01 0.0000000000000000E+00 1.7609999999999999E+01 + 570 0 0 0 + 1.0199999999999999E+01 -1.4130000000000001E+01 1.7609999999999999E+01 + 583 0 0 0 + 1.0199999999999999E+01 1.4130000000000001E+01 1.7609999999999999E+01 + 591 0 0 0 + 1.0199999999999999E+01 0.0000000000000000E+00 1.8969999999999999E+01 + 592 0 0 0 + 1.0199999999999999E+01 -3.2556229999999999E-02 9.5263449999999992E+00 + -1 + -1 + 2412 + 1 44 2 1 7 4 + 1 167 164 2 + 2 44 2 1 7 4 + 167 346 344 164 + 3 44 2 1 7 4 + 346 455 453 344 + 9 44 2 1 7 4 + 2 164 163 3 + 10 44 2 1 7 4 + 164 344 345 163 + 11 44 2 1 7 4 + 344 453 454 345 + 17 44 2 1 7 4 + 3 163 169 4 + 18 44 2 1 7 4 + 163 345 353 169 + 19 44 2 1 7 4 + 345 454 463 353 + 25 44 2 1 7 4 + 4 169 170 5 + 26 44 2 1 7 4 + 169 353 355 170 + 27 44 2 1 7 4 + 353 463 466 355 + 33 44 2 1 7 4 + 5 170 171 6 + 34 44 2 1 7 4 + 170 355 356 171 + 35 44 2 1 7 4 + 355 466 469 356 + 41 44 2 1 7 4 + 6 171 186 7 + 42 44 2 1 7 4 + 171 356 361 186 + 43 44 2 1 7 4 + 356 469 473 361 + 49 44 2 1 7 4 + 7 186 188 8 + 50 44 2 1 7 4 + 186 361 366 188 + 51 44 2 1 7 4 + 361 473 479 366 + 57 44 2 1 7 4 + 8 188 191 9 + 58 44 2 1 7 4 + 188 366 368 191 + 59 44 2 1 7 4 + 366 479 487 368 + 65 44 2 1 7 4 + 9 191 194 10 + 66 44 2 1 7 4 + 191 368 370 194 + 67 44 2 1 7 4 + 368 487 490 370 + 73 44 2 1 7 4 + 10 194 195 11 + 74 44 2 1 7 4 + 194 370 378 195 + 75 44 2 1 7 4 + 370 490 497 378 + 81 44 2 1 7 4 + 11 195 206 12 + 82 44 2 1 7 4 + 195 378 380 206 + 83 44 2 1 7 4 + 378 497 499 380 + 89 44 2 1 7 4 + 12 206 209 13 + 90 44 2 1 7 4 + 206 380 384 209 + 91 44 2 1 7 4 + 380 499 505 384 + 97 44 2 1 7 4 + 13 209 217 14 + 98 44 2 1 7 4 + 209 384 395 217 + 99 44 2 1 7 4 + 384 505 510 395 + 105 44 2 1 7 4 + 14 217 218 15 + 106 44 2 1 7 4 + 217 395 398 218 + 107 44 2 1 7 4 + 395 510 515 398 + 113 44 2 1 7 4 + 15 218 225 16 + 114 44 2 1 7 4 + 218 398 405 225 + 115 44 2 1 7 4 + 398 515 522 405 + 121 44 2 1 7 4 + 16 225 226 17 + 122 44 2 1 7 4 + 225 405 408 226 + 123 44 2 1 7 4 + 405 522 527 408 + 129 44 2 1 7 4 + 17 226 227 18 + 130 44 2 1 7 4 + 226 408 410 227 + 131 44 2 1 7 4 + 408 527 531 410 + 137 44 2 1 7 4 + 18 227 228 19 + 138 44 2 1 7 4 + 227 410 411 228 + 139 44 2 1 7 4 + 410 531 533 411 + 145 44 2 1 7 4 + 20 245 244 21 + 146 44 2 1 7 4 + 245 426 425 244 + 147 44 2 1 7 4 + 426 558 559 425 + 153 44 2 1 7 4 + 21 244 243 22 + 154 44 2 1 7 4 + 244 425 424 243 + 155 44 2 1 7 4 + 425 559 560 424 + 161 44 2 1 7 4 + 22 243 242 23 + 162 44 2 1 7 4 + 243 424 423 242 + 163 44 2 1 7 4 + 424 560 557 423 + 169 44 2 1 7 4 + 23 242 241 24 + 170 44 2 1 7 4 + 242 423 422 241 + 171 44 2 1 7 4 + 423 557 550 422 + 177 44 2 1 7 4 + 24 241 240 25 + 178 44 2 1 7 4 + 241 422 421 240 + 179 44 2 1 7 4 + 422 550 547 421 + 185 44 2 1 7 4 + 25 240 238 26 + 186 44 2 1 7 4 + 240 421 417 238 + 187 44 2 1 7 4 + 421 547 541 417 + 193 44 2 1 7 4 + 26 238 228 19 + 194 44 2 1 7 4 + 238 417 411 228 + 195 44 2 1 7 4 + 417 541 533 411 + 201 44 2 1 7 4 + 27 174 173 29 + 202 44 2 1 7 4 + 174 349 350 173 + 203 44 2 1 7 4 + 349 460 459 350 + 209 44 2 1 7 4 + 29 173 172 30 + 210 44 2 1 7 4 + 173 350 354 172 + 211 44 2 1 7 4 + 350 459 465 354 + 217 44 2 1 7 4 + 30 172 277 31 + 218 44 2 1 7 4 + 172 354 437 277 + 219 44 2 1 7 4 + 354 465 528 437 + 225 44 2 1 7 4 + 31 277 183 32 + 226 44 2 1 7 4 + 277 437 362 183 + 227 44 2 1 7 4 + 437 528 475 362 + 233 44 2 1 7 4 + 32 183 184 33 + 234 44 2 1 7 4 + 183 362 363 184 + 235 44 2 1 7 4 + 362 475 476 363 + 241 44 2 1 7 4 + 33 184 187 34 + 242 44 2 1 7 4 + 184 363 365 187 + 243 44 2 1 7 4 + 363 476 478 365 + 249 44 2 1 7 4 + 34 187 190 35 + 250 44 2 1 7 4 + 187 365 367 190 + 251 44 2 1 7 4 + 365 478 485 367 + 257 44 2 1 7 4 + 36 216 215 37 + 258 44 2 1 7 4 + 216 376 393 215 + 259 44 2 1 7 4 + 376 495 504 393 + 265 44 2 1 7 4 + 37 215 224 38 + 266 44 2 1 7 4 + 215 393 399 224 + 267 44 2 1 7 4 + 393 504 512 399 + 273 44 2 1 7 4 + 38 224 223 39 + 274 44 2 1 7 4 + 224 399 404 223 + 275 44 2 1 7 4 + 399 512 520 404 + 281 44 2 1 7 4 + 39 223 233 40 + 282 44 2 1 7 4 + 223 404 409 233 + 283 44 2 1 7 4 + 404 520 526 409 + 289 44 2 1 7 4 + 40 233 266 41 + 290 44 2 1 7 4 + 233 409 446 266 + 291 44 2 1 7 4 + 409 526 570 446 + 297 44 2 1 7 4 + 41 266 239 42 + 298 44 2 1 7 4 + 266 446 418 239 + 299 44 2 1 7 4 + 446 570 540 418 + 305 44 2 1 7 4 + 42 239 238 26 + 306 44 2 1 7 4 + 239 418 417 238 + 307 44 2 1 7 4 + 418 540 541 417 + 313 44 2 1 7 4 + 2 164 173 29 + 314 44 2 1 7 4 + 164 344 350 173 + 315 44 2 1 7 4 + 344 453 459 350 + 321 44 2 1 7 4 + 4 169 277 31 + 322 44 2 1 7 4 + 169 353 437 277 + 323 44 2 1 7 4 + 353 463 528 437 + 329 44 2 1 7 4 + 7 186 187 34 + 330 44 2 1 7 4 + 186 361 365 187 + 331 44 2 1 7 4 + 361 473 478 365 + 337 44 2 1 7 4 + 36 216 206 12 + 338 44 2 1 7 4 + 216 376 380 206 + 339 44 2 1 7 4 + 376 495 499 380 + 345 44 2 1 7 4 + 38 224 217 14 + 346 44 2 1 7 4 + 224 399 395 217 + 347 44 2 1 7 4 + 399 512 510 395 + 353 44 2 1 7 4 + 40 233 225 16 + 354 44 2 1 7 4 + 233 409 405 225 + 355 44 2 1 7 4 + 409 526 522 405 + 361 44 2 1 7 4 + 35 190 216 36 + 362 44 2 1 7 4 + 190 367 376 216 + 363 44 2 1 7 4 + 367 485 495 376 + 369 44 2 1 7 4 + 1 167 166 53 + 370 44 2 1 7 4 + 167 346 347 166 + 371 44 2 1 7 4 + 346 455 456 347 + 377 44 2 1 7 4 + 53 166 165 54 + 378 44 2 1 7 4 + 166 347 348 165 + 379 44 2 1 7 4 + 347 456 457 348 + 385 44 2 1 7 4 + 54 165 177 55 + 386 44 2 1 7 4 + 165 348 357 177 + 387 44 2 1 7 4 + 348 457 467 357 + 393 44 2 1 7 4 + 55 177 178 56 + 394 44 2 1 7 4 + 177 357 359 178 + 395 44 2 1 7 4 + 357 467 471 359 + 401 44 2 1 7 4 + 56 178 179 57 + 402 44 2 1 7 4 + 178 359 360 179 + 403 44 2 1 7 4 + 359 471 472 360 + 409 44 2 1 7 4 + 57 179 200 58 + 410 44 2 1 7 4 + 179 360 369 200 + 411 44 2 1 7 4 + 360 472 484 369 + 417 44 2 1 7 4 + 58 200 205 59 + 418 44 2 1 7 4 + 200 369 377 205 + 419 44 2 1 7 4 + 369 484 491 377 + 425 44 2 1 7 4 + 59 205 208 60 + 426 44 2 1 7 4 + 205 377 382 208 + 427 44 2 1 7 4 + 377 491 498 382 + 433 44 2 1 7 4 + 60 208 213 61 + 434 44 2 1 7 4 + 208 382 392 213 + 435 44 2 1 7 4 + 382 498 507 392 + 441 44 2 1 7 4 + 61 213 214 62 + 442 44 2 1 7 4 + 213 392 396 214 + 443 44 2 1 7 4 + 392 507 516 396 + 449 44 2 1 7 4 + 62 214 219 63 + 450 44 2 1 7 4 + 214 396 400 219 + 451 44 2 1 7 4 + 396 516 517 400 + 457 44 2 1 7 4 + 63 219 220 64 + 458 44 2 1 7 4 + 219 400 402 220 + 459 44 2 1 7 4 + 400 517 521 402 + 465 44 2 1 7 4 + 64 220 229 65 + 466 44 2 1 7 4 + 220 402 406 229 + 467 44 2 1 7 4 + 402 521 524 406 + 473 44 2 1 7 4 + 65 229 230 66 + 474 44 2 1 7 4 + 229 406 412 230 + 475 44 2 1 7 4 + 406 524 529 412 + 481 44 2 1 7 4 + 66 230 234 67 + 482 44 2 1 7 4 + 230 412 414 234 + 483 44 2 1 7 4 + 412 529 538 414 + 489 44 2 1 7 4 + 67 234 235 68 + 490 44 2 1 7 4 + 234 414 415 235 + 491 44 2 1 7 4 + 414 538 542 415 + 497 44 2 1 7 4 + 68 235 236 69 + 498 44 2 1 7 4 + 235 415 416 236 + 499 44 2 1 7 4 + 415 542 544 416 + 505 44 2 1 7 4 + 69 236 237 70 + 506 44 2 1 7 4 + 236 416 419 237 + 507 44 2 1 7 4 + 416 544 548 419 + 513 44 2 1 7 4 + 71 246 247 72 + 514 44 2 1 7 4 + 246 427 428 247 + 515 44 2 1 7 4 + 427 556 561 428 + 521 44 2 1 7 4 + 72 247 250 73 + 522 44 2 1 7 4 + 247 428 431 250 + 523 44 2 1 7 4 + 428 561 563 431 + 529 44 2 1 7 4 + 73 250 251 74 + 530 44 2 1 7 4 + 250 431 434 251 + 531 44 2 1 7 4 + 431 563 565 434 + 537 44 2 1 7 4 + 74 251 252 75 + 538 44 2 1 7 4 + 251 434 435 252 + 539 44 2 1 7 4 + 434 565 566 435 + 545 44 2 1 7 4 + 75 252 253 76 + 546 44 2 1 7 4 + 252 435 433 253 + 547 44 2 1 7 4 + 435 566 564 433 + 553 44 2 1 7 4 + 76 253 254 77 + 554 44 2 1 7 4 + 253 433 432 254 + 555 44 2 1 7 4 + 433 564 562 432 + 561 44 2 1 7 4 + 77 254 255 78 + 562 44 2 1 7 4 + 254 432 429 255 + 563 44 2 1 7 4 + 432 562 555 429 + 569 44 2 1 7 4 + 78 255 237 70 + 570 44 2 1 7 4 + 255 429 419 237 + 571 44 2 1 7 4 + 429 555 548 419 + 577 44 2 1 7 4 + 27 174 175 79 + 578 44 2 1 7 4 + 174 349 352 175 + 579 44 2 1 7 4 + 349 460 461 352 + 585 44 2 1 7 4 + 79 175 176 80 + 586 44 2 1 7 4 + 175 352 358 176 + 587 44 2 1 7 4 + 352 461 470 358 + 593 44 2 1 7 4 + 80 176 289 81 + 594 44 2 1 7 4 + 176 358 439 289 + 595 44 2 1 7 4 + 358 470 534 439 + 601 44 2 1 7 4 + 81 289 196 82 + 602 44 2 1 7 4 + 289 439 371 196 + 603 44 2 1 7 4 + 439 534 486 371 + 609 44 2 1 7 4 + 82 196 201 83 + 610 44 2 1 7 4 + 196 371 373 201 + 611 44 2 1 7 4 + 371 486 488 373 + 617 44 2 1 7 4 + 83 201 207 84 + 618 44 2 1 7 4 + 201 373 379 207 + 619 44 2 1 7 4 + 373 488 493 379 + 625 44 2 1 7 4 + 84 207 212 85 + 626 44 2 1 7 4 + 207 379 388 212 + 627 44 2 1 7 4 + 379 493 503 388 + 633 44 2 1 7 4 + 86 222 221 87 + 634 44 2 1 7 4 + 222 397 403 221 + 635 44 2 1 7 4 + 397 514 519 403 + 641 44 2 1 7 4 + 87 221 232 88 + 642 44 2 1 7 4 + 221 403 407 232 + 643 44 2 1 7 4 + 403 519 525 407 + 649 44 2 1 7 4 + 88 232 231 89 + 650 44 2 1 7 4 + 232 407 413 231 + 651 44 2 1 7 4 + 407 525 532 413 + 657 44 2 1 7 4 + 89 231 259 90 + 658 44 2 1 7 4 + 231 413 420 259 + 659 44 2 1 7 4 + 413 532 539 420 + 665 44 2 1 7 4 + 90 259 267 91 + 666 44 2 1 7 4 + 259 420 447 267 + 667 44 2 1 7 4 + 420 539 583 447 + 673 44 2 1 7 4 + 91 267 256 92 + 674 44 2 1 7 4 + 267 447 430 256 + 675 44 2 1 7 4 + 447 583 554 430 + 681 44 2 1 7 4 + 92 256 255 78 + 682 44 2 1 7 4 + 256 430 429 255 + 683 44 2 1 7 4 + 430 554 555 429 + 689 44 2 1 7 4 + 53 166 175 79 + 690 44 2 1 7 4 + 166 347 352 175 + 691 44 2 1 7 4 + 347 456 461 352 + 697 44 2 1 7 4 + 55 177 289 81 + 698 44 2 1 7 4 + 177 357 439 289 + 699 44 2 1 7 4 + 357 467 534 439 + 705 44 2 1 7 4 + 58 200 207 84 + 706 44 2 1 7 4 + 200 369 379 207 + 707 44 2 1 7 4 + 369 484 493 379 + 713 44 2 1 7 4 + 86 222 219 63 + 714 44 2 1 7 4 + 222 397 400 219 + 715 44 2 1 7 4 + 397 514 517 400 + 721 44 2 1 7 4 + 88 232 229 65 + 722 44 2 1 7 4 + 232 407 406 229 + 723 44 2 1 7 4 + 407 525 524 406 + 729 44 2 1 7 4 + 90 259 234 67 + 730 44 2 1 7 4 + 259 420 414 234 + 731 44 2 1 7 4 + 420 539 538 414 + 737 44 2 1 7 4 + 85 212 222 86 + 738 44 2 1 7 4 + 212 388 397 222 + 739 44 2 1 7 4 + 388 503 514 397 + 745 44 2 1 7 4 + 1 167 174 27 + 746 44 2 1 7 4 + 167 346 349 174 + 747 44 2 1 7 4 + 346 455 460 349 + 753 44 2 1 7 4 + 27 174 168 48 + 754 44 2 1 7 4 + 174 349 351 168 + 755 44 2 1 7 4 + 349 460 462 351 + 761 44 2 1 7 4 + 48 168 278 49 + 762 44 2 1 7 4 + 168 351 436 278 + 763 44 2 1 7 4 + 351 462 530 436 + 769 44 2 1 7 4 + 49 278 182 101 + 770 44 2 1 7 4 + 278 436 364 182 + 771 44 2 1 7 4 + 436 530 480 364 + 777 44 2 1 7 4 + 101 182 261 102 + 778 44 2 1 7 4 + 182 364 374 261 + 779 44 2 1 7 4 + 364 480 492 374 + 785 44 2 1 7 4 + 102 261 210 103 + 786 44 2 1 7 4 + 261 374 394 210 + 787 44 2 1 7 4 + 374 492 508 394 + 793 44 2 1 7 4 + 103 210 263 104 + 794 44 2 1 7 4 + 210 394 401 263 + 795 44 2 1 7 4 + 394 508 518 401 + 801 44 2 1 7 4 + 104 263 265 52 + 802 44 2 1 7 4 + 263 401 445 265 + 803 44 2 1 7 4 + 401 518 569 445 + 809 44 2 1 7 4 + 52 265 339 28 + 810 44 2 1 7 4 + 265 445 448 339 + 811 44 2 1 7 4 + 445 569 591 448 + 817 44 2 1 7 4 + 71 246 339 28 + 818 44 2 1 7 4 + 246 427 448 339 + 819 44 2 1 7 4 + 427 556 591 448 + 825 44 2 1 7 4 + 71 246 245 20 + 826 44 2 1 7 4 + 246 427 426 245 + 827 44 2 1 7 4 + 427 556 558 426 + 838 11 2 1 7 2 + 0 0 0 + 450 436 + 839 11 2 1 7 2 + 0 0 0 + 305 278 + 845 11 2 1 7 2 + 0 0 0 + 449 450 + 846 11 2 1 7 2 + 0 0 0 + 304 305 + 852 11 2 1 7 2 + 0 0 0 + 437 449 + 853 11 2 1 7 2 + 0 0 0 + 277 304 + 859 11 2 1 7 2 + 0 0 0 + 350 349 + 860 11 2 1 7 2 + 0 0 0 + 173 174 + 861 11 2 1 7 2 + 0 0 0 + 29 27 + 867 11 2 1 7 2 + 0 0 0 + 346 344 + 868 11 2 1 7 2 + 0 0 0 + 167 164 + 869 11 2 1 7 2 + 0 0 0 + 1 2 + 875 11 2 1 7 2 + 0 0 0 + 477 452 + 876 11 2 1 7 2 + 0 0 0 + 316 302 + 882 11 2 1 7 2 + 0 0 0 + 483 477 + 883 11 2 1 7 2 + 0 0 0 + 326 316 + 889 11 2 1 7 2 + 0 0 0 + 482 483 + 890 11 2 1 7 2 + 0 0 0 + 325 326 + 896 11 2 1 7 2 + 0 0 0 + 481 482 + 897 11 2 1 7 2 + 0 0 0 + 315 325 + 903 11 2 1 7 2 + 0 0 0 + 452 481 + 904 11 2 1 7 2 + 0 0 0 + 302 315 + 910 11 2 1 7 2 + 0 0 0 + 446 502 + 911 11 2 1 7 2 + 0 0 0 + 266 297 + 917 11 2 1 7 2 + 0 0 0 + 502 536 + 918 11 2 1 7 2 + 0 0 0 + 297 318 + 924 11 2 1 7 2 + 0 0 0 + 536 545 + 925 11 2 1 7 2 + 0 0 0 + 318 327 + 931 11 2 1 7 2 + 0 0 0 + 545 546 + 932 11 2 1 7 2 + 0 0 0 + 327 328 + 938 11 2 1 7 2 + 0 0 0 + 546 543 + 939 11 2 1 7 2 + 0 0 0 + 328 317 + 945 11 2 1 7 2 + 0 0 0 + 543 506 + 946 11 2 1 7 2 + 0 0 0 + 317 294 + 952 11 2 1 7 2 + 0 0 0 + 506 445 + 953 11 2 1 7 2 + 0 0 0 + 294 265 + 954 11 2 1 7 2 + 0 0 0 + 216 268 + 955 11 2 1 7 2 + 0 0 0 + 268 292 + 956 11 2 1 7 2 + 0 0 0 + 292 311 + 957 11 2 1 7 2 + 0 0 0 + 311 313 + 958 11 2 1 7 2 + 0 0 0 + 313 314 + 959 11 2 1 7 2 + 0 0 0 + 314 306 + 960 11 2 1 7 2 + 0 0 0 + 306 269 + 961 11 2 1 7 2 + 0 0 0 + 224 295 + 962 11 2 1 7 2 + 0 0 0 + 295 383 + 963 11 2 1 7 2 + 0 0 0 + 383 443 + 964 11 2 1 7 2 + 0 0 0 + 443 444 + 965 11 2 1 7 2 + 0 0 0 + 444 372 + 966 11 2 1 7 2 + 0 0 0 + 372 290 + 967 11 2 1 7 2 + 0 0 0 + 233 293 + 968 11 2 1 7 2 + 0 0 0 + 293 381 + 969 11 2 1 7 2 + 0 0 0 + 381 441 + 970 11 2 1 7 2 + 0 0 0 + 441 442 + 971 11 2 1 7 2 + 0 0 0 + 442 375 + 972 11 2 1 7 2 + 0 0 0 + 375 291 + 978 11 2 1 7 2 + 0 0 0 + 451 458 + 979 11 2 1 7 2 + 0 0 0 + 312 319 + 985 11 2 1 7 2 + 0 0 0 + 439 451 + 986 11 2 1 7 2 + 0 0 0 + 289 312 + 992 11 2 1 7 2 + 0 0 0 + 352 349 + 993 11 2 1 7 2 + 0 0 0 + 175 174 + 994 11 2 1 7 2 + 0 0 0 + 79 27 + 1000 11 2 1 7 2 + 0 0 0 + 346 347 + 1001 11 2 1 7 2 + 0 0 0 + 167 166 + 1002 11 2 1 7 2 + 0 0 0 + 1 53 + 1008 11 2 1 7 2 + 0 0 0 + 496 468 + 1009 11 2 1 7 2 + 0 0 0 + 323 307 + 1015 11 2 1 7 2 + 0 0 0 + 501 496 + 1016 11 2 1 7 2 + 0 0 0 + 332 323 + 1022 11 2 1 7 2 + 0 0 0 + 500 501 + 1023 11 2 1 7 2 + 0 0 0 + 331 332 + 1029 11 2 1 7 2 + 0 0 0 + 494 500 + 1030 11 2 1 7 2 + 0 0 0 + 322 331 + 1036 11 2 1 7 2 + 0 0 0 + 468 494 + 1037 11 2 1 7 2 + 0 0 0 + 307 322 + 1043 11 2 1 7 2 + 0 0 0 + 447 511 + 1044 11 2 1 7 2 + 0 0 0 + 267 303 + 1050 11 2 1 7 2 + 0 0 0 + 511 551 + 1051 11 2 1 7 2 + 0 0 0 + 303 324 + 1057 11 2 1 7 2 + 0 0 0 + 551 552 + 1058 11 2 1 7 2 + 0 0 0 + 324 329 + 1064 11 2 1 7 2 + 0 0 0 + 552 553 + 1065 11 2 1 7 2 + 0 0 0 + 329 330 + 1071 11 2 1 7 2 + 0 0 0 + 553 549 + 1072 11 2 1 7 2 + 0 0 0 + 330 321 + 1073 11 2 1 7 2 + 0 0 0 + 222 270 + 1074 11 2 1 7 2 + 0 0 0 + 270 300 + 1075 11 2 1 7 2 + 0 0 0 + 300 309 + 1076 11 2 1 7 2 + 0 0 0 + 309 310 + 1077 11 2 1 7 2 + 0 0 0 + 310 308 + 1078 11 2 1 7 2 + 0 0 0 + 308 271 + 1079 11 2 1 7 2 + 0 0 0 + 271 260 + 1080 11 2 1 7 2 + 0 0 0 + 232 301 + 1081 11 2 1 7 2 + 0 0 0 + 301 386 + 1082 11 2 1 7 2 + 0 0 0 + 386 387 + 1083 11 2 1 7 2 + 0 0 0 + 387 385 + 1084 11 2 1 7 2 + 0 0 0 + 385 296 + 1085 11 2 1 7 2 + 0 0 0 + 296 262 + 1086 11 2 1 7 2 + 0 0 0 + 259 299 + 1087 11 2 1 7 2 + 0 0 0 + 299 390 + 1088 11 2 1 7 2 + 0 0 0 + 390 391 + 1089 11 2 1 7 2 + 0 0 0 + 391 389 + 1090 11 2 1 7 2 + 0 0 0 + 389 298 + 1091 11 2 1 7 2 + 0 0 0 + 298 264 + 1097 11 2 1 7 2 + 0 0 0 + 346 349 + 1098 11 2 1 7 2 + 0 0 0 + 167 174 + 1099 11 2 1 7 2 + 0 0 0 + 1 27 + 1100 11 2 1 7 2 + 0 0 0 + 291 263 + 1101 11 2 1 7 2 + 0 0 0 + 290 261 + 1102 11 2 1 7 2 + 0 0 0 + 269 278 + 1103 11 2 1 7 2 + 0 0 0 + 263 264 + 1104 11 2 1 7 2 + 0 0 0 + 261 262 + 1105 11 2 1 7 2 + 0 0 0 + 278 260 + 1106 11 2 1 7 2 + 0 0 0 + 319 340 + 1107 11 2 1 7 2 + 0 0 0 + 340 342 + 1108 11 2 1 7 2 + 0 0 0 + 342 343 + 1109 11 2 1 7 2 + 0 0 0 + 343 341 + 1110 11 2 1 7 2 + 0 0 0 + 341 320 + 1111 11 2 1 7 2 + 0 0 0 + 320 321 + 1112 11 2 1 7 2 + 0 0 0 + 458 474 + 1118 11 2 1 7 2 + 0 0 0 + 474 489 + 1124 11 2 1 7 2 + 0 0 0 + 489 509 + 1130 11 2 1 7 2 + 0 0 0 + 509 513 + 1136 11 2 1 7 2 + 0 0 0 + 513 523 + 1142 11 2 1 7 2 + 0 0 0 + 523 549 + 1153 11 2 1 7 2 + 0 0 0 + 448 591 + 1154 11 2 1 7 2 + 0 0 0 + 339 448 + 1155 11 2 1 7 2 + 0 0 0 + 28 339 + 1156 11 2 1 7 2 + 0 0 0 + 28 118 + 1157 11 2 1 7 2 + 0 0 0 + 118 152 + 1158 11 2 1 7 2 + 0 0 0 + 152 153 + 1159 11 2 1 7 2 + 0 0 0 + 153 154 + 1160 11 2 1 7 2 + 0 0 0 + 154 155 + 1161 11 2 1 7 2 + 0 0 0 + 28 157 + 1162 11 2 1 7 2 + 0 0 0 + 157 158 + 1163 11 2 1 7 2 + 0 0 0 + 158 159 + 1164 11 2 1 7 2 + 0 0 0 + 159 160 + 1165 11 2 1 7 2 + 0 0 0 + 155 156 + 1166 11 2 1 7 2 + 0 0 0 + 156 92 + 1167 11 2 1 7 2 + 0 0 0 + 160 161 + 1168 11 2 1 7 2 + 0 0 0 + 161 162 + 1169 11 2 1 7 2 + 0 0 0 + 162 42 + 1175 44 2 1 7 4 + 438 351 349 350 + 1176 44 2 1 7 4 + 180 168 174 173 + 1177 44 2 1 7 4 + 50 48 27 29 + 1183 44 2 1 7 4 + 450 436 351 438 + 1184 44 2 1 7 4 + 305 278 168 180 + 1190 44 2 1 7 4 + 449 438 350 354 + 1191 44 2 1 7 4 + 304 180 173 172 + 1197 44 2 1 7 4 + 354 350 344 345 + 1198 44 2 1 7 4 + 172 173 164 163 + 1199 44 2 1 7 4 + 30 29 2 3 + 1205 44 2 1 7 4 + 437 354 345 353 + 1206 44 2 1 7 4 + 277 172 163 169 + 1207 44 2 1 7 4 + 31 30 3 4 + 1213 44 2 1 7 4 + 362 437 353 355 + 1214 44 2 1 7 4 + 183 277 169 170 + 1215 44 2 1 7 4 + 32 31 4 5 + 1221 44 2 1 7 4 + 363 362 355 356 + 1222 44 2 1 7 4 + 184 183 170 171 + 1223 44 2 1 7 4 + 33 32 5 6 + 1229 44 2 1 7 4 + 365 363 356 361 + 1230 44 2 1 7 4 + 187 184 171 186 + 1236 44 2 1 7 4 + 452 365 361 366 + 1237 44 2 1 7 4 + 302 187 186 188 + 1238 44 2 1 7 4 + 43 34 7 8 + 1244 44 2 1 7 4 + 481 452 366 368 + 1245 44 2 1 7 4 + 315 302 188 191 + 1246 44 2 1 7 4 + 47 43 8 9 + 1252 44 2 1 7 4 + 477 367 365 452 + 1253 44 2 1 7 4 + 316 190 187 302 + 1254 44 2 1 7 4 + 46 35 34 43 + 1260 44 2 1 7 4 + 483 376 367 477 + 1261 44 2 1 7 4 + 326 216 190 316 + 1262 44 2 1 7 4 + 45 36 35 46 + 1268 44 2 1 7 4 + 378 482 481 370 + 1269 44 2 1 7 4 + 195 325 315 194 + 1270 44 2 1 7 4 + 11 44 47 10 + 1276 44 2 1 7 4 + 380 376 483 482 + 1277 44 2 1 7 4 + 206 216 326 325 + 1278 44 2 1 7 4 + 12 36 45 44 + 1284 44 2 1 7 4 + 384 393 376 380 + 1285 44 2 1 7 4 + 209 215 216 206 + 1286 44 2 1 7 4 + 13 37 36 12 + 1292 44 2 1 7 4 + 395 399 393 384 + 1293 44 2 1 7 4 + 217 224 215 209 + 1294 44 2 1 7 4 + 14 38 37 13 + 1300 44 2 1 7 4 + 398 404 399 395 + 1301 44 2 1 7 4 + 218 223 224 217 + 1302 44 2 1 7 4 + 15 39 38 14 + 1308 44 2 1 7 4 + 405 409 404 398 + 1309 44 2 1 7 4 + 225 233 223 218 + 1310 44 2 1 7 4 + 16 40 39 15 + 1316 44 2 1 7 4 + 408 446 409 405 + 1317 44 2 1 7 4 + 226 266 233 225 + 1318 44 2 1 7 4 + 17 41 40 16 + 1324 44 2 1 7 4 + 410 418 446 408 + 1325 44 2 1 7 4 + 227 239 266 226 + 1326 44 2 1 7 4 + 18 42 41 17 + 1332 44 2 1 7 4 + 411 417 418 410 + 1333 44 2 1 7 4 + 228 238 239 227 + 1334 44 2 1 7 4 + 19 26 42 18 + 1340 44 2 1 7 4 + 417 421 502 418 + 1341 44 2 1 7 4 + 238 240 297 239 + 1342 44 2 1 7 4 + 26 25 162 42 + 1348 44 2 1 7 4 + 421 422 536 502 + 1349 44 2 1 7 4 + 240 241 318 297 + 1350 44 2 1 7 4 + 25 24 161 162 + 1356 44 2 1 7 4 + 422 423 545 536 + 1357 44 2 1 7 4 + 241 242 327 318 + 1358 44 2 1 7 4 + 24 23 160 161 + 1364 44 2 1 7 4 + 423 424 546 545 + 1365 44 2 1 7 4 + 242 243 328 327 + 1366 44 2 1 7 4 + 23 22 159 160 + 1372 44 2 1 7 4 + 424 425 543 546 + 1373 44 2 1 7 4 + 243 244 317 328 + 1374 44 2 1 7 4 + 22 21 158 159 + 1380 44 2 1 7 4 + 425 426 506 543 + 1381 44 2 1 7 4 + 244 245 294 317 + 1382 44 2 1 7 4 + 21 20 157 158 + 1383 44 2 1 7 4 + 44 45 46 47 + 1384 44 2 1 7 4 + 110 113 33 34 + 1385 44 2 1 7 4 + 113 112 32 33 + 1386 44 2 1 7 4 + 112 111 31 32 + 1387 44 2 1 7 4 + 111 51 30 31 + 1388 44 2 1 7 4 + 51 50 29 30 + 1389 44 2 1 7 4 + 119 123 110 35 + 1390 44 2 1 7 4 + 123 135 113 110 + 1391 44 2 1 7 4 + 135 150 112 113 + 1392 44 2 1 7 4 + 150 151 111 112 + 1393 44 2 1 7 4 + 151 133 51 111 + 1394 44 2 1 7 4 + 133 120 50 51 + 1395 44 2 1 7 4 + 120 49 48 50 + 1396 44 2 1 7 4 + 37 131 119 36 + 1397 44 2 1 7 4 + 131 211 135 123 + 1398 44 2 1 7 4 + 211 258 150 135 + 1399 44 2 1 7 4 + 258 257 151 150 + 1400 44 2 1 7 4 + 257 181 133 151 + 1401 44 2 1 7 4 + 181 124 120 133 + 1402 44 2 1 7 4 + 38 143 131 37 + 1403 44 2 1 7 4 + 143 279 211 131 + 1404 44 2 1 7 4 + 279 337 258 211 + 1405 44 2 1 7 4 + 337 338 257 258 + 1406 44 2 1 7 4 + 338 272 181 257 + 1407 44 2 1 7 4 + 272 136 124 181 + 1408 44 2 1 7 4 + 39 142 143 38 + 1409 44 2 1 7 4 + 142 276 279 143 + 1410 44 2 1 7 4 + 276 335 337 279 + 1411 44 2 1 7 4 + 335 336 338 337 + 1412 44 2 1 7 4 + 336 273 272 338 + 1413 44 2 1 7 4 + 273 137 136 272 + 1414 44 2 1 7 4 + 40 141 142 39 + 1415 44 2 1 7 4 + 141 275 276 142 + 1416 44 2 1 7 4 + 275 333 335 276 + 1417 44 2 1 7 4 + 333 334 336 335 + 1418 44 2 1 7 4 + 334 274 273 336 + 1419 44 2 1 7 4 + 274 138 137 273 + 1420 44 2 1 7 4 + 41 125 141 40 + 1421 44 2 1 7 4 + 125 189 275 141 + 1422 44 2 1 7 4 + 189 248 333 275 + 1423 44 2 1 7 4 + 248 249 334 333 + 1424 44 2 1 7 4 + 249 192 274 334 + 1425 44 2 1 7 4 + 192 126 138 274 + 1426 44 2 1 7 4 + 42 162 125 41 + 1427 44 2 1 7 4 + 162 161 189 125 + 1428 44 2 1 7 4 + 161 160 248 189 + 1429 44 2 1 7 4 + 160 159 249 248 + 1430 44 2 1 7 4 + 159 158 192 249 + 1431 44 2 1 7 4 + 158 157 126 192 + 1432 44 2 1 7 4 + 268 119 123 292 + 1433 44 2 1 7 4 + 292 123 135 311 + 1434 44 2 1 7 4 + 311 135 150 313 + 1435 44 2 1 7 4 + 313 150 151 314 + 1436 44 2 1 7 4 + 314 151 133 306 + 1437 44 2 1 7 4 + 306 133 120 269 + 1438 44 2 1 7 4 + 216 36 119 268 + 1439 44 2 1 7 4 + 224 38 143 295 + 1440 44 2 1 7 4 + 295 143 279 383 + 1441 44 2 1 7 4 + 383 279 337 443 + 1442 44 2 1 7 4 + 443 337 338 444 + 1443 44 2 1 7 4 + 444 338 272 372 + 1444 44 2 1 7 4 + 372 272 136 290 + 1445 44 2 1 7 4 + 233 40 141 293 + 1446 44 2 1 7 4 + 293 141 275 381 + 1447 44 2 1 7 4 + 381 275 333 441 + 1448 44 2 1 7 4 + 441 333 334 442 + 1449 44 2 1 7 4 + 442 334 274 375 + 1450 44 2 1 7 4 + 375 274 138 291 + 1456 44 2 1 7 4 + 440 351 349 352 + 1457 44 2 1 7 4 + 185 168 174 175 + 1458 44 2 1 7 4 + 98 48 27 79 + 1464 44 2 1 7 4 + 458 436 351 440 + 1465 44 2 1 7 4 + 319 278 168 185 + 1471 44 2 1 7 4 + 451 440 352 358 + 1472 44 2 1 7 4 + 312 185 175 176 + 1478 44 2 1 7 4 + 358 352 347 348 + 1479 44 2 1 7 4 + 176 175 166 165 + 1480 44 2 1 7 4 + 80 79 53 54 + 1486 44 2 1 7 4 + 439 358 348 357 + 1487 44 2 1 7 4 + 289 176 165 177 + 1488 44 2 1 7 4 + 81 80 54 55 + 1494 44 2 1 7 4 + 371 439 357 359 + 1495 44 2 1 7 4 + 196 289 177 178 + 1496 44 2 1 7 4 + 82 81 55 56 + 1502 44 2 1 7 4 + 373 371 359 360 + 1503 44 2 1 7 4 + 201 196 178 179 + 1504 44 2 1 7 4 + 83 82 56 57 + 1510 44 2 1 7 4 + 379 373 360 369 + 1511 44 2 1 7 4 + 207 201 179 200 + 1512 44 2 1 7 4 + 84 83 57 58 + 1518 44 2 1 7 4 + 468 379 369 377 + 1519 44 2 1 7 4 + 307 207 200 205 + 1520 44 2 1 7 4 + 93 84 58 59 + 1526 44 2 1 7 4 + 494 468 377 382 + 1527 44 2 1 7 4 + 322 307 205 208 + 1528 44 2 1 7 4 + 97 93 59 60 + 1534 44 2 1 7 4 + 496 388 379 468 + 1535 44 2 1 7 4 + 323 212 207 307 + 1536 44 2 1 7 4 + 96 85 84 93 + 1542 44 2 1 7 4 + 501 397 388 496 + 1543 44 2 1 7 4 + 332 222 212 323 + 1544 44 2 1 7 4 + 95 86 85 96 + 1550 44 2 1 7 4 + 396 500 494 392 + 1551 44 2 1 7 4 + 214 331 322 213 + 1552 44 2 1 7 4 + 62 94 97 61 + 1558 44 2 1 7 4 + 400 397 501 500 + 1559 44 2 1 7 4 + 219 222 332 331 + 1560 44 2 1 7 4 + 63 86 95 94 + 1566 44 2 1 7 4 + 402 403 397 400 + 1567 44 2 1 7 4 + 220 221 222 219 + 1568 44 2 1 7 4 + 64 87 86 63 + 1574 44 2 1 7 4 + 406 407 403 402 + 1575 44 2 1 7 4 + 229 232 221 220 + 1576 44 2 1 7 4 + 65 88 87 64 + 1582 44 2 1 7 4 + 412 413 407 406 + 1583 44 2 1 7 4 + 230 231 232 229 + 1584 44 2 1 7 4 + 66 89 88 65 + 1590 44 2 1 7 4 + 414 420 413 412 + 1591 44 2 1 7 4 + 234 259 231 230 + 1592 44 2 1 7 4 + 67 90 89 66 + 1598 44 2 1 7 4 + 415 447 420 414 + 1599 44 2 1 7 4 + 235 267 259 234 + 1600 44 2 1 7 4 + 68 91 90 67 + 1606 44 2 1 7 4 + 416 430 447 415 + 1607 44 2 1 7 4 + 236 256 267 235 + 1608 44 2 1 7 4 + 69 92 91 68 + 1614 44 2 1 7 4 + 419 429 430 416 + 1615 44 2 1 7 4 + 237 255 256 236 + 1616 44 2 1 7 4 + 70 78 92 69 + 1622 44 2 1 7 4 + 429 432 511 430 + 1623 44 2 1 7 4 + 255 254 303 256 + 1624 44 2 1 7 4 + 78 77 156 92 + 1630 44 2 1 7 4 + 432 433 551 511 + 1631 44 2 1 7 4 + 254 253 324 303 + 1632 44 2 1 7 4 + 77 76 155 156 + 1638 44 2 1 7 4 + 433 435 552 551 + 1639 44 2 1 7 4 + 253 252 329 324 + 1640 44 2 1 7 4 + 76 75 154 155 + 1646 44 2 1 7 4 + 435 434 553 552 + 1647 44 2 1 7 4 + 252 251 330 329 + 1648 44 2 1 7 4 + 75 74 153 154 + 1654 44 2 1 7 4 + 434 431 549 553 + 1655 44 2 1 7 4 + 251 250 321 330 + 1656 44 2 1 7 4 + 74 73 152 153 + 1662 44 2 1 7 4 + 431 428 464 549 + 1663 44 2 1 7 4 + 250 247 193 321 + 1664 44 2 1 7 4 + 73 72 118 152 + 1670 44 2 1 7 4 + 428 427 448 464 + 1671 44 2 1 7 4 + 247 246 339 193 + 1672 44 2 1 7 4 + 72 71 28 118 + 1673 44 2 1 7 4 + 94 95 96 97 + 1674 44 2 1 7 4 + 114 117 83 84 + 1675 44 2 1 7 4 + 117 116 82 83 + 1676 44 2 1 7 4 + 116 115 81 82 + 1677 44 2 1 7 4 + 115 100 80 81 + 1678 44 2 1 7 4 + 100 98 79 80 + 1679 44 2 1 7 4 + 121 129 114 85 + 1680 44 2 1 7 4 + 129 139 117 114 + 1681 44 2 1 7 4 + 139 140 116 117 + 1682 44 2 1 7 4 + 140 134 115 116 + 1683 44 2 1 7 4 + 134 122 100 115 + 1684 44 2 1 7 4 + 122 99 98 100 + 1685 44 2 1 7 4 + 99 49 48 98 + 1686 44 2 1 7 4 + 87 132 121 86 + 1687 44 2 1 7 4 + 132 199 139 129 + 1688 44 2 1 7 4 + 199 198 140 139 + 1689 44 2 1 7 4 + 198 197 134 140 + 1690 44 2 1 7 4 + 197 127 122 134 + 1691 44 2 1 7 4 + 88 149 132 87 + 1692 44 2 1 7 4 + 149 287 199 132 + 1693 44 2 1 7 4 + 287 288 198 199 + 1694 44 2 1 7 4 + 288 280 197 198 + 1695 44 2 1 7 4 + 280 144 127 197 + 1696 44 2 1 7 4 + 89 148 149 88 + 1697 44 2 1 7 4 + 148 283 287 149 + 1698 44 2 1 7 4 + 283 284 288 287 + 1699 44 2 1 7 4 + 284 281 280 288 + 1700 44 2 1 7 4 + 281 145 144 280 + 1701 44 2 1 7 4 + 90 147 148 89 + 1702 44 2 1 7 4 + 147 285 283 148 + 1703 44 2 1 7 4 + 285 286 284 283 + 1704 44 2 1 7 4 + 286 282 281 284 + 1705 44 2 1 7 4 + 282 146 145 281 + 1706 44 2 1 7 4 + 91 128 147 90 + 1707 44 2 1 7 4 + 128 202 285 147 + 1708 44 2 1 7 4 + 202 203 286 285 + 1709 44 2 1 7 4 + 203 204 282 286 + 1710 44 2 1 7 4 + 204 130 146 282 + 1711 44 2 1 7 4 + 92 156 128 91 + 1712 44 2 1 7 4 + 156 155 202 128 + 1713 44 2 1 7 4 + 155 154 203 202 + 1714 44 2 1 7 4 + 154 153 204 203 + 1715 44 2 1 7 4 + 153 152 130 204 + 1716 44 2 1 7 4 + 270 121 129 300 + 1717 44 2 1 7 4 + 300 129 139 309 + 1718 44 2 1 7 4 + 309 139 140 310 + 1719 44 2 1 7 4 + 310 140 134 308 + 1720 44 2 1 7 4 + 308 134 122 271 + 1721 44 2 1 7 4 + 271 122 99 260 + 1722 44 2 1 7 4 + 222 86 121 270 + 1723 44 2 1 7 4 + 232 88 149 301 + 1724 44 2 1 7 4 + 301 149 287 386 + 1725 44 2 1 7 4 + 386 287 288 387 + 1726 44 2 1 7 4 + 387 288 280 385 + 1727 44 2 1 7 4 + 385 280 144 296 + 1728 44 2 1 7 4 + 259 90 147 299 + 1729 44 2 1 7 4 + 299 147 285 390 + 1730 44 2 1 7 4 + 390 285 286 391 + 1731 44 2 1 7 4 + 391 286 282 389 + 1732 44 2 1 7 4 + 389 282 146 298 + 1733 44 2 1 7 4 + 136 102 101 124 + 1734 44 2 1 7 4 + 137 103 102 136 + 1735 44 2 1 7 4 + 138 104 103 137 + 1736 44 2 1 7 4 + 124 101 49 120 + 1737 44 2 1 7 4 + 126 52 104 138 + 1738 44 2 1 7 4 + 157 28 52 126 + 1739 44 2 1 7 4 + 269 120 49 278 + 1740 44 2 1 7 4 + 290 136 102 261 + 1741 44 2 1 7 4 + 291 138 104 263 + 1742 44 2 1 7 4 + 278 49 99 260 + 1743 44 2 1 7 4 + 127 105 99 122 + 1744 44 2 1 7 4 + 105 101 49 99 + 1745 44 2 1 7 4 + 144 106 105 127 + 1746 44 2 1 7 4 + 106 102 101 105 + 1747 44 2 1 7 4 + 145 107 106 144 + 1748 44 2 1 7 4 + 107 103 102 106 + 1749 44 2 1 7 4 + 146 108 107 145 + 1750 44 2 1 7 4 + 108 104 103 107 + 1751 44 2 1 7 4 + 296 144 106 262 + 1752 44 2 1 7 4 + 262 106 102 261 + 1753 44 2 1 7 4 + 298 146 108 264 + 1754 44 2 1 7 4 + 264 108 104 263 + 1755 44 2 1 7 4 + 130 109 108 146 + 1756 44 2 1 7 4 + 109 52 104 108 + 1757 44 2 1 7 4 + 152 118 109 130 + 1758 44 2 1 7 4 + 118 28 52 109 + 1759 44 2 1 7 4 + 340 182 278 319 + 1760 44 2 1 7 4 + 342 261 182 340 + 1761 44 2 1 7 4 + 343 210 261 342 + 1762 44 2 1 7 4 + 341 263 210 343 + 1763 44 2 1 7 4 + 320 265 263 341 + 1764 44 2 1 7 4 + 193 339 265 320 + 1765 44 2 1 7 4 + 474 364 436 458 + 1771 44 2 1 7 4 + 489 374 364 474 + 1777 44 2 1 7 4 + 509 394 374 489 + 1783 44 2 1 7 4 + 513 401 394 509 + 1789 44 2 1 7 4 + 523 445 401 513 + 1795 44 2 1 7 4 + 464 448 445 523 + 1801 44 2 1 7 4 + 71 20 157 28 + 1802 44 2 1 7 4 + 246 245 294 339 + 1803 44 2 1 7 4 + 427 426 506 448 + 1809 44 2 1 7 4 + 34 33 6 7 + 1815 41 2 1 7 3 + 506 448 445 + 1816 41 2 1 7 3 + 294 339 265 + 1822 41 2 1 7 3 + 449 450 438 + 1823 41 2 1 7 3 + 304 305 180 + 1829 41 2 1 7 3 + 437 449 354 + 1830 41 2 1 7 3 + 277 304 172 + 1836 41 2 1 7 3 + 380 482 378 + 1837 41 2 1 7 3 + 206 325 195 + 1838 41 2 1 7 3 + 12 44 11 + 1843 41 2 1 7 3 + 370 481 368 + 1844 41 2 1 7 3 + 194 315 191 + 1845 41 2 1 7 3 + 10 47 9 + 1846 41 2 1 7 3 + 43 46 47 + 1847 41 2 1 7 3 + 35 110 34 + 1849 41 2 1 7 3 + 36 119 35 + 1850 41 2 1 7 3 + 131 123 119 + 1851 41 2 1 7 3 + 239 297 266 + 1852 41 2 1 7 3 + 418 502 446 + 1863 41 2 1 7 3 + 451 458 440 + 1864 41 2 1 7 3 + 312 319 185 + 1870 41 2 1 7 3 + 439 451 358 + 1871 41 2 1 7 3 + 289 312 176 + 1877 41 2 1 7 3 + 400 500 396 + 1878 41 2 1 7 3 + 219 331 214 + 1879 41 2 1 7 3 + 63 94 62 + 1884 41 2 1 7 3 + 392 494 382 + 1885 41 2 1 7 3 + 213 322 208 + 1886 41 2 1 7 3 + 61 97 60 + 1887 41 2 1 7 3 + 93 96 97 + 1888 41 2 1 7 3 + 85 114 84 + 1890 41 2 1 7 3 + 86 121 85 + 1891 41 2 1 7 3 + 132 129 121 + 1892 41 2 1 7 3 + 256 303 267 + 1893 41 2 1 7 3 + 430 511 447 + 1899 41 2 1 7 3 + 193 321 320 + 1900 41 2 1 7 3 + 464 549 523 + -1 diff --git a/idl/Makefile.in b/idl/Makefile.in index 2c96c9b5f..4dee4634d 100644 --- a/idl/Makefile.in +++ b/idl/Makefile.in @@ -34,7 +34,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) $< $@ @@ -55,7 +55,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/make_config.in b/make_config.in new file mode 100755 index 000000000..64b47c344 --- /dev/null +++ b/make_config.in @@ -0,0 +1,75 @@ +# make_config.in: template for make_config script +# make_config is used by check_cas.m4 to generate +# config.h file in case it cannot be found in OCC +# and SALOME include paths +#================================================= +dnl Process this file with autoconf to produce a configure script. + +AC_INIT(salome_adm/unix) +AC_CONFIG_SRCDIR(salome_adm/unix/config.h.in) +AC_CONFIG_AUX_DIR(salome_adm/unix/config_files) +AC_CANONICAL_HOST + +AC_CONFIG_HEADERS(./salome_adm/unix/config.h) + +AC_ISC_POSIX +AC_C_BIGENDIAN + +dnl Checks for programs. +AC_PROG_CXX +AC_PROG_CC_C_O + +AC_PROG_AWK +AC_PROG_INSTALL +AC_PROG_LN_S +AC_PROG_YACC +AC_PROG_MAKE_SET + +dnl Replace `main' with a function in -le: +AC_CHECK_LIB(e, main) + +dnl Replace `main' with a function in -links: +AC_CHECK_LIB(inks, main) + +dnl Checks for X window system directories. +AC_PATH_X +if test "x$ac_x_includes" = "x"; then + X_INCLUDE="" +else + X_INCLUDE="-I$ac_x_includes" +fi +if test "x$ac_x_libraries" = "x"; then + X_LIBS="-lXt -lX11" +else + X_LIBS="-L$ac_x_libraries -lXt -lX11" +fi + +dnl Checks for header files. + +AC_HEADER_STDC +AC_LANG([C]) +AC_MSG_CHECKING([ for C header files ]) +AC_CHECK_HEADERS(dlfcn.h dl.h ieeefp.h time.h sys/time.h pwd.h) +AC_CHECK_HEADERS(sys/statvfs.h sys/vfs.h sys/param.h osfcn.h netdb.h) +AC_CHECK_HEADERS(sys/ioctl.h net/if.h sys/systeminfo.h sys/utsname.h) +AC_CHECK_HEADERS(sysent.h unistd.h sys/unistd.h sys/socket.h) +AC_CHECK_HEADERS(ndir.h sys/ndir.h sys/dir.h signal.h sys/signal.h) +AC_CHECK_HEADERS(sigfpe.h floatingpoint.h sys/machsig.h sys/siginfo.h) +AC_CHECK_HEADERS(malloc.h strings.h sys/stat.h sys/sem.h sys/ipc.h) +AC_CHECK_HEADERS(sys/times.h dirent.h getopt.h sys/vnode.h) + + +AC_LANG([C++]) +AC_MSG_CHECKING([ for C++ header files ]) +AC_CHECK_HEADERS(istream ostream istream fstream ios iomanip iostream ) +AC_CHECK_HEADERS(stream.h strstream.h istream.h ostream.h fstream.h stdlib.h ios.h iostream.h) +AC_CHECK_HEADERS(iomanip.h limits.h values.h float.h) +AC_CHECK_HEADERS(siginfo.h bits/sigset.h bstring.h sys/types.h sys/select.h) +AC_CHECK_HEADERS(X11/extensions/transovl.h X11/extensions/readdisplay.h) +AC_CHECK_HEADERS(X11/extensions/multibuf.h) +AC_CHECK_HEADERS(sys/filio.h sys/mman.h libc.h) + +dnl Checks for library functions. +AC_TYPE_SIGNAL + +AC_OUTPUT() 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.h.in b/salome_adm/unix/config.h.in new file mode 100755 index 000000000..19d28510f --- /dev/null +++ b/salome_adm/unix/config.h.in @@ -0,0 +1,350 @@ +/* config.h.in. Generated from configure.in by autoheader. */ + +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +#undef CRAY_STACKSEG_END + +/* Define to 1 if using `alloca.c'. */ +#undef C_ALLOCA + +/* define if the compiler allows redefinition of stream input and output */ +#undef DEF_IOS_OK + +/* Define to 1 if you have `alloca', as a function or macro. */ +#undef HAVE_ALLOCA + +/* Define to 1 if you have and it should be used (not on Ultrix). + */ +#undef HAVE_ALLOCA_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_BITS_SIGSET_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_BSTRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_DIRENT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_DL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_DPS_DPSXCLIENT_H + +/* Define if we have a function called "finite" in -lm. */ +#undef HAVE_FINITE + +/* Define to 1 if you have the header file. */ +#undef HAVE_FLOATINGPOINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FLOAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FSTREAM + +/* Define to 1 if you have the header file. */ +#undef HAVE_FSTREAM_H + +/* Define to 1 if you have the `gethostname' function. */ +#undef HAVE_GETHOSTNAME + +/* Define to 1 if you have the header file. */ +#undef HAVE_GETOPT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_IEEEFP_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_IOMANIP + +/* Define to 1 if you have the header file. */ +#undef HAVE_IOMANIP_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_IOS + +/* Define to 1 if you have the header file. */ +#undef HAVE_IOSTREAM + +/* Define to 1 if you have the header file. */ +#undef HAVE_IOSTREAM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_IOS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_ISTREAM + +/* Define to 1 if you have the header file. */ +#undef HAVE_ISTREAM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBC_H + +/* Define to 1 if you have the `e' library (-le). */ +#undef HAVE_LIBE + +/* Define to 1 if you have the `inks' library (-links). */ +#undef HAVE_LIBINKS + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIMITS_H + +/* Define if we have a function called "mallinfo" in -lmalloc. */ +#undef HAVE_MALLINFO + +/* Define to 1 if you have the header file. */ +#undef HAVE_MALLOC_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NDIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETDB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NET_IF_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_OSFCN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_OSTREAM + +/* Define to 1 if you have the header file. */ +#undef HAVE_OSTREAM_H + +/* Define to 1 if you have the `putenv' function. */ +#undef HAVE_PUTENV + +/* Define to 1 if you have the header file. */ +#undef HAVE_PWD_H + +/* Define to 1 if you have the `regcomp' function. */ +#undef HAVE_REGCOMP + +/* Define to 1 if you have the `re_comp' function. */ +#undef HAVE_RE_COMP + +/* Define to 1 if you have the header file. */ +#undef HAVE_SIGFPE_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SIGINFO_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SIGNAL_H + +/* Define to 1 if you have the `statfs' function. */ +#undef HAVE_STATFS + +/* Define to 1 if you have the `statvfs' function. */ +#undef HAVE_STATVFS + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strcspn' function. */ +#undef HAVE_STRCSPN + +/* Define to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + +/* Define to 1 if you have the header file. */ +#undef HAVE_STREAM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRSTREAM_H + +/* Define to 1 if you have the `strtol' function. */ +#undef HAVE_STRTOL + +/* Define if we have a function called "ieee_handler" in -lsunmath. */ +#undef HAVE_SUNMATH + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYSENT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_DIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_FILIO_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IOCTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IPC_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_MACHSIG_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_MMAN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_NDIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_PARAM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SELECT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SEM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SIGINFO_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SIGNAL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SOCKET_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STATVFS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SYSTEMINFO_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIMES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_UNISTD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_UTSNAME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_VFS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_VNODE_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_VALUES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_X11_EXTENSIONS_MULTIBUF_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_X11_EXTENSIONS_READDISPLAY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_X11_EXTENSIONS_TRANSOVL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_XMU_EDITRES_H + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +#undef NO_MINUS_C_MINUS_O + +/* define if the class ostream has member function form */ +#undef OSTREAM_FORM_OK + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define if compiler has function prototypes */ +#undef PROTOTYPES + +/* Define as the return type of signal handlers (`int' or `void'). */ +#undef RETSIGTYPE + +/* define if the function semctl takes a value */ +#undef SEMCTL_NO_REFERENCE + +/* define if the function semop takes a value */ +#undef SEMOP_NO_REFERENCE + +/* define if semun has member __buf */ +#undef SEMUN_BUF_DEFINED + +/* define if the union semun is in sys/sem.h */ +#undef SEMUN_DEFINED + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +#undef STACK_DIRECTION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to 1 if your declares `struct tm'. */ +#undef TM_IN_SYS_TIME + +/* Version number of package */ +#undef VERSION + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +#undef WORDS_BIGENDIAN + +/* Define to 1 if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif + +/* Define to `unsigned' if does not define. */ +#undef size_t 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 c7a9699e3..af5b5f8fa 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 72033bdcd..3c50e1685 100644 --- a/salome_adm/unix/make_commence.in +++ b/salome_adm/unix/make_commence.in @@ -31,7 +31,7 @@ C_DEPEND_FLAG = @C_DEPEND_FLAG@ # C++ CXX = @CXX@ -CXXFLAGS = @CXXFLAGS@ +CXXFLAGS = @CXXFLAGS@ CXX_DEPEND_FLAG = @CXX_DEPEND_FLAG@ # BOOST Library @@ -78,6 +78,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/CASCatch/CASCatch_SignalsHandler.cxx b/src/CASCatch/CASCatch_SignalsHandler.cxx new file mode 100644 index 000000000..fd8cb5a0e --- /dev/null +++ b/src/CASCatch/CASCatch_SignalsHandler.cxx @@ -0,0 +1,29 @@ +// KERNEL Utils : common utils for KERNEL +// Copyright (C) 2003 CEA +// +// 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.salome-platform.org or email : webmaster.salome@opencascade.org + + +#include "CASCatch_SignalsHandler.h" +#include + + +CASCatch_SignalsHandler::CASCatch_SignalsHandler(bool theFloatingSignal) +{ + OSD::SetSignal(theFloatingSignal); +} diff --git a/src/CASCatch/CASCatch_SignalsHandler.h b/src/CASCatch/CASCatch_SignalsHandler.h new file mode 100644 index 000000000..24078c48f --- /dev/null +++ b/src/CASCatch/CASCatch_SignalsHandler.h @@ -0,0 +1,34 @@ +// KERNEL Utils : common utils for KERNEL +// Copyright (C) 2003 CEA +// +// 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.salome-platform.org or email : webmaster.salome@opencascade.org + +#ifndef _CASCATCH_SIGNALSHANDLER_H_ +#define _CASCATCH_SIGNALSHANDLER_H_ + + +#include "Utils_SignalsHandler.h" +#include + +class CASCatch_SignalsHandler: private Utils_SignalsHandler{ + public: + CASCatch_SignalsHandler(bool theFloatingSignal = true); +}; + + +#endif diff --git a/src/CASCatch/Makefile.in b/src/CASCatch/Makefile.in new file mode 100644 index 000000000..838e3e086 --- /dev/null +++ b/src/CASCatch/Makefile.in @@ -0,0 +1,50 @@ +# SALOME Utils : general SALOME's definitions and tools +# +# 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 : Makefile.in +# Author : Marc Tajchman (CEA) +# Module : SALOME +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= CASCatch_SignalsHandler.h + +# Libraries targets +LIB = libCASCatch.la +LIB_SRC = CASCatch_SignalsHandler.cxx + +CPPFLAGS += $(OCC_INCLUDES) +CXXFLAGS += $(OCC_CXXFLAGS) +LDFLAGS+= $(CAS_KERNEL) + +@CONCLUDE@ + + 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 87f372867..db16def90 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) +CPPFLAGS+= $(PYTHON_INCLUDES) $(OCC_INCLUDES) +CXXFLAGS+=$(OCC_CXXFLAGS) LDFLAGS+= -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification -lSALOMELocalTrace -LIBS += -Xlinker -export-dynamic $(PYTHON_LIBS) +LIBS += -Xlinker -export-dynamic $(PYTHON_LIBS) -lCASCatch @CONCLUDE@ 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 921c3ce26..d8cd500a3 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 @@ -44,189 +42,163 @@ 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 - { - - // 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" ); + + try{ + // 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 + +#include "CASCatch_SignalsHandler.h" // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + + +extern "C" void HandleServerSideSignals(CORBA::ORB_ptr theORB) +{ + CASCatch_SignalsHandler aSignalsHandler; + try { + theORB->run(); + }catch(Standard_Failure){ + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + throw std::runtime_error(aFail->GetMessageString()); + } +} diff --git a/src/Container/SALOME_Container_i.hxx b/src/Container/SALOME_Container_i.hxx index 4e83c867b..e960a3b83 100644 --- a/src/Container/SALOME_Container_i.hxx +++ b/src/Container/SALOME_Container_i.hxx @@ -29,21 +29,22 @@ #ifndef _SALOME_CONTAINER_I_HXX_ #define _SALOME_CONTAINER_I_HXX_ +#include +#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 5c3530e4b..d803f264f 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 \ 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_Prs.cxx b/src/OCCViewer/OCCViewer_Prs.cxx new file mode 100644 index 000000000..133bd4b71 --- /dev/null +++ b/src/OCCViewer/OCCViewer_Prs.cxx @@ -0,0 +1,112 @@ +// SALOME OCCViewer : build OCC Viewer into Salome desktop +// +// Copyright (C) 2004 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.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : OCCViewer_Prs.cxx +// Author : Sergey ANIKIN +// Module : SALOME +// $Header$ + +#include "OCCViewer_Prs.h" + +//========================================================== +/*! + * OCCViewer_Prs::OCCViewer_Prs + * Default constructor + */ +//========================================================== +OCCViewer_Prs::OCCViewer_Prs() +{ + myToActivate = true; +} + +//========================================================== +/*! + * OCCViewer_Prs::OCCViewer_Prs + * Standard constructor + */ +//========================================================== +OCCViewer_Prs::OCCViewer_Prs( const Handle(AIS_InteractiveObject)& obj ) +{ + AddObject( obj ); +} + +//========================================================== +/*! + * OCCViewer_Prs::~OCCViewer_Prs + * Destructor + */ +//========================================================== +OCCViewer_Prs::~OCCViewer_Prs() +{ + myObjects.Clear(); +} + +//========================================================== +/*! + * OCCViewer_Prs::GetObjects + * Get interactive objects list + */ +//========================================================== +void OCCViewer_Prs::GetObjects( AIS_ListOfInteractive& list ) const +{ + list = myObjects; +} + +//========================================================== +/*! + * OCCViewer_Prs::AddObject + * Add interactive object + */ +//========================================================== +void OCCViewer_Prs::AddObject( const Handle(AIS_InteractiveObject)& obj ) +{ + myObjects.Append( obj ); +} + +//========================================================== +/*! + * OCCViewer_Prs::IsNull + * Return 0 if list of the interactive objects is empty + * [ Reimplemented from SALOME_Prs ] + */ +//========================================================== +bool OCCViewer_Prs::IsNull() const +{ + return myObjects.IsEmpty(); +} + +//================================================================= +/*! + * GEOM_Displayer::SetToActivate + * This method is used for activisation/deactivisation of + * objects in the moment of displaying +*/ +//================================================================= +void OCCViewer_Prs::SetToActivate( const bool toActivate ) +{ + myToActivate = toActivate; +} +bool OCCViewer_Prs::ToActivate() const +{ + return myToActivate; +} diff --git a/src/OCCViewer/OCCViewer_Prs.h b/src/OCCViewer/OCCViewer_Prs.h new file mode 100644 index 000000000..c79e59e3f --- /dev/null +++ b/src/OCCViewer/OCCViewer_Prs.h @@ -0,0 +1,69 @@ +// SALOME OCCViewer : build OCC Viewer into Salome desktop +// +// Copyright (C) 2004 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.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : OCCViewer_Prs.h +// Author : Sergey ANIKIN +// Module : SALOME +// $Header$ + +#ifndef OCCVIEWER_PRS_H +#define OCCVIEWER_PRS_H + +#include "SALOME_Prs.h" + +#include +#include + +class OCCViewer_Prs : public SALOME_OCCPrs +{ +public: + OCCViewer_Prs(); + // Default constructor + OCCViewer_Prs( const Handle(AIS_InteractiveObject)& obj ); + // Standard constructor + ~OCCViewer_Prs(); + // Destructor + + void GetObjects( AIS_ListOfInteractive& list ) const; + // Get interactive objects list + void AddObject( const Handle(AIS_InteractiveObject)& obj ); + // Add interactive object + + bool IsNull() const; + // Reimplemented from SALOME_Prs + + /* This method is used for activisation/deactivisation of + objects in the moment of displaying */ + void SetToActivate( const bool ); + bool ToActivate() const; + +private: + AIS_ListOfInteractive myObjects; // list of interactive objects + bool myToActivate; +}; + +#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/LICENSE.QPL b/src/PatchQt/LICENSE.QPL new file mode 100644 index 000000000..ecdad6ef5 --- /dev/null +++ b/src/PatchQt/LICENSE.QPL @@ -0,0 +1,103 @@ + THE Q PUBLIC LICENSE + version 1.0 + + Copyright (C) 1999-2000 Trolltech AS, Norway. + Everyone is permitted to copy and + distribute this license document. + +The intent of this license is to establish freedom to share and change the +software regulated by this license under the open source model. + +This license applies to any software containing a notice placed by the +copyright holder saying that it may be distributed under the terms of +the Q Public License version 1.0. Such software is herein referred to as +the Software. This license covers modification and distribution of the +Software, use of third-party application programs based on the Software, +and development of free software which uses the Software. + + Granted Rights + +1. You are granted the non-exclusive rights set forth in this license + provided you agree to and comply with any and all conditions in this + license. Whole or partial distribution of the Software, or software + items that link with the Software, in any form signifies acceptance of + this license. + +2. You may copy and distribute the Software in unmodified form provided + that the entire package, including - but not restricted to - copyright, + trademark notices and disclaimers, as released by the initial developer + of the Software, is distributed. + +3. You may make modifications to the Software and distribute your + modifications, in a form that is separate from the Software, such as + patches. The following restrictions apply to modifications: + + a. Modifications must not alter or remove any copyright notices in + the Software. + + b. When modifications to the Software are released under this + license, a non-exclusive royalty-free right is granted to the + initial developer of the Software to distribute your modification + in future versions of the Software provided such versions remain + available under these terms in addition to any other license(s) of + the initial developer. + +4. You may distribute machine-executable forms of the Software or + machine-executable forms of modified versions of the Software, provided + that you meet these restrictions: + + a. You must include this license document in the distribution. + + b. You must ensure that all recipients of the machine-executable forms + are also able to receive the complete machine-readable source code + to the distributed Software, including all modifications, without + any charge beyond the costs of data transfer, and place prominent + notices in the distribution explaining this. + + c. You must ensure that all modifications included in the + machine-executable forms are available under the terms of this + license. + +5. You may use the original or modified versions of the Software to + compile, link and run application programs legally developed by you + or by others. + +6. You may develop application programs, reusable components and other + software items that link with the original or modified versions of the + Software. These items, when distributed, are subject to the following + requirements: + + a. You must ensure that all recipients of machine-executable forms of + these items are also able to receive and use the complete + machine-readable source code to the items without any charge + beyond the costs of data transfer. + + b. You must explicitly license all recipients of your items to use + and re-distribute original and modified versions of the items in + both machine-executable and source code forms. The recipients must + be able to do so without any charges whatsoever, and they must be + able to re-distribute to anyone they choose. + + + c. If the items are not available to the general public, and the + initial developer of the Software requests a copy of the items, + then you must supply one. + + Limitations of Liability + +In no event shall the initial developers or copyright holders be liable +for any damages whatsoever, including - but not restricted to - lost +revenue or profits or other direct, indirect, special, incidental or +consequential damages, even if they have been advised of the possibility +of such damages, except to the extent invariable law, if any, provides +otherwise. + + No Warranty + +The Software and this license document are provided AS IS with NO WARRANTY +OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE. + Choice of Law + +This license is governed by the Laws of Norway. Disputes shall be settled +by Oslo City Court. 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/README b/src/PatchQt/README new file mode 100644 index 000000000..4a1c1a3bd --- /dev/null +++ b/src/PatchQt/README @@ -0,0 +1,2 @@ +This package includes the patch for Qt toolkit. +The files in this package are distributed under conditions of the Q Public License. \ No newline at end of file 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/qfiledialogP.cxx b/src/PatchQt/qfiledialogP.cxx new file mode 100644 index 000000000..0b3ca637b --- /dev/null +++ b/src/PatchQt/qfiledialogP.cxx @@ -0,0 +1,5978 @@ +///////////////////////////////////////////////////////////////////////////// +// Module : PatchQt +// File : qfiledialogP.cxx +// Description : the patch for Qt's QFileDialog class (qfiledialog.cpp) +///////////////////////////////////////////////////////////////////////////// + +/**************************************************************************** +** $Id$ +** +** Implementation of QFileDialog class +** +** Created : 950429 +** +** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** +** This file is part of the dialogs 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 "qplatformdefs.h" + +// Solaris redefines connect -> __xnet_connect with _XOPEN_SOURCE_EXTENDED. +#if defined(connect) +#undef connect +#endif + +#include "qfiledialogP.h" + +#ifndef QT_NO_FILEDIALOG + +#include "qlineedit.h" +#include "qcombobox.h" +#include "qlistview.h" +#include "qlistbox.h" +#include "qlabel.h" +#include "qpushbutton.h" +#include "qtoolbutton.h" +#include "qmessagebox.h" +#include "qapplication.h" +#include "private/qapplication_p.h" +#include "qlayout.h" +#include "qbitmap.h" +#include "qpopupmenu.h" +#include "qwidgetstack.h" +#include "qbuttongroup.h" +#include "qptrvector.h" +#include "qregexp.h" +#include "qstrlist.h" +#include "qtimer.h" +#include "qvbox.h" +#include "qhbox.h" +#include "qtooltip.h" +#include "qheader.h" +#include "qdragobject.h" +#include "qmime.h" +#include "qprogressbar.h" +#include "qfile.h" +#include "qcstring.h" +#include "qobjectlist.h" +#include "qcheckbox.h" +#include "qsplitter.h" +#include "qmap.h" +#include "qnetworkprotocol.h" +#include "qsemimodal.h" +#include "qpainter.h" +#include "qcleanuphandler.h" +#include "qstyle.h" +#include "qcursor.h" + +#ifndef Q_OS_TEMP +#include +#endif +#include +#include + +#ifdef Q_WS_MAC +#include "qt_mac.h" +#undef check +#endif + +#ifdef Q_WS_WIN +#include "qt_windows.h" +#endif + +/* XPM */ +static const char * const start_xpm[]={ + "16 15 8 1", + "a c #cec6bd", + "# c #000000", + "e c #ffff00", + "b c #999999", + "f c #cccccc", + "d c #dcdcdc", + "c c #ffffff", + ". c None", + ".....######aaaaa", + "...bb#cccc##aaaa", + "..bcc#cccc#d#aaa", + ".bcef#cccc#dd#aa", + ".bcfe#cccc#####a", + ".bcef#ccccccccc#", + "bbbbbbbbbbbbccc#", + "bccccccccccbbcc#", + "bcefefefefee#bc#", + ".bcefefefefef#c#", + ".bcfefefefefe#c#", + "..bcfefefefeeb##", + "..bbbbbbbbbbbbb#", + "...#############", + "................"}; + +/* XPM */ +static const char * const end_xpm[]={ + "16 15 9 1", + "d c #a0a0a0", + "c c #c3c3c3", + "# c #cec6bd", + ". c #000000", + "f c #ffff00", + "e c #999999", + "g c #cccccc", + "b c #ffffff", + "a c None", + "......####aaaaaa", + ".bbbb..###aaaaaa", + ".bbbb.c.##aaaaaa", + ".bbbb....ddeeeea", + ".bbbbbbb.bbbbbe.", + ".bbbbbbb.bcfgfe.", + "eeeeeeeeeeeeefe.", + "ebbbbbbbbbbeege.", + "ebfgfgfgfgff.ee.", + "aebfgfgfgfgfg.e.", + "aebgfgfgfgfgf.e.", + "aaebgfgfgfgffe..", + "aaeeeeeeeeeeeee.", + "aaa.............", + "aaaaaaaaaaaaaaaa"}; + +/* XPM */ +static const char* const open_xpm[]={ + "16 16 6 1", + ". c None", + "b c #ffff00", + "d c #000000", + "* c #999999", + "c c #cccccc", + "a c #ffffff", + "................", + "................", + "...*****........", + "..*aaaaa*.......", + ".*abcbcba******.", + ".*acbcbcaaaaaa*d", + ".*abcbcbcbcbcb*d", + "*************b*d", + "*aaaaaaaaaa**c*d", + "*abcbcbcbcbbd**d", + ".*abcbcbcbcbcd*d", + ".*acbcbcbcbcbd*d", + "..*acbcbcbcbb*dd", + "..*************d", + "...ddddddddddddd", + "................"}; + +/* XPM */ +static const char * const link_dir_xpm[]={ + "16 16 10 1", + "h c #808080", + "g c #a0a0a0", + "d c #000000", + "b c #ffff00", + "f c #303030", + "# c #999999", + "a c #cccccc", + "e c #585858", + "c c #ffffff", + ". c None", + "................", + "................", + "..#####.........", + ".#ababa#........", + "#abababa######..", + "#cccccccccccc#d.", + "#cbababababab#d.", + "#cabababababa#d.", + "#cbababdddddddd.", + "#cababadccccccd.", + "#cbababdcececcd.", + "#cababadcefdfcd.", + "#cbababdccgdhcd.", + "#######dccchccd.", + ".dddddddddddddd.", + "................"}; + +/* XPM */ +static const char * const link_file_xpm[]={ + "16 16 10 1", + "h c #808080", + "g c #a0a0a0", + "d c #c3c3c3", + ". c #7f7f7f", + "c c #000000", + "b c #bfbfbf", + "f c #303030", + "e c #585858", + "a c #ffffff", + "# c None", + "################", + "..........######", + ".aaaaaaaab.#####", + ".aaaaaaaaba.####", + ".aaaaaaaacccc###", + ".aaaaaaaaaabc###", + ".aaaaaaaaaabc###", + ".aaaaaaaaaadc###", + ".aaaaaaaaaadc###", + ".aaaacccccccc###", + ".aaaacaaaaaac###", + ".aaaacaeaeaac###", + ".aaaacaefcfac###", + ".aaaacaagchac###", + ".ddddcaaahaac###", + "ccccccccccccc###"}; + +/* XPM */ +static const char* const file_xpm[]={ + "16 16 5 1", + ". c #7f7f7f", + "# c None", + "c c #000000", + "b c #bfbfbf", + "a c #ffffff", + "################", + "..........######", + ".aaaaaaaab.#####", + ".aaaaaaaaba.####", + ".aaaaaaaacccc###", + ".aaaaaaaaaabc###", + ".aaaaaaaaaabc###", + ".aaaaaaaaaabc###", + ".aaaaaaaaaabc###", + ".aaaaaaaaaabc###", + ".aaaaaaaaaabc###", + ".aaaaaaaaaabc###", + ".aaaaaaaaaabc###", + ".aaaaaaaaaabc###", + ".bbbbbbbbbbbc###", + "ccccccccccccc###"}; + +/* XPM */ +static const char * const closed_xpm[]={ + "16 16 6 1", + ". c None", + "b c #ffff00", + "d c #000000", + "* c #999999", + "a c #cccccc", + "c c #ffffff", + "................", + "................", + "..*****.........", + ".*ababa*........", + "*abababa******..", + "*cccccccccccc*d.", + "*cbababababab*d.", + "*cabababababa*d.", + "*cbababababab*d.", + "*cabababababa*d.", + "*cbababababab*d.", + "*cabababababa*d.", + "*cbababababab*d.", + "**************d.", + ".dddddddddddddd.", + "................"}; + + +/* XPM */ +static const char* const cdtoparent_xpm[]={ + "15 13 3 1", + ". c None", + "* c #000000", + "a c #ffff99", + "..*****........", + ".*aaaaa*.......", + "***************", + "*aaaaaaaaaaaaa*", + "*aaaa*aaaaaaaa*", + "*aaa***aaaaaaa*", + "*aa*****aaaaaa*", + "*aaaa*aaaaaaaa*", + "*aaaa*aaaaaaaa*", + "*aaaa******aaa*", + "*aaaaaaaaaaaaa*", + "*aaaaaaaaaaaaa*", + "***************"}; + + +/* XPM */ +static const char* const newfolder_xpm[] = { + "15 14 4 1", + " c None", + ". c #000000", + "+ c #FFFF00", + "@ c #FFFFFF", + " . ", + " ", + " . ", + " . . ", + " .... . . . ", + " .+@+@. . . ", + ".......... . .", + ".@+@+@+@+@.. ", + ".+@+@+@+@+. . ", + ".@+@+@+@+@. . ", + ".+@+@+@+@+. ", + ".@+@+@+@+@. ", + ".+@+@+@+@+. ", + "........... "}; + +/* XPM */ +static const char* const detailedview_xpm[]={ + "14 11 3 1", + ". c None", + "* c #000000", + "a c #000099", + ".****.***.***.", + "..............", + "aaaaaaaaaaaaaa", + "..............", + ".****.***.***.", + "..............", + ".****.***.***.", + "..............", + ".****.***.***.", + "..............", + ".****.***.***."}; + +/* XPM */ +static const char* const previewinfoview_xpm[]={ + "13 13 4 1", + ". c #00007f", + "a c black", + "# c #cec6bd", + "b c #000000", + "..#####aaaaaa", + ".#.#bb#a#####", + "...####a#bbb#", + "#######a#####", + "#######a#bb##", + "..#####a#####", + ".#.#bb#a#bbb#", + "...####a#####", + "#######a#bb##", + "#######a#####", + "..#####a#bbb#", + ".#.#bb#a#####", + "...####aaaaaa"}; + +/* XPM */ +static const char* const previewcontentsview_xpm[]={ + "14 13 5 1", + ". c #00007f", + "a c black", + "c c #7f007f", + "# c #cec6bd", + "b c #000000", + "..#####aaaaaaa", + ".#.#bb#a#####a", + "...####a#ccc#a", + "#######a#ccc#a", + "#######a#####a", + "..#####a#bbb#a", + ".#.#bb#a#####a", + "...####a#bbb#a", + "#######a#####a", + "#######a#bbb#a", + "..#####a#####a", + ".#.#bb#a#####a", + "...####aaaaaaa"}; + +/* XPM */ +static const char* const mclistview_xpm[]={ + "15 11 4 1", + "* c None", + "b c #000000", + ". c #000099", + "a c #ffffff", + "...*****...****", + ".a.*bbb*.a.*bbb", + "...*****...****", + "***************", + "...*****...****", + ".a.*bbb*.a.*bbb", + "...*****...****", + "***************", + "...*****...****", + ".a.*bbb*.a.*bbb", + "...*****...****"}; + +/* XPM */ +static const char * const back_xpm [] = { + "13 11 3 1", + "a c #00ffff", + "# c #000000", + ". c None", + ".....#.......", + "....##.......", + "...#a#.......", + "..#aa########", + ".#aaaaaaaaaa#", + "#aaaaaaaaaaa#", + ".#aaaaaaaaaa#", + "..#aa########", + "...#a#.......", + "....##.......", + ".....#......."}; + +static QPixmap * openFolderIcon = 0; +static QPixmap * closedFolderIcon = 0; +static QPixmap * detailViewIcon = 0; +static QPixmap * multiColumnListViewIcon = 0; +static QPixmap * cdToParentIcon = 0; +static QPixmap * newFolderIcon = 0; +static QPixmap * fifteenTransparentPixels = 0; +static QPixmap * symLinkDirIcon = 0; +static QPixmap * symLinkFileIcon = 0; +static QPixmap * fileIcon = 0; +static QPixmap * startCopyIcon = 0; +static QPixmap * endCopyIcon = 0; +static QPixmap * previewContentsViewIcon = 0; +static QPixmap * previewInfoViewIcon = 0; +static QPixmap *goBackIcon = 0; +static QFileIconProviderP * fileIconProvider = 0; +static QSize *lastSize = 0; +static QString * workingDirectory = 0; + +static bool bShowHiddenFiles = FALSE; +static int sortFilesBy = (int)QDir::Name; +static bool sortAscending = TRUE; +static bool detailViewMode = FALSE; + +static QCleanupHandler qfd_cleanup_pixmap; +static QCleanupHandler qfd_cleanup_size; +static QCleanupHandler qfd_cleanup_string; + +static bool isDirectoryMode( int m ) +{ + return m == QFileDialogP::Directory || m == QFileDialogP::DirectoryOnly; +} + +#if defined(Q_WS_WIN) + +class QWindowsIconProvider : public QFileIconProviderP +{ +public: + QWindowsIconProvider( QObject *parent=0, const char *name=0 ); + ~QWindowsIconProvider(); + + const QPixmap * pixmap( const QFileInfo &fi ); + +private: + QPixmap defaultFolder; + QPixmap defaultFile; + QPixmap defaultExe; + QPixmap pix; + int pixw, pixh; + QMap< QString, QPixmap > cache; +}; +#endif + +static void makeVariables() { + if ( !openFolderIcon ) { + workingDirectory = new QString( QDir::currentDirPath() ); + qfd_cleanup_string.add( &workingDirectory ); + + openFolderIcon = new QPixmap( (const char **)open_xpm); + qfd_cleanup_pixmap.add( &openFolderIcon ); + symLinkDirIcon = new QPixmap( (const char **)link_dir_xpm); + qfd_cleanup_pixmap.add( &symLinkDirIcon ); + symLinkFileIcon = new QPixmap( (const char **)link_file_xpm); + qfd_cleanup_pixmap.add( &symLinkFileIcon ); + fileIcon = new QPixmap( (const char **)file_xpm); + qfd_cleanup_pixmap.add( &fileIcon ); + closedFolderIcon = new QPixmap( (const char **)closed_xpm); + qfd_cleanup_pixmap.add( &closedFolderIcon ); + detailViewIcon = new QPixmap( (const char **)detailedview_xpm); + qfd_cleanup_pixmap.add( &detailViewIcon ); + multiColumnListViewIcon = new QPixmap( (const char **)mclistview_xpm); + qfd_cleanup_pixmap.add( &multiColumnListViewIcon ); + cdToParentIcon = new QPixmap( (const char **)cdtoparent_xpm); + qfd_cleanup_pixmap.add( &cdToParentIcon ); + newFolderIcon = new QPixmap( (const char **)newfolder_xpm); + qfd_cleanup_pixmap.add( &newFolderIcon ); + previewInfoViewIcon + = new QPixmap( (const char **)previewinfoview_xpm ); + qfd_cleanup_pixmap.add( &previewInfoViewIcon ); + previewContentsViewIcon + = new QPixmap( (const char **)previewcontentsview_xpm ); + qfd_cleanup_pixmap.add( &previewContentsViewIcon ); + startCopyIcon = new QPixmap( (const char **)start_xpm ); + qfd_cleanup_pixmap.add( &startCopyIcon ); + endCopyIcon = new QPixmap( (const char **)end_xpm ); + qfd_cleanup_pixmap.add( &endCopyIcon ); + goBackIcon = new QPixmap( (const char **)back_xpm ); + qfd_cleanup_pixmap.add( &goBackIcon ); + fifteenTransparentPixels = new QPixmap( closedFolderIcon->width(), 1 ); + qfd_cleanup_pixmap.add( &fifteenTransparentPixels ); + QBitmap m( fifteenTransparentPixels->width(), 1 ); + m.fill( Qt::color0 ); + fifteenTransparentPixels->setMask( m ); + bShowHiddenFiles = FALSE; + sortFilesBy = (int)QDir::Name; + detailViewMode = FALSE; +#if defined(Q_WS_WIN) + if ( !fileIconProvider ) + fileIconProvider = new QWindowsIconProvider( qApp ); +#endif + } +} + +QFDProgressAnimation::QFDProgressAnimation( QWidget *parent ) + : QWidget( parent, "qt_progressanimation" ) +{ + setFixedSize( 300, 50 ); + step = -1; + next(); + timer = new QTimer( this ); + connect( timer, SIGNAL( timeout() ), + this, SLOT( next() ) ); +} + +void QFDProgressAnimation::start() +{ + timer->start( 150, FALSE ); +} + +void QFDProgressAnimation::next() +{ + ++step; + if ( step > 10 ) + step = 0; + repaint(); +} + +void QFDProgressAnimation::paintEvent( QPaintEvent * ) +{ + erase(); + + QPainter p; + p.begin( this ); + if ( step == 0 ) { + p.drawPixmap( 5, ( height() - startCopyIcon->height() ) / 2, + *startCopyIcon ); + p.drawPixmap( width() - 5 - openFolderIcon->width(), + ( height() - openFolderIcon->height() ) / 2 , *openFolderIcon ); + } else if ( step == 10 ) { + p.drawPixmap( 5, ( height() - openFolderIcon->height() ) / 2, + *openFolderIcon ); + p.drawPixmap( width() - 5 - endCopyIcon->width(), + ( height() - endCopyIcon->height() ) / 2 , *endCopyIcon ); + } else { + p.drawPixmap( 5, ( height() - openFolderIcon->height() ) / 2, + *openFolderIcon ); + p.drawPixmap( width() - 5 - openFolderIcon->width(), + ( height() - openFolderIcon->height() ) / 2 , *openFolderIcon ); + int x = 10 + openFolderIcon->width(); + int w = width() - 2 * x; + int s = w / 9; + p.drawPixmap( x + s * step, ( height() - fileIcon->height() ) / 2 - fileIcon->height(), + *fileIcon ); + } +} + +QFDProgressDialog::QFDProgressDialog( QWidget *parent, const QString &fn, int steps ) + : QDialog( parent, "", TRUE ) +{ +#ifndef QT_NO_WIDGET_TOPEXTRA + setCaption( QFileDialogP::tr( "Copy or Move a File" ) ); +#endif + QVBoxLayout *layout = new QVBoxLayout( this ); + layout->setSpacing( 5 ); + layout->setMargin( 5 ); + + animation = new QFDProgressAnimation( this ); + layout->addWidget( animation ); + + layout->addWidget( new QLabel( QFileDialogP::tr( "Read: %1" ).arg( fn ), + this, "qt_read_lbl" ) ); + readBar = new QProgressBar( steps, this, "qt_readbar" ); + readBar->reset(); + readBar->setProgress( 0 ); + layout->addWidget( readBar ); + writeLabel = new QLabel( QFileDialogP::tr( "Write: %1" ).arg( QString::null ), + this, "qt_write_lbl" ); + layout->addWidget( writeLabel ); + writeBar = new QProgressBar( steps, this, "qt_writebar" ); + writeBar->reset(); + writeBar->setProgress( 0 ); + layout->addWidget( writeBar ); + + QPushButton *b = new QPushButton( QFileDialogP::tr( "Cancel" ), this, + "qt_cancel_btn" ); + b->setFixedSize( b->sizeHint() ); + layout->addWidget( b ); + connect( b, SIGNAL( clicked() ), + this, SIGNAL( cancelled() ) ); + + animation->start(); +} + +void QFDProgressDialog::setReadProgress( int p ) +{ + readBar->setProgress( p ); +} + +void QFDProgressDialog::setWriteProgress( int p ) +{ + writeBar->setProgress( p ); +} + +void QFDProgressDialog::setWriteLabel( const QString &s ) +{ + writeLabel->setText( QFileDialogP::tr( "Write: %1" ).arg( s ) ); +} + +/************************************************************************ + * + * Private QFileDialogP members + * + ************************************************************************/ + +class QFileDialogPrivate { +public: + ~QFileDialogPrivate(); + + QStringList history; + + bool geometryDirty; + QComboBox * paths; + QComboBox * types; + QLabel * pathL; + QLabel * fileL; + QLabel * typeL; + + QVBoxLayout * topLevelLayout; + QHBoxLayout *buttonLayout, *leftLayout, *rightLayout; + QPtrList extraWidgetsLayouts; + QPtrList extraLabels; + QPtrList extraWidgets; + QPtrList extraButtons; + QPtrList toolButtons; + + QWidgetStack * stack; + + QToolButton * cdToParent, *newFolder, * detailView, * mcView, + *previewInfo, *previewContents, *goBack; + QButtonGroup * modeButtons; + + QString currentFileName; + QListViewItem *last; + + struct File: public QListViewItem { + File( QFileDialogPrivate * dlgp, + const QUrlInfo * fi, QListViewItem * parent ) + : QListViewItem( parent, dlgp->last ), info( *fi ), d(dlgp), i( 0 ), hasMimePixmap( FALSE ) + { setup(); dlgp->last = this; } + File( QFileDialogPrivate * dlgp, + const QUrlInfo * fi, QListView * parent ) + : QListViewItem( parent, dlgp->last ), info( *fi ), d(dlgp), i( 0 ), hasMimePixmap( FALSE ) + { setup(); dlgp->last = this; } + File( QFileDialogPrivate * dlgp, + const QUrlInfo * fi, QListView * parent, QListViewItem * after ) + : QListViewItem( parent, after ), info( *fi ), d(dlgp), i( 0 ), hasMimePixmap( FALSE ) + { setup(); if ( !nextSibling() ) dlgp->last = this; } + ~File(); + + QString text( int column ) const; + const QPixmap * pixmap( int ) const; + + QUrlInfo info; + QFileDialogPrivate * d; + QListBoxItem *i; + bool hasMimePixmap; + }; + + class MCItem: public QListBoxItem { + public: + MCItem( QListBox *, QListViewItem * item ); + MCItem( QListBox *, QListViewItem * item, QListBoxItem *after ); + QString text() const; + const QPixmap *pixmap() const; + int height( const QListBox * ) const; + int width( const QListBox * ) const; + void paint( QPainter * ); + QListViewItem * i; + }; + + class UrlInfoList : public QPtrList { + public: + UrlInfoList() { setAutoDelete( TRUE ); } + int compareItems( QPtrCollection::Item n1, QPtrCollection::Item n2 ) { + if ( !n1 || !n2 ) + return 0; + + QUrlInfo *i1 = ( QUrlInfo *)n1; + QUrlInfo *i2 = ( QUrlInfo *)n2; + + if ( i1->isDir() && !i2->isDir() ) + return -1; + if ( !i1->isDir() && i2->isDir() ) + return 1; + + if ( i1->name() == ".." ) + return -1; + if ( i2->name() == ".." ) + return 1; + +#if defined(Q_OS_WIN32) + if ( sortFilesBy == QDir::Name ) { + QString name1 = i1->name().lower(); + QString name2 = i2->name().lower(); + return name1.compare( name2 ); + } +#endif + if ( QUrlInfo::equal( *i1, *i2, sortFilesBy ) ) + return 0; + else if ( QUrlInfo::greaterThan( *i1, *i2, sortFilesBy ) ) + return 1; + else if ( QUrlInfo::lessThan( *i1, *i2, sortFilesBy ) ) + return -1; + // can't happen... + return 0; + } + QUrlInfo *operator[]( int i ) { + return at( i ); + } + }; + + UrlInfoList sortedList; + QPtrList pendingItems; + + QFileListBox * moreFiles; + + QFileDialogP::Mode mode; + + QString rw; + QString ro; + QString wo; + QString inaccessible; + + QString symLinkToFile; + QString file; + QString symLinkToDir; + QString dir; + QString symLinkToSpecial; + QString special; + QWidgetStack *preview; + bool infoPreview, contentsPreview; + QSplitter *splitter; + QUrlOperator url, oldUrl; + QWidget *infoPreviewWidget, *contentsPreviewWidget; + QFilePreviewP *infoPreviewer, *contentsPreviewer; + bool hadDotDot; + + bool ignoreNextKeyPress; + // ignores the next refresh operation in case the user forced a selection + bool ignoreNextRefresh; + QFDProgressDialog *progressDia; + bool checkForFilter; + bool ignoreReturn; + bool ignoreStop; + + QTimer *mimeTypeTimer; + const QNetworkOperation *currListChildren; + + // this is similar to QUrl::encode but does encode "*" and + // doesn't encode whitespaces + static QString encodeFileName( const QString& fName ) { + + QString newStr; + QCString cName = fName.utf8(); + const QCString sChars( +#ifdef Q_WS_WIN + "#%" +#else + "<>#@\"&%$:,;?={}|^~[]\'`\\*" +#endif + ); + + int len = cName.length(); + if ( !len ) + return QString::null; + for ( int i = 0; i < len ;++i ) { + uchar inCh = (uchar)cName[ i ]; + if ( inCh >= 128 || sChars.contains(inCh) ) + { + newStr += QChar( '%' ); + ushort c = inCh / 16; + c += c > 9 ? 'A' - 10 : '0'; + newStr += c; + c = inCh % 16; + c += c > 9 ? 'A' - 10 : '0'; + newStr += c; + } else { + newStr += inCh; + } + } + return newStr; + } + +}; + +QFileDialogPrivate::~QFileDialogPrivate() +{ + delete modeButtons; +} + + + +/************************************************************************ + * + * Internal class QRenameEdit + * + ************************************************************************/ + +void QRenameEdit::keyPressEvent( QKeyEvent *e ) +{ + if ( e->key() == Key_Escape ) + emit escapePressed(); + else + QLineEdit::keyPressEvent( e ); + e->accept(); +} + +void QRenameEdit::focusOutEvent( QFocusEvent * ) +{ + emit escapePressed(); +} + +/************************************************************************ + * + * Internal class QFileListBox + * + ************************************************************************/ + +QFileListBox::QFileListBox( QWidget *parent, QFileDialogP *dlg ) + : QListBox( parent, "filelistbox" ), filedialog( dlg ), + renaming( FALSE ), renameItem( 0 ), mousePressed( FALSE ), + firstMousePressEvent( TRUE ) +{ + changeDirTimer = new QTimer( this ); + QVBox *box = new QVBox( viewport(), "qt_vbox" ); + box->setFrameStyle( QFrame::Box | QFrame::Plain ); + lined = new QRenameEdit( box ); + lined->setFixedHeight( lined->sizeHint().height() ); + box->hide(); + box->setBackgroundMode( PaletteBase ); + renameTimer = new QTimer( this ); + connect( lined, SIGNAL( returnPressed() ), + this, SLOT (rename() ) ); + connect( lined, SIGNAL( escapePressed() ), + this, SLOT( cancelRename() ) ); + connect( renameTimer, SIGNAL( timeout() ), + this, SLOT( doubleClickTimeout() ) ); + connect( changeDirTimer, SIGNAL( timeout() ), + this, SLOT( changeDirDuringDrag() ) ); + connect( this, SIGNAL( contentsMoving( int, int ) ), + this, SLOT( contentsMoved( int, int ) ) ); + viewport()->setAcceptDrops( TRUE ); + dragItem = 0; +} + +void QFileListBox::show() +{ + setBackgroundMode( PaletteBase ); + viewport()->setBackgroundMode( PaletteBase ); + QListBox::show(); +} + +void QFileListBox::keyPressEvent( QKeyEvent *e ) +{ + if ( ( e->key() == Key_Enter || + e->key() == Key_Return ) && + renaming ) + return; + + QString keyPressed = ((QKeyEvent *)e)->text().lower(); + QChar keyChar = keyPressed[0]; + if ( keyChar.isLetterOrNumber() ) { + QListBoxItem * i = 0; + if ( currentItem() ) + i = item( currentItem() ); + else + i = firstItem(); + if ( i->next() ) + i = i->next(); + else + i = firstItem(); + while ( i != item( currentItem() ) ) { + QString it = text( index( i ) ); + if ( it[0].lower() == keyChar ) { + clearSelection(); + setCurrentItem( i ); + } else { + if ( i->next() ) + i = i->next(); + else + i = firstItem(); + } + } + } + cancelRename(); + QListBox::keyPressEvent( e ); +} + +void QFileListBox::viewportMousePressEvent( QMouseEvent *e ) +{ + pressPos = e->pos(); + mousePressed = FALSE; + + bool didRename = renaming; + + cancelRename(); + if ( !hasFocus() && !viewport()->hasFocus() ) + setFocus(); + + if ( e->button() != LeftButton ) { + QListBox::viewportMousePressEvent( e ); + firstMousePressEvent = FALSE; + return; + } + + int i = currentItem(); + bool wasSelected = FALSE; + if ( i != -1 ) + wasSelected = item( i )->isSelected(); + QListBox::viewportMousePressEvent( e ); + + QFileDialogPrivate::MCItem *i1 = (QFileDialogPrivate::MCItem*)item( currentItem() ); + if ( i1 ) + mousePressed = !( (QFileDialogPrivate::File*)i1->i )->info.isDir(); + + if ( itemAt( e->pos() ) != item( i ) ) { + firstMousePressEvent = FALSE; + return; + } + + if ( !firstMousePressEvent && !didRename && i == currentItem() && currentItem() != -1 && + wasSelected && filedialog->mode() != QFileDialogP::ExistingFiles && + QUrlInfo( filedialog->d->url, "." ).isWritable() && item( currentItem() )->text() != ".." ) { + renameTimer->start( QApplication::doubleClickInterval(), TRUE ); + renameItem = item( i ); + } + + firstMousePressEvent = FALSE; +} + +void QFileListBox::viewportMouseReleaseEvent( QMouseEvent *e ) +{ + dragItem = 0; + QListBox::viewportMouseReleaseEvent( e ); + mousePressed = FALSE; +} + +void QFileListBox::viewportMouseDoubleClickEvent( QMouseEvent *e ) +{ + renameTimer->stop(); + QListBox::viewportMouseDoubleClickEvent( e ); +} + +void QFileListBox::viewportMouseMoveEvent( QMouseEvent *e ) +{ + if ( !dragItem ) + dragItem = itemAt( e->pos() ); + renameTimer->stop(); +#ifndef QT_NO_DRAGANDDROP + if ( ( pressPos - e->pos() ).manhattanLength() > QApplication::startDragDistance() && mousePressed ) { + QListBoxItem *item = dragItem; + dragItem = 0; + if ( item ) { + if ( !itemRect( item ).contains( e->pos() ) ) + return; + QUriDrag* drag = new QUriDrag( viewport() ); + drag->setUnicodeUris( filedialog->selectedFiles() ); + + if ( lined->parentWidget()->isVisible() ) + cancelRename(); + + connect( drag, SIGNAL( destroyed() ), + this, SLOT( dragObjDestroyed() ) ); + drag->drag(); + + mousePressed = FALSE; + } + } else +#endif + { + QListBox::viewportMouseMoveEvent( e ); + } + +} + +void QFileListBox::dragObjDestroyed() +{ +#ifndef QT_NO_DRAGANDDROP + //####### + //filedialog->rereadDir(); +#endif +} + +#ifndef QT_NO_DRAGANDDROP +void QFileListBox::viewportDragEnterEvent( QDragEnterEvent *e ) +{ + startDragUrl = filedialog->d->url; + startDragDir = filedialog->dirPath(); + currDropItem = 0; + + if ( !QUriDrag::canDecode( e ) ) { + e->ignore(); + return; + } + + QStringList l; + QUriDrag::decodeLocalFiles( e, l ); + urls = (int)l.count(); + + if ( acceptDrop( e->pos(), e->source() ) ) { + e->accept(); + setCurrentDropItem( e->pos() ); + } else { + e->ignore(); + setCurrentDropItem( QPoint( -1, -1 ) ); + } + + oldDragPos = e->pos(); +} + +void QFileListBox::viewportDragMoveEvent( QDragMoveEvent *e ) +{ + if ( acceptDrop( e->pos(), e->source() ) ) { + switch ( e->action() ) { + case QDropEvent::Copy: + e->acceptAction(); + break; + case QDropEvent::Move: + e->acceptAction(); + break; + case QDropEvent::Link: + break; + default: + break; + } + if ( oldDragPos != e->pos() ) + setCurrentDropItem( e->pos() ); + } else { + changeDirTimer->stop(); + e->ignore(); + setCurrentDropItem( QPoint( -1, -1 ) ); + } + + oldDragPos = e->pos(); +} + +void QFileListBox::viewportDragLeaveEvent( QDragLeaveEvent * ) +{ + changeDirTimer->stop(); + setCurrentDropItem( QPoint( -1, -1 ) ); +//######## +// if ( startDragDir != filedialog->d->url ) +// filedialog->setUrl( startDragUrl ); +} + +void QFileListBox::viewportDropEvent( QDropEvent *e ) +{ + changeDirTimer->stop(); + + if ( !QUriDrag::canDecode( e ) ) { + e->ignore(); + return; + } + + QStrList l; + QUriDrag::decode( e, l ); + + bool move = e->action() == QDropEvent::Move; +// bool supportAction = move || e->action() == QDropEvent::Copy; + + QUrlOperator dest; + if ( currDropItem ) + dest = QUrlOperator( filedialog->d->url, QFileDialogPrivate::encodeFileName( currDropItem->text() ) ); + else + dest = filedialog->d->url; + QStringList lst; + for ( uint i = 0; i < l.count(); ++i ) { + lst << l.at( i ); + } + + filedialog->d->url.copy( lst, dest, move ); + + // ##### what is supportAction for? + e->acceptAction(); + currDropItem = 0; +} + +bool QFileListBox::acceptDrop( const QPoint &pnt, QWidget *source ) +{ + QListBoxItem *item = itemAt( pnt ); + if ( !item || item && !itemRect( item ).contains( pnt ) ) { + if ( source == viewport() && startDragDir == filedialog->dirPath() ) + return FALSE; + return TRUE; + } + + QUrlInfo fi( filedialog->d->url, item->text() ); + + if ( fi.isDir() && itemRect( item ).contains( pnt ) ) + return TRUE; + return FALSE; +} + +void QFileListBox::setCurrentDropItem( const QPoint &pnt ) +{ + changeDirTimer->stop(); + + QListBoxItem *item = 0; + if ( pnt != QPoint( -1, -1 ) ) + item = itemAt( pnt ); + if ( item && !QUrlInfo( filedialog->d->url, item->text() ).isDir() ) + item = 0; + if ( item && !itemRect( item ).contains( pnt ) ) + item = 0; + + currDropItem = item; + if ( currDropItem ) + setCurrentItem( currDropItem ); + changeDirTimer->start( 750 ); +} +#endif // QT_NO_DRAGANDDROP + +void QFileListBox::changeDirDuringDrag() +{ +#ifndef QT_NO_DRAGANDDROP + if ( !currDropItem ) + return; + changeDirTimer->stop(); + QUrl u( filedialog->d->url, QFileDialogPrivate::encodeFileName(currDropItem->text()) ); + filedialog->setDir( u ); + currDropItem = 0; +#endif +} + +void QFileListBox::doubleClickTimeout() +{ + startRename(); + renameTimer->stop(); +} + +void QFileListBox::startRename( bool check ) +{ + if ( check && ( !renameItem || renameItem != item( currentItem() ) ) ) + return; + + int i = currentItem(); + setSelected( i, TRUE ); + QRect r = itemRect( item( i ) ); + int bdr = item( i )->pixmap() ? + item( i )->pixmap()->width() : 16; + int x = r.x() + bdr; + int y = r.y(); + int w = item( i )->width( this ) - bdr; + int h = QMAX( lined->height() + 2, r.height() ); + y = y + r.height() / 2 - h / 2; + + lined->parentWidget()->setGeometry( x, y, w + 6, h ); + lined->setFocus(); + lined->setText( item( i )->text() ); + lined->selectAll(); + lined->setFrame( FALSE ); + lined->parentWidget()->show(); + viewport()->setFocusProxy( lined ); + renaming = TRUE; +} + +void QFileListBox::clear() +{ + cancelRename(); + QListBox::clear(); +} + +void QFileListBox::rename() +{ + if ( !lined->text().isEmpty() ) { + QString file = currentText(); + + if ( lined->text() != file ) + filedialog->d->url.rename( file, lined->text() ); + } + cancelRename(); +} + +void QFileListBox::cancelRename() +{ + renameItem = 0; + lined->parentWidget()->hide(); + viewport()->setFocusProxy( this ); + renaming = FALSE; + updateItem( currentItem() ); + if ( lined->hasFocus() ) + viewport()->setFocus(); +} + +void QFileListBox::contentsMoved( int, int ) +{ + changeDirTimer->stop(); +#ifndef QT_NO_DRAGANDDROP + setCurrentDropItem( QPoint( -1, -1 ) ); +#endif +} + +/************************************************************************ + * + * Internal class QFileListView + * + ************************************************************************/ + +QFileDialogQFileListView::QFileDialogQFileListView( QWidget *parent, QFileDialogP *dlg ) + : QListView( parent, "qt_filedlg_listview" ), renaming( FALSE ), renameItem( 0 ), + filedialog( dlg ), mousePressed( FALSE ), + firstMousePressEvent( TRUE ) +{ + changeDirTimer = new QTimer( this ); + QVBox *box = new QVBox( viewport(), "qt_vbox" ); + box->setFrameStyle( QFrame::Box | QFrame::Plain ); + lined = new QRenameEdit( box ); + lined->setFixedHeight( lined->sizeHint().height() ); + box->hide(); + box->setBackgroundMode( PaletteBase ); + renameTimer = new QTimer( this ); + connect( lined, SIGNAL( returnPressed() ), + this, SLOT (rename() ) ); + connect( lined, SIGNAL( escapePressed() ), + this, SLOT( cancelRename() ) ); + header()->setMovingEnabled( FALSE ); + connect( renameTimer, SIGNAL( timeout() ), + this, SLOT( doubleClickTimeout() ) ); + connect( changeDirTimer, SIGNAL( timeout() ), + this, SLOT( changeDirDuringDrag() ) ); + disconnect( header(), SIGNAL( sectionClicked( int ) ), + this, SLOT( changeSortColumn( int ) ) ); + connect( header(), SIGNAL( sectionClicked( int ) ), + this, SLOT( changeSortColumn2( int ) ) ); + connect( this, SIGNAL( contentsMoving( int, int ) ), + this, SLOT( contentsMoved( int, int ) ) ); + + viewport()->setAcceptDrops( TRUE ); + sortcolumn = 0; + ascending = TRUE; + dragItem = 0; +} + +void QFileDialogQFileListView::setSorting( int column, bool increasing ) +{ + if ( column == -1 ) { + QListView::setSorting( column, increasing ); + return; + } + + sortAscending = ascending = increasing; + sortcolumn = column; + switch ( column ) { + case 0: + sortFilesBy = QDir::Name; + break; + case 1: + sortFilesBy = QDir::Size; + break; + case 3: + sortFilesBy = QDir::Time; + break; + default: + sortFilesBy = QDir::Name; // #### ??? + break; + } + + filedialog->resortDir(); +} + +void QFileDialogQFileListView::changeSortColumn2( int column ) +{ + int lcol = header()->mapToLogical( column ); + setSorting( lcol, sortcolumn == lcol ? !ascending : TRUE ); +} + +void QFileDialogQFileListView::keyPressEvent( QKeyEvent *e ) +{ + if ( ( e->key() == Key_Enter || + e->key() == Key_Return ) && + renaming ) + return; + + QString keyPressed = e->text().lower(); + QChar keyChar = keyPressed[0]; + if ( keyChar.isLetterOrNumber() ) { + QListViewItem * i = 0; + if ( currentItem() ) + i = currentItem(); + else + i = firstChild(); + if ( i->nextSibling() ) + i = i->nextSibling(); + else + i = firstChild(); + while ( i != currentItem() ) { + QString it = i->text(0); + if ( it[0].lower() == keyChar ) { + clearSelection(); + ensureItemVisible( i ); + setCurrentItem( i ); + } else { + if ( i->nextSibling() ) + i = i->nextSibling(); + else + i = firstChild(); + } + } + return; + } + + cancelRename(); + QListView::keyPressEvent( e ); +} + +void QFileDialogQFileListView::viewportMousePressEvent( QMouseEvent *e ) +{ + pressPos = e->pos(); + mousePressed = FALSE; + + bool didRename = renaming; + cancelRename(); + if ( !hasFocus() && !viewport()->hasFocus() ) + setFocus(); + + if ( e->button() != LeftButton ) { + QListView::viewportMousePressEvent( e ); + firstMousePressEvent = FALSE; + return; + } + + QListViewItem *i = currentItem(); + QListView::viewportMousePressEvent( e ); + + QFileDialogPrivate::File *i1 = (QFileDialogPrivate::File*)currentItem(); + if ( i1 ) + mousePressed = !i1->info.isDir(); + + if ( itemAt( e->pos() ) != i || + e->x() + contentsX() > columnWidth( 0 ) ) { + firstMousePressEvent = FALSE; + return; + } + + if ( !firstMousePressEvent && !didRename && i == currentItem() && currentItem() && + filedialog->mode() != QFileDialogP::ExistingFiles && + QUrlInfo( filedialog->d->url, "." ).isWritable() && currentItem()->text( 0 ) != ".." ) { + renameTimer->start( QApplication::doubleClickInterval(), TRUE ); + renameItem = currentItem(); + } + + firstMousePressEvent = FALSE; +} + +void QFileDialogQFileListView::viewportMouseDoubleClickEvent( QMouseEvent *e ) +{ + renameTimer->stop(); + QListView::viewportMouseDoubleClickEvent( e ); +} + +void QFileDialogQFileListView::viewportMouseReleaseEvent( QMouseEvent *e ) +{ + QListView::viewportMouseReleaseEvent( e ); + mousePressed = FALSE; + dragItem = 0; +} + +void QFileDialogQFileListView::viewportMouseMoveEvent( QMouseEvent *e ) +{ + renameTimer->stop(); + if ( !dragItem ) + dragItem = itemAt( e->pos() ); +#ifndef QT_NO_DRAGANDDROP + if ( ( pressPos - e->pos() ).manhattanLength() > QApplication::startDragDistance() && mousePressed ) { + QListViewItem *item = dragItem; + dragItem = 0; + if ( item ) { + QUriDrag* drag = new QUriDrag( viewport() ); + drag->setUnicodeUris( filedialog->selectedFiles() ); + + if ( lined->isVisible() ) + cancelRename(); + + connect( drag, SIGNAL( destroyed() ), + this, SLOT( dragObjDestroyed() ) ); + drag->drag(); + + mousePressed = FALSE; + } + } +#endif +} + +void QFileDialogQFileListView::dragObjDestroyed() +{ +#ifndef QT_NO_DRAGANDDROP + //###### + //filedialog->rereadDir(); +#endif +} + +#ifndef QT_NO_DRAGANDDROP +void QFileDialogQFileListView::viewportDragEnterEvent( QDragEnterEvent *e ) +{ + startDragUrl = filedialog->d->url; + startDragDir = filedialog->dirPath(); + currDropItem = 0; + + if ( !QUriDrag::canDecode( e ) ) { + e->ignore(); + return; + } + + QStringList l; + QUriDrag::decodeLocalFiles( e, l ); + urls = (int)l.count(); + + if ( acceptDrop( e->pos(), e->source() ) ) { + e->accept(); + setCurrentDropItem( e->pos() ); + } else { + e->ignore(); + setCurrentDropItem( QPoint( -1, -1 ) ); + } + + oldDragPos = e->pos(); +} + +void QFileDialogQFileListView::viewportDragMoveEvent( QDragMoveEvent *e ) +{ + if ( acceptDrop( e->pos(), e->source() ) ) { + if ( oldDragPos != e->pos() ) + setCurrentDropItem( e->pos() ); + switch ( e->action() ) { + case QDropEvent::Copy: + e->acceptAction(); + break; + case QDropEvent::Move: + e->acceptAction(); + break; + case QDropEvent::Link: + break; + default: + break; + } + } else { + changeDirTimer->stop(); + e->ignore(); + setCurrentDropItem( QPoint( -1, -1 ) ); + } + + oldDragPos = e->pos(); +} + +void QFileDialogQFileListView::viewportDragLeaveEvent( QDragLeaveEvent * ) +{ + changeDirTimer->stop(); + setCurrentDropItem( QPoint( -1, -1 ) ); +//######## +// if ( startDragDir != filedialog->d->url ) +// filedialog->setUrl( startDragUrl ); +} + +void QFileDialogQFileListView::viewportDropEvent( QDropEvent *e ) +{ + changeDirTimer->stop(); + + if ( !QUriDrag::canDecode( e ) ) { + e->ignore(); + return; + } + + QStringList l; + QUriDrag::decodeToUnicodeUris( e, l ); + + bool move = e->action() == QDropEvent::Move; +// bool supportAction = move || e->action() == QDropEvent::Copy; + + QUrlOperator dest; + if ( currDropItem ) + dest = QUrlOperator( filedialog->d->url, QFileDialogPrivate::encodeFileName( currDropItem->text( 0 ) ) ); + else + dest = filedialog->d->url; + filedialog->d->url.copy( l, dest, move ); + + // ##### what is supportAction for? + e->acceptAction(); + currDropItem = 0; +} + +bool QFileDialogQFileListView::acceptDrop( const QPoint &pnt, QWidget *source ) +{ + QListViewItem *item = itemAt( pnt ); + if ( !item || item && !itemRect( item ).contains( pnt ) ) { + if ( source == viewport() && startDragDir == filedialog->dirPath() ) + return FALSE; + return TRUE; + } + + QUrlInfo fi( filedialog->d->url, item->text( 0 ) ); + + if ( fi.isDir() && itemRect( item ).contains( pnt ) ) + return TRUE; + return FALSE; +} + +void QFileDialogQFileListView::setCurrentDropItem( const QPoint &pnt ) +{ + changeDirTimer->stop(); + + QListViewItem *item = itemAt( pnt ); + if ( pnt == QPoint( -1, -1 ) ) + item = 0; + if ( item && !QUrlInfo( filedialog->d->url, item->text( 0 ) ).isDir() ) + item = 0; + + if ( item && !itemRect( item ).contains( pnt ) ) + item = 0; + + currDropItem = item; + + if ( currDropItem ) + setCurrentItem( currDropItem ); + + changeDirTimer->start( 750 ); +} +#endif // QT_NO_DRAGANDDROP + +void QFileDialogQFileListView::changeDirDuringDrag() +{ +#ifndef QT_NO_DRAGANDDROP + if ( !currDropItem ) + return; + changeDirTimer->stop(); + QUrl u( filedialog->d->url, QFileDialogPrivate::encodeFileName(currDropItem->text( 0 ) ) ); + filedialog->setDir( u ); + currDropItem = 0; +#endif // QT_NO_DRAGANDDROP +} + + +void QFileDialogQFileListView::doubleClickTimeout() +{ + startRename(); + renameTimer->stop(); +} + +void QFileDialogQFileListView::startRename( bool check ) +{ + if ( check && ( !renameItem || renameItem != currentItem() ) ) + return; + + QListViewItem *i = currentItem(); + setSelected( i, TRUE ); + + QRect r = itemRect( i ); + int bdr = i->pixmap( 0 ) ? + i->pixmap( 0 )->width() : 16; + int x = r.x() + bdr; + int y = r.y(); + int w = columnWidth( 0 ) - bdr; + int h = QMAX( lined->height() + 2, r.height() ); + y = y + r.height() / 2 - h / 2; + + lined->parentWidget()->setGeometry( x, y, w + 6, h ); + lined->setFocus(); + lined->setText( i->text( 0 ) ); + lined->selectAll(); + lined->setFrame( FALSE ); + lined->parentWidget()->show(); + viewport()->setFocusProxy( lined ); + renaming = TRUE; +} + +void QFileDialogQFileListView::clear() +{ + cancelRename(); + QListView::clear(); +} + +void QFileDialogQFileListView::rename() +{ + if ( !lined->text().isEmpty() ) { + QString file = currentItem()->text( 0 ); + + if ( lined->text() != file ) + filedialog->d->url.rename( file, lined->text() ); + } + cancelRename(); +} + +void QFileDialogQFileListView::cancelRename() +{ + renameItem = 0; + lined->parentWidget()->hide(); + viewport()->setFocusProxy( this ); + renaming = FALSE; + if ( currentItem() ) + currentItem()->repaint(); + if ( lined->hasFocus() ) + viewport()->setFocus(); +} + +void QFileDialogQFileListView::contentsMoved( int, int ) +{ + changeDirTimer->stop(); +#ifndef QT_NO_DRAGANDDROP + setCurrentDropItem( QPoint( -1, -1 ) ); +#endif +} + + +QFileDialogPrivate::File::~File() +{ + if ( d->pendingItems.findRef( this ) ) + d->pendingItems.removeRef( this ); +} + +QString QFileDialogPrivate::File::text( int column ) const +{ + makeVariables(); + + switch( column ) { + case 0: + return info.name(); + case 1: + if ( info.isFile() ) + return QString::number(info.size()); + else + return QString::fromLatin1(""); + case 2: + if ( info.isFile() && info.isSymLink() ) { + return d->symLinkToFile; + } else if ( info.isFile() ) { + return d->file; + } else if ( info.isDir() && info.isSymLink() ) { + return d->symLinkToDir; + } else if ( info.isDir() ) { + return d->dir; + } else if ( info.isSymLink() ) { + return d->symLinkToSpecial; + } else { + return d->special; + } + case 3: { + return info.lastModified().toString( Qt::LocalDate ); + } + case 4: + if ( info.isReadable() ) + return info.isWritable() ? d->rw : d->ro; + else + return info.isWritable() ? d->wo : d->inaccessible; + } + + return QString::fromLatin1("<--->"); +} + +const QPixmap * QFileDialogPrivate::File::pixmap( int column ) const +{ + if ( column ) { + return 0; + } else if ( QListViewItem::pixmap( column ) ) { + return QListViewItem::pixmap( column ); + } else if ( info.isSymLink() ) { + if ( info.isFile() ) + return symLinkFileIcon; + else + return symLinkDirIcon; + } else if ( info.isDir() ) { + return closedFolderIcon; + } else if ( info.isFile() ) { + return fileIcon; + } else { + return fifteenTransparentPixels; + } +} + +QFileDialogPrivate::MCItem::MCItem( QListBox * lb, QListViewItem * item ) + : QListBoxItem() +{ + i = item; + if ( lb ) + lb->insertItem( this ); +} + +QFileDialogPrivate::MCItem::MCItem( QListBox * lb, QListViewItem * item, QListBoxItem *after ) + : QListBoxItem() +{ + i = item; + if ( lb ) + lb->insertItem( this, after ); +} + +QString QFileDialogPrivate::MCItem::text() const +{ + return i->text( 0 ); +} + + +const QPixmap *QFileDialogPrivate::MCItem::pixmap() const +{ + return i->pixmap( 0 ); +} + + +int QFileDialogPrivate::MCItem::height( const QListBox * lb ) const +{ + if ( pixmap() ) + return QMAX( lb->fontMetrics().height(), pixmap()->height()) + 2; + + return lb->fontMetrics().height() + 2; +} + + +int QFileDialogPrivate::MCItem::width( const QListBox * lb ) const +{ + QFontMetrics fm = lb->fontMetrics(); + int w = 2; + if ( pixmap() ) + w += pixmap()->width() + 4; + else + w += 18; + w += fm.width( text() ); + w += -fm.minLeftBearing(); + w += -fm.minRightBearing(); + w += 6; + return w; +} + + +void QFileDialogPrivate::MCItem::paint( QPainter * ptr ) +{ + QFontMetrics fm = ptr->fontMetrics(); + + int h; + + if ( pixmap() ) + h = QMAX( fm.height(), pixmap()->height()) + 2; + else + h = fm.height() + 2; + + const QPixmap * pm = pixmap(); + if ( pm ) + ptr->drawPixmap( 2, 1, *pm ); + + ptr->drawText( pm ? pm->width() + 4 : 22, h - fm.descent() - 2, + text() ); +} + +static QStringList makeFiltersList( const QString &filter ) +{ + if ( filter.isEmpty() ) + return QStringList(); + + int i = filter.find( ";;", 0 ); + QString sep( ";;" ); + if ( i == -1 ) { + if ( filter.find( "\n", 0 ) != -1 ) { + sep = "\n"; + i = filter.find( sep, 0 ); + } + } + + return QStringList::split( sep, filter ); +} + +/*! + \class QFileDialogP qfiledialog.h + \brief The QFileDialogP class provides dialogs that allow users to select files or directories. + \ingroup dialogs + \mainclass + + The QFileDialogP class enables a user to traverse their file system in + order to select one or many files or a directory. + + The easiest way to create a QFileDialogP is to use the static + functions. On Windows, these static functions will call the native + Windows file dialog and on Mac OS X, these static function will call + the native Mac OS X file dialog. + + \code + QString s = QFileDialogP::getOpenFileName( + "/home", + "Images (*.png *.xpm *.jpg)", + this, + "open file dialog" + "Choose a file" ); + \endcode + + In the above example, a modal QFileDialogP is created using a static + function. The startup directory is set to "/home". The file filter + is set to "Images (*.png *.xpm *.jpg)". The parent of the file dialog + is set to \e this and it is given the identification name - "open file + dialog". The caption at the top of file dialog is set to "Choose a + file". + + You can create your own QFileDialogP without using the static + functions. By calling setMode(), you can set what can be returned by + the QFileDialogP. + + \code + QFileDialogP* fd = new QFileDialogP( this, "file dialog", TRUE ); + fd->setMode( QFileDialogP::AnyFile ); + \endcode + + In the above example, the mode of the file dialog is set to \c + AnyFile, meaning that the user can select any file, or even specify a + file that doesn't exist. This mode is useful for creating a "File Save + As" file dialog. Use \c ExistingFile if the user must select an + existing file or \c Directory if only a directory may be selected. + (See the \l QFileDialogP::Mode enum for the complete list of modes.) + + You can retrieve the dialog's mode with mode(). Use setFilter() to set + the dialog's file filter, e.g. + + \code + fd->setFilter( "Images (*.png *.xpm *.jpg)" ); + \endcode + + In the above example, the filter is set to "Images (*.png *.xpm + *.jpg)", this means that only files with the extension \c png, \c xpm + or \c jpg will be shown in the QFileDialogP. You can apply + several filters by using setFilters() and add additional filters with + addFilter(). Use setSelectedFilter() to select one of the filters + you've given as the file dialog's default filter. Whenever the user + changes the filter the filterSelected() signal is emitted. + + The file dialog has two view modes, QFileDialogP::List which simply + lists file and directory names and QFileDialogP::Detail which + displays additional information alongside each name, e.g. file size, + modification date, etc. Set the mode with setViewMode(). + + \code + fd->setViewMode( QFileDialogP::Detail ); + \endcode + + The last important function you will need to use when creating your + own file dialog is selectedFile(). + + \code + QString fileName; + if ( fd->exec() == QDialog::Accepted ) + fileName = fd->selectedFile(); + \endcode + + In the above example, a modal file dialog is created and shown. If + the user clicked OK, then the file they selected is put in \c + fileName. + + If you are using the \c ExistingFiles mode then you will need to use + selectedFiles() which will return the selected files in a QStringList. + + The dialog's working directory can be set with setDir(). The display + of hidden files is controlled with setShowHiddenFiles(). The dialog + can be forced to re-read the directory with rereadDir() and re-sort + the directory with resortDir(). All the files in the current directory + can be selected with selectAll(). + + \section1 Creating and using preview widgets + + There are two kinds of preview widgets that can be used with + QFileDialogPs: \e content preview widgets and \e information preview + widgets. They are created and used in the same way except that the + function names differ, e.g. setContentsPreview() and setInfoPreview(). + + A preview widget is a widget that is placed inside a QFileDialogP so + that the user can see either the contents of the file, or information + about the file. + + \code + class Preview : public QLabel, public QFilePreviewP + { + public: + Preview( QWidget *parent=0 ) : QLabel( parent ) {} + + void previewUrl( const QUrl &u ) + { + QString path = u.path(); + QPixmap pix( path ); + if ( pix.isNull() ) + setText( "This is not a pixmap" ); + else + setPixmap( pix ); + } + }; + \endcode + + In the above snippet, we create a preview widget which inherits from + QLabel and QFilePreviewP. File preview widgets \e must inherit from + QFilePreviewP. + + Inside the class we reimplement QFilePreviewP::previewUrl(), this is + where we determine what happens when a file is selected. In the + above example we only show a preview of the file if it is a valid + pixmap. Here's how to make a file dialog use a preview widget: + + \code + Preview* p = new Preview; + + QFileDialogP* fd = new QFileDialogP( this ); + fd->setContentsPreviewEnabled( TRUE ); + fd->setContentsPreview( p, p ); + fd->setPreviewMode( QFileDialogP::Contents ); + fd->show(); + \endcode + + The first line creates an instance of our preview widget. We then + create our file dialog and call setContentsPreviewEnabled( TRUE ), + this tell the file dialog to preview the contents of the currently + selected file. We then call setContentsPreview() -- note that we pass + the same preview widget twice. Finally, before showing the file + dialog, we call setPreviewMode() setting the mode to \e Contents which + will show the contents preview of the file that the user has selected. + + If you create another preview widget that is used for displaying + information about a file, create it in the same way as the contents + preview widget and call setInfoPreviewEnabled(), and + setInfoPreview(). Then the user will be able to switch between the + two preview modes. + + For more information about creating a QFilePreviewP widget see + \l{QFilePreviewP}. + + + +*/ + + +/*! \enum QFileDialogP::Mode + + This enum is used to indicate what the user may select in the file + dialog, i.e. what the dialog will return if the user clicks OK. + + \value AnyFile The name of a file, whether it exists or not. + \value ExistingFile The name of a single existing file. + \value Directory The name of a directory. Both files and directories + are displayed. + \value DirectoryOnly The name of a directory. The file dialog will only display directories. + \value ExistingFiles The names of zero or more existing files. + + See setMode(). +*/ + +/*! + \enum QFileDialogP::ViewMode + + This enum describes the view mode of the file dialog, i.e. what + information about each file will be displayed. + + \value List Display file and directory names with icons. + \value Detail Display file and directory names with icons plus + additional information, such as file size and modification date. + + See setViewMode(). +*/ + +/*! + \enum QFileDialogP::PreviewMode + + This enum describes the preview mode of the file dialog. + + \value NoPreview No preview is shown at all. + \value Contents Show a preview of the contents of the current file + using the contents preview widget. + \value Info Show information about the current file using the + info preview widget. + + See setPreviewMode(), setContentsPreview() and setInfoPreview(). +*/ + +/*! + \fn void QFileDialogP::detailViewSelectionChanged() + \internal +*/ + +/*! + \fn void QFileDialogP::listBoxSelectionChanged() + \internal +*/ + +extern const char qt_file_dialog_filter_reg_exp[] = + "([a-zA-Z0-9 ]*)\\(([a-zA-Z0-9_.*? +;#\\[\\]]*)\\)$"; + +/*! + Constructs a file dialog called \a name, with the parent, \a parent. + If \a modal is TRUE then the file dialog is modal; otherwise it is + modeless. +*/ + +QFileDialogP::QFileDialogP( QWidget *parent, const char *name, bool modal ) + : QDialog( parent, name, modal, + (modal ? + (WStyle_Customize | WStyle_DialogBorder | WStyle_Title | WStyle_SysMenu) : 0) ) +{ + init(); + d->mode = ExistingFile; + d->types->insertItem( tr( "All Files (*)" ) ); + emit dirEntered( d->url.dirPath() ); + rereadDir(); +} + + +/*! + Constructs a file dialog called \a name with the parent, \a parent. + If \a modal is TRUE then the file dialog is modal; otherwise it is + modeless. + + If \a dirName is specified then it will be used as the dialog's + working directory, i.e. it will be the directory that is shown when + the dialog appears. If \a filter is specified it will be used as the + dialog's file filter. + +*/ + +QFileDialogP::QFileDialogP( const QString& dirName, const QString & filter, + QWidget *parent, const char *name, bool modal ) + : QDialog( parent, name, modal, + (modal ? + (WStyle_Customize | WStyle_DialogBorder | WStyle_Title | WStyle_SysMenu) : 0) ) +{ + init(); + d->mode = ExistingFile; + rereadDir(); + if ( !dirName.isEmpty() ) + setSelection( dirName ); + else if ( workingDirectory && !workingDirectory->isEmpty() ) + setDir( *workingDirectory ); + + if ( !filter.isEmpty() ) { + setFilters( filter ); + if ( !dirName.isEmpty() ) { + int dotpos = dirName.find( QChar('.'), 0, FALSE ); + if ( dotpos != -1 ) { + for ( int b=0 ; btypes->count() ; b++ ) { + if ( d->types->text(b).contains( dirName.right( dirName.length() - dotpos ) ) ) { + d->types->setCurrentItem( b ); + setFilter( d->types->text( b ) ); + return; + } + } + } + } + } else { + d->types->insertItem( tr( "All Files (*)" ) ); + } +} + + +/*! + \internal + Initializes the file dialog. +*/ + +void QFileDialogP::init() +{ + setSizeGripEnabled( TRUE ); + d = new QFileDialogPrivate(); + d->mode = AnyFile; + d->last = 0; + d->moreFiles = 0; + d->infoPreview = FALSE; + d->contentsPreview = FALSE; + d->hadDotDot = FALSE; + d->ignoreNextKeyPress = FALSE; + d->progressDia = 0; + d->checkForFilter = FALSE; + d->ignoreReturn = FALSE; + d->ignoreNextRefresh = FALSE; + d->ignoreStop = FALSE; + d->pendingItems.setAutoDelete( FALSE ); + d->mimeTypeTimer = new QTimer( this ); + connect( d->mimeTypeTimer, SIGNAL( timeout() ), + this, SLOT( doMimeTypeLookup() ) ); + + d->url = QUrlOperator( QDir::currentDirPath() ); + d->oldUrl = d->url; + d->currListChildren = 0; + + connect( &d->url, SIGNAL( start( QNetworkOperation * ) ), + this, SLOT( urlStart( QNetworkOperation * ) ) ); + connect( &d->url, SIGNAL( finished( QNetworkOperation * ) ), + this, SLOT( urlFinished( QNetworkOperation * ) ) ); + connect( &d->url, SIGNAL( newChildren( const QValueList &, QNetworkOperation * ) ), + this, SLOT( insertEntry( const QValueList &, QNetworkOperation * ) ) ); + connect( &d->url, SIGNAL( removed( QNetworkOperation * ) ), + this, SLOT( removeEntry( QNetworkOperation * ) ) ); + connect( &d->url, SIGNAL( createdDirectory( const QUrlInfo &, QNetworkOperation * ) ), + this, SLOT( createdDirectory( const QUrlInfo &, QNetworkOperation * ) ) ); + connect( &d->url, SIGNAL( itemChanged( QNetworkOperation * ) ), + this, SLOT( itemChanged( QNetworkOperation * ) ) ); + connect( &d->url, SIGNAL( dataTransferProgress( int, int, QNetworkOperation * ) ), + this, SLOT( dataTransferProgress( int, int, QNetworkOperation * ) ) ); + + nameEdit = new QLineEdit( this, "name/filter editor" ); + nameEdit->setMaxLength( 255 ); //_POSIX_MAX_PATH + connect( nameEdit, SIGNAL(textChanged(const QString&)), + this, SLOT(fileNameEditDone()) ); + nameEdit->installEventFilter( this ); + + d->splitter = new QSplitter( this, "qt_splitter" ); + + d->stack = new QWidgetStack( d->splitter, "files and more files" ); + + d->splitter->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + + files = new QFileDialogQFileListView( d->stack, this ); + QFontMetrics fm = fontMetrics(); + files->addColumn( tr("Name") ); + files->addColumn( tr("Size") ); + files->setColumnAlignment( 1, AlignRight ); + files->addColumn( tr("Type") ); + files->addColumn( tr("Date") ); + files->addColumn( tr("Attributes") ); + files->header()->setStretchEnabled( TRUE, 0 ); + + files->setMinimumSize( 50, 25 + 2*fm.lineSpacing() ); + + connect( files, SIGNAL( selectionChanged() ), + this, SLOT( detailViewSelectionChanged() ) ); + connect( files, SIGNAL(currentChanged(QListViewItem *)), + this, SLOT(updateFileNameEdit(QListViewItem *)) ); + connect( files, SIGNAL(doubleClicked(QListViewItem *)), + this, SLOT(selectDirectoryOrFile(QListViewItem *)) ); + connect( files, SIGNAL(returnPressed(QListViewItem *)), + this, SLOT(selectDirectoryOrFile(QListViewItem *)) ); + connect( files, SIGNAL(rightButtonPressed(QListViewItem *, + const QPoint &, int)), + this, SLOT(popupContextMenu(QListViewItem *, + const QPoint &, int)) ); + + files->installEventFilter( this ); + files->viewport()->installEventFilter( this ); + + d->moreFiles = new QFileListBox( d->stack, this ); + d->moreFiles->setRowMode( QListBox::FitToHeight ); + d->moreFiles->setVariableWidth( TRUE ); + + connect( d->moreFiles, SIGNAL(selected(QListBoxItem *)), + this, SLOT(selectDirectoryOrFile(QListBoxItem *)) ); + connect( d->moreFiles, SIGNAL( selectionChanged() ), + this, SLOT( listBoxSelectionChanged() ) ); + connect( d->moreFiles, SIGNAL(highlighted(QListBoxItem *)), + this, SLOT(updateFileNameEdit(QListBoxItem *)) ); + connect( d->moreFiles, SIGNAL( rightButtonPressed( QListBoxItem *, const QPoint & ) ), + this, SLOT( popupContextMenu( QListBoxItem *, const QPoint & ) ) ); + + d->moreFiles->installEventFilter( this ); + d->moreFiles->viewport()->installEventFilter( this ); + + okB = new QPushButton( tr("OK"), this, "OK" ); //### Or "Save (see other "OK") + okB->setDefault( TRUE ); + okB->setEnabled( FALSE ); + connect( okB, SIGNAL(clicked()), this, SLOT(okClicked()) ); + cancelB = new QPushButton( tr("Cancel") , this, "Cancel" ); + connect( cancelB, SIGNAL(clicked()), this, SLOT(cancelClicked()) ); + + d->paths = new QComboBox( TRUE, this, "directory history/editor" ); + d->paths->setDuplicatesEnabled( FALSE ); + d->paths->setInsertionPolicy( QComboBox::NoInsertion ); + const QFileInfoList * rootDrives = QDir::drives(); + QFileInfoListIterator it( *rootDrives ); + QFileInfo *fi; + makeVariables(); + + while ( (fi = it.current()) != 0 ) { + ++it; + d->paths->insertItem( *openFolderIcon, fi->absFilePath() ); + } + + if ( !!QDir::homeDirPath() ) { + if ( !d->paths->listBox()->findItem( QDir::homeDirPath() ) ) + d->paths->insertItem( *openFolderIcon, QDir::homeDirPath() ); + } + + connect( d->paths, SIGNAL(activated(const QString&)), + this, SLOT(setDir(const QString&)) ); + + d->paths->installEventFilter( this ); + QObjectList *ol = d->paths->queryList( "QLineEdit" ); + if ( ol && ol->first() ) + ( (QLineEdit*)ol->first() )->installEventFilter( this ); + delete ol; + + d->geometryDirty = TRUE; + d->types = new QComboBox( TRUE, this, "file types" ); + d->types->setDuplicatesEnabled( FALSE ); + d->types->setEditable( FALSE ); + connect( d->types, SIGNAL(activated(const QString&)), + this, SLOT(setFilter(const QString&)) ); + connect( d->types, SIGNAL(activated(const QString&)), + this, SIGNAL(filterSelected(const QString&)) ); + + d->pathL = new QLabel( d->paths, tr("Look &in:"), this, "qt_looin_lbl" ); + d->fileL = new QLabel( nameEdit, tr("File &name:"), this, "qt_filename_lbl" ); + d->typeL = new QLabel( d->types, tr("File &type:"), this, "qt_filetype_lbl" ); + +#if defined(Q_WS_WIN) + if ( qt_winver == Qt::WV_2000 || qt_winver == Qt::WV_XP ) { + d->goBack = new QToolButton( this, "go back" ); + d->goBack->setAutoRaise( TRUE ); + d->goBack->setEnabled( FALSE ); + d->goBack->setFocusPolicy( TabFocus ); + connect( d->goBack, SIGNAL( clicked() ), + this, SLOT( goBack() ) ); + QToolTip::add( d->goBack, tr( "Back" ) ); + d->goBack->setIconSet( *goBackIcon ); + } else { + d->goBack = 0; + } +#else + d->goBack = 0; +#endif + + d->cdToParent = new QToolButton( this, "cd to parent" ); +#if defined(Q_WS_WIN) + if ( qt_winver == Qt::WV_2000 || qt_winver == Qt::WV_XP ) + d->cdToParent->setAutoRaise( TRUE ); +#endif + d->cdToParent->setFocusPolicy( TabFocus ); +#ifndef QT_NO_TOOLTIP + QToolTip::add( d->cdToParent, tr( "One directory up" ) ); +#endif + d->cdToParent->setIconSet( *cdToParentIcon ); + connect( d->cdToParent, SIGNAL(clicked()), + this, SLOT(cdUpClicked()) ); + + d->newFolder = new QToolButton( this, "new folder" ); +#if defined(Q_WS_WIN) + if ( qt_winver == Qt::WV_2000 || qt_winver == Qt::WV_XP ) + d->newFolder->setAutoRaise( TRUE ); +#endif + d->newFolder->setFocusPolicy( TabFocus ); +#ifndef QT_NO_TOOLTIP + QToolTip::add( d->newFolder, tr( "Create New Folder" ) ); +#endif + d->newFolder->setIconSet( *newFolderIcon ); + connect( d->newFolder, SIGNAL(clicked()), + this, SLOT(newFolderClicked()) ); + + d->modeButtons = new QButtonGroup( 0, "invisible group" ); + connect( d->modeButtons, SIGNAL(destroyed()), + this, SLOT(modeButtonsDestroyed()) ); + d->modeButtons->setExclusive( TRUE ); + connect( d->modeButtons, SIGNAL(clicked(int)), + d->stack, SLOT(raiseWidget(int)) ); + connect( d->modeButtons, SIGNAL(clicked(int)), + this, SLOT(changeMode(int)) ); + + d->mcView = new QToolButton( this, "mclistbox view" ); +#if defined(Q_WS_WIN) + if ( qt_winver == Qt::WV_2000 || qt_winver == Qt::WV_XP ) + d->mcView->setAutoRaise( TRUE ); +#endif + d->mcView->setFocusPolicy( TabFocus ); +#ifndef QT_NO_TOOLTIP + QToolTip::add( d->mcView, tr( "List View" ) ); +#endif + d->mcView->setIconSet( *multiColumnListViewIcon ); + d->mcView->setToggleButton( TRUE ); + d->stack->addWidget( d->moreFiles, d->modeButtons->insert( d->mcView ) ); + d->detailView = new QToolButton( this, "list view" ); +#if defined(Q_WS_WIN) + if ( qt_winver == Qt::WV_2000 || qt_winver == Qt::WV_XP ) + d->detailView->setAutoRaise( TRUE ); +#endif + d->detailView->setFocusPolicy( TabFocus ); +#ifndef QT_NO_TOOLTIP + QToolTip::add( d->detailView, tr( "Detail View" ) ); +#endif + d->detailView->setIconSet( *detailViewIcon ); + d->detailView->setToggleButton( TRUE ); + d->stack->addWidget( files, d->modeButtons->insert( d->detailView ) ); + + d->previewInfo = new QToolButton( this, "preview info view" ); +#if defined(Q_WS_WIN) + if ( qt_winver == Qt::WV_2000 || qt_winver == Qt::WV_XP ) + d->previewInfo->setAutoRaise( TRUE ); +#endif + d->previewInfo->setFocusPolicy( TabFocus ); +#ifndef QT_NO_TOOLTIP + QToolTip::add( d->previewInfo, tr( "Preview File Info" ) ); +#endif + d->previewInfo->setIconSet( *previewInfoViewIcon ); + d->previewInfo->setToggleButton( TRUE ); + d->modeButtons->insert( d->previewInfo ); + + d->previewContents = new QToolButton( this, "preview info view" ); +#if defined(Q_WS_WIN) + if ( qt_winver == Qt::WV_2000 || qt_winver == Qt::WV_XP ) + d->previewContents->setAutoRaise( TRUE ); +#endif + d->previewContents->setFocusPolicy( TabFocus ); +#ifndef QT_NO_TOOLTIP + QToolTip::add( d->previewContents, tr( "Preview File Contents" ) ); +#endif + d->previewContents->setIconSet( *previewContentsViewIcon ); + d->previewContents->setToggleButton( TRUE ); + d->modeButtons->insert( d->previewContents ); + + connect( d->detailView, SIGNAL( clicked() ), + d->moreFiles, SLOT( cancelRename() ) ); + connect( d->detailView, SIGNAL( clicked() ), + files, SLOT( cancelRename() ) ); + connect( d->mcView, SIGNAL( clicked() ), + d->moreFiles, SLOT( cancelRename() ) ); + connect( d->mcView, SIGNAL( clicked() ), + files, SLOT( cancelRename() ) ); + + d->stack->raiseWidget( d->moreFiles ); + d->mcView->setOn( TRUE ); + + QHBoxLayout *lay = new QHBoxLayout( this ); + lay->setMargin( 6 ); + d->leftLayout = new QHBoxLayout( lay, 5 ); + d->topLevelLayout = new QVBoxLayout( (QWidget*)0, 5 ); + lay->addLayout( d->topLevelLayout, 1 ); + d->extraWidgetsLayouts.setAutoDelete( FALSE ); + d->extraLabels.setAutoDelete( FALSE ); + d->extraWidgets.setAutoDelete( FALSE ); + d->extraButtons.setAutoDelete( FALSE ); + d->toolButtons.setAutoDelete( FALSE ); + + QHBoxLayout * h; + + d->preview = new QWidgetStack( d->splitter, "qt_preview" ); + + d->infoPreviewWidget = new QWidget( d->preview, "qt_preview_info" ); + d->contentsPreviewWidget = new QWidget( d->preview, "qt_preview_contents" ); + d->infoPreviewer = d->contentsPreviewer = 0; + + h = new QHBoxLayout( 0 ); + d->buttonLayout = h; + d->topLevelLayout->addLayout( h ); + h->addWidget( d->pathL ); + h->addSpacing( 8 ); + h->addWidget( d->paths ); + h->addSpacing( 8 ); + if ( d->goBack ) + h->addWidget( d->goBack ); + h->addWidget( d->cdToParent ); + h->addSpacing( 2 ); + h->addWidget( d->newFolder ); + h->addSpacing( 4 ); + h->addWidget( d->mcView ); + h->addWidget( d->detailView ); + h->addWidget( d->previewInfo ); + h->addWidget( d->previewContents ); + + d->topLevelLayout->addWidget( d->splitter ); + + h = new QHBoxLayout(); + d->topLevelLayout->addLayout( h ); + h->addWidget( d->fileL ); + h->addWidget( nameEdit ); + h->addSpacing( 15 ); + h->addWidget( okB ); + + h = new QHBoxLayout(); + d->topLevelLayout->addLayout( h ); + h->addWidget( d->typeL ); + h->addWidget( d->types ); + h->addSpacing( 15 ); + h->addWidget( cancelB ); + + d->rightLayout = new QHBoxLayout( lay, 5 ); + d->topLevelLayout->setStretchFactor( d->mcView, 1 ); + d->topLevelLayout->setStretchFactor( files, 1 ); + + updateGeometries(); + + if ( d->goBack ) { + setTabOrder( d->paths, d->goBack ); + setTabOrder( d->goBack, d->cdToParent ); + } else { + setTabOrder( d->paths, d->cdToParent ); + } + setTabOrder( d->cdToParent, d->newFolder ); + setTabOrder( d->newFolder, d->mcView ); + setTabOrder( d->mcView, d->detailView ); + setTabOrder( d->detailView, d->moreFiles ); + setTabOrder( d->moreFiles, files ); + setTabOrder( files, nameEdit ); + setTabOrder( nameEdit, d->types ); + setTabOrder( d->types, okB ); + setTabOrder( okB, cancelB ); + + d->rw = tr( "Read-write" ); + d->ro = tr( "Read-only" ); + d->wo = tr( "Write-only" ); + d->inaccessible = tr( "Inaccessible" ); + + d->symLinkToFile = tr( "Symlink to File" ); + d->symLinkToDir = tr( "Symlink to Directory" ); + d->symLinkToSpecial = tr( "Symlink to Special" ); + d->file = tr( "File" ); + d->dir = tr( "Dir" ); + d->special = tr( "Special" ); + + if ( !lastSize ) { + QRect screen = QApplication::desktop()->screenGeometry( QApplication::desktop()->screenNumber( pos() ) ); + if ( screen.width() < 1024 || + screen.height() < 768 ) { + resize( QMIN(screen.width(),420), + QMIN(screen.height(),236) ); + } else { + QSize s( files->sizeHint() ); + s = QSize( s.width() + 300, s.height() + 82 ); + + if ( s.width() * 3 > screen.width() * 2 ) + s.setWidth( screen.width() * 2 / 3 ); + + if ( s.height() * 3 > screen.height() * 2 ) + s.setHeight( screen.height() * 2 / 3 ); + else if ( s.height() * 3 < screen.height() ) + s.setHeight( screen.height() / 3 ); + + resize( s ); + } + lastSize = new QSize; + qfd_cleanup_size.add( &lastSize ); + *lastSize = size(); + } else + resize( *lastSize ); + + if ( detailViewMode ) { + d->stack->raiseWidget( files ); + d->mcView->setOn( FALSE ); + d->detailView->setOn( TRUE ); + } + + d->preview->hide(); + nameEdit->setFocus(); + + connect( nameEdit, SIGNAL( returnPressed() ), + this, SLOT( fileNameEditReturnPressed() ) ); +} + +/*! + \internal +*/ + +void QFileDialogP::fileNameEditReturnPressed() +{ + d->oldUrl = d->url; + if ( !isDirectoryMode( d->mode ) ) { + okClicked(); + } else { + d->currentFileName = QString::null; + if ( nameEdit->text().isEmpty() ) { + emit fileSelected( selectedFile() ); + accept(); + } else { + QUrlInfo f; + QFileDialogPrivate::File * c + = (QFileDialogPrivate::File *)files->currentItem(); + if ( c && files->isSelected(c) ) + f = c->info; + else + f = QUrlInfo( d->url, nameEdit->text() ); + if ( f.isDir() ) { + setUrl( QUrlOperator( d->url, QFileDialogPrivate::encodeFileName(nameEdit->text() + "/" ) ) ); + d->checkForFilter = TRUE; + trySetSelection( TRUE, d->url, TRUE ); + d->checkForFilter = FALSE; + } + } + nameEdit->setText( QString::null ); + d->ignoreReturn = TRUE; + } +} + +/*! + \internal + Changes the preview mode to the mode specified at \a id. +*/ + +void QFileDialogP::changeMode( int id ) +{ + if ( !d->infoPreview && !d->contentsPreview ) + return; + + QButton *btn = (QButton*)d->modeButtons->find( id ); + if ( !btn ) + return; + + if ( btn == d->previewContents && !d->contentsPreview ) + return; + if ( btn == d->previewInfo && !d->infoPreview ) + return; + + if ( btn != d->previewContents && btn != d->previewInfo ) { + d->preview->hide(); + } else { + if ( files->currentItem() ) { + if ( d->infoPreviewer ) + d->infoPreviewer->previewUrl( QUrl( d->url, files->currentItem()->text( 0 ) ) ); + if ( d->contentsPreviewer ) + d->contentsPreviewer->previewUrl( QUrl( d->url, files->currentItem()->text( 0 ) ) ); + } + if ( btn == d->previewInfo ) + d->preview->raiseWidget( d->infoPreviewWidget ); + else + d->preview->raiseWidget( d->contentsPreviewWidget ); + d->preview->show(); + } +} + +/*! + Destroys the file dialog. +*/ + +QFileDialogP::~QFileDialogP() +{ + // since clear might call setContentsPos which would emit + // a signal and thus cause a recompute of sizes... + files->blockSignals( TRUE ); + d->moreFiles->blockSignals( TRUE ); + files->clear(); + d->moreFiles->clear(); + d->moreFiles->blockSignals( FALSE ); + files->blockSignals( FALSE ); + if ( QApplication::overrideCursor() ) + QApplication::restoreOverrideCursor(); + delete d; + d = 0; +} + + +/*! + \property QFileDialogP::selectedFile + + \brief the name of the selected file + + If a file was selected selectedFile contains the file's name including + its absolute path; otherwise selectedFile is empty. + + \sa QString::isEmpty(), selectedFiles, selectedFilter +*/ + +QString QFileDialogP::selectedFile() const +{ + QString s = d->currentFileName; + // remove the protocol because we do not want to encode it... + QString prot = QUrl( s ).protocol(); + if ( !prot.isEmpty() ) { + prot += ":"; + s.remove( 0, prot.length() ); + } + QUrl u( prot + QFileDialogPrivate::encodeFileName( s ) ); + if ( u.isLocalFile() ) { + QString s = u.toString(); + if ( s.left( 5 ) == "file:" ) + s.remove( 0, 5 ); + return s; + } + return d->currentFileName; +} + +/*! + \property QFileDialogP::selectedFilter + + \brief the filter which the user has selected in the file dialog + + \sa filterSelected(), selectedFiles, selectedFile +*/ + +QString QFileDialogP::selectedFilter() const +{ + return d->types->currentText(); +} + +/*! \overload + + Sets the current filter selected in the file dialog to the + \a{n}-th filter in the filter list. + + \sa filterSelected(), selectedFilter(), selectedFiles(), selectedFile() +*/ + +void QFileDialogP::setSelectedFilter( int n ) +{ + d->types->setCurrentItem( n ); + QString f = d->types->currentText(); + QRegExp r( QString::fromLatin1(qt_file_dialog_filter_reg_exp) ); + int index = r.search( f ); + if ( index >= 0 ) + f = r.cap( 2 ); + d->url.setNameFilter( f ); + rereadDir(); +} + +/*! + Sets the current filter selected in the file dialog to the first + one that contains the text \a mask. +*/ + +void QFileDialogP::setSelectedFilter( const QString& mask ) +{ + int n; + + for ( n = 0; n < d->types->count(); n++ ) { + if ( d->types->text( n ).contains( mask, FALSE ) ) { + d->types->setCurrentItem( n ); + QString f = mask; + QRegExp r( QString::fromLatin1(qt_file_dialog_filter_reg_exp) ); + int index = r.search( f ); + if ( index >= 0 ) + f = r.cap( 2 ); + d->url.setNameFilter( f ); + rereadDir(); + return; + } + } +} + +/*! + \property QFileDialogP::selectedFiles + + \brief the list of selected files + + If one or more files are selected, selectedFiles contains their + names including their absolute paths. If no files are selected or + the mode isn't ExistingFiles selectedFiles is an empty list. + + It is more convenient to use selectedFile() if the mode is + \c ExistingFile, \c Directory or \c DirectoryOnly. + + Note that if you want to iterate over the list, you should + iterate over a copy, e.g. + \code + QStringList list = myFileDialog.selectedFiles(); + QStringList::Iterator it = list.begin(); + while( it != list.end() ) { + myProcessing( *it ); + ++it; + } + \endcode + + \sa selectedFile, selectedFilter, QValueList::empty() +*/ + +QStringList QFileDialogP::selectedFiles() const +{ + QStringList lst; + + if ( mode() == ExistingFiles ) { + QStringList selectedLst; + QString selectedFiles = nameEdit->text(); + selectedFiles.truncate( selectedFiles.findRev( '\"' ) ); + selectedLst = selectedLst.split( QString("\" "), selectedFiles ); + for ( QStringList::Iterator it = selectedLst.begin(); it != selectedLst.end(); ++it ) { + QUrl u; + if ( (*it)[0] == '\"' ) { + u = QUrl( d->url, QFileDialogPrivate::encodeFileName( (*it).mid(1) ) ); + } else { + u = QUrl( d->url, QFileDialogPrivate::encodeFileName( (*it) ) ); + } + if ( u.isLocalFile() ) { + QString s = u.toString(); + if ( s.left( 5 ) == "file:" ) + s.remove( 0, 5 ); + lst << s; + } else { + lst << u.toString(); + } + } + } + + return lst; +} + +/*! + Sets the default selection to \a filename. If \a filename is + absolute, setDir() is also called to set the file dialog's working + directory to the filename's directory. + + \omit + Only for external use. Not useful inside QFileDialogP. + \endomit +*/ + +void QFileDialogP::setSelection( const QString & filename ) +{ + d->oldUrl = d->url; + QString nf = d->url.nameFilter(); + if ( QUrl::isRelativeUrl( filename ) ) + d->url = QUrlOperator( d->url, QFileDialogPrivate::encodeFileName( filename ) ); + else + d->url = QUrlOperator( filename ); + d->url.setNameFilter( nf ); + d->checkForFilter = TRUE; + bool isDirOk; + bool isDir = d->url.isDir( &isDirOk ); + if ( !isDirOk ) + isDir = d->url.path().right( 1 ) == "/"; + if ( !isDir ) { + QUrlOperator u( d->url ); + d->url.setPath( d->url.dirPath() ); + trySetSelection( FALSE, u, TRUE ); + d->ignoreNextRefresh = TRUE; + nameEdit->selectAll(); + rereadDir(); + emit dirEntered( d->url.dirPath() ); + } else { + if ( !d->url.path().isEmpty() && + d->url.path().right( 1 ) != "/" ) { + QString p = d->url.path(); + p += "/"; + d->url.setPath( p ); + } + trySetSelection( TRUE, d->url, FALSE ); + rereadDir(); + emit dirEntered( d->url.dirPath() ); + nameEdit->setText( QString::fromLatin1("") ); + } + d->checkForFilter = FALSE; +} + +/*! + \property QFileDialogP::dirPath + + \brief the file dialog's working directory + + \sa dir(), setDir() +*/ + +QString QFileDialogP::dirPath() const +{ + return d->url.dirPath(); +} + + +/*! + + Sets the filter used in the file dialog to \a newFilter. + + If \a newFilter contains a pair of parentheses containing one or more + of anything*something separated by spaces or by + semi-colons then only the text contained in the parentheses is used as + the filter. This means that these calls are all equivalent: + + \code + fd->setFilter( "All C++ files (*.cpp *.cc *.C *.cxx *.c++)" ); + fd->setFilter( "*.cpp *.cc *.C *.cxx *.c++" ); + fd->setFilter( "All C++ files (*.cpp;*.cc;*.C;*.cxx;*.c++)" ); + fd->setFilter( "*.cpp;*.cc;*.C;*.cxx;*.c++" ); + \endcode + + \sa setFilters() +*/ + +void QFileDialogP::setFilter( const QString & newFilter ) +{ + if ( newFilter.isEmpty() ) + return; + QString f = newFilter; + QRegExp r( QString::fromLatin1(qt_file_dialog_filter_reg_exp) ); + int index = r.search( f ); + if ( index >= 0 ) + f = r.cap( 2 ); + d->url.setNameFilter( f ); + if ( d->types->count() == 1 ) { + d->types->clear(); + d->types->insertItem( newFilter ); + } else { + for ( int i = 0; i < d->types->count(); ++i ) { + if ( d->types->text( i ).left( newFilter.length() ) == newFilter ) { + d->types->setCurrentItem( i ); + break; + } + } + } + rereadDir(); +} + + +/*! \overload + Sets the file dialog's working directory to \a pathstr. + + \sa dir() +*/ + +void QFileDialogP::setDir( const QString & pathstr ) +{ + QString dr = pathstr; + if ( dr.isEmpty() ) + return; + +#if defined(Q_OS_UNIX) + if ( dr.length() && dr[0] == '~' ) { + struct passwd *pw; + int i; + + i = 0; + while( i < (int)dr.length() && dr[i] != '/' ) + i++; + QCString user; + if ( i == 1 ) { + user = ::getlogin(); + if ( !user ) + user = getenv( "LOGNAME" ); + } else + user = dr.mid( 1, i-1 ).local8Bit(); + dr = dr.mid( i, dr.length() ); + pw = ::getpwnam( user ); + if ( pw ) + dr.prepend( QString::fromLocal8Bit(pw->pw_dir) ); + } +#endif + + setUrl( dr ); +} + +/*! + Returns the current directory shown in the file dialog. + + The ownership of the QDir pointer is transferred to the caller, so + it must be deleted by the caller when no longer required. + + \sa setDir() +*/ + +const QDir *QFileDialogP::dir() const +{ + if ( d->url.isLocalFile() ) + return new QDir( d->url.path() ); + else + return 0; +} + +/*! + Sets the file dialog's working directory to \a dir. + \sa dir() +*/ + +void QFileDialogP::setDir( const QDir &dir ) +{ + d->oldUrl = d->url; + QString nf( d->url.nameFilter() ); + d->url = dir.canonicalPath(); + d->url.setNameFilter( nf ); + QUrlInfo i( d->url, nameEdit->text() ); + d->checkForFilter = TRUE; + trySetSelection( i.isDir(), QUrlOperator( d->url, QFileDialogPrivate::encodeFileName(nameEdit->text() ) ), FALSE ); + d->checkForFilter = FALSE; + rereadDir(); + emit dirEntered( d->url.path() ); +} + +/*! + Sets the file dialog's working directory to the directory specified at \a url. + + \sa url() +*/ + +void QFileDialogP::setUrl( const QUrlOperator &url ) +{ + QString nf = d->url.nameFilter(); + + d->url = QUrl( d->url, url.toString( FALSE, FALSE ) ); + d->url.setNameFilter( nf ); + + d->checkForFilter = TRUE; + if ( !d->url.isDir() ) { + QUrlOperator u = d->url; + d->url.setPath( d->url.dirPath() ); + trySetSelection( FALSE, u, FALSE ); + rereadDir(); + emit dirEntered( d->url.dirPath() ); + QString fn = u.fileName(); + nameEdit->setText( fn ); + } else { + trySetSelection( TRUE, d->url, FALSE ); + rereadDir(); + emit dirEntered( d->url.dirPath() ); + } + d->checkForFilter = FALSE; +} + +/*! + \property QFileDialogP::showHiddenFiles + + \brief whether hidden files are shown in the file dialog + + The default is FALSE, i.e. don't show hidden files. +*/ + +void QFileDialogP::setShowHiddenFiles( bool s ) +{ + if ( s == bShowHiddenFiles ) + return; + + bShowHiddenFiles = s; + rereadDir(); +} + +bool QFileDialogP::showHiddenFiles() const +{ + return bShowHiddenFiles; +} + +/*! + Rereads the current directory shown in the file dialog. + + The only time you will need to call this function is if the contents of + the directory change and you wish to refresh the file dialog to reflect + the change. + + \sa resortDir() +*/ + +void QFileDialogP::rereadDir() +{ + if ( !QApplication::overrideCursor() ) + QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) ); + d->pendingItems.clear(); + if ( d->mimeTypeTimer->isActive() ) + d->mimeTypeTimer->stop(); + d->currListChildren = d->url.listChildren(); +} + + +/*! + \fn void QFileDialogP::fileHighlighted( const QString& ) + + This signal is emitted when the user highlights a file. + + \sa fileSelected(), filesSelected() +*/ + +/*! + \fn void QFileDialogP::fileSelected( const QString& ) + + This signal is emitted when the user selects a file. + + \sa filesSelected(), fileHighlighted(), selectedFile() +*/ + +/*! + \fn void QFileDialogP::filesSelected( const QStringList& ) + + This signal is emitted when the user selects one or more files in \e + ExistingFiles mode. + + \sa fileSelected(), fileHighlighted(), selectedFiles() +*/ + +/*! + \fn void QFileDialogP::dirEntered( const QString& ) + + This signal is emitted when the user enters a directory. + + \sa dir() +*/ + +/*! + \fn void QFileDialogP::filterSelected( const QString& ) + + This signal is emitted when the user selects a filter. + + \sa selectedFilter() +*/ + +extern bool qt_resolve_symlinks; // defined in qapplication.cpp + +/*! + This is a convenience static function that returns an existing file + selected by the user. If the user pressed Cancel, it returns a null + string. + + \code + QString s = QFileDialogP::getOpenFileName( + "/home", + "Images (*.png *.xpm *.jpg)", + this, + "open file dialog", + "Choose a file to open" ); + \endcode + + The function creates a modal file dialog called \a name, with + parent, \a parent. If a parent is not 0, the dialog will be shown + centered over the parent. + + The file dialog's working directory will be set to \a startWith. If \a + startWith includes a file name, the file will be selected. The filter + is set to \a filter so that only those files which match the filter + are shown. The filter selected is set to \a selectedFilter. The parameters + \a startWith, \a selectedFilter and \a filter may be QString::null. + + The dialog's caption is set to \a caption. If \a caption is not + specified then a default caption will be used. + + Under Windows and Mac OS X, this static function will use the native + file dialog and not a QFileDialogP, unless the style of the application + is set to something other than the native style. + + Under Unix/X11, the normal behavior of the file dialog is to resolve + and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp, + the file dialog will change to /var/tmp after entering /usr/tmp. + If \a resolveSymlinks is FALSE, the file dialog will treat + symlinks as regular directories. + + \sa getOpenFileNames(), getSaveFileName(), getExistingDirectory() +*/ + +QString QFileDialogP::getOpenFileName( const QString & startWith, + const QString& filter, + QWidget *parent, const char* name, + const QString& caption, + QString *selectedFilter, + bool resolveSymlinks ) +{ + bool save_qt_resolve_symlinks = qt_resolve_symlinks; + qt_resolve_symlinks = resolveSymlinks; + + QStringList filters; + if ( !filter.isEmpty() ) + filters = makeFiltersList( filter ); + + makeVariables(); + QString initialSelection; + //### Problem with the logic here: If a startWith is given and a file + // with that name exists in D->URL, the box will be opened at D->URL instead of + // the last directory used ('workingDirectory'). + // + // hm... isn't that problem exactly the documented behaviour? the + // documented behaviour sounds meaningful. + if ( !startWith.isEmpty() ) { + QUrlOperator u( startWith ); + if ( u.isLocalFile() && QFileInfo( u.path() ).isDir() ) { + *workingDirectory = startWith; + } else { + if ( u.isLocalFile() ) { + QFileInfo fi( u.dirPath() ); + if ( fi.exists() ) { + *workingDirectory = u.dirPath(); + initialSelection = u.fileName(); + } + } else { + *workingDirectory = u.toString(); + initialSelection = QString::null;//u.fileName(); + } + } + } + + if ( workingDirectory->isNull() ) + *workingDirectory = QDir::currentDirPath(); + +#if defined(Q_WS_WIN) + if ( qApp->style().styleHint( QStyle::SH_GUIStyle ) == WindowsStyle ) + return winGetOpenFileName( initialSelection, filter, workingDirectory, + parent, name, caption, selectedFilter ); +#elif defined(Q_WS_MAC) + if( ( qApp->style().inherits(QMAC_DEFAULT_STYLE) ) ) { + QString f = macGetOpenFileNames(filter, workingDirectory, + parent, name, caption, FALSE).first(); + return f; + } +#endif + + QFileDialogP *dlg = new QFileDialogP( *workingDirectory, QString::null, parent, name ? name : "qt_filedlg_gofn", TRUE ); + +#ifndef QT_NO_WIDGET_TOPEXTRA + if ( parent && parent->icon() && !parent->icon()->isNull() ) + dlg->setIcon( *parent->icon() ); + else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() ) + dlg->setIcon( *qApp->mainWidget()->icon() ); + + if ( !caption.isNull() ) + dlg->setCaption( caption ); + else + dlg->setCaption( QFileDialogP::tr( "Open" ) ); +#endif + + dlg->setFilters( filters ); + if ( selectedFilter ) + dlg->setFilter( *selectedFilter ); + dlg->setMode( QFileDialogP::ExistingFile ); + QString result; + if ( !initialSelection.isEmpty() ) + dlg->setSelection( initialSelection ); + if ( dlg->exec() == QDialog::Accepted ) { + result = dlg->selectedFile(); + *workingDirectory = dlg->d->url; + if ( selectedFilter ) + *selectedFilter = dlg->selectedFilter(); + } + delete dlg; + + qt_resolve_symlinks = save_qt_resolve_symlinks; + + return result; +} + +/*! + This is a convenience static function that will return a file name + selected by the user. The file does not have to exist. + + It creates a modal file dialog called \a name, with parent, \a parent. + If a parent is not 0, the dialog will be shown centered over the + parent. + + \code + QString s = QFileDialogP::getSaveFileName( + "/home", + "Images (*.png *.xpm *.jpg)", + this, + "save file dialog" + "Choose a filename to save under" ); + \endcode + + The file dialog's working directory will be set to \a startWith. If \a + startWith includes a file name, the file will be selected. The filter + is set to \a filter so that only those files which match the filter + are shown. The filter selected is set to \a selectedFilter. The parameters + \a startWith, \a selectedFilter and \a filter may be QString::null. + + The dialog's caption is set to \a caption. If \a caption is not + specified then a default caption will be used. + + Under Windows and Mac OS X, this static function will use the native + file dialog and not a QFileDialogP, unless the style of the application + is set to something other than the native style. + + Under Unix/X11, the normal behavior of the file dialog is to resolve + and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp, + the file dialog will change to /var/tmp after entering /usr/tmp. + If \a resolveSymlinks is FALSE, the file dialog will treat + symlinks as regular directories. + + \sa getOpenFileName(), getOpenFileNames(), getExistingDirectory() +*/ + +QString QFileDialogP::getSaveFileName( const QString & startWith, + const QString& filter, + QWidget *parent, const char* name, + const QString& caption, + QString *selectedFilter, + bool resolveSymlinks) +{ + bool save_qt_resolve_symlinks = qt_resolve_symlinks; + qt_resolve_symlinks = resolveSymlinks; + + QStringList filters; + if ( !filter.isEmpty() ) + filters = makeFiltersList( filter ); + + makeVariables(); + QString initialSelection; + if ( !startWith.isEmpty() ) { + QUrlOperator u( startWith ); + if ( u.isLocalFile() && QFileInfo( u.path() ).isDir() ) { + *workingDirectory = startWith; + } else { + if ( u.isLocalFile() ) { + QFileInfo fi( u.dirPath() ); + if ( fi.exists() ) { + *workingDirectory = u.dirPath(); + initialSelection = u.fileName(); + } + } else { + *workingDirectory = u.toString(); + initialSelection = QString::null;//u.fileName(); + } + } + } + + if ( workingDirectory->isNull() ) + *workingDirectory = QDir::currentDirPath(); + +#if defined(Q_WS_WIN) + if ( qApp->style().styleHint( QStyle::SH_GUIStyle ) == WindowsStyle ) + return winGetSaveFileName( initialSelection, filter, workingDirectory, + parent, name, caption, selectedFilter ); +#elif defined(Q_WS_MAC) + if( ( qApp->style().inherits(QMAC_DEFAULT_STYLE) ) ) + return macGetSaveFileName( initialSelection, filter, workingDirectory, + parent, name, caption ); +#endif + + QFileDialogP *dlg = new QFileDialogP( *workingDirectory, QString::null, parent, name ? name : "qt_filedlg_gsfn", TRUE ); + + Q_CHECK_PTR( dlg ); +#ifndef QT_NO_WIDGET_TOPEXTRA + if ( parent && parent->icon() && !parent->icon()->isNull() ) + dlg->setIcon( *parent->icon() ); + else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() ) + dlg->setIcon( *qApp->mainWidget()->icon() ); + + if ( !caption.isNull() ) + dlg->setCaption( caption ); + else + dlg->setCaption( QFileDialogP::tr( "Save As" ) ); +#endif + + QString result; + dlg->setFilters( filters ); + if ( selectedFilter ) + dlg->setFilter( *selectedFilter ); + dlg->setMode( QFileDialogP::AnyFile ); + if ( !initialSelection.isEmpty() ) + dlg->setSelection( initialSelection ); + if ( dlg->exec() == QDialog::Accepted ) { + result = dlg->selectedFile(); + *workingDirectory = dlg->d->url; + if ( selectedFilter ) + *selectedFilter = dlg->selectedFilter(); + } + delete dlg; + + qt_resolve_symlinks = save_qt_resolve_symlinks; + + return result; +} + +/*! + \internal + Activated when the "OK" button is clicked. +*/ + +void QFileDialogP::okClicked() +{ + QString fn( nameEdit->text() ); + +#if defined(Q_WS_WIN) + QFileInfo fi( d->url.path() + fn ); + if ( fi.isSymLink() ) { + nameEdit->setText( fi.readLink() ); + } +#endif + + if ( fn.contains("*") ) { + addFilter( fn ); + nameEdit->blockSignals( TRUE ); + nameEdit->setText( QString::fromLatin1("") ); + nameEdit->blockSignals( FALSE ); + return; + } + + *workingDirectory = d->url; + detailViewMode = files->isVisible(); + *lastSize = size(); + + if ( isDirectoryMode( d->mode ) ) { + if ( d->ignoreReturn ) { + d->ignoreReturn = FALSE; + return; + } + QUrlInfo f( d->url, nameEdit->text() ); + if ( f.isDir() ) { + d->currentFileName = d->url; + if ( d->currentFileName.right(1) != "/" ) + d->currentFileName += '/'; + if ( f.name() != "." ) + d->currentFileName += f.name(); + accept(); + return; + } + } + + // if we're in multi-selection mode and something is selected, + // accept it and be done. + if ( mode() == ExistingFiles ) { + if ( ! nameEdit->text().isEmpty() ) { + QStringList sf = selectedFiles(); + bool isdir = FALSE; + if ( sf.count() == 1 ) { + QUrlOperator u( d->url, sf[0] ); + bool ok; + isdir = u.isDir(&ok) && ok; + } + if ( !isdir ) { + emit filesSelected( sf ); + accept(); + return; + } + } + } + + if ( mode() == AnyFile ) { + QUrlOperator u( d->url, QFileDialogPrivate::encodeFileName(nameEdit->text()) ); + if ( !u.isDir() ) { + d->currentFileName = u; + emit fileSelected( selectedFile() ); + accept(); + return; + } + } + + if ( mode() == ExistingFile ) { + QUrl u( d->url, QFileDialogPrivate::encodeFileName(nameEdit->text()) ); + if ( u.isLocalFile() ) { + QFileInfo f( u.path() ); + if ( !f.exists() ) + return; + } else { + QNetworkProtocol *p = QNetworkProtocol::getNetworkProtocol( d->url.protocol() ); + if ( p && (p->supportedOperations()&QNetworkProtocol::OpListChildren) ) { + QUrlInfo ui( d->url, nameEdit->text() ); + if ( !ui.isValid() ) + return; + } + } + } + + // If selection is valid, return it, else try + // using selection as a directory to change to. + if ( !d->currentFileName.isNull() && !d->currentFileName.contains( "*" ) ) { + emit fileSelected( selectedFile() ); + accept(); + } else { + QUrlInfo f; + QFileDialogPrivate::File * c + = (QFileDialogPrivate::File *)files->currentItem(); + QFileDialogPrivate::MCItem * m + = (QFileDialogPrivate::MCItem *)d->moreFiles->item( d->moreFiles->currentItem() ); + if ( c && files->isVisible() && files->hasFocus() || + m && d->moreFiles->isVisible() && d->moreFiles->hasFocus() ) { + if ( c && files->isVisible() ) + f = c->info; + else + f = ( (QFileDialogPrivate::File*)m->i )->info; + } else { + f = QUrlInfo( d->url, nameEdit->text() ); + } + if ( f.isDir() ) { + setUrl( QUrlOperator( d->url, QFileDialogPrivate::encodeFileName(f.name() + "/" ) ) ); + d->checkForFilter = TRUE; + trySetSelection( TRUE, d->url, TRUE ); + d->checkForFilter = FALSE; + } else { + if ( !nameEdit->text().contains( "/" ) && + !nameEdit->text().contains( "\\" ) +#if defined(Q_OS_WIN32) + && nameEdit->text()[ 1 ] != ':' +#endif + ) + addFilter( nameEdit->text() ); + else if ( nameEdit->text()[ 0 ] == '/' || + nameEdit->text()[ 0 ] == '\\' +#if defined(Q_OS_WIN32) + || nameEdit->text()[ 1 ] == ':' +#endif + ) + setDir( nameEdit->text() ); + else if ( nameEdit->text().left( 3 ) == "../" || nameEdit->text().left( 3 ) == "..\\" ) + setDir( QUrl( d->url.toString(), QFileDialogPrivate::encodeFileName(nameEdit->text() ) ).toString() ); + } + nameEdit->setText( "" ); + } +} + +/*! + \internal + Activated when the "Filter" button is clicked. +*/ + +void QFileDialogP::filterClicked() +{ + // unused +} + +/*! + \internal + Activated when the "Cancel" button is clicked. +*/ + +void QFileDialogP::cancelClicked() +{ + *workingDirectory = d->url; + detailViewMode = files->isVisible(); + *lastSize = size(); + reject(); +} + + +/*!\reimp +*/ + +void QFileDialogP::resizeEvent( QResizeEvent * e ) +{ + QDialog::resizeEvent( e ); + updateGeometries(); +} + +/* + \internal + The only correct way to try to set currentFileName +*/ +bool QFileDialogP::trySetSelection( bool isDir, const QUrlOperator &u, bool updatelined ) +{ + if ( !isDir && !u.path().isEmpty() && u.path().right( 1 ) == "/" ) + isDir = TRUE; + if ( u.fileName().contains( "*") && d->checkForFilter ) { + QString fn( u.fileName() ); + if ( fn.contains( "*" ) ) { + addFilter( fn ); + d->currentFileName = QString::null; + d->url.setFileName( QString::null ); + nameEdit->setText( QString::fromLatin1("") ); + return FALSE; + } + } + + if ( isDir ) { + if ( d->preview && d->preview->isVisible() ) { + if ( d->infoPreviewer ) + d->infoPreviewer->previewUrl( u ); + if ( d->contentsPreviewer ) + d->contentsPreviewer->previewUrl( u ); + } + } + + QString old = d->currentFileName; + + if ( isDirectoryMode( mode() ) ) { + if ( isDir ) + d->currentFileName = u; + else + d->currentFileName = QString::null; + } else if ( !isDir && mode() == ExistingFiles ) { + d->currentFileName = u; + } else if ( !isDir || ( mode() == AnyFile && !isDir ) ) { + d->currentFileName = u; + } else { + d->currentFileName = QString::null; + } + if ( updatelined && !d->currentFileName.isEmpty() ) { + // If the selection is valid, or if its a directory, allow OK. + if ( !d->currentFileName.isNull() || isDir ) { + if ( u.fileName() != ".." ) { + QString fn = u.fileName(); + nameEdit->setText( fn ); + } else { + nameEdit->setText(""); + } + } else + nameEdit->setText( QString::fromLatin1("") ); + } + + if ( !d->currentFileName.isNull() || isDir ) { + okB->setEnabled( TRUE ); + } else if ( !isDirectoryMode( d->mode ) ) { + okB->setEnabled( FALSE ); + } + + if ( d->currentFileName.length() && old != d->currentFileName ) + emit fileHighlighted( selectedFile() ); + + return !d->currentFileName.isNull(); +} + + +/*! Make sure the minimum and maximum sizes of everything are sane. +*/ + +void QFileDialogP::updateGeometries() +{ + if ( !d || !d->geometryDirty ) + return; + + d->geometryDirty = FALSE; + + QSize r, t; + + // we really should have a QSize::unite() +#define RM r.setWidth( QMAX(r.width(),t.width()) ); \ +r.setHeight( QMAX(r.height(),t.height()) ) + + // labels first + r = d->pathL->sizeHint(); + t = d->fileL->sizeHint(); + RM; + t = d->typeL->sizeHint(); + RM; + d->pathL->setFixedSize( d->pathL->sizeHint() ); + d->fileL->setFixedSize( r ); + d->typeL->setFixedSize( r ); + + // single-line input areas + r = d->paths->sizeHint(); + t = nameEdit->sizeHint(); + RM; + t = d->types->sizeHint(); + RM; + r.setWidth( t.width() * 2 / 3 ); + t.setWidth( QWIDGETSIZE_MAX ); + t.setHeight( r.height() ); + d->paths->setMinimumSize( r ); + d->paths->setMaximumSize( t ); + nameEdit->setMinimumSize( r ); + nameEdit->setMaximumSize( t ); + d->types->setMinimumSize( r ); + d->types->setMaximumSize( t ); + + // buttons on top row + r = QSize( 0, d->paths->minimumSize().height() ); + t = QSize( 21, 20 ); + RM; + if ( r.height()+1 > r.width() ) + r.setWidth( r.height()+1 ); + if ( d->goBack ) + d->goBack->setFixedSize( r ); + d->cdToParent->setFixedSize( r ); + d->newFolder->setFixedSize( r ); + d->mcView->setFixedSize( r ); + d->detailView->setFixedSize( r ); + + QButton *b = 0; + if ( !d->toolButtons.isEmpty() ) { + for ( b = d->toolButtons.first(); b; b = d->toolButtons.next() ) + b->setFixedSize( b->sizeHint().width(), r.height() ); + } + + if ( d->infoPreview ) { + d->previewInfo->show(); + d->previewInfo->setFixedSize( r ); + } else { + d->previewInfo->hide(); + d->previewInfo->setFixedSize( QSize( 0, 0 ) ); + } + + if ( d->contentsPreview ) { + d->previewContents->show(); + d->previewContents->setFixedSize( r ); + } else { + d->previewContents->hide(); + d->previewContents->setFixedSize( QSize( 0, 0 ) ); + } + + // open/save, cancel + r = QSize( 75, 20 ); + t = okB->sizeHint(); + RM; + t = cancelB->sizeHint(); + RM; + + okB->setFixedSize( r ); + cancelB->setFixedSize( r ); + + d->topLevelLayout->activate(); + +#undef RM +} + + +/*! Updates the file name edit box to \a newItem in the file dialog + when the cursor moves in the listview. +*/ + +void QFileDialogP::updateFileNameEdit( QListViewItem * newItem ) +{ + if ( !newItem ) + return; + + if ( mode() == ExistingFiles ) { + detailViewSelectionChanged(); + QUrl u = QUrl( d->url, QFileDialogPrivate::encodeFileName( ((QFileDialogPrivate::File*)files->currentItem())->info.name() ) ); + QFileInfo fi( u.toString( FALSE, FALSE ) ); + if ( !fi.isDir() ) + emit fileHighlighted( u.toString( FALSE, FALSE ) ); + } else if ( files->isSelected( newItem ) ) { + QFileDialogPrivate::File * i = (QFileDialogPrivate::File *)newItem; + if ( i && i->i && !i->i->isSelected() ) { + d->moreFiles->blockSignals( TRUE ); + d->moreFiles->setSelected( i->i, TRUE ); + d->moreFiles->blockSignals( FALSE ); + } + // Encode the filename in case it had any special characters in it + QString encFile = QFileDialogPrivate::encodeFileName( newItem->text( 0 ) ); + trySetSelection( i->info.isDir(), QUrlOperator( d->url, encFile ), TRUE ); + } +} + +void QFileDialogP::detailViewSelectionChanged() +{ + if ( d->mode != ExistingFiles ) + return; + + nameEdit->clear(); + QString str; + QListViewItem * i = files->firstChild(); + d->moreFiles->blockSignals( TRUE ); + while( i ) { + if ( d->moreFiles && isVisible() ) { + if ( ( (QFileDialogPrivate::File *)i )->i->isSelected() != i->isSelected() ) + d->moreFiles->setSelected( ( (QFileDialogPrivate::File *)i )->i, i->isSelected() ); + } + if ( i->isSelected() && !( (QFileDialogPrivate::File *)i )->info.isDir() ) + str += QString( "\"%1\" " ).arg( i->text( 0 ) ); + i = i->nextSibling(); + } + d->moreFiles->blockSignals( FALSE ); + nameEdit->setText( str ); + nameEdit->setCursorPosition( str.length() ); + okB->setEnabled( TRUE ); + if ( d->preview && d->preview->isVisible() && files->currentItem() ) { + QUrl u = QUrl( d->url, QFileDialogPrivate::encodeFileName( ((QFileDialogPrivate::File*)files->currentItem())->info.name() ) ); + if ( d->infoPreviewer ) + d->infoPreviewer->previewUrl( u ); + if ( d->contentsPreviewer ) + d->contentsPreviewer->previewUrl( u ); + } +} + +void QFileDialogP::listBoxSelectionChanged() +{ + if ( d->mode != ExistingFiles ) + return; + + if ( d->ignoreNextRefresh ) { + d->ignoreNextRefresh = FALSE; + return; + } + + nameEdit->clear(); + QString str; + QListBoxItem * i = d->moreFiles->item( 0 ); + QListBoxItem * j = 0; + int index = 0; + files->blockSignals( TRUE ); + while( i ) { + if ( files && isVisible() ) { + if ( ( (QFileDialogPrivate::MCItem *)i )->i->isSelected() != i->isSelected() ) + files->setSelected( ( (QFileDialogPrivate::MCItem *)i )->i, i->isSelected() ); + } + if ( d->moreFiles->isSelected( i ) + && !( (QFileDialogPrivate::File*)( (QFileDialogPrivate::MCItem *)i )->i )->info.isDir() ) + { + str += QString( "\"%1\" " ).arg( i->text() ); + if ( j == 0 ) + j = i; + } + i = d->moreFiles->item( ++index ); + } + files->blockSignals( FALSE ); + nameEdit->setText( str ); + nameEdit->setCursorPosition( str.length() ); + okB->setEnabled( TRUE ); + if ( d->preview && d->preview->isVisible() && j ) { + QUrl u = QUrl( d->url, + QFileDialogPrivate::encodeFileName( ( (QFileDialogPrivate::File*)( (QFileDialogPrivate::MCItem*)j )->i )->info.name() ) ); + if ( d->infoPreviewer ) + d->infoPreviewer->previewUrl( u ); + if ( d->contentsPreviewer ) + d->contentsPreviewer->previewUrl( u ); + } +} + +/*! \overload */ + +void QFileDialogP::updateFileNameEdit( QListBoxItem * newItem ) +{ + if ( !newItem ) + return; + QFileDialogPrivate::MCItem * i = (QFileDialogPrivate::MCItem *)newItem; + if ( d->mode != ExistingFiles && i->i ) { + i->i->listView()->setSelected( i->i, i->isSelected() ); + updateFileNameEdit( i->i ); + } +} + + +/*! Updates the dialog when the file name edit changes. */ + +void QFileDialogP::fileNameEditDone() +{ + QUrlInfo f( d->url, nameEdit->text() ); + if ( mode() != QFileDialogP::ExistingFiles ) { + QUrlOperator u( d->url, QFileDialogPrivate::encodeFileName( nameEdit->text() ) ); + trySetSelection( f.isDir(), u, FALSE ); + if ( d->preview && d->preview->isVisible() ) { + if ( d->infoPreviewer ) + d->infoPreviewer->previewUrl( u ); + if ( d->contentsPreviewer ) + d->contentsPreviewer->previewUrl( u ); + } + } +} + + + +/*! This private slot reacts to double-clicks in the list view. The item that +was double-clicked is specified in \a newItem */ + +void QFileDialogP::selectDirectoryOrFile( QListViewItem * newItem ) +{ + + *workingDirectory = d->url; + detailViewMode = files->isVisible(); + *lastSize = size(); + + if ( !newItem ) + return; + +#if defined(Q_WS_WIN) + QFileInfo fi( d->url.path() + newItem->text(0) ); + if ( fi.isSymLink() ) { + nameEdit->setText( fi.readLink() ); + okClicked(); + return; + } +#endif + + QFileDialogPrivate::File * i = (QFileDialogPrivate::File *)newItem; + + QString oldName = nameEdit->text(); + if ( i->info.isDir() ) { + setUrl( QUrlOperator( d->url, QFileDialogPrivate::encodeFileName( i->info.name() ) + "/" ) ); + if ( isDirectoryMode( mode() ) ) { + QUrlInfo f ( d->url, QString::fromLatin1( "." ) ); + trySetSelection( f.isDir(), d->url, TRUE ); + } + } else if ( newItem->isSelectable() && + trySetSelection( i->info.isDir(), QUrlOperator( d->url, QFileDialogPrivate::encodeFileName( i->info.name() ) ), TRUE ) ) { + if ( !isDirectoryMode( mode() ) ) { + emit fileSelected( selectedFile() ); + accept(); + } + } else if ( isDirectoryMode( d->mode ) ) { + d->currentFileName = d->url; + accept(); + } + if ( !oldName.isEmpty() && !isDirectoryMode( mode() ) ) + nameEdit->setText( oldName ); +} + + +void QFileDialogP::selectDirectoryOrFile( QListBoxItem * newItem ) +{ + if ( !newItem ) + return; + + QFileDialogPrivate::MCItem * i = (QFileDialogPrivate::MCItem *)newItem; + if ( i->i ) { + i->i->listView()->setSelected( i->i, i->isSelected() ); + selectDirectoryOrFile( i->i ); + } +} + + +void QFileDialogP::popupContextMenu( QListViewItem *item, const QPoint &p, + int ) +{ + if ( item && d->mode == ExistingFiles ) + return; + if ( item ) { + files->setCurrentItem( item ); + files->setSelected( item, TRUE ); + } + + PopupAction action; + popupContextMenu( item ? item->text( 0 ) : QString::null, TRUE, action, p ); + + if ( action == PA_Open ) + selectDirectoryOrFile( item ); + else if ( action == PA_Rename ) + files->startRename( FALSE ); + else if ( action == PA_Delete ) + deleteFile( item ? item->text( 0 ) : QString::null ); + else if ( action == PA_Reload ) + rereadDir(); + else if ( action == PA_Hidden ) { + bShowHiddenFiles = !bShowHiddenFiles; + rereadDir(); + } else if ( action == PA_SortName ) { + sortFilesBy = (int)QDir::Name; + sortAscending = TRUE; + resortDir(); + } else if ( action == PA_SortSize ) { + sortFilesBy = (int)QDir::Size; + sortAscending = TRUE; + resortDir(); + } else if ( action == PA_SortDate ) { + sortFilesBy = (int)QDir::Time; + sortAscending = TRUE; + resortDir(); + } else if ( action == PA_SortUnsorted ) { + sortFilesBy = (int)QDir::Unsorted; + sortAscending = TRUE; + resortDir(); + } + +} + +void QFileDialogP::popupContextMenu( QListBoxItem *item, const QPoint & p ) +{ + if ( item && d->mode == ExistingFiles ) + return; + + PopupAction action; + popupContextMenu( item ? item->text() : QString::null, FALSE, action, p ); + + if ( action == PA_Open ) + selectDirectoryOrFile( item ); + else if ( action == PA_Rename ) + d->moreFiles->startRename( FALSE ); + else if ( action == PA_Delete ) + deleteFile( item->text() ); + else if ( action == PA_Reload ) + rereadDir(); + else if ( action == PA_Hidden ) { + bShowHiddenFiles = !bShowHiddenFiles; + rereadDir(); + } else if ( action == PA_SortName ) { + sortFilesBy = (int)QDir::Name; + sortAscending = TRUE; + resortDir(); + } else if ( action == PA_SortSize ) { + sortFilesBy = (int)QDir::Size; + sortAscending = TRUE; + resortDir(); + } else if ( action == PA_SortDate ) { + sortFilesBy = (int)QDir::Time; + sortAscending = TRUE; + resortDir(); + } else if ( action == PA_SortUnsorted ) { + sortFilesBy = (int)QDir::Unsorted; + sortAscending = TRUE; + resortDir(); + } +} + +void QFileDialogP::popupContextMenu( const QString &filename, bool, + PopupAction &action, const QPoint &p ) +{ + action = PA_Cancel; + + bool glob = filename.isEmpty(); + + QPopupMenu m( 0, "file dialog context menu" ); + m.setCheckable( TRUE ); + + if ( !glob ) { + QString okt; + if ( QUrlInfo( d->url, filename ).isDir() ) { + okt = tr( "&Open" ); + } else { + if ( mode() == AnyFile ) + okt = tr( "&Save" ); + else + okt = tr( "&Open" ); + } + int ok = m.insertItem( okt ); + + m.insertSeparator(); + int rename = m.insertItem( tr( "&Rename" ) ); + int del = m.insertItem( tr( "&Delete" ) ); + + if ( filename.isEmpty() || !QUrlInfo( d->url, filename ).isWritable() || + filename == ".." ) { + if ( filename.isEmpty() || !QUrlInfo( d->url, filename ).isReadable() ) + m.setItemEnabled( ok, FALSE ); + m.setItemEnabled( rename, FALSE ); + m.setItemEnabled( del, FALSE ); + } + + if ( mode() == QFileDialogP::ExistingFiles ) + m.setItemEnabled( rename, FALSE ); + + m.move( p ); + int res = m.exec(); + + if ( res == ok ) + action = PA_Open; + else if ( res == rename ) + action = PA_Rename; + else if ( res == del ) + action = PA_Delete; + } else { + int reload = m.insertItem( tr( "R&eload" ) ); + + QPopupMenu m2( 0, "sort menu" ); + + int sname = m2.insertItem( tr( "Sort by &Name" ) ); + //int stype = m2.insertItem( tr( "Sort by &Type" ) ); + int ssize = m2.insertItem( tr( "Sort by &Size" ) ); + int sdate = m2.insertItem( tr( "Sort by &Date" ) ); + m2.insertSeparator(); + int sunsorted = m2.insertItem( tr( "&Unsorted" ) ); + + //m2.setItemEnabled( stype, FALSE ); + + if ( sortFilesBy == (int)QDir::Name ) + m2.setItemChecked( sname, TRUE ); + else if ( sortFilesBy == (int)QDir::Size ) + m2.setItemChecked( ssize, TRUE ); +// else if ( sortFilesBy == 0x16 ) +// m2.setItemChecked( stype, TRUE ); + else if ( sortFilesBy == (int)QDir::Time ) + m2.setItemChecked( sdate, TRUE ); + else if ( sortFilesBy == (int)QDir::Unsorted ) + m2.setItemChecked( sunsorted, TRUE ); + + m.insertItem( tr( "Sort" ), &m2 ); + + m.insertSeparator(); + + int hidden = m.insertItem( tr( "Show &hidden files" ) ); + m.setItemChecked( hidden, bShowHiddenFiles ); + + m.move( p ); + int res = m.exec(); + + if ( res == reload ) + action = PA_Reload; + else if ( res == hidden ) + action = PA_Hidden; + else if ( res == sname ) + action = PA_SortName; +// else if ( res == stype ) +// action = PA_SortType; + else if ( res == sdate ) + action = PA_SortDate; + else if ( res == ssize ) + action = PA_SortSize; + else if ( res == sunsorted ) + action = PA_SortUnsorted; + } + +} + +void QFileDialogP::deleteFile( const QString &filename ) +{ + if ( filename.isEmpty() ) + return; + + QUrlInfo fi( d->url, QFileDialogPrivate::encodeFileName( filename ) ); + QString t = tr( "the file" ); + if ( fi.isDir() ) + t = tr( "the directory" ); + if ( fi.isSymLink() ) + t = tr( "the symlink" ); + + if ( QMessageBox::warning( this, + tr( "Delete %1" ).arg( t ), + tr( "Are you sure you wish to delete %1 \"%2\"?" ) + .arg( t ).arg(filename), + tr( "&Yes" ), tr( "&No" ), QString::null, 1 ) == 0 ) + d->url.remove( QFileDialogPrivate::encodeFileName( filename ) ); + +} + +void QFileDialogP::fileSelected( int ) +{ + // unused +} + +void QFileDialogP::fileHighlighted( int ) +{ + // unused +} + +void QFileDialogP::dirSelected( int ) +{ + // unused +} + +void QFileDialogP::pathSelected( int ) +{ + // unused +} + + +void QFileDialogP::cdUpClicked() +{ + QString oldName = nameEdit->text(); + setUrl( QUrlOperator( d->url, ".." ) ); + if ( !oldName.isEmpty() ) + nameEdit->setText( oldName ); +} + +void QFileDialogP::newFolderClicked() +{ + QString foldername( tr( "New Folder 1" ) ); + int i = 0; + QStringList lst; + QListViewItemIterator it( files ); + for ( ; it.current(); ++it ) + if ( it.current()->text( 0 ).contains( tr( "New Folder" ) ) ) + lst.append( it.current()->text( 0 ) ); + + if ( !lst.count() == 0 ) + while ( lst.contains( foldername ) ) + foldername = tr( "New Folder %1" ).arg( ++i ); + + d->url.mkdir( foldername ); +} + +void QFileDialogP::createdDirectory( const QUrlInfo &info, QNetworkOperation * ) +{ + resortDir(); + if ( d->moreFiles->isVisible() ) { + for ( uint i = 0; i < d->moreFiles->count(); ++i ) { + if ( d->moreFiles->text( i ) == info.name() ) { + d->moreFiles->setCurrentItem( i ); + d->moreFiles->startRename( FALSE ); + break; + } + } + } else { + QListViewItem *item = files->firstChild(); + while ( item ) { + if ( item->text( 0 ) == info.name() ) { + files->setSelected( item, TRUE ); + files->setCurrentItem( item ); + files->startRename( FALSE ); + break; + } + item = item->nextSibling(); + } + } +} + + +/*! + This is a convenience static function that will return an existing directory + selected by the user. + + \code + QString s = QFileDialogP::getExistingDirectory( + "/home", + this, + "get existing directory" + "Choose a directory", + TRUE ); + \endcode + + This function creates a modal file dialog called \a name, with + parent, \a parent. If parent is not 0, the dialog will be shown + centered over the parent. + + The dialog's working directory is set to \a dir, and the caption is + set to \a caption. Either of these may be QString::null in which case + the current directory and a default caption will be used respectively. + + If \a dirOnly is TRUE, then only directories will be shown in + the file dialog; otherwise both directories and files will be shown. + + Under Unix/X11, the normal behavior of the file dialog is to resolve + and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp, + the file dialog will change to /var/tmp after entering /usr/tmp. + If \a resolveSymlinks is FALSE, the file dialog will treat + symlinks as regular directories. + + \sa getOpenFileName(), getOpenFileNames(), getSaveFileName() +*/ + +QString QFileDialogP::getExistingDirectory( const QString & dir, + QWidget *parent, + const char* name, + const QString& caption, + bool dirOnly, + bool resolveSymlinks) +{ + bool save_qt_resolve_symlinks = qt_resolve_symlinks; + qt_resolve_symlinks = resolveSymlinks; + + makeVariables(); + QString wd; + if ( workingDirectory ) + wd = *workingDirectory; + +#if defined(Q_WS_WIN) + QString initialDir; + if ( !dir.isEmpty() ) { + QUrlOperator u( dir ); + if ( QFileInfo( u.path() ).isDir() ) + initialDir = dir; + } else + initialDir = QString::null; + if ( qApp->style().styleHint( QStyle::SH_GUIStyle ) == WindowsStyle && dirOnly ) + return winGetExistingDirectory( initialDir, parent, name, caption ); +#endif +#if defined(Q_WS_MAC) + if( ( qApp->style().inherits(QMAC_DEFAULT_STYLE) ) ) + return macGetOpenFileNames("", 0, + parent, name, caption, FALSE, TRUE).first(); +#endif + + QFileDialogP *dialog = new QFileDialogP( parent, name ? name : "qt_filedlg_ged", TRUE ); +#ifndef QT_NO_WIDGET_TOPEXTRA + if ( !caption.isNull() ) + dialog->setCaption( caption ); + else + dialog->setCaption( QFileDialogP::tr("Find Directory") ); +#endif + + dialog->setMode( dirOnly ? DirectoryOnly : Directory ); + + dialog->d->types->clear(); + dialog->d->types->insertItem( QFileDialogP::tr("Directories") ); + dialog->d->types->setEnabled( FALSE ); + + QString dir_( dir ); + dir_ = dir_.simplifyWhiteSpace(); + if ( dir_.isEmpty() && !wd.isEmpty() ) + dir_ = wd; + QUrlOperator u( dir_ ); + if ( u.isLocalFile() ) { + if ( !dir_.isEmpty() ) { + QFileInfo f( u.path() ); + if ( f.exists() ) + if ( f.isDir() ) { + dialog->setDir( dir_ ); + wd = dir_; + } + } else if ( !wd.isEmpty() ) { + QUrl tempUrl( wd ); + QFileInfo f( tempUrl.path() ); + if ( f.isDir() ) { + dialog->setDir( wd ); + } + } else { + QString theDir = dir_; + if ( theDir.isEmpty() ) { + theDir = QDir::currentDirPath(); + } if ( !theDir.isEmpty() ) { + QUrl tempUrl( theDir ); + QFileInfo f( tempUrl.path() ); + if ( f.isDir() ) { + wd = theDir; + dialog->setDir( theDir ); + } + } + } + } else { + dialog->setUrl( dir_ ); + } + + QString result; + dialog->setSelection( dialog->d->url.toString() ); + + if ( dialog->exec() == QDialog::Accepted ) { + result = dialog->selectedFile(); + wd = result; + } + delete dialog; + + if ( !result.isEmpty() && result.right( 1 ) != "/" ) + result += "/"; + + qt_resolve_symlinks = save_qt_resolve_symlinks; + + return result; +} + + +/*! + \property QFileDialogP::mode + \brief the file dialog's mode + + The default mode is \c ExistingFile. +*/ + +void QFileDialogP::setMode( Mode newMode ) +{ + if ( d->mode != newMode ) { + d->mode = newMode; + QString sel = d->currentFileName; + if ( isDirectoryMode( newMode ) ) { + files->setMultiSelection( FALSE ); + d->moreFiles->setMultiSelection( FALSE ); + if ( sel.isNull() ) + sel = QString::fromLatin1("."); + d->types->setEnabled( FALSE ); + } else if ( newMode == ExistingFiles ) { + files->setSelectionMode( QListView::Extended ); + d->moreFiles->setSelectionMode( QListBox::Extended ); + d->types->setEnabled( TRUE ); + } else { + files->setMultiSelection( FALSE ); + d->moreFiles->setMultiSelection( FALSE ); + d->types->setEnabled( TRUE ); + } + rereadDir(); + QUrlInfo f( d->url, "." ); + trySetSelection( f.isDir(), d->url, FALSE ); + } + + QString okt; + bool changeFilters = FALSE; + if ( mode() == AnyFile ) { + okt = tr("Save"); + d->fileL->setText( tr("File &name:") ); + if ( d->types->count() == 1 ) { + d->types->setCurrentItem( 0 ); + if ( d->types->currentText() == "Directories" ) { + changeFilters = TRUE; + } + } + } + else if ( mode() == Directory || mode() == DirectoryOnly ) { + okt = tr("OK"); + d->fileL->setText( tr("Directory:") ); + d->types->clear(); + d->types->insertItem( tr("Directories") ); + } + else { + okt = tr("Open"); + d->fileL->setText( tr("File &name:") ); + if ( d->types->count() == 1 ) { + d->types->setCurrentItem( 0 ); + if ( d->types->currentText() == "Directories" ) { + changeFilters = TRUE; + } + } + } + + if ( changeFilters ) { + d->types->clear(); + d->types->insertItem( tr("All Files (*)") ); + } + + okB->setText( okt ); +} + +QFileDialogP::Mode QFileDialogP::mode() const +{ + return d->mode; +} + +/*! \reimp +*/ + +void QFileDialogP::done( int i ) +{ + if ( i == QDialog::Accepted && (d->mode == ExistingFile || d->mode == ExistingFiles) ) { + QStringList selection = selectedFiles(); + for ( uint f = 0; f < selection.count(); f++ ) { + QString file = selection[f]; + if ( file.isNull() ) + continue; + if ( d->url.isLocalFile() && !QFile::exists( file ) ) { + QMessageBox::information( this, tr("Error"), tr("%1\nFile not found.\nCheck path and filename.").arg( file ) ); + return; + } + } + } + QDialog::done( i ); +} + +/*! + \property QFileDialogP::viewMode + + \brief the file dialog's view mode + + If you set the view mode to be \e Detail (the default), then you + will see the file's details, such as the size of the file and the + date the file was last modified in addition to the file's name. + + If you set the view mode to be \e List, then you will just + see a list of the files and folders. + + See \l QFileDialogP::ViewMode +*/ + + +QFileDialogP::ViewMode QFileDialogP::viewMode() const +{ + if ( detailViewMode ) + return Detail; + else + return List; +} + +void QFileDialogP::setViewMode( ViewMode m ) +{ + if ( m == Detail ) { + detailViewMode = TRUE; + d->stack->raiseWidget( files ); + d->detailView->setOn( TRUE ); + d->mcView->setOn( FALSE ); + } else if ( m == List ) { + detailViewMode = FALSE; + d->stack->raiseWidget( d->moreFiles ); + d->detailView->setOn( FALSE ); + d->mcView->setOn( TRUE ); + } +} + + +/*! + \property QFileDialogP::previewMode + + \brief the preview mode for the file dialog + + If you set the mode to be a mode other than \e NoPreview, you must + use setInfoPreview() or setContentsPreview() to set the dialog's + preview widget to your preview widget and enable the preview + widget(s) with setInfoPreviewEnabled() or + setContentsPreviewEnabled(). + + \sa infoPreview, contentsPreview, viewMode +*/ + +void QFileDialogP::setPreviewMode( PreviewMode m ) +{ + if ( m == NoPreview ) { + d->previewInfo->setOn( FALSE ); + d->previewContents->setOn( FALSE ); + } else if ( m == Info && d->infoPreview ) { + d->previewInfo->setOn( TRUE ); + d->previewContents->setOn( FALSE ); + changeMode( d->modeButtons->id( d->previewInfo ) ); + } else if ( m == Contents && d->contentsPreview ) { + d->previewInfo->setOn( FALSE ); + d->previewContents->setOn( TRUE ); + changeMode( d->modeButtons->id( d->previewContents ) ); + } +} +QFileDialogP::PreviewMode QFileDialogP::previewMode() const +{ + if ( d->infoPreview && d->previewInfo->isVisible() ) + return Info; + else if ( d->contentsPreview && d->previewContents->isVisible() ) + return Contents; + + return NoPreview; +} + + +/*! + Adds the specified widgets to the bottom of the file dialog. The + label \a l is placed underneath the "file name" and the "file types" + labels. The widget \a w is placed underneath the file types combobox. + The button \a b is placed underneath the Cancel pushbutton. + + \code + MyFileDialog::MyFileDialog( QWidget* parent, const char* name ) : + QFileDialogP( parent, name ) + { + QLabel* label = new QLabel( "Added widgets", this ); + QLineEdit* lineedit = new QLineEdit( this ); + QToolButton* toolbutton = new QToolButton( this ); + + addWidgets( label, lineedit, toolbutton ); + } + \endcode + + If you don't want to have one of the widgets added, pass 0 in that + widget's position. + + Every time you call this function, a new row of widgets will be added + to the bottom of the file dialog. + + \sa addToolButton(), addLeftWidget(), addRightWidget() +*/ + +void QFileDialogP::addWidgets( QLabel * l, QWidget * w, QPushButton * b ) +{ + if ( !l && !w && !b ) + return; + + d->geometryDirty = TRUE; + + QHBoxLayout *lay = new QHBoxLayout(); + d->extraWidgetsLayouts.append( lay ); + d->topLevelLayout->addLayout( lay ); + + if ( !l ) + l = new QLabel( this, "qt_intern_lbl" ); + d->extraLabels.append( l ); + lay->addWidget( l ); + + if ( !w ) + w = new QWidget( this, "qt_intern_widget" ); + d->extraWidgets.append( w ); + lay->addWidget( w ); + lay->addSpacing( 15 ); + + if ( b ) { + d->extraButtons.append( b ); + lay->addWidget( b ); + } else { + QWidget *wid = new QWidget( this, "qt_extrabuttons_widget" ); + d->extraButtons.append( wid ); + lay->addWidget( wid ); + } + + updateGeometries(); +} + +/*! + Adds the tool button \a b to the row of tool buttons at the top of the + file dialog. The button is appended to the right of + this row. If \a separator is TRUE, a small space is inserted between the + last button of the row and the new button \a b. + + \sa addWidgets(), addLeftWidget(), addRightWidget() +*/ + +void QFileDialogP::addToolButton( QButton *b, bool separator ) +{ + if ( !b || !d->buttonLayout ) + return; + + d->geometryDirty = TRUE; + + d->toolButtons.append( b ); + if ( separator ) + d->buttonLayout->addSpacing( 8 ); + d->buttonLayout->addWidget( b ); + + updateGeometries(); +} + +/*! + Adds the widget \a w to the left-hand side of the file dialog. + + \sa addRightWidget(), addWidgets(), addToolButton() +*/ + +void QFileDialogP::addLeftWidget( QWidget *w ) +{ + if ( !w ) + return; + d->geometryDirty = TRUE; + + d->leftLayout->addWidget( w ); + d->leftLayout->addSpacing( 5 ); + + updateGeometries(); +} + +/*! + Adds the widget \a w to the right-hand side of the file dialog. + + \sa addLeftWidget(), addWidgets(), addToolButton() +*/ + +void QFileDialogP::addRightWidget( QWidget *w ) +{ + if ( !w ) + return; + d->geometryDirty = TRUE; + + d->rightLayout->addSpacing( 5 ); + d->rightLayout->addWidget( w ); + + updateGeometries(); +} + +/*! \reimp */ + +void QFileDialogP::keyPressEvent( QKeyEvent * ke ) +{ + if ( !d->ignoreNextKeyPress && + ke && ( ke->key() == Key_Enter || + ke->key() == Key_Return ) ) { + ke->ignore(); + if ( d->paths->hasFocus() ) { + ke->accept(); + if ( d->url == QUrl(d->paths->currentText()) ) + nameEdit->setFocus(); + } else if ( d->types->hasFocus() ) { + ke->accept(); + // ### is there a suitable condition for this? only valid + // wildcards? + nameEdit->setFocus(); + } else if ( nameEdit->hasFocus() ) { + if ( d->currentFileName.isNull() ) { + // maybe change directory + QUrlInfo i( d->url, nameEdit->text() ); + if ( i.isDir() ) { + nameEdit->setText( QString::fromLatin1("") ); + setDir( QUrlOperator( d->url, QFileDialogPrivate::encodeFileName(i.name()) ) ); + } + ke->accept(); + } else if ( mode() == ExistingFiles ) { + QUrlInfo i( d->url, nameEdit->text() ); + if ( i.isFile() ) { + QListViewItem * i = files->firstChild(); + while ( i && nameEdit->text() != i->text( 0 ) ) + i = i->nextSibling(); + if ( i ) + files->setSelected( i, TRUE ); + else + ke->accept(); // strangely, means to ignore that event + } + } + } else if ( files->hasFocus() || d->moreFiles->hasFocus() ) { + ke->accept(); + } + } else if ( ke->key() == Key_Escape ) { + ke->ignore(); + } + + d->ignoreNextKeyPress = FALSE; + + if ( !ke->isAccepted() ) { + QDialog::keyPressEvent( ke ); + } +} + + +/*! \class QFileIconProviderP qfiledialog.h + + \brief The QFileIconProviderP class provides icons for QFileDialogP to + use. + + \ingroup misc + + By default QFileIconProviderP is not used, but any application or + library can subclass it, reimplement pixmap() to return a suitable + icon, and make all QFileDialogP objects use it by calling the static + function QFileDialogP::setIconProvider(). + + It is advisable to make all the icons that QFileIconProviderP returns be + the same size or at least the same width. This makes the list view + look much better. + + \sa QFileDialogP +*/ + + +/*! Constructs an empty file icon provider called \a name, with the + parent \a parent. +*/ + +QFileIconProviderP::QFileIconProviderP( QObject * parent, const char* name ) + : QObject( parent, name ) +{ + // nothing necessary +} + + +/*! + Returns a pointer to a pixmap that should be used to + signify the file with the information \a info. + + If pixmap() returns 0, QFileDialogP draws the default pixmap. + + The default implementation returns particular icons for files, directories, + link-files and link-directories. It returns a blank "icon" for other types. + + If you return a pixmap here, it should measure 16x16 pixels. +*/ + +const QPixmap * QFileIconProviderP::pixmap( const QFileInfo & info ) +{ + if ( info.isSymLink() ) { + if ( info.isFile() ) + return symLinkFileIcon; + else + return symLinkDirIcon; + } else if ( info.isDir() ) { + return closedFolderIcon; + } else if ( info.isFile() ) { + return fileIcon; + } else { + return fifteenTransparentPixels; + } +} + +/*! + Sets the QFileIconProviderP used by the file dialog to \a provider. + + The default is that there is no QFileIconProviderP and QFileDialogP + just draws a folder icon next to each directory and nothing next + to files. + + \sa QFileIconProviderP, iconProvider() +*/ + +void QFileDialogP::setIconProvider( QFileIconProviderP * provider ) +{ + fileIconProvider = provider; +} + + +/*! + Returns a pointer to the icon provider currently set on the file dialog. + By default there is no icon provider, and this function returns 0. + + \sa setIconProvider(), QFileIconProviderP +*/ + +QFileIconProviderP * QFileDialogP::iconProvider() +{ + return fileIconProvider; +} + + +#if defined(Q_WS_WIN) + +static QString getWindowsRegString( HKEY key, const char *subKey ) +{ + QString s; + char buf[512]; + DWORD bsz = sizeof(buf); +#ifdef Q_OS_TEMP + int r = RegQueryValueEx( key, (LPCTSTR)qt_winTchar(subKey, TRUE), 0, 0, (LPBYTE)buf, &bsz ); +#else + int r = RegQueryValueExA( key, subKey, 0, 0, (LPBYTE)buf, &bsz ); +#endif + if ( r == ERROR_SUCCESS ) { + s = buf; + } else if ( r == ERROR_MORE_DATA ) { + char *ptr = new char[bsz+1]; +#ifdef Q_OS_TEMP + r = RegQueryValueEx( key, (LPCTSTR)qt_winTchar(subKey, TRUE), 0, 0, (LPBYTE)ptr, &bsz ); +#else + r = RegQueryValueExA( key, subKey, 0, 0, (LPBYTE)ptr, &bsz ); +#endif + if ( r == ERROR_SUCCESS ) + s = ptr; + delete [] ptr; + } + return s; +} + +static void initPixmap( QPixmap &pm ) +{ + pm.fill( Qt::white ); +} + +QWindowsIconProvider::QWindowsIconProvider( QObject *parent, const char *name ) + : QFileIconProviderP( parent, name ) +{ + pixw = GetSystemMetrics( SM_CXSMICON ); + pixh = GetSystemMetrics( SM_CYSMICON ); + + HKEY k; + HICON si; + int r; + QString s; + UINT res; + +#ifdef Q_OS_TEMP + // ---------- get default folder pixmap + r = RegOpenKeyEx( HKEY_CLASSES_ROOT, + L"folder\\DefaultIcon", + 0, KEY_READ, &k ); +#else + // ---------- get default folder pixmap + r = RegOpenKeyExA( HKEY_CLASSES_ROOT, + "folder\\DefaultIcon", + 0, KEY_READ, &k ); +#endif + if ( r == ERROR_SUCCESS ) { + s = getWindowsRegString( k, 0 ); + RegCloseKey( k ); + + QStringList lst = QStringList::split( ",", s ); + +#ifdef Q_OS_TEMP + res = (UINT)ExtractIconEx( (LPCTSTR)qt_winTchar( lst[ 0 ].simplifyWhiteSpace(), TRUE ), + lst[ 1 ].simplifyWhiteSpace().toInt(), + 0, &si, 1 ); +#else + res = ExtractIconExA( lst[ 0 ].simplifyWhiteSpace().latin1(), + lst[ 1 ].simplifyWhiteSpace().toInt(), + 0, &si, 1 ); +#endif + + if ( res ) { + defaultFolder.resize( pixw, pixh ); + initPixmap( defaultFolder ); + QPainter p( &defaultFolder ); + DrawIconEx( p.handle(), 0, 0, si, pixw, pixh, 0, NULL, DI_NORMAL ); + p.end(); + defaultFolder.setMask( defaultFolder.createHeuristicMask() ); + *closedFolderIcon = defaultFolder; + DestroyIcon( si ); + } else { + defaultFolder = *closedFolderIcon; + } + } else { + RegCloseKey( k ); + } + +#ifdef Q_OS_TEMP + //------------------------------- get default file pixmap + res = (UINT)ExtractIconEx( L"shell32.dll", + 0, 0, &si, 1 ); +#else + //------------------------------- get default file pixmap + res = ExtractIconExA( "shell32.dll", + 0, 0, &si, 1 ); +#endif + + if ( res ) { + defaultFile.resize( pixw, pixh ); + initPixmap( defaultFile ); + QPainter p( &defaultFile ); + DrawIconEx( p.handle(), 0, 0, si, pixw, pixh, 0, NULL, DI_NORMAL ); + p.end(); + defaultFile.setMask( defaultFile.createHeuristicMask() ); + *fileIcon = defaultFile; + DestroyIcon( si ); + } else { + defaultFile = *fileIcon; + } + +#ifdef Q_OS_TEMP + //------------------------------- get default exe pixmap + res = (UINT)ExtractIconEx( L"shell32.dll", + 2, 0, &si, 1 ); +#else + //------------------------------- get default exe pixmap + res = ExtractIconExA( "shell32.dll", + 2, 0, &si, 1 ); +#endif + + if ( res ) { + defaultExe.resize( pixw, pixh ); + initPixmap( defaultExe ); + QPainter p( &defaultExe ); + DrawIconEx( p.handle(), 0, 0, si, pixw, pixh, 0, NULL, DI_NORMAL ); + p.end(); + defaultExe.setMask( defaultExe.createHeuristicMask() ); + DestroyIcon( si ); + } else { + defaultExe = *fileIcon; + } +} + +QWindowsIconProvider::~QWindowsIconProvider() +{ + if ( this == fileIconProvider ) + fileIconProvider = 0; +} + +const QPixmap * QWindowsIconProvider::pixmap( const QFileInfo &fi ) +{ + QString ext = fi.extension().upper(); + QString key = ext; + ext.prepend( "." ); + QMap< QString, QPixmap >::Iterator it; + + if ( fi.isDir() ) { + return &defaultFolder; + } else if ( ext.lower() != ".exe" ) { + it = cache.find( key ); + if ( it != cache.end() ) + return &( *it ); + + HKEY k, k2; +#ifdef Q_OS_TEMP + int r = RegOpenKeyEx( HKEY_CLASSES_ROOT, + (LPCTSTR)qt_winTchar(ext, TRUE), + 0, KEY_READ, &k ); +#else + int r = RegOpenKeyExA( HKEY_CLASSES_ROOT, + ext.latin1(), + 0, KEY_READ, &k ); +#endif + QString s; + if ( r == ERROR_SUCCESS ) { + s = getWindowsRegString( k, 0 ); + } else { + cache[ key ] = defaultFile; + RegCloseKey( k ); + return &defaultFile; + } + RegCloseKey( k ); + +#ifdef Q_OS_TEMP + r = RegOpenKeyEx( HKEY_CLASSES_ROOT, + (LPCTSTR)qt_winTchar( s + "\\DefaultIcon", TRUE ), + 0, KEY_READ, &k2 ); +#else + r = RegOpenKeyExA( HKEY_CLASSES_ROOT, + QString( s + "\\DefaultIcon" ).latin1() , + 0, KEY_READ, &k2 ); +#endif + if ( r == ERROR_SUCCESS ) { + s = getWindowsRegString( k2, 0 ); + } else { + cache[ key ] = defaultFile; + RegCloseKey( k2 ); + return &defaultFile; + } + RegCloseKey( k2 ); + + QStringList lst = QStringList::split( ",", s ); + + HICON si; + UINT res; + QString filepath = lst[ 0 ].stripWhiteSpace(); + if ( filepath.find("%1") != -1 ) { + filepath = filepath.arg( fi.filePath() ); + if ( ext.lower() == ".dll" ) { + pix = defaultFile; + return &pix; + } + } + +#ifdef Q_OS_TEMP + res = (UINT)ExtractIconEx( (LPCTSTR)qt_winTchar(filepath, TRUE), + lst[ 1 ].stripWhiteSpace().toInt(), + NULL, &si, 1 ); +#else + res = ExtractIconExA( filepath.latin1(), + lst[ 1 ].stripWhiteSpace().toInt(), + NULL, &si, 1 ); +#endif + + if ( res ) { + pix.resize( pixw, pixh ); + initPixmap( pix ); + QPainter p( &pix ); + DrawIconEx( p.handle(), 0, 0, si, pixw, pixh, 0, NULL, DI_NORMAL ); + p.end(); + pix.setMask( pix.createHeuristicMask() ); + DestroyIcon( si ); + } else { + pix = defaultFile; + } + + cache[ key ] = pix; + return &pix; + } else { + HICON si; + UINT res; +#ifdef Q_OS_TEMP + res = (UINT)ExtractIconEx( (LPCTSTR)qt_winTchar(fi.absFilePath(), TRUE), + -1, + 0, 0, 1 ); +#else + res = ExtractIconExA( fi.absFilePath().latin1(), + -1, + 0, 0, 1 ); +#endif + + if ( res == 0 ) { + return &defaultExe; + } else { +#ifdef Q_OS_TEMP + res = (UINT)ExtractIconEx( (LPCTSTR)qt_winTchar(fi.absFilePath(), TRUE), + res - 1, + 0, &si, 1 ); +#else + res = ExtractIconExA( fi.absFilePath().latin1(), + res - 1, + 0, &si, 1 ); +#endif + } + + if ( res ) { + pix.resize( pixw, pixh ); + initPixmap( pix ); + QPainter p( &pix ); + DrawIconEx( p.handle(), 0, 0, si, pixw, pixh, 0, NULL, DI_NORMAL ); + p.end(); + pix.setMask( pix.createHeuristicMask() ); + DestroyIcon( si ); + } else { + pix = defaultExe; + } + + return &pix; + } + + // can't happen! + return 0; +} +#endif + + + +/*! + \reimp +*/ +bool QFileDialogP::eventFilter( QObject * o, QEvent * e ) +{ + if ( e->type() == QEvent::KeyPress && ( (QKeyEvent*)e )->key() == Key_F5 ) { + rereadDir(); + ((QKeyEvent *)e)->accept(); + return TRUE; + } else if ( e->type() == QEvent::KeyPress && ( (QKeyEvent*)e )->key() == Key_F2 && + ( o == files || o == files->viewport() ) ) { + if ( files->isVisible() && files->currentItem() ) { + if ( mode() != QFileDialogP::ExistingFiles && + QUrlInfo( d->url, "." ).isWritable() && files->currentItem()->text( 0 ) != ".." ) { + files->renameItem = files->currentItem(); + files->startRename( TRUE ); + } + } + ((QKeyEvent *)e)->accept(); + return TRUE; + } else if ( e->type() == QEvent::KeyPress && ( (QKeyEvent*)e )->key() == Key_F2 && + ( o == d->moreFiles || o == d->moreFiles->viewport() ) ) { + if ( d->moreFiles->isVisible() && d->moreFiles->currentItem() != -1 ) { + if ( mode() != QFileDialogP::ExistingFiles && + QUrlInfo( d->url, "." ).isWritable() && + d->moreFiles->item( d->moreFiles->currentItem() )->text() != ".." ) { + d->moreFiles->renameItem = d->moreFiles->item( d->moreFiles->currentItem() ); + d->moreFiles->startRename( TRUE ); + } + } + ((QKeyEvent *)e)->accept(); + return TRUE; + } else if ( e->type() == QEvent::KeyPress && d->moreFiles->renaming ) { + d->moreFiles->lined->setFocus(); + QApplication::sendEvent( d->moreFiles->lined, e ); + ((QKeyEvent *)e)->accept(); + return TRUE; + } else if ( e->type() == QEvent::KeyPress && files->renaming ) { + files->lined->setFocus(); + QApplication::sendEvent( files->lined, e ); + ((QKeyEvent *)e)->accept(); + return TRUE; + } else if ( e->type() == QEvent::KeyPress && + ((QKeyEvent *)e)->key() == Key_Backspace && + ( o == files || + o == d->moreFiles || + o == files->viewport() || + o == d->moreFiles->viewport() ) ) { + cdUpClicked(); + ((QKeyEvent *)e)->accept(); + return TRUE; + } else if ( e->type() == QEvent::KeyPress && + ((QKeyEvent *)e)->key() == Key_Delete && + ( o == files || + o == files->viewport() ) ) { + if ( files->currentItem() ) + deleteFile( files->currentItem()->text( 0 ) ); + ((QKeyEvent *)e)->accept(); + return TRUE; + } else if ( e->type() == QEvent::KeyPress && + ((QKeyEvent *)e)->key() == Key_Delete && + ( o == d->moreFiles || + o == d->moreFiles->viewport() ) ) { + int c = d->moreFiles->currentItem(); + if ( c >= 0 ) + deleteFile( d->moreFiles->item( c )->text() ); + ((QKeyEvent *)e)->accept(); + return TRUE; + } else if ( o == files && e->type() == QEvent::FocusOut && + files->currentItem() && mode() != ExistingFiles ) { + } else if ( o == files && e->type() == QEvent::KeyPress ) { + QTimer::singleShot( 0, this, SLOT(fixupNameEdit()) ); + } else if ( o == nameEdit && e->type() == QEvent::KeyPress ) { + if ( ( nameEdit->cursorPosition() == (int)nameEdit->text().length() || nameEdit->hasSelectedText() ) && + isprint(((QKeyEvent *)e)->ascii()) ) { +#if defined(_WS_WIN_) + QString nt( nameEdit->text().lower() ); +#else + QString nt( nameEdit->text() ); +#endif + nt.truncate( nameEdit->cursorPosition() ); + nt += (char)(((QKeyEvent *)e)->ascii()); + QListViewItem * i = files->firstChild(); +#if defined(_WS_WIN_) + while( i && i->text( 0 ).left(nt.length()).lower() != nt ) +#else + while( i && i->text( 0 ).left(nt.length()) != nt ) +#endif + i = i->nextSibling(); + if ( i ) { + nt = i->text( 0 ); + int cp = nameEdit->cursorPosition()+1; + nameEdit->validateAndSet( nt, cp, cp, nt.length() ); + return TRUE; + } + } + } else if ( o == nameEdit && e->type() == QEvent::FocusIn ) { + fileNameEditDone(); + } else if ( d->moreFiles->renaming && o != d->moreFiles->lined && e->type() == QEvent::FocusIn ) { + d->moreFiles->lined->setFocus(); + return TRUE; + } else if ( files->renaming && o != files->lined && e->type() == QEvent::FocusIn ) { + files->lined->setFocus(); + return TRUE; + } else if ( ( o == d->moreFiles || o == d->moreFiles->viewport() ) && + e->type() == QEvent::FocusIn ) { + if ( o == d->moreFiles->viewport() && !d->moreFiles->viewport()->hasFocus() || + o == d->moreFiles && !d->moreFiles->hasFocus() ) + ((QWidget*)o)->setFocus(); + return FALSE; + } + + return QDialog::eventFilter( o, e ); +} + +/*! + Sets the filters used in the file dialog to \a filters. Each group + of filters must be separated by \c{;;} (\e two semi-colons). + + \code + QString types("*.png;;*.xpm;;*.jpg"); + QFileDialogP fd = new QFileDialogP( this ); + fd->setFilters( types ); + fd->show(); + \endcode + +*/ + +void QFileDialogP::setFilters( const QString &filters ) +{ + QStringList lst = makeFiltersList( filters ); + setFilters( lst ); +} + +/*! + \overload + + \a types must be a null-terminated list of strings. + +*/ + +void QFileDialogP::setFilters( const char ** types ) +{ + if ( !types || !*types ) + return; + + d->types->clear(); + while( types && *types ) { + d->types->insertItem( QString::fromLatin1(*types) ); + types++; + } + d->types->setCurrentItem( 0 ); + setFilter( d->types->text( 0 ) ); +} + + +/*! \overload void QFileDialogP::setFilters( const QStringList & ) +*/ + +void QFileDialogP::setFilters( const QStringList & types ) +{ + if ( types.count() < 1 ) + return; + + d->types->clear(); + for ( QStringList::ConstIterator it = types.begin(); it != types.end(); ++it ) + d->types->insertItem( *it ); + d->types->setCurrentItem( 0 ); + setFilter( d->types->text( 0 ) ); +} + +/*! + Adds the filter \a filter to the list of filters and makes it the + current filter. + + \code + QFileDialogP* fd = new QFileDialogP( this ); + fd->addFilter( "Images (*.png *.jpg *.xpm)" ); + fd->show(); + \endcode + + In the above example, a file dialog is created, and the file filter "Images + (*.png *.jpg *.xpm)" is added and is set as the current filter. The original + filter, "All Files (*)", is still available. + + \sa setFilter(), setFilters() +*/ + +void QFileDialogP::addFilter( const QString &filter ) +{ + if ( filter.isEmpty() ) + return; + QString f = filter; + QRegExp r( QString::fromLatin1(qt_file_dialog_filter_reg_exp) ); + int index = r.search( f ); + if ( index >= 0 ) + f = r.cap( 2 ); + for ( int i = 0; i < d->types->count(); ++i ) { + QString f2( d->types->text( i ) ); + int index = r.search( f2 ); + if ( index >= 0 ) + f2 = r.cap( 1 ); + if ( f2 == f ) { + d->types->setCurrentItem( i ); + setFilter( f2 ); + return; + } + } + + d->types->insertItem( filter ); + d->types->setCurrentItem( d->types->count() - 1 ); + setFilter( d->types->text( d->types->count() - 1 ) ); +} + +/*! + Since modeButtons is a top-level widget, it may be destroyed by the + kernel at application exit. Notice if this happens to + avoid double deletion. +*/ + +void QFileDialogP::modeButtonsDestroyed() +{ + if ( d ) + d->modeButtons = 0; +} + + +/*! + This is a convenience static function that will return one or more + existing files selected by the user. + + \code + QStringList files = QFileDialogP::getOpenFileNames( + "Images (*.png *.xpm *.jpg)", + "/home", + this, + "open files dialog" + "Select one or more files to open" ); + \endcode + + This function creates a modal file dialog called \a name, with + parent \a parent. If \a parent is not 0, the dialog will be shown + centered over the parent. + + The file dialog's working directory will be set to \a dir. If \a + dir includes a file name, the file will be selected. The filter + is set to \a filter so that only those files which match the filter + are shown. The filter selected is set to \a selectedFilter. The parameters + \a dir, \a selectedFilter and \a filter may be QString::null. + + The dialog's caption is set to \a caption. If \a caption is not + specified then a default caption will be used. + + Under Windows and Mac OS X, this static function will use the native + file dialog and not a QFileDialogP, unless the style of the application + is set to something other than the native style. + + Under Unix/X11, the normal behavior of the file dialog is to resolve + and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp, + the file dialog will change to /var/tmp after entering /usr/tmp. + If \a resolveSymlinks is FALSE, the file dialog will treat + symlinks as regular directories. + + Note that if you want to iterate over the list of files, you should + iterate over a copy, e.g. + \code + QStringList list = files; + QStringList::Iterator it = list.begin(); + while( it != list.end() ) { + myProcessing( *it ); + ++it; + } + \endcode + + \sa getOpenFileName(), getSaveFileName(), getExistingDirectory() +*/ + +QStringList QFileDialogP::getOpenFileNames( const QString & filter, + const QString& dir, + QWidget *parent, + const char* name, + const QString& caption, + QString *selectedFilter, + bool resolveSymlinks ) +{ + bool save_qt_resolve_symlinks = qt_resolve_symlinks; + qt_resolve_symlinks = resolveSymlinks; + + QStringList filters; + if ( !filter.isEmpty() ) + filters = makeFiltersList( filter ); + + makeVariables(); + + if ( workingDirectory->isNull() ) + *workingDirectory = QDir::currentDirPath(); + + if ( !dir.isEmpty() ) { + // #### works only correct for local files + QUrlOperator u( dir ); + if ( u.isLocalFile() && QFileInfo( u ).isDir() ) { + *workingDirectory = dir; + } else { + *workingDirectory = u.toString(); + } + } + +#if defined(Q_WS_WIN) + if ( qApp->style().styleHint( QStyle::SH_GUIStyle ) == WindowsStyle ) + return winGetOpenFileNames( filter, workingDirectory, parent, name, caption, selectedFilter ); +#elif defined(Q_WS_MAC) + if( ( qApp->style().inherits(QMAC_DEFAULT_STYLE) ) ) + return macGetOpenFileNames(filter, workingDirectory, parent, name, caption ); +#endif + + QFileDialogP *dlg = new QFileDialogP( *workingDirectory, QString::null, parent, name ? name : "qt_filedlg_gofns", TRUE ); + + Q_CHECK_PTR( dlg ); +#ifndef QT_NO_WIDGET_TOPEXTRA + if ( parent && parent->icon() && !parent->icon()->isNull() ) + dlg->setIcon( *parent->icon() ); + else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() ) + dlg->setIcon( *qApp->mainWidget()->icon() ); +#endif + + dlg->setFilters( filters ); + if ( selectedFilter ) + dlg->setFilter( *selectedFilter ); +#ifndef QT_NO_WIDGET_TOPEXTRA + if ( !caption.isNull() ) + dlg->setCaption( caption ); + else + dlg->setCaption( QFileDialogP::tr("Open") ); +#endif + dlg->setMode( QFileDialogP::ExistingFiles ); + QString result; + QStringList lst; + if ( dlg->exec() == QDialog::Accepted ) { + lst = dlg->selectedFiles(); + *workingDirectory = dlg->d->url; + if ( selectedFilter ) + *selectedFilter = dlg->selectedFilter(); + } + delete dlg; + + qt_resolve_symlinks = save_qt_resolve_symlinks; + + return lst; +} + +/*! Updates the line edit to match the speed-key usage in QListView. */ + +void QFileDialogP::fixupNameEdit() +{ + if ( files->currentItem() && d->mode != ExistingFiles ) { + if ( ( (QFileDialogPrivate::File*)files->currentItem() )->info.isFile() ) + nameEdit->setText( files->currentItem()->text( 0 ) ); + } +} + +/*! + Returns the URL of the current working directory in the file dialog. + + \sa setUrl() +*/ + +QUrl QFileDialogP::url() const +{ + return d->url; +} + +static bool isRoot( const QUrl &u ) +{ +#if defined(Q_OS_MAC9) + QString p = QDir::convertSeparators(u.path()); + if(p.contains(':') == 1) + return TRUE; +#elif defined(Q_OS_UNIX) + if ( u.path() == "/" ) + return TRUE; +#elif defined(Q_OS_WIN32) + QString p = u.path(); + if ( p.length() == 3 && + p.right( 2 ) == ":/" ) + return TRUE; + if ( p[ 0 ] == '/' && p[ 1 ] == '/' ) { + int slashes = p.contains( '/' ); + if ( slashes <= 3 ) + return TRUE; + if ( slashes == 4 && p[ (int)p.length() - 1 ] == '/' ) + return TRUE; + } +#else +#if defined(Q_CC_GNU) +#warning "case not covered.." +#endif +#endif + + if ( !u.isLocalFile() && u.path() == "/" ) + return TRUE; + + return FALSE; +} + +void QFileDialogP::urlStart( QNetworkOperation *op ) +{ + if ( !op ) + return; + + if ( op->operation() == QNetworkProtocol::OpListChildren ) { + if ( isRoot( d->url ) ) + d->cdToParent->setEnabled( FALSE ); + else + d->cdToParent->setEnabled( TRUE ); + d->mimeTypeTimer->stop(); + d->sortedList.clear(); + d->pendingItems.clear(); + d->moreFiles->clearSelection(); + files->clearSelection(); + d->moreFiles->clear(); + files->clear(); + files->setSorting( -1 ); + + QString s = d->url.toString( FALSE, FALSE ); + bool found = FALSE; + for ( int i = 0; i < d->paths->count(); ++i ) { +#if defined(Q_WS_WIN) + if ( d->paths->text( i ).lower() == s.lower() ) { +#else + if ( d->paths->text( i ) == s ) { +#endif + found = TRUE; + d->paths->setCurrentItem( i ); + break; + } + } + if ( !found ) { + d->paths->insertItem( *openFolderIcon, s, -1 ); + d->paths->setCurrentItem( d->paths->count() - 1 ); + } + d->last = 0; + d->hadDotDot = FALSE; + + if ( d->goBack && d->history.last() != d->url.toString() ) { + d->history.append( d->url.toString() ); + if ( d->history.count() > 1 ) + d->goBack->setEnabled( TRUE ); + } + } +} + +void QFileDialogP::urlFinished( QNetworkOperation *op ) +{ + if ( !op ) + return; + + if ( op->operation() == QNetworkProtocol::OpListChildren ) { + if ( QApplication::overrideCursor() ) + QApplication::restoreOverrideCursor(); + } + if ( op->state() == QNetworkProtocol::StFailed ) { + if ( d->paths->hasFocus() ) + d->ignoreNextKeyPress = TRUE; + + if ( d->progressDia ) { + d->ignoreStop = TRUE; + d->progressDia->close(); + delete d->progressDia; + d->progressDia = 0; + } + + QMessageBox::critical( this, tr( "Error" ), op->protocolDetail() ); + + int ecode = op->errorCode(); + if ( ecode == QNetworkProtocol::ErrListChildren || ecode == QNetworkProtocol::ErrParse || + ecode == QNetworkProtocol::ErrUnknownProtocol || ecode == QNetworkProtocol::ErrLoginIncorrect || + ecode == QNetworkProtocol::ErrValid || ecode == QNetworkProtocol::ErrHostNotFound || + ecode == QNetworkProtocol::ErrFileNotExisting ) { + if (d->url != d->oldUrl) { + QString nf = d->url.nameFilter(); + d->url = d->oldUrl; + d->url.setNameFilter( nf ); + rereadDir(); + } + } else { + // another error happened, no need to go back to last dir + } + } else if ( op->operation() == QNetworkProtocol::OpListChildren && + op == d->currListChildren ) { + if ( !d->hadDotDot && !isRoot( d->url ) ) { + bool ok = TRUE; +#if defined(Q_WS_WIN) + if ( d->url.path().left( 2 ) == "//" ) + ok = FALSE; +#endif + if ( ok ) { + QUrlInfo ui( d->url, ".." ); + ui.setName( ".." ); + ui.setDir( TRUE ); + ui.setFile( FALSE ); + ui.setSymLink( FALSE ); + ui.setSize( 0 ); + QValueList lst; + lst << ui; + insertEntry( lst, 0 ); + } + } + resortDir(); + } else if ( op->operation() == QNetworkProtocol::OpGet ) { + } else if ( op->operation() == QNetworkProtocol::OpPut ) { + rereadDir(); + if ( d->progressDia ) { + d->ignoreStop = TRUE; + d->progressDia->close(); + } + delete d->progressDia; + d->progressDia = 0; + } +} + +void QFileDialogP::dataTransferProgress( int bytesDone, int bytesTotal, QNetworkOperation *op ) +{ + if ( !op ) + return; + + QString label; + QUrl u( op->arg( 0 ) ); + if ( u.isLocalFile() ) { + label = u.path(); + } else { + label = QString( "%1 (on %2)" ); + label = label.arg( u.path() ).arg( u.host() ); + } + + if ( !d->progressDia ) { + if ( bytesDone < bytesTotal) { + d->ignoreStop = FALSE; + d->progressDia = new QFDProgressDialog( this, label, bytesTotal ); + connect( d->progressDia, SIGNAL( cancelled() ), + this, SLOT( stopCopy() ) ); + d->progressDia->show(); + } else + return; + } + + if ( d->progressDia ) { + if ( op->operation() == QNetworkProtocol::OpGet ) { + if ( d->progressDia ) { + d->progressDia->setReadProgress( bytesDone ); + } + } else if ( op->operation() == QNetworkProtocol::OpPut ) { + if ( d->progressDia ) { + d->progressDia->setWriteLabel( label ); + d->progressDia->setWriteProgress( bytesDone ); + } + } else { + return; + } + } +} + +void QFileDialogP::insertEntry( const QValueList &lst, QNetworkOperation *op ) +{ + if ( op && op->operation() == QNetworkProtocol::OpListChildren && + op != d->currListChildren ) + return; + QValueList::ConstIterator it = lst.begin(); + for ( ; it != lst.end(); ++it ) { + const QUrlInfo &inf = *it; + if ( d->mode == DirectoryOnly && !inf.isDir() ) + continue; + if ( inf.name() == ".." ) { + d->hadDotDot = TRUE; + if ( isRoot( d->url ) ) + continue; +#if defined(Q_WS_WIN) + if ( d->url.path().left( 2 ) == "//" ) + continue; +#endif + } else if ( inf.name() == "." ) + continue; + +#if defined(Q_WS_WIN) + if ( !bShowHiddenFiles ) { + if ( d->url.isLocalFile() ) { + QString file = d->url.path() + inf.name(); +#if defined(UNICODE) + if ( qWinVersion() & Qt::WV_NT_based ) { + if ( GetFileAttributesW( (TCHAR*)qt_winTchar( file, TRUE ) ) & FILE_ATTRIBUTE_HIDDEN ) + continue; + } + else +#endif + { + if ( GetFileAttributesA( file.local8Bit() ) & FILE_ATTRIBUTE_HIDDEN ) + continue; + } + } else { + if ( inf.name() != ".." && inf.name()[0] == QChar('.') ) + continue; + } + } +#else + if ( !bShowHiddenFiles && inf.name() != ".." ) { + if ( inf.name()[ 0 ] == QChar( '.' ) ) + continue; + } + +#endif + if ( !d->url.isLocalFile() ) { + QFileDialogPrivate::File * i = 0; + QFileDialogPrivate::MCItem *i2 = 0; + i = new QFileDialogPrivate::File( d, &inf, files ); + i2 = new QFileDialogPrivate::MCItem( d->moreFiles, i ); + + if ( d->mode == ExistingFiles && inf.isDir() || + ( isDirectoryMode( d->mode ) && inf.isFile() ) ) { + i->setSelectable( FALSE ); + i2->setSelectable( FALSE ); + } + + i->i = i2; + } + + d->sortedList.append( new QUrlInfo( inf ) ); + } +} + +void QFileDialogP::removeEntry( QNetworkOperation *op ) +{ + if ( !op ) + return; + + QUrlInfo *i = 0; + QListViewItemIterator it( files ); + bool ok1 = FALSE, ok2 = FALSE; + for ( i = d->sortedList.first(); it.current(); ++it, i = d->sortedList.next() ) { + if ( ( (QFileDialogPrivate::File*)it.current() )->info.name() == op->arg( 0 ) ) { + d->pendingItems.removeRef( (QFileDialogPrivate::File*)it.current() ); + delete ( (QFileDialogPrivate::File*)it.current() )->i; + delete it.current(); + ok1 = TRUE; + } + if ( i && i->name() == op->arg( 0 ) ) { + d->sortedList.removeRef( i ); + i = d->sortedList.prev(); + ok2 = TRUE; + } + if ( ok1 && ok2 ) + break; + } +} + +void QFileDialogP::itemChanged( QNetworkOperation *op ) +{ + if ( !op ) + return; + + QUrlInfo *i = 0; + QListViewItemIterator it1( files ); + bool ok1 = FALSE, ok2 = FALSE; + // first check whether the new file replaces an existing file. + for ( i = d->sortedList.first(); it1.current(); ++it1, i = d->sortedList.next() ) { + if ( ( (QFileDialogPrivate::File*)it1.current() )->info.name() == op->arg( 1 ) ) { + delete ( (QFileDialogPrivate::File*)it1.current() )->i; + delete it1.current(); + ok1 = TRUE; + } + if ( i && i->name() == op->arg( 1 ) ) { + d->sortedList.removeRef( i ); + i = d->sortedList.prev(); + ok2 = TRUE; + } + if ( ok1 && ok2 ) + break; + } + + i = 0; + QListViewItemIterator it( files ); + ok1 = FALSE; + ok2 = FALSE; + for ( i = d->sortedList.first(); it.current(); ++it, i = d->sortedList.next() ) { + if ( ( (QFileDialogPrivate::File*)it.current() )->info.name() == op->arg( 0 ) ) { + ( (QFileDialogPrivate::File*)it.current() )->info.setName( op->arg( 1 ) ); + ok1 = TRUE; + } + if ( i && i->name() == op->arg( 0 ) ) { + i->setName( op->arg( 1 ) ); + ok2 = TRUE; + } + if ( ok1 && ok2 ) + break; + } + + resortDir(); +} + +/*! + \property QFileDialogP::infoPreview + + \brief whether the file dialog can provide preview information about + the currently selected file + + The default is FALSE. +*/ +bool QFileDialogP::isInfoPreviewEnabled() const +{ + return d->infoPreview; +} + +void QFileDialogP::setInfoPreviewEnabled( bool info ) +{ + if ( info == d->infoPreview ) + return; + d->geometryDirty = TRUE; + d->infoPreview = info; + updateGeometries(); +} + + +/*! + \property QFileDialogP::contentsPreview + + \brief whether the file dialog can provide a contents preview of the + currently selected file + + The default is FALSE. + + \sa setContentsPreview() setInfoPreviewEnabled() +*/ +// ### improve the above documentation: how is the preview done, how can I add +// support for customized preview, etc. + +bool QFileDialogP::isContentsPreviewEnabled() const +{ + return d->contentsPreview; +} + +void QFileDialogP::setContentsPreviewEnabled( bool contents ) +{ + if ( contents == d->contentsPreview ) + return; + d->geometryDirty = TRUE; + d->contentsPreview = contents; + updateGeometries(); +} + + +/*! + Sets the widget to be used for displaying information about the file + to the widget \a w and a preview of that information to the + QFilePreviewP \a preview. + + Normally you would create a preview widget that derives from both QWidget and + QFilePreviewP, so you should pass the same widget twice. + + \code + class Preview : public QLabel, public QFilePreviewP + { + public: + Preview( QWidget *parent=0 ) : QLabel( parent ) {} + + void previewUrl( const QUrl &u ) + { + QString path = u.path(); + QPixmap pix( path ); + if ( pix.isNull() ) + setText( "This is not a pixmap" ); + else + setText( "This is a pixmap" ); + } + }; + + //... + + int main( int argc, char** argv ) + { + Preview* p = new Preview; + + QFileDialogP* fd = new QFileDialogP( this ); + fd->setInfoPreviewEnabled( TRUE ); + fd->setInfoPreview( p, p ); + fd->setPreviewMode( QFileDialogP::Info ); + fd->show(); + } + + \endcode + + \sa setContentsPreview(), setInfoPreviewEnabled(), setPreviewMode() + +*/ + +void QFileDialogP::setInfoPreview( QWidget *w, QFilePreviewP *preview ) +{ + if ( !w || !preview ) + return; + + if ( d->infoPreviewWidget ) { + d->preview->removeWidget( d->infoPreviewWidget ); + delete d->infoPreviewWidget; + } + if ( d->infoPreviewer ) + delete d->infoPreviewer; + d->infoPreviewWidget = w; + d->infoPreviewer = preview; + w->reparent( d->preview, 0, QPoint( 0, 0 ) ); +} + +/*! + Sets the widget to be used for displaying the contents of the file + to the widget \a w and a preview of those contents to the + QFilePreviewP \a preview. + + Normally you would create a preview widget that derives from both QWidget and + QFilePreviewP, so you should pass the same widget twice. + + \code + class Preview : public QLabel, public QFilePreviewP + { + public: + Preview( QWidget *parent=0 ) : QLabel( parent ) {} + + void previewUrl( const QUrl &u ) + { + QString path = u.path(); + QPixmap pix( path ); + if ( pix.isNull() ) + setText( "This is not a pixmap" ); + else + setPixmap( pix ); + } + }; + + //... + + int main( int argc, char** argv ) + { + Preview* p = new Preview; + + QFileDialogP* fd = new QFileDialogP( this ); + fd->setContentsPreviewEnabled( TRUE ); + fd->setContentsPreview( p, p ); + fd->setPreviewMode( QFileDialogP::Contents ); + fd->show(); + } + \endcode + + \sa setContentsPreviewEnabled(), setInfoPreview(), setPreviewMode() +*/ + +void QFileDialogP::setContentsPreview( QWidget *w, QFilePreviewP *preview ) +{ + if ( !w || !preview ) + return; + + if ( d->contentsPreviewWidget ) { + d->preview->removeWidget( d->contentsPreviewWidget ); + delete d->contentsPreviewWidget; + } + if ( d->contentsPreviewer ) + delete d->contentsPreviewer; + d->contentsPreviewWidget = w; + d->contentsPreviewer = preview; + w->reparent( d->preview, 0, QPoint( 0, 0 ) ); +} + +/*! + Re-sorts the displayed directory. + + \sa rereadDir() +*/ + +void QFileDialogP::resortDir() +{ + d->mimeTypeTimer->stop(); + d->pendingItems.clear(); + + QFileDialogPrivate::File *item = 0; + QFileDialogPrivate::MCItem *item2 = 0; + + d->sortedList.sort(); + + if ( files->childCount() > 0 || d->moreFiles->count() > 0 ) { + d->moreFiles->clear(); + files->clear(); + d->last = 0; + files->setSorting( -1 ); + } + + QUrlInfo *i = sortAscending ? d->sortedList.first() : d->sortedList.last(); + for ( ; i; i = sortAscending ? d->sortedList.next() : d->sortedList.prev() ) { + item = new QFileDialogPrivate::File( d, i, files ); + item2 = new QFileDialogPrivate::MCItem( d->moreFiles, item, item2 ); + item->i = item2; + d->pendingItems.append( item ); + if ( d->mode == ExistingFiles && item->info.isDir() || + ( isDirectoryMode( d->mode ) && item->info.isFile() ) ) { + item->setSelectable( FALSE ); + item2->setSelectable( FALSE ); + } + } + + // ##### As the QFileIconProviderP only support QFileInfo and no + // QUrlInfo it can be only used for local files at the moment. In + // 3.0 we have to change the API of QFileIconProviderP to work on + // QUrlInfo so that also remote filesystems can be show mime-type + // specific icons. + if ( d->url.isLocalFile() ) + d->mimeTypeTimer->start( 0 ); +} + +/*! + Stops the current copy operation. +*/ + +void QFileDialogP::stopCopy() +{ + if ( d->ignoreStop ) + return; + + d->url.blockSignals( TRUE ); + d->url.stop(); + if ( d->progressDia ) { + d->ignoreStop = TRUE; + QTimer::singleShot( 100, this, SLOT( removeProgressDia() ) ); + } + d->url.blockSignals( FALSE ); +} + +/*! + \internal +*/ + +void QFileDialogP::removeProgressDia() +{ + if ( d->progressDia ) + delete d->progressDia; + d->progressDia = 0; +} + +/*! + \internal +*/ + +void QFileDialogP::doMimeTypeLookup() +{ + if ( !iconProvider() ) { + d->pendingItems.clear(); + d->mimeTypeTimer->stop(); + return; + } + + d->mimeTypeTimer->stop(); + if ( d->pendingItems.count() == 0 ) { + return; + } + + QRect r; + QFileDialogPrivate::File *item = d->pendingItems.first(); + if ( item ) { + QFileInfo fi; + if ( d->url.isLocalFile() ) { + fi.setFile( QUrl( d->url.path(), QFileDialogPrivate::encodeFileName( item->info.name() ) ).path( FALSE ) ); + } else + fi.setFile( item->info.name() ); // ##### + const QPixmap *p = iconProvider()->pixmap( fi ); + if ( p && p != item->pixmap( 0 ) && + ( !item->pixmap( 0 ) || p->serialNumber() != item->pixmap( 0 )->serialNumber() ) && + p != fifteenTransparentPixels ) { + item->hasMimePixmap = TRUE; + + // evil hack to avoid much too much repaints! + qApp->processEvents(); + files->setUpdatesEnabled( FALSE ); + files->viewport()->setUpdatesEnabled( FALSE ); + if ( item != d->pendingItems.first() ) + return; + item->setPixmap( 0, *p ); + qApp->processEvents(); + files->setUpdatesEnabled( TRUE ); + files->viewport()->setUpdatesEnabled( TRUE ); + + if ( files->isVisible() ) { + QRect ir( files->itemRect( item ) ); + if ( ir != QRect( 0, 0, -1, -1 ) ) { + r = r.unite( ir ); + } + } else { + QRect ir( d->moreFiles->itemRect( item->i ) ); + if ( ir != QRect( 0, 0, -1, -1 ) ) { + r = r.unite( ir ); + } + } + } + if ( d->pendingItems.count() ) + d->pendingItems.removeFirst(); + } + + if ( d->moreFiles->isVisible() ) { + d->moreFiles->viewport()->repaint( r, FALSE ); + } else { + files->viewport()->repaint( r, FALSE ); + } + + if ( d->pendingItems.count() ) + d->mimeTypeTimer->start( 0 ); + else if ( d->moreFiles->isVisible() ) + d->moreFiles->triggerUpdate( TRUE ); +} + +/*! + If \a b is TRUE then all the files in the current directory are selected; + otherwise, they are deselected. +*/ + +void QFileDialogP::selectAll( bool b ) +{ + if ( d->mode != ExistingFiles ) + return; + d->moreFiles->selectAll( b ); + files->selectAll( b ); +} + +void QFileDialogP::goBack() +{ + if ( !d->goBack || !d->goBack->isEnabled() ) + return; + d->history.remove( d->history.last() ); + if ( d->history.count() < 2 ) + d->goBack->setEnabled( FALSE ); + setUrl( d->history.last() ); +} + +// a class with wonderfully inflexible flexibility. why doesn't it +// just subclass QWidget in the first place? 'you have to derive your +// preview widget from QWidget and from this class' indeed. + +/*! + \class QFilePreviewP qfiledialog.h + \ingroup misc + \brief The QFilePreviewP class provides file previewing in QFileDialogP. + + This class is an abstract base class which is used to implement + widgets that can display a preview of a file in a QFileDialogP. + + You must derive the preview widget from both QWidget and from this + class. Then you must reimplement this class's previewUrl() function, + which is called by the file dialog if the preview of a file + (specified as a URL) should be shown. + + See also QFileDialog::setPreviewMode(), QFileDialogP::setContentsPreview(), + QFileDialogP::setInfoPreview(), QFileDialogP::setInfoPreviewEnabled(), + QFileDialogP::setContentsPreviewEnabled(). + + For an example of a preview widget see qt/examples/qdir/qdir.cpp. +*/ + +/*! + Constructs the QFilePreviewP. +*/ + +QFilePreviewP::QFilePreviewP() +{ +} + +/*! + \fn void QFilePreviewP::previewUrl( const QUrl &url ) + + This function is called by QFileDialogP if a preview + for the \a url should be shown. Reimplement this + function to provide file previewing. +*/ + +#endif diff --git a/src/PatchQt/qfiledialogP.h b/src/PatchQt/qfiledialogP.h new file mode 100644 index 000000000..f7355a193 --- /dev/null +++ b/src/PatchQt/qfiledialogP.h @@ -0,0 +1,528 @@ +///////////////////////////////////////////////////////////////////////////// +// Module : PatchQt +// File : qfiledialogP.h +// Description : the patch for Qt's QFileDialog class (qfiledialog.h) +///////////////////////////////////////////////////////////////////////////// + +/**************************************************************************** +** $Id$ +** +** Definition of QFileDialog class +** +** Created : 950428 +** +** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** +** This file is part of the dialogs 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 QFILEDIALOGP_H +#define QFILEDIALOGP_H + +class QPushButton; +class QButton; +class QLabel; +class QWidget; +class QFileDialog; +class QTimer; +class QNetworkOperation; +class QLineEdit; +class QListViewItem; +class QListBoxItem; +class QProgressBar; +class QFileDialogPrivate; +class QFileDialogQFileListView; + +#ifndef QT_H +#include "qdir.h" +#include "qdialog.h" +#include "qurloperator.h" +#include "qurlinfo.h" +#include "qlistbox.h" +#include "qlistview.h" +#include "qlineedit.h" +#endif // QT_H + +#ifndef QT_NO_FILEDIALOG + +class Q_EXPORT QFileIconProviderP : public QObject +{ + Q_OBJECT +public: + QFileIconProviderP( QObject * parent = 0, const char* name = 0 ); + virtual const QPixmap * pixmap( const QFileInfo & ); + +private: // Disabled copy constructor and operator= +#if defined(Q_DISABLE_COPY) + QFileIconProviderP( const QFileIconProviderP & ); + QFileIconProviderP& operator=( const QFileIconProviderP & ); +#endif +}; + +class Q_EXPORT QFilePreviewP +{ +public: + QFilePreviewP(); + virtual void previewUrl( const QUrl &url ) = 0; + +}; + +class Q_EXPORT QFileDialogP : public QDialog +{ + Q_OBJECT + Q_ENUMS( Mode ViewMode PreviewMode ) + // ##### Why are this read-only properties ? + Q_PROPERTY( QString selectedFile READ selectedFile ) + Q_PROPERTY( QString selectedFilter READ selectedFilter ) + Q_PROPERTY( QStringList selectedFiles READ selectedFiles ) + // #### Should not we be able to set the path ? + Q_PROPERTY( QString dirPath READ dirPath ) + Q_PROPERTY( bool showHiddenFiles READ showHiddenFiles WRITE setShowHiddenFiles ) + Q_PROPERTY( Mode mode READ mode WRITE setMode ) + Q_PROPERTY( ViewMode viewMode READ viewMode WRITE setViewMode ) + Q_PROPERTY( PreviewMode previewMode READ previewMode WRITE setPreviewMode ) + Q_PROPERTY( bool infoPreview READ isInfoPreviewEnabled WRITE setInfoPreviewEnabled ) + Q_PROPERTY( bool contentsPreview READ isContentsPreviewEnabled WRITE setContentsPreviewEnabled ) + +public: + QFileDialogP( const QString& dirName, const QString& filter = QString::null, + QWidget* parent=0, const char* name=0, bool modal = FALSE ); + QFileDialogP( QWidget* parent=0, const char* name=0, bool modal = FALSE ); + ~QFileDialogP(); + + // recommended static functions + + static QString getOpenFileName( const QString &initially = QString::null, + const QString &filter = QString::null, + QWidget *parent = 0, const char* name = 0, + const QString &caption = QString::null, + QString *selectedFilter = 0, + bool resolveSymlinks = TRUE); + static QString getSaveFileName( const QString &initially = QString::null, + const QString &filter = QString::null, + QWidget *parent = 0, const char* name = 0, + const QString &caption = QString::null, + QString *selectedFilter = 0, + bool resolveSymlinks = TRUE); + static QString getExistingDirectory( const QString &dir = QString::null, + QWidget *parent = 0, + const char* name = 0, + const QString &caption = QString::null, + bool dirOnly = TRUE, + bool resolveSymlinks = TRUE); + static QStringList getOpenFileNames( const QString &filter= QString::null, + const QString &dir = QString::null, + QWidget *parent = 0, + const char* name = 0, + const QString &caption = QString::null, + QString *selectedFilter = 0, + bool resolveSymlinks = TRUE); + + // other static functions + + static void setIconProvider( QFileIconProviderP * ); + static QFileIconProviderP* iconProvider(); + + // non-static function for special needs + + QString selectedFile() const; + QString selectedFilter() const; + virtual void setSelectedFilter( const QString& ); + virtual void setSelectedFilter( int ); + + void setSelection( const QString &); + + void selectAll( bool b ); + + QStringList selectedFiles() const; + + QString dirPath() const; + + void setDir( const QDir & ); + const QDir *dir() const; + + void setShowHiddenFiles( bool s ); + bool showHiddenFiles() const; + + void rereadDir(); + void resortDir(); + + enum Mode { AnyFile, ExistingFile, Directory, ExistingFiles, DirectoryOnly }; + void setMode( Mode ); + Mode mode() const; + + enum ViewMode { Detail, List }; + enum PreviewMode { NoPreview, Contents, Info }; + void setViewMode( ViewMode m ); + ViewMode viewMode() const; + void setPreviewMode( PreviewMode m ); + PreviewMode previewMode() const; + + bool eventFilter( QObject *, QEvent * ); + + bool isInfoPreviewEnabled() const; + bool isContentsPreviewEnabled() const; + void setInfoPreviewEnabled( bool ); + void setContentsPreviewEnabled( bool ); + + void setInfoPreview( QWidget *w, QFilePreviewP *preview ); + void setContentsPreview( QWidget *w, QFilePreviewP *preview ); + + QUrl url() const; + + void addFilter( const QString &filter ); + +public slots: + void done( int ); + void setDir( const QString& ); + void setUrl( const QUrlOperator &url ); + void setFilter( const QString& ); + void setFilters( const QString& ); + void setFilters( const char ** ); + void setFilters( const QStringList& ); + +protected: + void resizeEvent( QResizeEvent * ); + void keyPressEvent( QKeyEvent * ); + + void addWidgets( QLabel *, QWidget *, QPushButton * ); + void addToolButton( QButton *b, bool separator = FALSE ); + void addLeftWidget( QWidget *w ); + void addRightWidget( QWidget *w ); + +signals: + void fileHighlighted( const QString& ); + void fileSelected( const QString& ); + void filesSelected( const QStringList& ); + void dirEntered( const QString& ); + void filterSelected( const QString& ); + +private slots: + void detailViewSelectionChanged(); + void listBoxSelectionChanged(); + void changeMode( int ); + void fileNameEditReturnPressed(); + void stopCopy(); + void removeProgressDia(); + + void fileSelected( int ); + void fileHighlighted( int ); + void dirSelected( int ); + void pathSelected( int ); + + void updateFileNameEdit( QListViewItem *); + void selectDirectoryOrFile( QListViewItem * ); + void popupContextMenu( QListViewItem *, const QPoint &, int ); + void popupContextMenu( QListBoxItem *, const QPoint & ); + void updateFileNameEdit( QListBoxItem *); + void selectDirectoryOrFile( QListBoxItem * ); + void fileNameEditDone(); + + void okClicked(); + void filterClicked(); // not used + void cancelClicked(); + + void cdUpClicked(); + void newFolderClicked(); + + void fixupNameEdit(); + + void doMimeTypeLookup(); + + void updateGeometries(); + void modeButtonsDestroyed(); + void urlStart( QNetworkOperation *op ); + void urlFinished( QNetworkOperation *op ); + void dataTransferProgress( int bytesDone, int bytesTotal, QNetworkOperation * ); + void insertEntry( const QValueList &fi, QNetworkOperation *op ); + void removeEntry( QNetworkOperation * ); + void createdDirectory( const QUrlInfo &info, QNetworkOperation * ); + void itemChanged( QNetworkOperation * ); + void goBack(); + +private: + enum PopupAction { + PA_Open = 0, + PA_Delete, + PA_Rename, + PA_SortName, + PA_SortSize, + PA_SortType, + PA_SortDate, + PA_SortUnsorted, + PA_Cancel, + PA_Reload, + PA_Hidden + }; + + void init(); + bool trySetSelection( bool isDir, const QUrlOperator &, bool ); + void deleteFile( const QString &filename ); + void popupContextMenu( const QString &filename, bool withSort, + PopupAction &action, const QPoint &p ); + + QDir reserved; // was cwd + QString fileName; + + friend class QFileDialogQFileListView; + friend class QFileListBox; + + QFileDialogPrivate *d; + QFileDialogQFileListView *files; + + QLineEdit *nameEdit; // also filter + QPushButton *okB; + QPushButton *cancelB; + +#if defined(Q_WS_WIN) + static QString winGetOpenFileName( const QString &initialSelection, + const QString &filter, + QString* workingDirectory, + QWidget *parent = 0, + const char* name = 0, + const QString& caption = QString::null, + QString* selectedFilter = 0 ); + static QString winGetSaveFileName( const QString &initialSelection, + const QString &filter, + QString* workingDirectory, + QWidget *parent = 0, + const char* name = 0, + const QString& caption = QString::null, + QString* selectedFilter = 0 ); + static QStringList winGetOpenFileNames( const QString &filter, + QString* workingDirectory, + QWidget *parent = 0, + const char* name = 0, + const QString& caption = QString::null, + QString* selectedFilter = 0 ); + static QString winGetExistingDirectory( const QString &initialDirectory, + QWidget* parent = 0, + const char* name = 0, + const QString& caption = QString::null); + static QString resolveLinkFile( const QString& linkfile ); +#endif +#if defined(Q_WS_MACX) || defined(Q_WS_MAC9) + static QString macGetSaveFileName( const QString &, const QString &, + QString *, QWidget *, const char*, + const QString& ); + static QStringList macGetOpenFileNames( const QString &, QString*, + QWidget *, const char *, + const QString&, bool = TRUE, + bool = FALSE ); +#endif + + +private: // Disabled copy constructor and operator= +#if defined(Q_DISABLE_COPY) + QFileDialogP( const QFileDialogP & ); + QFileDialogP &operator=( const QFileDialogP & ); +#endif +}; + +/****************************************************************** + * + * Definitions of view classes + * + ******************************************************************/ + +class QRenameEdit : public QLineEdit +{ + Q_OBJECT + +public: + QRenameEdit( QWidget *parent ) + : QLineEdit( parent, "qt_rename_edit" ) + {} + +protected: + void keyPressEvent( QKeyEvent *e ); + void focusOutEvent( QFocusEvent *e ); + +signals: + void escapePressed(); + +}; + +class QFileListBox : public QListBox +{ + friend class QFileDialogP; + + Q_OBJECT + +private: + QFileListBox( QWidget *parent, QFileDialogP *d ); + + void clear(); + void show(); + void startRename( bool check = TRUE ); + void viewportMousePressEvent( QMouseEvent *e ); + void viewportMouseReleaseEvent( QMouseEvent *e ); + void viewportMouseDoubleClickEvent( QMouseEvent *e ); + void viewportMouseMoveEvent( QMouseEvent *e ); +#ifndef QT_NO_DRAGANDDROP + void viewportDragEnterEvent( QDragEnterEvent *e ); + void viewportDragMoveEvent( QDragMoveEvent *e ); + void viewportDragLeaveEvent( QDragLeaveEvent *e ); + void viewportDropEvent( QDropEvent *e ); + bool acceptDrop( const QPoint &pnt, QWidget *source ); + void setCurrentDropItem( const QPoint &pnt ); +#endif + void keyPressEvent( QKeyEvent *e ); + +private slots: + void rename(); + void cancelRename(); + void doubleClickTimeout(); + void changeDirDuringDrag(); + void dragObjDestroyed(); + void contentsMoved( int, int ); + +private: + QRenameEdit *lined; + QFileDialogP *filedialog; + bool renaming; + QTimer* renameTimer; + QListBoxItem *renameItem, *dragItem; + QPoint pressPos, oldDragPos; + bool mousePressed; + int urls; + QString startDragDir; + QListBoxItem *currDropItem; + QTimer *changeDirTimer; + bool firstMousePressEvent; + QUrlOperator startDragUrl; + +}; + + +class QFileDialogQFileListView : public QListView +{ + Q_OBJECT + +public: + QFileDialogQFileListView( QWidget *parent, QFileDialogP *d ); + + void clear(); + void startRename( bool check = TRUE ); + void setSorting( int column, bool increasing = TRUE ); + + QRenameEdit *lined; + bool renaming; + QListViewItem *renameItem; + +private: + void viewportMousePressEvent( QMouseEvent *e ); + void viewportMouseDoubleClickEvent( QMouseEvent *e ); + void keyPressEvent( QKeyEvent *e ); + void viewportMouseReleaseEvent( QMouseEvent *e ); + void viewportMouseMoveEvent( QMouseEvent *e ); +#ifndef QT_NO_DRAGANDDROP + void viewportDragEnterEvent( QDragEnterEvent *e ); + void viewportDragMoveEvent( QDragMoveEvent *e ); + void viewportDragLeaveEvent( QDragLeaveEvent *e ); + void viewportDropEvent( QDropEvent *e ); + bool acceptDrop( const QPoint &pnt, QWidget *source ); + void setCurrentDropItem( const QPoint &pnt ); +#endif + +private slots: + void rename(); + void cancelRename(); + void changeSortColumn2( int column ); + void doubleClickTimeout(); + void changeDirDuringDrag(); + void dragObjDestroyed(); + void contentsMoved( int, int ); + +private: + QFileDialogP *filedialog; + QTimer* renameTimer; + QPoint pressPos, oldDragPos; + bool mousePressed; + int urls; + QString startDragDir; + QListViewItem *currDropItem, *dragItem; + QTimer *changeDirTimer; + bool firstMousePressEvent; + bool ascending; + int sortcolumn; + QUrlOperator startDragUrl; + +}; + +/**************************************************************************** + * + * Classes for copy progress dialog + * + ****************************************************************************/ + +class QFDProgressAnimation : public QWidget +{ + Q_OBJECT + +public: + QFDProgressAnimation( QWidget *parent ); + void start(); + +private slots: + void next(); + +protected: + void paintEvent( QPaintEvent *e ); + +private: + int step; + QTimer *timer; + +}; + +class QFDProgressDialog : public QDialog +{ + Q_OBJECT + +public: + QFDProgressDialog( QWidget *parent, const QString &fn, int steps ); + + void setReadProgress( int p ); + void setWriteProgress( int p ); + void setWriteLabel( const QString &s ); + +signals: + void cancelled(); + +private: + QProgressBar *readBar; + QProgressBar *writeBar; + QLabel *writeLabel; + QFDProgressAnimation *animation; + +}; + +#endif + +#endif // QFILEDIALOG_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_Prs.cxx b/src/Plot2d/Plot2d_Prs.cxx new file mode 100644 index 000000000..2db19dfc4 --- /dev/null +++ b/src/Plot2d/Plot2d_Prs.cxx @@ -0,0 +1,95 @@ +// SALOME OCCViewer : build OCC Viewer into Salome desktop +// +// Copyright (C) 2004 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.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : Plot2d_Prs.cxx +// Author : Sergey ANIKIN +// Module : SALOME +// $Header$ + +#include "Plot2d_Prs.h" + +//========================================================== +/*! + * Plot2d_Prs::Plot2d_Prs + * Default constructor + */ +//========================================================== +Plot2d_Prs::Plot2d_Prs() +{ +} + +//========================================================== +/*! + * Plot2d_Prs::Plot2d_Prs + * Standard constructor + */ +//========================================================== +Plot2d_Prs::Plot2d_Prs( const Plot2d_Curve* obj ) +{ + AddObject( obj ); +} + +//========================================================== +/*! + * Plot2d_Prs::~Plot2d_Prs + * Destructor + */ +//========================================================== +Plot2d_Prs::~Plot2d_Prs() +{ + myObjects.clear(); +} + +//========================================================== +/*! + * Plot2d_Prs::GetObjects + * Get curves list + */ +//========================================================== +Plot2d_CurveContainer Plot2d_Prs::GetObjects() const +{ + return myObjects; +} + +//========================================================== +/*! + * Plot2d_Prs::AddObject + * Add curbe + */ +//========================================================== +void Plot2d_Prs::AddObject( const Plot2d_Curve* obj ) +{ + myObjects.addCurve( (Plot2d_Curve*)obj ); +} + +//========================================================== +/*! + * Plot2d_Prs::IsNull + * Return 0 if list of the curves is empty + * [ Reimplemented from SALOME_Prs ] + */ +//========================================================== +bool Plot2d_Prs::IsNull() const +{ + return myObjects.isEmpty(); +} diff --git a/src/Plot2d/Plot2d_Prs.h b/src/Plot2d/Plot2d_Prs.h new file mode 100644 index 000000000..551f75511 --- /dev/null +++ b/src/Plot2d/Plot2d_Prs.h @@ -0,0 +1,59 @@ +// SALOME OCCViewer : build OCC Viewer into Salome desktop +// +// Copyright (C) 2004 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.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : Plot2d_Prs.h +// Author : Sergey ANIKIN +// Module : SALOME +// $Header$ + +#ifndef PLOT2D_PRS_H +#define PLOT2D_PRS_H + +#include "SALOME_Prs.h" +#include + +class Plot2d_Curve; + +class Plot2d_Prs : public SALOME_Prs2d +{ +public: + Plot2d_Prs(); + // Default constructor + Plot2d_Prs( const Plot2d_Curve* obj ); + // Standard constructor + ~Plot2d_Prs(); + // Destructor + + Plot2d_CurveContainer GetObjects() const; + // Get curves list + void AddObject( const Plot2d_Curve* obj ); + // Add curve + + bool IsNull() const; + // Reimplemented from SALOME_Prs + +private: + Plot2d_CurveContainer myObjects; // list of curves +}; + +#endif 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/Prs/Makefile.in b/src/Prs/Makefile.in new file mode 100755 index 000000000..09f8a248a --- /dev/null +++ b/src/Prs/Makefile.in @@ -0,0 +1,27 @@ +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +EXPORT_HEADERS = SALOME_Prs.h + +# Libraries targets + +LIB = libSalomePrs.la +LIB_SRC = SALOME_Prs.cxx + +LIB_CLIENT_IDL = + +# Executables targets +BIN = +BIN_SRC = + +CPPFLAGS+= +LDFLAGS+= + + +@CONCLUDE@ diff --git a/src/Prs/SALOME_Prs.cxx b/src/Prs/SALOME_Prs.cxx new file mode 100644 index 000000000..1856fa15a --- /dev/null +++ b/src/Prs/SALOME_Prs.cxx @@ -0,0 +1,364 @@ +// File: SALOME_Prs.cxx +// Created: Wed Apr 28 15:03:43 2004 +// Author: Sergey ANIKIN +// + + +#include "SALOME_Prs.h" + +#include "utilities.h" + +using namespace std; + +//=========================================================== +/*! + * Function: SALOME_OCCPrs::DisplayIn + * Purpose: Dispatches display operation to proper Display() + * method of SALOME_View + */ +//=========================================================== +void SALOME_OCCPrs::DisplayIn( SALOME_View* v ) const +{ + if ( v ) v->Display( this ); +} + +//=========================================================== +/*! + * Function: SALOME_OCCPrs::EraseIn + * Purpose: Dispatches display operation to proper Erase() + * method of SALOME_View + */ +//=========================================================== +void SALOME_OCCPrs::EraseIn( SALOME_View* v, const bool forced ) const +{ + if ( v ) v->Erase( this, forced ); +} + +//=========================================================== +/*! + * Function: SALOME_OCCPrs::LocalSelectionIn + * Purpose: Dispatches operation to proper LocalSelectionIn() + * method of SALOME_View + */ +//=========================================================== +void SALOME_OCCPrs::LocalSelectionIn( SALOME_View* v, const int mode ) const +{ + if ( v ) v->LocalSelection( this, mode ); +} + +//=========================================================== +/*! + * Function: SALOME_OCCPrs::Update + * Purpose: Dispatches update operation to proper Update() + * method of SALOME_Displayer + */ +//=========================================================== +void SALOME_OCCPrs::Update( SALOME_Displayer* d ) +{ + if ( d ) d->Update( this ); +} + +//=========================================================== +/*! + * Function: SALOME_VTKPrs::DisplayIn + * Purpose: Dispatches display operation to proper Display() + * method of SALOME_View + */ +//=========================================================== +void SALOME_VTKPrs::DisplayIn( SALOME_View* v ) const +{ + if ( v ) v->Display( this ); +} + +//=========================================================== +/*! + * Function: SALOME_VTKPrs::EraseIn + * Purpose: Dispatches display operation to proper Erase() + * method of SALOME_View + */ +//=========================================================== +void SALOME_VTKPrs::EraseIn( SALOME_View* v, const bool forced ) const +{ + if ( v ) v->Erase( this, forced ); +} + +//=========================================================== +/*! + * Function: SALOME_VTKPrs::LocalSelectionIn + * Purpose: Dispatches operation to proper LocalSelectionIn() + * method of SALOME_View + */ +//=========================================================== +void SALOME_VTKPrs::LocalSelectionIn( SALOME_View* v, const int mode ) const +{ + if ( v ) v->LocalSelection( this, mode ); +} + +//=========================================================== +/*! + * Function: SALOME_VTKPrs::Update + * Purpose: Dispatches update operation to proper Update() + * method of SALOME_Displayer + */ +//=========================================================== +void SALOME_VTKPrs::Update( SALOME_Displayer* d ) +{ + if ( d ) d->Update( this ); +} + +//=========================================================== +/*! + * Function: SALOME_Prs2d::DisplayIn + * Purpose: Dispatches display operation to proper Display() + * method of SALOME_View + */ +//=========================================================== +void SALOME_Prs2d::DisplayIn( SALOME_View* v ) const +{ + if ( v ) v->Display( this ); +} + +//=========================================================== +/*! + * Function: SALOME_Prs2d::EraseIn + * Purpose: Dispatches display operation to proper Erase() + * method of SALOME_View + */ +//=========================================================== +void SALOME_Prs2d::EraseIn( SALOME_View* v, const bool forced ) const +{ + if ( v ) v->Erase( this, forced ); +} + +//=========================================================== +/*! + * Function: SALOME_Prs2d::LocalSelectionIn + * Purpose: Dispatches operation to proper LocalSelectionIn() + * method of SALOME_View + */ +//=========================================================== +void SALOME_Prs2d::LocalSelectionIn( SALOME_View* v, const int mode ) const +{ + if ( v ) v->LocalSelection( this, mode ); +} + +//=========================================================== +/*! + * Function: SALOME_Prs2d::Update + * Purpose: Dispatches update operation to proper Update() + * method of SALOME_Displayer + */ +//=========================================================== +void SALOME_Prs2d::Update( SALOME_Displayer* d ) +{ + if ( d ) d->Update( this ); +} + +//=========================================================== +/*! + * Function: SALOME_View::Display + * Purpose: Gives control to SALOME_Prs object, so that + * it could perform double dispatch + */ +//=========================================================== +void SALOME_View::Display( const SALOME_Prs* prs ) +{ + prs->DisplayIn( this ); +} + +//=========================================================== +/*! + * Function: SALOME_View::Erase + * Purpose: Gives control to SALOME_Prs object, so that + * it could perform double dispatch + */ +//=========================================================== +void SALOME_View::Erase( const SALOME_Prs* prs, const bool forced ) +{ + prs->EraseIn( this, forced ); +} + +//=========================================================== +/*! + * Function: SALOME_View::LocalSelection + * Purpose: Gives control to SALOME_Prs object, so that + * it could perform double dispatch + */ +//=========================================================== +void SALOME_View::LocalSelection( const SALOME_Prs* prs, const int mode ) +{ + prs->LocalSelectionIn( this, mode ); +} + +//=========================================================== +/*! + * Function: SALOME_View::Display + * Purpose: Virtual method, should be reimplemented in successors, + * by default issues a warning and does nothing. + */ +//=========================================================== +void SALOME_View::Display( const SALOME_OCCPrs* ) +{ + MESSAGE( "SALOME_View::Display( const SALOME_OCCPrs& ) called! Probably, presentation is being displayed in uncompatible viewframe." ); +} + +//=========================================================== +/*! + * Function: SALOME_View::Display + * Purpose: Virtual method, should be reimplemented in successors, + * by default issues a warning and does nothing. + */ +//=========================================================== +void SALOME_View::Display( const SALOME_VTKPrs* ) +{ + MESSAGE( "SALOME_View::Display( const SALOME_VTKPrs& ) called! Probably, presentation is being displayed in uncompatible viewframe." ); +} + +//=========================================================== +/*! + * Function: SALOME_View::Display + * Purpose: Virtual method, should be reimplemented in successors, + * by default issues a warning and does nothing. + */ +//=========================================================== +void SALOME_View::Display( const SALOME_Prs2d* ) +{ + MESSAGE( "SALOME_View::Display( const SALOME_Prs2d& ) called! Probably, presentation is being displayed in uncompatible viewframe." ); +} + +//=========================================================== +/*! + * Function: SALOME_View::Erase + * Purpose: Virtual method, should be reimplemented in successors, + * by default issues a warning and does nothing. + */ +//=========================================================== +void SALOME_View::Erase( const SALOME_OCCPrs*, const bool ) +{ + MESSAGE( "SALOME_View::Erase( const SALOME_OCCPrs& ) called! Probably, presentation is being erased in uncompatible viewframe." ); +} + +//=========================================================== +/*! + * Function: SALOME_View::Erase + * Purpose: Virtual method, should be reimplemented in successors, + * by default issues a warning and does nothing. + */ +//=========================================================== +void SALOME_View::Erase( const SALOME_VTKPrs*, const bool ) +{ + MESSAGE( "SALOME_View::Erase( const SALOME_VTKPrs& ) called! Probably, presentation is being erased in uncompatible viewframe." ); +} + +//=========================================================== +/*! + * Function: SALOME_View::Erase + * Purpose: Virtual method, should be reimplemented in successors, + * by default issues a warning and does nothing. + */ +//=========================================================== +void SALOME_View::Erase( const SALOME_Prs2d*, const bool ) +{ + MESSAGE( "SALOME_View::Erase( const SALOME_Prs2d& ) called! Probably, presentation is being erased in uncompatible viewframe." ); +} + +//=========================================================== +/*! + * Function: SALOME_View::LocalSelection + * Purpose: Virtual method, should be reimplemented in successors, + * by default issues a warning and does nothing. + */ +//=========================================================== +void SALOME_View::LocalSelection( const SALOME_OCCPrs*, const int ) +{ + MESSAGE( "SALOME_View::LocalSelection( const SALOME_OCCPrs* ) called! \ + Probably, selection is being activated in uncompatible viewframe." ); +} + +//=========================================================== +/*! + * Function: SALOME_View::LocalSelection + * Purpose: Virtual method, should be reimplemented in successors, + * by default issues a warning and does nothing. + */ +//=========================================================== +void SALOME_View::LocalSelection( const SALOME_VTKPrs*, const int ) +{ + MESSAGE( "SALOME_View::LocalSelection( const SALOME_VTKPrs* ) called! \ + Probably, selection is being activated in uncompatible viewframe." ); +} + +//=========================================================== +/*! + * Function: SALOME_View::LocalSelection + * Purpose: Virtual method, should be reimplemented in successors, + * by default issues a warning and does nothing. + */ +//=========================================================== +void SALOME_View::LocalSelection( const SALOME_Prs2d*, const int ) +{ + MESSAGE( "SALOME_View::LocalSelection( const SALOME_Prs2d* ) called! \ + Probably, selection is being activated in uncompatible viewframe." ); +} + +//=========================================================== +/*! + * Function: SALOME_View::GlobalSelection + * Purpose: Virtual method, should be reimplemented in successors, + * by default issues a warning and does nothing. + */ +//=========================================================== +void SALOME_View::GlobalSelection( const bool ) const +{ + MESSAGE( "SALOME_View::GlobalSelection() called! \ + Probably, selection is being activated in uncompatible viewframe." ); +} + +//=========================================================== +/*! + * Function: SALOME_Displayer::UpdatePrs + * Purpose: Gives control to SALOME_Prs object, so that + * it could perform double dispatch + */ +//=========================================================== +void SALOME_Displayer::UpdatePrs( SALOME_Prs* prs ) +{ + prs->Update( this ); +} + +//=========================================================== +/*! + * Function: SALOME_Displayer::Update + * Purpose: Virtual method, should be reimplemented in successors, + * by default issues a warning and does nothing. + */ +//=========================================================== +void SALOME_Displayer::Update( SALOME_OCCPrs* ) +{ + MESSAGE( "SALOME_Displayer::Update( SALOME_OCCPrs* ) called! Probably, presentation is being updated in uncompatible viewframe." ); +} + +//=========================================================== +/*! + * Function: SALOME_Displayer::Update + * Purpose: Virtual method, should be reimplemented in successors, + * by default issues a warning and does nothing. + */ +//=========================================================== +void SALOME_Displayer::Update( SALOME_VTKPrs* ) +{ + MESSAGE( "SALOME_Displayer::Update( SALOME_VTKPrs* ) called! Probably, presentation is being updated in uncompatible viewframe." ); +} + +//=========================================================== +/*! + * Function: SALOME_Displayer::Update + * Purpose: Virtual method, should be reimplemented in successors, + * by default issues a warning and does nothing. + */ +//=========================================================== +void SALOME_Displayer::Update( SALOME_Prs2d* ) +{ + MESSAGE( "SALOME_Displayer::Update( SALOME_Prs2d* ) called! Probably, presentation is being updated in uncompatible viewframe." ); +} + diff --git a/src/Prs/SALOME_Prs.h b/src/Prs/SALOME_Prs.h new file mode 100644 index 000000000..060bf1838 --- /dev/null +++ b/src/Prs/SALOME_Prs.h @@ -0,0 +1,255 @@ +// SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers +// +// Copyright (C) 2004 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.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : SALOME_Prs.h +// Author : Sergey ANIKIN +// Module : SALOME +// $Header$ + +#ifndef SALOME_PRS_H +#define SALOME_PRS_H + +class SALOME_View; +class SALOME_Displayer; + +//=========================================================== +/*! + * Class: SALOME_Prs + * Description: Base class for SALOME graphic object wrappers - presentations. + * Presentations are temporary objects, so they can be created on the stack. + */ +//=========================================================== + +class SALOME_Prs +{ +public: + virtual ~SALOME_Prs() {} + // Destructor + + virtual void DisplayIn( SALOME_View* ) const = 0; + // Key method for double dispatch of display operation + + virtual void EraseIn( SALOME_View*, const bool = false ) const = 0; + // Key method for double dispatch of erase operation + + virtual void Update( SALOME_Displayer* ) = 0; + // Key method for double dispatch of update operation + + virtual bool IsNull() const = 0; + // Should return true, if this presentation contains a graphic object + + virtual void LocalSelectionIn( SALOME_View*, const int ) const = 0; + // Key method for double dispatch of activation of subshapes selection +}; + +//=========================================================== +/*! + * Class: SALOME_OCCPrs + * Description: Base class for OpenCASCADE graphic object (AIS_InteractiveObject) wrappers. + * This intermediate class is necessary to avoid dependencies from OCC libs. + */ +//=========================================================== + +class SALOME_OCCPrs : public SALOME_Prs +{ +public: + virtual void DisplayIn( SALOME_View* ) const; + // It uses double dispatch in order to + // invoke Display() method corresponding to the actual type of presentation. + + virtual void EraseIn( SALOME_View*, const bool = false ) const; + // It uses double dispatch in order to + // invoke Erase() method corresponding to the actual type of presentation. + + virtual void Update( SALOME_Displayer* ); + // It uses double dispatch in order to + // invoke Update() method corresponding to the actual type of presentation. + + virtual void LocalSelectionIn( SALOME_View*, const int ) const; + // Key method for double dispatch of activation of subshapes selection +}; + +//=========================================================== +/*! + * Class: SALOME_VTKPrs + * Description: Base class for VTK graphic object (vtkActor) wrappers + * This intermediate class is necessary to avoid dependencies from VTK libs. + */ +//=========================================================== + +class SALOME_VTKPrs : public SALOME_Prs +{ +public: + virtual void DisplayIn( SALOME_View* ) const; + // It uses double dispatch in order to + // invoke Display() method corresponding to the actual type of presentation. + + virtual void EraseIn( SALOME_View*, const bool = false ) const; + // It uses double dispatch in order to + // invoke Erase() method corresponding to the actual type of presentation. + + virtual void Update( SALOME_Displayer* ); + // It uses double dispatch in order to + // invoke Update() method corresponding to the actual type of presentation. + + virtual void LocalSelectionIn( SALOME_View*, const int ) const; + // Key method for double dispatch of activation of subshapes selection +}; + +//=========================================================== +/*! + * Class: SALOME_Prs2d + * Description: Base class for Plot2d graphic object (Plot2d_Curve) wrappers. + */ +//=========================================================== + +class SALOME_Prs2d : public SALOME_Prs +{ +public: + virtual void DisplayIn( SALOME_View* ) const; + // It uses double dispatch in order to + // invoke Display() method corresponding to the actual type of presentation. + + virtual void EraseIn( SALOME_View*, const bool = false ) const; + // It uses double dispatch in order to + // invoke Erase() method corresponding to the actual type of presentation. + + virtual void Update( SALOME_Displayer* ); + // It uses double dispatch in order to + // invoke Update() method corresponding to the actual type of presentation. + + virtual void LocalSelectionIn( SALOME_View*, const int ) const; + // Key method for double dispatch of activation of subshapes selection +}; + +///////////////////////////////////////////////////////////////////////// +// Base classes for object wrappers for any other visualization libraries +// should be added here! +///////////////////////////////////////////////////////////////////////// + +//=========================================================== +/*! + * Class: SALOME_View + * Description: Base class for SALOME views (or view frames) + */ +//=========================================================== + +class SALOME_View +{ +public: + virtual ~SALOME_View() {} + // Destructor + + void Display( const SALOME_Prs* ); + // This Display() method should be called to display given presentation + // created anywhere by anybody. It simply passes control to SALOME_Prs object + // so that it could perform double dispatch. + void Erase( const SALOME_Prs*, const bool = false ); + // This Erase() method should be called to erase given presentation + // created anywhere by anybody. It simply passes control to SALOME_Prs object + // so that it could perform double dispatch. + + void LocalSelection( const SALOME_Prs*, const int ); + // This LocalSelection() method should be called to activate sub-shapes selection + // created anywhere by anybody. It simply passes control to SALOME_Prs object + // so that it could perform double dispatch. + + // Interface for derived views + + // Display() methods for ALL kinds of presentation should appear here + virtual void Display( const SALOME_OCCPrs* ); + virtual void Display( const SALOME_VTKPrs* ); + virtual void Display( const SALOME_Prs2d* ); + // Add new Display() methods here... + + // Erase() methods for ALL kinds of presentation should appear here + virtual void Erase( const SALOME_OCCPrs*, const bool = false ); + virtual void Erase( const SALOME_VTKPrs*, const bool = false ); + virtual void Erase( const SALOME_Prs2d*, const bool = false ); + // Add new Erase() methods here... + + // LocalSelection() methods for ALL kinds of presentation should appear here + virtual void LocalSelection( const SALOME_OCCPrs*, const int ); + virtual void LocalSelection( const SALOME_VTKPrs*, const int ); + virtual void LocalSelection( const SALOME_Prs2d* , const int ); + + virtual void GlobalSelection( const bool = false ) const; + // Deactivates selection of sub-shapes (must be redefined with OCC viewer) + + // Creates empty presenation of corresponding type + virtual SALOME_Prs* CreatePrs( const char* entry = 0 ) { return 0; } + + // Axiluary methods called before and after displaying of objects + virtual void BeforeDisplay( SALOME_Displayer* d ) {} + virtual void AfterDisplay ( SALOME_Displayer* d ) {} +}; + +//=========================================================== +/*! + * Classes: SALOME_Displayer + * Description: These classes are used to specify type of view + * VTK, OCC or Plot2d + */ +//=========================================================== + +class SALOME_OCCViewType {}; +class SALOME_VTKViewType {}; +class SALOME_Plot2dViewType {}; + +//=========================================================== +/*! + * Class: SALOME_Displayer + * Description: Base class for SALOME displayers + */ +//=========================================================== + +class SALOME_Displayer +{ +public: + virtual ~SALOME_Displayer() {} + // Destructor + + void UpdatePrs( SALOME_Prs* ); + // This Update() method should be called to update given presentation + // created anywhere by anybody. It simply passes control to SALOME_Prs object + // so that it could perform double dispatch. + + // Interface for derived displayers + + // Update() methods for ALL kinds of presentation should appear here + virtual void Update( SALOME_OCCPrs* ); + virtual void Update( SALOME_VTKPrs* ); + virtual void Update( SALOME_Prs2d* ); + // Add new Update() methods here... + + // Axiluary methods called before and after displaying of objects + virtual void BeforeDisplay( SALOME_View*, const SALOME_OCCViewType& ) {}; + virtual void AfterDisplay ( SALOME_View*, const SALOME_OCCViewType& ) {}; + virtual void BeforeDisplay( SALOME_View*, const SALOME_VTKViewType& ) {}; + virtual void AfterDisplay ( SALOME_View*, const SALOME_VTKViewType& ) {}; + virtual void BeforeDisplay( SALOME_View*, const SALOME_Plot2dViewType& ) {}; + virtual void AfterDisplay ( SALOME_View*, const SALOME_Plot2dViewType& ) {}; +}; + +#endif + 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_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_SignalsHandler.cxx b/src/Session/SALOME_Session_SignalsHandler.cxx new file mode 100644 index 000000000..c02f6132a --- /dev/null +++ b/src/Session/SALOME_Session_SignalsHandler.cxx @@ -0,0 +1,38 @@ +// 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 + + +#include +#include + +#include "CASCatch_SignalsHandler.h" // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + + +extern "C" int HandleSignals(QApplication *theQApplication) +{ + CASCatch_SignalsHandler aSignalsHandler; + int aRet = -1; + try { + aRet = theQApplication->exec(); + }catch(Standard_Failure){ + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + throw std::runtime_error(aFail->GetMessageString()); + } + return aRet; +} 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_SignalsHandler.cxx b/src/Utils/Utils_SignalsHandler.cxx new file mode 100644 index 000000000..d72879e4b --- /dev/null +++ b/src/Utils/Utils_SignalsHandler.cxx @@ -0,0 +1,119 @@ +// KERNEL Utils : common utils for KERNEL +// Copyright (C) 2003 CEA +// +// 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.salome-platform.org or email : webmaster.salome@opencascade.org + + +#include +#include +#include + +#include "Utils_SignalsHandler.h" + + +//============================================================================ +//function : Handler +//purpose : univisal handler for signals +//============================================================================ +static void Handler(int theSigId) +{ + char aMessage[256] = ""; + sprintf(aMessage,"Signal with ID = %d was cautch!",theSigId); + throw std::runtime_error(aMessage); +} + + +//======================================================================= +//function : SetSigHandler +//purpose : Redefine signal handlers. If the handler of the signal is +// set as SIG_IGN. That's why the shells often ignore some +// signal when starting child processes. We keep it. +//======================================================================= +static void SetSignalHandler(Utils_SignalsHandler::TSigHandlerCont& theSigHandlerCont, + int theSigId) +{ + TSigHandler anOldHandler = signal(theSigId,&Handler); + if(anOldHandler == SIG_IGN) + signal(theSigId,SIG_IGN); + theSigHandlerCont[theSigId] = anOldHandler; +} + +static TSigHandler StoreSignalHandler(Utils_SignalsHandler::TSigHandlerCont& theSigHandlerCont, + int theSigId) +{ + TSigHandler anOldHandler = signal(theSigId,&Handler); + signal(theSigId,anOldHandler); + if(anOldHandler == SIG_IGN) + signal(theSigId,SIG_IGN); + theSigHandlerCont[theSigId] = anOldHandler; + return anOldHandler; +} + +static void RestoreSigHandler(TSigHandler theSigHandler, + int theSigId) +{ + signal(theSigId,theSigHandler); +} + + +//======================================================================= +//function : Utils_SignalsHandler +//purpose : Constructor +//======================================================================= +Utils_SignalsHandler::Utils_SignalsHandler() +{ + StoreSignalHandler(mySigHandlerCont,SIGHUP); // floating point exception + StoreSignalHandler(mySigHandlerCont,SIGFPE); // floating point exception + + StoreSignalHandler(mySigHandlerCont,SIGINT); // interrupt + StoreSignalHandler(mySigHandlerCont,SIGQUIT); // quit + StoreSignalHandler(mySigHandlerCont,SIGBUS); // bus error + StoreSignalHandler(mySigHandlerCont,SIGILL); // illegal instruction + StoreSignalHandler(mySigHandlerCont,SIGTERM); // termination + StoreSignalHandler(mySigHandlerCont,SIGSEGV); // segmentation + //StoreSignalHandler(mySigHandlerCont,SIGABRT); // abort (ANSI). + StoreSignalHandler(mySigHandlerCont,SIGSTKFLT); // stack fault. +} + + +//======================================================================= +//function : Utils_SignalsHandler +//purpose : destructor +//======================================================================= +Utils_SignalsHandler::~Utils_SignalsHandler() +{ + TSigHandlerCont::iterator anIter = mySigHandlerCont.begin(); + TSigHandlerCont::iterator anIterEnd = mySigHandlerCont.end(); + for(; anIter != anIterEnd; anIter++) + RestoreSigHandler(anIter->second,anIter->first); +} + + +//======================================================================= +//function : SetSigHandler +//purpose : sets new handler for pointed signal +//======================================================================= +TSigHandler Utils_SignalsHandler::SetSigHandler(int theSigId, + TSigHandler theSigHandler) +{ + TSigHandler anOldHandler = signal(theSigId,theSigHandler); + if(anOldHandler == SIG_IGN) + signal(theSigId,SIG_IGN); + mySigHandlerCont[theSigId] = anOldHandler; + return anOldHandler; +} diff --git a/src/Utils/Utils_SignalsHandler.h b/src/Utils/Utils_SignalsHandler.h new file mode 100644 index 000000000..475dcf18e --- /dev/null +++ b/src/Utils/Utils_SignalsHandler.h @@ -0,0 +1,49 @@ +// KERNEL Utils : common utils for KERNEL +// Copyright (C) 2003 CEA +// +// 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.salome-platform.org or email : webmaster.salome@opencascade.org + +#ifndef _UTILS_SIGNALSHANDLER_H_ +#define _UTILS_SIGNALSHANDLER_H_ + + +#include +typedef void (*TSigHandler)(int); + + +class Utils_SignalsHandler{ + public: + Utils_SignalsHandler(); + ~Utils_SignalsHandler(); + + TSigHandler GetSigHandler(int theSigId); + TSigHandler SetSigHandler(int theSigId, TSigHandler theSigHandler); + typedef std::map TSigHandlerCont; + + private: + TSigHandlerCont mySigHandlerCont; +}; + + +class Utils_CASSignalsHandler: private Utils_SignalsHandler{ + public: + Utils_CASSignalsHandler(); +}; + + +#endif 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/VTKFilter/SALOME_ShrinkFilter.cxx b/src/VTKFilter/SALOME_ShrinkFilter.cxx new file mode 100644 index 000000000..1ea45c86f --- /dev/null +++ b/src/VTKFilter/SALOME_ShrinkFilter.cxx @@ -0,0 +1,176 @@ +// SALOME OBJECT : kernel of SALOME component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SALOME_GeometryFilter.cxx +// Author : Michael ZORIN +// Module : SALOME +// $Header$ + +#include "SALOME_ShrinkFilter.h" + +#include +#include +#include +#include +#include +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +static int MYDEBUGWITHFILES = 0; +#else +static int MYDEBUG = 0; +static int MYDEBUGWITHFILES = 0; +#endif + +vtkCxxRevisionMacro(SALOME_ShrinkFilter, "$Revision$"); +vtkStandardNewMacro(SALOME_ShrinkFilter); + + +SALOME_ShrinkFilter::SALOME_ShrinkFilter(): + myStoreMapping(0) +{} + + +SALOME_ShrinkFilter::~SALOME_ShrinkFilter() +{} + + +void SALOME_ShrinkFilter::Execute() +{ + vtkPoints *newPts; + int i, j, numIds, abort=0; + vtkIdType cellId, numCells, numPts; + vtkIdType oldId, newId; + float center[3], *p, pt[3]; + vtkPointData *pd, *outPD;; + vtkIdList *ptIds, *newPtIds; + vtkDataSet *input= this->GetInput(); + vtkUnstructuredGrid *output = this->GetOutput(); + vtkIdType tenth; + float decimal; + + vtkDebugMacro(<<"Shrinking cells"); + + numCells=input->GetNumberOfCells(); + numPts = input->GetNumberOfPoints(); + if (numCells < 1 || numPts < 1) + { + vtkErrorMacro(<<"No data to shrink!"); + return; + } + + ptIds = vtkIdList::New(); + ptIds->Allocate(VTK_CELL_SIZE); + newPtIds = vtkIdList::New(); + newPtIds->Allocate(VTK_CELL_SIZE); + + output->Allocate(numCells); + newPts = vtkPoints::New(); + newPts->Allocate(numPts*8,numPts); + pd = input->GetPointData(); + outPD = output->GetPointData(); + outPD->CopyAllocate(pd,numPts*8,numPts); + + // Traverse all cells, obtaining node coordinates. Compute "center" of cell, + // then create new vertices shrunk towards center. + // + tenth = numCells/10 + 1; + decimal = 0.0; + if(myStoreMapping){ + myVTK2ObjIds.clear(); + myVTK2ObjIds.reserve(numCells); + } + + for (cellId=0; cellId < numCells && !abort; cellId++) + { + input->GetCellPoints(cellId, ptIds); + numIds = ptIds->GetNumberOfIds(); + + //abort/progress methods + if (cellId % tenth == 0) + { + decimal += 0.1; + this->UpdateProgress (decimal); + abort = this->GetAbortExecute(); + } + + // get the center of the cell + center[0] = center[1] = center[2] = 0.0; + for (i=0; i < numIds; i++) + { + p = input->GetPoint(ptIds->GetId(i)); + for (j=0; j < 3; j++) + { + center[j] += p[j]; + } + } + for (j=0; j<3; j++) + { + center[j] /= numIds; + } + + // Create new points and cells + newPtIds->Reset(); + for (i=0; i < numIds; i++) + { + p = input->GetPoint(ptIds->GetId(i)); + for (j=0; j < 3; j++) + { + pt[j] = center[j] + this->ShrinkFactor*(p[j] - center[j]); + } + + oldId = ptIds->GetId(i); + newId = newPts->InsertNextPoint(pt); + if(myStoreMapping) + myVTK2ObjIds.push_back(oldId); + newPtIds->InsertId(i,newId); + + outPD->CopyData(pd, oldId, newId); + } + output->InsertNextCell(input->GetCellType(cellId), newPtIds); + }//for all cells + + // Update ourselves and release memory + // + output->GetCellData()->PassData(input->GetCellData()); + + output->SetPoints(newPts); + output->Squeeze(); + + ptIds->Delete(); + newPtIds->Delete(); + newPts->Delete(); +} + + +void SALOME_ShrinkFilter::SetStoreMapping(int theStoreMapping){ + myStoreMapping = theStoreMapping; + this->Modified(); +} + + +vtkIdType SALOME_ShrinkFilter::GetNodeObjId(int theVtkID){ + if(myVTK2ObjIds.empty() || theVtkID > myVTK2ObjIds.size()) return -1; + return myVTK2ObjIds[theVtkID]; +} diff --git a/src/VTKFilter/SALOME_ShrinkFilter.h b/src/VTKFilter/SALOME_ShrinkFilter.h new file mode 100644 index 000000000..837b93978 --- /dev/null +++ b/src/VTKFilter/SALOME_ShrinkFilter.h @@ -0,0 +1,61 @@ +// SALOME OBJECT : kernel of SALOME component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SALOME_GeometryFilter.h +// Author : Michael ZORIN +// Module : SALOME +// $Header$ + + +#ifndef __SALOME_ShrinkFilter_h +#define __SALOME_ShrinkFilter_h + +#include +#include + +class SALOME_ShrinkFilter : public vtkShrinkFilter +{ +public: + static SALOME_ShrinkFilter *New(); + vtkTypeRevisionMacro(SALOME_ShrinkFilter, vtkShrinkFilter); + + void SetStoreMapping(int theStoreMapping); + int GetStoreMapping(){ return myStoreMapping;} + + virtual vtkIdType GetNodeObjId(int theVtkID); + virtual vtkIdType GetElemObjId(int theVtkID) { return theVtkID;} + +protected: + SALOME_ShrinkFilter(); + ~SALOME_ShrinkFilter(); + + void Execute(); + void UnstructuredGridExecute(); + +private: + int myStoreMapping; + typedef std::vector TVectorId; + TVectorId myVTK2ObjIds; +}; + +#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_Actor.cxx b/src/VTKViewer/VTKViewer_Actor.cxx new file mode 100644 index 000000000..eb8cd140f --- /dev/null +++ b/src/VTKViewer/VTKViewer_Actor.cxx @@ -0,0 +1,233 @@ +// 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 + +#include "VTKViewer_Actor.h" + +#include "SALOME_PassThroughFilter.h" + +// VTK Includes +#include +#include +#include +#include + +#include +#include +#include + +#include "utilities.h" + +using namespace std; + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + + +static void CopyPoints(vtkUnstructuredGrid* theGrid, vtkDataSet *theSourceDataSet){ + vtkPoints *aPoints = vtkPoints::New(); + vtkIdType iEnd = theSourceDataSet->GetNumberOfPoints(); + aPoints->SetNumberOfPoints(iEnd); + for(vtkIdType i = 0; i < iEnd; i++){ + aPoints->SetPoint(i,theSourceDataSet->GetPoint(i)); + } + theGrid->SetPoints(aPoints); + aPoints->Delete(); +} + + +//======================================================================= + +vtkStandardNewMacro(VTKViewer_Actor); + +VTKViewer_Actor::VTKViewer_Actor() +{ + myRenderer = NULL; + myIsInfinite = true; + + Visibility = Pickable = false; + + myUnstructuredGrid = vtkUnstructuredGrid::New(); + myUnstructuredGrid->Allocate(); + + myIsShrunk = false; + myIsShrinkable = true; + myShrinkFilter = vtkShrinkFilter::New(); + + myMapper = vtkDataSetMapper::New(); + + myMapper->SetInput(myUnstructuredGrid); + Superclass::InitPipeLine(myMapper); + + SetResolveCoincidentTopology(false); +} + + +void VTKViewer_Actor::SetShrinkFactor(float theValue){ + myShrinkFilter->SetShrinkFactor(theValue); + Modified(); +} + + +void VTKViewer_Actor::SetShrink() +{ + if ( !myIsShrinkable ) return; + if ( vtkDataSet* aDataSet = myPassFilter[0]->GetOutput() ) + { + myShrinkFilter->SetInput( aDataSet ); + myPassFilter[1]->SetInput( myShrinkFilter->GetOutput() ); + myIsShrunk = true; + } +} + +void VTKViewer_Actor::UnShrink() +{ + if ( !myIsShrunk ) return; + if ( vtkDataSet* aDataSet = myPassFilter[0]->GetOutput() ) + { + myPassFilter[1]->SetInput( aDataSet ); + myPassFilter[1]->Modified(); + myIsShrunk = false; + Modified(); + } +} + + +//---------------------------------------------------------------------------- +VTKViewer_Actor::~VTKViewer_Actor() +{ + if(MYDEBUG) INFOS("VTKViewer_Actor::~VTKViewer_Actor()"); + + myMapper->RemoveAllInputs(); + myMapper->Delete(); + + myShrinkFilter->UnRegisterAllOutputs(); + myShrinkFilter->Delete(); + + myUnstructuredGrid->Delete(); +} + + +//---------------------------------------------------------------------------- +void VTKViewer_Actor::MapCells(SALOME_Actor* theMapActor, + const TColStd_IndexedMapOfInteger& theMapIndex) +{ + myUnstructuredGrid->Reset(); + + vtkDataSet *aSourceDataSet = theMapActor->GetInput(); + CopyPoints(myUnstructuredGrid,aSourceDataSet); + + int aNbOfParts = theMapIndex.Extent(); + for(int ind = 1; ind <= aNbOfParts; ind++){ + int aPartId = theMapIndex( ind ); + vtkCell* aCell = theMapActor->GetElemCell(aPartId); + myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds()); + //for (int i = 0, iEnd = aCell->GetNumberOfEdges(); i < iEnd; i++){ + // vtkCell* anEdgeCell = aCell->GetEdge(i); + // myUnstructuredGrid->InsertNextCell(VTK_LINE,anEdgeCell->GetPointIds()); + //} + } + + UnShrink(); + if(theMapActor->IsShrunk()){ + SetShrinkFactor(theMapActor->GetShrinkFactor()); + SetShrink(); + } +} + + +//---------------------------------------------------------------------------- +void VTKViewer_Actor::MapPoints(SALOME_Actor* theMapActor, + const TColStd_IndexedMapOfInteger& theMapIndex) +{ + myUnstructuredGrid->Reset(); + if(int aNbOfParts = theMapIndex.Extent()){ + vtkPoints *aPoints = vtkPoints::New(); + aPoints->SetNumberOfPoints(aNbOfParts); + for(int i = 0; i < aNbOfParts; i++){ + int aPartId = theMapIndex( i+1 ); + float* aCoord = theMapActor->GetNodeCoord(aPartId); + aPoints->SetPoint(i,aCoord); + myUnstructuredGrid->InsertNextCell(VTK_VERTEX,1,&i); + } + myUnstructuredGrid->SetPoints(aPoints); + aPoints->Delete(); + } + + UnShrink(); +} + + +//---------------------------------------------------------------------------- +void VTKViewer_Actor::MapEdge(SALOME_Actor* theMapActor, + const TColStd_IndexedMapOfInteger& theMapIndex) +{ + myUnstructuredGrid->Reset(); + + vtkDataSet *aSourceDataSet = theMapActor->GetInput(); + CopyPoints(myUnstructuredGrid,aSourceDataSet); + + int iEnd = theMapIndex.Extent(); + int aCellId = -1, aCellCounter = 0; + for(int i = 1; i <= iEnd; i++){ + int anId = theMapIndex( i ); + if(anId > 0) { + aCellCounter++; + aCellId = anId; + } + } + + if(aCellCounter == 1){ + vtkCell* aCell = theMapActor->GetElemCell(aCellId); + if(aCell->GetCellType() <= VTK_LINE){ + myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds()); + }else{ + int aNbOfParts = aCell->GetNumberOfEdges(); + for(int i = 1; i <= iEnd; i++){ + int aPartId = theMapIndex(i); + if( aPartId < 0){ + aPartId = -aPartId-1; + if(0 > aPartId || aPartId >= aNbOfParts) break; + vtkCell* anEdgeCell = aCell->GetEdge(aPartId); + myUnstructuredGrid->InsertNextCell(VTK_LINE,anEdgeCell->GetPointIds()); + } + } + } + }else{ + int aNbOfParts = aSourceDataSet->GetNumberOfCells(); + for(int i = 1; i <= iEnd; i++){ + int aPartId = theMapIndex( i ); + if(aPartId > 0){ + if(aPartId >= aNbOfParts) break; + vtkCell* aCell = aSourceDataSet->GetCell(aPartId); + myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds()); + } + } + } + + UnShrink(); + if(theMapActor->IsShrunk()){ + SetShrinkFactor(theMapActor->GetShrinkFactor()); + SetShrink(); + } +} + +//---------------------------------------------------------------------------- diff --git a/src/VTKViewer/VTKViewer_Actor.h b/src/VTKViewer/VTKViewer_Actor.h new file mode 100644 index 000000000..a708aa63e --- /dev/null +++ b/src/VTKViewer/VTKViewer_Actor.h @@ -0,0 +1,64 @@ +// 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 + +#ifndef VTKVIEWER_ACTOR_H +#define VTKVIEWER_ACTOR_H + +#include + +class vtkRenderer; +class vtkShrinkFilter; +class vtkDataSetMapper; +class vtkUnstructuredGrid; + +#include "SALOME_Actor.h" + +class VTKViewer_Actor : public SALOME_Actor { + public: + vtkTypeMacro(VTKViewer_Actor,SALOME_Actor); + static VTKViewer_Actor* New(); + virtual ~VTKViewer_Actor(); + + void SetShrinkFactor(float value); + virtual void SetShrink(); + virtual void UnShrink(); + + void MapCells(SALOME_Actor* theMapActor, + const TColStd_IndexedMapOfInteger& theMapIndex); + + void MapPoints(SALOME_Actor* theMapActor, + const TColStd_IndexedMapOfInteger& theMapIndex); + + void MapEdge(SALOME_Actor* theMapActor, + const TColStd_IndexedMapOfInteger& theMapIndex); + + protected: + vtkUnstructuredGrid* myUnstructuredGrid; + vtkDataSetMapper* myMapper; + + vtkRenderer* myRenderer; + + vtkShrinkFilter* myShrinkFilter; + bool myIsShrinkable; + bool myIsShrunk; + + VTKViewer_Actor(); +}; + +#endif diff --git a/src/VTKViewer/VTKViewer_Algorithm.h b/src/VTKViewer/VTKViewer_Algorithm.h new file mode 100644 index 000000000..cd38a862d --- /dev/null +++ b/src/VTKViewer/VTKViewer_Algorithm.h @@ -0,0 +1,83 @@ +// SALOME VTKViewer : build VTK viewer into Salome desktop +// +// 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 : VTKViewer_ViewFrame.h +// Author : Nicolas REJNERI +// Module : SALOME +// $Header$ + +#ifndef VTKViewer_Algorithm_H +#define VTKViewer_Algorithm_H + +class vtkActor; +class vtkActorCollection; + +namespace SALOME{ + namespace VTK{ + + template + TFunction ForEach(vtkActorCollection *theCollection, TFunction theFun) + { + if(theCollection){ + theCollection->InitTraversal(); + while(vtkActor *anAct = theCollection->GetNextActor()) + if(TActor *anActor = dynamic_cast(anAct)) + theFun(anActor); + } + return theFun; + } + + + template + TFunction ForEachIf(vtkActorCollection *theCollection, + TPredicate thePredicate, + TFunction theFun) + { + if(theCollection){ + theCollection->InitTraversal(); + while(vtkActor *anAct = theCollection->GetNextActor()) + if(TActor *anActor = dynamic_cast(anAct)) + if(thePredicate(anActor)) + theFun(anActor); + } + return theFun; + } + + + template + TActor* Find(vtkActorCollection *theCollection, TPredicate thePredicate) + { + if(theCollection){ + theCollection->InitTraversal(); + while(vtkActor *anAct = theCollection->GetNextActor()) + if(TActor *anActor = dynamic_cast(anAct)) + if(thePredicate(anActor)) + return anActor; + } + return NULL; + } + + } +} + +#endif 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_Functor.h b/src/VTKViewer/VTKViewer_Functor.h new file mode 100644 index 000000000..825f855cb --- /dev/null +++ b/src/VTKViewer/VTKViewer_Functor.h @@ -0,0 +1,98 @@ +// SALOME VTKViewer : build VTK viewer into Salome desktop +// +// 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 : VTKViewer_ViewFrame.h +// Author : Nicolas REJNERI +// Module : SALOME +// $Header$ + +#ifndef VTKViewer_Functor_H +#define VTKViewer_Functor_H + +#include + +#include +#include "SALOME_InteractiveObject.hxx" + +namespace SALOME{ + namespace VTK{ + + + template struct TIsSameEntry + { + std::string myEntry; + TIsSameEntry(const char* theEntry): myEntry(theEntry){} + bool operator()(TActor* theActor){ + if(theActor->hasIO()){ + Handle(SALOME_InteractiveObject) anIO = theActor->getIO(); + if(anIO->hasEntry()) + return myEntry == anIO->getEntry(); + } + return false; + } + }; + + + template struct TIsSameIObject + { + Handle(SALOME_InteractiveObject) myIObject; + TIsSameIObject(const Handle(SALOME_InteractiveObject)& theIObject): + myIObject(theIObject) + {} + bool operator()(TActor* theActor){ + if(theActor->hasIO()){ + Handle(SALOME_InteractiveObject) anIO = theActor->getIO(); + return myIObject->isSame(anIO); + } + return false; + } + }; + + + template struct TSetFunction + { + typedef void (TActor::* TAction)(TArg); + TAction myAction; + TStoreArg myArg; + TSetFunction(TAction theAction, TArg theArg): + myAction(theAction), myArg(theArg) + {} + void operator()(TActor* theActor){ + (theActor->*myAction)(myArg); + } + }; + + + template struct TSetVisibility: TSetFunction + { + TSetVisibility(TArg theArg): + TSetFunction(&TActor::SetVisibility,theArg) + {} + }; + + + } +} + + +#endif 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_Prs.cxx b/src/VTKViewer/VTKViewer_Prs.cxx new file mode 100644 index 000000000..4d048c609 --- /dev/null +++ b/src/VTKViewer/VTKViewer_Prs.cxx @@ -0,0 +1,97 @@ +// SALOME VTKViewer : build VTK viewer into Salome desktop +// +// Copyright (C) 2004 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.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : VTKViewer_Prs.cxx +// Author : Sergey ANIKIN +// Module : SALOME +// $Header$ + +#include "VTKViewer_Prs.h" + +//========================================================== +/*! + * VTKViewer_Prs::VTKViewer_Prs + * Default constructor + */ +//========================================================== +VTKViewer_Prs::VTKViewer_Prs() : myObjects( 0 ) +{ +} + +//========================================================== +/*! + * VTKViewer_Prs::VTKViewer_Prs + * tandard constructora + */ +//========================================================== +VTKViewer_Prs::VTKViewer_Prs( const vtkActor* obj ) +{ + AddObject( obj ); +} + +//========================================================== +/*! + * VTKViewer_Prs::~VTKViewer_Prs + * Destructor + */ +//========================================================== +VTKViewer_Prs:: ~VTKViewer_Prs() +{ + if ( myObjects ) myObjects->Delete(); +} + +//========================================================== +/*! + * VTKViewer_Prs::GetObjects + * Get actors list + */ +//========================================================== +vtkActorCollection* VTKViewer_Prs::GetObjects() const +{ + return myObjects; +} + +//========================================================== +/*! + * VTKViewer_Prs::AddObject + * Add actor + */ +//========================================================== +void VTKViewer_Prs::AddObject( const vtkActor* obj ) +{ + if ( !myObjects) + myObjects = vtkActorCollection::New(); + myObjects->AddItem( (vtkActor*)obj ); +} + +//========================================================== +/*! + * VTKViewer_Prs::IsNull + * Return 0 if list of the actors is empty + * [ Reimplemented from SALOME_Prs ] + */ +//========================================================== +bool VTKViewer_Prs::IsNull() const +{ + return !myObjects || myObjects->GetNumberOfItems() <= 0; +} diff --git a/src/VTKViewer/VTKViewer_Prs.h b/src/VTKViewer/VTKViewer_Prs.h new file mode 100644 index 000000000..6e61c0abe --- /dev/null +++ b/src/VTKViewer/VTKViewer_Prs.h @@ -0,0 +1,58 @@ +// SALOME VTKViewer : build VTK viewer into Salome desktop +// +// Copyright (C) 2004 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.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : VTKViewer_Prs.h +// Author : Sergey ANIKIN +// Module : SALOME +// $Header$ + +#ifndef VTKVIEWER_PRS_H +#define VTKVIEWER_PRS_H + +#include "SALOME_Prs.h" + +#include + +class VTKViewer_Prs : public SALOME_VTKPrs +{ +public: + VTKViewer_Prs(); + // Default constructor + VTKViewer_Prs( const vtkActor* obj ); + // Standard constructor + ~VTKViewer_Prs(); + // Destructor + + vtkActorCollection* GetObjects() const; + // Get actors list + void AddObject( const vtkActor* obj ); + // Add actor + + bool IsNull() const; + // Reimplemented from SALOME_Prs + +private: + vtkActorCollection* myObjects; // list of actors +}; + +#endif 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